Class: Oca::Oep::Client

Inherits:
BaseClient show all
Defined in:
lib/oca-epak/oep/client.rb

Constant Summary collapse

WSDL_URL =
"#{BASE_WSDL_URL}/oep_tracking/Oep_Track.asmx?wsdl".freeze

Constants inherited from BaseClient

BaseClient::BASE_WSDL_URL, BaseClient::FALSE_STRING

Instance Attribute Summary

Attributes inherited from BaseClient

#client, #password, #username

Instance Method Summary collapse

Constructor Details

#initialize(username, password) ⇒ Client

Returns a new instance of Client.



6
7
8
9
10
# File 'lib/oca-epak/oep/client.rb', line 6

def initialize(username, password)
  super
  @opts = { wsdl: WSDL_URL }.merge(Oca::Logger.options)
  @client = Savon.client(@opts)
end

Instance Method Details

#get_html_de_etiquetas_por_orden_or_numero_envio(opts = {}) ⇒ String

Returns the HTML for a label

Parameters:

  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :id_orden_retiro (Integer)
  • :nro_envio (String)

Returns:

  • (String)

    HTML



18
19
20
21
22
23
24
# File 'lib/oca-epak/oep/client.rb', line 18

def get_html_de_etiquetas_por_orden_or_numero_envio(opts = {})
  method = :get_html_de_etiquetas_por_orden_or_numero_envio
  opts = { "idOrdenRetiro" => opts[:id_orden_retiro],
           "nroEnvio" => opts[:nro_envio] }
  response = client.call(method, message: opts)
  parse_result(response, method)
end

#get_pdf_de_etiquetas_por_orden_or_numero_envio(opts = {}) ⇒ String

Returns the PDF (Base64 encoded) String for a label

Parameters:

  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :id_orden_retiro (Integer)
  • :nro_envio (String)
  • :logistica_inversa (Boolean)

Returns:

  • (String)

    PDF data Base64 encoded



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/oca-epak/oep/client.rb', line 33

def get_pdf_de_etiquetas_por_orden_or_numero_envio(opts = {})
  method = :get_pdf_de_etiquetas_por_orden_or_numero_envio
  opts = {
    "idOrdenRetiro" => opts[:id_orden_retiro],
    "nroEnvio" => opts[:nro_envio],
    "logisticaInversa" => opts.fetch(:logistica_inversa, FALSE_STRING).to_s
  }
  response = client.call(method, message: opts)
  parse_result(response, method)
rescue Savon::SOAPFault => error
  msg = "Oca WS responded with:\n#{error.http.code}\n#{error}"
  raise Oca::Errors::BadRequest.new(msg)
end