class Deliveries::Couriers::Envialia::Pickups::Trace
Attributes
tracking_code[RW]
Public Class Methods
new(tracking_code:)
click to toggle source
# File lib/deliveries/couriers/envialia/pickups/trace.rb, line 13 def initialize(tracking_code:) self.tracking_code = tracking_code end
Public Instance Methods
api_endpoint()
click to toggle source
# File lib/deliveries/couriers/envialia/pickups/trace.rb, line 58 def api_endpoint if Envialia.live? Envialia::ENVIALIA_ENDPOINT_LIVE else Envialia::ENVIALIA_ENDPOINT_TEST end end
body()
click to toggle source
# File lib/deliveries/couriers/envialia/pickups/trace.rb, line 37 def body <<~XML <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header> <tns:ROClientIDHeader xmlns:tns="http://tempuri.org/"> <tns:ID>#{session_id}</tns:ID> </tns:ROClientIDHeader> </soapenv:Header> <soapenv:Body> <tns:WebServService___ConsRecEstados xmlns:tns="http://tempuri.org/"> <tns:strCodRec>#{tracking_code}</tns:strCodRec> </tns:WebServService___ConsRecEstados> </soapenv:Body> </soapenv:Envelope> XML end
execute()
click to toggle source
# File lib/deliveries/couriers/envialia/pickups/trace.rb, line 17 def execute response = self.class.post( api_endpoint, body: body, headers: headers, debug_output: Deliveries.debug ? Deliveries.logger : nil ) raise Deliveries::ClientError unless response.success? if response.dig('Envelope', 'Body', 'WebServService___ConsRecEstadosResponse', 'strRecEstados').nil? raise Deliveries::APIError.new( 'No se han encontrado datos para este envĂo', '402' ) else response end end
headers()
click to toggle source
# File lib/deliveries/couriers/envialia/pickups/trace.rb, line 54 def headers { 'Content-Type' => 'application/json;charset=UTF-8', 'Accept' => 'application/json' } end