From 8d2302a75b822b6ecd839ef8ce92662ffb2ca01a Mon Sep 17 00:00:00 2001 From: "piotr.jaskulski@gmail.com" Date: Thu, 3 Dec 2020 11:38:49 +0100 Subject: [PATCH] fixes --- README.md | 5 +++-- currency.go | 4 ++-- currency_test.go | 8 ++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index bc3b66c..58635eb 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,7 @@ type NBPCurrency struct { func NewCurrency(tableType string) *NBPCurrency NewCurrency - function creates new currency type -func (c *NBPCurrency) CurrencyByDate(date string, code string) error +func (c *NBPCurrency) CurrencyByDate(code string, date string) error CurrencyByDate - function downloads and writes data to exchange (exchangeC) slice, raw data (json) still available in result field @@ -164,7 +164,7 @@ func (c *NBPCurrency) CurrencyLast(code string, last int) error last - as an alternative to date, the last tables/rates can be retrieved -func (c *NBPCurrency) CurrencyRaw(date string, last int, code string, format string) error +func (c *NBPCurrency) CurrencyRaw(code string, date string, last int, format string) error CurrencyRaw - function downloads data in json or xml form @@ -251,6 +251,7 @@ func (c *NBPCurrency) GetRawOutput() string type NBPGold struct { GoldRates []GoldRate + // Has unexported fields. } NBPGold type diff --git a/currency.go b/currency.go index 2327402..8cad85c 100644 --- a/currency.go +++ b/currency.go @@ -102,7 +102,7 @@ Parameters: format - 'json' or 'xml' */ -func (c *NBPCurrency) CurrencyRaw(date string, last int, code string, format string) error { +func (c *NBPCurrency) CurrencyRaw(code string, date string, last int, format string) error { var err error url := c.getCurrencyAddress(c.tableType, date, last, code) @@ -129,7 +129,7 @@ Parameters: code - ISO 4217 currency code, depending on the type of the table available currencies may vary */ -func (c *NBPCurrency) CurrencyByDate(date string, code string) error { +func (c *NBPCurrency) CurrencyByDate(code string, date string) error { var err error url := c.getCurrencyAddress(c.tableType, date, 0, code) diff --git a/currency_test.go b/currency_test.go index 6506b01..e45f065 100644 --- a/currency_test.go +++ b/currency_test.go @@ -14,7 +14,7 @@ func TestGetCurrencyCurrent(t *testing.T) { littleDelay() client := NewCurrency(table) - err := client.CurrencyByDate("current", currency) + err := client.CurrencyByDate(currency, "current") if err != nil { t.Errorf("expected: err == nil, received: err != nil") } @@ -52,7 +52,7 @@ func TestGetCurrencyDay(t *testing.T) { littleDelay() client := NewCurrency(table) - err := client.CurrencyByDate(day, currency) + err := client.CurrencyByDate(currency, day) if err != nil { t.Errorf("expected: err == nil, received: err != nil") } @@ -79,7 +79,7 @@ func TestGetCurrencyDaySaturdayFailed(t *testing.T) { client := NewCurrency(table) - err := client.CurrencyByDate(day, currency) + err := client.CurrencyByDate(currency, day) if err == nil { t.Errorf("expected: err != nil, received: err == nil") } @@ -221,7 +221,7 @@ func TestCurrencyCSVOutput(t *testing.T) { want := "TABLE,DATE,AVERAGE (PLN)" client := NewCurrency("A") - err := client.CurrencyByDate("current", "EUR") + err := client.CurrencyByDate("EUR", "current") if err != nil { t.Error(err) }