smartsend-ruby 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/smartsend/client.rb +1 -0
- data/lib/smartsend/parcel.rb +2 -1
- data/lib/smartsend/shipment.rb +13 -2
- data/lib/smartsend/version.rb +1 -1
- data/test/test_shipment.rb +24 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a573aa1aa235b1b914a7ab618d5b3e86c225bdfe0cb10a58a9e1f3aa16f50c62
|
4
|
+
data.tar.gz: bafffcf48ea300e14228a2c3ac3d274e8b3d587fdcf3e89bd5139d4bfd7a5300
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3be7a08b73eff8efeea99edf68843066b3bbf53f24c300eff1524b2f3fb078ec6ec18aa17171bfeb4c5af358fccc120ca5725973b5e0bd55488a97a5ce112cc4
|
7
|
+
data.tar.gz: 914c1a79cafab55a715bce8c75a3362badb93ce8400c07b89e960e3f5c8c787d76aef8acdafdc9c9a4978832f1c8f7bf2cd6e7a3299b7b1f464c1e78ec28458b
|
data/lib/smartsend/client.rb
CHANGED
data/lib/smartsend/parcel.rb
CHANGED
@@ -2,7 +2,8 @@ class Smartsend::Parcel
|
|
2
2
|
attr_accessor :internal_id, :internal_reference, :weight, :height, :width,
|
3
3
|
:length, :freetext1, :freetext2, :freetext3,
|
4
4
|
:total_price_excluding_tax, :total_price_including_tax,
|
5
|
-
:total_tax_amount, :items
|
5
|
+
:total_tax_amount, :items, :label_url, :tracking_code,
|
6
|
+
:tracking_link
|
6
7
|
|
7
8
|
def initialize(args={})
|
8
9
|
args.each do |k, v|
|
data/lib/smartsend/shipment.rb
CHANGED
@@ -5,7 +5,7 @@ class Smartsend::Shipment
|
|
5
5
|
:sub_total_price_including_tax, :shipping_price_excluding_tax,
|
6
6
|
:shipping_price_including_tax, :total_price_excluding_tax,
|
7
7
|
:total_price_including_tax, :total_tax_amount, :currency,
|
8
|
-
:success, :
|
8
|
+
:success, :error, :labels_url
|
9
9
|
|
10
10
|
def initialize(args={})
|
11
11
|
args.each do |k, v|
|
@@ -24,7 +24,18 @@ class Smartsend::Shipment
|
|
24
24
|
|
25
25
|
if response.success?
|
26
26
|
@success = true
|
27
|
-
@
|
27
|
+
@labels_url = response.dig('data', 'pdf', 'link')
|
28
|
+
|
29
|
+
response['data']['parcels'].each do |parcel_response|
|
30
|
+
parcel = parcels.find do |item|
|
31
|
+
item.internal_id == parcel_response['parcel_internal_id']
|
32
|
+
end
|
33
|
+
|
34
|
+
parcel&.label_url = parcel_response.dig('pdf', 'link')
|
35
|
+
parcel&.tracking_code = parcel_response['tracking_code']
|
36
|
+
parcel&.tracking_link = parcel_response['tracking_link']
|
37
|
+
|
38
|
+
end
|
28
39
|
else
|
29
40
|
self.error = Smartsend::RequestError.build(response)
|
30
41
|
end
|
data/lib/smartsend/version.rb
CHANGED
data/test/test_shipment.rb
CHANGED
@@ -82,6 +82,19 @@ class ShipmentTest < Minitest::Test
|
|
82
82
|
freetext3: "We look forward to seeing you soon Brian",
|
83
83
|
)
|
84
84
|
|
85
|
+
# add one or more parcels/fulfillments to the shipment
|
86
|
+
parcel2 = Smartsend::Parcel.new(
|
87
|
+
internal_id: "123456789b", # your internal parcel id
|
88
|
+
internal_reference: "123456789b",
|
89
|
+
weight: 1.25,
|
90
|
+
height: 21,
|
91
|
+
width: 27,
|
92
|
+
length: 35,
|
93
|
+
freetext1: "Brians birthday gift",
|
94
|
+
freetext2: "Don't open this before your birthday Brian",
|
95
|
+
freetext3: "We look forward to seeing you soon Brian",
|
96
|
+
)
|
97
|
+
|
85
98
|
# add items to the parcel
|
86
99
|
parcel_item = Smartsend::ParcelItem.new(
|
87
100
|
internal_id: "ABC123",
|
@@ -93,13 +106,23 @@ class ShipmentTest < Minitest::Test
|
|
93
106
|
)
|
94
107
|
|
95
108
|
parcel.items << parcel_item
|
109
|
+
parcel2.items << parcel_item
|
96
110
|
shipment.parcels << parcel
|
111
|
+
shipment.parcels << parcel2
|
97
112
|
|
98
113
|
# send the shipment to Smartsend.io
|
99
114
|
shipment.save!
|
100
115
|
|
101
116
|
assert shipment.success?
|
102
|
-
|
117
|
+
|
118
|
+
assert shipment.parcels[0].label_url
|
119
|
+
assert shipment.parcels[1].label_url
|
120
|
+
|
121
|
+
assert shipment.parcels[0].tracking_code
|
122
|
+
assert shipment.parcels[1].tracking_code
|
123
|
+
|
124
|
+
assert shipment.parcels[0].tracking_link
|
125
|
+
assert shipment.parcels[1].tracking_link
|
103
126
|
end
|
104
127
|
|
105
128
|
def test_invalid_request
|