diff --git a/Apps.Magento/Polling/ProductPollingList.cs b/Apps.Magento/Polling/ProductPollingList.cs index 41ddc49..2c32aee 100644 --- a/Apps.Magento/Polling/ProductPollingList.cs +++ b/Apps.Magento/Polling/ProductPollingList.cs @@ -48,58 +48,37 @@ public async Task> OnProducts PollingEventRequest request, [PollingEventParameter] OnProductsUpdatedRequest filterRequest) { - try + if (request.Memory is null) { - if (request.Memory is null) - { - return new() - { - FlyBird = false, - Memory = new() - { - LastInteractionDate = DateTime.UtcNow - } - }; - } - - var products = await GetProducts(new BaseFilterRequest - { UpdatedAt = request.Memory.LastInteractionDate, Title = filterRequest.Title }); - var items = products.Items.Where(x => x.CreatedAt != x.UpdatedAt).ToList(); - - await WebhookLogger.LogAsync(new - { - ItemsBeforeWhere = products.Items, - itemsAfterWhere = items, - }); - return new() { - FlyBird = products.Items.Any(), - Result = products, + FlyBird = false, Memory = new() { LastInteractionDate = DateTime.UtcNow } }; } - catch (Exception e) + + var products = await GetProducts(new BaseFilterRequest + { UpdatedAt = request.Memory.LastInteractionDate, Title = filterRequest.Title }); + products.Items = products.Items.Where(x => x.CreatedAt != x.UpdatedAt).ToList(); + + return new() { - await WebhookLogger.LogAsync(e); - throw; - } + FlyBird = products.Items.Any(), + Result = products, + Memory = new() + { + LastInteractionDate = DateTime.UtcNow + } + }; } private async Task GetProducts(BaseFilterRequest request) { var queryString = BuildQueryString(request); var requestUrl = $"/rest/V1/products?searchCriteria{queryString}"; - await WebhookLogger.LogAsync(new - { - queryString, - requestUrl, - request - }); - return await Client.ExecuteWithErrorHandling(new ApiRequest(requestUrl, Method.Get, Creds)); } diff --git a/Apps.Magento/WebhookLogger.cs b/Apps.Magento/WebhookLogger.cs deleted file mode 100644 index 1b43b30..0000000 --- a/Apps.Magento/WebhookLogger.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Blackbird.Applications.Sdk.Utils.Extensions.Http; -using RestSharp; - -namespace Apps.Magento; - -public static class WebhookLogger -{ - private const string WebhookUrl = "https://webhook.site/10569094-e5ef-4839-9e81-42fd4ecccde9"; - - public static async Task LogAsync(T obj) where T : class - { - var restClient = new RestClient(WebhookUrl); - var restRequest = new RestRequest(string.Empty, Method.Post) - .WithJsonBody(obj); - - await restClient.ExecuteAsync(restRequest); - } - - public static void Log(T obj) where T : class - { - LogAsync(obj).Wait(); - } - - public static async Task LogAsync(Exception exception) - { - await LogAsync(new - { - Exception = exception.Message, - exception.StackTrace, - InnerException = exception.InnerException?.Message, - ExceptionType = exception.GetType().Name - }); - } -} \ No newline at end of file