frankfurtergo

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: MIT Imports: 9 Imported by: 0

README

Go Report Card Go Reference

frankfurtergo

A neat Go wrapper for the frankfurter.app API

Installation

go get -u github.com/masl/frankfurtergo

Usage

Initialize
client := frankfurtergo.New()
Latest Data
latest, err := client.FetchLatest()
if err != nil {
    return err
}
Historical Data
t := time.Date(
    2010, 8, 18, 16, 0, 0, 0, time.UTC)

hist, err := client.FetchHistorical(t)
if err != nil {
    return err
}
Time Series Data
f := time.Date(
    2010, 8, 18, 16, 0, 0, 0, time.UTC)

t := time.Date(
    2012, 4, 20, 16, 0, 0, 0, time.UTC)

series, err := client.FetchSeries(f, t)
if err != nil {
    return err
}

Contribution

Feel free to help me out as I'm learning Go with this project and would appreciate any kind of help

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func New

func New(options ...ClientOptions) *Client

func (*Client) ConvertCurrency

func (c *Client) ConvertCurrency(from, to string, amount float64) (latest *Latest, err error)

func (*Client) FetchCurrencies

func (c *Client) FetchCurrencies() (currencies map[string]string, err error)

func (*Client) FetchHistorical

func (c *Client) FetchHistorical(d time.Time, options ...RequestOptions) (historical *Historical, err error)

func (*Client) FetchLatest

func (c *Client) FetchLatest(options ...RequestOptions) (latest *Latest, err error)

func (*Client) FetchSeries

func (c *Client) FetchSeries(from time.Time, to time.Time, options ...RequestOptions) (series *Series, err error)

type ClientOptions

type ClientOptions struct {
	Host string `json:"host"`
}

type Date

type Date struct {
	Year  int `json:"year"`
	Month int `json:"month"`
	Day   int `json:"day"`
}

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(data []byte) (err error)

type Historical

type Historical struct {
	Amount float32            `json:"amount"`
	Base   string             `json:"base"`
	Date   Date               `json:"date"`
	Rates  map[string]float64 `json:"rates"`
}

type Latest

type Latest struct {
	Amount float32            `json:"amount"`
	Base   string             `json:"base"`
	Date   Date               `json:"date"`
	Rates  map[string]float64 `json:"rates"`
}

type RequestOptions

type RequestOptions struct {
	From   string   `json:"from"`
	To     []string `json:"to"`
	Amount float64  `json:"amount"`
}

type Series

type Series struct {
	Amount    float32                       `json:"amount"`
	Base      string                        `json:"base"`
	StartDate string                        `json:"start_date"`
	EndDate   string                        `json:"end_date"`
	Rates     map[string]map[string]float64 `json:"rates"`
}

Jump to

Keyboard shortcuts

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