Class: Deliveries::Couriers::Envialia::Pickups::Trace::FormatResponse
- Inherits:
-
Object
- Object
- Deliveries::Couriers::Envialia::Pickups::Trace::FormatResponse
- Defined in:
- lib/deliveries/couriers/envialia/pickups/trace/format_response.rb
Constant Summary collapse
- STATUS_CODES =
{ 'R0' => 'Solicitada', 'R1' => 'Lectura en delegaciĆ³n', 'R2' => 'Asignada', 'R3' => 'Incidencia', 'R4' => 'Realizada', 'R5' => 'Pendiente de asignaciĆ³n', 'R6' => 'Recogida fallida', 'R7' => 'Finalizada', 'R8' => 'Anulada', 'R9' => 'Lectura repartidor' }.freeze
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(response:) ⇒ FormatResponse
constructor
A new instance of FormatResponse.
Constructor Details
#initialize(response:) ⇒ FormatResponse
Returns a new instance of FormatResponse.
13 14 15 |
# File 'lib/deliveries/couriers/envialia/pickups/trace/format_response.rb', line 13 def initialize(response:) self.response = response end |
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
11 12 13 |
# File 'lib/deliveries/couriers/envialia/pickups/trace/format_response.rb', line 11 def response @response end |
Instance Method Details
#execute ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/deliveries/couriers/envialia/pickups/trace/format_response.rb', line 30 def execute body = response.dig('Envelope', 'Body', 'WebServService___ConsRecEstadosResponse', 'strRecEstados') parsed_response = Hash.from_xml(body).dig('CONSULTA', 'REC_ESTADOS') checkpoints = formatted_checkpoints(parsed_response) tracking_info_params = {} tracking_info_params[:courier_id] = 'envialia' tracking_info_params[:tracking_code] = nil tracking_info_params[:status] = checkpoints.last.try(:status) tracking_info_params[:checkpoints] = checkpoints tracking_info_params end |