diff --git a/goshopify.go b/goshopify.go index e25d809a..e741091d 100644 --- a/goshopify.go +++ b/goshopify.go @@ -22,6 +22,8 @@ import ( const ( UserAgent = "goshopify/1.0.0" + // UnstableApiVersion Shopify API version for accessing unstable API features + UnstableApiVersion = "unstable" // Shopify API version YYYY-MM - defaults to admin which uses the oldest stable version of the api defaultApiPathPrefix = "admin" @@ -87,7 +89,7 @@ type Client struct { Customer CustomerService CustomerAddress CustomerAddressService Order OrderService - Fulfillment FulfillmentService + Fulfillment FulfillmentService DraftOrder DraftOrderService Shop ShopService Webhook WebhookService diff --git a/options.go b/options.go index c3016d40..7f8a75d1 100644 --- a/options.go +++ b/options.go @@ -9,7 +9,7 @@ type Option func(c *Client) func WithVersion(apiVersion string) Option { return func(c *Client) { pathPrefix := defaultApiPathPrefix - if len(apiVersion) > 0 && apiVersionRegex.MatchString(apiVersion) { + if len(apiVersion) > 0 && (apiVersionRegex.MatchString(apiVersion) || apiVersion == UnstableApiVersion) { pathPrefix = fmt.Sprintf("admin/api/%s", apiVersion) } c.apiVersion = apiVersion diff --git a/options_test.go b/options_test.go index 76dadca5..64e00e25 100644 --- a/options_test.go +++ b/options_test.go @@ -53,3 +53,11 @@ func TestWithLogger(t *testing.T) { t.Errorf("WithLogger expected logs to match %v != %v", c.log, logger) } } + +func TestWithUnstableVersion(t *testing.T) { + c := NewClient(app, "fooshop", "abcd", WithVersion(UnstableApiVersion)) + expected := fmt.Sprintf("admin/api/%s", UnstableApiVersion) + if c.pathPrefix != expected { + t.Errorf("WithVersion client.pathPrefix = %s, expected %s", c.pathPrefix, expected) + } +}