Skip to content

Commit

Permalink
Removed webhook logger
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalii-bezuhlyi committed Nov 19, 2024
1 parent 90592cd commit 3585814
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 70 deletions.
51 changes: 15 additions & 36 deletions Apps.Magento/Polling/ProductPollingList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,58 +48,37 @@ public async Task<PollingEventResponse<DateMemory, ProductsResponse>> OnProducts
PollingEventRequest<DateMemory> 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<ProductsResponse> 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<ProductsResponse>(new ApiRequest(requestUrl, Method.Get, Creds));
}

Expand Down
34 changes: 0 additions & 34 deletions Apps.Magento/WebhookLogger.cs

This file was deleted.

0 comments on commit 3585814

Please sign in to comment.