Class: Deliveries::Couriers::CorreosExpress::CollectionPoints::Search::FormatResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/deliveries/couriers/correos_express/collection_points/search/format_response.rb

Constant Summary collapse

SATURDAY_HOUR_KEY =
'S:'.freeze
WORKDAY_HOUR_KEY =
'L-V:'.freeze
HOLIDAY_HOUR_KEY =
'Festivos:'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response:) ⇒ FormatResponse

Returns a new instance of FormatResponse.



22
23
24
# File 'lib/deliveries/couriers/correos_express/collection_points/search/format_response.rb', line 22

def initialize(response:)
  self.response = response
end

Instance Attribute Details

#responseObject

Returns the value of attribute response.



20
21
22
# File 'lib/deliveries/couriers/correos_express/collection_points/search/format_response.rb', line 20

def response
  @response
end

Instance Method Details

#executeObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/deliveries/couriers/correos_express/collection_points/search/format_response.rb', line 26

def execute
  collection_point = {}
  collection_point[:courier_id] = 'correos_express'
  collection_point[:name] = response['nombreOficina']
  collection_point[:point_id] = response['codigoOficina']
  collection_point[:street] = response['direccionOficina']
  collection_point[:city] = response['poblacionOficina']
  collection_point[:postcode] = response['codigoPostalOficina']
  latitude, longitude = response['geoposicionOficina'].split(',')
  collection_point[:latitude] = latitude.to_f
  collection_point[:longitude] = longitude.to_f
  collection_point[:timetable] = formatted_timetable(response['horarioOficina'])

  collection_point
end