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_body ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/deliveries/couriers/envialia/authentication.rb', line 22 def login_body " <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_endpoint ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/deliveries/couriers/envialia/authentication.rb', line 40 def login_endpoint if Envialia.live? Envialia::ENVIALIA_LOGIN_ENDPOINT_LIVE else Envialia::ENVIALIA_LOGIN_ENDPOINT_TEST end end |
#login_headers ⇒ Object
36 37 38 |
# File 'lib/deliveries/couriers/envialia/authentication.rb', line 36 def login_headers { 'Content-Type' => 'application/json;charset=UTF-8', 'Accept' => 'application/json' } end |
#session_id ⇒ Object
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( login_endpoint, body: login_body, headers: login_headers, debug_output: Deliveries.debug ? Deliveries.logger : nil ) raise Deliveries::ClientError unless response.success? response.dig('Envelope', 'Header', 'ROClientIDHeader', 'ID') end |