Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion shopify/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import (
type Config struct {
ShopifyDomain string
ShopifyAccessToken string
ShopifyApiVersion string
}

func (c *Config) NewClient() *shopify.Client {
return shopify.NewClient(c.ShopifyDomain, c.ShopifyAccessToken)
return shopify.NewClient(c.ShopifyDomain, c.ShopifyAccessToken, c.ShopifyApiVersion)
}
6 changes: 6 additions & 0 deletions shopify/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ func Provider() terraform.ResourceProvider {
DefaultFunc: schema.EnvDefaultFunc("SHOPIFY_ACCESS_TOKEN", nil),
Description: "Shopify access token",
},
"api_version": &schema.Schema{
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("SHOPIFY_API_VERSION", nil),
Description: "Shopify API version",
},
},

ResourcesMap: map[string]*schema.Resource{
Expand Down
4 changes: 2 additions & 2 deletions shopify/shopify-go/shopify-go.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ type Client struct {
Webhooks *WebhookService
}

func NewClient(shopifyDomain string, shopifyAccessToken string) *Client {
func NewClient(shopifyDomain string, shopifyAccessToken string, shopifyApiVersion string) *Client {
base := sling.New().Base("https://"+shopifyDomain).Set("Content-Type", "application/json").Set("X-Shopify-Access-Token", shopifyAccessToken)

return &Client{
sling: base,
Webhooks: newWebhookService(base.New()),
Webhooks: newWebhookService(base.New(), shopifyApiVersion),
}
}
7 changes: 4 additions & 3 deletions shopify/shopify-go/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ package shopifygo
import (
"encoding/json"
"fmt"
"github.com/dghubble/sling"
"net/http"
"net/url"

"github.com/dghubble/sling"
)

type WebhookService struct {
sling *sling.Sling
}

func newWebhookService(sling *sling.Sling) *WebhookService {
func newWebhookService(sling *sling.Sling, shopifyApiVersion string) *WebhookService {
return &WebhookService{
sling: sling.New().Path("admin/"),
sling: sling.New().Path("admin/api/" + shopifyApiVersion + "/"),
}
}

Expand Down