Class: Deliveries::Couriers::MondialRelayDual::Shipments::Create::FormatParams

Inherits:
Object
  • Object
show all
Defined in:
lib/deliveries/couriers/mondial_relay_dual/shipments/create/format_params.rb

Direct Known Subclasses

Pickups::Create::FormatParams

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sender:, receiver:, parcels:, reference_code:, collection_point:, remarks:, language:) ⇒ FormatParams

Returns a new instance of FormatParams.



9
10
11
12
13
14
15
16
17
# File 'lib/deliveries/couriers/mondial_relay_dual/shipments/create/format_params.rb', line 9

def initialize(sender:, receiver:, parcels:, reference_code:, collection_point:, remarks:, language:)
  self.sender = sender.courierize(:mondial_relay_dual)
  self.receiver = receiver.courierize(:mondial_relay_dual)
  self.parcels = parcels
  self.reference_code = reference_code
  self.collection_point = collection_point
  self.remarks = remarks
  self.language = language
end

Instance Attribute Details

#collection_pointObject

Returns the value of attribute collection_point.



7
8
9
# File 'lib/deliveries/couriers/mondial_relay_dual/shipments/create/format_params.rb', line 7

def collection_point
  @collection_point
end

#languageObject

Returns the value of attribute language.



7
8
9
# File 'lib/deliveries/couriers/mondial_relay_dual/shipments/create/format_params.rb', line 7

def language
  @language
end

#parcelsObject

Returns the value of attribute parcels.



7
8
9
# File 'lib/deliveries/couriers/mondial_relay_dual/shipments/create/format_params.rb', line 7

def parcels
  @parcels
end

#receiverObject

Returns the value of attribute receiver.



7
8
9
# File 'lib/deliveries/couriers/mondial_relay_dual/shipments/create/format_params.rb', line 7

def receiver
  @receiver
end

#reference_codeObject

Returns the value of attribute reference_code.



7
8
9
# File 'lib/deliveries/couriers/mondial_relay_dual/shipments/create/format_params.rb', line 7

def reference_code
  @reference_code
end

#remarksObject

Returns the value of attribute remarks.



7
8
9
# File 'lib/deliveries/couriers/mondial_relay_dual/shipments/create/format_params.rb', line 7

def remarks
  @remarks
end

#senderObject

Returns the value of attribute sender.



7
8
9
# File 'lib/deliveries/couriers/mondial_relay_dual/shipments/create/format_params.rb', line 7

def sender
  @sender
end

Instance Method Details

#executeObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/deliveries/couriers/mondial_relay_dual/shipments/create/format_params.rb', line 19

def execute
  {
    culture: culture,
    order_no: reference_code,
    parcel_count: parcels.to_i,
    delivery_mode: delivery_mode,
    collection_mode: collection_mode,
    deliver_instruction: remarks,
    parcels: parcel_list,
    sender: {
      streetname: sender.street,
      country_code: sender.country,
      post_code: sender.postcode,
      city: sender.city,
      address_add_1: sender.name,
      phone_no: sender.phone,
      email: sender.email
    },
    recipient: {
      streetname: receiver.street,
      country_code: receiver.country,
      post_code: receiver.postcode,
      city: receiver.city,
      address_add_1: receiver.name,
      phone_no: receiver.phone,
      email: receiver.email
    }
  }
end