diff --git a/ShopifySharp/Factories/ProductServiceFactory.cs b/ShopifySharp/Factories/ProductServiceFactory.cs new file mode 100644 index 00000000..efb90ed2 --- /dev/null +++ b/ShopifySharp/Factories/ProductServiceFactory.cs @@ -0,0 +1,39 @@ +#nullable enable +// Notice: +// This class is auto-generated from a template. Please do not edit it or change it directly. + +using ShopifySharp.Credentials; + +namespace ShopifySharp.Factories; + +public interface IProductServiceFactory +{ + /// Creates a new instance of the with the given credentials. + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + IProductService Create(string shopDomain, string accessToken); + + /// Creates a new instance of the with the given credentials. + /// Credentials for authenticating with the Shopify API. + IProductService Create(ShopifyApiCredentials credentials); +} + +public class ProductServiceFactory(IRequestExecutionPolicy? requestExecutionPolicy = null) : IProductServiceFactory +{ + /// + public virtual IProductService Create(string shopDomain, string accessToken) + { + var service = new ProductService(shopDomain, accessToken); + + if (requestExecutionPolicy is not null) + { + service.SetExecutionPolicy(requestExecutionPolicy); + } + + return service; + } + + /// + public virtual IProductService Create(ShopifyApiCredentials credentials) => + Create(credentials.ShopDomain, credentials.AccessToken); +}