generated from Kentico/repo-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from Kentico/feat/update-user-redirection
Feat/update user redirection
- Loading branch information
Showing
4 changed files
with
104 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 36 additions & 43 deletions
79
src/Kentico.Xperience.Shopify/Orders/ShopifyOrderService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,36 @@ | ||
using Kentico.Xperience.Shopify.Config; | ||
using Kentico.Xperience.Shopify.Products; | ||
|
||
using ShopifySharp; | ||
using ShopifySharp.Factories; | ||
using ShopifySharp.Filters; | ||
|
||
namespace Kentico.Xperience.Shopify.Orders | ||
{ | ||
internal class ShopifyOrderService : ShopifyServiceBase, IShopifyOrderService | ||
{ | ||
private const string ORDERS_FIELDS = "customer,source_identifier,name,order_status_url,id,line_items,total_price_set,presentment_currency"; | ||
|
||
private readonly IOrderService orderService; | ||
|
||
public ShopifyOrderService( | ||
IOrderServiceFactory orderServiceFactory, | ||
IShopifyIntegrationSettingsService integrationSettingsService) : base(integrationSettingsService) | ||
{ | ||
orderService = orderServiceFactory.Create(shopifyCredentials); | ||
} | ||
|
||
|
||
/// <inheritdoc/> | ||
public async Task<Order?> GetRecentOrder(string sourceId) | ||
{ | ||
if (string.IsNullOrEmpty(sourceId)) | ||
{ | ||
return null; | ||
} | ||
|
||
var filter = new OrderListFilter() | ||
{ | ||
CreatedAtMin = DateTime.Now.AddDays(-1).Date, | ||
Fields = ORDERS_FIELDS | ||
}; | ||
|
||
var result = await orderService.ListAsync(filter); | ||
|
||
return result.Items.FirstOrDefault(x => x.SourceIdentifier.Equals(sourceId, StringComparison.Ordinal)); | ||
} | ||
} | ||
} | ||
using Kentico.Xperience.Shopify.Config; | ||
using Kentico.Xperience.Shopify.Products; | ||
|
||
using ShopifySharp; | ||
using ShopifySharp.Factories; | ||
|
||
namespace Kentico.Xperience.Shopify.Orders | ||
{ | ||
internal class ShopifyOrderService : ShopifyServiceBase, IShopifyOrderService | ||
{ | ||
private const string ORDER_FIELDS = "customer,source_identifier,name,order_status_url,id,line_items,total_price_set,presentment_currency"; | ||
|
||
private readonly IOrderService orderService; | ||
|
||
public ShopifyOrderService( | ||
IOrderServiceFactory orderServiceFactory, | ||
IShopifyIntegrationSettingsService integrationSettingsService) : base(integrationSettingsService) | ||
{ | ||
orderService = orderServiceFactory.Create(shopifyCredentials); | ||
} | ||
|
||
|
||
/// <inheritdoc/> | ||
public async Task<Order?> GetOrder(long orderId) | ||
{ | ||
if (orderId == 0) | ||
{ | ||
return null; | ||
} | ||
|
||
return await TryCatch<Order?>( | ||
async () => await orderService.GetAsync(orderId, ORDER_FIELDS), | ||
() => null); | ||
} | ||
} | ||
} |