dhl_ecommerce_api 0.1.11 → 0.1.12
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 +4 -4
- data/Gemfile.lock +16 -12
- data/lib/dhl_ecommerce_api/resources/base.rb +9 -10
- data/lib/dhl_ecommerce_api/resources/shipment/shipment_item/consignee_address.rb +6 -0
- data/lib/dhl_ecommerce_api/resources/shipment/shipment_item.rb +14 -1
- data/lib/dhl_ecommerce_api/resources/shipment.rb +42 -120
- data/lib/dhl_ecommerce_api/version.rb +1 -1
- data/lib/dhl_ecommerce_api.rb +5 -2
- metadata +6 -8
- data/.tool-versions +0 -1
- data/lib/dhl_ecommerce_api/resources/shipment_test.rb +0 -157
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 313e4f0218fc7c15423ff488ebd28927d61f253235e8baf70ea95dacf19dfe0c
|
|
4
|
+
data.tar.gz: 4f9ccb99bad33a08025c15d6d442e86dbbf433e2cd9d19362ab9fd1ee825b362
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f6db6ce2275c4fbf285a9845ac69cd653bc9e1a642872612adb1c74b1d69dcb7c9ab6e63a1305b28516bacd7f272bcda45cdbfd270f7fff2a77286a7aecce998
|
|
7
|
+
data.tar.gz: 93ed8643180a3d55b0cc7573c834ecc6d6c3b73d38418c56a88a8aa2e3bbe9d32debda883e59711df33d136c5be307560a0809dd8231fcbab88890247af6f8ef
|
data/Gemfile.lock
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
dhl_ecommerce_api (0.1.
|
|
4
|
+
dhl_ecommerce_api (0.1.7)
|
|
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.
|
|
11
|
-
activesupport (= 6.1.
|
|
10
|
+
activemodel (6.1.4.6)
|
|
11
|
+
activesupport (= 6.1.4.6)
|
|
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.
|
|
20
|
+
activesupport (6.1.4.6)
|
|
21
21
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
22
22
|
i18n (>= 1.6, < 2)
|
|
23
23
|
minitest (>= 5.1)
|
|
@@ -64,7 +64,7 @@ GEM
|
|
|
64
64
|
nenv (~> 0.1)
|
|
65
65
|
shellany (~> 0.0)
|
|
66
66
|
parallel (1.21.0)
|
|
67
|
-
parser (3.1.
|
|
67
|
+
parser (3.1.0.0)
|
|
68
68
|
ast (~> 2.4.1)
|
|
69
69
|
pry (0.14.1)
|
|
70
70
|
coderay (~> 1.1)
|
|
@@ -90,21 +90,25 @@ GEM
|
|
|
90
90
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
91
91
|
rspec-support (~> 3.11.0)
|
|
92
92
|
rspec-support (3.11.0)
|
|
93
|
-
rubocop (1.
|
|
93
|
+
rubocop (1.25.1)
|
|
94
94
|
parallel (~> 1.10)
|
|
95
95
|
parser (>= 3.1.0.0)
|
|
96
96
|
rainbow (>= 2.2.2, < 4.0)
|
|
97
97
|
regexp_parser (>= 1.8, < 3.0)
|
|
98
98
|
rexml
|
|
99
|
-
rubocop-ast (>= 1.
|
|
99
|
+
rubocop-ast (>= 1.15.1, < 2.0)
|
|
100
100
|
ruby-progressbar (~> 1.7)
|
|
101
101
|
unicode-display_width (>= 1.4.0, < 3.0)
|
|
102
|
-
rubocop-ast (1.
|
|
103
|
-
parser (>= 3.1.1
|
|
102
|
+
rubocop-ast (1.15.2)
|
|
103
|
+
parser (>= 3.0.1.1)
|
|
104
|
+
rubocop-performance (1.13.2)
|
|
105
|
+
rubocop (>= 1.7.0, < 2.0)
|
|
106
|
+
rubocop-ast (>= 0.4.0)
|
|
104
107
|
ruby-progressbar (1.11.0)
|
|
105
108
|
shellany (0.0.1)
|
|
106
|
-
standard (
|
|
107
|
-
rubocop (
|
|
109
|
+
standard (1.7.2)
|
|
110
|
+
rubocop (= 1.25.1)
|
|
111
|
+
rubocop-performance (= 1.13.2)
|
|
108
112
|
thor (1.2.1)
|
|
109
113
|
tzinfo (2.0.4)
|
|
110
114
|
concurrent-ruby (~> 1.0)
|
|
@@ -116,7 +120,7 @@ GEM
|
|
|
116
120
|
zeitwerk (2.5.4)
|
|
117
121
|
|
|
118
122
|
PLATFORMS
|
|
119
|
-
-darwin-21
|
|
123
|
+
arm64-darwin-21
|
|
120
124
|
|
|
121
125
|
DEPENDENCIES
|
|
122
126
|
dhl_ecommerce_api!
|
|
@@ -5,11 +5,18 @@ 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
|
+
|
|
8
15
|
# by default convert to snake_case when initializing
|
|
9
16
|
def load(attributes, remove_root = false, persisted = false)
|
|
10
17
|
# convert loaded attributes to underscore, then symbolize
|
|
11
18
|
attributes.deep_transform_keys! { |k| k.to_s.underscore.to_sym }
|
|
12
|
-
|
|
19
|
+
|
|
13
20
|
# merge default_attrs(symbols) with incoming attributes
|
|
14
21
|
if defined?(self.class::DEFAULT_ATTRIBUTES)
|
|
15
22
|
attributes = self.class::DEFAULT_ATTRIBUTES.merge(attributes)
|
|
@@ -36,7 +43,7 @@ module DHLEcommerceAPI
|
|
|
36
43
|
# We have to write our own method to format the request data
|
|
37
44
|
def formatted_request_data(request_data)
|
|
38
45
|
request_data.as_json
|
|
39
|
-
.deep_transform_keys {|key| custom_key_format(key)}
|
|
46
|
+
.deep_transform_keys {|key| custom_key_format(key)}.to_json
|
|
40
47
|
end
|
|
41
48
|
|
|
42
49
|
# custom keys that arent following lowerCamel convention
|
|
@@ -68,13 +75,5 @@ module DHLEcommerceAPI
|
|
|
68
75
|
key.to_s.camelize(:lower)
|
|
69
76
|
end
|
|
70
77
|
end
|
|
71
|
-
|
|
72
|
-
# catchall overwrite default to_json method for anything that inherits from Base.
|
|
73
|
-
# Not used by anything so far.
|
|
74
|
-
def to_json(options = {})
|
|
75
|
-
attributes.as_json
|
|
76
|
-
.deep_transform_keys { |k| custom_key_format(k) }
|
|
77
|
-
.to_json(include_root_in_json ? { root: self.class.element_name }.merge(options) : options)
|
|
78
|
-
end
|
|
79
78
|
end
|
|
80
79
|
end
|
|
@@ -20,7 +20,20 @@ module DHLEcommerceAPI
|
|
|
20
20
|
currency: "MYR",
|
|
21
21
|
remarks: nil,
|
|
22
22
|
is_routing_info_required: "Y",
|
|
23
|
-
consignee_address: {
|
|
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
|
+
}
|
|
24
37
|
}
|
|
25
38
|
|
|
26
39
|
def initialize(attributes = {}, persisted = false)
|
|
@@ -6,6 +6,8 @@ module DHLEcommerceAPI
|
|
|
6
6
|
self.prefix = "/rest/v3/Shipment"
|
|
7
7
|
self.element_name = ""
|
|
8
8
|
|
|
9
|
+
validates_presence_of :handover_method
|
|
10
|
+
|
|
9
11
|
def create
|
|
10
12
|
run_callbacks :create do
|
|
11
13
|
data = formatted_request_data(manifest_request)
|
|
@@ -44,7 +46,7 @@ module DHLEcommerceAPI
|
|
|
44
46
|
{
|
|
45
47
|
manifest_request: {
|
|
46
48
|
hdr: headers,
|
|
47
|
-
bd: attributes_with_account_ids
|
|
49
|
+
bd: attributes_with_account_ids.deep_transform_keys {|key| key.to_s.underscore.to_sym }
|
|
48
50
|
}
|
|
49
51
|
}
|
|
50
52
|
end
|
|
@@ -60,126 +62,9 @@ module DHLEcommerceAPI
|
|
|
60
62
|
end
|
|
61
63
|
end
|
|
62
64
|
|
|
63
|
-
=begin
|
|
64
65
|
# Examples:
|
|
65
|
-
shipment_with_pickup_params = {
|
|
66
|
-
"handoverMethod": 2,
|
|
67
|
-
"shipperAddress": {
|
|
68
|
-
"companyName": "Pickup From Company",
|
|
69
|
-
"name": "Pickup From Name",
|
|
70
|
-
"address1": "Holistic Pharmacy PostCo, 55, Jalan Landak",
|
|
71
|
-
"address2": "",
|
|
72
|
-
"address3": "",
|
|
73
|
-
"city": " Kuala Lumpur",
|
|
74
|
-
"state": " Kuala Lumpur",
|
|
75
|
-
"postCode": "55100",
|
|
76
|
-
"country": "MY",
|
|
77
|
-
"phone": "0123456789",
|
|
78
|
-
"email": "hello@example.com"
|
|
79
|
-
},
|
|
80
|
-
"pickupDateTime": DateTime.now.to_s,
|
|
81
|
-
"pickupAddress": {
|
|
82
|
-
"companyName": "Pickup From Company",
|
|
83
|
-
"name": "Pickup From Name",
|
|
84
|
-
"address1": "Holistic Pharmacy PostCo, 55, Jalan Landak",
|
|
85
|
-
"address2": "",
|
|
86
|
-
"address3": "",
|
|
87
|
-
"city": " Kuala Lumpur",
|
|
88
|
-
"state": " Kuala Lumpur",
|
|
89
|
-
"postCode": "55100",
|
|
90
|
-
"country": "MY",
|
|
91
|
-
"phone": "0123456789",
|
|
92
|
-
"email": "hello@example.com"
|
|
93
|
-
},
|
|
94
|
-
"shipmentItems": [
|
|
95
|
-
{
|
|
96
|
-
"shipmentID": "MYPTC0085",
|
|
97
|
-
"packageDesc": "Laptop Sleeve",
|
|
98
|
-
"totalWeight": 500,
|
|
99
|
-
"totalWeightUOM": "G",
|
|
100
|
-
"dimensionUOM": "CM",
|
|
101
|
-
"height": nil,
|
|
102
|
-
"length": nil,
|
|
103
|
-
"width": nil,
|
|
104
|
-
"productCode": "PDO",
|
|
105
|
-
"codValue": nil,
|
|
106
|
-
"insuranceValue": nil,
|
|
107
|
-
"totalValue": 300,
|
|
108
|
-
"currency": "MYR",
|
|
109
|
-
"remarks": nil,
|
|
110
|
-
"isRoutingInfoRequired": "Y",
|
|
111
|
-
"consigneeAddress": {
|
|
112
|
-
"companyName": "Sleeve Company",
|
|
113
|
-
"name": "Sleeve Sdn Bhd",
|
|
114
|
-
"address1": "No. 3, Jalan Bangsar, Kampung Haji Abdullah Hukum",
|
|
115
|
-
"address2": nil,
|
|
116
|
-
"address3": nil,
|
|
117
|
-
"city": "Kuala Lumpur",
|
|
118
|
-
"state": "Kuala Lumpur",
|
|
119
|
-
"district": nil,
|
|
120
|
-
"country": "MY",
|
|
121
|
-
"postCode": "59200",
|
|
122
|
-
"phone": "0169822645",
|
|
123
|
-
"email": nil
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
]
|
|
127
|
-
}.deep_transform_keys {|key| key.to_s.underscore }
|
|
128
|
-
|
|
129
|
-
shipment_with_dropoff_params = {
|
|
130
|
-
"handover_method" => 1,
|
|
131
|
-
"shipment_items" => [
|
|
132
|
-
{
|
|
133
|
-
"consignee_address" => {
|
|
134
|
-
"company_name" => "Test",
|
|
135
|
-
"name" => "Test1",
|
|
136
|
-
"address1" => "NO 3 JALAN PPU 1",
|
|
137
|
-
"address2" => "TAMAN PERINDUSTRIAN PUCHONG UTAMA",
|
|
138
|
-
"address3" => nil,
|
|
139
|
-
"city" => "PUCHONG",
|
|
140
|
-
"state" => "SELANGOR",
|
|
141
|
-
"district" => nil,
|
|
142
|
-
"country" => "MY",
|
|
143
|
-
"post_code" => "57000",
|
|
144
|
-
"phone" => "0123456798",
|
|
145
|
-
"email" => nil
|
|
146
|
-
},
|
|
147
|
-
"shipment_id" => "MYPTC000102",
|
|
148
|
-
"package_desc" => "Bread Materials",
|
|
149
|
-
"total_weight" => 2000,
|
|
150
|
-
"total_weight_uom" => "G",
|
|
151
|
-
"dimension_uom" => "CM",
|
|
152
|
-
"height" => nil,
|
|
153
|
-
"length" => nil,
|
|
154
|
-
"width" => nil,
|
|
155
|
-
"product_code" => "PDO",
|
|
156
|
-
"cod_value" => nil,
|
|
157
|
-
"insurance_value" => nil,
|
|
158
|
-
"total_value" => 300,
|
|
159
|
-
"currency" => "MYR",
|
|
160
|
-
"remarks" => nil,
|
|
161
|
-
"is_routing_info_required" => "Y"
|
|
162
|
-
}
|
|
163
|
-
],
|
|
164
|
-
}
|
|
165
|
-
=end
|
|
166
|
-
|
|
167
|
-
|
|
168
66
|
# shipment_with_pickup_params = {
|
|
169
67
|
# "handoverMethod": 2,
|
|
170
|
-
# "shipperAddress": {
|
|
171
|
-
# "companyName": "Pickup From Company",
|
|
172
|
-
# "name": "Pickup From Name",
|
|
173
|
-
# "address1": "Holistic Pharmacy PostCo, 55, Jalan Landak",
|
|
174
|
-
# "address2": "",
|
|
175
|
-
# "address3": "",
|
|
176
|
-
# "city": " Kuala Lumpur",
|
|
177
|
-
# "state": " Kuala Lumpur",
|
|
178
|
-
# "postCode": "55100",
|
|
179
|
-
# "country": "MY",
|
|
180
|
-
# "phone": "0123456789",
|
|
181
|
-
# "email": "hello@example.com"
|
|
182
|
-
# },
|
|
183
68
|
# "pickupDateTime": DateTime.now.to_s,
|
|
184
69
|
# "pickupAddress": {
|
|
185
70
|
# "companyName": "Pickup From Company",
|
|
@@ -196,7 +81,7 @@ shipment_with_dropoff_params = {
|
|
|
196
81
|
# },
|
|
197
82
|
# "shipmentItems": [
|
|
198
83
|
# {
|
|
199
|
-
# "shipmentID": "
|
|
84
|
+
# "shipmentID": "MYPTC0083",
|
|
200
85
|
# "packageDesc": "Laptop Sleeve",
|
|
201
86
|
# "totalWeight": 500,
|
|
202
87
|
# "totalWeightUOM": "G",
|
|
@@ -227,4 +112,41 @@ shipment_with_dropoff_params = {
|
|
|
227
112
|
# }
|
|
228
113
|
# },
|
|
229
114
|
# ]
|
|
230
|
-
# }
|
|
115
|
+
# }
|
|
116
|
+
|
|
117
|
+
# shipment_with_dropoff_params = {
|
|
118
|
+
# "handover_method" => 1,
|
|
119
|
+
# "shipment_items" => [
|
|
120
|
+
# {
|
|
121
|
+
# "consignee_address" => {
|
|
122
|
+
# "company_name" => "Test",
|
|
123
|
+
# "name" => "Test1",
|
|
124
|
+
# "address1" => "NO 3 JALAN PPU 1",
|
|
125
|
+
# "address2" => "TAMAN PERINDUSTRIAN PUCHONG UTAMA",
|
|
126
|
+
# "address3" => nil,
|
|
127
|
+
# "city" => "PUCHONG",
|
|
128
|
+
# "state" => "SELANGOR",
|
|
129
|
+
# "district" => nil,
|
|
130
|
+
# "country" => "MY",
|
|
131
|
+
# "post_code" => "57000",
|
|
132
|
+
# "phone" => "0123456798",
|
|
133
|
+
# "email" => nil
|
|
134
|
+
# },
|
|
135
|
+
# "shipment_id" => "MYPTC000102",
|
|
136
|
+
# "package_desc" => "Bread Materials",
|
|
137
|
+
# "total_weight" => 2000,
|
|
138
|
+
# "total_weight_uom" => "G",
|
|
139
|
+
# "dimension_uom" => "CM",
|
|
140
|
+
# "height" => nil,
|
|
141
|
+
# "length" => nil,
|
|
142
|
+
# "width" => nil,
|
|
143
|
+
# "product_code" => "PDO",
|
|
144
|
+
# "cod_value" => nil,
|
|
145
|
+
# "insurance_value" => nil,
|
|
146
|
+
# "total_value" => 300,
|
|
147
|
+
# "currency" => "MYR",
|
|
148
|
+
# "remarks" => nil,
|
|
149
|
+
# "is_routing_info_required" => "Y"
|
|
150
|
+
# }
|
|
151
|
+
# ],
|
|
152
|
+
# }
|
data/lib/dhl_ecommerce_api.rb
CHANGED
|
@@ -12,9 +12,12 @@ module DHLEcommerceAPI
|
|
|
12
12
|
require "dhl_ecommerce_api/resources/authentication"
|
|
13
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
|
+
|
|
15
18
|
require "dhl_ecommerce_api/resources/shipment/shipment_item"
|
|
16
|
-
require "dhl_ecommerce_api/resources/
|
|
17
|
-
|
|
19
|
+
require "dhl_ecommerce_api/resources/shipment/shipment_item/consignee_address"
|
|
20
|
+
|
|
18
21
|
require "dhl_ecommerce_api/resources/pickup"
|
|
19
22
|
|
|
20
23
|
require "dhl_ecommerce_api/resources/tracking"
|
metadata
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dhl_ecommerce_api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.12
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Er Whey
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
11
|
date: 2022-03-16 00:00:00.000000000 Z
|
|
@@ -123,7 +123,6 @@ extra_rdoc_files: []
|
|
|
123
123
|
files:
|
|
124
124
|
- ".rspec"
|
|
125
125
|
- ".rubocop.yml"
|
|
126
|
-
- ".tool-versions"
|
|
127
126
|
- CHANGELOG.md
|
|
128
127
|
- CODE_OF_CONDUCT.md
|
|
129
128
|
- Gemfile
|
|
@@ -144,7 +143,7 @@ files:
|
|
|
144
143
|
- lib/dhl_ecommerce_api/resources/pickup/handover_item.rb
|
|
145
144
|
- lib/dhl_ecommerce_api/resources/shipment.rb
|
|
146
145
|
- lib/dhl_ecommerce_api/resources/shipment/shipment_item.rb
|
|
147
|
-
- lib/dhl_ecommerce_api/resources/
|
|
146
|
+
- lib/dhl_ecommerce_api/resources/shipment/shipment_item/consignee_address.rb
|
|
148
147
|
- lib/dhl_ecommerce_api/resources/shipment_with_dropoff.rb
|
|
149
148
|
- lib/dhl_ecommerce_api/resources/shipment_with_pickup.rb
|
|
150
149
|
- lib/dhl_ecommerce_api/resources/tracking.rb
|
|
@@ -158,7 +157,7 @@ metadata:
|
|
|
158
157
|
homepage_uri: https://github.com/PostCo/dhl_ecommerce_api
|
|
159
158
|
source_code_uri: https://github.com/PostCo/dhl_ecommerce_api
|
|
160
159
|
changelog_uri: https://github.com/PostCo/dhl_ecommerce_api/releases
|
|
161
|
-
post_install_message:
|
|
160
|
+
post_install_message:
|
|
162
161
|
rdoc_options: []
|
|
163
162
|
require_paths:
|
|
164
163
|
- lib
|
|
@@ -173,9 +172,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
173
172
|
- !ruby/object:Gem::Version
|
|
174
173
|
version: '0'
|
|
175
174
|
requirements: []
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
signing_key:
|
|
175
|
+
rubygems_version: 3.3.3
|
|
176
|
+
signing_key:
|
|
179
177
|
specification_version: 4
|
|
180
178
|
summary: Unofficial Ruby object based DHL eCommerce API wrapper.
|
|
181
179
|
test_files: []
|
data/.tool-versions
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
ruby 2.5.8
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
module DHLEcommerceAPI
|
|
2
|
-
class ShipmentTest < ActiveResource::Base
|
|
3
|
-
self.include_format_in_path = false
|
|
4
|
-
self.site = "https://sandbox.dhlecommerce.asia"
|
|
5
|
-
self.prefix = "/rest/v3/Shipment"
|
|
6
|
-
self.element_name = ""
|
|
7
|
-
|
|
8
|
-
def to_json(options = {})
|
|
9
|
-
attributes.as_json
|
|
10
|
-
.deep_transform_keys { |k| custom_key_format(k) }
|
|
11
|
-
.to_json(include_root_in_json ? { root: self.class.element_name }.merge(options) : options)
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def custom_key_format(key)
|
|
15
|
-
case key
|
|
16
|
-
when "shipment_id"
|
|
17
|
-
"shipmentID"
|
|
18
|
-
when "total_weight_uom"
|
|
19
|
-
"totalWeightUOM"
|
|
20
|
-
when "dimension_uom"
|
|
21
|
-
"dimensionUOM"
|
|
22
|
-
when "order_url"
|
|
23
|
-
"orderURL"
|
|
24
|
-
when "location_id"
|
|
25
|
-
"locationID"
|
|
26
|
-
when "piece_id"
|
|
27
|
-
"pieceID"
|
|
28
|
-
when "weight_uom"
|
|
29
|
-
"weightUOM"
|
|
30
|
-
when "marketplace_url"
|
|
31
|
-
"marketplaceURL"
|
|
32
|
-
when "handover_id"
|
|
33
|
-
"handoverID"
|
|
34
|
-
when "email_id"
|
|
35
|
-
"emailID"
|
|
36
|
-
when "e_pod_required"
|
|
37
|
-
"ePODRequired"
|
|
38
|
-
else
|
|
39
|
-
key.to_s.camelize(:lower)
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
=begin
|
|
46
|
-
def format_data(data)
|
|
47
|
-
data.as_json.deep_transform_keys {|key| custom_key_format(key)}
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def custom_key_format(key)
|
|
51
|
-
case key
|
|
52
|
-
when "shipment_id"
|
|
53
|
-
"shipmentID"
|
|
54
|
-
when "total_weight_uom"
|
|
55
|
-
"totalWeightUOM"
|
|
56
|
-
when "dimension_uom"
|
|
57
|
-
"dimensionUOM"
|
|
58
|
-
when "order_url"
|
|
59
|
-
"orderURL"
|
|
60
|
-
when "location_id"
|
|
61
|
-
"locationID"
|
|
62
|
-
when "piece_id"
|
|
63
|
-
"pieceID"
|
|
64
|
-
when "weight_uom"
|
|
65
|
-
"weightUOM"
|
|
66
|
-
when "marketplace_url"
|
|
67
|
-
"marketplaceURL"
|
|
68
|
-
when "handover_id"
|
|
69
|
-
"handoverID"
|
|
70
|
-
when "email_id"
|
|
71
|
-
"emailID"
|
|
72
|
-
when "e_pod_required"
|
|
73
|
-
"ePODRequired"
|
|
74
|
-
else
|
|
75
|
-
key.to_s.camelize(:lower)
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
params = {
|
|
80
|
-
"manifestRequest": {
|
|
81
|
-
"hdr": {
|
|
82
|
-
"message_type": "SHIPMENT",
|
|
83
|
-
"message_date_time": DateTime.now.to_s,
|
|
84
|
-
"access_token": DHLEcommerceAPI::Authentication.get_token,
|
|
85
|
-
"message_version": "1.0"
|
|
86
|
-
},
|
|
87
|
-
"bd": {
|
|
88
|
-
"pickup_account_id": DHLEcommerceAPI.config.pickup_account_id,
|
|
89
|
-
"sold_to_account_id": DHLEcommerceAPI.config.sold_to_account_id,
|
|
90
|
-
"handoverMethod": 2,
|
|
91
|
-
"shipperAddress": {
|
|
92
|
-
"companyName": "Pickup From Company",
|
|
93
|
-
"name": "Pickup From Name",
|
|
94
|
-
"address1": "Holistic Pharmacy PostCo, 55, Jalan Landak",
|
|
95
|
-
"address2": "",
|
|
96
|
-
"address3": "",
|
|
97
|
-
"city": " Kuala Lumpur",
|
|
98
|
-
"state": " Kuala Lumpur",
|
|
99
|
-
"postCode": "55100",
|
|
100
|
-
"country": "MY",
|
|
101
|
-
"phone": "0123456789",
|
|
102
|
-
"email": "hello@example.com"
|
|
103
|
-
},
|
|
104
|
-
"pickupDateTime": DateTime.now.to_s,
|
|
105
|
-
"pickupAddress": {
|
|
106
|
-
"companyName": "Pickup From Company",
|
|
107
|
-
"name": "Pickup From Name",
|
|
108
|
-
"address1": "Holistic Pharmacy PostCo, 55, Jalan Landak",
|
|
109
|
-
"address2": "",
|
|
110
|
-
"address3": "",
|
|
111
|
-
"city": " Kuala Lumpur",
|
|
112
|
-
"state": " Kuala Lumpur",
|
|
113
|
-
"postCode": "55100",
|
|
114
|
-
"country": "MY",
|
|
115
|
-
"phone": "0123456789",
|
|
116
|
-
"email": "hello@example.com"
|
|
117
|
-
},
|
|
118
|
-
"shipmentItems": [
|
|
119
|
-
{
|
|
120
|
-
"shipmentID": "MYPTC0085",
|
|
121
|
-
"packageDesc": "Laptop Sleeve",
|
|
122
|
-
"totalWeight": 500,
|
|
123
|
-
"totalWeightUOM": "G",
|
|
124
|
-
"dimensionUOM": "CM",
|
|
125
|
-
"height": nil,
|
|
126
|
-
"length": nil,
|
|
127
|
-
"width": nil,
|
|
128
|
-
"productCode": "PDO",
|
|
129
|
-
"codValue": nil,
|
|
130
|
-
"insuranceValue": nil,
|
|
131
|
-
"totalValue": 300,
|
|
132
|
-
"currency": "MYR",
|
|
133
|
-
"remarks": nil,
|
|
134
|
-
"isRoutingInfoRequired": "Y",
|
|
135
|
-
"consigneeAddress": {
|
|
136
|
-
"companyName": "Sleeve Company",
|
|
137
|
-
"name": "Sleeve Sdn Bhd",
|
|
138
|
-
"address1": "No. 3, Jalan Bangsar, Kampung Haji Abdullah Hukum",
|
|
139
|
-
"address2": nil,
|
|
140
|
-
"address3": nil,
|
|
141
|
-
"city": "Kuala Lumpur",
|
|
142
|
-
"state": "Kuala Lumpur",
|
|
143
|
-
"district": nil,
|
|
144
|
-
"country": "MY",
|
|
145
|
-
"postCode": "59200",
|
|
146
|
-
"phone": "0169822645",
|
|
147
|
-
"email": nil
|
|
148
|
-
}
|
|
149
|
-
},
|
|
150
|
-
]
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}.deep_transform_keys {|key| key.to_s.underscore }
|
|
154
|
-
|
|
155
|
-
formatted_data = format_data(params)
|
|
156
|
-
|
|
157
|
-
=end
|