mnb

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2024 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ArfolyamokURL = "http://www.mnb.hu/arfolyamok.asmx"
	AlapkamatURL  = "http://www.mnb.hu/alapkamat.asmx"
)

Variables

This section is empty.

Functions

func FindBody

func FindBody(dec *xml.Decoder) ([]byte, error)

FindBody will find the first StartElement after soap:Body.

Types

type Date

type Date time.Time

func (Date) MarshalText

func (d Date) MarshalText() ([]byte, error)

func (Date) String

func (d Date) String() string

func (*Date) UnmarshalText

func (d *Date) UnmarshalText(data []byte) error

type DateInterval

type DateInterval struct {
	Start Date `xml:"startdate,attr"`
	End   Date `xml:"enddate,attr"`
}

type DayRates

type DayRates struct {
	Day   Date   `xml:"date,attr"`
	Rates []Rate `xml:"Rate"`
}

type Double

type Double struct {
	*apd.Decimal
}

func NewDouble

func NewDouble(coeff int64, exponent int32) Double

func NewDoubleFromString

func NewDoubleFromString(s string) (Double, error)

func (Double) MarshalText

func (d Double) MarshalText() ([]byte, error)

func (Double) String

func (d Double) String() string

func (*Double) UnmarshalText

func (d *Double) UnmarshalText(data []byte) error

type MNB

type MNB struct {
	URL string
	*slog.Logger
	*http.Client
}

func NewMNB

func NewMNB(URL string, client *http.Client, logger *slog.Logger) MNB

func (MNB) GetCentralBankBaseRateXML

func (req MNB) GetCentralBankBaseRateXML(start, end time.Time) string

func (MNB) GetCurrencyUnitsXML

func (req MNB) GetCurrencyUnitsXML(currencies ...string) string

func (MNB) GetExchangeRatesXML

func (req MNB) GetExchangeRatesXML(start, end time.Time, currencies ...string) string

func (MNB) StreamGetCentralBankBaseRateXML

func (req MNB) StreamGetCentralBankBaseRateXML(qw422016 *qt422016.Writer, start, end time.Time)

func (MNB) StreamGetCurrencyUnitsXML

func (req MNB) StreamGetCurrencyUnitsXML(qw422016 *qt422016.Writer, currencies ...string)

func (MNB) StreamGetExchangeRatesXML

func (req MNB) StreamGetExchangeRatesXML(qw422016 *qt422016.Writer, start, end time.Time, currencies ...string)

func (MNB) WriteGetCentralBankBaseRateXML

func (req MNB) WriteGetCentralBankBaseRateXML(qq422016 qtio422016.Writer, start, end time.Time)

func (MNB) WriteGetCurrencyUnitsXML

func (req MNB) WriteGetCurrencyUnitsXML(qq422016 qtio422016.Writer, currencies ...string)

func (MNB) WriteGetExchangeRatesXML

func (req MNB) WriteGetExchangeRatesXML(qq422016 qtio422016.Writer, start, end time.Time, currencies ...string)

type MNBAlapkamatService

type MNBAlapkamatService struct {
	MNB
}

func NewMNBAlapkamatService

func NewMNBAlapkamatService(URL string, client *http.Client, logger *slog.Logger) MNBAlapkamatService

func (MNBAlapkamatService) GetBaseRates

func (m MNBAlapkamatService) GetBaseRates(ctx context.Context, start, end time.Time) ([]MNBBaseRate, error)

func (MNBAlapkamatService) GetCentralBankBaseRate

func (m MNBAlapkamatService) GetCentralBankBaseRate(ctx context.Context, start, end time.Time) ([]MNBBaseRate, error)

func (MNBAlapkamatService) GetCurrentBaseRate

func (m MNBAlapkamatService) GetCurrentBaseRate(ctx context.Context) (MNBBaseRate, error)

func (MNBAlapkamatService) GetCurrentCentralBankBaseRate

func (m MNBAlapkamatService) GetCurrentCentralBankBaseRate(ctx context.Context) (MNBBaseRate, error)

type MNBArfolyamService

type MNBArfolyamService struct {
	MNB
}

func NewMNBArfolyamService

func NewMNBArfolyamService(URL string, client *http.Client, logger *slog.Logger) MNBArfolyamService

func (MNBArfolyamService) GetCurrencies

func (m MNBArfolyamService) GetCurrencies(ctx context.Context) ([]string, error)

func (MNBArfolyamService) GetCurrencyUnits

func (m MNBArfolyamService) GetCurrencyUnits(ctx context.Context, currency string) ([]Unit, error)

func (MNBArfolyamService) GetCurrentExchangeRates

func (m MNBArfolyamService) GetCurrentExchangeRates(ctx context.Context) (DayRates, error)

func (MNBArfolyamService) GetDateIntervalResponse

func (m MNBArfolyamService) GetDateIntervalResponse(ctx context.Context) (DateInterval, error)

func (MNBArfolyamService) GetExchangeRates

func (m MNBArfolyamService) GetExchangeRates(ctx context.Context, start, end time.Time, currencies ...string) ([]DayRates, error)

func (MNBArfolyamService) GetInfo

type MNBBaseRate

type MNBBaseRate struct {
	XMLName     xml.Name `xml:"BaseRate" json:"-"`
	Publication Date     `xml:"publicationDate,attr"`
	Rate        Double   `xml:",chardata"`
}

type MNBCentralBankBaseRates

type MNBCentralBankBaseRates struct {
	XMLName   xml.Name      `xml:"MNBCentralBankBaseRates" json:"-"`
	BaseRates []MNBBaseRate `xml:"BaseRate"`
}

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">

<s:Body>
   <GetCentralBankBaseRateResponse xmlns="http://www.mnb.hu/webservices/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
      <GetCentralBankBaseRateResult><![CDATA[<MNBCentralBankBaseRates><BaseRate publicationDate="2020-07-21">0,60</BaseRate><BaseRate publicationDate="2020-06-23">0,75</BaseRate></MNBCentralBankBaseRates>]]></GetCentralBankBaseRateResult>
   </GetCentralBankBaseRateResponse>
</s:Body>

</s:Envelope>

<MNBCentralBankBaseRates><BaseRate publicationDate="2015-07-22">1,35</BaseRate><BaseRate publicationDate="2015-06-24">1,50</BaseRate><BaseRate publicationDate="2015-05-27">1,65</BaseRate><BaseRate publicationDate="2015-04-22">1,80</BaseRate><BaseRate publicationDate="2015-03-25">1,95</BaseRate></MNBCentralBankBaseRates>

type MNBCurrencies

type MNBCurrencies struct {
	Currencies []string `xml:"Currencies>Curr"`
}

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">

<s:Body>
   <GetCurrenciesResponse xmlns="http://www.mnb.hu/webservices/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
      <GetCurrenciesResult><![CDATA[<MNBCurrencies><Currencies><Curr>HUF</Curr><Curr>EUR</Curr><Curr>AUD</Curr><Curr>BGN</Curr><Curr>BRL</Curr><Curr>CAD</Curr><Curr>CHF</Curr><Curr>CNY</Curr><Curr>CZK</Curr><Curr>DKK</Curr><Curr>GBP</Curr><Curr>HKD</Curr><Curr>HRK</Curr><Curr>IDR</Curr><Curr>ILS</Curr><Curr>INR</Curr><Curr>ISK</Curr><Curr>JPY</Curr><Curr>KRW</Curr><Curr>MXN</Curr><Curr>MYR</Curr><Curr>NOK</Curr><Curr>NZD</Curr><Curr>PHP</Curr><Curr>PLN</Curr><Curr>RON</Curr><Curr>RSD</Curr><Curr>RUB</Curr><Curr>SEK</Curr><Curr>SGD</Curr><Curr>THB</Curr><Curr>TRY</Curr><Curr>UAH</Curr><Curr>USD</Curr><Curr>ZAR</Curr><Curr>ATS</Curr><Curr>AUP</Curr><Curr>BEF</Curr><Curr>BGL</Curr><Curr>CSD</Curr><Curr>CSK</Curr><Curr>DDM</Curr><Curr>DEM</Curr><Curr>EEK</Curr><Curr>EGP</Curr><Curr>ESP</Curr><Curr>FIM</Curr><Curr>FRF</Curr><Curr>GHP</Curr><Curr>GRD</Curr><Curr>IEP</Curr><Curr>ITL</Curr><Curr>KPW</Curr><Curr>KWD</Curr><Curr>LBP</Curr><Curr>LTL</Curr><Curr>LUF</Curr><Curr>LVL</Curr><Curr>MNT</Curr><Curr>NLG</Curr><Curr>OAL</Curr><Curr>OBL</Curr><Curr>OFR</Curr><Curr>ORB</Curr><Curr>PKR</Curr><Curr>PTE</Curr><Curr>ROL</Curr><Curr>SDP</Curr><Curr>SIT</Curr><Curr>SKK</Curr><Curr>SUR</Curr><Curr>VND</Curr><Curr>XEU</Curr><Curr>XTR</Curr><Curr>YUD</Curr></Currencies></MNBCurrencies>]]></GetCurrenciesResult>
   </GetCurrenciesResponse>
</s:Body>

</s:Envelope>

type MNBCurrencyUnits

type MNBCurrencyUnits struct {
	Units []Unit `xml:"Units>Unit"`
}

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">

<s:Body>
   <GetCurrencyUnitsResponse xmlns="http://www.mnb.hu/webservices/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
      <GetCurrencyUnitsResult><![CDATA[<MNBCurrencyUnits><Units><Unit curr="HUF">1</Unit></Units></MNBCurrencyUnits>]]></GetCurrencyUnitsResult>
   </GetCurrencyUnitsResponse>
</s:Body>

</s:Envelope>

type MNBCurrentCentralBankBaseRate

type MNBCurrentCentralBankBaseRate struct {
	BaseRate MNBBaseRate
}

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">

<s:Body>
   <GetCurrentCentralBankBaseRateResponse xmlns="http://www.mnb.hu/webservices/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
      <GetCurrentCentralBankBaseRateResult>&lt;MNBCurrentCentralBankBaseRate>&lt;BaseRate publicationDate="2020-07-21">0,60&lt;/BaseRate>&lt;/MNBCurrentCentralBankBaseRate></GetCurrentCentralBankBaseRateResult>
   </GetCurrentCentralBankBaseRateResponse>
</s:Body>

</s:Envelope>

&lt;MNBCurrentCentralBankBaseRate&gt;&lt;BaseRate publicationDate="2015-06-24"&gt;1,5000&lt;/BaseRate&gt;&lt;/MNBCurrentCentralBankBaseRate&gt

type MNBCurrentExchangeRates

type MNBCurrentExchangeRates struct {
	Day DayRates
}

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">

<s:Body>
   <GetCurrentExchangeRatesResponse xmlns="http://www.mnb.hu/webservices/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
      <GetCurrentExchangeRatesResult><![CDATA[<MNBCurrentExchangeRates><Day date="2020-08-14"><Rate unit="1" curr="AUD">209,44</Rate><Rate unit="1" curr="BGN">177,03</Rate><Rate unit="1" curr="BRL">54,58</Rate><Rate unit="1" curr="CAD">221,22</Rate><Rate unit="1" curr="CHF">321,99</Rate><Rate unit="1" curr="CNY">42,16</Rate><Rate unit="1" curr="CZK">13,26</Rate><Rate unit="1" curr="DKK">46,48</Rate><Rate unit="1" curr="EUR">346,25</Rate><Rate unit="1" curr="GBP">383,23</Rate><Rate unit="1" curr="HKD">37,81</Rate><Rate unit="1" curr="HRK">45,96</Rate><Rate unit="100" curr="IDR">1,98</Rate><Rate unit="1" curr="ILS">86,1</Rate><Rate unit="1" curr="INR">3,91</Rate><Rate unit="1" curr="ISK">2,15</Rate><Rate unit="100" curr="JPY">274,56</Rate><Rate unit="100" curr="KRW">24,7</Rate><Rate unit="1" curr="MXN">13,2</Rate><Rate unit="1" curr="MYR">69,87</Rate><Rate unit="1" curr="NOK">32,86</Rate><Rate unit="1" curr="NZD">191,57</Rate><Rate unit="1" curr="PHP">6,02</Rate><Rate unit="1" curr="PLN">78,69</Rate><Rate unit="1" curr="RON">71,59</Rate><Rate unit="1" curr="RSD">2,94</Rate><Rate unit="1" curr="RUB">3,99</Rate><Rate unit="1" curr="SEK">33,63</Rate><Rate unit="1" curr="SGD">213,53</Rate><Rate unit="1" curr="THB">9,42</Rate><Rate unit="1" curr="TRY">39,76</Rate><Rate unit="1" curr="UAH">10,71</Rate><Rate unit="1" curr="USD">293,01</Rate><Rate unit="1" curr="ZAR">16,77</Rate></Day></MNBCurrentExchangeRates>]]></GetCurrentExchangeRatesResult>
   </GetCurrentExchangeRatesResponse>
</s:Body>

</s:Envelope>

type MNBExchangeRates

type MNBExchangeRates struct {
	Days []DayRates `xml:"Day"`
}

type MNBExchangeRatesQueryValues

type MNBExchangeRatesQueryValues struct {
	FirstDate  Date
	LastDate   Date
	Currencies []string `xml:"Currencies>Curr"`
}

type MNBStoredInterval

type MNBStoredInterval struct {
	Interval DateInterval `xml:"DateInterva"`
}

type Rate

type Rate struct {
	Currency string `xml:"curr,attr"`
	Unit     int    `xml:"unit,attr"`
	Rate     Double `xml:",chardata"`
}

type Unit

type Unit struct {
	Currency string `xml:"curr,attr"`
	Unit     Double `xml:",chardata"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳