ratios

package
v0.0.0-...-f003305 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MPL-2.0 Imports: 15 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	FetchRate(ctx context.Context, base string, currency string) (*RateResponse, error)
}

Client abstracts over the underlying client

func New

func New() (Client, error)

New returns a new HTTPClient, retrieving the base URL from the environment

func NewWithContext

func NewWithContext(ctx context.Context) (Client, error)

NewWithContext returns a new HTTPClient, retrieving the base URL from the context

type ClientWithPrometheus

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

ClientWithPrometheus implements Client interface with all methods wrapped with Prometheus metrics

func NewClientWithPrometheus

func NewClientWithPrometheus(base Client, instanceName string) ClientWithPrometheus

NewClientWithPrometheus returns an instance of the Client decorated with prometheus summary metric

func (ClientWithPrometheus) FetchRate

func (_d ClientWithPrometheus) FetchRate(ctx context.Context, base string, currency string) (rp1 *RateResponse, err error)

FetchRate implements Client

type FetchOptions

type FetchOptions struct {
	Currency string `url:"currency,omitempty"`
}

FetchOptions options for fetching rates from ratios

func (*FetchOptions) GenerateQueryString

func (fo *FetchOptions) GenerateQueryString() (url.Values, error)

GenerateQueryString - implement the QueryStringBody interface

type HTTPClient

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

HTTPClient wraps http.Client for interacting with the ratios server

func (*HTTPClient) FetchRate

func (c *HTTPClient) FetchRate(ctx context.Context, base string, currency string) (*RateResponse, error)

FetchRate fetches the rate of a currency to BAT

type RateResponse

type RateResponse struct {
	LastUpdated time.Time                  `json:"lastUpdated"`
	Payload     map[string]decimal.Decimal `json:"payload"`
}

RateResponse is the response received from ratios

type RelativeResponse

type RelativeResponse struct {
	Payload     coingecko.SimplePriceResponse `json:"payload"`
	LastUpdated time.Time                     `json:"lastUpdated"`
}

RelativeResponse - the relative response structure

Directories

Path Synopsis
Package mock_ratios is a generated GoMock package.
Package mock_ratios is a generated GoMock package.

Jump to

Keyboard shortcuts

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