dhl_ecommerce_api 0.1.9 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 571e37c9ef69611b1303b950b5ff333d61602131078074680bc92b48ebdfd29a
4
- data.tar.gz: 8810514c60c15cf4e1fca79e9d619ff19df7932dfb313c195c0e9d66d77a80ee
3
+ metadata.gz: 894fe3942cd1b2e5e908d8e0a4a644e47ad32339d35947b9e320663fab0e8332
4
+ data.tar.gz: 48c07a18b59aad9a537b1b7e54395e8dda48c70cf547eec800a28577db0e5774
5
5
  SHA512:
6
- metadata.gz: '080882853eae5f18c8c63e3891be5cd3d77560156b687a26240e6101ce925e1354076b128388bdc271ae4784056d2289d530ed765ba19b3b179f6d9538a7e59b'
7
- data.tar.gz: 74a83c87ac5302cfb1ee1362ceda51bbbff51338042d777cf2a69a911871fc406e96b19a39e52a8c5d8c6d8070bc5840b32fff10caa35b299750183995a8af4a
6
+ metadata.gz: edeaad255cdebe539487991812a8a3017f94a1f5300e2a2a939016387b6e360fc17e5c3f47baa1e7f9edc9dbe453d0a7b0f58d2fe766bae5fe3372cf521e900a
7
+ data.tar.gz: 44f21615352723faff79ec7cfe2adfdd31fc6f11fc7e12f9381f1f88cfcfdaa229ff3d477f15e0d044eafcaab18838d727bbc2e484a06a4a5b0d4dd3e510c6a4
data/Gemfile.lock CHANGED
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dhl_ecommerce_api (0.1.8)
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.5)
11
- activesupport (= 6.1.5)
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.5)
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.1.0)
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.26.0)
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.16.0, < 2.0)
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.16.0)
103
- parser (>= 3.1.1.0)
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 (0.0.36)
107
- rubocop (>= 0.63)
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)
@@ -35,13 +42,12 @@ module DHLEcommerceAPI
35
42
  # Since request_data isnt the same as object attributes.
36
43
  # We have to write our own method to format the request data
37
44
  def formatted_request_data(request_data)
38
- request_data.as_json
39
- .deep_transform_keys {|key| custom_key_format(key)}
45
+ request_data.as_json.deep_transform_keys {|key| custom_key_format(key)}
40
46
  end
41
47
 
42
48
  # custom keys that arent following lowerCamel convention
43
49
  def custom_key_format(key)
44
- case key
50
+ case key.to_s
45
51
  when "shipment_id"
46
52
  "shipmentID"
47
53
  when "total_weight_uom"
@@ -68,13 +74,5 @@ module DHLEcommerceAPI
68
74
  key.to_s.camelize(:lower)
69
75
  end
70
76
  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
77
  end
80
78
  end
@@ -0,0 +1,6 @@
1
+ module DHLEcommerceAPI
2
+ # Component item
3
+ class Shipment::ShipmentItem::ConsigneeAddress < Base
4
+ self.element_name = ""
5
+ end
6
+ 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)
@@ -10,8 +10,8 @@ module DHLEcommerceAPI
10
10
 
11
11
  def create
12
12
  run_callbacks :create do
13
- data = formatted_request_data(manifest_request)
14
- connection.post(collection_path, data, self.class.headers).tap do |response|
13
+ data = formatted_request_data(manifest_request).deep_transform_keys{|key| custom_key_format(key)}
14
+ connection.post(collection_path, data.to_json, self.class.headers).tap do |response|
15
15
  load_attributes_from_response(response)
16
16
  end
17
17
  end
@@ -46,7 +46,7 @@ module DHLEcommerceAPI
46
46
  {
47
47
  manifest_request: {
48
48
  hdr: headers,
49
- bd: attributes_with_account_ids
49
+ bd: attributes_with_account_ids.deep_transform_keys {|key| key.to_s.underscore.to_sym }
50
50
  }
51
51
  }
52
52
  end
@@ -61,126 +61,10 @@ module DHLEcommerceAPI
61
61
  end
62
62
  end
63
63
  end
64
- =begin
65
- # Examples:
66
- shipment_with_pickup_params = {
67
- "handoverMethod": 2,
68
- "shipperAddress": {
69
- "companyName": "Pickup From Company",
70
- "name": "Pickup From Name",
71
- "address1": "Holistic Pharmacy PostCo, 55, Jalan Landak",
72
- "address2": "",
73
- "address3": "",
74
- "city": " Kuala Lumpur",
75
- "state": " Kuala Lumpur",
76
- "postCode": "55100",
77
- "country": "MY",
78
- "phone": "0123456789",
79
- "email": "hello@example.com"
80
- },
81
- "pickupDateTime": DateTime.now.to_s,
82
- "pickupAddress": {
83
- "companyName": "Pickup From Company",
84
- "name": "Pickup From Name",
85
- "address1": "Holistic Pharmacy PostCo, 55, Jalan Landak",
86
- "address2": "",
87
- "address3": "",
88
- "city": " Kuala Lumpur",
89
- "state": " Kuala Lumpur",
90
- "postCode": "55100",
91
- "country": "MY",
92
- "phone": "0123456789",
93
- "email": "hello@example.com"
94
- },
95
- "shipmentItems": [
96
- {
97
- "shipmentID": "MYPTC0085",
98
- "packageDesc": "Laptop Sleeve",
99
- "totalWeight": 500,
100
- "totalWeightUOM": "G",
101
- "dimensionUOM": "CM",
102
- "height": nil,
103
- "length": nil,
104
- "width": nil,
105
- "productCode": "PDO",
106
- "codValue": nil,
107
- "insuranceValue": nil,
108
- "totalValue": 300,
109
- "currency": "MYR",
110
- "remarks": nil,
111
- "isRoutingInfoRequired": "Y",
112
- "consigneeAddress": {
113
- "companyName": "Sleeve Company",
114
- "name": "Sleeve Sdn Bhd",
115
- "address1": "No. 3, Jalan Bangsar, Kampung Haji Abdullah Hukum",
116
- "address2": nil,
117
- "address3": nil,
118
- "city": "Kuala Lumpur",
119
- "state": "Kuala Lumpur",
120
- "district": nil,
121
- "country": "MY",
122
- "postCode": "59200",
123
- "phone": "0169822645",
124
- "email": nil
125
- }
126
- },
127
- ]
128
- }.deep_transform_keys {|key| key.to_s.underscore }
129
-
130
- shipment_with_dropoff_params = {
131
- "handover_method" => 1,
132
- "shipment_items" => [
133
- {
134
- "consignee_address" => {
135
- "company_name" => "Test",
136
- "name" => "Test1",
137
- "address1" => "NO 3 JALAN PPU 1",
138
- "address2" => "TAMAN PERINDUSTRIAN PUCHONG UTAMA",
139
- "address3" => nil,
140
- "city" => "PUCHONG",
141
- "state" => "SELANGOR",
142
- "district" => nil,
143
- "country" => "MY",
144
- "post_code" => "57000",
145
- "phone" => "0123456798",
146
- "email" => nil
147
- },
148
- "shipment_id" => "MYPTC000102",
149
- "package_desc" => "Bread Materials",
150
- "total_weight" => 2000,
151
- "total_weight_uom" => "G",
152
- "dimension_uom" => "CM",
153
- "height" => nil,
154
- "length" => nil,
155
- "width" => nil,
156
- "product_code" => "PDO",
157
- "cod_value" => nil,
158
- "insurance_value" => nil,
159
- "total_value" => 300,
160
- "currency" => "MYR",
161
- "remarks" => nil,
162
- "is_routing_info_required" => "Y"
163
- }
164
- ],
165
- }
166
- =end
167
-
168
64
 
65
+ # Examples:
169
66
  # shipment_with_pickup_params = {
170
67
  # "handoverMethod": 2,
171
- # "shipperAddress": {
172
- # "companyName": "Pickup From Company",
173
- # "name": "Pickup From Name",
174
- # "address1": "Holistic Pharmacy PostCo, 55, Jalan Landak",
175
- # "address2": "",
176
- # "address3": "",
177
- # "city": " Kuala Lumpur",
178
- # "state": " Kuala Lumpur",
179
- # "postCode": "55100",
180
- # "country": "MY",
181
- # "phone": "0123456789",
182
- # "email": "hello@example.com"
183
- # },
184
68
  # "pickupDateTime": DateTime.now.to_s,
185
69
  # "pickupAddress": {
186
70
  # "companyName": "Pickup From Company",
@@ -197,7 +81,7 @@ shipment_with_dropoff_params = {
197
81
  # },
198
82
  # "shipmentItems": [
199
83
  # {
200
- # "shipmentID": "MYPTC0085",
84
+ # "shipmentID": "MYPTC0083",
201
85
  # "packageDesc": "Laptop Sleeve",
202
86
  # "totalWeight": 500,
203
87
  # "totalWeightUOM": "G",
@@ -228,4 +112,41 @@ shipment_with_dropoff_params = {
228
112
  # }
229
113
  # },
230
114
  # ]
231
- # }
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
+ # }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DHLEcommerceAPI
4
- VERSION = "0.1.9"
4
+ VERSION = "0.1.13"
5
5
  end
@@ -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/shipment_test"
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.9
4
+ version: 0.1.13
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/shipment_test.rb
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
- rubyforge_project:
177
- rubygems_version: 2.7.6.2
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