From 393bdb4be5172043fa4f2b9385e25e9c4d7d379f Mon Sep 17 00:00:00 2001 From: Pedro Costa <550684+pnmcosta@users.noreply.github.com> Date: Wed, 3 May 2023 17:37:36 +0100 Subject: [PATCH] added shopify shop admin endpoints --- endpoints/endpoints.go | 13 +++++++++++++ endpoints/endpoints_test.go | 25 +++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/endpoints/endpoints.go b/endpoints/endpoints.go index 7cc37c876..1ebae5317 100644 --- a/endpoints/endpoints.go +++ b/endpoints/endpoints.go @@ -254,3 +254,16 @@ func AWSCognito(domain string) oauth2.Endpoint { TokenURL: domain + "/oauth2/token", } } + +// Shopify returns a new oauth2.Endpoint for the supplied shop domain name +// +// Example domain: my-test-shop.myshopify.com +// +// For more information see: +// https://shopify.dev/docs/apps/auth/oauth +func Shopify(domain string) oauth2.Endpoint { + return oauth2.Endpoint{ + AuthURL: "https://" + domain + "/admin/oauth/authorize", + TokenURL: "https://" + domain + "/admin/oauth/access_token", + } +} diff --git a/endpoints/endpoints_test.go b/endpoints/endpoints_test.go index 4ffa31429..6574f3ba5 100644 --- a/endpoints/endpoints_test.go +++ b/endpoints/endpoints_test.go @@ -41,3 +41,28 @@ func TestAWSCognitoEndpoint(t *testing.T) { }) } } + +func TestShopifyEndpoint(t *testing.T) { + + var endpointTests = []struct { + in string + out oauth2.Endpoint + }{ + { + in: "my-test-shop.myshopify.com", + out: oauth2.Endpoint{ + AuthURL: "https://my-test-shop.myshopify.com/admin/oauth/authorize", + TokenURL: "https://my-test-shop.myshopify.com/admin/oauth/access_token", + }, + }, + } + + for _, tt := range endpointTests { + t.Run(tt.in, func(t *testing.T) { + endpoint := Shopify(tt.in) + if endpoint != tt.out { + t.Errorf("got %q, want %q", endpoint, tt.out) + } + }) + } +}