Class: Deliveries::Couriers::MondialRelay::CollectionPoints::Search::FormatResponse

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

Constant Summary collapse

WEEKDAYS_STARTING_SUNDAY =
%w[
  dimanche
  lundi
  mardi
  mercredi
  jeudi
  vendredi
  samedi
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response:) ⇒ FormatResponse

Returns a new instance of FormatResponse.



43
44
45
# File 'lib/deliveries/couriers/mondial_relay/collection_points/search/format_response.rb', line 43

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

Instance Attribute Details

#responseObject

Returns the value of attribute response.



41
42
43
# File 'lib/deliveries/couriers/mondial_relay/collection_points/search/format_response.rb', line 41

def response
  @response
end

Instance Method Details

#executeObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/deliveries/couriers/mondial_relay/collection_points/search/format_response.rb', line 47

def execute
  point = {}

  point[:courier_id] = 'mondial_relay'
  point[:point_id] = response[:num]
  point[:country] = response[:pays]
  point[:city] = response[:ville].strip unless response[:ville].nil?
  point[:postcode] = response[:cp].strip unless response[:cp].nil?
  point[:url_map] = response[:url_plan]
  point[:latitude] = response[:latitude].tr(',', '.').to_f
  point[:longitude] = response[:longitude].tr(',', '.').to_f
  point[:timetable] = formatted_timetable(response)
  point[:url_photo] = response[:url_photo]
  point[:name] = response[:lg_adr1].strip
  point[:street] = response[:lg_adr3].strip

  point
end