exchangecr
v0.3.1
Published
Nodejs utility to consult the rate exchange from The Central Bank of Costa Rica
Downloads
23
Readme
ExchangeCR
Nodejs utility to consult the rate exchange (Us Dollar / Euro -> Colon) from The Central Bank of Costa Rica
Table of contents
Installation
$ npm install exchangecr --save
Common usage
import { UsDollar, Euro } from 'exchangecr'
const dollar = new UsDollar()
await dollar.exchange() // { date: '00/00/0000', purchaseRate: 000.00, saleRate: 000.00 }
const euro = new Euro()
await euro.exchange() // { date: '00/00/0000', rate: 000.00 }
Configuration Options
The exchange methods support range of dates (should be in EU format DD/MM/YYYY), one date or even no date.
Examples
If there is no params exchange
returns the exchange of today
await dollar.exchange()
// { date: '00/00/0000', purchaseRate: 000.00, saleRate: 000.00 }
If there is one date exchange
returns a exchange object
await dollar.exchange('25/12/2018')
// { date: '25/12/2018', purchaseRate: 000.00, saleRate: 000.00 }
If there is a range of dates exchange
returns a exchange array
await dollar.exchange('25/12/2018', '26/12/2018')
// [
// { date: '25/12/2018', purchaseRate: 000.00, saleRate: 000.00 },
// { date: '26/12/2018', purchaseRate: 000.00, saleRate: 000.00 }
// ]
For euro there is only one rate (no purchase and sale rates). Usually with poor support from the bank for updates dates, works fine with 3 days of delay
await euro.exchange('25/12/2018', '26/12/2018')
// [
// { date: '25/12/2018', rate: 000.00 },
// { date: '26/12/2018', rate: 000.00 }
// ]
Disclaimer
- The information is from web service of The Central Bank of Costa Rica, so check the availability of the service before opening an issue
Feel free to dive in! Open an issue or submit PRs.