dhl_ecommerce_api 0.1.5 → 0.1.8

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: e03ab10a63b305e1b945187a967a676fb6723ecaf11dc2ed3b913f39d6aec46e
4
- data.tar.gz: 892480ae678747fff07c1bcf18855ba8ec96a01b9c6e5dbe31ca10975eedd7a7
3
+ metadata.gz: 2c631b27d8fbe5337fb63e73caf9a577ab9be717d56f72b0d726d004439e954a
4
+ data.tar.gz: 5fd628b9b8339e5f0baeb0e36f2f59f97ee72b110e7dc7a94100b7fac18c3287
5
5
  SHA512:
6
- metadata.gz: 25393870b5b0ab687d847cac0581537949988e9e71e296ae7686bf23edaa324482787939b9e2f22e155abc3a58b8ab212d1940de7fd78e7515b099461430ca5d
7
- data.tar.gz: 7616a892d236831382ef549c8b1d713dc4c5ac8b03f2f3b119386e09510bd36b7502349ed14c00d37b828ea2651c2c266bb88bdad3bec0981bbe5884736f5044
6
+ metadata.gz: 22ab3ba491f789331432b8466a74679188537236682fb16c864712539a4f5e046f149ae52974751b76919859f49e6cbfb8c720a3a060b825026b00ef23ad6c3a
7
+ data.tar.gz: df9c0a8d9d63bb8570f30d296ca24e0602f6500c18bfe68dd6a888ee0dc3c04accdf7b3a209411c1bff3a490deca73432804aab98506e73069659129e5e81cf8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dhl_ecommerce_api (0.1.4)
4
+ dhl_ecommerce_api (0.1.7)
5
5
  activeresource (>= 4.1.0, < 6.0.0)
6
6
 
7
7
  GEM
@@ -24,7 +24,6 @@ module DHLEcommerceAPI
24
24
  super
25
25
  end
26
26
 
27
-
28
27
  def attributes_with_account_ids
29
28
  account_ids.merge(attributes)
30
29
  end
@@ -18,7 +18,6 @@ module DHLEcommerceAPI
18
18
  end
19
19
 
20
20
  def status_slug
21
- binding.pry
22
21
  STATUS_CODES[status.to_sym]
23
22
  end
24
23
  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
@@ -1,52 +1,48 @@
1
- # module DHLEcommerceAPI
2
- # # Component item
3
- # class Shipment::ShipmentItem < Base
4
- # # add some validations?
5
- # DEFAULT_ATTRIBUTES = {
6
- # shipment_id: nil,
7
- # package_desc: "",
8
- # total_weight: nil,
9
- # total_weight_uom: "G",
10
- # dimension_uom: "CM",
11
- # height: nil,
12
- # length: nil,
13
- # width: nil,
14
- # product_code: "PDO",
15
- # cod_value: nil,
16
- # insurance_value: nil,
17
- # total_value: 300,
18
- # currency: "MYR",
19
- # remarks: nil,
20
- # is_routing_info_required: "Y",
21
- # consignee_address: {
22
- # company_name: "",
23
- # name: "",
24
- # address1: "",
25
- # address2: nil,
26
- # address3: nil,
27
- # city: "",
28
- # state: "",
29
- # district: nil,
30
- # country: "MY",
31
- # post_code: "",
32
- # phone: "",
33
- # email: nil
34
- # }
35
- # }
1
+ module DHLEcommerceAPI
2
+ # Component item
3
+ class Shipment::ShipmentItem < Base
4
+ self.element_name = ""
36
5
 
37
- # def initialize(attributes = {}, persisted = false)
38
- # status = attributes["response_status"]
39
- # if status.present? && status["code"] != "200"
40
- # error_messages = status["message_details"].map{|err| err["message_detail"]}
41
- # handle_errors(status["code"], error_messages)
42
- # end
43
- # super
44
- # end
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
+ }
45
38
 
46
- # def to_json(options = {})
47
- # attributes.as_json
48
- # .deep_transform_keys { |k| k.to_s.camelize(:lower) }
49
- # .to_json(include_root_in_json ? { root: self.class.element_name }.merge(options) : options)
50
- # end
51
- # end
52
- # end
39
+ def initialize(attributes = {}, persisted = false)
40
+ status = attributes["response_status"]
41
+ if status.present? && status["code"] != "200"
42
+ error_messages = status["message_details"].map{|err| err["message_detail"]}
43
+ handle_errors(status["code"], error_messages)
44
+ end
45
+ super
46
+ end
47
+ end
48
+ end
@@ -6,8 +6,6 @@ module DHLEcommerceAPI
6
6
  self.prefix = "/rest/v3/Shipment"
7
7
  self.element_name = ""
8
8
 
9
- has_many :shipment_items, class_name: "DHLEcommerceAPI::Shipment::ShipmentItem"
10
-
11
9
  validates_presence_of :handover_method
12
10
 
13
11
  def create
@@ -0,0 +1,52 @@
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,5 +1,5 @@
1
1
  module DHLEcommerceAPI
2
- class Shipment::Pickup < Shipment
2
+ class ShipmentWithPickup < Shipment
3
3
  # This is a coupled shipment + pickup request.
4
4
 
5
5
  self.element_name = ""
@@ -25,7 +25,8 @@ module DHLEcommerceAPI
25
25
  end
26
26
  end
27
27
 
28
- shipment_with_pickup_params = {
28
+ =begin
29
+ params = {
29
30
  "handoverMethod": 2,
30
31
  "pickupDateTime": DateTime.now.to_s,
31
32
  "pickupAddress": {
@@ -58,6 +59,20 @@ shipment_with_pickup_params = {
58
59
  "currency": "MYR",
59
60
  "remarks": nil,
60
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
+ },
61
76
  "consigneeAddress": {
62
77
  "companyName": "Sleeve Company",
63
78
  "name": "Sleeve Sdn Bhd",
@@ -74,4 +89,5 @@ shipment_with_pickup_params = {
74
89
  }
75
90
  },
76
91
  ]
77
- }
92
+ }.deep_transform_keys!{ |key| key.to_s.underscore }
93
+ =end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DHLEcommerceAPI
4
- VERSION = "0.1.5"
4
+ VERSION = "0.1.8"
5
5
  end
@@ -12,9 +12,11 @@ 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/pickup"
16
- require "dhl_ecommerce_api/resources/shipment/dropoff"
17
- # require "dhl_ecommerce_api/resources/shipment/shipment_item"
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"
18
20
 
19
21
  require "dhl_ecommerce_api/resources/pickup"
20
22
 
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.5
4
+ version: 0.1.8
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-14 00:00:00.000000000 Z
11
+ date: 2022-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeresource
@@ -142,9 +142,10 @@ files:
142
142
  - lib/dhl_ecommerce_api/resources/pickup.rb
143
143
  - lib/dhl_ecommerce_api/resources/pickup/handover_item.rb
144
144
  - lib/dhl_ecommerce_api/resources/shipment.rb
145
- - lib/dhl_ecommerce_api/resources/shipment/dropoff.rb
146
- - lib/dhl_ecommerce_api/resources/shipment/pickup.rb
147
145
  - 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
148
149
  - lib/dhl_ecommerce_api/resources/tracking.rb
149
150
  - lib/dhl_ecommerce_api/version.rb
150
151
  - sig/dhl_ecommerce_api.rbs
@@ -1,50 +0,0 @@
1
- module DHLEcommerceAPI
2
- class Shipment::Dropoff < 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
- # shipment_with_dropoff_params = {
17
- # "shipment_items" => [
18
- # {
19
- # "consignee_address" => {
20
- # "company_name" => "Test",
21
- # "name" => "Test1",
22
- # "address1" => "NO 3 JALAN PPU 1",
23
- # "address2" => "TAMAN PERINDUSTRIAN PUCHONG UTAMA",
24
- # "address3" => nil,
25
- # "city" => "PUCHONG",
26
- # "state" => "SELANGOR",
27
- # "district" => nil,
28
- # "country" => "MY",
29
- # "post_code" => "57000",
30
- # "phone" => "0123456798",
31
- # "email" => nil
32
- # },
33
- # "shipment_id" => "MYPTC000103",
34
- # "package_desc" => "Bread Materials",
35
- # "total_weight" => 2000,
36
- # "total_weight_uom" => "G",
37
- # "dimension_uom" => "CM",
38
- # "height" => nil,
39
- # "length" => nil,
40
- # "width" => nil,
41
- # "product_code" => "PDO",
42
- # "cod_value" => nil,
43
- # "insurance_value" => nil,
44
- # "total_value" => 300,
45
- # "currency" => "MYR",
46
- # "remarks" => nil,
47
- # "is_routing_info_required" => "Y"
48
- # }
49
- # ],
50
- # }