Class: FE::Data
- Inherits:
-
Object
- Object
- FE::Data
- Defined in:
- lib/facturacr/data.rb
Constant Summary collapse
- ENDPOINT =
"https://api.hacienda.go.cr"
Class Method Summary collapse
- .contributor(id_number) ⇒ Object
- .exchange_rate(currency = "USD") ⇒ Object
- .exonerations(id_number) ⇒ Object
Class Method Details
.contributor(id_number) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/facturacr/data.rb', line 10 def self.contributor(id_number) response = RestClient.get "#{ENDPOINT}/fe/ae?identificacion=#{id_number}" return JSON.parse(response.body).with_indifferent_access rescue => e puts "FE::Data.contributor(#{id_number}) #{e.}" return nil end |
.exchange_rate(currency = "USD") ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/facturacr/data.rb', line 18 def self.exchange_rate(currency = "USD") if currency.eql?("USD") path = "tc/dolar" elsif currency.eql?("EUR") path = "tc/euro" else raise "#{currency} is not a valid argument" end response = RestClient.get "#{ENDPOINT}/indicadores/#{path}" return JSON.parse(response.body).with_indifferent_access rescue => e puts "FE::Data.exchange_rate(#{currency}) #{e.}" return nil end |
.exonerations(id_number) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/facturacr/data.rb', line 33 def self.exonerations(id_number) response = RestClient.get "#{ENDPOINT}/fe/ex?identificacion=#{id_number}" return JSON.parse(response.body).with_indifferent_access rescue => e puts "FE::Data.exonerations(#{id_number}) #{e.}" return nil end |