Class: BcnNi::Request
- Inherits:
-
Object
- Object
- BcnNi::Request
- Defined in:
- lib/bcn_ni/helpers/request.rb
Instance Method Summary collapse
- #exceptions ⇒ Object
- #exchange_day(year, month, day) ⇒ Object
- #exchange_month(year, month) ⇒ Object
-
#initialize(args = {}) ⇒ Request
constructor
A new instance of Request.
- #request_mode ⇒ Object
- #request_url ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Request
Returns a new instance of Request.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/bcn_ni/helpers/request.rb', line 32 def initialize(args = {}) @request_mode = (args[:request_mode] || :scrapping).to_sym @exceptions = [] case @request_mode when :scrapping @request_url = "https://www.bcn.gob.ni/IRR/tipo_cambio_mensual/mes.php" when :soap # See 'https://servicios.bcn.gob.ni/Tc_Servicio/ServicioTC.asmx' for more info about how to build a RAW SOAP request @request_url = "https://servicios.bcn.gob.ni/Tc_Servicio/ServicioTC.asmx?WSDL" else raise NotImplementedError, 'Request mode not implemented' end end |
Instance Method Details
#exceptions ⇒ Object
28 29 30 |
# File 'lib/bcn_ni/helpers/request.rb', line 28 def exceptions return @exceptions end |
#exchange_day(year, month, day) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/bcn_ni/helpers/request.rb', line 65 def exchange_day(year, month, day) begin # Evaluate scrapping mode to call the correct method for processing the request case request_mode when :scrapping return scra__exchange_day(year, month, day) when :soap return soap__exchange_day(year, month, day) end rescue Exception => e # Save the exception into the exception list for future error messages or debugging @exceptions.push e # Return an empty value according to the called method return nil end end |
#exchange_month(year, month) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/bcn_ni/helpers/request.rb', line 47 def exchange_month(year, month) begin # Evaluate scrapping mode to call the correct method for processing the request case request_mode when :scrapping return scra__exchange_month(year, month) when :soap return soap__exchange_month(year, month) end rescue Exception => e # Save the exception into the exception list for future error messages or debugging @exceptions.push e # Return an empty value according to the called method return [] end end |
#request_mode ⇒ Object
24 25 26 |
# File 'lib/bcn_ni/helpers/request.rb', line 24 def request_mode return @request_mode end |
#request_url ⇒ Object
20 21 22 |
# File 'lib/bcn_ni/helpers/request.rb', line 20 def request_url return @request_url end |