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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e338e7c9a7df4d21d802d3add16f25ff4f9215b01e251cac1f0cf0f6895325c
4
- data.tar.gz: 694b44590d3806a8b4be161adbfcfd40bf32489325cb09d913a7b1974fa4bec7
3
+ metadata.gz: a573aa1aa235b1b914a7ab618d5b3e86c225bdfe0cb10a58a9e1f3aa16f50c62
4
+ data.tar.gz: bafffcf48ea300e14228a2c3ac3d274e8b3d587fdcf3e89bd5139d4bfd7a5300
5
5
  SHA512:
6
- metadata.gz: 0ae5e3227403d982d6a9f590af15cd654d93d0b10627ff301d3315ce13d666b19b8fd7123a6e4fd9751c3fe06df7d1ea95d9eb7a1d98617df8b078c025dd94c7
7
- data.tar.gz: b4aa12989d2d520920a39e3b0c6d8b1a0485991f8e621dcfadf3cc06b0901cf057aa8d3c94b172733cfa4dbb4f2545cceb849ed6911e4b0d61126624d1401b02
6
+ metadata.gz: 3be7a08b73eff8efeea99edf68843066b3bbf53f24c300eff1524b2f3fb078ec6ec18aa17171bfeb4c5af358fccc120ca5725973b5e0bd55488a97a5ce112cc4
7
+ data.tar.gz: 914c1a79cafab55a715bce8c75a3362badb93ce8400c07b89e960e3f5c8c787d76aef8acdafdc9c9a4978832f1c8f7bf2cd6e7a3299b7b1f464c1e78ec28458b
@@ -1,4 +1,5 @@
1
1
  require 'http'
2
+ require 'logger'
2
3
 
3
4
  class Smartsend::Client
4
5
 
@@ -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|
@@ -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, :label_url, :error
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
- @label_url = response.dig('data', 'pdf', 'link')
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
@@ -1,3 +1,3 @@
1
1
  module Smartsend
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -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
- assert shipment.label_url
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smartsend-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aske Hansen