Documentation ¶
Overview ¶
Package client provides the base for all requests and responses to the Paddle API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrDirectiveRequiresBool = errors.New("include directive requires a boolean value")
ErrDirectiveRequiresBool is returned when the directive's struct field is not a boolean.
Functions ¶
func ContextWithTransitID ¶
ContextWithTransitID returns a new context with the provided transit ID.
func TransitIDFromContext ¶
TransitIDFromContext returns the transit ID from the provided context.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides the base for all requests and responses to the Paddle API.
func (*Client) Do ¶
Do sends an API request and returns the API response. The src field is a request which contains `json` or `in` struct tags (see github.com/ggicci/httpin) and will be encoded as the request body. The dst field is a response which will be decoded from the response body. The dst field should be given as a pointer. If the src field is nil, no request body will be sent. If the dst field is nil, no response body will be decoded.
type DirectiveInclude ¶
type DirectiveInclude struct{}
DirectiveInclude is a directive that adds the custom 'include' query parameter to the request, based on the value of the directive's struct field.
func (*DirectiveInclude) Decode ¶
func (*DirectiveInclude) Decode(_ *core.DirectiveRuntime) error
Decode is not implemented. This is because we only deal with encoding concerns in the client.
func (*DirectiveInclude) Encode ¶
func (*DirectiveInclude) Encode(rtm *core.DirectiveRuntime) error
Encode adds/appends the custom 'include' query parameter to the request. The value of the directive's struct field is expected to be a boolean. If the value is true, the directive's value query parameter 'include'. e.g.
type Request struct { IncludeCustomer bool `in:"paddle_include=customer"` } Req{IncludeCustomer: true} // ?paddle_include=customer
type DirectiveQuery ¶
type DirectiveQuery struct {
core.DirectiveQuery
}
DirectiveQuery extends the core.DirectiveQuery struct from the httpin package and adds support for the "omitempty" tag.
func (*DirectiveQuery) Encode ¶
func (d *DirectiveQuery) Encode(rtm *core.DirectiveRuntime) error
Encode adds the values of the input struct into the http.Request as query parameters. If the value is zero and the "omitempty" tag is present, the value will not be added to the query string.