after_ship 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +9 -21
- data/.rubocop-my.yml +4 -1
- data/.travis.yml +2 -1
- data/LICENSE.txt +17 -18
- data/README.md +1 -3
- data/Rakefile +0 -5
- data/after_ship.gemspec +13 -11
- data/bin/console +10 -0
- data/bin/setup +7 -0
- data/lib/after_ship.rb +2 -2
- data/lib/after_ship/core/date_utils.rb +2 -6
- data/lib/after_ship/core/error.rb +1 -0
- data/lib/after_ship/core/error_handler.rb +4 -4
- data/lib/after_ship/core/request.rb +18 -18
- data/lib/after_ship/core/version.rb +1 -1
- metadata +23 -49
- data/spec/integration/after_ship_spec.rb +0 -40
- data/spec/request_stubs.rb +0 -66
- data/spec/requests/couriers.json +0 -50
- data/spec/requests/tracking/created.json +0 -53
- data/spec/requests/tracking/delivered.json +0 -277
- data/spec/requests/trackings.json +0 -654
- data/spec/spec_helper.rb +0 -13
- data/spec/units/after_ship_spec.rb +0 -104
- data/spec/units/checkpoint_spec.rb +0 -135
- data/spec/units/courier_spec.rb +0 -41
- data/spec/units/date_utils_spec.rb +0 -67
- data/spec/units/error_handler_spec.rb +0 -168
- data/spec/units/request_spec.rb +0 -190
- data/spec/units/tracking_spec.rb +0 -276
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe AfterShip do
|
4
|
-
let(:client) { AfterShip.new(api_key: 'key') }
|
5
|
-
|
6
|
-
it 'trackings' do
|
7
|
-
trackings = client.trackings
|
8
|
-
expect(trackings.size).to eq(2)
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'trackings with debug' do
|
12
|
-
AfterShip.debug = true
|
13
|
-
|
14
|
-
trackings = client.trackings
|
15
|
-
expect(trackings.size).to eq(2)
|
16
|
-
|
17
|
-
AfterShip.debug = nil
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'tracking' do
|
21
|
-
tracking = client.tracking('delivered', 'ups')
|
22
|
-
expect(tracking.tracking_number).to eq('1ZA2207X0444990982')
|
23
|
-
expect(tracking.checkpoints.size).to eq(15)
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'create_tracking' do
|
27
|
-
tracking = client.create_tracking('created', 'ups', order_id: 'external-id')
|
28
|
-
expect(tracking.tracking_number).to eq('1Z0659120300549388')
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'update_tracking' do
|
32
|
-
tracking = client.update_tracking('updated', 'ups', order_id: 'external-id')
|
33
|
-
expect(tracking.tracking_number).to eq('1Z0659120300549388')
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'couriers' do
|
37
|
-
couriers = client.couriers
|
38
|
-
expect(couriers.size).to eq(4)
|
39
|
-
end
|
40
|
-
end
|
data/spec/request_stubs.rb
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
# Get trackings
|
2
|
-
WebMock.stub_request(
|
3
|
-
:get,
|
4
|
-
'https://api.aftership.com/v4/trackings'
|
5
|
-
).with(
|
6
|
-
headers: { 'Aftership-Api-Key' => 'key' }
|
7
|
-
).to_return(
|
8
|
-
status: 200,
|
9
|
-
body: File.open('spec/requests/trackings.json')
|
10
|
-
)
|
11
|
-
|
12
|
-
# Get a tracking
|
13
|
-
WebMock.stub_request(
|
14
|
-
:get,
|
15
|
-
'https://api.aftership.com/v4/trackings/ups/delivered'
|
16
|
-
).with(
|
17
|
-
headers: { 'Aftership-Api-Key' => 'key' }
|
18
|
-
).to_return(
|
19
|
-
status: 200,
|
20
|
-
body: File.open('spec/requests/tracking/delivered.json')
|
21
|
-
)
|
22
|
-
|
23
|
-
# Create a tracking
|
24
|
-
WebMock.stub_request(
|
25
|
-
:post,
|
26
|
-
'https://api.aftership.com/v4/trackings'
|
27
|
-
).with(
|
28
|
-
headers: { 'Aftership-Api-Key' => 'key' },
|
29
|
-
body: MultiJson.dump(
|
30
|
-
'tracking' => {
|
31
|
-
'tracking_number' => 'created',
|
32
|
-
'slug' => 'ups',
|
33
|
-
'order_id' => 'external-id'
|
34
|
-
}
|
35
|
-
)
|
36
|
-
).to_return(
|
37
|
-
status: 200,
|
38
|
-
body: File.open('spec/requests/tracking/created.json')
|
39
|
-
)
|
40
|
-
|
41
|
-
# Update a tracking
|
42
|
-
WebMock.stub_request(
|
43
|
-
:put,
|
44
|
-
'https://api.aftership.com/v4/trackings/ups/updated'
|
45
|
-
).with(
|
46
|
-
headers: { 'Aftership-Api-Key' => 'key' },
|
47
|
-
body: MultiJson.dump(
|
48
|
-
'tracking' => {
|
49
|
-
'order_id' => 'external-id'
|
50
|
-
}
|
51
|
-
)
|
52
|
-
).to_return(
|
53
|
-
status: 200,
|
54
|
-
body: File.open('spec/requests/tracking/created.json')
|
55
|
-
)
|
56
|
-
|
57
|
-
# Couriers
|
58
|
-
WebMock.stub_request(
|
59
|
-
:get,
|
60
|
-
'https://api.aftership.com/v4/couriers'
|
61
|
-
).with(
|
62
|
-
headers: { 'Aftership-Api-Key' => 'key' }
|
63
|
-
).to_return(
|
64
|
-
status: 200,
|
65
|
-
body: File.open('spec/requests/couriers.json')
|
66
|
-
)
|
data/spec/requests/couriers.json
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"meta": {
|
3
|
-
"code": 200
|
4
|
-
},
|
5
|
-
"data": {
|
6
|
-
"total": 4,
|
7
|
-
"couriers": [
|
8
|
-
{
|
9
|
-
"slug": "usps",
|
10
|
-
"name": "USPS",
|
11
|
-
"phone": "+1 800-275-8777",
|
12
|
-
"other_name": "United States Postal Service",
|
13
|
-
"web_url": "https://www.usps.com",
|
14
|
-
"required_fields": [
|
15
|
-
|
16
|
-
]
|
17
|
-
},
|
18
|
-
{
|
19
|
-
"slug": "ups",
|
20
|
-
"name": "UPS",
|
21
|
-
"phone": "+1 800 742 5877",
|
22
|
-
"other_name": "United Parcel Service",
|
23
|
-
"web_url": "http://www.ups.com",
|
24
|
-
"required_fields": [
|
25
|
-
|
26
|
-
]
|
27
|
-
},
|
28
|
-
{
|
29
|
-
"slug": "fedex",
|
30
|
-
"name": "FedEx",
|
31
|
-
"phone": "+1 800 247 4747",
|
32
|
-
"other_name": "Federal Express",
|
33
|
-
"web_url": "http://www.fedex.com/",
|
34
|
-
"required_fields": [
|
35
|
-
|
36
|
-
]
|
37
|
-
},
|
38
|
-
{
|
39
|
-
"slug": "dhl",
|
40
|
-
"name": "DHL Express",
|
41
|
-
"phone": "+1 800 225 5345",
|
42
|
-
"other_name": "DHL International",
|
43
|
-
"web_url": "http://www.dhl.com/",
|
44
|
-
"required_fields": [
|
45
|
-
|
46
|
-
]
|
47
|
-
}
|
48
|
-
]
|
49
|
-
}
|
50
|
-
}
|
@@ -1,53 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"meta": {
|
3
|
-
"code": 201
|
4
|
-
},
|
5
|
-
"data": {
|
6
|
-
"tracking": {
|
7
|
-
"id": "547348581a374b0a3d91f2ba",
|
8
|
-
"created_at": "2014-11-24T15:01:44+00:00",
|
9
|
-
"updated_at": "2014-11-24T15:01:44+00:00",
|
10
|
-
"tracking_number": "1Z0659120300549388",
|
11
|
-
"tracking_account_number": null,
|
12
|
-
"tracking_postal_code": null,
|
13
|
-
"tracking_ship_date": null,
|
14
|
-
"slug": "ups",
|
15
|
-
"active": true,
|
16
|
-
"android": [
|
17
|
-
|
18
|
-
],
|
19
|
-
"custom_fields": {
|
20
|
-
},
|
21
|
-
"customer_name": null,
|
22
|
-
"delivery_time": 0,
|
23
|
-
"destination_country_iso3": null,
|
24
|
-
"emails": [
|
25
|
-
|
26
|
-
],
|
27
|
-
"expected_delivery": null,
|
28
|
-
"ios": [
|
29
|
-
|
30
|
-
],
|
31
|
-
"note": null,
|
32
|
-
"order_id": "external-id",
|
33
|
-
"order_id_path": null,
|
34
|
-
"origin_country_iso3": null,
|
35
|
-
"shipment_package_count": 0,
|
36
|
-
"shipment_type": null,
|
37
|
-
"shipment_weight": 0,
|
38
|
-
"shipment_weight_unit": "",
|
39
|
-
"signed_by": null,
|
40
|
-
"smses": [
|
41
|
-
|
42
|
-
],
|
43
|
-
"source": "api",
|
44
|
-
"tag": "Pending",
|
45
|
-
"title": "1Z0659120300549388",
|
46
|
-
"tracked_count": 0,
|
47
|
-
"unique_token": "Zyw-V8LlD",
|
48
|
-
"checkpoints": [
|
49
|
-
|
50
|
-
]
|
51
|
-
}
|
52
|
-
}
|
53
|
-
}
|
@@ -1,277 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"meta": {
|
3
|
-
"code": 200
|
4
|
-
},
|
5
|
-
"data": {
|
6
|
-
"tracking": {
|
7
|
-
"id": "5457a109bb8bce546b7abafa",
|
8
|
-
"created_at": "2014-11-03T15:36:41+00:00",
|
9
|
-
"updated_at": "2014-11-03T19:55:45+00:00",
|
10
|
-
"tracking_number": "1ZA2207X0444990982",
|
11
|
-
"tracking_account_number": null,
|
12
|
-
"tracking_postal_code": null,
|
13
|
-
"tracking_ship_date": null,
|
14
|
-
"slug": "ups",
|
15
|
-
"active": false,
|
16
|
-
"android": [
|
17
|
-
|
18
|
-
],
|
19
|
-
"custom_fields": {
|
20
|
-
},
|
21
|
-
"customer_name": null,
|
22
|
-
"delivery_time": 4,
|
23
|
-
"destination_country_iso3": "USA",
|
24
|
-
"emails": [
|
25
|
-
|
26
|
-
],
|
27
|
-
"expected_delivery": null,
|
28
|
-
"ios": [
|
29
|
-
|
30
|
-
],
|
31
|
-
"note": null,
|
32
|
-
"order_id": "PL-35210992",
|
33
|
-
"order_id_path": null,
|
34
|
-
"origin_country_iso3": "IND",
|
35
|
-
"shipment_package_count": 1,
|
36
|
-
"shipment_type": "UPS SAVER",
|
37
|
-
"shipment_weight": 1,
|
38
|
-
"shipment_weight_unit": "kg",
|
39
|
-
"signed_by": "A GUPTA (OFFICE)",
|
40
|
-
"smses": [
|
41
|
-
|
42
|
-
],
|
43
|
-
"source": "api",
|
44
|
-
"tag": "Delivered",
|
45
|
-
"title": "1ZA2207X0444990982",
|
46
|
-
"tracked_count": 3,
|
47
|
-
"unique_token": "bk6ysTW1U",
|
48
|
-
"checkpoints": [
|
49
|
-
{
|
50
|
-
"slug": "ups",
|
51
|
-
"city": null,
|
52
|
-
"created_at": "2014-11-03T15:36:41+00:00",
|
53
|
-
"country_name": "IN",
|
54
|
-
"message": "BILLING INFORMATION RECEIVED",
|
55
|
-
"country_iso3": "IND",
|
56
|
-
"tag": "InfoReceived",
|
57
|
-
"checkpoint_time": "2014-10-30T10:05:48",
|
58
|
-
"coordinates": [
|
59
|
-
|
60
|
-
],
|
61
|
-
"state": null,
|
62
|
-
"zip": null
|
63
|
-
},
|
64
|
-
{
|
65
|
-
"slug": "ups",
|
66
|
-
"city": "MUMBAI",
|
67
|
-
"created_at": "2014-11-03T15:36:41+00:00",
|
68
|
-
"country_name": "IN",
|
69
|
-
"message": "PICKUP SCAN",
|
70
|
-
"country_iso3": null,
|
71
|
-
"tag": "InTransit",
|
72
|
-
"checkpoint_time": "2014-10-30T20:02:00",
|
73
|
-
"coordinates": [
|
74
|
-
|
75
|
-
],
|
76
|
-
"state": null,
|
77
|
-
"zip": null
|
78
|
-
},
|
79
|
-
{
|
80
|
-
"slug": "ups",
|
81
|
-
"city": "MUMBAI",
|
82
|
-
"created_at": "2014-11-03T15:36:42+00:00",
|
83
|
-
"country_name": "IN",
|
84
|
-
"message": "ORIGIN SCAN",
|
85
|
-
"country_iso3": null,
|
86
|
-
"tag": "InTransit",
|
87
|
-
"checkpoint_time": "2014-10-31T02:54:00",
|
88
|
-
"coordinates": [
|
89
|
-
|
90
|
-
],
|
91
|
-
"state": null,
|
92
|
-
"zip": null
|
93
|
-
},
|
94
|
-
{
|
95
|
-
"slug": "ups",
|
96
|
-
"city": "MUMBAI",
|
97
|
-
"created_at": "2014-11-03T15:36:42+00:00",
|
98
|
-
"country_name": "IN",
|
99
|
-
"message": "DEPARTURE SCAN",
|
100
|
-
"country_iso3": null,
|
101
|
-
"tag": "InTransit",
|
102
|
-
"checkpoint_time": "2014-10-31T05:45:00",
|
103
|
-
"coordinates": [
|
104
|
-
|
105
|
-
],
|
106
|
-
"state": null,
|
107
|
-
"zip": null
|
108
|
-
},
|
109
|
-
{
|
110
|
-
"slug": "ups",
|
111
|
-
"city": "MUMBAI",
|
112
|
-
"created_at": "2014-11-03T15:36:42+00:00",
|
113
|
-
"country_name": "IN",
|
114
|
-
"message": "ARRIVAL SCAN",
|
115
|
-
"country_iso3": null,
|
116
|
-
"tag": "InTransit",
|
117
|
-
"checkpoint_time": "2014-10-31T06:01:00",
|
118
|
-
"coordinates": [
|
119
|
-
|
120
|
-
],
|
121
|
-
"state": null,
|
122
|
-
"zip": null
|
123
|
-
},
|
124
|
-
{
|
125
|
-
"slug": "ups",
|
126
|
-
"city": "MUMBAI",
|
127
|
-
"created_at": "2014-11-03T15:36:42+00:00",
|
128
|
-
"country_name": "IN",
|
129
|
-
"message": "DEPARTURE SCAN",
|
130
|
-
"country_iso3": null,
|
131
|
-
"tag": "InTransit",
|
132
|
-
"checkpoint_time": "2014-10-31T16:55:00",
|
133
|
-
"coordinates": [
|
134
|
-
|
135
|
-
],
|
136
|
-
"state": null,
|
137
|
-
"zip": null
|
138
|
-
},
|
139
|
-
{
|
140
|
-
"slug": "ups",
|
141
|
-
"city": null,
|
142
|
-
"created_at": "2014-11-03T15:36:42+00:00",
|
143
|
-
"country_name": "DE",
|
144
|
-
"message": "THE PACKAGE IS AWAITING CLEARING AGENCY REVIEW. / THE PACKAGE IS AT THE CLEARING AGENCY AWAITING FINAL RELEASE.",
|
145
|
-
"country_iso3": "DEU",
|
146
|
-
"tag": "InTransit",
|
147
|
-
"checkpoint_time": "2014-11-01T00:18:00",
|
148
|
-
"coordinates": [
|
149
|
-
|
150
|
-
],
|
151
|
-
"state": null,
|
152
|
-
"zip": null
|
153
|
-
},
|
154
|
-
{
|
155
|
-
"slug": "ups",
|
156
|
-
"city": "KOELN (COLOGNE)",
|
157
|
-
"created_at": "2014-11-03T15:36:42+00:00",
|
158
|
-
"country_name": "DE",
|
159
|
-
"message": "DEPARTURE SCAN",
|
160
|
-
"country_iso3": null,
|
161
|
-
"tag": "InTransit",
|
162
|
-
"checkpoint_time": "2014-11-01T01:12:00",
|
163
|
-
"coordinates": [
|
164
|
-
|
165
|
-
],
|
166
|
-
"state": null,
|
167
|
-
"zip": null
|
168
|
-
},
|
169
|
-
{
|
170
|
-
"slug": "ups",
|
171
|
-
"city": null,
|
172
|
-
"created_at": "2014-11-03T15:36:42+00:00",
|
173
|
-
"country_name": "DE",
|
174
|
-
"message": "THE PACKAGE IS AWAITING CLEARING AGENCY REVIEW. / YOUR PACKAGE WAS RELEASED BY THE CLEARING AGENCY.",
|
175
|
-
"country_iso3": "DEU",
|
176
|
-
"tag": "InTransit",
|
177
|
-
"checkpoint_time": "2014-11-02T08:17:00",
|
178
|
-
"coordinates": [
|
179
|
-
|
180
|
-
],
|
181
|
-
"state": null,
|
182
|
-
"zip": null
|
183
|
-
},
|
184
|
-
{
|
185
|
-
"slug": "ups",
|
186
|
-
"city": "LOUISVILLE",
|
187
|
-
"created_at": "2014-11-03T15:36:42+00:00",
|
188
|
-
"country_name": "US",
|
189
|
-
"message": "IMPORT SCAN",
|
190
|
-
"country_iso3": null,
|
191
|
-
"tag": "InTransit",
|
192
|
-
"checkpoint_time": "2014-11-02T11:44:00",
|
193
|
-
"coordinates": [
|
194
|
-
|
195
|
-
],
|
196
|
-
"state": "KY",
|
197
|
-
"zip": null
|
198
|
-
},
|
199
|
-
{
|
200
|
-
"slug": "ups",
|
201
|
-
"city": "LOUISVILLE",
|
202
|
-
"created_at": "2014-11-03T15:36:42+00:00",
|
203
|
-
"country_name": "US",
|
204
|
-
"message": "DEPARTURE SCAN",
|
205
|
-
"country_iso3": null,
|
206
|
-
"tag": "InTransit",
|
207
|
-
"checkpoint_time": "2014-11-02T15:45:00",
|
208
|
-
"coordinates": [
|
209
|
-
|
210
|
-
],
|
211
|
-
"state": "KY",
|
212
|
-
"zip": null
|
213
|
-
},
|
214
|
-
{
|
215
|
-
"slug": "ups",
|
216
|
-
"city": "OAKLAND",
|
217
|
-
"created_at": "2014-11-03T15:36:42+00:00",
|
218
|
-
"country_name": "US",
|
219
|
-
"message": "ARRIVAL SCAN",
|
220
|
-
"country_iso3": null,
|
221
|
-
"tag": "InTransit",
|
222
|
-
"checkpoint_time": "2014-11-02T17:20:00",
|
223
|
-
"coordinates": [
|
224
|
-
|
225
|
-
],
|
226
|
-
"state": "CA",
|
227
|
-
"zip": null
|
228
|
-
},
|
229
|
-
{
|
230
|
-
"slug": "ups",
|
231
|
-
"city": "OAKLAND",
|
232
|
-
"created_at": "2014-11-03T15:36:42+00:00",
|
233
|
-
"country_name": "US",
|
234
|
-
"message": "DEPARTURE SCAN",
|
235
|
-
"country_iso3": null,
|
236
|
-
"tag": "InTransit",
|
237
|
-
"checkpoint_time": "2014-11-03T03:22:00",
|
238
|
-
"coordinates": [
|
239
|
-
|
240
|
-
],
|
241
|
-
"state": "CA",
|
242
|
-
"zip": null
|
243
|
-
},
|
244
|
-
{
|
245
|
-
"slug": "ups",
|
246
|
-
"city": "SAN FRANCISCO",
|
247
|
-
"created_at": "2014-11-03T15:36:42+00:00",
|
248
|
-
"country_name": "US",
|
249
|
-
"message": "OUT FOR DELIVERY",
|
250
|
-
"country_iso3": null,
|
251
|
-
"tag": "OutForDelivery",
|
252
|
-
"checkpoint_time": "2014-11-03T06:20:00",
|
253
|
-
"coordinates": [
|
254
|
-
|
255
|
-
],
|
256
|
-
"state": "CA",
|
257
|
-
"zip": null
|
258
|
-
},
|
259
|
-
{
|
260
|
-
"slug": "ups",
|
261
|
-
"city": "SAN FRANCISCO",
|
262
|
-
"created_at": "2014-11-03T19:55:45+00:00",
|
263
|
-
"country_name": "US",
|
264
|
-
"message": "DELIVERED",
|
265
|
-
"country_iso3": null,
|
266
|
-
"tag": "Delivered",
|
267
|
-
"checkpoint_time": "2014-11-03T09:56:00",
|
268
|
-
"coordinates": [
|
269
|
-
|
270
|
-
],
|
271
|
-
"state": "CA",
|
272
|
-
"zip": "94110"
|
273
|
-
}
|
274
|
-
]
|
275
|
-
}
|
276
|
-
}
|
277
|
-
}
|