Documentation
¶
Index ¶
- func Bool(value bool) param.Field[bool]
- func F[T any](value T) param.Field[T]
- func FileParam(reader io.Reader, filename string, contentType string) param.Field[io.Reader]
- func Float(value float64) param.Field[float64]
- func Int(value int64) param.Field[int64]
- func Null[T any]() param.Field[T]
- func Raw[T any](value any) param.Field[T]
- func String(value string) param.Field[string]
- type Address
- type AddressParam
- type Card
- type CardExpiration
- type CardListResponse
- type CardService
- type Cart
- type CartItem
- type CartListResponse
- type CartService
- func (r *CartService) List(ctx context.Context, opts ...option.RequestOption) (res *CartListResponse, err error)
- func (r *CartService) SetCard(ctx context.Context, body CartSetCardParams, opts ...option.RequestOption) (res *CartSetCardResponse, err error)
- func (r *CartService) SetItem(ctx context.Context, body CartSetItemParams, opts ...option.RequestOption) (res *CartSetItemResponse, err error)
- func (r *CartService) SetShipping(ctx context.Context, body CartSetShippingParams, opts ...option.RequestOption) (res *CartSetShippingResponse, err error)
- type CartSetCardParams
- type CartSetCardResponse
- type CartSetCardResponseResult
- type CartSetItemParams
- type CartSetItemResponse
- type CartSetItemResponseResult
- type CartSetShippingParams
- type CartSetShippingResponse
- type CartSetShippingResponseResult
- type Client
- func (r *Client) Delete(ctx context.Context, path string, params interface{}, res interface{}, ...) error
- func (r *Client) Execute(ctx context.Context, method string, path string, params interface{}, ...) error
- func (r *Client) Get(ctx context.Context, path string, params interface{}, res interface{}, ...) error
- func (r *Client) Patch(ctx context.Context, path string, params interface{}, res interface{}, ...) error
- func (r *Client) Post(ctx context.Context, path string, params interface{}, res interface{}, ...) error
- func (r *Client) Put(ctx context.Context, path string, params interface{}, res interface{}, ...) error
- type Error
- type Product
- type ProductListResponse
- type ProductService
- type ProductVariant
- type User
- type UserMeResponse
- type UserService
- type UserShippingDeleteResponse
- type UserShippingDeleteResponseResult
- type UserShippingListResponse
- type UserShippingListResponseResult
- type UserShippingNewParams
- type UserShippingNewResponse
- type UserShippingNewResponseResult
- type UserShippingService
- func (r *UserShippingService) Delete(ctx context.Context, id string, opts ...option.RequestOption) (res *UserShippingDeleteResponse, err error)
- func (r *UserShippingService) List(ctx context.Context, opts ...option.RequestOption) (res *UserShippingListResponse, err error)
- func (r *UserShippingService) New(ctx context.Context, body UserShippingNewParams, opts ...option.RequestOption) (res *UserShippingNewResponse, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func F ¶
F is a param field helper used to initialize a param.Field generic struct. This helps specify null, zero values, and overrides, as well as normal values. You can read more about this in our README.
func Int ¶
Int is a param field helper which helps specify integers. This is particularly helpful when specifying integer constants for fields.
func Raw ¶
Raw is a param field helper for specifying values for fields when the type you are looking to send is different from the type that is specified in the SDK. For example, if the type of the field is an integer, but you want to send a float, you could do that by setting the corresponding field with Raw[int](0.5).
Types ¶
type CardExpiration ¶
type CardExpiration = shared.CardExpiration
This is an alias to an internal type.
type CardListResponse ¶
type CardListResponse struct {
Result []shared.Card `json:"result,required"`
JSON cardListResponseJSON `json:"-"`
}
func (*CardListResponse) UnmarshalJSON ¶
func (r *CardListResponse) UnmarshalJSON(data []byte) (err error)
type CardService ¶
type CardService struct {
Options []option.RequestOption
}
CardService contains methods and other services that help with interacting with the terminal API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewCardService method instead.
func NewCardService ¶
func NewCardService(opts ...option.RequestOption) (r *CardService)
NewCardService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*CardService) List ¶
func (r *CardService) List(ctx context.Context, opts ...option.RequestOption) (res *CardListResponse, err error)
type CartListResponse ¶
type CartListResponse struct {
Result shared.Cart `json:"result,required"`
JSON cartListResponseJSON `json:"-"`
}
func (*CartListResponse) UnmarshalJSON ¶
func (r *CartListResponse) UnmarshalJSON(data []byte) (err error)
type CartService ¶
type CartService struct {
Options []option.RequestOption
}
CartService contains methods and other services that help with interacting with the terminal API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewCartService method instead.
func NewCartService ¶
func NewCartService(opts ...option.RequestOption) (r *CartService)
NewCartService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*CartService) List ¶
func (r *CartService) List(ctx context.Context, opts ...option.RequestOption) (res *CartListResponse, err error)
func (*CartService) SetCard ¶
func (r *CartService) SetCard(ctx context.Context, body CartSetCardParams, opts ...option.RequestOption) (res *CartSetCardResponse, err error)
func (*CartService) SetItem ¶
func (r *CartService) SetItem(ctx context.Context, body CartSetItemParams, opts ...option.RequestOption) (res *CartSetItemResponse, err error)
func (*CartService) SetShipping ¶
func (r *CartService) SetShipping(ctx context.Context, body CartSetShippingParams, opts ...option.RequestOption) (res *CartSetShippingResponse, err error)
type CartSetCardParams ¶
func (CartSetCardParams) MarshalJSON ¶
func (r CartSetCardParams) MarshalJSON() (data []byte, err error)
type CartSetCardResponse ¶
type CartSetCardResponse struct {
Result CartSetCardResponseResult `json:"result,required"`
JSON cartSetCardResponseJSON `json:"-"`
}
func (*CartSetCardResponse) UnmarshalJSON ¶
func (r *CartSetCardResponse) UnmarshalJSON(data []byte) (err error)
type CartSetCardResponseResult ¶
type CartSetCardResponseResult string
const (
CartSetCardResponseResultOk CartSetCardResponseResult = "ok"
)
func (CartSetCardResponseResult) IsKnown ¶
func (r CartSetCardResponseResult) IsKnown() bool
type CartSetItemParams ¶
type CartSetItemParams struct {
ProductVariantID param.Field[string] `json:"productVariantID,required"`
Quantity param.Field[int64] `json:"quantity,required"`
}
func (CartSetItemParams) MarshalJSON ¶
func (r CartSetItemParams) MarshalJSON() (data []byte, err error)
type CartSetItemResponse ¶
type CartSetItemResponse struct {
Result []CartSetItemResponseResult `json:"result,required"`
JSON cartSetItemResponseJSON `json:"-"`
}
func (*CartSetItemResponse) UnmarshalJSON ¶
func (r *CartSetItemResponse) UnmarshalJSON(data []byte) (err error)
type CartSetItemResponseResult ¶
type CartSetItemResponseResult struct {
ID string `json:"id,required"`
ProductVariantID string `json:"productVariantID,required"`
Quantity int64 `json:"quantity,required"`
Subtotal float64 `json:"subtotal,required"`
JSON cartSetItemResponseResultJSON `json:"-"`
}
func (*CartSetItemResponseResult) UnmarshalJSON ¶
func (r *CartSetItemResponseResult) UnmarshalJSON(data []byte) (err error)
type CartSetShippingParams ¶
func (CartSetShippingParams) MarshalJSON ¶
func (r CartSetShippingParams) MarshalJSON() (data []byte, err error)
type CartSetShippingResponse ¶
type CartSetShippingResponse struct {
Result CartSetShippingResponseResult `json:"result,required"`
JSON cartSetShippingResponseJSON `json:"-"`
}
func (*CartSetShippingResponse) UnmarshalJSON ¶
func (r *CartSetShippingResponse) UnmarshalJSON(data []byte) (err error)
type CartSetShippingResponseResult ¶
type CartSetShippingResponseResult string
const (
CartSetShippingResponseResultOk CartSetShippingResponseResult = "ok"
)
func (CartSetShippingResponseResult) IsKnown ¶
func (r CartSetShippingResponseResult) IsKnown() bool
type Client ¶
type Client struct {
Options []option.RequestOption
Product *ProductService
User *UserService
Card *CardService
Cart *CartService
}
Client creates a struct with services and top level methods that help with interacting with the terminal API. You should not instantiate this client directly, and instead use the NewClient method instead.
func NewClient ¶
func NewClient(opts ...option.RequestOption) (r *Client)
NewClient generates a new client with the default option read from the environment (TERMINAL_BEARER_TOKEN). The option passed in as arguments are applied after these default arguments, and all option will be passed down to the services and requests that this client makes.
func (*Client) Delete ¶
func (r *Client) Delete(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error
Delete makes a DELETE request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) Execute ¶
func (r *Client) Execute(ctx context.Context, method string, path string, params interface{}, res interface{}, opts ...option.RequestOption) error
Execute makes a request with the given context, method, URL, request params, response, and request options. This is useful for hitting undocumented endpoints while retaining the base URL, auth, retries, and other options from the client.
If a byte slice or an io.Reader is supplied to params, it will be used as-is for the request body.
The params is by default serialized into the body using encoding/json. If your type implements a MarshalJSON function, it will be used instead to serialize the request. If a URLQuery method is implemented, the returned [url.Values] will be used as query strings to the url.
If your params struct uses param.Field, you must provide either [MarshalJSON], [URLQuery], and/or [MarshalForm] functions. It is undefined behavior to use a struct uses param.Field without specifying how it is serialized.
Any "…Params" object defined in this library can be used as the request argument. Note that 'path' arguments will not be forwarded into the url.
The response body will be deserialized into the res variable, depending on its type:
- A pointer to a *http.Response is populated by the raw response.
- A pointer to a byte array will be populated with the contents of the request body.
- A pointer to any other type uses this library's default JSON decoding, which respects UnmarshalJSON if it is defined on the type.
- A nil value will not read the response body.
For even greater flexibility, see option.WithResponseInto and option.WithResponseBodyInto.
func (*Client) Get ¶
func (r *Client) Get(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error
Get makes a GET request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) Patch ¶
func (r *Client) Patch(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error
Patch makes a PATCH request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) Post ¶
func (r *Client) Post(ctx context.Context, path string, params interface{}, res interface{}, opts ...option.RequestOption) error
Post makes a POST request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
type ProductListResponse ¶
type ProductListResponse struct {
Result []shared.Product `json:"result,required"`
JSON productListResponseJSON `json:"-"`
}
func (*ProductListResponse) UnmarshalJSON ¶
func (r *ProductListResponse) UnmarshalJSON(data []byte) (err error)
type ProductService ¶
type ProductService struct {
Options []option.RequestOption
}
ProductService contains methods and other services that help with interacting with the terminal API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewProductService method instead.
func NewProductService ¶
func NewProductService(opts ...option.RequestOption) (r *ProductService)
NewProductService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*ProductService) List ¶
func (r *ProductService) List(ctx context.Context, opts ...option.RequestOption) (res *ProductListResponse, err error)
type ProductVariant ¶
type ProductVariant = shared.ProductVariant
This is an alias to an internal type.
type UserMeResponse ¶
type UserMeResponse struct {
Result shared.User `json:"result,required"`
JSON userMeResponseJSON `json:"-"`
}
func (*UserMeResponse) UnmarshalJSON ¶
func (r *UserMeResponse) UnmarshalJSON(data []byte) (err error)
type UserService ¶
type UserService struct {
Options []option.RequestOption
Shipping *UserShippingService
}
UserService contains methods and other services that help with interacting with the terminal API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewUserService method instead.
func NewUserService ¶
func NewUserService(opts ...option.RequestOption) (r *UserService)
NewUserService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*UserService) Me ¶
func (r *UserService) Me(ctx context.Context, opts ...option.RequestOption) (res *UserMeResponse, err error)
type UserShippingDeleteResponse ¶
type UserShippingDeleteResponse struct {
Result []UserShippingDeleteResponseResult `json:"result,required"`
JSON userShippingDeleteResponseJSON `json:"-"`
}
func (*UserShippingDeleteResponse) UnmarshalJSON ¶
func (r *UserShippingDeleteResponse) UnmarshalJSON(data []byte) (err error)
type UserShippingDeleteResponseResult ¶
type UserShippingDeleteResponseResult struct {
ID string `json:"id,required"`
Address shared.Address `json:"address,required"`
JSON userShippingDeleteResponseResultJSON `json:"-"`
}
func (*UserShippingDeleteResponseResult) UnmarshalJSON ¶
func (r *UserShippingDeleteResponseResult) UnmarshalJSON(data []byte) (err error)
type UserShippingListResponse ¶
type UserShippingListResponse struct {
Result []UserShippingListResponseResult `json:"result,required"`
JSON userShippingListResponseJSON `json:"-"`
}
func (*UserShippingListResponse) UnmarshalJSON ¶
func (r *UserShippingListResponse) UnmarshalJSON(data []byte) (err error)
type UserShippingListResponseResult ¶
type UserShippingListResponseResult struct {
ID string `json:"id,required"`
Address shared.Address `json:"address,required"`
JSON userShippingListResponseResultJSON `json:"-"`
}
func (*UserShippingListResponseResult) UnmarshalJSON ¶
func (r *UserShippingListResponseResult) UnmarshalJSON(data []byte) (err error)
type UserShippingNewParams ¶
type UserShippingNewParams struct {
Address shared.AddressParam `json:"address,required"`
}
func (UserShippingNewParams) MarshalJSON ¶
func (r UserShippingNewParams) MarshalJSON() (data []byte, err error)
type UserShippingNewResponse ¶
type UserShippingNewResponse struct {
Result []UserShippingNewResponseResult `json:"result,required"`
JSON userShippingNewResponseJSON `json:"-"`
}
func (*UserShippingNewResponse) UnmarshalJSON ¶
func (r *UserShippingNewResponse) UnmarshalJSON(data []byte) (err error)
type UserShippingNewResponseResult ¶
type UserShippingNewResponseResult struct {
ID string `json:"id,required"`
Address shared.Address `json:"address,required"`
JSON userShippingNewResponseResultJSON `json:"-"`
}
func (*UserShippingNewResponseResult) UnmarshalJSON ¶
func (r *UserShippingNewResponseResult) UnmarshalJSON(data []byte) (err error)
type UserShippingService ¶
type UserShippingService struct {
Options []option.RequestOption
}
UserShippingService contains methods and other services that help with interacting with the terminal API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewUserShippingService method instead.
func NewUserShippingService ¶
func NewUserShippingService(opts ...option.RequestOption) (r *UserShippingService)
NewUserShippingService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*UserShippingService) Delete ¶
func (r *UserShippingService) Delete(ctx context.Context, id string, opts ...option.RequestOption) (res *UserShippingDeleteResponse, err error)
func (*UserShippingService) List ¶
func (r *UserShippingService) List(ctx context.Context, opts ...option.RequestOption) (res *UserShippingListResponse, err error)
func (*UserShippingService) New ¶
func (r *UserShippingService) New(ctx context.Context, body UserShippingNewParams, opts ...option.RequestOption) (res *UserShippingNewResponse, err error)