common

package
v0.0.0-...-a563c19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeaderContentType         = "Content-Type"
	ApplicationJSON           = "application/json"
	HeaderAccept              = "Accept"
	HeaderXShopifyAccessToken = "X-Shopify-Access-Token"
)

Variables

This section is empty.

Functions

func DefaultHTTPClient

func DefaultHTTPClient() *http.Client

func Int64Str

func Int64Str(v int64) string

Int64Str use to convert int64 to string it is more efficient than we do fmt.Sprintf("%d",v)

func MakeRequest

func MakeRequest(ctx context.Context, baseURL url.URL, method, path string, params interface{}, options ...Option) (req *http.Request, err error)

MakeRequest construct the http request for api call

func Send

func Send(ctx context.Context, sender Sender, method, path string, req, resp interface{}, authSetter AuthSetter) (err error)

Send use to send HTTP request to shopify

func ShopBaseUrl

func ShopBaseUrl(name string) string

ShopBaseUrl return the Shop's base url.

func ShopDomain

func ShopDomain(name string) string

ShopDomain input shop name and get the shopDomain like <shop>.myshopify.com

func ShopShortName

func ShopShortName(name string) string

ShopShortName return the short shop name without .myshopify.com

Types

type AuthSetter

type AuthSetter func(r *http.Request)

type Call

type Call func(ctx context.Context, method, path string, req, resp interface{}) (err error)

type Credentials

type Credentials struct {
	Password  string
	APIKey    string
	APISecret string
}

type Endpoint

type Endpoint struct {
	Path   string
	Method string
}

type Option

type Option func(r *http.Request)

func WithAdminAuthHeader

func WithAdminAuthHeader(token string) Option

WithAdminAuthHeader optionally sets the api-version if the passed string is valid

func WithCredentials

func WithCredentials(credentials Credentials) Option

WithCredentials is a function to set shopify credentials

type Sender

type Sender interface {
	Call(ctx context.Context, method, path string, req, resp interface{}) (err error)
	Client() *http.Client
	ErrorDTO() error
	BaseURL() url.URL
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL