Documentation ¶
Overview ¶
Package opts allows us to customise the settings to use with a payment provider API
the settings defined here are platform agnostic and can be applied to all providers. applying settings in this fashion also allows us to set reasonable defaults in tests.
Index ¶
- type APIOption
- func WithBackoff(b backoff.Backoff) APIOption
- func WithCredentials(c auth.Credentials) APIOption
- func WithEncoder(f format.Encoder) APIOption
- func WithHTTPClient(h *http.Client) APIOption
- func WithLanguage(l language.Tag) APIOption
- func WithLogger(l log.Logger) APIOption
- func WithMaxNetworkRetries(n int64) APIOption
- func WithTimeout(t time.Duration) APIOption
- func WithUserAgent(ua string) APIOption
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIOption ¶
type APIOption interface {
// contains filtered or unexported methods
}
APIOption configures how we set up the API.
func WithBackoff ¶
WithBackoff overrides the backoff strategy to in between retries.
func WithCredentials ¶
func WithCredentials(c auth.Credentials) APIOption
WithCredentials overrides the credentials to use.
func WithEncoder ¶
WithEncoder overrides the request and response encoder for the client.
func WithHTTPClient ¶
WithHTTPClient sets the http.Client to use for each request. this can be used to finely tweak TLS settings or add a custom http.RoundTripper
func WithLanguage ¶
WithLanguage overrides the language to use.
func WithMaxNetworkRetries ¶
WithMaxNetworkRetries overrides the max number of retries to attempt.
func WithTimeout ¶
WithTimeout overrides the per-request timeout.
func WithUserAgent ¶
WithUserAgent updates the API options with the supplied user-agent.
type Options ¶
type Options struct { HTTPClient *http.Client // HTTPClient is the http client to use. MaxNetworkRetries int64 // MaxNetworkRetries the maximum number of retries on API failure. Encoder format.Encoder // Encoder is the encoder to use to encode / decode requests and responses. UserAgent string // UserAgent the user agent to send with each request. Credentials auth.Credentials // Credentials the method in which to authenticate if applicable. Backoff backoff.Backoff // Backoff allows us to customise the function to determine the backoff for retries. Logger log.Logger // Logger the logger to use when performing requests. Language language.Tag // Language language used to set the Accept-Language header. // Timeout defines the timeout which is applied to each request, a timeout of zero // represents no timeout is applied. Timeout time.Duration }
Options defines the options to use with the API.