Documentation
¶
Index ¶
Constants ¶
const (
// APIUrl is the URL of our API.
APIUrl = "https://api.sumup.com"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func New ¶
func New(opts ...ClientOption) *Client
New creates new HTTP API client. The client is by default configured with environment variables (e.g. `SUMUP_API_KEY`). To override the default configuration use [ClientOption]s.
func (*Client) Call ¶
func (c *Client) Call( ctx context.Context, method, path string, opts ...RequestOption, ) (*http.Response, error)
Call executes an API call. Use [RequestOption]s to configure the request.
type ClientOption ¶
ClientOption is an option for the API client.
func WithAPIKey ¶
func WithAPIKey(key string) ClientOption
WithAPIKey returns a ClientOption that configures the client with an API key for authorization.
func WithBaseURL ¶
func WithBaseURL(base string) ClientOption
WithBaseURL returns a ClientOption that configures the client with a base URL that the individual API call paths will be resolved against.
func WithClient ¶
func WithClient(client *http.Client) ClientOption
WithClient returns a ClientOption that configures the client to use a specific http client for underlying requests.
type RequestOption ¶
type RequestOption func(req *request) error
RequestOption is an option for the request made by the Client.
func WithHTTPClient ¶
func WithHTTPClient(client *http.Client) RequestOption
WithHTTPClient returns a RequestOption that overrides the underlying http.Client of the service used to make the request.
func WithHeader ¶
func WithHeader(key, value string) RequestOption
WithHeader returns a RequestOption that sets a header key-value pair. Any previously set value will be overwritten.
func WithJSONBody ¶
func WithJSONBody(v any) RequestOption
WithBody returns a RequestOption that sets the request body as a JSON of the value v.
func WithQueryValues ¶
func WithQueryValues(q url.Values) RequestOption
WithQueryValues returns a RequestOption that sets the request query params.
func WithoutRedirects ¶ added in v0.22.0
func WithoutRedirects() RequestOption
WithoutRedirects prevents this request from following redirects. The configured client's transport, timeout, and cookie jar are preserved. Its redirect policy is unchanged for other requests.