connect

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BCClient

type BCClient struct {
	AuthToken  string
	AuthClient string
	StoreKey   string
	BaseURL    string
	Limit      int
}

BCClient represents the client wrapper containing BC specific connection details

func NewClient

func NewClient(authToken, authClient, storeKey string) *BCClient

NewClient create a new client wrapper based on BC connection details, default result limit is set to 50

func (*BCClient) BuildUrlRequest added in v0.3.4

func (s *BCClient) BuildUrlRequest(endpoint string) (req *http.Request, err error)

BuildUrl - gets the golang request out of the endpoint (e.g. /v2/orders/) needed for sending to the BC api

func (*BCClient) DoRequest

func (s *BCClient) DoRequest(req *http.Request) ([]byte, error)

DoRequest will call out to bigcommerce API for the passed in request, this is mostly used internal to the package but can be used to expand on the library

func (*BCClient) GetAndUnmarshal added in v0.3.4

func (s *BCClient) GetAndUnmarshal(endpoint string, outData interface{}) error

GetAndUnmarshal - gets the request body of a plain url and unmarshals to passed in struct pointer

Example of the endpoint parameter would be "/v2/orders/" and the client will handle the store key and base url pieces

func (*BCClient) GetAndUnmarshalRaw added in v0.5.0

func (s *BCClient) GetAndUnmarshalRaw(fullEndpoint string, outData interface{}) error

GetAndUnmarshalRaw - gets the request body of a full plain bigcommerce url and unmarshals to passed in struct pointer

Example of the fullEndpoint parameter would be "https://api.bigcommerce.com/stores/{{YOUR-STORE-KEY}}/v2/orders/12039/products" the client will not manipulate the endpoint in any way. This function is used by things like Resource.EagerGet

func (*BCClient) GetAndUnmarshalWithQuery added in v0.3.4

func (s *BCClient) GetAndUnmarshalWithQuery(endpoint string, rawQuery string, outData interface{}) error

GetAndUnmarshalWithQuery - gets the request body of the url with a query string added on and unmarshals to passed in struct pointer

Example of the endpoint parameter would be "/v2/orders/count/" and the client will handle the store key and base url pieces

func (*BCClient) GetBody

func (s *BCClient) GetBody(url string) (body []byte, err error)

GetBody - gets the request body of the url

func (*BCClient) SetBaseURL

func (s *BCClient) SetBaseURL(url string)

SetBaseURL will override the default (https://api.bigcommerce.com/stores/) base url of the client to the string passed in

type Client added in v0.5.0

type Client interface {
	SetBaseURL(url string)
	DoRequest(req *http.Request) ([]byte, error)
	GetBody(url string) (body []byte, err error)
	BuildUrlRequest(endpoint string) (req *http.Request, err error)
	GetAndUnmarshal(endpoint string, outData interface{}) error
	GetAndUnmarshalRaw(fullEndpoint string, outData interface{}) error
	GetAndUnmarshalWithQuery(endpoint string, rawQuery string, outData interface{}) error
}

Jump to

Keyboard shortcuts

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