mirror of
https://github.com/hanzo-fi/payments.git
synced 2026-10-30 20:31:20 +00:00
* Use formance-sdk-go/v3 to in connector uninstall e2e test * Compile API docs from openapi spec * Generate go SDK locally for use in integration tests * Get rid of unnecessary redirect in e2e tests now that SDK is generated * Omit generated SDK code from codecoverage checks * Add flake and envrc for nix * Run Dirty and Tests CI steps with nix * Run pre-commit using nix * Remove duplicated steps from Earthfile * Fixes for linter * Add go generate to Justfile pre-commit * Still run Deploy on ubuntu-latest * Address coderabbit feedback
95 lines
2.6 KiB
Go
95 lines
2.6 KiB
Go
// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
|
|
package operations
|
|
|
|
import (
|
|
"errors"
|
|
"github.com/formancehq/payments/pkg/client/internal/utils"
|
|
"github.com/formancehq/payments/pkg/client/retry"
|
|
"time"
|
|
)
|
|
|
|
var ErrUnsupportedOption = errors.New("unsupported option")
|
|
|
|
const (
|
|
SupportedOptionRetries = "retries"
|
|
SupportedOptionTimeout = "timeout"
|
|
SupportedOptionAcceptHeaderOverride = "acceptHeaderOverride"
|
|
SupportedOptionURLOverride = "urlOverride"
|
|
)
|
|
|
|
type Options struct {
|
|
ServerURL *string
|
|
Retries *retry.Config
|
|
Timeout *time.Duration
|
|
URLOverride *string
|
|
SetHeaders map[string]string
|
|
}
|
|
|
|
type Option func(*Options, ...string) error
|
|
|
|
// WithServerURL allows providing an alternative server URL.
|
|
func WithServerURL(serverURL string) Option {
|
|
return func(opts *Options, supportedOptions ...string) error {
|
|
opts.ServerURL = &serverURL
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// WithTemplatedServerURL allows providing an alternative server URL with templated parameters.
|
|
func WithTemplatedServerURL(serverURL string, params map[string]string) Option {
|
|
return func(opts *Options, supportedOptions ...string) error {
|
|
if params != nil {
|
|
serverURL = utils.ReplaceParameters(serverURL, params)
|
|
}
|
|
|
|
opts.ServerURL = &serverURL
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// WithRetries allows customizing the default retry configuration.
|
|
func WithRetries(config retry.Config) Option {
|
|
return func(opts *Options, supportedOptions ...string) error {
|
|
if !utils.Contains(supportedOptions, SupportedOptionRetries) {
|
|
return ErrUnsupportedOption
|
|
}
|
|
|
|
opts.Retries = &config
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// WithOperationTimeout allows setting the request timeout applied for an operation.
|
|
func WithOperationTimeout(timeout time.Duration) Option {
|
|
return func(opts *Options, supportedOptions ...string) error {
|
|
if !utils.Contains(supportedOptions, SupportedOptionRetries) {
|
|
return ErrUnsupportedOption
|
|
}
|
|
|
|
opts.Timeout = &timeout
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// WithURLOverride allows overriding the URL.
|
|
func WithURLOverride(urlOverride string) Option {
|
|
return func(opts *Options, supportedOptions ...string) error {
|
|
if !utils.Contains(supportedOptions, SupportedOptionURLOverride) {
|
|
return ErrUnsupportedOption
|
|
}
|
|
|
|
opts.URLOverride = &urlOverride
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// WithSetHeaders takes a map of headers that will applied to a request. If the
|
|
// request contains headers that are in the map then they will be overwritten.
|
|
func WithSetHeaders(hdrs map[string]string) Option {
|
|
return func(opts *Options, supportedOptions ...string) error {
|
|
opts.SetHeaders = hdrs
|
|
return nil
|
|
}
|
|
}
|