bold-commerce / go-shopify

Go client for the Shopify API
MIT License
330 stars 256 forks source link

Why does `StorefrontAccessTokenService` accept a `StorefrontAccessToken`? #281

Closed Nikola-Milovic closed 6 months ago

Nikola-Milovic commented 8 months ago

If I wanted to create a storefront access token, why do I have to pass in a StorefrontAccessToken?

type StorefrontAccessTokenService interface {
    List(context.Context, interface{}) ([]StorefrontAccessToken, error)
    Create(context.Context, StorefrontAccessToken) (*StorefrontAccessToken, error)
    Delete(context.Context, uint64) error
}

The api is

curl -d '{"storefront_access_token":{"title":"Test"}}' \
-X POST "https://your-development-store.myshopify.com/admin/api/2024-01/storefront_access_tokens.json" \
-H "X-Shopify-Access-Token: {access_token}" \
-H "Content-Type: application/json"

Seems that only the title is required?

oliver006 commented 7 months ago

You're right, that seems like a bug, thanks for reporting!

oliver006 commented 6 months ago

Just looked at this again and I think this is fine. See the docs here: https://shopify.dev/docs/api/admin-rest/2024-04/resources/storefrontaccesstoken#post-storefront-access-tokens Looks like only title is relevant but the whole storefrontaccesstoken object is passed. Let's leave this as is.