Skip to content

Commit

Permalink
updated go-sequence marketplace client
Browse files Browse the repository at this point in the history
  • Loading branch information
david-littlefarmer committed Jul 15, 2024
1 parent 983f72d commit 6ac8cac
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions marketplace/marketplace.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

type Options struct {
MarketplaceApiUrl string
MarketplaceAPIURL string
JWTAuthToken string
HTTPClient HTTPClient
}
Expand All @@ -21,21 +21,23 @@ func NewMarketplaceAdmin(projectAccessKey string, chainHandle string, options ..
client: opts.HTTPClient,
projectAccessKey: projectAccessKey,
}
if opts.HTTPClient == nil {

if client.client == nil {
client.client = http.DefaultClient
}

if opts.JWTAuthToken != "" {
client.jwtAuthHeader = fmt.Sprintf("BEARER %s", opts.JWTAuthToken)
}

// prod: https://marketplace-api.sequence.app
// dev: https://dev-marketplace-api.sequence.app
apiUrl := fmt.Sprintf("https://marketplace-api.sequence.app/%s", chainHandle)
if opts.MarketplaceApiUrl != "" {
apiUrl = opts.MarketplaceApiUrl + "/" + chainHandle
apiURL := fmt.Sprintf("https://marketplace-api.sequence.app/%s", chainHandle)
if opts.MarketplaceAPIURL != "" {
apiURL = opts.MarketplaceAPIURL + "/" + chainHandle
}

return NewAdminClient(apiUrl, client.client)
return NewAdminClient(apiURL, client)
}

type httpclient struct {
Expand All @@ -50,7 +52,7 @@ func (c *httpclient) Do(req *http.Request) (*http.Response, error) {
}

if c.jwtAuthHeader != "" {
req.Header.Set("Authorization", fmt.Sprintf("BEARER %s", c.jwtAuthHeader))
req.Header.Set("Authorization", c.jwtAuthHeader)
}

return c.client.Do(req)
Expand Down

0 comments on commit 6ac8cac

Please sign in to comment.