aftership-tracking-sdk 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +11 -0
- data/LICENSE +21 -0
- data/README.md +285 -0
- data/aftership-tracking-sdk.gemspec +27 -0
- data/lib/aftership-tracking-sdk/api/courier.rb +163 -0
- data/lib/aftership-tracking-sdk/api/estimated_delivery_date.rb +67 -0
- data/lib/aftership-tracking-sdk/api/last_checkpoint.rb +143 -0
- data/lib/aftership-tracking-sdk/api/notification.rb +403 -0
- data/lib/aftership-tracking-sdk/api/tracking.rb +793 -0
- data/lib/aftership-tracking-sdk/api_client.rb +426 -0
- data/lib/aftership-tracking-sdk/configuration.rb +122 -0
- data/lib/aftership-tracking-sdk/error.rb +125 -0
- data/lib/aftership-tracking-sdk/models/additional_fields_v1.rb +32 -0
- data/lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_tracking.rb +181 -0
- data/lib/aftership-tracking-sdk/models/carbon_emissions_tracking.rb +161 -0
- data/lib/aftership-tracking-sdk/models/checkpoint.rb +301 -0
- data/lib/aftership-tracking-sdk/models/coordinate_checkpoint.rb +161 -0
- data/lib/aftership-tracking-sdk/models/courier.rb +241 -0
- data/lib/aftership-tracking-sdk/models/courier_response_v1.rb +161 -0
- data/lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_tracking.rb +181 -0
- data/lib/aftership-tracking-sdk/models/custom_fields_tracking_update_tracking_by_slug_tracking_number_request.rb +139 -0
- data/lib/aftership-tracking-sdk/models/data_courier_response_v1.rb +161 -0
- data/lib/aftership-tracking-sdk/models/data_notification_response_v1.rb +151 -0
- data/lib/aftership-tracking-sdk/models/data_tracking_delete_response_v1.rb +151 -0
- data/lib/aftership-tracking-sdk/models/data_tracking_response_get_multiple_v1.rb +281 -0
- data/lib/aftership-tracking-sdk/models/data_tracking_response_v1.rb +151 -0
- data/lib/aftership-tracking-sdk/models/destination_address_estimated_delivery_date_request.rb +191 -0
- data/lib/aftership-tracking-sdk/models/destination_address_estimated_delivery_date_response.rb +191 -0
- data/lib/aftership-tracking-sdk/models/detect_courier_response.rb +161 -0
- data/lib/aftership-tracking-sdk/models/estimated_delivery_date_request.rb +221 -0
- data/lib/aftership-tracking-sdk/models/estimated_delivery_date_response.rb +261 -0
- data/lib/aftership-tracking-sdk/models/estimated_pickup_estimated_delivery_date_request.rb +181 -0
- data/lib/aftership-tracking-sdk/models/estimated_pickup_estimated_delivery_date_response.rb +191 -0
- data/lib/aftership-tracking-sdk/models/events_checkpoint.rb +161 -0
- data/lib/aftership-tracking-sdk/models/first_estimated_delivery_tracking.rb +191 -0
- data/lib/aftership-tracking-sdk/models/get_all_couriers_response.rb +161 -0
- data/lib/aftership-tracking-sdk/models/get_checkpoint_by_slug_tracking_number_response.rb +211 -0
- data/lib/aftership-tracking-sdk/models/get_checkpoint_by_tracking_id_response.rb +211 -0
- data/lib/aftership-tracking-sdk/models/get_trackings_response.rb +161 -0
- data/lib/aftership-tracking-sdk/models/get_user_couriers_response.rb +161 -0
- data/lib/aftership-tracking-sdk/models/latest_estimated_delivery_tracking.rb +191 -0
- data/lib/aftership-tracking-sdk/models/mark_tracking_completed_by_id_request.rb +151 -0
- data/lib/aftership-tracking-sdk/models/mark_tracking_completed_by_slug_tracking_number_request.rb +151 -0
- data/lib/aftership-tracking-sdk/models/meta_v1.rb +171 -0
- data/lib/aftership-tracking-sdk/models/next_couriers_tracking.rb +171 -0
- data/lib/aftership-tracking-sdk/models/next_couriers_tracking_create_tracking_request.rb +161 -0
- data/lib/aftership-tracking-sdk/models/notification.rb +161 -0
- data/lib/aftership-tracking-sdk/models/notification_request_v1.rb +161 -0
- data/lib/aftership-tracking-sdk/models/notification_response_v1.rb +161 -0
- data/lib/aftership-tracking-sdk/models/order_processing_time_estimated_pickup_estimated_delivery_date_request.rb +161 -0
- data/lib/aftership-tracking-sdk/models/order_processing_time_estimated_pickup_estimated_delivery_date_response.rb +161 -0
- data/lib/aftership-tracking-sdk/models/origin_address_estimated_delivery_date_request.rb +191 -0
- data/lib/aftership-tracking-sdk/models/origin_address_estimated_delivery_date_response.rb +191 -0
- data/lib/aftership-tracking-sdk/models/pagination.rb +156 -0
- data/lib/aftership-tracking-sdk/models/partial_delete_tracking.rb +241 -0
- data/lib/aftership-tracking-sdk/models/partial_update_tracking.rb +251 -0
- data/lib/aftership-tracking-sdk/models/predict_batch_request.rb +151 -0
- data/lib/aftership-tracking-sdk/models/predict_batch_response.rb +151 -0
- data/lib/aftership-tracking-sdk/models/reason_events_checkpoint.rb +151 -0
- data/lib/aftership-tracking-sdk/models/slug_group_v1.rb +37 -0
- data/lib/aftership-tracking-sdk/models/tag_v1.rb +34 -0
- data/lib/aftership-tracking-sdk/models/tracking.rb +921 -0
- data/lib/aftership-tracking-sdk/models/tracking_create_tracking_request.rb +551 -0
- data/lib/aftership-tracking-sdk/models/tracking_delete_response_v1.rb +161 -0
- data/lib/aftership-tracking-sdk/models/tracking_detect_courier_request.rb +261 -0
- data/lib/aftership-tracking-sdk/models/tracking_response_get_multiple_v1.rb +161 -0
- data/lib/aftership-tracking-sdk/models/tracking_response_v1.rb +161 -0
- data/lib/aftership-tracking-sdk/models/tracking_update_tracking_by_id_request.rb +501 -0
- data/lib/aftership-tracking-sdk/models/tracking_update_tracking_by_slug_tracking_number_request.rb +391 -0
- data/lib/aftership-tracking-sdk/models/weight_estimated_delivery_date_request.rb +161 -0
- data/lib/aftership-tracking-sdk/models/weight_estimated_delivery_date_response.rb +161 -0
- data/lib/aftership-tracking-sdk/sign_string.rb +77 -0
- data/lib/aftership-tracking-sdk/version.rb +5 -0
- data/lib/aftership-tracking-sdk.rb +47 -0
- metadata +157 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b560ff92050a3b12743fc681acf86dec23a3e9aac74ca21482ae1eb1009bbdd1
|
4
|
+
data.tar.gz: 8b151513a014450d4aee600b9234d0389d3e2af4490ac843463690b89e358da3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 475be9f3d5f13bd091c8747f34222b140df69a05e093e8e131e0ec8eb4226036d42b5c6930c7b301952c89274185321b92cd8ed0839969fee35b796b2692d621
|
7
|
+
data.tar.gz: 284af39f619b5a6073fc36abf4a6cae79ad95a970e71a1bce55ff366f62f2bcbf6eda5be598df54cafe9044d3126d949d1cfbf2390779aa343313591bfcb201c
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 AfterShip
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,285 @@
|
|
1
|
+
# AfterShip Tracking API library for Ruby
|
2
|
+
|
3
|
+
This library allows you to quickly and easily use the AfterShip Tracking API via Go.
|
4
|
+
|
5
|
+
For updates to this library, see our [GitHub release page](https://github.com/AfterShip/tracking-sdk-ruby/releases).
|
6
|
+
|
7
|
+
If you need support using AfterShip products, please contact support@aftership.com.
|
8
|
+
|
9
|
+
## Table of Contents
|
10
|
+
|
11
|
+
- [AfterShip Tracking API library for Ruby](#aftership-tracking-api-library-for-ruby)
|
12
|
+
- [Table of Contents](#table-of-contents)
|
13
|
+
- [Before you begin](#before-you-begin)
|
14
|
+
- [Quick Start](#quick-start)
|
15
|
+
- [Installation](#installation)
|
16
|
+
- [Constructor](#constructor)
|
17
|
+
- [Example](#example)
|
18
|
+
- [Rate Limiter](#rate-limiter)
|
19
|
+
- [Error Handling](#error-handling)
|
20
|
+
- [Error List](#error-list)
|
21
|
+
- [Endpoints](#endpoints)
|
22
|
+
- [/trackings](#trackings)
|
23
|
+
- [/couriers](#couriers)
|
24
|
+
- [/last\_checkpoint](#last_checkpoint)
|
25
|
+
- [/notifications](#notifications)
|
26
|
+
- [/estimated-delivery-date](#estimated-delivery-date)
|
27
|
+
- [Help](#help)
|
28
|
+
- [License](#license)
|
29
|
+
|
30
|
+
|
31
|
+
## Before you begin
|
32
|
+
|
33
|
+
Before you begin to integrate:
|
34
|
+
|
35
|
+
- [Create an AfterShip account](https://admin.aftership.com/).
|
36
|
+
- [Create an API key](https://organization.automizely.com/api-keys).
|
37
|
+
- [Install Ruby](https://www.ruby-lang.org/en/) version Ruby 2.7 or later.
|
38
|
+
|
39
|
+
## Quick Start
|
40
|
+
|
41
|
+
### Installation
|
42
|
+
```bash
|
43
|
+
gem install aftership-tracking-sdk
|
44
|
+
```
|
45
|
+
|
46
|
+
Or add a line to your Gemfile
|
47
|
+
|
48
|
+
```bash
|
49
|
+
gem 'aftership-tracking-sdk', '~> 7.0.0'
|
50
|
+
```
|
51
|
+
|
52
|
+
## Constructor
|
53
|
+
|
54
|
+
Create AfterShip instance with options
|
55
|
+
|
56
|
+
| Name | Type | Required | Description |
|
57
|
+
|------------|--------|----------|-----------------------------------------------------------------------------------------------------------------------------------|
|
58
|
+
| api_key | string | ✔ | Your AfterShip API key |
|
59
|
+
| auth_type | enum | | Default value: `AuthType.API_KEY` <br > AES authentication: `AuthType.AES` <br > RSA authentication: `AuthType.RSA` |
|
60
|
+
| api_secret | string | | Required if the authentication type is `AuthType.AES` or `AuthType.RSA` |
|
61
|
+
| domain | string | | AfterShip API domain. Default value: https://api.aftership.com |
|
62
|
+
| user_agent | string | | User-defined user-agent string, please follow [RFC9110](https://www.rfc-editor.org/rfc/rfc9110#field.user-agent) format standard. |
|
63
|
+
| proxy | string | | HTTP proxy URL to use for requests. <br > Default value: `null` <br > Example: `http://192.168.0.100:8888` |
|
64
|
+
| max_retry | number | | Number of retries for each request. Default value: 2. Min is 0, Max is 10. |
|
65
|
+
| timeout | number | | Timeout for each request in milliseconds. |
|
66
|
+
|
67
|
+
### Example
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
require 'aftership-tracking-sdk'
|
71
|
+
|
72
|
+
AftershipAPI.configure do |config|
|
73
|
+
config.as_api_key = "YOUR_API_KEY"
|
74
|
+
end
|
75
|
+
|
76
|
+
begin
|
77
|
+
resp = AftershipAPI::Tracking.get_trackings
|
78
|
+
p resp
|
79
|
+
rescue AftershipAPI::Error => e
|
80
|
+
p e.message
|
81
|
+
end
|
82
|
+
```
|
83
|
+
|
84
|
+
## Rate Limiter
|
85
|
+
|
86
|
+
See the [Rate Limit](https://www.aftership.com/docs/aftership/quickstart/rate-limit) to understand the AfterShip rate limit policy.
|
87
|
+
|
88
|
+
## Error Handling
|
89
|
+
|
90
|
+
The SDK will return an error object when there is any error during the request, with the following specification:
|
91
|
+
|
92
|
+
| Name | Type | Description |
|
93
|
+
|---------------|--------|--------------------------------|
|
94
|
+
| message | string | Detail message of the error |
|
95
|
+
| code | enum | Error code enum for API Error. |
|
96
|
+
| meta_code | number | API response meta code. |
|
97
|
+
| status_code | number | HTTP status code. |
|
98
|
+
| response_body | string | API response body. |
|
99
|
+
|
100
|
+
|
101
|
+
### Error List
|
102
|
+
|
103
|
+
| code | meta_code | status_code | message |
|
104
|
+
|-----------------------------------|------------------|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
105
|
+
| INVALID_REQUEST | 400 | 400 | The request was invalid or cannot be otherwise served. |
|
106
|
+
| INVALID_JSON | 4001 | 400 | Invalid JSON data. |
|
107
|
+
| TRACKING_ALREADY_EXIST | 4003 | 400 | Tracking already exists. |
|
108
|
+
| TRACKING_DOES_NOT_EXIST | 4004 | 404 | Tracking does not exist. |
|
109
|
+
| TRACKING_NUMBER_INVALID | 4005 | 400 | The value of tracking_number is invalid. |
|
110
|
+
| TRACKING_REQUIRED | 4006 | 400 | tracking object is required. |
|
111
|
+
| TRACKING_NUMBER_REQUIRED | 4007 | 400 | tracking_number is required. |
|
112
|
+
| VALUE_INVALID | 4008 | 400 | The value of [field_name] is invalid. |
|
113
|
+
| VALUE_REQUIRED | 4009 | 400 | [field_name] is required. |
|
114
|
+
| SLUG_INVALID | 4010 | 400 | The value of slug is invalid. |
|
115
|
+
| MISSING_OR_INVALID_REQUIRED_FIELD | 4011 | 400 | Missing or invalid value of the required fields for this courier. Besides tracking_number, also required: [field_name] |
|
116
|
+
| BAD_COURIER | 4012 | 400 | The error message will be one of the following:<br/>1. Unable to import shipment as the carrier is not on your approved list for carrier auto-detection. Add the carrier here: https://admin.aftership.com/settings/couriers<br/>2. Unable to import shipment as we don’t recognize the carrier from this tracking number.<br/>3. Unable to import shipment as the tracking number has an invalid format.<br/>4. Unable to import shipment as this carrier is no longer supported.<br/>5. Unable to import shipment as the tracking number does not belong to a carrier in that group. |
|
117
|
+
| INACTIVE_RETRACK_NOT_ALLOWED | 4013 | 400 | Retrack is not allowed. You can only retrack an inactive tracking. |
|
118
|
+
| NOTIFICATION_REUQIRED | 4014 | 400 | notification object is required. |
|
119
|
+
| ID_INVALID | 4015 | 400 | The value of id is invalid. |
|
120
|
+
| RETRACK_ONCE_ALLOWED | 4016 | 400 | Retrack is not allowed. You can only retrack each shipment once. |
|
121
|
+
| TRACKING_NUMBER_FORMAT_INVALID | 4017 | 400 | The format of tracking_number is invalid. |
|
122
|
+
| API_KEY_INVALID | 401 | 401 | The API key is invalid. |
|
123
|
+
| REQUEST_NOT_ALLOWED | 403 | 403 | The request is understood, but it has been refused or access is not allowed. |
|
124
|
+
| NOT_FOUND | 404 | 404 | The URI requested is invalid or the resource requested does not exist. |
|
125
|
+
| TOO_MANY_REQUEST | 429 | 429 | You have exceeded the API call rate limit. The default limit is 10 requests per second. |
|
126
|
+
| INTERNAL_ERROR | 500 502 503 504 | 500 502 503 504 | Something went wrong on AfterShip's end. |
|
127
|
+
|
128
|
+
## Endpoints
|
129
|
+
|
130
|
+
The AfterShip instance has the following properties which are exactly the same as the API endpoints:
|
131
|
+
|
132
|
+
- courier - Get a list of our supported couriers.
|
133
|
+
- tracking - Create trackings, update trackings, and get tracking results.
|
134
|
+
- last_checkpoint - Get tracking information of the last checkpoint of a tracking.
|
135
|
+
- notification - Get, add or remove contacts (sms or email) to be notified when the status of a tracking has changed.
|
136
|
+
- estimated-delivery-date - Get estimated delivery date for your order.
|
137
|
+
|
138
|
+
|
139
|
+
### /trackings
|
140
|
+
|
141
|
+
**POST** /trackings
|
142
|
+
|
143
|
+
```ruby
|
144
|
+
begin
|
145
|
+
req = AftershipAPI::Model::TrackingCreateTrackingRequest. new
|
146
|
+
req.tracking_number = "9588871095280078382516"
|
147
|
+
req.slug = "usps"
|
148
|
+
|
149
|
+
resp = AftershipAPI::Tracking.create_tracking(body: req)
|
150
|
+
p resp
|
151
|
+
rescue AftershipAPI::Error => e
|
152
|
+
p e.message
|
153
|
+
end
|
154
|
+
```
|
155
|
+
|
156
|
+
**DELETE** /trackings/:id
|
157
|
+
|
158
|
+
```ruby
|
159
|
+
resp = AftershipAPI::Tracking.delete_tracking_by_id(id: "jyhuvuj9j7ccslxyfnf2v01q")
|
160
|
+
p resp.to_json
|
161
|
+
```
|
162
|
+
|
163
|
+
**GET** /trackings
|
164
|
+
|
165
|
+
```ruby
|
166
|
+
resp = AftershipAPI::Tracking.get_trackings(opts: {keyword: "123"})
|
167
|
+
p resp.to_json
|
168
|
+
```
|
169
|
+
|
170
|
+
**GET** /trackings/:id
|
171
|
+
|
172
|
+
```ruby
|
173
|
+
resp = AftershipAPI::Tracking.get_tracking_by_id(id: "jyhuvuj9j7ccslxyfnf2v01q")
|
174
|
+
p resp.to_json
|
175
|
+
```
|
176
|
+
|
177
|
+
**PUT** /trackings/:id
|
178
|
+
|
179
|
+
```ruby
|
180
|
+
req = AftershipAPI::Model::TrackingUpdateTrackingByIdRequest.new
|
181
|
+
req.note = "test update"
|
182
|
+
resp = AftershipAPI::Tracking.update_tracking_by_id(id: "hphtmivs7jq99lxo378h400e", body: req)
|
183
|
+
p resp.to_json
|
184
|
+
```
|
185
|
+
|
186
|
+
**POST** /trackings/:id/retrack
|
187
|
+
|
188
|
+
```ruby
|
189
|
+
resp = AftershipAPI::Tracking.retrack_tracking_by_id(id: "hphtmivs7jq99lxo378h400e")
|
190
|
+
p resp.to_json
|
191
|
+
```
|
192
|
+
|
193
|
+
**POST** /trackings/:id/mark-as-completed
|
194
|
+
|
195
|
+
```ruby
|
196
|
+
req = AftershipAPI::Model::MarkTrackingCompletedByIdRequest.new
|
197
|
+
req.reason = "DELIVERED"
|
198
|
+
resp = AftershipAPI::Tracking.mark_tracking_completed_by_id(id: "hphtmivs7jq99lxo378h400e", body: req)
|
199
|
+
p resp.to_json
|
200
|
+
```
|
201
|
+
|
202
|
+
### /couriers
|
203
|
+
**GET** /couriers
|
204
|
+
|
205
|
+
```ruby
|
206
|
+
resp = AftershipAPI::Courier.get_user_couriers()
|
207
|
+
p resp.to_json
|
208
|
+
```
|
209
|
+
|
210
|
+
**GET** /couriers/all
|
211
|
+
|
212
|
+
```ruby
|
213
|
+
resp = AftershipAPI::Courier.get_all_couriers()
|
214
|
+
p resp.to_json
|
215
|
+
```
|
216
|
+
|
217
|
+
**POST** /couriers/detect
|
218
|
+
|
219
|
+
```ruby
|
220
|
+
req = AftershipAPI::Model::TrackingDetectCourierRequest.new
|
221
|
+
req.tracking_number = "1Z498YV28643018510"
|
222
|
+
resp = AftershipAPI::Courier.detect_courier(body: req)
|
223
|
+
p resp.to_json
|
224
|
+
```
|
225
|
+
|
226
|
+
### /last_checkpoint
|
227
|
+
|
228
|
+
**GET** /last_checkpoint/:id
|
229
|
+
|
230
|
+
```ruby
|
231
|
+
resp = AftershipAPI::LastCheckpoint.get_checkpoint_by_tracking_id(tracking_id: "hphtmivs7jq99lxo378h400e")
|
232
|
+
p resp.to_json
|
233
|
+
```
|
234
|
+
|
235
|
+
### /notifications
|
236
|
+
|
237
|
+
**GET** /notifications/:id
|
238
|
+
|
239
|
+
```ruby
|
240
|
+
resp = AftershipAPI::Notification.get_notification_by_tracking_id(tracking_id: "hphtmivs7jq99lxo378h400e")
|
241
|
+
p resp.to_json
|
242
|
+
```
|
243
|
+
|
244
|
+
**POST** /notifications/:id/add
|
245
|
+
|
246
|
+
```ruby
|
247
|
+
req = AftershipAPI::Model::NotificationRequestV1.new
|
248
|
+
req.emails = ["your_mail@gmail.com"]
|
249
|
+
resp = AftershipAPI::Notification.add_notification_by_tracking_id(tracking_id: "hphtmivs7jq99lxo378h400e",body: req)
|
250
|
+
p resp.to_json
|
251
|
+
```
|
252
|
+
|
253
|
+
**POST** /notifications/:id/remove
|
254
|
+
|
255
|
+
```ruby
|
256
|
+
req = AftershipAPI::Model::NotificationRequestV1.new
|
257
|
+
req.emails = ["your_mail@gmail.com"]
|
258
|
+
resp = AftershipAPI::Notification.delete_notification_by_tracking_id(tracking_id: "hphtmivs7jq99lxo378h400e",body: req)
|
259
|
+
p resp.to_json
|
260
|
+
```
|
261
|
+
|
262
|
+
### /estimated-delivery-date
|
263
|
+
|
264
|
+
**POST** /estimated-delivery-date/predict-batch
|
265
|
+
|
266
|
+
```ruby
|
267
|
+
edd = AftershipAPI::Model::EstimatedDeliveryDateRequest.new
|
268
|
+
edd.slug = "ups"
|
269
|
+
req = AftershipAPI::Model::PredictBatchRequest.new
|
270
|
+
req.estimated_delivery_dates = [edd]
|
271
|
+
resp = AftershipAPI::EstimatedDeliveryDate.predict_batch(body: req)
|
272
|
+
p resp.to_json
|
273
|
+
```
|
274
|
+
|
275
|
+
## Help
|
276
|
+
|
277
|
+
If you get stuck, we're here to help:
|
278
|
+
|
279
|
+
- [Issue Tracker](https://github.com/AfterShip/tracking-sdk-ruby/issues) for questions, feature requests, bug reports and general discussion related to this package. Try searching before you create a new issue.
|
280
|
+
- Contact AfterShip official support via support@aftership.com
|
281
|
+
|
282
|
+
## License
|
283
|
+
Copyright (c) 2024 AfterShip
|
284
|
+
|
285
|
+
Licensed under the MIT license.
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
$:.push File.expand_path("../lib", __FILE__)
|
4
|
+
require "aftership-tracking-sdk/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "aftership-tracking-sdk"
|
8
|
+
s.version = AftershipAPI::VERSION
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.authors = ["AfterShip Team"]
|
11
|
+
s.email = ["support@aftership.com"]
|
12
|
+
s.homepage = "https://www.aftership.com/docs/tracking/quickstart/api-quick-start"
|
13
|
+
s.summary = "API Overview Ruby Gem"
|
14
|
+
s.description = ""
|
15
|
+
s.license = "MIT"
|
16
|
+
s.required_ruby_version = ">= 2.7"
|
17
|
+
s.metadata = {}
|
18
|
+
|
19
|
+
s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
|
20
|
+
|
21
|
+
s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'
|
22
|
+
|
23
|
+
s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? }
|
24
|
+
s.test_files = `find spec/*`.split("\n")
|
25
|
+
s.executables = []
|
26
|
+
s.require_paths = ["lib"]
|
27
|
+
end
|
@@ -0,0 +1,163 @@
|
|
1
|
+
# This code was auto generated by AfterShip SDK Generator.
|
2
|
+
# Do not edit the class manually.
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
module AftershipAPI
|
6
|
+
class CourierApi
|
7
|
+
attr_accessor :api_client
|
8
|
+
|
9
|
+
def initialize(api_client = ApiClient.default)
|
10
|
+
@api_client = api_client
|
11
|
+
end
|
12
|
+
|
13
|
+
# detect_courier
|
14
|
+
# Return a list of matched couriers based on tracking number format and or a list of couriers.
|
15
|
+
|
16
|
+
# @param body [Model::TrackingDetectCourierRequest]
|
17
|
+
# @param [Hash] opts the optional parameters
|
18
|
+
# @return [Model::DetectCourierResponse]
|
19
|
+
def detect_courier(body:, opts: {})
|
20
|
+
if "tracking" != ""
|
21
|
+
body = { :'tracking' => body }
|
22
|
+
end
|
23
|
+
opts[:body] = body
|
24
|
+
data, _status_code, _headers = detect_courier_with_http_info(opts: opts)
|
25
|
+
data
|
26
|
+
end
|
27
|
+
|
28
|
+
def detect_courier_with_http_info(opts: {})
|
29
|
+
if @api_client.config.debugging
|
30
|
+
@api_client.config.logger.debug 'Calling API: CourierApi.detect_courier ...'
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
# resource path
|
36
|
+
local_var_path = "/tracking/2024-04/couriers/detect"
|
37
|
+
method = :'POST'
|
38
|
+
|
39
|
+
# query parameters
|
40
|
+
query_params = opts[:query_params] || {}
|
41
|
+
# header parameters
|
42
|
+
header_params = opts[:header_params] || {}
|
43
|
+
|
44
|
+
# http body (model)
|
45
|
+
post_body = opts[:body]
|
46
|
+
|
47
|
+
# return_type
|
48
|
+
return_type = 'DetectCourierResponse'
|
49
|
+
|
50
|
+
new_options = opts.merge(
|
51
|
+
:operation => :"CourierApi.detect_courier",
|
52
|
+
:header_params => header_params,
|
53
|
+
:query_params => query_params,
|
54
|
+
:body => post_body,
|
55
|
+
:return_type => return_type,
|
56
|
+
:response_legacy_tag => "",
|
57
|
+
:is_paging => false
|
58
|
+
)
|
59
|
+
|
60
|
+
data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
|
61
|
+
if @api_client.config.debugging
|
62
|
+
@api_client.config.logger.debug "API called: CourierApi#detect_courier\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
63
|
+
end
|
64
|
+
return data, status_code, headers
|
65
|
+
end
|
66
|
+
|
67
|
+
# get_all_couriers
|
68
|
+
# Return a list of all couriers.
|
69
|
+
# @param [Hash] opts the optional parameters
|
70
|
+
# @return [Model::GetAllCouriersResponse]
|
71
|
+
def get_all_couriers(opts: {})
|
72
|
+
data, _status_code, _headers = get_all_couriers_with_http_info(opts: opts)
|
73
|
+
data
|
74
|
+
end
|
75
|
+
|
76
|
+
def get_all_couriers_with_http_info(opts: {})
|
77
|
+
if @api_client.config.debugging
|
78
|
+
@api_client.config.logger.debug 'Calling API: CourierApi.get_all_couriers ...'
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
# resource path
|
84
|
+
local_var_path = "/tracking/2024-04/couriers/all"
|
85
|
+
method = :'GET'
|
86
|
+
|
87
|
+
# query parameters
|
88
|
+
query_params = opts[:query_params] || {}
|
89
|
+
# header parameters
|
90
|
+
header_params = opts[:header_params] || {}
|
91
|
+
|
92
|
+
# http body (model)
|
93
|
+
post_body = opts[:body]
|
94
|
+
|
95
|
+
# return_type
|
96
|
+
return_type = 'GetAllCouriersResponse'
|
97
|
+
|
98
|
+
new_options = opts.merge(
|
99
|
+
:operation => :"CourierApi.get_all_couriers",
|
100
|
+
:header_params => header_params,
|
101
|
+
:query_params => query_params,
|
102
|
+
:body => post_body,
|
103
|
+
:return_type => return_type,
|
104
|
+
:response_legacy_tag => "",
|
105
|
+
:is_paging => false
|
106
|
+
)
|
107
|
+
|
108
|
+
data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
|
109
|
+
if @api_client.config.debugging
|
110
|
+
@api_client.config.logger.debug "API called: CourierApi#get_all_couriers\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
111
|
+
end
|
112
|
+
return data, status_code, headers
|
113
|
+
end
|
114
|
+
|
115
|
+
# get_user_couriers
|
116
|
+
# Return a list of .
|
117
|
+
# @param [Hash] opts the optional parameters
|
118
|
+
# @return [Model::GetUserCouriersResponse]
|
119
|
+
def get_user_couriers(opts: {})
|
120
|
+
data, _status_code, _headers = get_user_couriers_with_http_info(opts: opts)
|
121
|
+
data
|
122
|
+
end
|
123
|
+
|
124
|
+
def get_user_couriers_with_http_info(opts: {})
|
125
|
+
if @api_client.config.debugging
|
126
|
+
@api_client.config.logger.debug 'Calling API: CourierApi.get_user_couriers ...'
|
127
|
+
end
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
# resource path
|
132
|
+
local_var_path = "/tracking/2024-04/couriers"
|
133
|
+
method = :'GET'
|
134
|
+
|
135
|
+
# query parameters
|
136
|
+
query_params = opts[:query_params] || {}
|
137
|
+
# header parameters
|
138
|
+
header_params = opts[:header_params] || {}
|
139
|
+
|
140
|
+
# http body (model)
|
141
|
+
post_body = opts[:body]
|
142
|
+
|
143
|
+
# return_type
|
144
|
+
return_type = 'GetUserCouriersResponse'
|
145
|
+
|
146
|
+
new_options = opts.merge(
|
147
|
+
:operation => :"CourierApi.get_user_couriers",
|
148
|
+
:header_params => header_params,
|
149
|
+
:query_params => query_params,
|
150
|
+
:body => post_body,
|
151
|
+
:return_type => return_type,
|
152
|
+
:response_legacy_tag => "",
|
153
|
+
:is_paging => false
|
154
|
+
)
|
155
|
+
|
156
|
+
data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
|
157
|
+
if @api_client.config.debugging
|
158
|
+
@api_client.config.logger.debug "API called: CourierApi#get_user_couriers\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
159
|
+
end
|
160
|
+
return data, status_code, headers
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# This code was auto generated by AfterShip SDK Generator.
|
2
|
+
# Do not edit the class manually.
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
module AftershipAPI
|
6
|
+
class EstimatedDeliveryDateApi
|
7
|
+
attr_accessor :api_client
|
8
|
+
|
9
|
+
def initialize(api_client = ApiClient.default)
|
10
|
+
@api_client = api_client
|
11
|
+
end
|
12
|
+
|
13
|
+
# predict_batch
|
14
|
+
# > The estimated delivery date is provided by AfterShip, based on its AI-predictive model. You can display the EDD on the product page, cart, and order checkout page. It indicates when a customer will receive the order.You can use to activate this feature.Supported functionalities require:1. One `EstimatedDeliveryDate` object for one prediction result.2. Maximum 5 `EstimatedDeliveryDate` objects are allowed.3. API call will fail if any of the requests `EstimatedDeliveryDate` objects do not meet the specification requirement.
|
15
|
+
|
16
|
+
# @param body [Model::PredictBatchRequest]
|
17
|
+
# @param [Hash] opts the optional parameters
|
18
|
+
# @return [Model::PredictBatchResponse]
|
19
|
+
def predict_batch(body:, opts: {})
|
20
|
+
if "" != ""
|
21
|
+
body = { :'' => body }
|
22
|
+
end
|
23
|
+
opts[:body] = body
|
24
|
+
data, _status_code, _headers = predict_batch_with_http_info(opts: opts)
|
25
|
+
data
|
26
|
+
end
|
27
|
+
|
28
|
+
def predict_batch_with_http_info(opts: {})
|
29
|
+
if @api_client.config.debugging
|
30
|
+
@api_client.config.logger.debug 'Calling API: EstimatedDeliveryDateApi.predict_batch ...'
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
# resource path
|
36
|
+
local_var_path = "/tracking/2024-04/estimated-delivery-date/predict-batch"
|
37
|
+
method = :'POST'
|
38
|
+
|
39
|
+
# query parameters
|
40
|
+
query_params = opts[:query_params] || {}
|
41
|
+
# header parameters
|
42
|
+
header_params = opts[:header_params] || {}
|
43
|
+
|
44
|
+
# http body (model)
|
45
|
+
post_body = opts[:body]
|
46
|
+
|
47
|
+
# return_type
|
48
|
+
return_type = 'PredictBatchResponse'
|
49
|
+
|
50
|
+
new_options = opts.merge(
|
51
|
+
:operation => :"EstimatedDeliveryDateApi.predict_batch",
|
52
|
+
:header_params => header_params,
|
53
|
+
:query_params => query_params,
|
54
|
+
:body => post_body,
|
55
|
+
:return_type => return_type,
|
56
|
+
:response_legacy_tag => "",
|
57
|
+
:is_paging => false
|
58
|
+
)
|
59
|
+
|
60
|
+
data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
|
61
|
+
if @api_client.config.debugging
|
62
|
+
@api_client.config.logger.debug "API called: EstimatedDeliveryDateApi#predict_batch\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
63
|
+
end
|
64
|
+
return data, status_code, headers
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|