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 CartListResponse
- type CartListResponseResult
- type CartListResponseResultItem
- type CartService
- type CartSetItemParams
- type CartSetItemResponse
- type CartSetItemResponseResult
- 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 ProductListResponse
- type ProductListResponseResult
- type ProductListResponseResultVariant
- type ProductService
- type User
- type UserMeResponse
- type UserService
- type UserShippingDeleteResponse
- type UserShippingDeleteResponseResult
- type UserShippingDeleteResponseResultAddress
- type UserShippingListResponse
- type UserShippingListResponseResult
- type UserShippingListResponseResultAddress
- type UserShippingNewParams
- type UserShippingNewResponse
- type UserShippingNewResponseResult
- type UserShippingNewResponseResultAddress
- 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 CartListResponse ¶
type CartListResponse struct {
Result CartListResponseResult `json:"result,required"`
JSON cartListResponseJSON `json:"-"`
}
func (*CartListResponse) UnmarshalJSON ¶
func (r *CartListResponse) UnmarshalJSON(data []byte) (err error)
type CartListResponseResult ¶
type CartListResponseResult struct {
Items []CartListResponseResultItem `json:"items,required"`
Subtotal int64 `json:"subtotal,required"`
CardID string `json:"cardID"`
ShippingID string `json:"shippingID"`
JSON cartListResponseResultJSON `json:"-"`
}
func (*CartListResponseResult) UnmarshalJSON ¶
func (r *CartListResponseResult) UnmarshalJSON(data []byte) (err error)
type CartListResponseResultItem ¶
type CartListResponseResultItem struct {
ID string `json:"id,required"`
ProductVariantID string `json:"productVariantID,required"`
Quantity int64 `json:"quantity,required"`
Subtotal float64 `json:"subtotal,required"`
JSON cartListResponseResultItemJSON `json:"-"`
}
func (*CartListResponseResultItem) UnmarshalJSON ¶
func (r *CartListResponseResultItem) 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) SetItem ¶
func (r *CartService) SetItem(ctx context.Context, body CartSetItemParams, opts ...option.RequestOption) (res *CartSetItemResponse, err error)
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 Client ¶
type Client struct {
Options []option.RequestOption
Product *ProductService
User *UserService
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 []ProductListResponseResult `json:"result,required"`
JSON productListResponseJSON `json:"-"`
}
func (*ProductListResponse) UnmarshalJSON ¶
func (r *ProductListResponse) UnmarshalJSON(data []byte) (err error)
type ProductListResponseResult ¶
type ProductListResponseResult struct {
ID string `json:"id,required"`
Description string `json:"description,required"`
Name string `json:"name,required"`
Variants []ProductListResponseResultVariant `json:"variants,required"`
JSON productListResponseResultJSON `json:"-"`
}
func (*ProductListResponseResult) UnmarshalJSON ¶
func (r *ProductListResponseResult) UnmarshalJSON(data []byte) (err error)
type ProductListResponseResultVariant ¶
type ProductListResponseResultVariant struct {
ID string `json:"id,required"`
Name string `json:"name,required"`
Price int64 `json:"price,required"`
JSON productListResponseResultVariantJSON `json:"-"`
}
func (*ProductListResponseResultVariant) UnmarshalJSON ¶
func (r *ProductListResponseResultVariant) 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 User ¶
type User struct {
ID string `json:"id,required"`
Email string `json:"email,required,nullable"`
Fingerprint string `json:"fingerprint,required,nullable"`
StripeCustomerID string `json:"stripeCustomerID,required"`
JSON userJSON `json:"-"`
}
func (*User) UnmarshalJSON ¶
type UserMeResponse ¶
type UserMeResponse struct {
Result 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 UserShippingDeleteResponseResultAddress `json:"address,required"`
JSON userShippingDeleteResponseResultJSON `json:"-"`
}
func (*UserShippingDeleteResponseResult) UnmarshalJSON ¶
func (r *UserShippingDeleteResponseResult) UnmarshalJSON(data []byte) (err error)
type UserShippingDeleteResponseResultAddress ¶
type UserShippingDeleteResponseResultAddress struct {
City string `json:"city,required"`
Country string `json:"country,required"`
Name string `json:"name,required"`
Province string `json:"province,required"`
Street1 string `json:"street1,required"`
Zip string `json:"zip,required"`
Street2 string `json:"street2"`
JSON userShippingDeleteResponseResultAddressJSON `json:"-"`
}
func (*UserShippingDeleteResponseResultAddress) UnmarshalJSON ¶
func (r *UserShippingDeleteResponseResultAddress) 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 UserShippingListResponseResultAddress `json:"address,required"`
JSON userShippingListResponseResultJSON `json:"-"`
}
func (*UserShippingListResponseResult) UnmarshalJSON ¶
func (r *UserShippingListResponseResult) UnmarshalJSON(data []byte) (err error)
type UserShippingListResponseResultAddress ¶
type UserShippingListResponseResultAddress struct {
City string `json:"city,required"`
Country string `json:"country,required"`
Name string `json:"name,required"`
Province string `json:"province,required"`
Street1 string `json:"street1,required"`
Zip string `json:"zip,required"`
Street2 string `json:"street2"`
JSON userShippingListResponseResultAddressJSON `json:"-"`
}
func (*UserShippingListResponseResultAddress) UnmarshalJSON ¶
func (r *UserShippingListResponseResultAddress) UnmarshalJSON(data []byte) (err error)
type UserShippingNewParams ¶
type UserShippingNewParams struct {
City param.Field[string] `json:"city,required"`
Country param.Field[string] `json:"country,required"`
Name param.Field[string] `json:"name,required"`
Province param.Field[string] `json:"province,required"`
Street1 param.Field[string] `json:"street1,required"`
Zip param.Field[string] `json:"zip,required"`
Street2 param.Field[string] `json:"street2"`
}
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 UserShippingNewResponseResultAddress `json:"address,required"`
JSON userShippingNewResponseResultJSON `json:"-"`
}
func (*UserShippingNewResponseResult) UnmarshalJSON ¶
func (r *UserShippingNewResponseResult) UnmarshalJSON(data []byte) (err error)
type UserShippingNewResponseResultAddress ¶
type UserShippingNewResponseResultAddress struct {
City string `json:"city,required"`
Country string `json:"country,required"`
Name string `json:"name,required"`
Province string `json:"province,required"`
Street1 string `json:"street1,required"`
Zip string `json:"zip,required"`
Street2 string `json:"street2"`
JSON userShippingNewResponseResultAddressJSON `json:"-"`
}
func (*UserShippingNewResponseResultAddress) UnmarshalJSON ¶
func (r *UserShippingNewResponseResultAddress) 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)