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/"
endTo get the current (daily) exchange rate call USD_exchange_rate
DOF::Indicator.USD_exchange_rateThis 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_indicatorsTo get the current (daily) exchange rate call UDIS_exchange_rate
DOF::Indicator.UDIS_exchange_rateYou 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:
Stringin mm/dd/YYYY formatStringin mm-dd-YYYY formatStringin mm.dd.YYYY formatDatetype, eg: Date.today
Bug reports and pull requests are welcome on GitHub at https://github.com/yellowme/DOF.