dhl_ecommerce_api 0.1.12 → 0.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 313e4f0218fc7c15423ff488ebd28927d61f253235e8baf70ea95dacf19dfe0c
4
- data.tar.gz: 4f9ccb99bad33a08025c15d6d442e86dbbf433e2cd9d19362ab9fd1ee825b362
3
+ metadata.gz: ddc6328d0bd244a84d7aee00a96890d1d7003d227fc46357312f7f7bba3da896
4
+ data.tar.gz: 3d0359ea889a9e13099995118cb3a8b16f5d5f169ca4133e09c4a1690d0f70e2
5
5
  SHA512:
6
- metadata.gz: f6db6ce2275c4fbf285a9845ac69cd653bc9e1a642872612adb1c74b1d69dcb7c9ab6e63a1305b28516bacd7f272bcda45cdbfd270f7fff2a77286a7aecce998
7
- data.tar.gz: 93ed8643180a3d55b0cc7573c834ecc6d6c3b73d38418c56a88a8aa2e3bbe9d32debda883e59711df33d136c5be307560a0809dd8231fcbab88890247af6f8ef
6
+ metadata.gz: 19111a620dab055825fec90fad626d3ec902712b2a8b58b494cd1130501b6fb315f252c724200bd20402139605f011353909984bdfe2a9dbdf20c57358667b6d
7
+ data.tar.gz: e8399ea8631e95c336c9c86abf7c608be5013b5ea1d51219e7561c47a05bc4af409c4b013512500522b2b4418fe935a63e1e231785bd6dc0458747d8ee485fab
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dhl_ecommerce_api (0.1.7)
4
+ dhl_ecommerce_api (0.1.14)
5
5
  activeresource (>= 4.1.0, < 6.0.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activemodel (6.1.4.6)
11
- activesupport (= 6.1.4.6)
10
+ activemodel (6.1.5)
11
+ activesupport (= 6.1.5)
12
12
  activemodel-serializers-xml (1.0.2)
13
13
  activemodel (> 5.x)
14
14
  activesupport (> 5.x)
@@ -17,7 +17,7 @@ GEM
17
17
  activemodel (>= 5.0, < 7)
18
18
  activemodel-serializers-xml (~> 1.0)
19
19
  activesupport (>= 5.0, < 7)
20
- activesupport (6.1.4.6)
20
+ activesupport (6.1.5)
21
21
  concurrent-ruby (~> 1.0, >= 1.0.2)
22
22
  i18n (>= 1.6, < 2)
23
23
  minitest (>= 5.1)
@@ -5,7 +5,6 @@ module DHLEcommerceAPI
5
5
  payload[:method] = method
6
6
  payload[:request_uri] = "#{site.scheme}://#{site.host}:#{site.port}#{path}"
7
7
  payload[:result] = http.send(method, path, *arguments)
8
- # debug outgoing request here if needed
9
8
  end
10
9
 
11
10
  handle_response(result)
@@ -5,50 +5,24 @@ module DHLEcommerceAPI
5
5
  self.include_format_in_path = false
6
6
  self.connection_class = Connection
7
7
 
8
- # by default convert to lowerCamelcase before sending request
9
- def to_json(options = {})
10
- attributes.as_json
11
- .deep_transform_keys { |k| k.to_s.camelize(:lower) }
12
- .to_json(include_root_in_json ? { root: self.class.element_name }.merge(options) : options)
13
- end
14
-
15
- # by default convert to snake_case when initializing
16
- def load(attributes, remove_root = false, persisted = false)
17
- # convert loaded attributes to underscore, then symbolize
18
- attributes.deep_transform_keys! { |k| k.to_s.underscore.to_sym }
19
-
20
- # merge default_attrs(symbols) with incoming attributes
21
- if defined?(self.class::DEFAULT_ATTRIBUTES)
22
- attributes = self.class::DEFAULT_ATTRIBUTES.merge(attributes)
23
- end
24
- super
25
- end
26
-
27
8
  def attributes_with_account_ids
28
9
  account_ids.merge(attributes)
29
10
  end
30
11
 
31
12
  def account_ids
32
13
  {
33
- pickup_account_id: DHLEcommerceAPI.config.pickup_account_id,
34
- sold_to_account_id: DHLEcommerceAPI.config.sold_to_account_id,
14
+ "pickupAccountId": DHLEcommerceAPI.config.pickup_account_id,
15
+ "soldToAccountId": DHLEcommerceAPI.config.sold_to_account_id,
35
16
  }
36
17
  end
37
18
 
38
19
  def handle_errors(code, error_messages)
39
20
  errors.add(:base, "#{code} - #{error_messages.join(", ")}")
40
21
  end
41
-
42
- # Since request_data isnt the same as object attributes.
43
- # We have to write our own method to format the request data
44
- def formatted_request_data(request_data)
45
- request_data.as_json
46
- .deep_transform_keys {|key| custom_key_format(key)}.to_json
47
- end
48
22
 
49
23
  # custom keys that arent following lowerCamel convention
50
24
  def custom_key_format(key)
51
- case key
25
+ case key.to_s
52
26
  when "shipment_id"
53
27
  "shipmentID"
54
28
  when "total_weight_uom"
@@ -9,7 +9,8 @@ module DHLEcommerceAPI
9
9
 
10
10
  def create
11
11
  run_callbacks :create do
12
- connection.post(collection_path, formatted_request_data(pickup_request), self.class.headers).tap do |response|
12
+ connection.post(collection_path, pickup_request.to_json, self.class.headers).tap do |response|
13
+ self.id = id_from_response(response)
13
14
  load_attributes_from_response(response)
14
15
  end
15
16
  end
@@ -35,56 +36,58 @@ module DHLEcommerceAPI
35
36
  @persisted = false
36
37
  end
37
38
 
38
- new_attributes = attributes.merge(bd)
39
+ new_attributes = attributes.merge({response: JSON.parse(response.body)})
40
+
39
41
  load(new_attributes, true, @persisted)
40
42
  end
41
43
  end
42
44
 
43
45
  def pickup_request
44
46
  {
45
- pickup_request: {
46
- hdr: headers,
47
- bd: attributes_with_account_ids.deep_transform_keys {|key| key.to_s.underscore.to_sym }
47
+ "pickupRequest": {
48
+ "hdr": headers,
49
+ "bd": attributes_with_account_ids
48
50
  }
49
51
  }
50
52
  end
51
53
 
52
54
  def headers
53
55
  {
54
- message_type: "PICKUP",
55
- message_date_time: DateTime.now.to_s,
56
- access_token: DHLEcommerceAPI::Authentication.get_token,
57
- message_version: "1.2"
56
+ "messageType": "PICKUP",
57
+ "messageDateTime": DateTime.now.to_s,
58
+ "accessToken": DHLEcommerceAPI::Authentication.get_token,
59
+ "messageVersion": "1.2"
58
60
  }
59
61
  end
60
62
  end
61
63
  end
62
-
63
- # example_pickup_params = {
64
- # "handover_items": [
65
- # {
66
- # "pickup_date": "2022-03-09",
67
- # "pickup_start_time": "09:00",
68
- # "pickup_end_time": "18:00",
69
- # "shipment_type": "1",
70
- # "notification_email": nil,
71
- # "shipper_details": {
72
- # "company": "PostCo",
73
- # "name": "PostCo",
74
- # "email_id": nil,
75
- # "phone_number": "0169822645",
76
- # "address_line_1": "no 26 jalan 31/123, petaling jaya",
77
- # "address_line_2": nil,
78
- # "address_line_3": nil,
79
- # "city": "Kuala Lumpur",
80
- # "state": "Kuala Lumpur",
81
- # "postal_code": "57000",
82
- # "country": "MY",
83
- # },
84
- # "shipments": {
85
- # "quantity": 1,
86
- # "totalWeight": 100
87
- # }
88
- # }
89
- # ]
90
- # }
64
+ =begin
65
+ pickup_params = {
66
+ "handoverItems": [
67
+ {
68
+ "pickupDate": "2022-03-17",
69
+ "pickupStartTime": "09:00",
70
+ "pickupEndTime": "18:00",
71
+ "shipmentType": "1",
72
+ "notificationEmail": nil,
73
+ "shipperDetails": {
74
+ "company": "PostCo",
75
+ "name": "PostCo",
76
+ "emailID": nil,
77
+ "phoneNumber": "0169822645",
78
+ "addressLine1": "no 26 jalan 31/123, petaling jaya",
79
+ "addressLine2": nil,
80
+ "addressLine3": nil,
81
+ "city": "Kuala Lumpur",
82
+ "state": "Kuala Lumpur",
83
+ "postalCode": "57000",
84
+ "country": "MY",
85
+ },
86
+ "shipments": {
87
+ "quantity": 1,
88
+ "totalWeight": 100
89
+ }
90
+ }
91
+ ]
92
+ }
93
+ =end
@@ -3,39 +3,6 @@ module DHLEcommerceAPI
3
3
  class Shipment::ShipmentItem < Base
4
4
  self.element_name = ""
5
5
 
6
- # add some validations?
7
- DEFAULT_ATTRIBUTES = {
8
- shipment_id: nil,
9
- package_desc: "",
10
- total_weight: nil,
11
- total_weight_uom: "G",
12
- dimension_uom: "CM",
13
- height: nil,
14
- length: nil,
15
- width: nil,
16
- product_code: "PDO",
17
- cod_value: nil,
18
- insurance_value: nil,
19
- total_value: 300,
20
- currency: "MYR",
21
- remarks: nil,
22
- is_routing_info_required: "Y",
23
- consignee_address: {
24
- company_name: "",
25
- name: "",
26
- address1: "",
27
- address2: nil,
28
- address3: nil,
29
- city: "",
30
- state: "",
31
- district: nil,
32
- country: "MY",
33
- post_code: "",
34
- phone: "",
35
- email: nil
36
- }
37
- }
38
-
39
6
  def initialize(attributes = {}, persisted = false)
40
7
  status = attributes["response_status"]
41
8
  if status.present? && status["code"] != "200"
@@ -5,13 +5,11 @@ module DHLEcommerceAPI
5
5
 
6
6
  self.prefix = "/rest/v3/Shipment"
7
7
  self.element_name = ""
8
-
9
- validates_presence_of :handover_method
10
8
 
11
9
  def create
12
10
  run_callbacks :create do
13
- data = formatted_request_data(manifest_request)
14
- connection.post(collection_path, data, self.class.headers).tap do |response|
11
+ connection.post(collection_path, manifest_request.to_json, self.class.headers).tap do |response|
12
+ self.id = id_from_response(response)
15
13
  load_attributes_from_response(response)
16
14
  end
17
15
  end
@@ -29,90 +27,169 @@ module DHLEcommerceAPI
29
27
  if code == "200"
30
28
  @persisted = true
31
29
  elsif code == "204"
32
- # handle partial success
33
30
  @persisted = false
34
31
  else
35
32
  error_messages = response_status["messageDetails"].map{|err| err["messageDetail"]}
36
33
  handle_errors(code, error_messages)
37
34
  @persisted = false
38
35
  end
36
+
37
+ # service level
38
+ new_attributes = attributes.merge({response: JSON.parse(response.body)})
39
+
40
+ # object level
41
+ new_attributes["shipmentItems"] = new_attributes["shipmentItems"].map do |item|
42
+ item.attributes.merge(bd["shipmentItems"].find{|i| i["shipmentID"] == item.shipmentID})
43
+ end
39
44
 
40
- new_attributes = attributes.merge(bd)
41
45
  load(new_attributes, true, @persisted)
42
46
  end
43
47
  end
44
48
 
45
49
  def manifest_request
46
50
  {
47
- manifest_request: {
48
- hdr: headers,
49
- bd: attributes_with_account_ids.deep_transform_keys {|key| key.to_s.underscore.to_sym }
51
+ "manifestRequest": {
52
+ "hdr": headers,
53
+ "bd": attributes_with_account_ids
50
54
  }
51
55
  }
52
56
  end
53
57
 
54
58
  def headers
55
59
  {
56
- message_type: "SHIPMENT",
57
- message_date_time: DateTime.now.to_s,
58
- access_token: DHLEcommerceAPI::Authentication.get_token,
59
- message_version: "1.0"
60
+ "messageType": "SHIPMENT",
61
+ "messageDateTime": DateTime.now.to_s,
62
+ "accessToken": DHLEcommerceAPI::Authentication.get_token,
63
+ "messageVersion": "1.0"
60
64
  }
61
65
  end
62
66
  end
63
67
  end
64
68
 
65
69
  # Examples:
66
- # shipment_with_pickup_params = {
67
- # "handoverMethod": 2,
68
- # "pickupDateTime": DateTime.now.to_s,
69
- # "pickupAddress": {
70
- # "companyName": "Pickup From Company",
71
- # "name": "Pickup From Name",
72
- # "address1": "Holistic Pharmacy PostCo, 55, Jalan Landak",
73
- # "address2": "",
74
- # "address3": "",
75
- # "city": " Kuala Lumpur",
76
- # "state": " Kuala Lumpur",
77
- # "postCode": "55100",
78
- # "country": "MY",
79
- # "phone": "0123456789",
80
- # "email": "hello@example.com"
81
- # },
82
- # "shipmentItems": [
83
- # {
84
- # "shipmentID": "MYPTC0083",
85
- # "packageDesc": "Laptop Sleeve",
86
- # "totalWeight": 500,
87
- # "totalWeightUOM": "G",
88
- # "dimensionUOM": "CM",
89
- # "height": nil,
90
- # "length": nil,
91
- # "width": nil,
92
- # "productCode": "PDO",
93
- # "codValue": nil,
94
- # "insuranceValue": nil,
95
- # "totalValue": 300,
96
- # "currency": "MYR",
97
- # "remarks": nil,
98
- # "isRoutingInfoRequired": "Y",
99
- # "consigneeAddress": {
100
- # "companyName": "Sleeve Company",
101
- # "name": "Sleeve Sdn Bhd",
102
- # "address1": "No. 3, Jalan Bangsar, Kampung Haji Abdullah Hukum",
103
- # "address2": nil,
104
- # "address3": nil,
105
- # "city": "Kuala Lumpur",
106
- # "state": "Kuala Lumpur",
107
- # "district": nil,
108
- # "country": "MY",
109
- # "postCode": "59200",
110
- # "phone": "0169822645",
111
- # "email": nil
112
- # }
113
- # },
114
- # ]
115
- # }
70
+ =begin
71
+ shipment_with_pickup_params = {
72
+ "handoverMethod": 2,
73
+ "pickupDateTime": DateTime.now.to_s,
74
+ "pickupAddress": {
75
+ "companyName": "Pickup From Company",
76
+ "name": "Pickup From Name",
77
+ "address1": "Holistic Pharmacy PostCo, 55, Jalan Landak",
78
+ "address2": "",
79
+ "address3": "",
80
+ "city": " Kuala Lumpur",
81
+ "state": " Kuala Lumpur",
82
+ "postCode": "55100",
83
+ "country": "MY",
84
+ "phone": "0123456789",
85
+ "email": "hello@example.com"
86
+ },
87
+ "shipperAddress": {
88
+ "companyName": "Pickup From Company",
89
+ "name": "Pickup From Name",
90
+ "address1": "Holistic Pharmacy PostCo, 55, Jalan Landak",
91
+ "address2": "",
92
+ "address3": "",
93
+ "city": " Kuala Lumpur",
94
+ "state": " Kuala Lumpur",
95
+ "postCode": "55100",
96
+ "country": "MY",
97
+ "phone": "0123456789",
98
+ "email": "hello@example.com"
99
+ },
100
+ "shipmentItems": [
101
+ {
102
+ "shipmentID": "MYPTC0090",
103
+ "packageDesc": "Laptop Sleeve",
104
+ "totalWeight": 500,
105
+ "totalWeightUOM": "G",
106
+ "dimensionUOM": "CM",
107
+ "height": nil,
108
+ "length": nil,
109
+ "width": nil,
110
+ "productCode": "PDO",
111
+ "codValue": nil,
112
+ "insuranceValue": nil,
113
+ "totalValue": 300,
114
+ "currency": "MYR",
115
+ "remarks": nil,
116
+ "isRoutingInfoRequired": "Y",
117
+ "consigneeAddress": {
118
+ "companyName": "Sleeve Company",
119
+ "name": "Sleeve Sdn Bhd",
120
+ "address1": "No. 3, Jalan Bangsar, Kampung Haji Abdullah Hukum",
121
+ "address2": nil,
122
+ "address3": nil,
123
+ "city": "Kuala Lumpur",
124
+ "state": "Kuala Lumpur",
125
+ "district": nil,
126
+ "country": "MY",
127
+ "postCode": "59200",
128
+ "phone": "0169822645",
129
+ "email": nil
130
+ },
131
+ "returnMode": "03",
132
+ "returnAddress": {
133
+ "companyName": "Pickup From Company",
134
+ "name": "Pickup From Name",
135
+ "address1": "Holistic Pharmacy PostCo, 55, Jalan Landak",
136
+ "address2": "",
137
+ "address3": "",
138
+ "city": " Kuala Lumpur",
139
+ "state": " Kuala Lumpur",
140
+ "postCode": "55100",
141
+ "country": "MY",
142
+ "phone": "0123456789",
143
+ "email": "hello@example.com"
144
+ }
145
+ },
146
+ {
147
+ "shipmentID": "MYPTC0089",
148
+ "totalWeight": 500,
149
+ "totalWeightUOM": "G",
150
+ "dimensionUOM": "CM",
151
+ "height": nil,
152
+ "length": nil,
153
+ "width": nil,
154
+ "productCode": "PDO",
155
+ "codValue": nil,
156
+ "insuranceValue": nil,
157
+ "totalValue": 300,
158
+ "currency": "MYR",
159
+ "remarks": nil,
160
+ "isRoutingInfoRequired": "Y",
161
+ "consigneeAddress": {
162
+ "companyName": "Sleeve Company",
163
+ "name": "Sleeve Sdn Bhd",
164
+ "address1": "No. 3, Jalan Bangsar, Kampung Haji Abdullah Hukum",
165
+ "address2": nil,
166
+ "address3": nil,
167
+ "city": "Kuala Lumpur",
168
+ "state": "Kuala Lumpur",
169
+ "district": nil,
170
+ "country": "MY",
171
+ "postCode": "59200",
172
+ "phone": "0169822645",
173
+ "email": nil
174
+ },
175
+ "returnMode": "03",
176
+ "returnAddress": {
177
+ "companyName": "Pickup From Company",
178
+ "name": "Pickup From Name",
179
+ "address1": "Holistic Pharmacy PostCo, 55, Jalan Landak",
180
+ "address2": "",
181
+ "address3": "",
182
+ "city": " Kuala Lumpur",
183
+ "state": " Kuala Lumpur",
184
+ "postCode": "55100",
185
+ "country": "MY",
186
+ "phone": "0123456789",
187
+ "email": "hello@example.com"
188
+ }
189
+ },
190
+ ]
191
+ }
192
+ =end
116
193
 
117
194
  # shipment_with_dropoff_params = {
118
195
  # "handover_method" => 1,
@@ -1,12 +1,5 @@
1
1
  module DHLEcommerceAPI
2
2
  class Tracking < Base
3
- # example_tracking_params = {
4
- # "e_pod_required": "Y",
5
- # "trackingReferenceNumber": [
6
- # "MYPTC00012", "MYPTC00013"
7
- # ]
8
- # }
9
-
10
3
  self.prefix = "/rest/v3/Tracking"
11
4
  self.element_name = ""
12
5
 
@@ -17,16 +10,17 @@ module DHLEcommerceAPI
17
10
 
18
11
  def self.find(arguments)
19
12
  tracking = self.new({
20
- e_pod_required: "Y",
21
- tracking_reference_number: arguments.is_a?(Array) ? arguments : [arguments]
13
+ "ePODRequired": "Y",
14
+ "trackingReferenceNumber": arguments.is_a?(Array) ? arguments : [arguments]
22
15
  })
23
16
  tracking.save
17
+
24
18
  return tracking.shipment_items.presence || []
25
19
  end
26
20
 
27
21
  def create
28
22
  run_callbacks :create do
29
- connection.post(collection_path, formatted_request_data(request_data), self.class.headers).tap do |response|
23
+ connection.post(collection_path, request_data.to_json, self.class.headers).tap do |response|
30
24
  load_attributes_from_response(response)
31
25
  end
32
26
  end
@@ -52,37 +46,38 @@ module DHLEcommerceAPI
52
46
  @persisted = false
53
47
  end
54
48
 
55
- new_attributes = attributes.merge(bd)
49
+ new_attributes = attributes.merge({response: JSON.parse(response.body)})
50
+ new_attributes = new_attributes.merge({shipment_items: bd["shipmentItems"]})
51
+
56
52
  load(new_attributes, true, @persisted)
57
53
  end
58
54
  end
59
55
 
60
56
  def request_data
61
57
  {
62
- track_item_request: {
63
- hdr: headers,
64
- bd: attributes.except("response_status") # dont send responseStatus
58
+ "trackItemRequest": {
59
+ "hdr": headers,
60
+ "bd": attributes.except("response_status") # dont send responseStatus
65
61
  }
66
62
  }
67
63
  end
68
64
 
69
65
  def headers
70
66
  {
71
- message_type: "TRACKITEM",
72
- message_date_time: DateTime.now.to_s,
73
- access_token: DHLEcommerceAPI::Authentication.get_token,
74
- message_version: "1.0"
67
+ "messageType": "TRACKITEM",
68
+ "messageDateTime": DateTime.now.to_s,
69
+ "accessToken": DHLEcommerceAPI::Authentication.get_token,
70
+ "messageVersion": "1.0"
75
71
  }
76
72
  end
77
-
78
-
79
- # Since request_data isnt the same as object attributes.
80
- # We have to write our own method to format the request data
81
- def formatted_request_data(request_data)
82
- request_data.as_json
83
- .deep_transform_keys do |key|
84
- custom_key_format(key) # method from Base
85
- end.to_json
86
- end
87
73
  end
88
- end
74
+ end
75
+
76
+ =begin
77
+ example_tracking_params = {
78
+ "ePODRequired": "Y",
79
+ "trackingReferenceNumber": [
80
+ "MYPTC00012", "MYPTC00013"
81
+ ]
82
+ }
83
+ =end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DHLEcommerceAPI
4
- VERSION = "0.1.12"
4
+ VERSION = "0.1.15"
5
5
  end
@@ -9,16 +9,10 @@ module DHLEcommerceAPI
9
9
  require "dhl_ecommerce_api/connection"
10
10
 
11
11
  require "dhl_ecommerce_api/resources/base"
12
+
12
13
  require "dhl_ecommerce_api/resources/authentication"
13
14
 
14
- require "dhl_ecommerce_api/resources/shipment"
15
- require "dhl_ecommerce_api/resources/shipment_with_pickup"
16
- require "dhl_ecommerce_api/resources/shipment_with_dropoff"
17
-
18
- require "dhl_ecommerce_api/resources/shipment/shipment_item"
19
- require "dhl_ecommerce_api/resources/shipment/shipment_item/consignee_address"
20
-
15
+ require "dhl_ecommerce_api/resources/shipment"
21
16
  require "dhl_ecommerce_api/resources/pickup"
22
-
23
17
  require "dhl_ecommerce_api/resources/tracking"
24
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dhl_ecommerce_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Er Whey
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-16 00:00:00.000000000 Z
11
+ date: 2022-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeresource
@@ -140,12 +140,8 @@ files:
140
140
  - lib/dhl_ecommerce_api/resources/base.rb
141
141
  - lib/dhl_ecommerce_api/resources/event.rb
142
142
  - lib/dhl_ecommerce_api/resources/pickup.rb
143
- - lib/dhl_ecommerce_api/resources/pickup/handover_item.rb
144
143
  - lib/dhl_ecommerce_api/resources/shipment.rb
145
144
  - lib/dhl_ecommerce_api/resources/shipment/shipment_item.rb
146
- - lib/dhl_ecommerce_api/resources/shipment/shipment_item/consignee_address.rb
147
- - lib/dhl_ecommerce_api/resources/shipment_with_dropoff.rb
148
- - lib/dhl_ecommerce_api/resources/shipment_with_pickup.rb
149
145
  - lib/dhl_ecommerce_api/resources/tracking.rb
150
146
  - lib/dhl_ecommerce_api/version.rb
151
147
  - sig/dhl_ecommerce_api.rbs
@@ -1,12 +0,0 @@
1
- module DHLEcommerceAPI
2
- class Pickup::HandoverItem < Base
3
- def initialize(attributes = {}, persisted = false)
4
- status = attributes["response_status"]
5
- if status.present? && status["code"] != "200"
6
- error_messages = status["message_details"].map{|err| err["message_detail"]}
7
- handle_errors(status["code"], error_messages)
8
- end
9
- super
10
- end
11
- end
12
- end
@@ -1,6 +0,0 @@
1
- module DHLEcommerceAPI
2
- # Component item
3
- class Shipment::ShipmentItem::ConsigneeAddress < Base
4
- self.element_name = ""
5
- end
6
- end
@@ -1,52 +0,0 @@
1
- module DHLEcommerceAPI
2
- class ShipmentWithDropoff < Shipment
3
- # This creates a Shipment ONLY.
4
- # DHL will expect the item to be dropped off at one of their locations.
5
- # Used in conjunction with the Pickup class.
6
-
7
- self.element_name = ""
8
-
9
- DEFAULT_ATTRIBUTES = {
10
- handover_method: 1,
11
- shipment_items: []
12
- }
13
- end
14
- end
15
-
16
- =begin
17
- shipment_with_dropoff_params = {
18
- "shipment_items" => [
19
- {
20
- "consignee_address" => {
21
- "company_name" => "Test",
22
- "name" => "Test1",
23
- "address1" => "NO 3 JALAN PPU 1",
24
- "address2" => "TAMAN PERINDUSTRIAN PUCHONG UTAMA",
25
- "address3" => nil,
26
- "city" => "PUCHONG",
27
- "state" => "SELANGOR",
28
- "district" => nil,
29
- "country" => "MY",
30
- "post_code" => "57000",
31
- "phone" => "0123456798",
32
- "email" => nil
33
- },
34
- "shipment_id" => "MYPTC000103",
35
- "package_desc" => "Bread Materials",
36
- "total_weight" => 2000,
37
- "total_weight_uom" => "G",
38
- "dimension_uom" => "CM",
39
- "height" => nil,
40
- "length" => nil,
41
- "width" => nil,
42
- "product_code" => "PDO",
43
- "cod_value" => nil,
44
- "insurance_value" => nil,
45
- "total_value" => 300,
46
- "currency" => "MYR",
47
- "remarks" => nil,
48
- "is_routing_info_required" => "Y"
49
- }
50
- ],
51
- }
52
- =end
@@ -1,93 +0,0 @@
1
- module DHLEcommerceAPI
2
- class ShipmentWithPickup < Shipment
3
- # This is a coupled shipment + pickup request.
4
-
5
- self.element_name = ""
6
-
7
- DEFAULT_ATTRIBUTES = {
8
- handover_method: 2,
9
- pickup_date_time: nil,
10
- pickup_address: {
11
- company_name: "",
12
- name: "",
13
- address1: "",
14
- address2: nil,
15
- address3: nil,
16
- city: "",
17
- state: "",
18
- post_code: "",
19
- country: "MY",
20
- phone: "",
21
- email: nil
22
- },
23
- shipment_items: []
24
- }
25
- end
26
- end
27
-
28
- =begin
29
- params = {
30
- "handoverMethod": 2,
31
- "pickupDateTime": DateTime.now.to_s,
32
- "pickupAddress": {
33
- "companyName": "Pickup From Company",
34
- "name": "Pickup From Name",
35
- "address1": "Holistic Pharmacy PostCo, 55, Jalan Landak",
36
- "address2": "",
37
- "address3": "",
38
- "city": " Kuala Lumpur",
39
- "state": " Kuala Lumpur",
40
- "postCode": "55100",
41
- "country": "MY",
42
- "phone": "0169822645",
43
- "email": "erwhey@postco.co"
44
- },
45
- "shipmentItems": [
46
- {
47
- "shipmentID": "MYPTC0087",
48
- "packageDesc": "Laptop Sleeve",
49
- "totalWeight": 500,
50
- "totalWeightUOM": "G",
51
- "dimensionUOM": "CM",
52
- "height": nil,
53
- "length": nil,
54
- "width": nil,
55
- "productCode": "PDO",
56
- "codValue": nil,
57
- "insuranceValue": nil,
58
- "totalValue": 300,
59
- "currency": "MYR",
60
- "remarks": nil,
61
- "isRoutingInfoRequired": "Y",
62
- "returnMode": 3,
63
- "returnAddress": {
64
- "companyName": "Pickup From Company",
65
- "name": "Pickup From Name",
66
- "address1": "Holistic Pharmacy PostCo, 55, Jalan Landak",
67
- "address2": "",
68
- "address3": "",
69
- "city": " Kuala Lumpur",
70
- "state": " Kuala Lumpur",
71
- "postCode": "55100",
72
- "country": "MY",
73
- "phone": "0169822645",
74
- "email": "erwhey@postco.co"
75
- },
76
- "consigneeAddress": {
77
- "companyName": "Sleeve Company",
78
- "name": "Sleeve Sdn Bhd",
79
- "address1": "No. 3, Jalan Bangsar, Kampung Haji Abdullah Hukum",
80
- "address2": nil,
81
- "address3": nil,
82
- "city": "Kuala Lumpur",
83
- "state": "Kuala Lumpur",
84
- "district": nil,
85
- "country": "MY",
86
- "postCode": "59200",
87
- "phone": "0169822645",
88
- "email": nil
89
- }
90
- },
91
- ]
92
- }.deep_transform_keys!{ |key| key.to_s.underscore }
93
- =end