forked from getconversio/go-shopify
-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa02f85
commit 5b6f777
Showing
3 changed files
with
176 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package goshopify | ||
|
||
import "fmt" | ||
|
||
// Option is used to configure client with options | ||
type Option func(c *Client) | ||
|
||
// WithVersion optionally sets the api-version if the passed string is valid | ||
func WithVersion(apiVersion string) Option { | ||
return func(c *Client) { | ||
pathPrefix := defaultApiPathPrefix | ||
if len(apiVersion) > 0 && apiVersionRegex.MatchString(apiVersion) { | ||
pathPrefix = fmt.Sprintf("admin/api/%s", apiVersion) | ||
} | ||
c.apiVersion = apiVersion | ||
c.pathPrefix = pathPrefix | ||
} | ||
} | ||
|
||
func WithRetry(retries int) Option { | ||
return func(c *Client) { | ||
c.retries = retries | ||
} | ||
} |