after_ship 0.0.4 → 0.0.5

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
  SHA1:
3
- metadata.gz: 3060bd34a3212af9a3fc8d11f6639218eb721a21
4
- data.tar.gz: 6cc52a30fd7414efb6cfe67a91dd1823191bda4d
3
+ metadata.gz: e2612a655857c96bc533957c3da0cf03989d36e3
4
+ data.tar.gz: 41fee10a3620d19bda2dbbda5b251aa0d3e0e9cb
5
5
  SHA512:
6
- metadata.gz: a40b8f5a968c21b2c61fbe139c729ced7fd0d4ea66930fb1d8fbece394bdf0504d009e20b1d0090fe1cb7083119220230c57d607ac24eeaef0bfbd19efa1054d
7
- data.tar.gz: 3bf32a786e3dcd6846363fa46035b67855aa312b46ff804c81570e73b4e07737bc11f6fe8aa9bc5cb59d559424f438e6d7f93a515cc4fd74faa899318b284684
6
+ metadata.gz: 67eeb6d9f3805833a5b2a82c96a6c6ba4aeef97cbe9f156d2f036abed2de4f02b7abecbcf9e640af9966cc495a8be901539726673bda5612b388f6c1830fcfbf
7
+ data.tar.gz: 3bf88f54b44171695ad65a5c516f4a7e6d56b0de4ce54a57425bbfaef788fb57d2f59d0b0b22def4bafa55343e36284b8c080db260739d50cb800f5db63acce2
data/README.md CHANGED
@@ -2,40 +2,46 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/ollie/after_ship.svg?branch=master)](https://travis-ci.org/ollie/after_ship)
4
4
 
5
- A smallish library to talking to AfterShip via v4 API.
5
+ A smallish library to talking to AfterShip via v4 API. It currently supports
6
+ those methods:
7
+
8
+ * Get a list of trackings,
9
+ * Get a particular tracking (with tracking_number + slug combination),
10
+ * Create a tracking,
11
+ * Update a tracking (with tracking_number + slug combination),
12
+ * Get activated couriers.
13
+
14
+ I may implement other methods if I need them or if you are interested.
6
15
 
7
16
  You will need an AfterShip API key, see here https://www.aftership.com/docs/api/4.
8
17
  The JSON is parsed by MultiJson (https://github.com/intridea/multi_json) so
9
18
  you may want to drop in your favorite JSON engine.
10
19
 
11
- ## Installation
12
-
13
- Add this line to your application's Gemfile:
14
-
15
- ```ruby
16
- gem 'after_ship', git: 'https://github.com/ollie/after_ship.git'
17
- ```
18
-
19
- And then execute:
20
-
21
- $ bundle
22
-
23
20
  ## Usage
24
21
 
25
- Init the client:
22
+ ### Init the client
26
23
 
27
24
  ```ruby
28
25
  client = AfterShip.new(api_key: 'your-aftership-api-key')
29
26
  ```
30
27
 
31
- Get a list of trackings
32
- https://www.aftership.com/docs/api/4/trackings/get-trackings
28
+ ### [Get a list of trackings][trackings_url]
33
29
 
34
30
  ```ruby
35
- client.trackings
31
+ trackings = client.trackings
32
+
33
+ trackings.each do |tracking|
34
+ puts tracking.tracking_number
35
+
36
+ tracking.checkpoints.each do |checkpoint|
37
+ puts "#{ checkpoint.city } #{ checkpoint.checkpoint_time }"
38
+ end
39
+ end
40
+ ```
36
41
 
37
- # Will return list of Tracking objects:
42
+ Returns a list of `AfterShip::Tracking` objects:
38
43
 
44
+ ```
39
45
  [
40
46
  #<AfterShip::Tracking ...>,
41
47
  #<AfterShip::Tracking ...>,
@@ -43,14 +49,21 @@ client.trackings
43
49
  ]
44
50
  ```
45
51
 
46
- Get a tracking
47
- https://www.aftership.com/docs/api/4/trackings/get-trackings-slug-tracking_number
52
+ ### [Get a tracking][tracking_url]
48
53
 
49
54
  ```ruby
50
- client.tracking('tracking-number', 'ups')
55
+ tracking = client.tracking('tracking-number', 'ups')
51
56
 
52
- # Will return Tracking object or raise AfterShip::Error::NotFound:
57
+ puts tracking.tracking_number
53
58
 
59
+ tracking.checkpoints.each do |checkpoint|
60
+ puts "#{ checkpoint.city } #{ checkpoint.checkpoint_time }"
61
+ end
62
+ ```
63
+
64
+ Returns a `AfterShip::Tracking` object or raises a `AfterShip::Error::NotFound` if not found:
65
+
66
+ ```
54
67
  #<AfterShip::Tracking:0x007f838ef44e58
55
68
  @active=false,
56
69
  @android=[],
@@ -107,38 +120,44 @@ client.tracking('tracking-number', 'ups')
107
120
  >
108
121
  ```
109
122
 
110
- Create a new tracking
111
- https://www.aftership.com/docs/api/4/trackings/post-trackings
123
+ ### [Create a new tracking][create_tracking_url]
112
124
 
113
125
  ```ruby
114
- client.create_tracking('tracking-number', 'ups', order_id: 'external-id')
126
+ tracking = client.create_tracking('tracking-number', 'ups', order_id: 'external-id')
127
+ ```
115
128
 
116
- # Will return Tracking object or raise
117
- # AfterShip::Error::TrackingAlreadyExists:
129
+ Returns a `AfterShip::Tracking` object or raises a `AfterShip::Error::TrackingAlreadyExists`
130
+ if tracking already exists:
118
131
 
132
+ ```
119
133
  #<AfterShip::Tracking ...>
120
134
  ```
121
135
 
122
- Update a tracking
123
- https://www.aftership.com/docs/api/4/trackings/put-trackings-slug-tracking_number
136
+ ### [Update a tracking][update_tracking_url]
124
137
 
125
138
  ```ruby
126
- client.update_tracking('tracking-number', 'ups', order_id: 'external-id')
139
+ tracking = client.update_tracking('tracking-number', 'ups', order_id: 'external-id')
140
+ ```
127
141
 
128
- # Will return Tracking object or raise
129
- # AfterShip::Error::TrackingAlreadyExists:
142
+ Returns a `AfterShip::Tracking` object or raises a `AfterShip::Error::NotFound` if not found:
130
143
 
144
+ ```
131
145
  #<AfterShip::Tracking ...>
132
146
  ```
133
147
 
134
- Get activated couriers
135
- https://www.aftership.com/docs/api/4/couriers/get-couriers
148
+ ### [Get activated couriers][couriers_url]
136
149
 
137
150
  ```ruby
138
- client.couriers
151
+ couriers = client.couriers
152
+
153
+ couriers.each do |courier|
154
+ puts "#{ courier.name } #{ courier.other_name }"
155
+ end
156
+ ```
139
157
 
140
- # Will return list of Courier objects:
158
+ Returns a list of `AfterShip::Courier` objects:
141
159
 
160
+ ```
142
161
  [
143
162
  #<AfterShip::Courier:0x007fa2771d4bf8
144
163
  @name="USPS",
@@ -152,11 +171,69 @@ client.couriers
152
171
  ]
153
172
  ```
154
173
 
174
+ ### [Errors][errors_url]
175
+
176
+ The library can respond with all of the v4 errors. The first colum is
177
+ HTTP status code, the second meta code. The indentation indicates inheritance.
178
+
179
+ ```
180
+ | HTTP | Meta | Error class |
181
+ |------+------+--------------------------------------------|
182
+ | 400 | 400 | AfterShip::Error::BadRequest |
183
+ | 400 | 4001 | AfterShip::Error::InvalidJsonData |
184
+ | 400 | 4002 | AfterShip::Error::InvalidJsonData |
185
+ | 400 | 4003 | AfterShip::Error::TrackingAlreadyExists |
186
+ | 400 | 4004 | AfterShip::Error::TrackingDoesNotExist |
187
+ | 400 | 4005 | AfterShip::Error::TrackingNumberInvalid |
188
+ | 400 | 4006 | AfterShip::Error::TrackingObjectRequired |
189
+ | 400 | 4007 | AfterShip::Error::TrackingNumberRequired |
190
+ | 400 | 4008 | AfterShip::Error::FieldInvalid |
191
+ | 400 | 4009 | AfterShip::Error::FieldRequired |
192
+ | 400 | 4010 | AfterShip::Error::SlugInvalid |
193
+ | 400 | 4011 | AfterShip::Error::CourierFieldInvalid |
194
+ | 400 | 4012 | AfterShip::Error::CourierNotDetected |
195
+ | 400 | 4013 | AfterShip::Error::RetrackNotAllowed |
196
+ | 400 | 4016 | AfterShip::Error::RetrackNotAllowed |
197
+ | 400 | 4014 | AfterShip::Error::NotificationRequired |
198
+ | 400 | 4015 | AfterShip::Error::IdInvalid |
199
+ | 401 | 401 | AfterShip::Error::Unauthorized |
200
+ | 403 | 403 | AfterShip::Error::Forbidden |
201
+ | 404 | 404 | AfterShip::Error::NotFound |
202
+ | 429 | 429 | AfterShip::Error::TooManyRequests |
203
+ | 500 | 500 | AfterShip::Error::InternalError |
204
+ | 502 | 502 | AfterShip::Error::InternalError |
205
+ | 503 | 503 | AfterShip::Error::InternalError |
206
+ | 504 | 504 | AfterShip::Error::InternalError |
207
+ ```
208
+
209
+ ## Installation
210
+
211
+ Add this line to your application's Gemfile:
212
+
213
+ ```ruby
214
+ gem 'after_ship'
215
+ ```
216
+
217
+ And then execute:
218
+
219
+ $ bundle
220
+
221
+ Or install it yourself as:
222
+
223
+ $ gem install after_ship
224
+
155
225
  ## Contributing
156
226
 
157
- 0. E-mail me or create an issue
158
- 1. Fork it (https://github.com/ollie/after_ship/fork)
159
- 2. Create your feature branch (`git checkout -b my-new-feature`)
160
- 3. Commit your changes (`git commit -am 'Add some feature'`)
161
- 4. Push to the branch (`git push origin my-new-feature`)
162
- 5. Create a new Pull Request
227
+ 0. E-mail me or create an issue.
228
+ 1. Fork it (https://github.com/ollie/after_ship/fork).
229
+ 2. Create your feature branch (`git checkout -b my-new-feature`).
230
+ 3. Commit your changes (`git commit -am 'Add some feature'`).
231
+ 4. Push to the branch (`git push origin my-new-feature`).
232
+ 5. Create a new Pull Request.
233
+
234
+ [trackings_url]: https://www.aftership.com/docs/api/4/trackings/get-trackings
235
+ [tracking_url]: https://www.aftership.com/docs/api/4/trackings/get-trackings-slug-tracking_number
236
+ [create_tracking_url]: https://www.aftership.com/docs/api/4/trackings/post-trackings
237
+ [update_tracking_url]: https://www.aftership.com/docs/api/4/trackings/put-trackings-slug-tracking_number
238
+ [couriers_url]: https://www.aftership.com/docs/api/4/couriers/get-couriers
239
+ [errors_url]: https://www.aftership.com/docs/api/4/errors
@@ -1,4 +1,4 @@
1
1
  class AfterShip
2
2
  # Version number, happy now?
3
- VERSION = '0.0.4'
3
+ VERSION = '0.0.5'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: after_ship
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oldrich Vetesnik