currencyconverter

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 10 Imported by: 0

README

GoCryptoTrader package Currencyconverterapi

Build Status Software License GoDoc Coverage Status Go Report Card

This currencyconverterapi package is part of the GoCryptoTrader codebase.

This is still in active development

You can track ideas, planned features and what's in progress on this Trello board: https://trello.com/b/ZAhMhpOy/gocryptotrader.

Join our slack to discuss all things related to GoCryptoTrader! GoCryptoTrader Slack

Current Features for currencyconverterapi

How to enable
import (
	"github.com/aaabigfish/gocryptotrader/currency/forexprovider/base"
	"github.com/aaabigfish/gocryptotrader/currency/forexprovider/currencyconverter"
)

c := currencyconverter.CurrencyConverter{}

// Define configuration
newSettings := base.Settings{
	Name:             "CurrencyConverter",
	Enabled:          true,
	Verbose:          false,
	RESTPollingDelay: time.Duration,
	APIKey:           "key",
	APIKeyLvl:        "keylvl",
	PrimaryProvider:  true,
}

c.Setup(newSettings)

mapstringfloat, err := c.GetRates("USD", "EUR,CHY")
// Handle error
Please click GoDocs chevron above to view current GoDoc information for this package

Contribution

Please feel free to submit any pull requests or suggest any desired features to be added.

When submitting a PR, please abide by our coding guidelines:

  • Code must adhere to the official Go formatting guidelines (i.e. uses gofmt).
  • Code must be documented adhering to the official Go commentary guidelines.
  • Code must adhere to our coding style.
  • Pull requests need to be based on and opened against the master branch.

Donations

If this framework helped you in any way, or you would like to support the developers working on it, please donate Bitcoin to:

bc1qk0jareu4jytc0cfrhr5wgshsq8282awpavfahc

Documentation

Overview

Package currencyconverter package https://free.currencyconverterapi.com/

Index

Constants

View Source
const (
	APIEndpointURL     = "https://currencyconverterapi.com/api/"
	APIEndpointFreeURL = "https://free.currencyconverterapi.com/api/"
	APIEndpointVersion = "v5"

	APIEndpointConvert    = "convert"
	APIEndpointCurrencies = "currencies"
	APIEndpointCountries  = "countries"
	APIEndpointUsage      = "usage"
)

const declarations consist of endpoints

Variables

This section is empty.

Functions

This section is empty.

Types

type Countries

type Countries struct {
	Results map[string]CountryItem
}

Countries stores the country result data

type CountryItem

type CountryItem struct {
	Alpha3         string `json:"alpha3"`
	CurrencyID     string `json:"currencyId"`
	CurrencyName   string `json:"currencyName"`
	CurrencySymbol string `json:"currencySymbol"`
	ID             string `json:"ID"`
	Name           string `json:"Name"`
}

CountryItem stores variables related to the country response

type Currencies

type Currencies struct {
	Results map[string]CurrencyItem
}

Currencies stores the currency result data

type CurrencyConverter

type CurrencyConverter struct {
	base.Base
	Requester *request.Requester
}

CurrencyConverter stores the struct for the CurrencyConverter API

func (*CurrencyConverter) Convert

func (c *CurrencyConverter) Convert(from, to string) (map[string]float64, error)

Convert gets the conversion rate for the supplied currencies

func (*CurrencyConverter) ConvertMany

func (c *CurrencyConverter) ConvertMany(currencies []string) (map[string]float64, error)

ConvertMany takes 2 or more currencies depending on if using the free or paid API

func (*CurrencyConverter) GetCountries

func (c *CurrencyConverter) GetCountries() (map[string]CountryItem, error)

GetCountries returns a list of the supported countries and their symbols

func (*CurrencyConverter) GetRates

func (c *CurrencyConverter) GetRates(baseCurrency, symbols string) (map[string]float64, error)

GetRates is a wrapper function to return rates

func (*CurrencyConverter) GetSupportedCurrencies

func (c *CurrencyConverter) GetSupportedCurrencies() ([]string, error)

GetSupportedCurrencies returns a list of the supported currencies

func (*CurrencyConverter) SendHTTPRequest

func (c *CurrencyConverter) SendHTTPRequest(endPoint string, values url.Values, result interface{}) error

SendHTTPRequest sends a HTTP request, if account is not free it automatically upgrades request to SSL.

func (*CurrencyConverter) Setup

func (c *CurrencyConverter) Setup(config base.Settings) error

Setup sets appropriate values for CurrencyLayer

type CurrencyItem

type CurrencyItem struct {
	CurrencyName   string `json:"currencyName"`
	CurrencySymbol string `json:"currencySymbol"`
	ID             string `json:"ID"`
}

CurrencyItem stores variables related to the currency response

type Error

type Error struct {
	Status int    `json:"status"`
	Error  string `json:"error"`
}

Error stores the error message

Jump to

Keyboard shortcuts

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