Documentation ¶
Overview ¶
Package doitpay provides the binding for Doitpay APIs.
Index ¶
- Variables
- func CacheExpires(r *http.Response) time.Time
- type APIClient
- func (c *APIClient) CallAPI(request *http.Request) (*http.Response, error)
- func (c *APIClient) Decode(v interface{}, b []byte, contentType string) error
- func (c *APIClient) GetAPIKey() string
- func (c *APIClient) GetConfig() common.IConfiguration
- func (c *APIClient) PrepareRequest(ctx context.Context, path string, method string, postBody interface{}, ...) (localVarRequest *http.Request, err error)
- type APIKey
- type APIResponse
- type BasicAuth
- type Configuration
- func (c *Configuration) AddDefaultHeader(key string, value string)
- func (c *Configuration) GetConfig() Configuration
- func (c *Configuration) ServerURL(index int, variables map[string]string) (string, error)
- func (c *Configuration) ServerURLWithContext(ctx context.Context, endpoint string) (string, error)
- type GenericDoitpayError
- type ServerConfiguration
- type ServerConfigurations
- type ServerVariable
Constants ¶
This section is empty.
Variables ¶
var ( // ContextOAuth2 takes an oauth2.TokenSource as authentication for the request. ContextOAuth2 = contextKey("token") // ContextBasicAuth takes BasicAuth as authentication for the request. ContextBasicAuth = contextKey("basic") // ContextAPIKeys takes a string apikey as authentication for the request ContextAPIKeys = contextKey("apiKeys") // ContextServerIndex uses a server configuration from the index. ContextServerIndex = contextKey("serverIndex") // ContextOperationServerIndices uses a server configuration from the index mapping. ContextOperationServerIndices = contextKey("serverOperationIndices") // ContextServerVariables overrides a server configuration variables. ContextServerVariables = contextKey("serverVariables") // ContextOperationServerVariables overrides a server configuration variables using operation specific values. ContextOperationServerVariables = contextKey("serverOperationVariables") )
Functions ¶
Types ¶
type APIClient ¶
type APIClient struct { // API Services BalanceAPI balance.PublicBalanceAPI InvoiceAPI invoice.PublicInvoiceAPI SimulateAPI simulate.PublicSimulateAPI VirtualAccountAPI virtualaccount.PublicVirtualAccountAPI // contains filtered or unexported fields }
APIClient manages communication with the Doitpay API API v1.0 In most cases there should be only one, shared, APIClient.
func NewClient ¶
NewClient creates a new API client. Requires a userAgent string describing your application. optionally a custom http.Client to allow for advanced features such as caching.
func (*APIClient) GetConfig ¶
func (c *APIClient) GetConfig() common.IConfiguration
Allow modification of underlying config for alternate implementations and testing Caution: modifying the configuration while live can cause data races and potentially unwanted behavior
func (*APIClient) PrepareRequest ¶
func (c *APIClient) PrepareRequest( ctx context.Context, path string, method string, postBody interface{}, headerParams map[string]string, queryParams url.Values, formParams url.Values, formFiles []common.FormFile) (localVarRequest *http.Request, err error)
PrepareRequest build the request
type APIKey ¶
APIKey provides API key based authentication to a request passed via context using ContextAPIKey
type APIResponse ¶
type APIResponse struct { *http.Response `json:"-"` Message string `json:"message,omitempty"` // Operation is the name of the OpenAPI operation. Operation string `json:"operation,omitempty"` // RequestURL is the request URL. This value is always available, even if the // embedded *http.Response is nil. RequestURL string `json:"url,omitempty"` // Method is the HTTP method used for the request. This value is always // available, even if the embedded *http.Response is nil. Method string `json:"method,omitempty"` // Payload holds the contents of the response body (which may be nil or empty). // This is provided here as the raw response.Body() reader will have already // been drained. Payload []byte `json:"-"` }
APIResponse stores the API response returned by the server.
func NewAPIResponse ¶
func NewAPIResponse(r *http.Response) *APIResponse
NewAPIResponse returns a new APIResponse object.
func NewAPIResponseWithError ¶
func NewAPIResponseWithError(errorMessage string) *APIResponse
NewAPIResponseWithError returns a new APIResponse object with the provided error message.
type BasicAuth ¶
type BasicAuth struct { UserName string `json:"userName,omitempty"` Password string `json:"password,omitempty"` }
BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth
type Configuration ¶
type Configuration struct { Host string `json:"host,omitempty"` Scheme string `json:"scheme,omitempty"` DefaultHeader map[string]string `json:"defaultHeader,omitempty"` UserAgent string `json:"userAgent,omitempty"` Debug bool `json:"debug,omitempty"` Servers ServerConfigurations OperationServers map[string]ServerConfigurations HTTPClient *http.Client }
Configuration stores the configuration of the API client
func NewConfiguration ¶
func NewConfiguration() *Configuration
NewConfiguration returns a new Configuration object
func (*Configuration) AddDefaultHeader ¶
func (c *Configuration) AddDefaultHeader(key string, value string)
AddDefaultHeader adds a new HTTP header to the default header in the request
func (*Configuration) GetConfig ¶
func (c *Configuration) GetConfig() Configuration
func (*Configuration) ServerURLWithContext ¶
ServerURLWithContext returns a new server URL given an endpoint
type GenericDoitpayError ¶
type GenericDoitpayError struct {
// contains filtered or unexported fields
}
GenericDoitpayError Provides access to the body, error and model on returned errors.
func (GenericDoitpayError) Body ¶
func (e GenericDoitpayError) Body() []byte
Body returns the raw bytes of the response
func (GenericDoitpayError) Error ¶
func (e GenericDoitpayError) Error() string
Error returns non-empty string if there was an error.
func (GenericDoitpayError) Model ¶
func (e GenericDoitpayError) Model() interface{}
Model returns the unpacked model of the error
type ServerConfiguration ¶
type ServerConfiguration struct { URL string Description string Variables map[string]ServerVariable }
ServerConfiguration stores the information about a server
type ServerConfigurations ¶
type ServerConfigurations []ServerConfiguration
ServerConfigurations stores multiple ServerConfiguration items
type ServerVariable ¶
ServerVariable stores the information about a server variable