Module: Deliveries::Couriers::Envialia::Authentication

Includes:
HTTParty
Included in:
Labels::Generate, Pickups::Create, Pickups::Trace, Shipments::Create, Shipments::Trace
Defined in:
lib/deliveries/couriers/envialia/authentication.rb

Instance Method Summary collapse

Instance Method Details

#login_bodyObject



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/deliveries/couriers/envialia/authentication.rb', line 22

def 
  "    <soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">\n      <soapenv:Body>\n        <tns:LoginWSService___LoginCli2 xmlns:tns=\"http://tempuri.org/\">\n          <strCodAge>\#{Deliveries.courier(:envialia).config(:agency_code)}</strCodAge>\n          <strCliente>\#{Deliveries.courier(:envialia).config(:username)}</strCliente>\n          <strPass>\#{Deliveries.courier(:envialia).config(:password)}</strPass>\n        </tns:LoginWSService___LoginCli2>\n      </soapenv:Body>\n    </soapenv:Envelope>\n  XML\nend\n"

#login_endpointObject



40
41
42
43
44
45
46
# File 'lib/deliveries/couriers/envialia/authentication.rb', line 40

def 
  if Envialia.live?
    Envialia::
  else
    Envialia::
  end
end

#login_headersObject



36
37
38
# File 'lib/deliveries/couriers/envialia/authentication.rb', line 36

def 
  { 'Content-Type' => 'application/json;charset=UTF-8', 'Accept' => 'application/json' }
end

#session_idObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/deliveries/couriers/envialia/authentication.rb', line 9

def session_id
  response = HTTParty.post(
    ,
    body: ,
    headers: ,
    debug_output: Deliveries.debug ? Deliveries.logger : nil
  )

  raise Deliveries::ClientError unless response.success?

  response.dig('Envelope', 'Header', 'ROClientIDHeader', 'ID')
end