Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ Before you begin to integrate:

### API and SDK Version

- SDK Version: 14.0.0
- API Version: 2026-01
- SDK Version: 15.0.0
- API Version: 2026-07
## Quick Start

### Installation
Expand All @@ -50,7 +50,7 @@ gem install aftership-tracking-sdk
Or add a line to your Gemfile

```bash
gem 'aftership-tracking-sdk', '~> 14.0.0'
gem 'aftership-tracking-sdk', '~> 15.0.0'
```

## Constructor
Expand Down Expand Up @@ -89,6 +89,27 @@ end

See the [Rate Limit](https://www.aftership.com/docs/tracking/quickstart/rate-limit) to understand the AfterShip rate limit policy.

The API returns its current rate limit status in the headers of every response, and the SDK exposes these headers on both successful responses and rate-limited errors, so you can monitor your consumption proactively instead of waiting for `429` errors.

| Header | Description |
| ----------------------- | ---------------------------------------------------------- |
| `X-RateLimit-Limit` | The rate limit ceiling for the current endpoint per second |
| `X-RateLimit-Remaining` | The number of requests left for the 1-second window |
| `X-RateLimit-Reset` | The Unix timestamp when the rate limit will be reset |

Every successful response exposes a `response_header` hash (case-insensitive lookup) alongside `data`. Taking the Quick Start example above:

```ruby
remaining = response.response_header['x-ratelimit-remaining'].to_i
reset_at = response.response_header['x-ratelimit-reset'].to_i

if remaining <= 1
# Throttle or defer lower-priority requests until reset_at
end
```

When the rate limit is exceeded, the request fails with a `429` error that carries the same headers — see [Error Handling](#error-handling).

## Error Handling

The SDK will return an error object when there is any error during the request, with the following specification:
Expand Down
4 changes: 2 additions & 2 deletions lib/aftership-tracking-sdk/api/courier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def get_couriers(opts: {})


# resource path
local_var_path = "/tracking/2026-01/couriers"
local_var_path = "/tracking/2026-07/couriers"
method = :'GET'

# query parameters
Expand Down Expand Up @@ -72,7 +72,7 @@ def detect_courier(body:, opts: {})


# resource path
local_var_path = "/tracking/2026-01/couriers/detect"
local_var_path = "/tracking/2026-07/couriers/detect"
method = :'POST'

# query parameters
Expand Down
10 changes: 5 additions & 5 deletions lib/aftership-tracking-sdk/api/courier_connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def get_courier_connections(opts: {})


# resource path
local_var_path = "/tracking/2026-01/courier-connections"
local_var_path = "/tracking/2026-07/courier-connections"
method = :'GET'

# query parameters
Expand Down Expand Up @@ -74,7 +74,7 @@ def post_courier_connections(body:, opts: {})


# resource path
local_var_path = "/tracking/2026-01/courier-connections"
local_var_path = "/tracking/2026-07/courier-connections"
method = :'POST'

# query parameters
Expand Down Expand Up @@ -122,7 +122,7 @@ def get_courier_connections_by_id(id:, opts: {})


# resource path
local_var_path = "/tracking/2026-01/courier-connections/#{id}"
local_var_path = "/tracking/2026-07/courier-connections/#{id}"
method = :'GET'

# query parameters
Expand Down Expand Up @@ -173,7 +173,7 @@ def put_courier_connections_by_id(id:, body:, opts: {})


# resource path
local_var_path = "/tracking/2026-01/courier-connections/#{id}"
local_var_path = "/tracking/2026-07/courier-connections/#{id}"
method = :'PATCH'

# query parameters
Expand Down Expand Up @@ -221,7 +221,7 @@ def delete_courier_connections_by_id(id:, opts: {})


# resource path
local_var_path = "/tracking/2026-01/courier-connections/#{id}"
local_var_path = "/tracking/2026-07/courier-connections/#{id}"
method = :'DELETE'

# query parameters
Expand Down
4 changes: 2 additions & 2 deletions lib/aftership-tracking-sdk/api/estimated_delivery_date.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def predict(body:, opts: {})


# resource path
local_var_path = "/tracking/2026-01/estimated-delivery-date/predict"
local_var_path = "/tracking/2026-07/estimated-delivery-date/predict"
method = :'POST'

# query parameters
Expand Down Expand Up @@ -71,7 +71,7 @@ def predict_batch(body:, opts: {})


# resource path
local_var_path = "/tracking/2026-01/estimated-delivery-date/predict-batch"
local_var_path = "/tracking/2026-07/estimated-delivery-date/predict-batch"
method = :'POST'

# query parameters
Expand Down
14 changes: 7 additions & 7 deletions lib/aftership-tracking-sdk/api/tracking.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_trackings(opts: {})


# resource path
local_var_path = "/tracking/2026-01/trackings"
local_var_path = "/tracking/2026-07/trackings"
method = :'GET'

# query parameters
Expand Down Expand Up @@ -104,7 +104,7 @@ def create_tracking(body:, opts: {})


# resource path
local_var_path = "/tracking/2026-01/trackings"
local_var_path = "/tracking/2026-07/trackings"
method = :'POST'

# query parameters
Expand Down Expand Up @@ -154,7 +154,7 @@ def get_tracking_by_id(id:, opts: {})


# resource path
local_var_path = "/tracking/2026-01/trackings/#{id}"
local_var_path = "/tracking/2026-07/trackings/#{id}"
method = :'GET'

# query parameters
Expand Down Expand Up @@ -207,7 +207,7 @@ def update_tracking_by_id(id:, body:, opts: {})


# resource path
local_var_path = "/tracking/2026-01/trackings/#{id}"
local_var_path = "/tracking/2026-07/trackings/#{id}"
method = :'PUT'

# query parameters
Expand Down Expand Up @@ -255,7 +255,7 @@ def delete_tracking_by_id(id:, opts: {})


# resource path
local_var_path = "/tracking/2026-01/trackings/#{id}"
local_var_path = "/tracking/2026-07/trackings/#{id}"
method = :'DELETE'

# query parameters
Expand Down Expand Up @@ -303,7 +303,7 @@ def retrack_tracking_by_id(id:, opts: {})


# resource path
local_var_path = "/tracking/2026-01/trackings/#{id}/retrack"
local_var_path = "/tracking/2026-07/trackings/#{id}/retrack"
method = :'POST'

# query parameters
Expand Down Expand Up @@ -354,7 +354,7 @@ def mark_tracking_completed_by_id(id:, body:, opts: {})


# resource path
local_var_path = "/tracking/2026-01/trackings/#{id}/mark-as-completed"
local_var_path = "/tracking/2026-07/trackings/#{id}/mark-as-completed"
method = :'POST'

# query parameters
Expand Down
10 changes: 10 additions & 0 deletions lib/aftership-tracking-sdk/models/checkpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ class Checkpoint
# source?: CheckpointSource;
attr_accessor :source

# Unique hash identifier for each checkpoint event, could be used for deduplication.
# hash?: String;
attr_accessor :hash

# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
Expand Down Expand Up @@ -148,6 +152,10 @@ def initialize(attributes = {})
if attributes.key?(:'source')
self.source = attributes[:'source']
end

if attributes.key?(:'hash')
self.hash = attributes[:'hash']
end
end

# Attribute type mapping.
Expand All @@ -170,6 +178,7 @@ def self.openapi_types
:'raw_tag' => :'String',
:'events' => :'Array<CheckpointEvents>',
:'source' => :'CheckpointSource',
:'hash' => :'String',
}
end

Expand All @@ -193,6 +202,7 @@ def self.attribute_map
:'raw_tag' => :'raw_tag',
:'events' => :'events',
:'source' => :'source',
:'hash' => :'hash',
}
end

Expand Down
10 changes: 10 additions & 0 deletions lib/aftership-tracking-sdk/models/create_tracking_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ class CreateTrackingRequest
# customers?: CreateTrackingRequestCustomers[];
attr_accessor :customers

# Indicates the business direction of the shipment in the e-commerce fulfillment lifecycle.Possible values:- `forward`: A forward (outbound-to-customer) shipment created for order fulfillment.- `return`: A return (customer-to-merchant) shipment created for after-sales return or exchange.When provided, this field gives AfterShip additional context about the shipment's intent, enabling more accurate status identification.
# shipment_direction?: CreateTrackingRequestShipmentDirection;
attr_accessor :shipment_direction

# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
Expand Down Expand Up @@ -300,6 +304,10 @@ def initialize(attributes = {})
if attributes.key?(:'customers')
self.customers = attributes[:'customers']
end

if attributes.key?(:'shipment_direction')
self.shipment_direction = attributes[:'shipment_direction']
end
end

# Attribute type mapping.
Expand Down Expand Up @@ -341,6 +349,7 @@ def self.openapi_types
:'shipping_method' => :'String',
:'last_mile' => :'CreateTrackingRequestLastMile',
:'customers' => :'Array<CreateTrackingRequestCustomers>',
:'shipment_direction' => :'CreateTrackingRequestShipmentDirection',
}
end

Expand Down Expand Up @@ -383,6 +392,7 @@ def self.attribute_map
:'shipping_method' => :'shipping_method',
:'last_mile' => :'last_mile',
:'customers' => :'customers',
:'shipment_direction' => :'shipment_direction',
}
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class CreateTrackingRequestCustomers
# language?: String;
attr_accessor :language

# The customer's identifier on the merchant or platform (for example, Shopify) side.
# id?: String;
attr_accessor :id

# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
Expand Down Expand Up @@ -52,6 +56,10 @@ def initialize(attributes = {})
if attributes.key?(:'language')
self.language = attributes[:'language']
end

if attributes.key?(:'id')
self.id = attributes[:'id']
end
end

# Attribute type mapping.
Expand All @@ -62,6 +70,7 @@ def self.openapi_types
:'phone_number' => :'String',
:'email' => :'String',
:'language' => :'String',
:'id' => :'String',
}
end

Expand All @@ -73,6 +82,7 @@ def self.attribute_map
:'phone_number' => :'phone_number',
:'email' => :'email',
:'language' => :'language',
:'id' => :'id',
}
end

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This code was auto generated by AfterShip SDK Generator.
# Do not edit the class manually.
module AftershipAPI::Model
class CreateTrackingRequestShipmentDirection
FORWARD = "forward".freeze
RETURN = "return".freeze
def self.all_vars
@all_vars ||= [FORWARD, RETURN,].freeze
end

# Builds the enum from string
# @param value [String] The enum value in the form of the string
# @return [String] The enum value
def self.build_from_hash(value)
new.build_from_hash(value)
end

# Builds the enum from string
# @param value [String] The enum value in the form of the string
# @return [String] The enum value
def build_from_hash(value)
return value if CreateTrackingRequestShipmentDirection.all_vars.include?(value)
raise "Invalid ENUM value #{value} for class #CreateTrackingRequestShipmentDirection"
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ class EstimatedDeliveryDateRequestDestinationAddress
# country_region: String;
attr_accessor :country_region

# State, province, or the equivalent location of the destination address where the package will be delivered.Either `destination_address.state` or `destination_address.postal_code` is required.
# State, province, or the equivalent location of the destination address where the package will be delivered.</br><span style=color:#ff6b2b;padding:2px>**Either `destination_address.state` or `destination_address.postal_code` is required.**</span>
# state?: String;
attr_accessor :state

# City of the destination address where the package will be delivered.
# city?: String;
attr_accessor :city

# Postal code of the destination address.Either `destination_address.state` or `destination_address.postal_code` is required.
# Postal code of the destination address.</br><span style=color:#ff6b2b;padding:2px>**Either `destination_address.state` or `destination_address.postal_code` is required.**</span>
# postal_code?: String;
attr_accessor :postal_code

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ class EstimatedDeliveryDateRequestOriginAddress
# country_region: String;
attr_accessor :country_region

# State, province, or the equivalent location of the origin address. Use 3 letters of ISO 3166-1 country/region code for countries/regions without state. Either `origin_address.state` or `origin_address.postal_code` is required.
# State, province, or the equivalent location of the origin address. Use 3 letters of ISO 3166-1 country/region code for countries/regions without state. </br><span style=color:#ff6b2b;padding:2px>**Either `origin_address.state` or `origin_address.postal_code` is required.**</span>
# state?: String;
attr_accessor :state

# City of the origin address. Use 3 letters of ISO 3166-1 country/region code for countries/regions without City.
# city?: String;
attr_accessor :city

# Postal code of the origin address. Use 3 letters of ISO 3166-1 country/region code for countries/regions without postal code. Either `origin_address.state` or `origin_address.postal_code` is required.
# Postal code of the origin address. Use 3 letters of ISO 3166-1 country/region code for countries/regions without postal code. </br><span style=color:#ff6b2b;padding:2px>**Either `origin_address.state` or `origin_address.postal_code` is required.**</span>
# postal_code?: String;
attr_accessor :postal_code

Expand Down
Loading