wise

package
v1.60.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

README

Wise

Wise API Docs

c := wise.NewClient()
c.Auth(os.Getenv("WISE_TOKEN"))

ctx := context.Background()
rates, err := c.QueryRate(ctx, "USD", "TWD")
if err != nil {
    panic(err)
}
fmt.Printf("%+v\n", rates)

// or
now := time.Now()
rates, err = c.QueryRateHistory(ctx, "USD", "TWD", now.Add(-time.Hour*24*7), now, types.Interval1h)
if err != nil {
    panic(err)
}
for _, rate := range rates {
    fmt.Printf("%+v\n", rate)
}

Documentation

Index

Constants

View Source
const (
	GroupMinute = Group("minute")
	GroupHour   = Group("hour")
	GroupDay    = Group("day")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	requestgen.BaseAPIClient
	// contains filtered or unexported fields
}

func NewClient

func NewClient() *Client

func (*Client) Auth

func (c *Client) Auth(token string)

func (*Client) NewAuthenticatedRequest

func (c *Client) NewAuthenticatedRequest(ctx context.Context, method, refURL string, params url.Values, payload interface{}) (*http.Request, error)

func (*Client) NewRateRequest

func (c *Client) NewRateRequest() *RateRequest

func (*Client) QueryRate

func (c *Client) QueryRate(ctx context.Context, source string, target string) ([]Rate, error)

func (*Client) QueryRateHistory

func (c *Client) QueryRateHistory(ctx context.Context, source string, target string, from time.Time, to time.Time, interval types.Interval) ([]Rate, error)

type Group

type Group string

type Rate

type Rate struct {
	Value  fixedpoint.Value `json:"rate"`
	Target string           `json:"target"`
	Source string           `json:"source"`
	Time   Time             `json:"time"`
}

type RateRequest

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

func (*RateRequest) Do

func (r *RateRequest) Do(ctx context.Context) ([]Rate, error)

Do generates the request object and send the request object to the API endpoint

func (*RateRequest) From

func (r *RateRequest) From(from time.Time) *RateRequest

func (*RateRequest) GetParameters

func (r *RateRequest) GetParameters() (map[string]interface{}, error)

GetParameters builds and checks the parameters and return the result in a map object

func (*RateRequest) GetParametersJSON

func (r *RateRequest) GetParametersJSON() ([]byte, error)

GetParametersJSON converts the parameters from GetParameters into the JSON format

func (*RateRequest) GetParametersQuery

func (r *RateRequest) GetParametersQuery() (url.Values, error)

GetParametersQuery converts the parameters from GetParameters into the url.Values format

func (*RateRequest) GetPath

func (r *RateRequest) GetPath() string

GetPath returns the request path of the API

func (*RateRequest) GetQueryParameters

func (r *RateRequest) GetQueryParameters() (url.Values, error)

GetQueryParameters builds and checks the query parameters and returns url.Values

func (*RateRequest) GetSlugParameters

func (r *RateRequest) GetSlugParameters() (map[string]interface{}, error)

GetSlugParameters builds and checks the slug parameters and return the result in a map object

func (*RateRequest) GetSlugsMap

func (r *RateRequest) GetSlugsMap() (map[string]string, error)

func (*RateRequest) Group

func (r *RateRequest) Group(group Group) *RateRequest

func (*RateRequest) Source

func (r *RateRequest) Source(source string) *RateRequest

func (*RateRequest) Target

func (r *RateRequest) Target(target string) *RateRequest

func (*RateRequest) Time

func (r *RateRequest) Time(time time.Time) *RateRequest

func (*RateRequest) To

func (r *RateRequest) To(to time.Time) *RateRequest

type Time

type Time time.Time

func (Time) String

func (t Time) String() string

func (Time) Time

func (t Time) Time() time.Time

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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