dhl_ecommerce_api 0.1.18 → 0.1.19

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: 7177f18f322a76691402beb30d7bc047c5bc0819891b916f5ec06b44bd6d310e
4
- data.tar.gz: '0955269c3ac3150ebb04db51c8db1b8772057600395f1450b3516d2fc5509eff'
3
+ metadata.gz: b7e23ebf6bf6ec39245a0f2628cfaf038be41a3e698cc3b1ba17926dc335e796
4
+ data.tar.gz: 14eba9b87ad576b262cb7b319d2f788fe9c90584ec6801c8499f6b1b8056246f
5
5
  SHA512:
6
- metadata.gz: e327eb6ff4cd469129ce422f5689d76bb8fc040a8337a4373fb6520988e2255483e23fb40b3906caf0cb9c66539a59f443da4c2cefad4b067f0acb4b09a509e3
7
- data.tar.gz: 2b6d41f0460b07fbb518513083ff0b46fd27cd562d20bc31aa6877e4b456a98e46763e005f4479efa6bf136fe17fa84128f7da17b45eedcef271165d288087ff
6
+ metadata.gz: 12d49caaff1ac181ad597d41dbd497fc56c2644ebd5101b9d2f44fc27a157b4aef8394b9edf46efca0099f150e92dc85f9cae315c9811b7329cb3822e70c0735
7
+ data.tar.gz: df2e813b339bd2a9574d57c5f9dd89f70e5a82c84ae58585873000d3327847b52857478efafcd90c08bb761328334284e63247d3bb95d74f58c05d85a1daa320
@@ -17,9 +17,9 @@ module DHLEcommerceAPI
17
17
 
18
18
  def load_attributes_from_response(response)
19
19
  if response_code_allows_body?(response.code.to_i) &&
20
- (response["Content-Length"].nil? || response["Content-Length"] != "0") &&
21
- !response.body.nil? && response.body.strip.size > 0
22
-
20
+ (response["Content-Length"].nil? || response["Content-Length"] != "0") &&
21
+ !response.body.nil? && response.body.strip.size > 0
22
+
23
23
  bd = self.class.format.decode(response.body)["bd"]
24
24
  response_status = bd["responseStatus"]
25
25
  code = response_status["code"]
@@ -29,17 +29,19 @@ module DHLEcommerceAPI
29
29
  elsif code == "204"
30
30
  @persisted = false
31
31
  else
32
- error_messages = response_status["messageDetails"].map{|err| err["messageDetail"]}
32
+ error_messages = response_status["messageDetails"].map { |err| err["messageDetail"] }
33
33
  handle_errors(code, error_messages)
34
34
  @persisted = false
35
35
  end
36
-
36
+
37
37
  # service level
38
- new_attributes = attributes.merge({response: JSON.parse(response.body)})
38
+ new_attributes = attributes.merge({ response: JSON.parse(response.body) })
39
39
 
40
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})
41
+ if bd["shipmentItems"].present?
42
+ new_attributes["shipmentItems"] = new_attributes["shipmentItems"].map do |item|
43
+ item.attributes.merge(bd["shipmentItems"].find { |i| i["shipmentID"] == item.shipmentID })
44
+ end
43
45
  end
44
46
 
45
47
  load(new_attributes, true, @persisted)
@@ -54,7 +56,7 @@ module DHLEcommerceAPI
54
56
  }
55
57
  }
56
58
  end
57
-
59
+
58
60
  def headers
59
61
  {
60
62
  "messageType": "SHIPMENT",
@@ -67,135 +69,133 @@ module DHLEcommerceAPI
67
69
  end
68
70
 
69
71
  # Examples:
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
72
+ # shipment_with_pickup_params = {
73
+ # "handoverMethod": 2,
74
+ # "pickupDateTime": DateTime.now.to_s,
75
+ # "pickupAddress": {
76
+ # "companyName": "Pickup From Company",
77
+ # "name": "Pickup From Name",
78
+ # "address1": "Holistic Pharmacy PostCo, 55, Jalan Landak",
79
+ # "address2": "",
80
+ # "address3": "",
81
+ # "city": " Kuala Lumpur",
82
+ # "state": " Kuala Lumpur",
83
+ # "postCode": "55100",
84
+ # "country": "MY",
85
+ # "phone": "0123456789",
86
+ # "email": "hello@example.com"
87
+ # },
88
+ # "shipperAddress": {
89
+ # "companyName": "Pickup From Company",
90
+ # "name": "Pickup From Name",
91
+ # "address1": "Holistic Pharmacy PostCo, 55, Jalan Landak",
92
+ # "address2": "",
93
+ # "address3": "",
94
+ # "city": " Kuala Lumpur",
95
+ # "state": " Kuala Lumpur",
96
+ # "postCode": "55100",
97
+ # "country": "MY",
98
+ # "phone": "0123456789",
99
+ # "email": "hello@example.com"
100
+ # },
101
+ # "shipmentItems": [
102
+ # {
103
+ # "shipmentID": "MYPTC0090",
104
+ # "packageDesc": "Laptop Sleeve",
105
+ # "totalWeight": 500,
106
+ # "totalWeightUOM": "G",
107
+ # "dimensionUOM": "CM",
108
+ # "height": nil,
109
+ # "length": nil,
110
+ # "width": nil,
111
+ # "productCode": "PDO",
112
+ # "codValue": nil,
113
+ # "insuranceValue": nil,
114
+ # "totalValue": 300,
115
+ # "currency": "MYR",
116
+ # "remarks": nil,
117
+ # "isRoutingInfoRequired": "Y",
118
+ # "consigneeAddress": {
119
+ # "companyName": "Sleeve Company",
120
+ # "name": "Sleeve Sdn Bhd",
121
+ # "address1": "No. 3, Jalan Bangsar, Kampung Haji Abdullah Hukum",
122
+ # "address2": nil,
123
+ # "address3": nil,
124
+ # "city": "Kuala Lumpur",
125
+ # "state": "Kuala Lumpur",
126
+ # "district": nil,
127
+ # "country": "MY",
128
+ # "postCode": "59200",
129
+ # "phone": "0169822645",
130
+ # "email": nil
131
+ # },
132
+ # "returnMode": "03",
133
+ # "returnAddress": {
134
+ # "companyName": "Pickup From Company",
135
+ # "name": "Pickup From Name",
136
+ # "address1": "Holistic Pharmacy PostCo, 55, Jalan Landak",
137
+ # "address2": "",
138
+ # "address3": "",
139
+ # "city": " Kuala Lumpur",
140
+ # "state": " Kuala Lumpur",
141
+ # "postCode": "55100",
142
+ # "country": "MY",
143
+ # "phone": "0123456789",
144
+ # "email": "hello@example.com"
145
+ # }
146
+ # },
147
+ # {
148
+ # "shipmentID": "MYPTC0089",
149
+ # "totalWeight": 500,
150
+ # "totalWeightUOM": "G",
151
+ # "dimensionUOM": "CM",
152
+ # "height": nil,
153
+ # "length": nil,
154
+ # "width": nil,
155
+ # "productCode": "PDO",
156
+ # "codValue": nil,
157
+ # "insuranceValue": nil,
158
+ # "totalValue": 300,
159
+ # "currency": "MYR",
160
+ # "remarks": nil,
161
+ # "isRoutingInfoRequired": "Y",
162
+ # "consigneeAddress": {
163
+ # "companyName": "Sleeve Company",
164
+ # "name": "Sleeve Sdn Bhd",
165
+ # "address1": "No. 3, Jalan Bangsar, Kampung Haji Abdullah Hukum",
166
+ # "address2": nil,
167
+ # "address3": nil,
168
+ # "city": "Kuala Lumpur",
169
+ # "state": "Kuala Lumpur",
170
+ # "district": nil,
171
+ # "country": "MY",
172
+ # "postCode": "59200",
173
+ # "phone": "0169822645",
174
+ # "email": nil
175
+ # },
176
+ # "returnMode": "03",
177
+ # "returnAddress": {
178
+ # "companyName": "Pickup From Company",
179
+ # "name": "Pickup From Name",
180
+ # "address1": "Holistic Pharmacy PostCo, 55, Jalan Landak",
181
+ # "address2": "",
182
+ # "address3": "",
183
+ # "city": " Kuala Lumpur",
184
+ # "state": " Kuala Lumpur",
185
+ # "postCode": "55100",
186
+ # "country": "MY",
187
+ # "phone": "0123456789",
188
+ # "email": "hello@example.com"
189
+ # }
190
+ # },
191
+ # ]
192
+ # }
193
193
 
194
194
  # shipment_with_dropoff_params = {
195
195
  # "handover_method" => 1,
196
196
  # "shipment_items" => [
197
- # {
198
- # "consignee_address" => {
197
+ # {
198
+ # "consignee_address" => {
199
199
  # "company_name" => "Test",
200
200
  # "name" => "Test1",
201
201
  # "address1" => "NO 3 JALAN PPU 1",
@@ -207,7 +207,7 @@ shipment_with_pickup_params = {
207
207
  # "country" => "MY",
208
208
  # "post_code" => "57000",
209
209
  # "phone" => "0123456798",
210
- # "email" => nil
210
+ # "email" => nil
211
211
  # },
212
212
  # "shipment_id" => "MYPTC000102",
213
213
  # "package_desc" => "Bread Materials",
@@ -223,7 +223,7 @@ shipment_with_pickup_params = {
223
223
  # "total_value" => 300,
224
224
  # "currency" => "MYR",
225
225
  # "remarks" => nil,
226
- # "is_routing_info_required" => "Y"
226
+ # "is_routing_info_required" => "Y"
227
227
  # }
228
228
  # ],
229
229
  # }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DHLEcommerceAPI
4
- VERSION = "0.1.18"
4
+ VERSION = "0.1.19"
5
5
  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.18
4
+ version: 0.1.19
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-04-05 00:00:00.000000000 Z
11
+ date: 2024-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeresource
@@ -169,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
169
  - !ruby/object:Gem::Version
170
170
  version: '0'
171
171
  requirements: []
172
- rubygems_version: 3.3.3
172
+ rubygems_version: 3.2.33
173
173
  signing_key:
174
174
  specification_version: 4
175
175
  summary: Unofficial Ruby object based DHL eCommerce API wrapper.