easypost 2.1.8 → 2.1.9

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
  SHA1:
3
- metadata.gz: 27f671afab9c3354d08fe18adca0c53a6b4a7e4c
4
- data.tar.gz: c25c8b164cd7b3b830fd4be8380dc54823c83caf
3
+ metadata.gz: f977a4b04d233847e9d417d4c45ed99ce29a1425
4
+ data.tar.gz: 96efd3b7d40573e98a9938b7acae74394a4ff067
5
5
  SHA512:
6
- metadata.gz: cff30106b921be6737f607e7bdacdfd7a6c62254d46ef204167eaf2a89bcc8a16612934e33cbd0f03aa1a718a4efe80da9420573eecad5951e817453e93d4446
7
- data.tar.gz: 03c9e2c39eeff00ecd6f25896438a25f9eb047c4aeee6b8adf6d8c48cc0bedf5c1de2ef454e67b604d8661bc5dd0d2d3d566321c8c2d81a0c7109e88e713e0f7
6
+ metadata.gz: 86c82a3a6c4300e67a3505cd3d8ed08e0b38b53a5cef2cf46f3fe45053e28d578974a4836695a3484a15e1980fa01d14a6d72de4e43e3510c9e332b81533d5db
7
+ data.tar.gz: 8a86be431a976ab579c5a7149eafefe2beef6422f2a1ef05e72501fd586aaaf544f24fecaf6b99fb67ccf3cf3f5a6fcb69311bfb70ced2e905469b31054ab432
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ === 2.1.9 2015-11-04
2
+
3
+ * Added new tests for Tracker.all
4
+ * Updated some old examples
5
+
6
+
1
7
  === 2.1.8 2015-10-21
2
8
 
3
9
  * Added Cancel method for Pickups (thanks Ramie Blatt!)
data/README.md CHANGED
@@ -48,7 +48,7 @@ from_address = EasyPost::Address.create(
48
48
 
49
49
  parcel = EasyPost::Parcel.create(
50
50
  :width => 15.2,
51
- :length => 18,
51
+ :length => 18,
52
52
  :height => 9.5,
53
53
  :weight => 35.1
54
54
  )
@@ -85,6 +85,10 @@ shipment.buy(
85
85
  :rate => shipment.lowest_rate
86
86
  )
87
87
 
88
+ shipment.insure(amount: 100)
89
+
90
+ puts shipment.insurance
91
+
88
92
  puts shipment.postage_label.label_url
89
93
 
90
94
  ```
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.8
1
+ 2.1.9
@@ -63,6 +63,25 @@ describe EasyPost::Shipment do
63
63
  expect(tracker.shipment_id).to eq(shipment.id)
64
64
  end
65
65
 
66
+ describe '#insure' do
67
+ it 'buys and insures a shipments' do
68
+ shipment = EasyPost::Shipment.create(
69
+ :to_address => ADDRESS[:missouri],
70
+ :from_address => ADDRESS[:california],
71
+ :parcel => PARCEL[:dimensions]
72
+ )
73
+ expect(shipment).to be_an_instance_of(EasyPost::Shipment)
74
+
75
+ shipment.buy(
76
+ :rate => shipment.lowest_rate("usps")
77
+ )
78
+
79
+ shipment.insure(amount: 100)
80
+
81
+ expect(shipment.insurance).to eq("100.00")
82
+ end
83
+ end
84
+
66
85
  describe '#stamp' do
67
86
  it 'returns a stamp for a domestic shipment' do
68
87
  shipment = EasyPost::Shipment.create(
@@ -118,4 +137,13 @@ describe EasyPost::Shipment do
118
137
  end
119
138
  end
120
139
  end
140
+
141
+ describe '#retrieve' do
142
+ it 'retrieves shipment by tracking_code and correctly sets ID field (this was a bug in python)' do
143
+ tracking_code = "LN123456789US"
144
+ shipment = EasyPost::Shipment.retrieve(tracking_code)
145
+
146
+ expect(shipment.id).not_to eq(tracking_code)
147
+ end
148
+ end
121
149
  end
data/spec/tracker_spec.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe EasyPost::Tracker do
4
+ let(:tracking_code) { 'EZ2000000002' }
5
+ let(:carrier) { 'usps' }
6
+
4
7
  describe '#create' do
5
8
  it 'tracks' do
6
- tracking_code = 'EZ2000000002'
7
- carrier = 'usps'
8
-
9
9
  tracker = EasyPost::Tracker.create({
10
10
  tracking_code: tracking_code,
11
11
  carrier: carrier
@@ -17,4 +17,78 @@ describe EasyPost::Tracker do
17
17
  expect(tracker.tracking_details.length).to be > 0
18
18
  end
19
19
  end
20
+
21
+ describe '#index' do
22
+ it 'retrieves a full page of trackers' do
23
+ trackers = EasyPost::Tracker.all
24
+
25
+ expect(trackers["trackers"].count).to eq(30)
26
+ expect(trackers["has_more"]).to eq(true)
27
+ end
28
+
29
+ it 'retrieves all trackers with given tracking code, up to a page' do
30
+ trackers = EasyPost::Tracker.all(tracking_code: tracking_code)
31
+
32
+ expect(trackers["trackers"].count).to eq(30)
33
+ expect(trackers["has_more"]).to eq(true)
34
+ end
35
+
36
+ it 'retrieves all trackers with given tracking code and carrier, up to a page' do
37
+ trackers = EasyPost::Tracker.all(tracking_code: tracking_code, carrier: carrier)
38
+
39
+ expect(trackers["trackers"].count).to eq(30)
40
+ expect(trackers["has_more"]).to eq(true)
41
+ end
42
+
43
+ it 'retrieves trackers correctly based on datetime' do
44
+ datetime = Time.now.utc
45
+
46
+ tracker = EasyPost::Tracker.create({
47
+ tracking_code: tracking_code,
48
+ carrier: carrier
49
+ })
50
+
51
+ trackers = EasyPost::Tracker.all(start_datetime: datetime)
52
+
53
+ expect(trackers["trackers"].count).to eq(1)
54
+ expect(trackers["trackers"].first.id).to eq(tracker.id)
55
+ expect(trackers["has_more"]).to eq(false)
56
+
57
+ trackers = EasyPost::Tracker.all(end_datetime: datetime)
58
+
59
+ expect(trackers["trackers"].count).to eq(30)
60
+ trackers["trackers"].each do |trk|
61
+ expect(trk.id).not_to eq(tracker.id)
62
+ end
63
+ expect(trackers["has_more"]).to eq(true)
64
+ end
65
+
66
+ it 'retrieves trackers correctly based on id' do
67
+ tracker = EasyPost::Tracker.create({
68
+ tracking_code: tracking_code,
69
+ carrier: carrier
70
+ })
71
+
72
+ tracker2 = EasyPost::Tracker.create({
73
+ tracking_code: tracking_code,
74
+ carrier: carrier
75
+ })
76
+
77
+ trackers = EasyPost::Tracker.all(after_id: tracker.id)
78
+
79
+ expect(trackers["trackers"].count).to eq(1)
80
+ expect(trackers["trackers"].first.id).to eq(tracker2.id)
81
+ expect(trackers["trackers"].first.id).not_to eq(tracker.id)
82
+ expect(trackers["has_more"]).to eq(false)
83
+
84
+ trackers = EasyPost::Tracker.all(before_id: tracker.id)
85
+
86
+ expect(trackers["trackers"].count).to eq(30)
87
+ trackers["trackers"].each do |trk|
88
+ expect(trk.id).not_to eq(tracker.id)
89
+ expect(trk.id).not_to eq(tracker2.id)
90
+ end
91
+ expect(trackers["has_more"]).to eq(true)
92
+ end
93
+ end
20
94
  end
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easypost
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.8
4
+ version: 2.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sawyer Bateman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-21 00:00:00.000000000 Z
11
+ date: 2015-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: multi_json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.3.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.3.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.7'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.7'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '10.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '10.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '2.13'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '2.13'
83
83
  description: Client library for accessing the EasyPost shipping API via Ruby.
@@ -87,7 +87,7 @@ executables:
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - .gitignore
90
+ - ".gitignore"
91
91
  - CHANGELOG
92
92
  - Gemfile
93
93
  - LICENSE
@@ -144,17 +144,17 @@ require_paths:
144
144
  - lib
145
145
  required_ruby_version: !ruby/object:Gem::Requirement
146
146
  requirements:
147
- - - '>='
147
+ - - ">="
148
148
  - !ruby/object:Gem::Version
149
149
  version: '0'
150
150
  required_rubygems_version: !ruby/object:Gem::Requirement
151
151
  requirements:
152
- - - '>='
152
+ - - ">="
153
153
  - !ruby/object:Gem::Version
154
154
  version: '0'
155
155
  requirements: []
156
156
  rubyforge_project:
157
- rubygems_version: 2.0.14
157
+ rubygems_version: 2.2.2
158
158
  signing_key:
159
159
  specification_version: 4
160
160
  summary: EasyPost Ruby Client Library