smartsend-ruby 0.5.0 → 0.5.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d36b8c30a86a4866accdd796d49fde62d5e2fe8454460d1a28d21620f52d57db
4
- data.tar.gz: 00c0cf8b2b5f219f03b4ccdc06aecdf3353c183909dd417721a19a927e784c2e
3
+ metadata.gz: c45ce36e82559cb441b9b08910b5d8013a74a9ba7ac286394f71bb989ee75dea
4
+ data.tar.gz: 5167540923efdbcc3278b8c79d09d21be7a097f8c37dd4e85884f9a437d7a5c8
5
5
  SHA512:
6
- metadata.gz: 6462b9a13139bf477a86c27aa5a5bdbdd5b53c56923b94f4fece41108bbc6373f2522a056ed7c7b5220dc07eeedabccd9daa57f487b7bf66591fd7be49af3e26
7
- data.tar.gz: 89df2896fa3dac223e5333cd43f7c2cbca5b2fcef7a5f3a33d82d5f3bb66b1be33500153a3d361c9e5db8a14f2a8fc5e0fa7f520fa29bd084da54528cd83c6aa
6
+ metadata.gz: abe6b8111118a639fcc3fa42442e15e9542c9b2d004536552dfa5d94655dd501eae30ef90f5364d0cb41c5e073c6f8e667ab8379811d330d97637130fb8d14b1
7
+ data.tar.gz: 81eadfc5a5fd8d1762b04ed533ac73e61da3d37b36661cf7f1e092b5a8e3c2f77eca8bf40cdd8d1c7f1f51a344ec2974cbb274be0238cf1eeba724d636e858a9
data/README.md CHANGED
@@ -153,6 +153,10 @@ account.valid?
153
153
 
154
154
  ## Changelog
155
155
 
156
+ ### [0.5.1] - 2018-05-25
157
+ * Compare parcel ids as string
158
+ * Abillity to log requests
159
+
156
160
  ### [0.5.0] - 2018-05-15
157
161
  * Find label by tracking_code
158
162
 
@@ -2,15 +2,21 @@ require 'http'
2
2
  require 'logger'
3
3
 
4
4
  class Smartsend::Client
5
+ @@logging = false
5
6
 
6
- def initialize(account=nil, debug: false)
7
+ def self.with_logs
8
+ @@logging = true
9
+ yield
10
+ @@logging = false
11
+ end
12
+
13
+ def initialize(account=nil)
7
14
  @account = account || Smartsend.account
8
- @debug = debug
9
15
  end
10
16
 
11
17
  def post(path, params)
12
- debug("POST #{path}")
13
- debug(params)
18
+ log("POST #{path}")
19
+ log(params)
14
20
 
15
21
  request do
16
22
  http.post(url(path), json: params)
@@ -18,7 +24,7 @@ class Smartsend::Client
18
24
  end
19
25
 
20
26
  def get(path)
21
- debug("GET #{path}")
27
+ log("GET #{path}")
22
28
 
23
29
  request do
24
30
  http.get(url(path))
@@ -32,8 +38,8 @@ class Smartsend::Client
32
38
  def request
33
39
  response = yield
34
40
 
35
- debug(response)
36
- debug(response.body.to_s)
41
+ log(response)
42
+ log(response.body.to_s)
37
43
 
38
44
  case response.code
39
45
  when (200..299)
@@ -74,8 +80,8 @@ class Smartsend::Client
74
80
 
75
81
  private
76
82
 
77
- def debug(value)
78
- Logger.new($stdout).debug(value) if @debug
83
+ def log(value)
84
+ Logger.new($stdout).log(value) if @@logging
79
85
  end
80
86
 
81
87
  BASE_URL = 'http://smartsend-prod.apigee.net/api/v1'.freeze
@@ -2,7 +2,7 @@ class Smartsend::Label
2
2
  attr_accessor :tracking_code, :url, :pdf
3
3
 
4
4
  def self.find_by_tracking_code(tracking_code, account: nil)
5
- response = Smartsend::Client.new(account, debug: true).get("shipments/tracking/#{tracking_code}/labels")
5
+ response = Smartsend::Client.new(account).get("shipments/tracking/#{tracking_code}/labels")
6
6
 
7
7
  if response.success?
8
8
  label = new
@@ -28,7 +28,7 @@ class Smartsend::Shipment
28
28
 
29
29
  response['data']['parcels'].each do |parcel_response|
30
30
  parcel = parcels.find do |item|
31
- item.internal_id == parcel_response['parcel_internal_id']
31
+ item.internal_id.to_s == parcel_response['parcel_internal_id'].to_s
32
32
  end
33
33
 
34
34
  parcel&.label_url = parcel_response.dig('pdf', 'link')
@@ -1,3 +1,3 @@
1
1
  module Smartsend
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
@@ -71,7 +71,7 @@ class ShipmentTest < Minitest::Test
71
71
 
72
72
  # add one or more parcels/fulfillments to the shipment
73
73
  parcel = Smartsend::Parcel.new(
74
- internal_id: "123456789", # your internal parcel id
74
+ internal_id: 123456789, # your internal parcel id
75
75
  internal_reference: "123456789",
76
76
  weight: 1.25,
77
77
  height: 21,
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.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aske Hansen