Skip to content

Commit

Permalink
Add missing ProductServiceFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
nozzlegear committed Dec 18, 2023
1 parent 99389e8 commit a4af82c
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions ShopifySharp/Factories/ProductServiceFactory.cs
Original file line number Diff line number Diff line change
@@ -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 <see cref="IProductService" /> 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>
IProductService Create(string shopDomain, string accessToken);

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

public class ProductServiceFactory(IRequestExecutionPolicy? requestExecutionPolicy = null) : IProductServiceFactory
{
/// <inheritDoc />
public virtual IProductService Create(string shopDomain, string accessToken)
{
var service = new ProductService(shopDomain, accessToken);

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

return service;
}

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

0 comments on commit a4af82c

Please sign in to comment.