Skip to content

Commit

Permalink
Add ShopPlanServiceFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
nozzlegear committed Jan 5, 2024
1 parent 3ea6461 commit 9d8805c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public static IServiceCollection AddShopifySharpServiceFactories(this IServiceCo
services.TryAddSingleton<IRefundServiceFactory, RefundServiceFactory>();
services.TryAddSingleton<IScriptTagServiceFactory, ScriptTagServiceFactory>();
services.TryAddSingleton<IShippingZoneServiceFactory, ShippingZoneServiceFactory>();
services.TryAddSingleton<IShopPlanServiceFactory, ShopPlanServiceFactory>();
services.TryAddSingleton<IShopServiceFactory, ShopServiceFactory>();
services.TryAddSingleton<IShopifyPaymentsServiceFactory, ShopifyPaymentsServiceFactory>();
services.TryAddSingleton<ISmartCollectionServiceFactory, SmartCollectionServiceFactory>();
Expand Down
41 changes: 41 additions & 0 deletions ShopifySharp/Factories/ShopPlanServiceFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#nullable enable
// Notice:
// This class is auto-generated from a template. Please do not edit it or change it directly.

using ShopifySharp.Credentials;
using ShopifySharp.Utilities;
using ShopifySharp.Services;

namespace ShopifySharp.Factories;

public interface IShopPlanServiceFactory
{
/// Creates a new instance of the <see cref="IShopPlanService" /> with the given credentials.
/// <param name="shopDomain">The shop's *.myshopify.com URL.</param>
/// <param name="accessToken">An API access token for the shop.</param>
IShopPlanService Create(string shopDomain, string accessToken);

/// Creates a new instance of the <see cref="IShopPlanService" /> with the given credentials.
/// <param name="credentials">Credentials for authenticating with the Shopify API.</param>
IShopPlanService Create(ShopifyApiCredentials credentials);
}

public class ShopPlanServiceFactory(IRequestExecutionPolicy? requestExecutionPolicy = null, IShopifyDomainUtility? shopifyDomainUtility = null) : IShopPlanServiceFactory
{
/// <inheritDoc />
public virtual IShopPlanService Create(string shopDomain, string accessToken)
{
IShopPlanService service = shopifyDomainUtility is null ? new ShopPlanService(shopDomain, accessToken) : new ShopPlanService(shopDomain, accessToken, shopifyDomainUtility);

if (requestExecutionPolicy is not null)
{
service.SetExecutionPolicy(requestExecutionPolicy);
}

return service;
}

/// <inheritDoc />
public virtual IShopPlanService Create(ShopifyApiCredentials credentials) =>
Create(credentials.ShopDomain, credentials.AccessToken);
}

0 comments on commit 9d8805c

Please sign in to comment.