nozzlegear / ShopifySharp

ShopifySharp is a .NET library that helps developers easily authenticate with and manage Shopify stores.
https://nozzlegear.com/shopify-development-handbook
MIT License
742 stars 309 forks source link

Support DiscountCodes lookup #605

Open KoanLeeroy opened 3 years ago

KoanLeeroy commented 3 years ago

Shopify supports a lookup of a discount code from the code: https://shopify.dev/docs/admin-api/rest/reference/discounts/discountcode#lookup-2020-10

Would be good to support this in this SDK.

KoanLeeroy commented 3 years ago

We did this ourselves, but would be great to get it baked in:

    public async Task<PriceRuleDiscountCode> LookupAsync(
        string discountCode,
        CancellationToken cancellationToken = default)
    {
        var uri = PrepareRequest("discount_codes/lookup.json");
        uri.QueryParams.Add("code", discountCode);

        var response = await ExecuteRequestAsync<PriceRuleDiscountCode>(uri, HttpMethod.Get, cancellationToken);
        return response.Result;
    }
nozzlegear commented 3 years ago

Thanks for the link! I didn't know they had added this feature, I'd be happy to add it to the package.