A simple gem to interact with the Mexican DOF open data service
Add this line to your application's Gemfile:
gem 'dof'
And then execute:
$ bundle
Or install it yourself as:
$ gem install dof
Add a new initializer and add the following lines
require "DOF"
DOF.config do |c|
c.base_uri = "https://sidofqa.segob.gob.mx/dof/sidof/"
end
To get the current (daily) exchange rate call USD_exchange_rate
DOF::Indicator.USD_exchange_rate
This will return an RequestResponse
object with the following attributes:
# An array of indicator objects
:indicators
# A request response confirmation
:response_code
# response status eg: 200/500
:response_status
# number of indicators found
:total_indicators
To get the current (daily) exchange rate call UDIS_exchange_rate
DOF::Indicator.UDIS_exchange_rate
You can call USD_exchange_rate
and UDIS_exchange_rate
with date params
DOF::Indicator.USD_exchange_rate(date: initial_date, end_date: end_date)
The accepted date formats are:
String
in mm/dd/YYYY formatString
in mm-dd-YYYY formatString
in mm.dd.YYYY formatDate
type, eg: Date.today
Bug reports and pull requests are welcome on GitHub at https://github.com/yellowme/DOF.