Class: Corrails::Directlog

Inherits:
Object
  • Object
show all
Defined in:
lib/corrails/directlog.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(wsdl = 'http://wsdirect.directlog.com.br/v2/wsdirectlog.asmx?wsdl') ⇒ Directlog

Returns a new instance of Directlog.



10
11
12
# File 'lib/corrails/directlog.rb', line 10

def initialize(wsdl='http://wsdirect.directlog.com.br/v2/wsdirectlog.asmx?wsdl')
  @client = Savon.client(wsdl);
end

Instance Attribute Details

#wsdlObject

Returns the value of attribute wsdl.



9
10
11
# File 'lib/corrails/directlog.rb', line 9

def wsdl
  @wsdl
end

Instance Method Details

#rastrear(login, password, pedido) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/corrails/directlog.rb', line 14

def rastrear(, password, pedido)
  resp = Response.new
  begin
    xml = "<?xml version="1.0" encoding="ISO-8859-1" ?><directlog><parametros><parametro name="pedido">#{pedido}</parametro></parametros></directlog>"
    response = @client.request :consulta_status_entrega, :xmlns => 'http://www.directlog.com.br/' do
      soap.namespaces["xmlns:soap"] = "http://schemas.xmlsoap.org/soap/envelope/"
      soap.body = "<login>#{}</login><password>#{password}</password><xml>#{xml}</xml><type>DEFAULT</type>" 
    end
    resp = Parser::DirectlogParser.parse(response)
  rescue => e
    resp.error_msg=e.message
  end
  resp
end