api

package
v0.0.0-...-28b228a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2021 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRestyClient

func NewRestyClient(cfg Config) *resty.Client

Types

type Authentication

type Authentication struct {
	// contains filtered or unexported fields
}

func NewAuthentication

func NewAuthentication(cfg Config) *Authentication

func (*Authentication) OAuth2

func (a *Authentication) OAuth2(ctx context.Context) (*entity.OAuth2Resp, error)

type Config

type Config struct {
	ClientID     string
	ClientSecret string
	// Timeout describes total waiting time before a request is treated as timeout.
	// Optional.
	// Default: 1 min.
	Timeout time.Duration
	// RetryCount describes total number of retry in case error occurred.
	// Optional.
	// Default: 0 = disable retry mechanism.
	RetryCount int
	// RetryMaxWaitTime describes total waiting time between each retry.
	// Optional.
	// Default: 2 second.
	RetryMaxWaitTime time.Duration
	// Debug describes the client to enter debug mode.
	// Debug mode will dump the request and response on each API call.
	// Be warn, credentials data will be dumped too.
	// Ensure you're only this mode on safe environment like local.
	// Optional.
	// Default: false.
	Debug bool
	// HostURL describes the host url target.
	// HostURL can be filled with your fake server host url for testing purpose.
	// Optional.
	// Default: https://api-sandbox.btpn.com:8089
	HostURL string
}

Config is the necessary configuration to call API.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates configuration correctness and fill fields with default configuration if left empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL