Class: Oca
- Inherits:
-
Object
- Object
- Oca
- Defined in:
- lib/oca-epak.rb
Constant Summary collapse
- WSDL =
'http://webservice.oca.com.ar/oep_tracking/Oep_Track.asmx?WSDL'.freeze
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#check_credentials(username, password) ⇒ Boolean
Checks if the user has input valid credentials.
-
#check_operation(cuit, op) ⇒ Boolean
Checks whether the operation is valid.
-
#get_shipping_rates(opts = {}) ⇒ Hash?
Get rates and delivery estimate for a shipment.
-
#initialize ⇒ Oca
constructor
A new instance of Oca.
-
#list_shipments(cuit, from_date, to_date) ⇒ Array?
Given a client’s CUIT with a range of dates, returns a list with all shipments made within the given period.
-
#provinces ⇒ Array?
Returns all provinces in Argentina.
-
#taxation_centers ⇒ Array?
Returns all existing Taxation Centers.
Constructor Details
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
4 5 6 |
# File 'lib/oca-epak.rb', line 4 def client @client end |
Instance Method Details
#check_credentials(username, password) ⇒ Boolean
Checks if the user has input valid credentials
17 18 19 20 21 22 23 24 25 |
# File 'lib/oca-epak.rb', line 17 def check_credentials(username, password) begin opts = { "usr" => username, "psw" => password } client.call(:generar_consolidacion_de_ordenes_de_retiro, message: opts) false rescue Savon::SOAPFault => e true end end |
#check_operation(cuit, op) ⇒ Boolean
Checks whether the operation is valid
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/oca-epak.rb', line 32 def check_operation(cuit, op) begin opts = { wt: "50", vol: "0.027", origin: "1414", destination: "5403", qty: "1", cuit: cuit, op: op } get_shipping_rates(opts) true rescue NoMethodError => e false end end |
#get_shipping_rates(opts = {}) ⇒ Hash?
Get rates and delivery estimate for a shipment
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/oca-epak.rb', line 54 def get_shipping_rates(opts = {}) method = :tarifar_envio_corporativo = { "PesoTotal" => opts[:wt], "VolumenTotal" => opts[:vol], "CodigoPostalOrigen" => opts[:origin], "CodigoPostalDestino" => opts[:destination], "CantidadPaquetes" => opts[:qty], "Cuit" => opts[:cuit], "Operativa" => opts[:op] } response = client.call(method, message: ) parse_results(method, response) end |
#list_shipments(cuit, from_date, to_date) ⇒ Array?
Given a client’s CUIT with a range of dates, returns a list with all shipments made within the given period.
81 82 83 84 85 86 87 |
# File 'lib/oca-epak.rb', line 81 def list_shipments(cuit, from_date, to_date) method = :list_envios opts = { "CUIT" => cuit, "FechaDesde" => from_date, "FechaHasta" => to_date } response = client.call(method, message: opts) parse_results(method, response) end |
#provinces ⇒ Array?
Returns all provinces in Argentina
92 93 94 95 96 97 |
# File 'lib/oca-epak.rb', line 92 def provinces response = client.call(:get_provincias) if body = response.body[:get_provincias_response] body[:get_provincias_result][:provincias][:provincia] end end |
#taxation_centers ⇒ Array?
Returns all existing Taxation Centers
68 69 70 71 72 |
# File 'lib/oca-epak.rb', line 68 def taxation_centers method = :get_centros_imposicion response = client.call(method) parse_results(method, response) end |