after_ship 0.0.2 → 0.0.4

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.
@@ -1,133 +1,66 @@
1
- # trackings
1
+ # Get trackings
2
2
  WebMock.stub_request(
3
3
  :get,
4
- 'https://api.aftership.com/v3/trackings'
4
+ 'https://api.aftership.com/v4/trackings'
5
5
  ).with(
6
- body: '{}',
7
6
  headers: { 'Aftership-Api-Key' => 'key' }
8
7
  ).to_return(
9
8
  status: 200,
10
- body: %({"meta":{"code":200},"data":{"trackings":[{"slug":"ups"}]}})
9
+ body: File.open('spec/requests/trackings.json')
11
10
  )
12
11
 
13
- # tracking with real delivered data (simple)
12
+ # Get a tracking
14
13
  WebMock.stub_request(
15
14
  :get,
16
- 'https://api.aftership.com/v3/trackings/ups/delivered-ok'
15
+ 'https://api.aftership.com/v4/trackings/ups/delivered'
17
16
  ).with(
18
- body: '{}',
19
17
  headers: { 'Aftership-Api-Key' => 'key' }
20
18
  ).to_return(
21
19
  status: 200,
22
- body: File.open('spec/requests/tracking/delivered_ok.json')
20
+ body: File.open('spec/requests/tracking/delivered.json')
23
21
  )
24
22
 
25
- # tracking with real delivered data (a lot of checkpoints)
26
- WebMock.stub_request(
27
- :get,
28
- 'https://api.aftership.com/v3/trackings/ups/delivered-wild'
29
- ).with(
30
- body: '{}',
31
- headers: { 'Aftership-Api-Key' => 'key' }
32
- ).to_return(
33
- status: 200,
34
- body: File.open('spec/requests/tracking/delivered_wild.json')
35
- )
36
-
37
- # tracking with real in-transit data
38
- WebMock.stub_request(
39
- :get,
40
- 'https://api.aftership.com/v3/trackings/usps/in-transit'
41
- ).with(
42
- body: '{}',
43
- headers: { 'Aftership-Api-Key' => 'key' }
44
- ).to_return(
45
- status: 200,
46
- body: File.open('spec/requests/tracking/in_transit.json')
47
- )
48
-
49
- # tracking
50
- WebMock.stub_request(
51
- :get,
52
- 'https://api.aftership.com/v3/trackings/ups/ABC123'
53
- ).with(
54
- body: '{}',
55
- headers: { 'Aftership-Api-Key' => 'key' }
56
- ).to_return(
57
- status: 200,
58
- body: %({"meta":{"code":200},"data":{"tracking":{}}})
59
- )
60
-
61
- [201, 400, 401, 402, 404, 409, 429, 500, 502, 503, 504, 666].each do |code|
62
- WebMock.stub_request(
63
- :get,
64
- "https://api.aftership.com/v3/trackings/ups/#{ code }"
65
- ).with(
66
- body: '{}',
67
- headers: { 'Aftership-Api-Key' => 'key' }
68
- ).to_return(
69
- status: 200,
70
- body: %({"meta":{"code":#{code}},"data":{"tracking":{"slug":"ups"}}})
71
- )
72
- end
73
-
74
- # create_tracking
23
+ # Create a tracking
75
24
  WebMock.stub_request(
76
25
  :post,
77
- 'https://api.aftership.com/v3/trackings'
26
+ 'https://api.aftership.com/v4/trackings'
78
27
  ).with(
79
- body: %({"tracking":{"tracking_number":"ABC123","slug":"ups"}}),
80
- headers: { 'Aftership-Api-Key' => 'key' }
81
- ).to_return(
82
- status: 200,
83
- body: %({"meta":{"code":200},"data":{"tracking":{"slug":"ups"}}})
84
- )
85
-
86
- WebMock.stub_request(
87
- :post,
88
- 'https://api.aftership.com/v3/trackings'
89
- ).with(
90
- body: %({"tracking":{"tracking_number":"ABC123","slug":"ups","order_id":"1234"}}), # rubocop:disable Metrics/LineLength
91
- headers: { 'Aftership-Api-Key' => 'key' }
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
+ )
92
36
  ).to_return(
93
37
  status: 200,
94
- body: %({"meta":{"code":200},"data":{"tracking":{"slug":"ups"}}})
38
+ body: File.open('spec/requests/tracking/created.json')
95
39
  )
96
40
 
97
- # update_tracking
98
-
41
+ # Update a tracking
99
42
  WebMock.stub_request(
100
43
  :put,
101
- 'https://api.aftership.com/v3/trackings/ups/ABC123'
44
+ 'https://api.aftership.com/v4/trackings/ups/updated'
102
45
  ).with(
103
- body: %({"tracking":{"order_id":"1234"}}),
104
- headers: { 'Aftership-Api-Key' => 'key' }
105
- ).to_return(
106
- status: 200,
107
- body: %({"meta":{"code":200},"data":{"tracking":{"slug":"ups"}}})
108
- )
109
-
110
- ## App-specific AfterShip tests
111
-
112
- # create_tracking
113
- WebMock.stub_request(
114
- :post,
115
- 'https://api.aftership.com/v3/trackings'
116
- ).with(
117
- body: %({"tracking":{"tracking_number":"ABC123","slug":"ups","order_id":"1234"}}), # rubocop:disable Metrics/LineLength
118
- headers: { 'Aftership-Api-Key' => 'key' }
46
+ headers: { 'Aftership-Api-Key' => 'key' },
47
+ body: MultiJson.dump(
48
+ 'tracking' => {
49
+ 'order_id' => 'external-id'
50
+ }
51
+ )
119
52
  ).to_return(
120
53
  status: 200,
121
- body: %({"meta":{"code":200},"data":{"tracking":{"slug":"ups"}}})
54
+ body: File.open('spec/requests/tracking/created.json')
122
55
  )
123
56
 
57
+ # Couriers
124
58
  WebMock.stub_request(
125
- :post,
126
- 'https://api.aftership.com/v3/trackings'
59
+ :get,
60
+ 'https://api.aftership.com/v4/couriers'
127
61
  ).with(
128
- body: %({"tracking":{"tracking_number":"EXISTING","slug":"ups","order_id":"1234"}}), # rubocop:disable Metrics/LineLength
129
62
  headers: { 'Aftership-Api-Key' => 'key' }
130
63
  ).to_return(
131
64
  status: 200,
132
- body: %({"meta":{"code":409}})
65
+ body: File.open('spec/requests/couriers.json')
133
66
  )
@@ -0,0 +1,50 @@
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
+ }
@@ -0,0 +1,53 @@
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
+ }
@@ -4,43 +4,57 @@
4
4
  },
5
5
  "data": {
6
6
  "tracking": {
7
- "created_at": "2014-05-05T13:50:27+00:00",
8
- "updated_at": "2014-07-18T08:04:49+00:00",
9
- "tracking_number": "1ZA2207X6791425225",
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,
10
14
  "slug": "ups",
11
15
  "active": false,
16
+ "android": [
17
+
18
+ ],
12
19
  "custom_fields": {
13
20
  },
14
21
  "customer_name": null,
22
+ "delivery_time": 4,
15
23
  "destination_country_iso3": "USA",
16
24
  "emails": [
17
25
 
18
26
  ],
19
27
  "expected_delivery": null,
20
- "order_id": "PL-55120855",
28
+ "ios": [
29
+
30
+ ],
31
+ "note": null,
32
+ "order_id": "PL-35210992",
21
33
  "order_id_path": null,
22
34
  "origin_country_iso3": "IND",
23
- "shipment_package_count": 0,
24
- "shipment_type": "EXPEDITED",
25
- "signed_by": "FRONT DOOR",
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)",
26
40
  "smses": [
27
41
 
28
42
  ],
29
43
  "source": "api",
30
44
  "tag": "Delivered",
31
- "title": "1ZA2207X6791425225",
32
- "tracked_count": 29,
33
- "unique_token": "xJ8CBha3T",
45
+ "title": "1ZA2207X0444990982",
46
+ "tracked_count": 3,
47
+ "unique_token": "bk6ysTW1U",
34
48
  "checkpoints": [
35
49
  {
36
50
  "slug": "ups",
37
51
  "city": null,
38
- "created_at": "2014-05-05T13:50:27+00:00",
52
+ "created_at": "2014-11-03T15:36:41+00:00",
39
53
  "country_name": "IN",
40
54
  "message": "BILLING INFORMATION RECEIVED",
41
55
  "country_iso3": "IND",
42
56
  "tag": "InfoReceived",
43
- "checkpoint_time": "2014-05-04T14:06:23",
57
+ "checkpoint_time": "2014-10-30T10:05:48",
44
58
  "coordinates": [
45
59
 
46
60
  ],
@@ -50,12 +64,12 @@
50
64
  {
51
65
  "slug": "ups",
52
66
  "city": "MUMBAI",
53
- "created_at": "2014-05-05T18:19:57+00:00",
67
+ "created_at": "2014-11-03T15:36:41+00:00",
54
68
  "country_name": "IN",
55
69
  "message": "PICKUP SCAN",
56
70
  "country_iso3": null,
57
71
  "tag": "InTransit",
58
- "checkpoint_time": "2014-05-05T19:56:00",
72
+ "checkpoint_time": "2014-10-30T20:02:00",
59
73
  "coordinates": [
60
74
 
61
75
  ],
@@ -65,12 +79,12 @@
65
79
  {
66
80
  "slug": "ups",
67
81
  "city": "MUMBAI",
68
- "created_at": "2014-05-06T00:30:19+00:00",
82
+ "created_at": "2014-11-03T15:36:42+00:00",
69
83
  "country_name": "IN",
70
84
  "message": "ORIGIN SCAN",
71
85
  "country_iso3": null,
72
86
  "tag": "InTransit",
73
- "checkpoint_time": "2014-05-06T03:43:00",
87
+ "checkpoint_time": "2014-10-31T02:54:00",
74
88
  "coordinates": [
75
89
 
76
90
  ],
@@ -80,12 +94,12 @@
80
94
  {
81
95
  "slug": "ups",
82
96
  "city": "MUMBAI",
83
- "created_at": "2014-05-06T00:30:19+00:00",
97
+ "created_at": "2014-11-03T15:36:42+00:00",
84
98
  "country_name": "IN",
85
99
  "message": "DEPARTURE SCAN",
86
100
  "country_iso3": null,
87
101
  "tag": "InTransit",
88
- "checkpoint_time": "2014-05-06T05:44:00",
102
+ "checkpoint_time": "2014-10-31T05:45:00",
89
103
  "coordinates": [
90
104
 
91
105
  ],
@@ -95,12 +109,12 @@
95
109
  {
96
110
  "slug": "ups",
97
111
  "city": "MUMBAI",
98
- "created_at": "2014-05-06T04:37:39+00:00",
112
+ "created_at": "2014-11-03T15:36:42+00:00",
99
113
  "country_name": "IN",
100
114
  "message": "ARRIVAL SCAN",
101
115
  "country_iso3": null,
102
116
  "tag": "InTransit",
103
- "checkpoint_time": "2014-05-06T06:11:00",
117
+ "checkpoint_time": "2014-10-31T06:01:00",
104
118
  "coordinates": [
105
119
 
106
120
  ],
@@ -110,12 +124,12 @@
110
124
  {
111
125
  "slug": "ups",
112
126
  "city": "MUMBAI",
113
- "created_at": "2014-05-06T13:23:12+00:00",
127
+ "created_at": "2014-11-03T15:36:42+00:00",
114
128
  "country_name": "IN",
115
129
  "message": "DEPARTURE SCAN",
116
130
  "country_iso3": null,
117
131
  "tag": "InTransit",
118
- "checkpoint_time": "2014-05-06T15:43:00",
132
+ "checkpoint_time": "2014-10-31T16:55:00",
119
133
  "coordinates": [
120
134
 
121
135
  ],
@@ -124,13 +138,13 @@
124
138
  },
125
139
  {
126
140
  "slug": "ups",
127
- "city": "KOELN (COLOGNE)",
128
- "created_at": "2014-05-06T21:53:37+00:00",
141
+ "city": null,
142
+ "created_at": "2014-11-03T15:36:42+00:00",
129
143
  "country_name": "DE",
130
- "message": "ARRIVAL SCAN",
131
- "country_iso3": null,
144
+ "message": "THE PACKAGE IS AWAITING CLEARING AGENCY REVIEW. / THE PACKAGE IS AT THE CLEARING AGENCY AWAITING FINAL RELEASE.",
145
+ "country_iso3": "DEU",
132
146
  "tag": "InTransit",
133
- "checkpoint_time": "2014-05-06T20:30:00",
147
+ "checkpoint_time": "2014-11-01T00:18:00",
134
148
  "coordinates": [
135
149
 
136
150
  ],
@@ -140,12 +154,12 @@
140
154
  {
141
155
  "slug": "ups",
142
156
  "city": "KOELN (COLOGNE)",
143
- "created_at": "2014-05-07T04:08:35+00:00",
157
+ "created_at": "2014-11-03T15:36:42+00:00",
144
158
  "country_name": "DE",
145
159
  "message": "DEPARTURE SCAN",
146
160
  "country_iso3": null,
147
161
  "tag": "InTransit",
148
- "checkpoint_time": "2014-05-07T05:30:00",
162
+ "checkpoint_time": "2014-11-01T01:12:00",
149
163
  "coordinates": [
150
164
 
151
165
  ],
@@ -154,108 +168,108 @@
154
168
  },
155
169
  {
156
170
  "slug": "ups",
157
- "city": "PHILADELPHIA",
158
- "created_at": "2014-05-07T13:04:20+00:00",
159
- "country_name": "US",
160
- "message": "ARRIVAL SCAN",
161
- "country_iso3": null,
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",
162
176
  "tag": "InTransit",
163
- "checkpoint_time": "2014-05-07T08:05:00",
177
+ "checkpoint_time": "2014-11-02T08:17:00",
164
178
  "coordinates": [
165
179
 
166
180
  ],
167
- "state": "PA",
181
+ "state": null,
168
182
  "zip": null
169
183
  },
170
184
  {
171
185
  "slug": "ups",
172
- "city": "PHILADELPHIA",
173
- "created_at": "2014-05-07T17:36:54+00:00",
186
+ "city": "LOUISVILLE",
187
+ "created_at": "2014-11-03T15:36:42+00:00",
174
188
  "country_name": "US",
175
189
  "message": "IMPORT SCAN",
176
190
  "country_iso3": null,
177
191
  "tag": "InTransit",
178
- "checkpoint_time": "2014-05-07T10:31:00",
192
+ "checkpoint_time": "2014-11-02T11:44:00",
179
193
  "coordinates": [
180
194
 
181
195
  ],
182
- "state": "PA",
196
+ "state": "KY",
183
197
  "zip": null
184
198
  },
185
199
  {
186
200
  "slug": "ups",
187
- "city": "PHILADELPHIA",
188
- "created_at": "2014-05-08T08:54:42+00:00",
201
+ "city": "LOUISVILLE",
202
+ "created_at": "2014-11-03T15:36:42+00:00",
189
203
  "country_name": "US",
190
204
  "message": "DEPARTURE SCAN",
191
205
  "country_iso3": null,
192
206
  "tag": "InTransit",
193
- "checkpoint_time": "2014-05-08T02:52:00",
207
+ "checkpoint_time": "2014-11-02T15:45:00",
194
208
  "coordinates": [
195
209
 
196
210
  ],
197
- "state": "PA",
211
+ "state": "KY",
198
212
  "zip": null
199
213
  },
200
214
  {
201
215
  "slug": "ups",
202
- "city": "PHILADELPHIA",
203
- "created_at": "2014-05-08T08:54:42+00:00",
216
+ "city": "OAKLAND",
217
+ "created_at": "2014-11-03T15:36:42+00:00",
204
218
  "country_name": "US",
205
219
  "message": "ARRIVAL SCAN",
206
220
  "country_iso3": null,
207
221
  "tag": "InTransit",
208
- "checkpoint_time": "2014-05-08T03:13:00",
222
+ "checkpoint_time": "2014-11-02T17:20:00",
209
223
  "coordinates": [
210
224
 
211
225
  ],
212
- "state": "PA",
226
+ "state": "CA",
213
227
  "zip": null
214
228
  },
215
229
  {
216
230
  "slug": "ups",
217
- "city": "PHILADELPHIA",
218
- "created_at": "2014-05-08T13:22:52+00:00",
231
+ "city": "OAKLAND",
232
+ "created_at": "2014-11-03T15:36:42+00:00",
219
233
  "country_name": "US",
220
- "message": "OUT FOR DELIVERY",
234
+ "message": "DEPARTURE SCAN",
221
235
  "country_iso3": null,
222
- "tag": "OutForDelivery",
223
- "checkpoint_time": "2014-05-08T06:35:00",
236
+ "tag": "InTransit",
237
+ "checkpoint_time": "2014-11-03T03:22:00",
224
238
  "coordinates": [
225
239
 
226
240
  ],
227
- "state": "PA",
241
+ "state": "CA",
228
242
  "zip": null
229
243
  },
230
244
  {
231
245
  "slug": "ups",
232
- "city": "PHILADELPHIA",
233
- "created_at": "2014-05-08T16:41:11+00:00",
246
+ "city": "SAN FRANCISCO",
247
+ "created_at": "2014-11-03T15:36:42+00:00",
234
248
  "country_name": "US",
235
- "message": "DESTINATION SCAN",
249
+ "message": "OUT FOR DELIVERY",
236
250
  "country_iso3": null,
237
- "tag": "InTransit",
238
- "checkpoint_time": "2014-05-08T06:35:00",
251
+ "tag": "OutForDelivery",
252
+ "checkpoint_time": "2014-11-03T06:20:00",
239
253
  "coordinates": [
240
254
 
241
255
  ],
242
- "state": "PA",
256
+ "state": "CA",
243
257
  "zip": null
244
258
  },
245
259
  {
246
260
  "slug": "ups",
247
- "city": "PHILADELPHIA",
248
- "created_at": "2014-05-08T16:41:11+00:00",
261
+ "city": "SAN FRANCISCO",
262
+ "created_at": "2014-11-03T19:55:45+00:00",
249
263
  "country_name": "US",
250
264
  "message": "DELIVERED",
251
265
  "country_iso3": null,
252
266
  "tag": "Delivered",
253
- "checkpoint_time": "2014-05-08T12:31:00",
267
+ "checkpoint_time": "2014-11-03T09:56:00",
254
268
  "coordinates": [
255
269
 
256
270
  ],
257
- "state": "PA",
258
- "zip": "19106"
271
+ "state": "CA",
272
+ "zip": "94110"
259
273
  }
260
274
  ]
261
275
  }