Documentation
¶
Index ¶
- func Bool(value bool) param.Field[bool]
- func DefaultClientOptions() []option.RequestOption
- 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 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 FuntoolService
- type FuntoolSetDarkmodeParams
- type FuntoolSetDarkmodeResponse
- type Product
- type ProductDeleteParams
- type ProductDeleteResponse
- type ProductGetParams
- type ProductListParams
- type ProductNewParams
- type ProductService
- func (r *ProductService) Delete(ctx context.Context, productID string, body ProductDeleteParams, ...) (res *ProductDeleteResponse, err error)
- func (r *ProductService) Get(ctx context.Context, productID string, query ProductGetParams, ...) (res *Product, err error)
- func (r *ProductService) List(ctx context.Context, params ProductListParams, opts ...option.RequestOption) (res *pagination.OffsetPagination[Product], err error)
- func (r *ProductService) ListAutoPaging(ctx context.Context, params ProductListParams, opts ...option.RequestOption) *pagination.OffsetPaginationAutoPager[Product]
- func (r *ProductService) New(ctx context.Context, params ProductNewParams, opts ...option.RequestOption) (res *Product, err error)
- func (r *ProductService) Update(ctx context.Context, productID string, params ProductUpdateParams, ...) (res *Product, err error)
- type ProductUpdateParams
- type ProductVariant
- type ProductVariantDeleteParams
- type ProductVariantDeleteResponse
- type ProductVariantGetParams
- type ProductVariantListParams
- type ProductVariantNewParams
- type ProductVariantService
- func (r *ProductVariantService) Delete(ctx context.Context, productID string, variantID string, ...) (res *ProductVariantDeleteResponse, err error)
- func (r *ProductVariantService) Get(ctx context.Context, productID string, variantID string, ...) (res *ProductVariant, err error)
- func (r *ProductVariantService) List(ctx context.Context, productID string, query ProductVariantListParams, ...) (res *[]ProductVariant, err error)
- func (r *ProductVariantService) New(ctx context.Context, productID string, params ProductVariantNewParams, ...) (res *ProductVariant, err error)
- func (r *ProductVariantService) Update(ctx context.Context, productID string, variantID string, ...) (res *ProductVariant, err error)
- type ProductVariantUpdateParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultClientOptions ¶ added in v0.3.0
func DefaultClientOptions() []option.RequestOption
DefaultClientOptions read from the environment (DEMOSTORE_API_KEY, DEMOSTORE_ORG_ID, STAINLESS_STORE_BASE_URL). This should be used to initialize new clients.
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 Client ¶
type Client struct {
Options []option.RequestOption
Funtools *FuntoolService
Products *ProductService
}
Client creates a struct with services and top level methods that help with interacting with the stainless store 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 (DEMOSTORE_API_KEY, DEMOSTORE_ORG_ID, STAINLESS_STORE_BASE_URL). 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 FuntoolService ¶ added in v0.4.0
type FuntoolService struct {
Options []option.RequestOption
}
FuntoolService contains methods and other services that help with interacting with the stainless store 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 NewFuntoolService method instead.
func NewFuntoolService ¶ added in v0.4.0
func NewFuntoolService(opts ...option.RequestOption) (r *FuntoolService)
NewFuntoolService 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 (*FuntoolService) SetDarkmode ¶ added in v0.4.0
func (r *FuntoolService) SetDarkmode(ctx context.Context, body FuntoolSetDarkmodeParams, opts ...option.RequestOption) (res *FuntoolSetDarkmodeResponse, err error)
Set Darkmode Value
type FuntoolSetDarkmodeParams ¶ added in v0.4.0
func (FuntoolSetDarkmodeParams) MarshalJSON ¶ added in v0.4.0
func (r FuntoolSetDarkmodeParams) MarshalJSON() (data []byte, err error)
type FuntoolSetDarkmodeResponse ¶ added in v0.4.0
type FuntoolSetDarkmodeResponse struct {
Success bool `json:"success,required"`
JSON funtoolSetDarkmodeResponseJSON `json:"-"`
}
func (*FuntoolSetDarkmodeResponse) UnmarshalJSON ¶ added in v0.4.0
func (r *FuntoolSetDarkmodeResponse) UnmarshalJSON(data []byte) (err error)
type Product ¶
type Product struct {
Description string `json:"description,required"`
ImageURL string `json:"image_url,required"`
Name string `json:"name,required"`
Price int64 `json:"price,required"`
ProductID string `json:"product_id,required"`
JSON productJSON `json:"-"`
}
Represents a Product record
func (*Product) UnmarshalJSON ¶
type ProductDeleteParams ¶ added in v0.4.0
type ProductDeleteResponse ¶
type ProductDeleteResponse struct {
Success bool `json:"success,required"`
JSON productDeleteResponseJSON `json:"-"`
}
func (*ProductDeleteResponse) UnmarshalJSON ¶
func (r *ProductDeleteResponse) UnmarshalJSON(data []byte) (err error)
type ProductGetParams ¶ added in v0.4.0
type ProductListParams ¶ added in v0.3.0
type ProductListParams struct {
// Use [option.WithOrgID] on the client to set a global default for this field.
OrgID param.Field[string] `path:"org_id,required"`
Limit param.Field[int64] `query:"limit"`
Skip param.Field[int64] `query:"skip"`
}
func (ProductListParams) URLQuery ¶ added in v0.3.0
func (r ProductListParams) URLQuery() (v url.Values)
URLQuery serializes ProductListParams's query parameters as `url.Values`.
type ProductNewParams ¶
type ProductNewParams struct {
// Use [option.WithOrgID] on the client to set a global default for this field.
OrgID param.Field[string] `path:"org_id,required"`
Description param.Field[string] `json:"description,required"`
ImageURL param.Field[string] `json:"image_url,required"`
Name param.Field[string] `json:"name,required"`
Price param.Field[int64] `json:"price,required"`
}
func (ProductNewParams) MarshalJSON ¶
func (r ProductNewParams) MarshalJSON() (data []byte, err error)
type ProductService ¶
type ProductService struct {
Options []option.RequestOption
Variants *ProductVariantService
}
ProductService contains methods and other services that help with interacting with the stainless store 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) Delete ¶
func (r *ProductService) Delete(ctx context.Context, productID string, body ProductDeleteParams, opts ...option.RequestOption) (res *ProductDeleteResponse, err error)
Delete Product
func (*ProductService) Get ¶
func (r *ProductService) Get(ctx context.Context, productID string, query ProductGetParams, opts ...option.RequestOption) (res *Product, err error)
Read Product
func (*ProductService) List ¶
func (r *ProductService) List(ctx context.Context, params ProductListParams, opts ...option.RequestOption) (res *pagination.OffsetPagination[Product], err error)
Read Products
func (*ProductService) ListAutoPaging ¶ added in v0.3.0
func (r *ProductService) ListAutoPaging(ctx context.Context, params ProductListParams, opts ...option.RequestOption) *pagination.OffsetPaginationAutoPager[Product]
Read Products
func (*ProductService) New ¶
func (r *ProductService) New(ctx context.Context, params ProductNewParams, opts ...option.RequestOption) (res *Product, err error)
Create Product
func (*ProductService) Update ¶
func (r *ProductService) Update(ctx context.Context, productID string, params ProductUpdateParams, opts ...option.RequestOption) (res *Product, err error)
Update Product
type ProductUpdateParams ¶
type ProductUpdateParams struct {
// Use [option.WithOrgID] on the client to set a global default for this field.
OrgID param.Field[string] `path:"org_id,required"`
Description param.Field[string] `json:"description,required"`
ImageURL param.Field[string] `json:"image_url,required"`
Name param.Field[string] `json:"name,required"`
Price param.Field[int64] `json:"price,required"`
}
func (ProductUpdateParams) MarshalJSON ¶
func (r ProductUpdateParams) MarshalJSON() (data []byte, err error)
type ProductVariant ¶
type ProductVariant struct {
ImageURL string `json:"image_url,required"`
Name string `json:"name,required"`
Price int64 `json:"price,required"`
ProductID string `json:"product_id,required"`
VariantID string `json:"variant_id,required"`
JSON productVariantJSON `json:"-"`
}
Represents a ProductVariant record
func (*ProductVariant) UnmarshalJSON ¶
func (r *ProductVariant) UnmarshalJSON(data []byte) (err error)
type ProductVariantDeleteParams ¶ added in v0.4.0
type ProductVariantDeleteResponse ¶
type ProductVariantDeleteResponse struct {
Success bool `json:"success,required"`
JSON productVariantDeleteResponseJSON `json:"-"`
}
func (*ProductVariantDeleteResponse) UnmarshalJSON ¶
func (r *ProductVariantDeleteResponse) UnmarshalJSON(data []byte) (err error)
type ProductVariantGetParams ¶ added in v0.4.0
type ProductVariantListParams ¶ added in v0.4.0
type ProductVariantNewParams ¶
type ProductVariantNewParams struct {
// Use [option.WithOrgID] on the client to set a global default for this field.
OrgID param.Field[string] `path:"org_id,required"`
ImageURL param.Field[string] `json:"image_url,required"`
Name param.Field[string] `json:"name,required"`
Price param.Field[int64] `json:"price,required"`
}
func (ProductVariantNewParams) MarshalJSON ¶
func (r ProductVariantNewParams) MarshalJSON() (data []byte, err error)
type ProductVariantService ¶
type ProductVariantService struct {
Options []option.RequestOption
}
ProductVariantService contains methods and other services that help with interacting with the stainless store 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 NewProductVariantService method instead.
func NewProductVariantService ¶
func NewProductVariantService(opts ...option.RequestOption) (r *ProductVariantService)
NewProductVariantService 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 (*ProductVariantService) Delete ¶
func (r *ProductVariantService) Delete(ctx context.Context, productID string, variantID string, body ProductVariantDeleteParams, opts ...option.RequestOption) (res *ProductVariantDeleteResponse, err error)
Delete Product Variant
func (*ProductVariantService) Get ¶
func (r *ProductVariantService) Get(ctx context.Context, productID string, variantID string, query ProductVariantGetParams, opts ...option.RequestOption) (res *ProductVariant, err error)
Read Product Variant
func (*ProductVariantService) List ¶
func (r *ProductVariantService) List(ctx context.Context, productID string, query ProductVariantListParams, opts ...option.RequestOption) (res *[]ProductVariant, err error)
Read Product Variants
func (*ProductVariantService) New ¶
func (r *ProductVariantService) New(ctx context.Context, productID string, params ProductVariantNewParams, opts ...option.RequestOption) (res *ProductVariant, err error)
Create Product Variant
func (*ProductVariantService) Update ¶
func (r *ProductVariantService) Update(ctx context.Context, productID string, variantID string, params ProductVariantUpdateParams, opts ...option.RequestOption) (res *ProductVariant, err error)
Update Product Variant
type ProductVariantUpdateParams ¶
type ProductVariantUpdateParams struct {
// Use [option.WithOrgID] on the client to set a global default for this field.
OrgID param.Field[string] `path:"org_id,required"`
ImageURL param.Field[string] `json:"image_url,required"`
Name param.Field[string] `json:"name,required"`
Price param.Field[int64] `json:"price,required"`
}
func (ProductVariantUpdateParams) MarshalJSON ¶
func (r ProductVariantUpdateParams) MarshalJSON() (data []byte, err error)