diff --git a/.github/workflows/gem-push.yml b/.github/workflows/gem-push.yml
new file mode 100644
index 0000000..15e9463
--- /dev/null
+++ b/.github/workflows/gem-push.yml
@@ -0,0 +1,47 @@
+name: Ruby Gem
+
+on:
+ push:
+ tags:
+ - '*'
+
+jobs:
+ build:
+ name: Build + Publish
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ packages: write
+
+ steps:
+ - uses: actions/checkout@v4
+ - name: Set up Ruby 2.7
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
+ # uses: ruby/setup-ruby@v1
+ uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
+ with:
+ ruby-version: 2.7.2
+
+ - name: Publish to GPR
+ run: |
+ mkdir -p $HOME/.gem
+ touch $HOME/.gem/credentials
+ chmod 0600 $HOME/.gem/credentials
+ printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
+ gem build *.gemspec
+ gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
+ env:
+ GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
+ OWNER: ${{ github.repository_owner }}
+
+ - name: Publish to RubyGems
+ run: |
+ mkdir -p $HOME/.gem
+ touch $HOME/.gem/credentials
+ chmod 0600 $HOME/.gem/credentials
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
+ gem build *.gemspec
+ gem push *.gem
+ env:
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..b62e343
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,63 @@
+*.gem
+*.rbc
+/.config
+/coverage/
+/InstalledFiles
+/pkg/
+/spec/reports/
+/spec/examples.txt
+/test/tmp/
+/test/version_tmp/
+/tmp/
+
+# sdk dont need spec files
+/spec
+
+# package dont need this
+Gemfile.lock
+
+# Used by dotenv library to load environment variables.
+# .env
+.env
+
+# Ignore Byebug command history file.
+.byebug_history
+
+## Specific to RubyMotion:
+.dat*
+.repl_history
+build/
+*.bridgesupport
+build-iPhoneOS/
+build-iPhoneSimulator/
+
+## Specific to RubyMotion (use of CocoaPods):
+#
+# We recommend against adding the Pods directory to your .gitignore. However
+# you should judge for yourself, the pros and cons are mentioned at:
+# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
+#
+# vendor/Pods/
+
+## Documentation cache and generated files:
+/.yardoc/
+/_yardoc/
+/doc/
+/rdoc/
+
+## Environment normalization:
+/.bundle/
+/vendor/bundle
+/lib/bundler/man/
+
+# for a library or gem, you might want to ignore these files since the code is
+# intended to run in multiple environments; otherwise, check them in:
+# Gemfile.lock
+# .ruby-version
+# .ruby-gemset
+
+# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
+.rvmrc
+
+# Used by RuboCop. Remote config files pulled in from inherit_from directive.
+# .rubocop-https?--*
diff --git a/.rubocop.yml b/.rubocop.yml
new file mode 100644
index 0000000..20ff236
--- /dev/null
+++ b/.rubocop.yml
@@ -0,0 +1,145 @@
+# This file is based on https://github.com/rails/rails/blob/master/.rubocop.yml (MIT license)
+# Automatically generated by OpenAPI Generator (https://openapi-generator.tech)
+AllCops:
+ TargetRubyVersion: 2.7
+ # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
+ # to ignore them, so only the ones explicitly set in this file are enabled.
+ DisabledByDefault: true
+ Exclude:
+
+# Prefer &&/|| over and/or.
+Style/AndOr:
+ Enabled: true
+
+# Align `when` with `case`.
+Layout/CaseIndentation:
+ Enabled: true
+
+# Align comments with method definitions.
+Layout/CommentIndentation:
+ Enabled: true
+
+Layout/ElseAlignment:
+ Enabled: true
+
+Layout/EmptyLineAfterMagicComment:
+ Enabled: true
+
+# In a regular class definition, no empty lines around the body.
+Layout/EmptyLinesAroundClassBody:
+ Enabled: true
+
+# In a regular method definition, no empty lines around the body.
+Layout/EmptyLinesAroundMethodBody:
+ Enabled: true
+
+# In a regular module definition, no empty lines around the body.
+Layout/EmptyLinesAroundModuleBody:
+ Enabled: true
+
+Layout/FirstArgumentIndentation:
+ Enabled: true
+
+# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
+Style/HashSyntax:
+ Enabled: false
+
+# Method definitions after `private` or `protected` isolated calls need one
+# extra level of indentation.
+Layout/IndentationConsistency:
+ Enabled: true
+ EnforcedStyle: indented_internal_methods
+
+# Two spaces, no tabs (for indentation).
+Layout/IndentationWidth:
+ Enabled: true
+
+Layout/LeadingCommentSpace:
+ Enabled: true
+
+Layout/SpaceAfterColon:
+ Enabled: true
+
+Layout/SpaceAfterComma:
+ Enabled: true
+
+Layout/SpaceAroundEqualsInParameterDefault:
+ Enabled: true
+
+Layout/SpaceAroundKeyword:
+ Enabled: true
+
+Layout/SpaceAroundOperators:
+ Enabled: true
+
+Layout/SpaceBeforeComma:
+ Enabled: true
+
+Layout/SpaceBeforeFirstArg:
+ Enabled: true
+
+Style/DefWithParentheses:
+ Enabled: true
+
+# Defining a method with parameters needs parentheses.
+Style/MethodDefParentheses:
+ Enabled: true
+
+Style/FrozenStringLiteralComment:
+ Enabled: false
+ EnforcedStyle: always
+
+# Use `foo {}` not `foo{}`.
+Layout/SpaceBeforeBlockBraces:
+ Enabled: true
+
+# Use `foo { bar }` not `foo {bar}`.
+Layout/SpaceInsideBlockBraces:
+ Enabled: true
+
+# Use `{ a: 1 }` not `{a:1}`.
+Layout/SpaceInsideHashLiteralBraces:
+ Enabled: true
+
+Layout/SpaceInsideParens:
+ Enabled: true
+
+# Check quotes usage according to lint rule below.
+#Style/StringLiterals:
+# Enabled: true
+# EnforcedStyle: single_quotes
+
+# Detect hard tabs, no hard tabs.
+Layout/IndentationStyle:
+ Enabled: true
+
+# Blank lines should not have any spaces.
+Layout/TrailingEmptyLines:
+ Enabled: true
+
+# No trailing whitespace.
+Layout/TrailingWhitespace:
+ Enabled: false
+
+# Use quotes for string literals when they are enough.
+Style/RedundantPercentQ:
+ Enabled: true
+
+# Align `end` with the matching keyword or starting expression except for
+# assignments, where it should be aligned with the LHS.
+Layout/EndAlignment:
+ Enabled: true
+ EnforcedStyleAlignWith: variable
+ AutoCorrect: true
+
+# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
+Lint/RequireParentheses:
+ Enabled: true
+
+Style/RedundantReturn:
+ Enabled: true
+ AllowMultipleReturnValues: true
+
+Style/Semicolon:
+ Enabled: true
+ AllowAsExpressionSeparator: true
diff --git a/Gemfile b/Gemfile
new file mode 100644
index 0000000..cd8ebfd
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,11 @@
+source 'https://rubygems.org'
+
+gemspec
+
+group :development, :test do
+ gem 'rake', '~> 13.0.1'
+ gem 'pry-byebug'
+ gem 'rubocop', '~> 1.63'
+ gem 'dotenv'
+ gem "webmock", "~> 3.23"
+end
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..f7ecb5c
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2024 AfterShip
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
index 91b31d0..109c919 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,285 @@
-# tracking-sdk-ruby
\ No newline at end of file
+# AfterShip Tracking API library for Ruby
+
+This library allows you to quickly and easily use the AfterShip Tracking API via Go.
+
+For updates to this library, see our [GitHub release page](https://github.com/AfterShip/tracking-sdk-ruby/releases).
+
+If you need support using AfterShip products, please contact support@aftership.com.
+
+## Table of Contents
+
+- [AfterShip Tracking API library for Ruby](#aftership-tracking-api-library-for-ruby)
+ - [Table of Contents](#table-of-contents)
+ - [Before you begin](#before-you-begin)
+ - [Quick Start](#quick-start)
+ - [Installation](#installation)
+ - [Constructor](#constructor)
+ - [Example](#example)
+ - [Rate Limiter](#rate-limiter)
+ - [Error Handling](#error-handling)
+ - [Error List](#error-list)
+ - [Endpoints](#endpoints)
+ - [/trackings](#trackings)
+ - [/couriers](#couriers)
+ - [/last\_checkpoint](#last_checkpoint)
+ - [/notifications](#notifications)
+ - [/estimated-delivery-date](#estimated-delivery-date)
+ - [Help](#help)
+ - [License](#license)
+
+
+## Before you begin
+
+Before you begin to integrate:
+
+- [Create an AfterShip account](https://admin.aftership.com/).
+- [Create an API key](https://organization.automizely.com/api-keys).
+- [Install Ruby](https://www.ruby-lang.org/en/) version Ruby 2.7 or later.
+
+## Quick Start
+
+### Installation
+```bash
+gem install aftership-tracking-sdk
+```
+
+Or add a line to your Gemfile
+
+```bash
+gem 'aftership-tracking-sdk', '~> 7.0.0'
+```
+
+## Constructor
+
+Create AfterShip instance with options
+
+| Name | Type | Required | Description |
+|------------|--------|----------|-----------------------------------------------------------------------------------------------------------------------------------|
+| api_key | string | ✔ | Your AfterShip API key |
+| auth_type | enum | | Default value: `AuthType.API_KEY`
AES authentication: `AuthType.AES`
RSA authentication: `AuthType.RSA` |
+| api_secret | string | | Required if the authentication type is `AuthType.AES` or `AuthType.RSA` |
+| domain | string | | AfterShip API domain. Default value: https://api.aftership.com |
+| user_agent | string | | User-defined user-agent string, please follow [RFC9110](https://www.rfc-editor.org/rfc/rfc9110#field.user-agent) format standard. |
+| proxy | string | | HTTP proxy URL to use for requests.
Default value: `null`
Example: `http://192.168.0.100:8888` |
+| max_retry | number | | Number of retries for each request. Default value: 2. Min is 0, Max is 10. |
+| timeout | number | | Timeout for each request in milliseconds. |
+
+### Example
+
+```ruby
+require 'aftership-tracking-sdk'
+
+AftershipAPI.configure do |config|
+ config.as_api_key = "YOUR_API_KEY"
+end
+
+begin
+ resp = AftershipAPI::Tracking.get_trackings
+ p resp
+rescue AftershipAPI::Error => e
+ p e.message
+end
+```
+
+## Rate Limiter
+
+See the [Rate Limit](https://www.aftership.com/docs/aftership/quickstart/rate-limit) to understand the AfterShip rate limit policy.
+
+## Error Handling
+
+The SDK will return an error object when there is any error during the request, with the following specification:
+
+| Name | Type | Description |
+|---------------|--------|--------------------------------|
+| message | string | Detail message of the error |
+| code | enum | Error code enum for API Error. |
+| meta_code | number | API response meta code. |
+| status_code | number | HTTP status code. |
+| response_body | string | API response body. |
+
+
+### Error List
+
+| code | meta_code | status_code | message |
+|-----------------------------------|------------------|-----------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| INVALID_REQUEST | 400 | 400 | The request was invalid or cannot be otherwise served. |
+| INVALID_JSON | 4001 | 400 | Invalid JSON data. |
+| TRACKING_ALREADY_EXIST | 4003 | 400 | Tracking already exists. |
+| TRACKING_DOES_NOT_EXIST | 4004 | 404 | Tracking does not exist. |
+| TRACKING_NUMBER_INVALID | 4005 | 400 | The value of tracking_number is invalid. |
+| TRACKING_REQUIRED | 4006 | 400 | tracking object is required. |
+| TRACKING_NUMBER_REQUIRED | 4007 | 400 | tracking_number is required. |
+| VALUE_INVALID | 4008 | 400 | The value of [field_name] is invalid. |
+| VALUE_REQUIRED | 4009 | 400 | [field_name] is required. |
+| SLUG_INVALID | 4010 | 400 | The value of slug is invalid. |
+| 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] |
+| BAD_COURIER | 4012 | 400 | The error message will be one of the following:
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
2. Unable to import shipment as we don’t recognize the carrier from this tracking number.
3. Unable to import shipment as the tracking number has an invalid format.
4. Unable to import shipment as this carrier is no longer supported.
5. Unable to import shipment as the tracking number does not belong to a carrier in that group. |
+| INACTIVE_RETRACK_NOT_ALLOWED | 4013 | 400 | Retrack is not allowed. You can only retrack an inactive tracking. |
+| NOTIFICATION_REUQIRED | 4014 | 400 | notification object is required. |
+| ID_INVALID | 4015 | 400 | The value of id is invalid. |
+| RETRACK_ONCE_ALLOWED | 4016 | 400 | Retrack is not allowed. You can only retrack each shipment once. |
+| TRACKING_NUMBER_FORMAT_INVALID | 4017 | 400 | The format of tracking_number is invalid. |
+| API_KEY_INVALID | 401 | 401 | The API key is invalid. |
+| REQUEST_NOT_ALLOWED | 403 | 403 | The request is understood, but it has been refused or access is not allowed. |
+| NOT_FOUND | 404 | 404 | The URI requested is invalid or the resource requested does not exist. |
+| TOO_MANY_REQUEST | 429 | 429 | You have exceeded the API call rate limit. The default limit is 10 requests per second. |
+| INTERNAL_ERROR | 500 502 503 504 | 500 502 503 504 | Something went wrong on AfterShip's end. |
+
+## Endpoints
+
+The AfterShip instance has the following properties which are exactly the same as the API endpoints:
+
+- courier - Get a list of our supported couriers.
+- tracking - Create trackings, update trackings, and get tracking results.
+- last_checkpoint - Get tracking information of the last checkpoint of a tracking.
+- notification - Get, add or remove contacts (sms or email) to be notified when the status of a tracking has changed.
+- estimated-delivery-date - Get estimated delivery date for your order.
+
+
+### /trackings
+
+**POST** /trackings
+
+```ruby
+begin
+ req = AftershipAPI::Model::TrackingCreateTrackingRequest. new
+ req.tracking_number = "9588871095280078382516"
+ req.slug = "usps"
+
+ resp = AftershipAPI::Tracking.create_tracking(body: req)
+ p resp
+rescue AftershipAPI::Error => e
+ p e.message
+end
+```
+
+**DELETE** /trackings/:id
+
+```ruby
+resp = AftershipAPI::Tracking.delete_tracking_by_id(id: "jyhuvuj9j7ccslxyfnf2v01q")
+p resp.to_json
+```
+
+**GET** /trackings
+
+```ruby
+resp = AftershipAPI::Tracking.get_trackings(opts: {keyword: "123"})
+p resp.to_json
+```
+
+**GET** /trackings/:id
+
+```ruby
+resp = AftershipAPI::Tracking.get_tracking_by_id(id: "jyhuvuj9j7ccslxyfnf2v01q")
+p resp.to_json
+```
+
+**PUT** /trackings/:id
+
+```ruby
+req = AftershipAPI::Model::TrackingUpdateTrackingByIdRequest.new
+req.note = "test update"
+resp = AftershipAPI::Tracking.update_tracking_by_id(id: "hphtmivs7jq99lxo378h400e", body: req)
+p resp.to_json
+```
+
+**POST** /trackings/:id/retrack
+
+```ruby
+resp = AftershipAPI::Tracking.retrack_tracking_by_id(id: "hphtmivs7jq99lxo378h400e")
+p resp.to_json
+```
+
+**POST** /trackings/:id/mark-as-completed
+
+```ruby
+req = AftershipAPI::Model::MarkTrackingCompletedByIdRequest.new
+req.reason = "DELIVERED"
+resp = AftershipAPI::Tracking.mark_tracking_completed_by_id(id: "hphtmivs7jq99lxo378h400e", body: req)
+p resp.to_json
+```
+
+### /couriers
+**GET** /couriers
+
+```ruby
+resp = AftershipAPI::Courier.get_user_couriers()
+p resp.to_json
+```
+
+**GET** /couriers/all
+
+```ruby
+resp = AftershipAPI::Courier.get_all_couriers()
+p resp.to_json
+```
+
+**POST** /couriers/detect
+
+```ruby
+req = AftershipAPI::Model::TrackingDetectCourierRequest.new
+req.tracking_number = "1Z498YV28643018510"
+resp = AftershipAPI::Courier.detect_courier(body: req)
+p resp.to_json
+```
+
+### /last_checkpoint
+
+**GET** /last_checkpoint/:id
+
+```ruby
+resp = AftershipAPI::LastCheckpoint.get_checkpoint_by_tracking_id(tracking_id: "hphtmivs7jq99lxo378h400e")
+p resp.to_json
+```
+
+### /notifications
+
+**GET** /notifications/:id
+
+```ruby
+resp = AftershipAPI::Notification.get_notification_by_tracking_id(tracking_id: "hphtmivs7jq99lxo378h400e")
+p resp.to_json
+```
+
+**POST** /notifications/:id/add
+
+```ruby
+req = AftershipAPI::Model::NotificationRequestV1.new
+req.emails = ["your_mail@gmail.com"]
+resp = AftershipAPI::Notification.add_notification_by_tracking_id(tracking_id: "hphtmivs7jq99lxo378h400e",body: req)
+p resp.to_json
+```
+
+**POST** /notifications/:id/remove
+
+```ruby
+req = AftershipAPI::Model::NotificationRequestV1.new
+req.emails = ["your_mail@gmail.com"]
+resp = AftershipAPI::Notification.delete_notification_by_tracking_id(tracking_id: "hphtmivs7jq99lxo378h400e",body: req)
+p resp.to_json
+```
+
+### /estimated-delivery-date
+
+**POST** /estimated-delivery-date/predict-batch
+
+```ruby
+edd = AftershipAPI::Model::EstimatedDeliveryDateRequest.new
+edd.slug = "ups"
+req = AftershipAPI::Model::PredictBatchRequest.new
+req.estimated_delivery_dates = [edd]
+resp = AftershipAPI::EstimatedDeliveryDate.predict_batch(body: req)
+p resp.to_json
+```
+
+## Help
+
+If you get stuck, we're here to help:
+
+- [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.
+- Contact AfterShip official support via support@aftership.com
+
+## License
+Copyright (c) 2024 AfterShip
+
+Licensed under the MIT license.
\ No newline at end of file
diff --git a/aftership-tracking-sdk.gemspec b/aftership-tracking-sdk.gemspec
new file mode 100644
index 0000000..c42e5f3
--- /dev/null
+++ b/aftership-tracking-sdk.gemspec
@@ -0,0 +1,27 @@
+# -*- encoding: utf-8 -*-
+
+$:.push File.expand_path("../lib", __FILE__)
+require "aftership-tracking-sdk/version"
+
+Gem::Specification.new do |s|
+ s.name = "aftership-tracking-sdk"
+ s.version = AftershipAPI::VERSION
+ s.platform = Gem::Platform::RUBY
+ s.authors = ["AfterShip Team"]
+ s.email = ["support@aftership.com"]
+ s.homepage = "https://www.aftership.com/docs/tracking/quickstart/api-quick-start"
+ s.summary = "API Overview Ruby Gem"
+ s.description = ""
+ s.license = "MIT"
+ s.required_ruby_version = ">= 2.7"
+ s.metadata = {}
+
+ s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
+
+ s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'
+
+ s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? }
+ s.test_files = `find spec/*`.split("\n")
+ s.executables = []
+ s.require_paths = ["lib"]
+end
diff --git a/lib/aftership-tracking-sdk.rb b/lib/aftership-tracking-sdk.rb
new file mode 100644
index 0000000..c1c152a
--- /dev/null
+++ b/lib/aftership-tracking-sdk.rb
@@ -0,0 +1,47 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+# Common files
+require 'aftership-tracking-sdk/api_client'
+require 'aftership-tracking-sdk/error'
+require 'aftership-tracking-sdk/version'
+require 'aftership-tracking-sdk/configuration'
+require 'aftership-tracking-sdk/sign_string'
+
+# Models
+Dir[File.join(__dir__, 'aftership-tracking-sdk/models', '*.rb')].each { |file| require file }
+
+# APIs
+Dir[File.join(__dir__, 'aftership-tracking-sdk/api', '*.rb')].each { |file| require file }
+
+module AftershipAPI
+ @is_initialized = false
+
+ class << self
+ def configure
+ config = Configuration.default
+ yield(config) if block_given?
+
+ config.check
+
+ if !@is_initialized
+ @is_initialized = true
+ self.constants.each do |c|
+ next unless c[-3..-1] == 'Api'
+ attributes = [:attr1]
+ wrapper_class = self.const_set(c[0..-4], Struct.new(*attributes))
+ original_class = self.const_get(c)
+
+ original_class.public_instance_methods(false).each do |m|
+ wrapper_class.class_eval do
+ define_singleton_method m do |**arg|
+ original_class.new.send(m, **arg)
+ end
+ end
+ end
+ end
+ end
+
+ config
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/api/courier.rb b/lib/aftership-tracking-sdk/api/courier.rb
new file mode 100644
index 0000000..07add83
--- /dev/null
+++ b/lib/aftership-tracking-sdk/api/courier.rb
@@ -0,0 +1,163 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+require 'cgi'
+
+module AftershipAPI
+ class CourierApi
+ attr_accessor :api_client
+
+ def initialize(api_client = ApiClient.default)
+ @api_client = api_client
+ end
+
+ # detect_courier
+ # Return a list of matched couriers based on tracking number format and or a list of couriers.
+
+ # @param body [Model::TrackingDetectCourierRequest]
+ # @param [Hash] opts the optional parameters
+ # @return [Model::DetectCourierResponse]
+ def detect_courier(body:, opts: {})
+ if "tracking" != ""
+ body = { :'tracking' => body }
+ end
+ opts[:body] = body
+ data, _status_code, _headers = detect_courier_with_http_info(opts: opts)
+ data
+ end
+
+ def detect_courier_with_http_info(opts: {})
+ if @api_client.config.debugging
+ @api_client.config.logger.debug 'Calling API: CourierApi.detect_courier ...'
+ end
+
+
+
+ # resource path
+ local_var_path = "/tracking/2024-04/couriers/detect"
+ method = :'POST'
+
+ # query parameters
+ query_params = opts[:query_params] || {}
+ # header parameters
+ header_params = opts[:header_params] || {}
+
+ # http body (model)
+ post_body = opts[:body]
+
+ # return_type
+ return_type = 'DetectCourierResponse'
+
+ new_options = opts.merge(
+ :operation => :"CourierApi.detect_courier",
+ :header_params => header_params,
+ :query_params => query_params,
+ :body => post_body,
+ :return_type => return_type,
+ :response_legacy_tag => "",
+ :is_paging => false
+ )
+
+ data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
+ if @api_client.config.debugging
+ @api_client.config.logger.debug "API called: CourierApi#detect_courier\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
+ end
+ return data, status_code, headers
+ end
+
+ # get_all_couriers
+ # Return a list of all couriers.
+ # @param [Hash] opts the optional parameters
+ # @return [Model::GetAllCouriersResponse]
+ def get_all_couriers(opts: {})
+ data, _status_code, _headers = get_all_couriers_with_http_info(opts: opts)
+ data
+ end
+
+ def get_all_couriers_with_http_info(opts: {})
+ if @api_client.config.debugging
+ @api_client.config.logger.debug 'Calling API: CourierApi.get_all_couriers ...'
+ end
+
+
+
+ # resource path
+ local_var_path = "/tracking/2024-04/couriers/all"
+ method = :'GET'
+
+ # query parameters
+ query_params = opts[:query_params] || {}
+ # header parameters
+ header_params = opts[:header_params] || {}
+
+ # http body (model)
+ post_body = opts[:body]
+
+ # return_type
+ return_type = 'GetAllCouriersResponse'
+
+ new_options = opts.merge(
+ :operation => :"CourierApi.get_all_couriers",
+ :header_params => header_params,
+ :query_params => query_params,
+ :body => post_body,
+ :return_type => return_type,
+ :response_legacy_tag => "",
+ :is_paging => false
+ )
+
+ data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
+ if @api_client.config.debugging
+ @api_client.config.logger.debug "API called: CourierApi#get_all_couriers\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
+ end
+ return data, status_code, headers
+ end
+
+ # get_user_couriers
+ # Return a list of .
+ # @param [Hash] opts the optional parameters
+ # @return [Model::GetUserCouriersResponse]
+ def get_user_couriers(opts: {})
+ data, _status_code, _headers = get_user_couriers_with_http_info(opts: opts)
+ data
+ end
+
+ def get_user_couriers_with_http_info(opts: {})
+ if @api_client.config.debugging
+ @api_client.config.logger.debug 'Calling API: CourierApi.get_user_couriers ...'
+ end
+
+
+
+ # resource path
+ local_var_path = "/tracking/2024-04/couriers"
+ method = :'GET'
+
+ # query parameters
+ query_params = opts[:query_params] || {}
+ # header parameters
+ header_params = opts[:header_params] || {}
+
+ # http body (model)
+ post_body = opts[:body]
+
+ # return_type
+ return_type = 'GetUserCouriersResponse'
+
+ new_options = opts.merge(
+ :operation => :"CourierApi.get_user_couriers",
+ :header_params => header_params,
+ :query_params => query_params,
+ :body => post_body,
+ :return_type => return_type,
+ :response_legacy_tag => "",
+ :is_paging => false
+ )
+
+ data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
+ if @api_client.config.debugging
+ @api_client.config.logger.debug "API called: CourierApi#get_user_couriers\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
+ end
+ return data, status_code, headers
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/api/estimated_delivery_date.rb b/lib/aftership-tracking-sdk/api/estimated_delivery_date.rb
new file mode 100644
index 0000000..87673ee
--- /dev/null
+++ b/lib/aftership-tracking-sdk/api/estimated_delivery_date.rb
@@ -0,0 +1,67 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+require 'cgi'
+
+module AftershipAPI
+ class EstimatedDeliveryDateApi
+ attr_accessor :api_client
+
+ def initialize(api_client = ApiClient.default)
+ @api_client = api_client
+ end
+
+ # predict_batch
+ # > 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.
+
+ # @param body [Model::PredictBatchRequest]
+ # @param [Hash] opts the optional parameters
+ # @return [Model::PredictBatchResponse]
+ def predict_batch(body:, opts: {})
+ if "" != ""
+ body = { :'' => body }
+ end
+ opts[:body] = body
+ data, _status_code, _headers = predict_batch_with_http_info(opts: opts)
+ data
+ end
+
+ def predict_batch_with_http_info(opts: {})
+ if @api_client.config.debugging
+ @api_client.config.logger.debug 'Calling API: EstimatedDeliveryDateApi.predict_batch ...'
+ end
+
+
+
+ # resource path
+ local_var_path = "/tracking/2024-04/estimated-delivery-date/predict-batch"
+ method = :'POST'
+
+ # query parameters
+ query_params = opts[:query_params] || {}
+ # header parameters
+ header_params = opts[:header_params] || {}
+
+ # http body (model)
+ post_body = opts[:body]
+
+ # return_type
+ return_type = 'PredictBatchResponse'
+
+ new_options = opts.merge(
+ :operation => :"EstimatedDeliveryDateApi.predict_batch",
+ :header_params => header_params,
+ :query_params => query_params,
+ :body => post_body,
+ :return_type => return_type,
+ :response_legacy_tag => "",
+ :is_paging => false
+ )
+
+ data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
+ if @api_client.config.debugging
+ @api_client.config.logger.debug "API called: EstimatedDeliveryDateApi#predict_batch\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
+ end
+ return data, status_code, headers
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/api/last_checkpoint.rb b/lib/aftership-tracking-sdk/api/last_checkpoint.rb
new file mode 100644
index 0000000..6962510
--- /dev/null
+++ b/lib/aftership-tracking-sdk/api/last_checkpoint.rb
@@ -0,0 +1,143 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+require 'cgi'
+
+module AftershipAPI
+ class LastCheckpointApi
+ attr_accessor :api_client
+
+ def initialize(api_client = ApiClient.default)
+ @api_client = api_client
+ end
+
+ # get_checkpoint_by_slug_tracking_number
+ # Return the tracking information of the last checkpoint of a single tracking.
+ # @param slug [String] Tracking slug
+ # @param tracking_number [String] Tracking number
+ # @param [Hash] opts the optional parameters
+ # @option opts [String] :fields List of fields to include in the response. Use comma for multiple values. Fields to include: `slug`, `created_at`, `checkpoint_time`, `city`, `coordinates`, `country_iso3`, `country_name`, `message`, `state`, `tag`, `zip`
+ # @option opts [String] :lang Support Chinese to English translation for `china-ems` and `china-post` only
+ # @option opts [String] :tracking_account_number Additional field required by some carriers to retrieve the tracking info. The shipper’s carrier account number. Refer to our article on for more details.
+ # @option opts [String] :tracking_origin_country Additional field required by some carriers to retrieve the tracking info. The origin country/region of the shipment. Refer to our article on for more details.
+ # @option opts [String] :tracking_destination_country Additional field required by some carriers to retrieve the tracking info. The destination country/region of the shipment. Refer to our article on for more details.
+ # @option opts [String] :tracking_key Additional field required by some carriers to retrieve the tracking info. A type of tracking credential required by some carriers. Refer to our article on for more details.
+ # @option opts [String] :tracking_postal_code Additional field required by some carriers to retrieve the tracking info. The postal code of the recipient’s address. Refer to our article on for more details.
+ # @option opts [String] :tracking_ship_date Additional field required by some carriers to retrieve the tracking info. The date the shipment was sent, using the format YYYYMMDD. Refer to our article on for more details.
+ # @option opts [String] :tracking_state Additional field required by some carriers to retrieve the tracking info. The state/province of the recipient’s address. Refer to our article on for more details.
+ # @return [Model::GetCheckpointBySlugTrackingNumberResponse]
+ def get_checkpoint_by_slug_tracking_number(slug:, tracking_number:, opts: {})
+ data, _status_code, _headers = get_checkpoint_by_slug_tracking_number_with_http_info(slug: slug, tracking_number: tracking_number, opts: opts)
+ data
+ end
+
+ def get_checkpoint_by_slug_tracking_number_with_http_info(slug:, tracking_number:, opts: {})
+ if @api_client.config.debugging
+ @api_client.config.logger.debug 'Calling API: LastCheckpointApi.get_checkpoint_by_slug_tracking_number ...'
+ end
+
+ if slug.nil? || (slug.to_s == '')
+ raise InvalidParamError.new "slug cannot be nil or empty"
+ end
+ if tracking_number.nil? || (tracking_number.to_s == '')
+ raise InvalidParamError.new "tracking_number cannot be nil or empty"
+ end
+
+
+ # resource path
+ local_var_path = "/tracking/2024-04/last_checkpoint/#{slug}/#{tracking_number}"
+ method = :'GET'
+
+ # query parameters
+ query_params = opts[:query_params] || {}
+ query_params[:'fields'] = opts[:'fields'] if !opts[:'fields'].nil?
+ query_params[:'lang'] = opts[:'lang'] if !opts[:'lang'].nil?
+ query_params[:'tracking_account_number'] = opts[:'tracking_account_number'] if !opts[:'tracking_account_number'].nil?
+ query_params[:'tracking_origin_country'] = opts[:'tracking_origin_country'] if !opts[:'tracking_origin_country'].nil?
+ query_params[:'tracking_destination_country'] = opts[:'tracking_destination_country'] if !opts[:'tracking_destination_country'].nil?
+ query_params[:'tracking_key'] = opts[:'tracking_key'] if !opts[:'tracking_key'].nil?
+ query_params[:'tracking_postal_code'] = opts[:'tracking_postal_code'] if !opts[:'tracking_postal_code'].nil?
+ query_params[:'tracking_ship_date'] = opts[:'tracking_ship_date'] if !opts[:'tracking_ship_date'].nil?
+ query_params[:'tracking_state'] = opts[:'tracking_state'] if !opts[:'tracking_state'].nil?
+ # header parameters
+ header_params = opts[:header_params] || {}
+
+ # http body (model)
+ post_body = opts[:body]
+
+ # return_type
+ return_type = 'GetCheckpointBySlugTrackingNumberResponse'
+
+ new_options = opts.merge(
+ :operation => :"LastCheckpointApi.get_checkpoint_by_slug_tracking_number",
+ :header_params => header_params,
+ :query_params => query_params,
+ :body => post_body,
+ :return_type => return_type,
+ :response_legacy_tag => "",
+ :is_paging => false
+ )
+
+ data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
+ if @api_client.config.debugging
+ @api_client.config.logger.debug "API called: LastCheckpointApi#get_checkpoint_by_slug_tracking_number\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
+ end
+ return data, status_code, headers
+ end
+
+ # get_checkpoint_by_tracking_id
+ # Return the tracking information of the last checkpoint of a single tracking.
+ # @param tracking_id [String] tracking id
+ # @param [Hash] opts the optional parameters
+ # @option opts [String] :fields List of fields to include in the response. Use comma for multiple values. Fields to include: `slug`, `created_at`, `checkpoint_time`, `city`, `coordinates`, `country_iso3`, `country_name`, `message`, `state`, `tag`, `zip`
+ # @option opts [String] :lang Support Chinese to English translation for `china-ems` and `china-post` only
+ # @return [Model::GetCheckpointByTrackingIdResponse]
+ def get_checkpoint_by_tracking_id(tracking_id:, opts: {})
+ data, _status_code, _headers = get_checkpoint_by_tracking_id_with_http_info(tracking_id: tracking_id, opts: opts)
+ data
+ end
+
+ def get_checkpoint_by_tracking_id_with_http_info(tracking_id:, opts: {})
+ if @api_client.config.debugging
+ @api_client.config.logger.debug 'Calling API: LastCheckpointApi.get_checkpoint_by_tracking_id ...'
+ end
+
+ if tracking_id.nil? || (tracking_id.to_s == '')
+ raise InvalidParamError.new "tracking_id cannot be nil or empty"
+ end
+
+
+ # resource path
+ local_var_path = "/tracking/2024-04/last_checkpoint/#{tracking_id}"
+ method = :'GET'
+
+ # query parameters
+ query_params = opts[:query_params] || {}
+ query_params[:'fields'] = opts[:'fields'] if !opts[:'fields'].nil?
+ query_params[:'lang'] = opts[:'lang'] if !opts[:'lang'].nil?
+ # header parameters
+ header_params = opts[:header_params] || {}
+
+ # http body (model)
+ post_body = opts[:body]
+
+ # return_type
+ return_type = 'GetCheckpointByTrackingIdResponse'
+
+ new_options = opts.merge(
+ :operation => :"LastCheckpointApi.get_checkpoint_by_tracking_id",
+ :header_params => header_params,
+ :query_params => query_params,
+ :body => post_body,
+ :return_type => return_type,
+ :response_legacy_tag => "",
+ :is_paging => false
+ )
+
+ data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
+ if @api_client.config.debugging
+ @api_client.config.logger.debug "API called: LastCheckpointApi#get_checkpoint_by_tracking_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
+ end
+ return data, status_code, headers
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/api/notification.rb b/lib/aftership-tracking-sdk/api/notification.rb
new file mode 100644
index 0000000..d90392f
--- /dev/null
+++ b/lib/aftership-tracking-sdk/api/notification.rb
@@ -0,0 +1,403 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+require 'cgi'
+
+module AftershipAPI
+ class NotificationApi
+ attr_accessor :api_client
+
+ def initialize(api_client = ApiClient.default)
+ @api_client = api_client
+ end
+
+ # add_notification_by_slug_tracking_number
+ # Add notification receivers to a tracking number.
+ # @param slug [String] Tracking slug
+ # @param tracking_number [String] Tracking number
+
+ # @param body [Model::NotificationRequestV1]
+ # @param [Hash] opts the optional parameters
+ # @option opts [String] :tracking_account_number Additional field required by some carriers to retrieve the tracking info. The shipper’s carrier account number. Refer to our article on for more details.
+ # @option opts [String] :tracking_origin_country Additional field required by some carriers to retrieve the tracking info. The origin country/region of the shipment. Refer to our article on for more details.
+ # @option opts [String] :tracking_destination_country Additional field required by some carriers to retrieve the tracking info. The destination country/region of the shipment. Refer to our article on for more details.
+ # @option opts [String] :tracking_key Additional field required by some carriers to retrieve the tracking info. A type of tracking credential required by some carriers. Refer to our article on for more details.
+ # @option opts [String] :tracking_postal_code Additional field required by some carriers to retrieve the tracking info. The postal code of the recipient’s address. Refer to our article on for more details.
+ # @option opts [String] :tracking_ship_date Additional field required by some carriers to retrieve the tracking info. The date the shipment was sent, using the format YYYYMMDD. Refer to our article on for more details.
+ # @option opts [String] :tracking_state Additional field required by some carriers to retrieve the tracking info. The state/province of the recipient’s address. Refer to our article on for more details.
+ # @return [Model::Notification]
+ def add_notification_by_slug_tracking_number(slug:, tracking_number:, body:, opts: {})
+ if "notification" != ""
+ body = { :'notification' => body }
+ end
+ opts[:body] = body
+ data, _status_code, _headers = add_notification_by_slug_tracking_number_with_http_info(slug: slug, tracking_number: tracking_number, opts: opts)
+ data
+ end
+
+ def add_notification_by_slug_tracking_number_with_http_info(slug:, tracking_number:, opts: {})
+ if @api_client.config.debugging
+ @api_client.config.logger.debug 'Calling API: NotificationApi.add_notification_by_slug_tracking_number ...'
+ end
+
+ if slug.nil? || (slug.to_s == '')
+ raise InvalidParamError.new "slug cannot be nil or empty"
+ end
+ if tracking_number.nil? || (tracking_number.to_s == '')
+ raise InvalidParamError.new "tracking_number cannot be nil or empty"
+ end
+
+
+ # resource path
+ local_var_path = "/tracking/2024-04/notifications/#{slug}/#{tracking_number}/add"
+ method = :'POST'
+
+ # query parameters
+ query_params = opts[:query_params] || {}
+ query_params[:'tracking_account_number'] = opts[:'tracking_account_number'] if !opts[:'tracking_account_number'].nil?
+ query_params[:'tracking_origin_country'] = opts[:'tracking_origin_country'] if !opts[:'tracking_origin_country'].nil?
+ query_params[:'tracking_destination_country'] = opts[:'tracking_destination_country'] if !opts[:'tracking_destination_country'].nil?
+ query_params[:'tracking_key'] = opts[:'tracking_key'] if !opts[:'tracking_key'].nil?
+ query_params[:'tracking_postal_code'] = opts[:'tracking_postal_code'] if !opts[:'tracking_postal_code'].nil?
+ query_params[:'tracking_ship_date'] = opts[:'tracking_ship_date'] if !opts[:'tracking_ship_date'].nil?
+ query_params[:'tracking_state'] = opts[:'tracking_state'] if !opts[:'tracking_state'].nil?
+ # header parameters
+ header_params = opts[:header_params] || {}
+
+ # http body (model)
+ post_body = opts[:body]
+
+ # return_type
+ return_type = 'Notification'
+
+ new_options = opts.merge(
+ :operation => :"NotificationApi.add_notification_by_slug_tracking_number",
+ :header_params => header_params,
+ :query_params => query_params,
+ :body => post_body,
+ :return_type => return_type,
+ :response_legacy_tag => "notification",
+ :is_paging => false
+ )
+
+ data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
+ if @api_client.config.debugging
+ @api_client.config.logger.debug "API called: NotificationApi#add_notification_by_slug_tracking_number\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
+ end
+ return data, status_code, headers
+ end
+
+ # add_notification_by_tracking_id
+ # Add notification receivers to a tracking number.
+ # @param tracking_id [String] tracking id
+
+ # @param body [Model::NotificationRequestV1]
+ # @param [Hash] opts the optional parameters
+ # @return [Model::Notification]
+ def add_notification_by_tracking_id(tracking_id:, body:, opts: {})
+ if "notification" != ""
+ body = { :'notification' => body }
+ end
+ opts[:body] = body
+ data, _status_code, _headers = add_notification_by_tracking_id_with_http_info(tracking_id: tracking_id, opts: opts)
+ data
+ end
+
+ def add_notification_by_tracking_id_with_http_info(tracking_id:, opts: {})
+ if @api_client.config.debugging
+ @api_client.config.logger.debug 'Calling API: NotificationApi.add_notification_by_tracking_id ...'
+ end
+
+ if tracking_id.nil? || (tracking_id.to_s == '')
+ raise InvalidParamError.new "tracking_id cannot be nil or empty"
+ end
+
+
+ # resource path
+ local_var_path = "/tracking/2024-04/notifications/#{tracking_id}/add"
+ method = :'POST'
+
+ # query parameters
+ query_params = opts[:query_params] || {}
+ # header parameters
+ header_params = opts[:header_params] || {}
+
+ # http body (model)
+ post_body = opts[:body]
+
+ # return_type
+ return_type = 'Notification'
+
+ new_options = opts.merge(
+ :operation => :"NotificationApi.add_notification_by_tracking_id",
+ :header_params => header_params,
+ :query_params => query_params,
+ :body => post_body,
+ :return_type => return_type,
+ :response_legacy_tag => "notification",
+ :is_paging => false
+ )
+
+ data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
+ if @api_client.config.debugging
+ @api_client.config.logger.debug "API called: NotificationApi#add_notification_by_tracking_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
+ end
+ return data, status_code, headers
+ end
+
+ # delete_notification_by_slug_tracking_number
+ # Remove notification receivers from a tracking number.
+ # @param slug [String] Tracking slug
+ # @param tracking_number [String] Tracking number
+
+ # @param body [Model::NotificationRequestV1]
+ # @param [Hash] opts the optional parameters
+ # @option opts [String] :tracking_account_number Additional field required by some carriers to retrieve the tracking info. The shipper’s carrier account number. Refer to our article on for more details.
+ # @option opts [String] :tracking_origin_country Additional field required by some carriers to retrieve the tracking info. The origin country/region of the shipment. Refer to our article on for more details.
+ # @option opts [String] :tracking_destination_country Additional field required by some carriers to retrieve the tracking info. The destination country/region of the shipment. Refer to our article on for more details.
+ # @option opts [String] :tracking_key Additional field required by some carriers to retrieve the tracking info. A type of tracking credential required by some carriers. Refer to our article on for more details.
+ # @option opts [String] :tracking_postal_code Additional field required by some carriers to retrieve the tracking info. The postal code of the recipient’s address. Refer to our article on for more details.
+ # @option opts [String] :tracking_ship_date Additional field required by some carriers to retrieve the tracking info. The date the shipment was sent, using the format YYYYMMDD. Refer to our article on for more details.
+ # @option opts [String] :tracking_state Additional field required by some carriers to retrieve the tracking info. The state/province of the recipient’s address. Refer to our article on for more details.
+ # @return [Model::Notification]
+ def delete_notification_by_slug_tracking_number(slug:, tracking_number:, body:, opts: {})
+ if "notification" != ""
+ body = { :'notification' => body }
+ end
+ opts[:body] = body
+ data, _status_code, _headers = delete_notification_by_slug_tracking_number_with_http_info(slug: slug, tracking_number: tracking_number, opts: opts)
+ data
+ end
+
+ def delete_notification_by_slug_tracking_number_with_http_info(slug:, tracking_number:, opts: {})
+ if @api_client.config.debugging
+ @api_client.config.logger.debug 'Calling API: NotificationApi.delete_notification_by_slug_tracking_number ...'
+ end
+
+ if slug.nil? || (slug.to_s == '')
+ raise InvalidParamError.new "slug cannot be nil or empty"
+ end
+ if tracking_number.nil? || (tracking_number.to_s == '')
+ raise InvalidParamError.new "tracking_number cannot be nil or empty"
+ end
+
+
+ # resource path
+ local_var_path = "/tracking/2024-04/notifications/#{slug}/#{tracking_number}/remove"
+ method = :'POST'
+
+ # query parameters
+ query_params = opts[:query_params] || {}
+ query_params[:'tracking_account_number'] = opts[:'tracking_account_number'] if !opts[:'tracking_account_number'].nil?
+ query_params[:'tracking_origin_country'] = opts[:'tracking_origin_country'] if !opts[:'tracking_origin_country'].nil?
+ query_params[:'tracking_destination_country'] = opts[:'tracking_destination_country'] if !opts[:'tracking_destination_country'].nil?
+ query_params[:'tracking_key'] = opts[:'tracking_key'] if !opts[:'tracking_key'].nil?
+ query_params[:'tracking_postal_code'] = opts[:'tracking_postal_code'] if !opts[:'tracking_postal_code'].nil?
+ query_params[:'tracking_ship_date'] = opts[:'tracking_ship_date'] if !opts[:'tracking_ship_date'].nil?
+ query_params[:'tracking_state'] = opts[:'tracking_state'] if !opts[:'tracking_state'].nil?
+ # header parameters
+ header_params = opts[:header_params] || {}
+
+ # http body (model)
+ post_body = opts[:body]
+
+ # return_type
+ return_type = 'Notification'
+
+ new_options = opts.merge(
+ :operation => :"NotificationApi.delete_notification_by_slug_tracking_number",
+ :header_params => header_params,
+ :query_params => query_params,
+ :body => post_body,
+ :return_type => return_type,
+ :response_legacy_tag => "notification",
+ :is_paging => false
+ )
+
+ data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
+ if @api_client.config.debugging
+ @api_client.config.logger.debug "API called: NotificationApi#delete_notification_by_slug_tracking_number\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
+ end
+ return data, status_code, headers
+ end
+
+ # delete_notification_by_tracking_id
+ # Remove notification receivers from a tracking number.
+ # @param tracking_id [String] tracking id
+
+ # @param body [Model::NotificationRequestV1]
+ # @param [Hash] opts the optional parameters
+ # @return [Model::Notification]
+ def delete_notification_by_tracking_id(tracking_id:, body:, opts: {})
+ if "notification" != ""
+ body = { :'notification' => body }
+ end
+ opts[:body] = body
+ data, _status_code, _headers = delete_notification_by_tracking_id_with_http_info(tracking_id: tracking_id, opts: opts)
+ data
+ end
+
+ def delete_notification_by_tracking_id_with_http_info(tracking_id:, opts: {})
+ if @api_client.config.debugging
+ @api_client.config.logger.debug 'Calling API: NotificationApi.delete_notification_by_tracking_id ...'
+ end
+
+ if tracking_id.nil? || (tracking_id.to_s == '')
+ raise InvalidParamError.new "tracking_id cannot be nil or empty"
+ end
+
+
+ # resource path
+ local_var_path = "/tracking/2024-04/notifications/#{tracking_id}/remove"
+ method = :'POST'
+
+ # query parameters
+ query_params = opts[:query_params] || {}
+ # header parameters
+ header_params = opts[:header_params] || {}
+
+ # http body (model)
+ post_body = opts[:body]
+
+ # return_type
+ return_type = 'Notification'
+
+ new_options = opts.merge(
+ :operation => :"NotificationApi.delete_notification_by_tracking_id",
+ :header_params => header_params,
+ :query_params => query_params,
+ :body => post_body,
+ :return_type => return_type,
+ :response_legacy_tag => "notification",
+ :is_paging => false
+ )
+
+ data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
+ if @api_client.config.debugging
+ @api_client.config.logger.debug "API called: NotificationApi#delete_notification_by_tracking_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
+ end
+ return data, status_code, headers
+ end
+
+ # get_notification_by_slug_tracking_number
+ # Get contact information for the users to notify when the tracking changes. Please note that only customer receivers will be returned. Any `email`, `sms` or `webhook` that belongs to the Store will not be returned.
+ # @param slug [String] Tracking slug
+ # @param tracking_number [String] Tracking number
+ # @param [Hash] opts the optional parameters
+ # @option opts [String] :tracking_account_number Additional field required by some carriers to retrieve the tracking info. The shipper’s carrier account number. Refer to our article on for more details.
+ # @option opts [String] :tracking_origin_country Additional field required by some carriers to retrieve the tracking info. The origin country/region of the shipment. Refer to our article on for more details.
+ # @option opts [String] :tracking_destination_country Additional field required by some carriers to retrieve the tracking info. The destination country/region of the shipment. Refer to our article on for more details.
+ # @option opts [String] :tracking_key Additional field required by some carriers to retrieve the tracking info. A type of tracking credential required by some carriers. Refer to our article on for more details.
+ # @option opts [String] :tracking_postal_code Additional field required by some carriers to retrieve the tracking info. The postal code of the recipient’s address. Refer to our article on for more details.
+ # @option opts [String] :tracking_ship_date Additional field required by some carriers to retrieve the tracking info. The date the shipment was sent, using the format YYYYMMDD. Refer to our article on for more details.
+ # @option opts [String] :tracking_state Additional field required by some carriers to retrieve the tracking info. The state/province of the recipient’s address. Refer to our article on for more details.
+ # @return [Model::Notification]
+ def get_notification_by_slug_tracking_number(slug:, tracking_number:, opts: {})
+ data, _status_code, _headers = get_notification_by_slug_tracking_number_with_http_info(slug: slug, tracking_number: tracking_number, opts: opts)
+ data
+ end
+
+ def get_notification_by_slug_tracking_number_with_http_info(slug:, tracking_number:, opts: {})
+ if @api_client.config.debugging
+ @api_client.config.logger.debug 'Calling API: NotificationApi.get_notification_by_slug_tracking_number ...'
+ end
+
+ if slug.nil? || (slug.to_s == '')
+ raise InvalidParamError.new "slug cannot be nil or empty"
+ end
+ if tracking_number.nil? || (tracking_number.to_s == '')
+ raise InvalidParamError.new "tracking_number cannot be nil or empty"
+ end
+
+
+ # resource path
+ local_var_path = "/tracking/2024-04/notifications/#{slug}/#{tracking_number}"
+ method = :'GET'
+
+ # query parameters
+ query_params = opts[:query_params] || {}
+ query_params[:'tracking_account_number'] = opts[:'tracking_account_number'] if !opts[:'tracking_account_number'].nil?
+ query_params[:'tracking_origin_country'] = opts[:'tracking_origin_country'] if !opts[:'tracking_origin_country'].nil?
+ query_params[:'tracking_destination_country'] = opts[:'tracking_destination_country'] if !opts[:'tracking_destination_country'].nil?
+ query_params[:'tracking_key'] = opts[:'tracking_key'] if !opts[:'tracking_key'].nil?
+ query_params[:'tracking_postal_code'] = opts[:'tracking_postal_code'] if !opts[:'tracking_postal_code'].nil?
+ query_params[:'tracking_ship_date'] = opts[:'tracking_ship_date'] if !opts[:'tracking_ship_date'].nil?
+ query_params[:'tracking_state'] = opts[:'tracking_state'] if !opts[:'tracking_state'].nil?
+ # header parameters
+ header_params = opts[:header_params] || {}
+
+ # http body (model)
+ post_body = opts[:body]
+
+ # return_type
+ return_type = 'Notification'
+
+ new_options = opts.merge(
+ :operation => :"NotificationApi.get_notification_by_slug_tracking_number",
+ :header_params => header_params,
+ :query_params => query_params,
+ :body => post_body,
+ :return_type => return_type,
+ :response_legacy_tag => "notification",
+ :is_paging => false
+ )
+
+ data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
+ if @api_client.config.debugging
+ @api_client.config.logger.debug "API called: NotificationApi#get_notification_by_slug_tracking_number\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
+ end
+ return data, status_code, headers
+ end
+
+ # get_notification_by_tracking_id
+ # Get contact information for the users to notify when the tracking changes. Please note that only customer receivers will be returned. Any `email`, `sms` or `webhook` that belongs to the Store will not be returned.
+ # @param tracking_id [String] tracking id
+ # @param [Hash] opts the optional parameters
+ # @return [Model::Notification]
+ def get_notification_by_tracking_id(tracking_id:, opts: {})
+ data, _status_code, _headers = get_notification_by_tracking_id_with_http_info(tracking_id: tracking_id, opts: opts)
+ data
+ end
+
+ def get_notification_by_tracking_id_with_http_info(tracking_id:, opts: {})
+ if @api_client.config.debugging
+ @api_client.config.logger.debug 'Calling API: NotificationApi.get_notification_by_tracking_id ...'
+ end
+
+ if tracking_id.nil? || (tracking_id.to_s == '')
+ raise InvalidParamError.new "tracking_id cannot be nil or empty"
+ end
+
+
+ # resource path
+ local_var_path = "/tracking/2024-04/notifications/#{tracking_id}"
+ method = :'GET'
+
+ # query parameters
+ query_params = opts[:query_params] || {}
+ # header parameters
+ header_params = opts[:header_params] || {}
+
+ # http body (model)
+ post_body = opts[:body]
+
+ # return_type
+ return_type = 'Notification'
+
+ new_options = opts.merge(
+ :operation => :"NotificationApi.get_notification_by_tracking_id",
+ :header_params => header_params,
+ :query_params => query_params,
+ :body => post_body,
+ :return_type => return_type,
+ :response_legacy_tag => "notification",
+ :is_paging => false
+ )
+
+ data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
+ if @api_client.config.debugging
+ @api_client.config.logger.debug "API called: NotificationApi#get_notification_by_tracking_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
+ end
+ return data, status_code, headers
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/api/tracking.rb b/lib/aftership-tracking-sdk/api/tracking.rb
new file mode 100644
index 0000000..089c03b
--- /dev/null
+++ b/lib/aftership-tracking-sdk/api/tracking.rb
@@ -0,0 +1,793 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+require 'cgi'
+
+module AftershipAPI
+ class TrackingApi
+ attr_accessor :api_client
+
+ def initialize(api_client = ApiClient.default)
+ @api_client = api_client
+ end
+
+ # create_tracking
+ # Create a tracking.
+
+ # @param body [Model::TrackingCreateTrackingRequest]
+ # @param [Hash] opts the optional parameters
+ # @return [Model::Tracking]
+ def create_tracking(body:, opts: {})
+ if "tracking" != ""
+ body = { :'tracking' => body }
+ end
+ opts[:body] = body
+ data, _status_code, _headers = create_tracking_with_http_info(opts: opts)
+ data
+ end
+
+ def create_tracking_with_http_info(opts: {})
+ if @api_client.config.debugging
+ @api_client.config.logger.debug 'Calling API: TrackingApi.create_tracking ...'
+ end
+
+
+
+ # resource path
+ local_var_path = "/tracking/2024-04/trackings"
+ method = :'POST'
+
+ # query parameters
+ query_params = opts[:query_params] || {}
+ # header parameters
+ header_params = opts[:header_params] || {}
+
+ # http body (model)
+ post_body = opts[:body]
+
+ # return_type
+ return_type = 'Tracking'
+
+ new_options = opts.merge(
+ :operation => :"TrackingApi.create_tracking",
+ :header_params => header_params,
+ :query_params => query_params,
+ :body => post_body,
+ :return_type => return_type,
+ :response_legacy_tag => "tracking",
+ :is_paging => false
+ )
+
+ data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
+ if @api_client.config.debugging
+ @api_client.config.logger.debug "API called: TrackingApi#create_tracking\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
+ end
+ return data, status_code, headers
+ end
+
+ # delete_tracking_by_id
+ # Delete a tracking.
+ # @param id [String] tracking ID
+ # @param [Hash] opts the optional parameters
+ # @return [Model::PartialDeleteTracking]
+ def delete_tracking_by_id(id:, opts: {})
+ data, _status_code, _headers = delete_tracking_by_id_with_http_info(id: id, opts: opts)
+ data
+ end
+
+ def delete_tracking_by_id_with_http_info(id:, opts: {})
+ if @api_client.config.debugging
+ @api_client.config.logger.debug 'Calling API: TrackingApi.delete_tracking_by_id ...'
+ end
+
+ if id.nil? || (id.to_s == '')
+ raise InvalidParamError.new "id cannot be nil or empty"
+ end
+
+
+ # resource path
+ local_var_path = "/tracking/2024-04/trackings/#{id}"
+ method = :'DELETE'
+
+ # query parameters
+ query_params = opts[:query_params] || {}
+ # header parameters
+ header_params = opts[:header_params] || {}
+
+ # http body (model)
+ post_body = opts[:body]
+
+ # return_type
+ return_type = 'PartialDeleteTracking'
+
+ new_options = opts.merge(
+ :operation => :"TrackingApi.delete_tracking_by_id",
+ :header_params => header_params,
+ :query_params => query_params,
+ :body => post_body,
+ :return_type => return_type,
+ :response_legacy_tag => "tracking",
+ :is_paging => false
+ )
+
+ data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
+ if @api_client.config.debugging
+ @api_client.config.logger.debug "API called: TrackingApi#delete_tracking_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
+ end
+ return data, status_code, headers
+ end
+
+ # delete_tracking_by_slug_tracking_number
+ # Delete a tracking.
+ # @param slug [String] Tracking slug
+ # @param tracking_number [String] Tracking number
+ # @param [Hash] opts the optional parameters
+ # @option opts [String] :tracking_account_number Additional field required by some carriers to retrieve the tracking info. The shipper’s carrier account number. Refer to our article on for more details.
+ # @option opts [String] :tracking_origin_country Additional field required by some carriers to retrieve the tracking info. The origin country/region of the shipment. Refer to our article on for more details.
+ # @option opts [String] :tracking_destination_country Additional field required by some carriers to retrieve the tracking info. The destination country/region of the shipment. Refer to our article on for more details.
+ # @option opts [String] :tracking_key Additional field required by some carriers to retrieve the tracking info. A type of tracking credential required by some carriers. Refer to our article on for more details.
+ # @option opts [String] :tracking_postal_code Additional field required by some carriers to retrieve the tracking info. The postal code of the recipient’s address. Refer to our article on for more details.
+ # @option opts [String] :tracking_ship_date Additional field required by some carriers to retrieve the tracking info. The date the shipment was sent, using the format YYYYMMDD. Refer to our article on for more details.
+ # @option opts [String] :tracking_state Additional field required by some carriers to retrieve the tracking info. The state/province of the recipient’s address. Refer to our article on for more details.
+ # @return [Model::PartialDeleteTracking]
+ def delete_tracking_by_slug_tracking_number(slug:, tracking_number:, opts: {})
+ data, _status_code, _headers = delete_tracking_by_slug_tracking_number_with_http_info(slug: slug, tracking_number: tracking_number, opts: opts)
+ data
+ end
+
+ def delete_tracking_by_slug_tracking_number_with_http_info(slug:, tracking_number:, opts: {})
+ if @api_client.config.debugging
+ @api_client.config.logger.debug 'Calling API: TrackingApi.delete_tracking_by_slug_tracking_number ...'
+ end
+
+ if slug.nil? || (slug.to_s == '')
+ raise InvalidParamError.new "slug cannot be nil or empty"
+ end
+ if tracking_number.nil? || (tracking_number.to_s == '')
+ raise InvalidParamError.new "tracking_number cannot be nil or empty"
+ end
+
+
+ # resource path
+ local_var_path = "/tracking/2024-04/trackings/#{slug}/#{tracking_number}"
+ method = :'DELETE'
+
+ # query parameters
+ query_params = opts[:query_params] || {}
+ query_params[:'tracking_account_number'] = opts[:'tracking_account_number'] if !opts[:'tracking_account_number'].nil?
+ query_params[:'tracking_origin_country'] = opts[:'tracking_origin_country'] if !opts[:'tracking_origin_country'].nil?
+ query_params[:'tracking_destination_country'] = opts[:'tracking_destination_country'] if !opts[:'tracking_destination_country'].nil?
+ query_params[:'tracking_key'] = opts[:'tracking_key'] if !opts[:'tracking_key'].nil?
+ query_params[:'tracking_postal_code'] = opts[:'tracking_postal_code'] if !opts[:'tracking_postal_code'].nil?
+ query_params[:'tracking_ship_date'] = opts[:'tracking_ship_date'] if !opts[:'tracking_ship_date'].nil?
+ query_params[:'tracking_state'] = opts[:'tracking_state'] if !opts[:'tracking_state'].nil?
+ # header parameters
+ header_params = opts[:header_params] || {}
+
+ # http body (model)
+ post_body = opts[:body]
+
+ # return_type
+ return_type = 'PartialDeleteTracking'
+
+ new_options = opts.merge(
+ :operation => :"TrackingApi.delete_tracking_by_slug_tracking_number",
+ :header_params => header_params,
+ :query_params => query_params,
+ :body => post_body,
+ :return_type => return_type,
+ :response_legacy_tag => "tracking",
+ :is_paging => false
+ )
+
+ data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
+ if @api_client.config.debugging
+ @api_client.config.logger.debug "API called: TrackingApi#delete_tracking_by_slug_tracking_number\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
+ end
+ return data, status_code, headers
+ end
+
+ # get_tracking_by_id
+ # Get tracking results of a single tracking.
+ # @param id [String] tracking ID
+ # @param [Hash] opts the optional parameters
+ # @option opts [String] :fields List of fields to include in the response. Use comma for multiple values. Fields to include: `tracking_postal_code`, `tracking_ship_date`, `tracking_account_number`, `tracking_key`, `tracking_origin_country`, `tracking_destination_country`, `tracking_state`, `title`, `order_id`, `tag`, `checkpoints`
+ # @option opts [String] :lang Translate checkpoint messages from the carrier’s provided language to the target language. Supported target languages include: - English (en) - French (fr) - French Canadian (fr-CA) - Arabic (ar) - Bulgarian (bg) - Catalan (ca) - Croatian (hr) - Czech (cs) - Danish (da) - Dutch (nl) - Estonian (et) - Filipino (tl) - Finnish (fi) - German (de) - Greek (el) - Hebrew (he) - Hindi (hi) - Hungarian (hu) - Indonesian (id) - Italian (it) - Japanese (ja) - Korean (ko) - Latvian (lv) - Lithuanian (lt) - Malay (ms) - Polish (pl) - Portuguese (pt) - Romanian (ro) - Russian (ru) - Serbian (sr) - Slovak (sk) - Slovenian (sl) - Spanish (es) - Swedish (sv) - Thai (th) - Turkish (tr) - Ukrainian (uk) - Vietnamese (vi) - Simplified Chinese (zh-Hans) - Traditional Chinese (zh-Hant) - Norwegian (nb)
+ # @return [Model::Tracking]
+ def get_tracking_by_id(id:, opts: {})
+ data, _status_code, _headers = get_tracking_by_id_with_http_info(id: id, opts: opts)
+ data
+ end
+
+ def get_tracking_by_id_with_http_info(id:, opts: {})
+ if @api_client.config.debugging
+ @api_client.config.logger.debug 'Calling API: TrackingApi.get_tracking_by_id ...'
+ end
+
+ if id.nil? || (id.to_s == '')
+ raise InvalidParamError.new "id cannot be nil or empty"
+ end
+
+
+ # resource path
+ local_var_path = "/tracking/2024-04/trackings/#{id}"
+ method = :'GET'
+
+ # query parameters
+ query_params = opts[:query_params] || {}
+ query_params[:'fields'] = opts[:'fields'] if !opts[:'fields'].nil?
+ query_params[:'lang'] = opts[:'lang'] if !opts[:'lang'].nil?
+ # header parameters
+ header_params = opts[:header_params] || {}
+
+ # http body (model)
+ post_body = opts[:body]
+
+ # return_type
+ return_type = 'Tracking'
+
+ new_options = opts.merge(
+ :operation => :"TrackingApi.get_tracking_by_id",
+ :header_params => header_params,
+ :query_params => query_params,
+ :body => post_body,
+ :return_type => return_type,
+ :response_legacy_tag => "tracking",
+ :is_paging => false
+ )
+
+ data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
+ if @api_client.config.debugging
+ @api_client.config.logger.debug "API called: TrackingApi#get_tracking_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
+ end
+ return data, status_code, headers
+ end
+
+ # get_tracking_by_slug_tracking_number
+ # Get tracking results of a single tracking.
+ # @param slug [String] Tracking slug
+ # @param tracking_number [String] Tracking number
+ # @param [Hash] opts the optional parameters
+ # @option opts [String] :fields List of fields to include in the response. Use comma for multiple values. Fields to include: `tracking_postal_code`, `tracking_ship_date`, `tracking_account_number`, `tracking_key`, `tracking_origin_country`, `tracking_destination_country`, `tracking_state`, `title`, `order_id`, `tag`, `checkpoints`
+ # @option opts [String] :lang Support Chinese to English translation for `china-ems` and `china-post` only
+ # @option opts [String] :tracking_account_number Additional field required by some carriers to retrieve the tracking info. The shipper’s carrier account number. Refer to our article on for more details.
+ # @option opts [String] :tracking_origin_country Additional field required by some carriers to retrieve the tracking info. The origin country/region of the shipment. Refer to our article on for more details.
+ # @option opts [String] :tracking_destination_country Additional field required by some carriers to retrieve the tracking info. The destination country/region of the shipment. Refer to our article on for more details.
+ # @option opts [String] :tracking_key Additional field required by some carriers to retrieve the tracking info. A type of tracking credential required by some carriers. Refer to our article on for more details.
+ # @option opts [String] :tracking_postal_code Additional field required by some carriers to retrieve the tracking info. The postal code of the recipient’s address. Refer to our article on for more details.
+ # @option opts [String] :tracking_ship_date Additional field required by some carriers to retrieve the tracking info. The date the shipment was sent, using the format YYYYMMDD. Refer to our article on for more details.
+ # @option opts [String] :tracking_state Additional field required by some carriers to retrieve the tracking info. The state/province of the recipient’s address. Refer to our article on for more details.
+ # @return [Model::Tracking]
+ def get_tracking_by_slug_tracking_number(slug:, tracking_number:, opts: {})
+ data, _status_code, _headers = get_tracking_by_slug_tracking_number_with_http_info(slug: slug, tracking_number: tracking_number, opts: opts)
+ data
+ end
+
+ def get_tracking_by_slug_tracking_number_with_http_info(slug:, tracking_number:, opts: {})
+ if @api_client.config.debugging
+ @api_client.config.logger.debug 'Calling API: TrackingApi.get_tracking_by_slug_tracking_number ...'
+ end
+
+ if slug.nil? || (slug.to_s == '')
+ raise InvalidParamError.new "slug cannot be nil or empty"
+ end
+ if tracking_number.nil? || (tracking_number.to_s == '')
+ raise InvalidParamError.new "tracking_number cannot be nil or empty"
+ end
+
+
+ # resource path
+ local_var_path = "/tracking/2024-04/trackings/#{slug}/#{tracking_number}"
+ method = :'GET'
+
+ # query parameters
+ query_params = opts[:query_params] || {}
+ query_params[:'fields'] = opts[:'fields'] if !opts[:'fields'].nil?
+ query_params[:'lang'] = opts[:'lang'] if !opts[:'lang'].nil?
+ query_params[:'tracking_account_number'] = opts[:'tracking_account_number'] if !opts[:'tracking_account_number'].nil?
+ query_params[:'tracking_origin_country'] = opts[:'tracking_origin_country'] if !opts[:'tracking_origin_country'].nil?
+ query_params[:'tracking_destination_country'] = opts[:'tracking_destination_country'] if !opts[:'tracking_destination_country'].nil?
+ query_params[:'tracking_key'] = opts[:'tracking_key'] if !opts[:'tracking_key'].nil?
+ query_params[:'tracking_postal_code'] = opts[:'tracking_postal_code'] if !opts[:'tracking_postal_code'].nil?
+ query_params[:'tracking_ship_date'] = opts[:'tracking_ship_date'] if !opts[:'tracking_ship_date'].nil?
+ query_params[:'tracking_state'] = opts[:'tracking_state'] if !opts[:'tracking_state'].nil?
+ # header parameters
+ header_params = opts[:header_params] || {}
+
+ # http body (model)
+ post_body = opts[:body]
+
+ # return_type
+ return_type = 'Tracking'
+
+ new_options = opts.merge(
+ :operation => :"TrackingApi.get_tracking_by_slug_tracking_number",
+ :header_params => header_params,
+ :query_params => query_params,
+ :body => post_body,
+ :return_type => return_type,
+ :response_legacy_tag => "tracking",
+ :is_paging => false
+ )
+
+ data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
+ if @api_client.config.debugging
+ @api_client.config.logger.debug "API called: TrackingApi#get_tracking_by_slug_tracking_number\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
+ end
+ return data, status_code, headers
+ end
+
+ # get_trackings
+ # Get tracking results of multiple trackings.
+ # @param [Hash] opts the optional parameters
+ # @option opts [Integer] :page The page to query. Maximum page number is bounded by total number of queried trackings which cannot exceed 160,000 trackings. (Default: 1)
+ # @option opts [Integer] :limit Number of trackings each page contain. (Default: 100, Max: 200)
+ # @option opts [String] :keyword Search the content of the tracking record fields: `tracking_number`, `title`, `order_id`, `customer_name`, `custom_fields`, `emails`, `smses`
+ # @option opts [String] :tracking_numbers Tracking number of shipments. Use comma to separate multiple values (Example: RA123456789US,LE123456789US). Supports up to 50 tracking numbers.
+ # @option opts [String] :slug Unique courier code Use comma for multiple values. (Example: dhl,ups,usps)
+ # @option opts [Integer] :transit_time Total delivery time in days.- When the shipment is delivered: Transit time = Delivered date - Picked up date- When the shipment is not delivered: Transit time = Current date - Picked up dateValue as `null` for the shipment without pickup date.
+ # @option opts [String] :origin Origin country/region of trackings. Use ISO Alpha-3 (three letters). Use comma for multiple values. (Example: USA,HKG)
+ # @option opts [String] :destination Destination country/region of trackings. Use ISO Alpha-3 (three letters). Use comma for multiple values. (Example: USA,HKG)
+ # @option opts [String] :tag Current status of tracking. Values include `Pending`, `InfoReceived`, `InTransit`, `OutForDelivery`, `AttemptFail`, `Delivered`, `AvailableForPickup`, `Exception`, `Expired` (See tag definition)
+ # @option opts [String] :created_at_min Start date and time of trackings created. AfterShip only stores data of 120 days.(Defaults: 30 days ago, Example: 2013-03-15T16:41:56+08:00)
+ # @option opts [String] :created_at_max End date and time of trackings created.(Defaults: now, Example: 2013-04-15T16:41:56+08:00)
+ # @option opts [String] :updated_at_min Start date and time of trackings updated. (Example: 2013-04-15T16:41:56+08:00)
+ # @option opts [String] :updated_at_max End date and time of trackings updated. (Example: 2013-04-15T16:41:56+08:00)
+ # @option opts [String] :fields List of fields to include in the response. Use comma for multiple values. Available options: `title`, `order_id`, `tag`, `checkpoints`. Example: `title,order_id`
+ # @option opts [String] :return_to_sender Select return to sender, the value should be `true` or `false`, with optional comma separated.
+ # @option opts [String] :courier_destination_country_iso3 Destination country/region of trackings returned by courier. Use ISO Alpha-3 (three letters). Use comma for multiple values. (Example: USA,HKG)
+ # @option opts [String] :shipment_tags Tags you added to your shipments to help categorize and filter them easily. Use a comma to separate multiple values (Example: a,b)
+ # @option opts [String] :order_id A globally-unique identifier for the order. Use comma for multiple values.(Example: 6845a095a27a4caeb27487806f058add,4845a095a27a4caeb27487806f058abc)
+ # @return [Model::GetTrackingsResponse]
+ def get_trackings(opts: {})
+ data, _status_code, _headers = get_trackings_with_http_info(opts: opts)
+ data
+ end
+
+ def get_trackings_with_http_info(opts: {})
+ if @api_client.config.debugging
+ @api_client.config.logger.debug 'Calling API: TrackingApi.get_trackings ...'
+ end
+
+
+
+ # resource path
+ local_var_path = "/tracking/2024-04/trackings"
+ method = :'GET'
+
+ # query parameters
+ query_params = opts[:query_params] || {}
+ query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
+ query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
+ query_params[:'keyword'] = opts[:'keyword'] if !opts[:'keyword'].nil?
+ query_params[:'tracking_numbers'] = opts[:'tracking_numbers'] if !opts[:'tracking_numbers'].nil?
+ query_params[:'slug'] = opts[:'slug'] if !opts[:'slug'].nil?
+ query_params[:'transit_time'] = opts[:'transit_time'] if !opts[:'transit_time'].nil?
+ query_params[:'origin'] = opts[:'origin'] if !opts[:'origin'].nil?
+ query_params[:'destination'] = opts[:'destination'] if !opts[:'destination'].nil?
+ query_params[:'tag'] = opts[:'tag'] if !opts[:'tag'].nil?
+ query_params[:'created_at_min'] = opts[:'created_at_min'] if !opts[:'created_at_min'].nil?
+ query_params[:'created_at_max'] = opts[:'created_at_max'] if !opts[:'created_at_max'].nil?
+ query_params[:'updated_at_min'] = opts[:'updated_at_min'] if !opts[:'updated_at_min'].nil?
+ query_params[:'updated_at_max'] = opts[:'updated_at_max'] if !opts[:'updated_at_max'].nil?
+ query_params[:'fields'] = opts[:'fields'] if !opts[:'fields'].nil?
+ query_params[:'return_to_sender'] = opts[:'return_to_sender'] if !opts[:'return_to_sender'].nil?
+ query_params[:'courier_destination_country_iso3'] = opts[:'courier_destination_country_iso3'] if !opts[:'courier_destination_country_iso3'].nil?
+ query_params[:'shipment_tags'] = opts[:'shipment_tags'] if !opts[:'shipment_tags'].nil?
+ query_params[:'order_id'] = opts[:'order_id'] if !opts[:'order_id'].nil?
+ # header parameters
+ header_params = opts[:header_params] || {}
+
+ # http body (model)
+ post_body = opts[:body]
+
+ # return_type
+ return_type = 'GetTrackingsResponse'
+
+ new_options = opts.merge(
+ :operation => :"TrackingApi.get_trackings",
+ :header_params => header_params,
+ :query_params => query_params,
+ :body => post_body,
+ :return_type => return_type,
+ :response_legacy_tag => "trackings",
+ :is_paging => true
+ )
+
+ data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
+ if @api_client.config.debugging
+ @api_client.config.logger.debug "API called: TrackingApi#get_trackings\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
+ end
+ return data, status_code, headers
+ end
+
+ # mark_tracking_completed_by_id
+ # Mark a tracking as completed. The tracking won't auto update until retrack it.
+ # @param id [String] tracking id
+
+ # @param body [Model::MarkTrackingCompletedByIdRequest]
+ # @param [Hash] opts the optional parameters
+ # @return [Model::Tracking]
+ def mark_tracking_completed_by_id(id:, body:, opts: {})
+ if "" != ""
+ body = { :'' => body }
+ end
+ opts[:body] = body
+ data, _status_code, _headers = mark_tracking_completed_by_id_with_http_info(id: id, opts: opts)
+ data
+ end
+
+ def mark_tracking_completed_by_id_with_http_info(id:, opts: {})
+ if @api_client.config.debugging
+ @api_client.config.logger.debug 'Calling API: TrackingApi.mark_tracking_completed_by_id ...'
+ end
+
+ if id.nil? || (id.to_s == '')
+ raise InvalidParamError.new "id cannot be nil or empty"
+ end
+
+
+ # resource path
+ local_var_path = "/tracking/2024-04/trackings/#{id}/mark-as-completed"
+ method = :'POST'
+
+ # query parameters
+ query_params = opts[:query_params] || {}
+ # header parameters
+ header_params = opts[:header_params] || {}
+
+ # http body (model)
+ post_body = opts[:body]
+
+ # return_type
+ return_type = 'Tracking'
+
+ new_options = opts.merge(
+ :operation => :"TrackingApi.mark_tracking_completed_by_id",
+ :header_params => header_params,
+ :query_params => query_params,
+ :body => post_body,
+ :return_type => return_type,
+ :response_legacy_tag => "tracking",
+ :is_paging => false
+ )
+
+ data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
+ if @api_client.config.debugging
+ @api_client.config.logger.debug "API called: TrackingApi#mark_tracking_completed_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
+ end
+ return data, status_code, headers
+ end
+
+ # mark_tracking_completed_by_slug_tracking_number
+ # Mark a tracking as completed. The tracking won't auto update until retrack it.
+ # @param slug [String] Tracking slug
+ # @param tracking_number [String] Tracking number
+
+ # @param body [Model::MarkTrackingCompletedBySlugTrackingNumberRequest]
+ # @param [Hash] opts the optional parameters
+ # @option opts [String] :tracking_account_number Additional field required by some carriers to retrieve the tracking info. The shipper’s carrier account number. Refer to our article on for more details.
+ # @option opts [String] :tracking_origin_country Additional field required by some carriers to retrieve the tracking info. The origin country/region of the shipment. Refer to our article on for more details.
+ # @option opts [String] :tracking_destination_country Additional field required by some carriers to retrieve the tracking info. The destination country/region of the shipment. Refer to our article on for more details.
+ # @option opts [String] :tracking_key Additional field required by some carriers to retrieve the tracking info. A type of tracking credential required by some carriers. Refer to our article on for more details.
+ # @option opts [String] :tracking_postal_code Additional field required by some carriers to retrieve the tracking info. The postal code of the recipient’s address. Refer to our article on for more details.
+ # @option opts [String] :tracking_ship_date Additional field required by some carriers to retrieve the tracking info. The date the shipment was sent, using the format YYYYMMDD. Refer to our article on for more details.
+ # @option opts [String] :tracking_state Additional field required by some carriers to retrieve the tracking info. The state/province of the recipient’s address. Refer to our article on for more details.
+ # @return [Model::Tracking]
+ def mark_tracking_completed_by_slug_tracking_number(slug:, tracking_number:, body:, opts: {})
+ if "" != ""
+ body = { :'' => body }
+ end
+ opts[:body] = body
+ data, _status_code, _headers = mark_tracking_completed_by_slug_tracking_number_with_http_info(slug: slug, tracking_number: tracking_number, opts: opts)
+ data
+ end
+
+ def mark_tracking_completed_by_slug_tracking_number_with_http_info(slug:, tracking_number:, opts: {})
+ if @api_client.config.debugging
+ @api_client.config.logger.debug 'Calling API: TrackingApi.mark_tracking_completed_by_slug_tracking_number ...'
+ end
+
+ if slug.nil? || (slug.to_s == '')
+ raise InvalidParamError.new "slug cannot be nil or empty"
+ end
+ if tracking_number.nil? || (tracking_number.to_s == '')
+ raise InvalidParamError.new "tracking_number cannot be nil or empty"
+ end
+
+
+ # resource path
+ local_var_path = "/tracking/2024-04/trackings/#{slug}/#{tracking_number}/mark-as-completed"
+ method = :'POST'
+
+ # query parameters
+ query_params = opts[:query_params] || {}
+ query_params[:'tracking_account_number'] = opts[:'tracking_account_number'] if !opts[:'tracking_account_number'].nil?
+ query_params[:'tracking_origin_country'] = opts[:'tracking_origin_country'] if !opts[:'tracking_origin_country'].nil?
+ query_params[:'tracking_destination_country'] = opts[:'tracking_destination_country'] if !opts[:'tracking_destination_country'].nil?
+ query_params[:'tracking_key'] = opts[:'tracking_key'] if !opts[:'tracking_key'].nil?
+ query_params[:'tracking_postal_code'] = opts[:'tracking_postal_code'] if !opts[:'tracking_postal_code'].nil?
+ query_params[:'tracking_ship_date'] = opts[:'tracking_ship_date'] if !opts[:'tracking_ship_date'].nil?
+ query_params[:'tracking_state'] = opts[:'tracking_state'] if !opts[:'tracking_state'].nil?
+ # header parameters
+ header_params = opts[:header_params] || {}
+
+ # http body (model)
+ post_body = opts[:body]
+
+ # return_type
+ return_type = 'Tracking'
+
+ new_options = opts.merge(
+ :operation => :"TrackingApi.mark_tracking_completed_by_slug_tracking_number",
+ :header_params => header_params,
+ :query_params => query_params,
+ :body => post_body,
+ :return_type => return_type,
+ :response_legacy_tag => "tracking",
+ :is_paging => false
+ )
+
+ data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
+ if @api_client.config.debugging
+ @api_client.config.logger.debug "API called: TrackingApi#mark_tracking_completed_by_slug_tracking_number\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
+ end
+ return data, status_code, headers
+ end
+
+ # retrack_tracking_by_id
+ # Retrack an expired tracking. Max 3 times per tracking.
+ # @param id [String] tracking id
+ # @param [Hash] opts the optional parameters
+ # @return [Model::PartialUpdateTracking]
+ def retrack_tracking_by_id(id:, opts: {})
+ data, _status_code, _headers = retrack_tracking_by_id_with_http_info(id: id, opts: opts)
+ data
+ end
+
+ def retrack_tracking_by_id_with_http_info(id:, opts: {})
+ if @api_client.config.debugging
+ @api_client.config.logger.debug 'Calling API: TrackingApi.retrack_tracking_by_id ...'
+ end
+
+ if id.nil? || (id.to_s == '')
+ raise InvalidParamError.new "id cannot be nil or empty"
+ end
+
+
+ # resource path
+ local_var_path = "/tracking/2024-04/trackings/#{id}/retrack"
+ method = :'POST'
+
+ # query parameters
+ query_params = opts[:query_params] || {}
+ # header parameters
+ header_params = opts[:header_params] || {}
+
+ # http body (model)
+ post_body = opts[:body]
+
+ # return_type
+ return_type = 'PartialUpdateTracking'
+
+ new_options = opts.merge(
+ :operation => :"TrackingApi.retrack_tracking_by_id",
+ :header_params => header_params,
+ :query_params => query_params,
+ :body => post_body,
+ :return_type => return_type,
+ :response_legacy_tag => "tracking",
+ :is_paging => false
+ )
+
+ data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
+ if @api_client.config.debugging
+ @api_client.config.logger.debug "API called: TrackingApi#retrack_tracking_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
+ end
+ return data, status_code, headers
+ end
+
+ # retrack_tracking_by_slug_tracking_number
+ # Retrack an expired tracking. Max 3 times per tracking.
+ # @param slug [String] Tracking slug
+ # @param tracking_number [String] Tracking number
+ # @param [Hash] opts the optional parameters
+ # @option opts [String] :tracking_account_number Additional field required by some carriers to retrieve the tracking info. The shipper’s carrier account number. Refer to our article on for more details.
+ # @option opts [String] :tracking_origin_country Additional field required by some carriers to retrieve the tracking info. The origin country/region of the shipment. Refer to our article on for more details.
+ # @option opts [String] :tracking_destination_country Additional field required by some carriers to retrieve the tracking info. The destination country/region of the shipment. Refer to our article on for more details.
+ # @option opts [String] :tracking_key Additional field required by some carriers to retrieve the tracking info. A type of tracking credential required by some carriers. Refer to our article on for more details.
+ # @option opts [String] :tracking_postal_code Additional field required by some carriers to retrieve the tracking info. The postal code of the recipient’s address. Refer to our article on for more details.
+ # @option opts [String] :tracking_ship_date Additional field required by some carriers to retrieve the tracking info. The date the shipment was sent, using the format YYYYMMDD. Refer to our article on for more details.
+ # @option opts [String] :tracking_state Additional field required by some carriers to retrieve the tracking info. The state/province of the recipient’s address. Refer to our article on for more details.
+ # @return [Model::PartialUpdateTracking]
+ def retrack_tracking_by_slug_tracking_number(slug:, tracking_number:, opts: {})
+ data, _status_code, _headers = retrack_tracking_by_slug_tracking_number_with_http_info(slug: slug, tracking_number: tracking_number, opts: opts)
+ data
+ end
+
+ def retrack_tracking_by_slug_tracking_number_with_http_info(slug:, tracking_number:, opts: {})
+ if @api_client.config.debugging
+ @api_client.config.logger.debug 'Calling API: TrackingApi.retrack_tracking_by_slug_tracking_number ...'
+ end
+
+ if slug.nil? || (slug.to_s == '')
+ raise InvalidParamError.new "slug cannot be nil or empty"
+ end
+ if tracking_number.nil? || (tracking_number.to_s == '')
+ raise InvalidParamError.new "tracking_number cannot be nil or empty"
+ end
+
+
+ # resource path
+ local_var_path = "/tracking/2024-04/trackings/#{slug}/#{tracking_number}/retrack"
+ method = :'POST'
+
+ # query parameters
+ query_params = opts[:query_params] || {}
+ query_params[:'tracking_account_number'] = opts[:'tracking_account_number'] if !opts[:'tracking_account_number'].nil?
+ query_params[:'tracking_origin_country'] = opts[:'tracking_origin_country'] if !opts[:'tracking_origin_country'].nil?
+ query_params[:'tracking_destination_country'] = opts[:'tracking_destination_country'] if !opts[:'tracking_destination_country'].nil?
+ query_params[:'tracking_key'] = opts[:'tracking_key'] if !opts[:'tracking_key'].nil?
+ query_params[:'tracking_postal_code'] = opts[:'tracking_postal_code'] if !opts[:'tracking_postal_code'].nil?
+ query_params[:'tracking_ship_date'] = opts[:'tracking_ship_date'] if !opts[:'tracking_ship_date'].nil?
+ query_params[:'tracking_state'] = opts[:'tracking_state'] if !opts[:'tracking_state'].nil?
+ # header parameters
+ header_params = opts[:header_params] || {}
+
+ # http body (model)
+ post_body = opts[:body]
+
+ # return_type
+ return_type = 'PartialUpdateTracking'
+
+ new_options = opts.merge(
+ :operation => :"TrackingApi.retrack_tracking_by_slug_tracking_number",
+ :header_params => header_params,
+ :query_params => query_params,
+ :body => post_body,
+ :return_type => return_type,
+ :response_legacy_tag => "tracking",
+ :is_paging => false
+ )
+
+ data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
+ if @api_client.config.debugging
+ @api_client.config.logger.debug "API called: TrackingApi#retrack_tracking_by_slug_tracking_number\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
+ end
+ return data, status_code, headers
+ end
+
+ # update_tracking_by_id
+ # Update a tracking.
+ # @param id [String] tracking ID
+
+ # @param body [Model::TrackingUpdateTrackingByIdRequest]
+ # @param [Hash] opts the optional parameters
+ # @return [Model::Tracking]
+ def update_tracking_by_id(id:, body:, opts: {})
+ if "tracking" != ""
+ body = { :'tracking' => body }
+ end
+ opts[:body] = body
+ data, _status_code, _headers = update_tracking_by_id_with_http_info(id: id, opts: opts)
+ data
+ end
+
+ def update_tracking_by_id_with_http_info(id:, opts: {})
+ if @api_client.config.debugging
+ @api_client.config.logger.debug 'Calling API: TrackingApi.update_tracking_by_id ...'
+ end
+
+ if id.nil? || (id.to_s == '')
+ raise InvalidParamError.new "id cannot be nil or empty"
+ end
+
+
+ # resource path
+ local_var_path = "/tracking/2024-04/trackings/#{id}"
+ method = :'PUT'
+
+ # query parameters
+ query_params = opts[:query_params] || {}
+ # header parameters
+ header_params = opts[:header_params] || {}
+
+ # http body (model)
+ post_body = opts[:body]
+
+ # return_type
+ return_type = 'Tracking'
+
+ new_options = opts.merge(
+ :operation => :"TrackingApi.update_tracking_by_id",
+ :header_params => header_params,
+ :query_params => query_params,
+ :body => post_body,
+ :return_type => return_type,
+ :response_legacy_tag => "tracking",
+ :is_paging => false
+ )
+
+ data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
+ if @api_client.config.debugging
+ @api_client.config.logger.debug "API called: TrackingApi#update_tracking_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
+ end
+ return data, status_code, headers
+ end
+
+ # update_tracking_by_slug_tracking_number
+ # Update a tracking.
+ # @param slug [String] Tracking slug
+ # @param tracking_number [String] Tracking number
+
+ # @param body [Model::TrackingUpdateTrackingBySlugTrackingNumberRequest]
+ # @param [Hash] opts the optional parameters
+ # @option opts [String] :tracking_account_number Additional field required by some carriers to retrieve the tracking info. The shipper’s carrier account number. Refer to our article on for more details.
+ # @option opts [String] :tracking_origin_country Additional field required by some carriers to retrieve the tracking info. The origin country/region of the shipment. Refer to our article on for more details.
+ # @option opts [String] :tracking_destination_country Additional field required by some carriers to retrieve the tracking info. The destination country/region of the shipment. Refer to our article on for more details.
+ # @option opts [String] :tracking_key Additional field required by some carriers to retrieve the tracking info. A type of tracking credential required by some carriers. Refer to our article on for more details.
+ # @option opts [String] :tracking_postal_code Additional field required by some carriers to retrieve the tracking info. The postal code of the recipient’s address. Refer to our article on for more details.
+ # @option opts [String] :tracking_ship_date Additional field required by some carriers to retrieve the tracking info. The date the shipment was sent, using the format YYYYMMDD. Refer to our article on for more details.
+ # @option opts [String] :tracking_state Additional field required by some carriers to retrieve the tracking info. The state/province of the recipient’s address. Refer to our article on for more details.
+ # @return [Model::Tracking]
+ def update_tracking_by_slug_tracking_number(slug:, tracking_number:, body:, opts: {})
+ if "tracking" != ""
+ body = { :'tracking' => body }
+ end
+ opts[:body] = body
+ data, _status_code, _headers = update_tracking_by_slug_tracking_number_with_http_info(slug: slug, tracking_number: tracking_number, opts: opts)
+ data
+ end
+
+ def update_tracking_by_slug_tracking_number_with_http_info(slug:, tracking_number:, opts: {})
+ if @api_client.config.debugging
+ @api_client.config.logger.debug 'Calling API: TrackingApi.update_tracking_by_slug_tracking_number ...'
+ end
+
+ if slug.nil? || (slug.to_s == '')
+ raise InvalidParamError.new "slug cannot be nil or empty"
+ end
+ if tracking_number.nil? || (tracking_number.to_s == '')
+ raise InvalidParamError.new "tracking_number cannot be nil or empty"
+ end
+
+
+ # resource path
+ local_var_path = "/tracking/2024-04/trackings/#{slug}/#{tracking_number}"
+ method = :'PUT'
+
+ # query parameters
+ query_params = opts[:query_params] || {}
+ query_params[:'tracking_account_number'] = opts[:'tracking_account_number'] if !opts[:'tracking_account_number'].nil?
+ query_params[:'tracking_origin_country'] = opts[:'tracking_origin_country'] if !opts[:'tracking_origin_country'].nil?
+ query_params[:'tracking_destination_country'] = opts[:'tracking_destination_country'] if !opts[:'tracking_destination_country'].nil?
+ query_params[:'tracking_key'] = opts[:'tracking_key'] if !opts[:'tracking_key'].nil?
+ query_params[:'tracking_postal_code'] = opts[:'tracking_postal_code'] if !opts[:'tracking_postal_code'].nil?
+ query_params[:'tracking_ship_date'] = opts[:'tracking_ship_date'] if !opts[:'tracking_ship_date'].nil?
+ query_params[:'tracking_state'] = opts[:'tracking_state'] if !opts[:'tracking_state'].nil?
+ # header parameters
+ header_params = opts[:header_params] || {}
+
+ # http body (model)
+ post_body = opts[:body]
+
+ # return_type
+ return_type = 'Tracking'
+
+ new_options = opts.merge(
+ :operation => :"TrackingApi.update_tracking_by_slug_tracking_number",
+ :header_params => header_params,
+ :query_params => query_params,
+ :body => post_body,
+ :return_type => return_type,
+ :response_legacy_tag => "tracking",
+ :is_paging => false
+ )
+
+ data, status_code, headers = @api_client.call_api(method, local_var_path, new_options)
+ if @api_client.config.debugging
+ @api_client.config.logger.debug "API called: TrackingApi#update_tracking_by_slug_tracking_number\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
+ end
+ return data, status_code, headers
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/api_client.rb b/lib/aftership-tracking-sdk/api_client.rb
new file mode 100644
index 0000000..b1672b8
--- /dev/null
+++ b/lib/aftership-tracking-sdk/api_client.rb
@@ -0,0 +1,426 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+require 'json'
+require 'logger'
+require 'tempfile'
+require 'time'
+require 'typhoeus'
+
+module AftershipAPI
+ class ApiClient
+ BASE_DELAY_SECONDS = 3
+
+ # The Configuration object holding settings to be used in the API client.
+ attr_accessor :config
+
+ # Defines the headers to be used in HTTP requests of all API calls by default.
+ #
+ # @return [Hash]
+ attr_accessor :default_headers
+
+ # Initializes the ApiClient
+ # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
+ def initialize(config = Configuration.default)
+ @config = config
+ @user_agent = config.user_agent
+ @aftership_client = config.aftership_client
+ @default_headers = @config.headers.merge({
+ 'Content-Type' => 'application/json',
+ 'User-Agent' => @user_agent,
+ 'aftership-client' => @aftership_client
+ })
+ end
+
+ def self.default
+ @@default ||= ApiClient.new
+ end
+
+ # Call an API with given options.
+ #
+ # @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
+ # the data deserialized from response body (may be a Tempfile or nil), response status code and response headers.
+ def call_api(http_method, path, opts = {})
+ retries = @config.max_retry || 0
+ begin
+ call_api_internal(http_method, path, opts)
+ rescue ApiError => e
+ if retries > 0 && (e.error_code == AftershipAPI::TIMED_OUT || e.status_code >= 500)
+ retries -= 1
+ delay_with_jitter
+ retry
+ else
+ raise e
+ end
+ end
+ end
+
+ # base delay is 3 seconds
+ def delay_with_jitter
+ delay = rand((BASE_DELAY_SECONDS / 2.0)..(BASE_DELAY_SECONDS * 2.0))
+ sleep delay
+ end
+
+ def call_api_internal(http_method, path, opts = {})
+ request = build_request(http_method, path, opts)
+ tempfile = download_file(request) if opts[:return_type] == 'File'
+ response = request.run
+
+ raise ApiError.new(:error_code => AftershipAPI::TIMED_OUT, :status_code => 0, :message => 'No response received') if response.timed_out?
+
+ if @config.debugging
+ @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
+ end
+
+ unless response.success?
+ if response.timed_out?
+ fail ApiError.new(:error_code => AftershipAPI::TIMED_OUT, :message => 'Request timed out!')
+ elsif response.code == 0
+ # Errors from libcurl will be made visible here
+ fail ApiError.new(:status_code => 0,
+ :message => response.return_message)
+ else
+ fail ApiError.new(:status_code => response.code,
+ :response_headers => response.headers,
+ :response_body => response.body),
+ response.status_message
+ end
+ end
+
+ if opts[:return_type] == 'File'
+ data = tempfile
+ elsif opts[:return_type]
+ data = deserialize(response, opts[:return_type], opts[:response_legacy_tag], opts[:is_paging])
+ else
+ data = nil
+ end
+ return data, response.code, response.headers
+ end
+
+ # Builds the HTTP request
+ #
+ # @param [String] http_method HTTP method/verb (e.g. POST)
+ # @param [String] path URL path (e.g. /account/new)
+ # @option opts [Hash] :header_params Header parameters
+ # @option opts [Hash] :query_params Query parameters
+ # @option opts [Hash] :form_params Query parameters
+ # @option opts [Object] :body HTTP body (JSON/XML)
+ # @return [Typhoeus::Request] A Typhoeus Request
+ def build_request(http_method, path, opts = {})
+ url = build_request_url(path, opts)
+ http_method = http_method.to_sym.downcase
+
+ header_params = @default_headers.merge(opts[:header_params] || {}).merge({ 'as-api-key' => config.as_api_key })
+ query_params = opts[:query_params] || {}
+ form_params = opts[:form_params] || {}
+ follow_location = opts[:follow_location] || true
+
+ header_params['date'] = Time.now.httpdate
+
+ req_opts = {
+ :method => http_method,
+ :headers => header_params,
+ :params => query_params,
+ :timeout => @config.timeout,
+ :verbose => @config.debugging,
+ :followlocation => follow_location,
+ :proxy => @config.proxy
+ }
+
+ if [:post, :patch, :put, :delete].include?(http_method)
+ req_body = build_request_body(header_params, form_params, opts[:body])
+ req_opts.update :body => req_body
+ if req_body.to_s.size == 0
+ req_opts[:headers]['Content-Type'] = ''
+ end
+ if @config.debugging
+ @config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
+ end
+ end
+
+ if @config.authentication_type == AUTHENTICATION_TYPE_AES || @config.authentication_type == AUTHENTICATION_TYPE_RSA
+ signature_header = @config.authentication_type == AUTHENTICATION_TYPE_AES ? "as-signature-hmac-sha256" : "as-signature-rsa-sha256"
+ req_opts[:headers][signature_header] = SignString.sign({
+ 'method' => http_method,
+ 'headers' => req_opts[:headers],
+ 'body' => req_opts[:body] || '',
+ 'content_type' => header_params['Content-Type'],
+ 'date' => header_params['date'],
+ 'url' => url,
+ 'query' => query_params,
+ 'auth_type' => @config.authentication_type,
+ 'secret' => @config.as_api_secret
+ })
+ end
+
+ Typhoeus::Request.new(url, req_opts)
+ end
+
+ # Builds the HTTP request body
+ #
+ # @param [Hash] header_params Header parameters
+ # @param [Hash] form_params Query parameters
+ # @param [Object] body HTTP body (JSON/XML)
+ # @return [String] HTTP body data in the form of string
+ def build_request_body(header_params, form_params, body)
+ # http form
+ if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
+ header_params['Content-Type'] == 'multipart/form-data'
+ data = {}
+ form_params.each do |key, value|
+ case value
+ when ::File, ::Array, nil
+ # let typhoeus handle File, Array and nil parameters
+ data[key] = value
+ else
+ data[key] = value.to_s
+ end
+ end
+ elsif body
+ data = body.is_a?(String) ? body : body.to_json
+ else
+ data = nil
+ end
+ data
+ end
+
+ # Save response body into a file in (the defined) temporary folder, using the filename
+ # from the "Content-Disposition" header if provided, otherwise a random filename.
+ # The response body is written to the file in chunks in order to handle files which
+ # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
+ # process can use.
+ #
+ # @see Configuration#temp_folder_path
+ #
+ # @return [Tempfile] the tempfile generated
+ def download_file(request)
+ tempfile = nil
+ encoding = nil
+ request.on_headers do |response|
+ content_disposition = response.headers['Content-Disposition']
+ if content_disposition && content_disposition =~ /filename=/i
+ filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
+ prefix = sanitize_filename(filename)
+ else
+ prefix = 'download-'
+ end
+ prefix = prefix + '-' unless prefix.end_with?('-')
+ encoding = response.body.encoding
+ tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
+ end
+ request.on_body do |chunk|
+ chunk.force_encoding(encoding)
+ tempfile.write(chunk)
+ end
+ # run the request to ensure the tempfile is created successfully before returning it
+ request.run
+ if tempfile
+ tempfile.close
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
+ "explicitly with `tempfile.delete`"
+ else
+ fail ApiError.new("Failed to create the tempfile based on the HTTP response from the server: #{request.inspect}")
+ end
+
+ tempfile
+ end
+
+ # Check if the given MIME is a JSON MIME.
+ # JSON MIME examples:
+ # application/json
+ # application/json; charset=UTF8
+ # APPLICATION/JSON
+ # */*
+ # @param [String] mime MIME
+ # @return [Boolean] True if the MIME is application/json
+ def json_mime?(mime)
+ (mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
+ end
+
+ # Deserialize the response to the given return type.
+ #
+ # @param [Response] response HTTP response
+ # @param [String] return_type some examples: "User", "Array", "Hash"
+ # @param [String] response_legacy_tag {tracking: Tracking{}} where response_legacy_tag is "tracking"
+ # @param [Boolean] is_paging
+ def deserialize(response, return_type, response_legacy_tag, is_paging)
+ body = response.body
+ return nil if body.nil? || body.empty?
+
+ # return response body directly for String return type
+ return body.to_s if return_type == 'String'
+
+ # ensuring a default content type
+ content_type = response.headers['Content-Type'] || 'application/json'
+
+ fail "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)
+
+ begin
+ data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
+ rescue JSON::ParserError => e
+ if %w(String Date Time).include?(return_type)
+ data = body
+ else
+ raise e
+ end
+ end
+
+ convert_to_type handle_data(response_legacy_tag, is_paging, data), return_type
+ end
+
+ def handle_data(response_legacy_tag, is_paging, data)
+ if response_legacy_tag.to_s != "" && !is_paging
+ return data[:data][response_legacy_tag.to_sym]
+ end
+
+ if response_legacy_tag.to_s != "" && is_paging
+ pagination = {
+ page: data[:data][:page],
+ limit: data[:data][:limit],
+ has_next_page: data[:data][:has_next_page],
+ }
+
+ total = data[:data][:total]
+ total = data[:data][:count] if total.nil?
+ pagination[:total] = total
+ return {
+ pagination: pagination,
+ response_legacy_tag.to_sym => data[:data][response_legacy_tag.to_sym]
+ }
+ end
+
+ data[:data]
+ end
+
+ # Convert data to the given return type.
+ # @param [Object] data Data to be converted
+ # @param [String] return_type Return type
+ # @return [Mixed] Data in a particular type
+ def convert_to_type(data, return_type)
+ return nil if data.nil?
+ case return_type
+ when 'String'
+ data.to_s
+ when 'Integer'
+ data.to_i
+ when 'Float'
+ data.to_f
+ when 'Boolean'
+ data == true
+ when 'Time'
+ # parse date time (expecting ISO 8601 format)
+ Time.parse data
+ when 'Date'
+ # parse date time (expecting ISO 8601 format)
+ Date.parse data
+ when 'Object'
+ # generic object (usually a Hash), return directly
+ data
+ when /\AArray<(.+)>\z/
+ # e.g. Array
+ sub_type = $1
+ data.map { |item| convert_to_type(item, sub_type) }
+ when /\AHash\\z/
+ # e.g. Hash
+ sub_type = $1
+ {}.tap do |hash|
+ data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
+ end
+ else
+ # models (e.g. Pet) or oneOf
+ klass = AftershipAPI::Model.const_get(return_type)
+ klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
+ end
+ end
+
+ # Sanitize filename by removing path.
+ # e.g. ../../sun.gif becomes sun.gif
+ #
+ # @param [String] filename the filename to be sanitized
+ # @return [String] the sanitized filename
+ def sanitize_filename(filename)
+ filename.gsub(/.*[\/\\]/, '')
+ end
+
+ def build_request_url(path, opts = {})
+ # Add leading and trailing slashes to path
+ path = "/#{path}".gsub(/\/+/, '/')
+ @config.domain + path
+ end
+
+ # Sets user agent in HTTP header
+ #
+ # @param [String] user_agent User agent (e.g. openapi-generator/ruby/1.0.0)
+ def user_agent=(user_agent)
+ @user_agent = user_agent
+ @default_headers['User-Agent'] = @user_agent
+ end
+
+ # Return Accept header based on an array of accepts provided.
+ # @param [Array] accepts array for Accept
+ # @return [String] the Accept header (e.g. application/json)
+ def select_header_accept(accepts)
+ return nil if accepts.nil? || accepts.empty?
+ # use JSON when present, otherwise use all of the provided
+ json_accept = accepts.find { |s| json_mime?(s) }
+ json_accept || accepts.join(',')
+ end
+
+ # Return Content-Type header based on an array of content types provided.
+ # @param [Array] content_types array for Content-Type
+ # @return [String] the Content-Type header (e.g. application/json)
+ def select_header_content_type(content_types)
+ # return nil by default
+ return if content_types.nil? || content_types.empty?
+ # use JSON when present, otherwise use the first one
+ json_content_type = content_types.find { |s| json_mime?(s) }
+ json_content_type || content_types.first
+ end
+
+ # Convert object (array, hash, object, etc) to JSON string.
+ # @param [Object] model object to be converted into JSON string
+ # @return [String] JSON string representation of the object
+ def object_to_http_body(model)
+ return model if model.nil? || model.is_a?(String)
+ local_body = nil
+ if model.is_a?(Array)
+ local_body = model.map { |m| object_to_hash(m) }
+ else
+ local_body = object_to_hash(model)
+ end
+ local_body.to_json
+ end
+
+ # Convert object(non-array) to hash.
+ # @param [Object] obj object to be converted into JSON string
+ # @return [String] JSON string representation of the object
+ def object_to_hash(obj)
+ if obj.respond_to?(:to_hash)
+ obj.to_hash
+ else
+ obj
+ end
+ end
+
+ # Build parameter value according to the given collection format.
+ # @param [String] collection_format one of :csv, :ssv, :tsv, :pipes and :multi
+ def build_collection_param(param, collection_format)
+ case collection_format
+ when :csv
+ param.join(',')
+ when :ssv
+ param.join(' ')
+ when :tsv
+ param.join("\t")
+ when :pipes
+ param.join('|')
+ when :multi
+ # return the array directly as typhoeus will handle it as expected
+ param
+ else
+ fail "unknown collection format: #{collection_format.inspect}"
+ end
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/configuration.rb b/lib/aftership-tracking-sdk/configuration.rb
new file mode 100644
index 0000000..45904e6
--- /dev/null
+++ b/lib/aftership-tracking-sdk/configuration.rb
@@ -0,0 +1,122 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+require 'uri'
+require 'typhoeus'
+
+module AftershipAPI
+ AUTHENTICATION_TYPE_API_KEY = 'API_KEY'
+ AUTHENTICATION_TYPE_AES = 'AES'
+ AUTHENTICATION_TYPE_RSA = 'RSA'
+
+ SDK_PREFIX = 'AFTERSHIP_TRACKING_SDK'
+
+
+ class Configuration
+ def get_env(key)
+ ENV[SDK_PREFIX + '_' + key]
+ end
+
+ # Defines domain
+ attr_accessor :domain
+
+ # Defines the authentication type used in the API.
+ #
+ # @return ["API_KEY", "AES", "RSA"]
+ attr_accessor :authentication_type
+
+ # Defines API keys used with API Key authentications.
+ #
+ # @return [string]
+ attr_accessor :as_api_key
+
+ # Defines AES secret or RSA private key used with AES or RSA authentications.
+ #
+ # @return [string]
+ attr_accessor :as_api_secret
+
+ # Defines the user agent used in the API requests.
+ # Default to 'aftership-sdk-ruby/$VERSION'
+ #
+ # @return [string]
+ attr_accessor :user_agent
+
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
+ # details will be logged with `logger.debug` (see the `logger` attribute).
+ # Default to false.
+ #
+ # @return [true, false]
+ attr_accessor :debugging
+
+ # Defines the logger used for debugging.
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
+ #
+ # @return [#debug]
+ attr_accessor :logger
+
+ # The time limit for HTTP request in seconds.
+ # Default to 30
+ attr_accessor :timeout
+
+ # When response is a retryable error, retry current request
+ # Default to 2
+ attr_accessor :max_retry
+
+ # HTTP proxy
+ attr_accessor :proxy
+
+ attr_accessor :aftership_client
+
+ attr_accessor :headers
+
+
+ def initialize
+ default_user_agent = "aftership-sdk-ruby/#{AftershipAPI::VERSION} (https://www.aftership.com) typhoeus/#{Typhoeus::VERSION}"
+
+ @domain = get_env('DOMAIN') || 'https://api.aftership.com'
+ @authentication_type = get_env('AUTHENTICATION_TYPE') || AUTHENTICATION_TYPE_API_KEY
+ @as_api_key = get_env('API_KEY') || ''
+ @as_api_secret = get_env('API_SECRET') || ''
+ @user_agent = get_env('USER_AGENT') || default_user_agent
+ @aftership_client = default_user_agent
+ @timeout = (get_env('TIMEOUT') || 30).to_i
+ @max_retry = (get_env('MAX_RETRY') || 2).to_i
+ @proxy = get_env('PROXY')
+ @debugging = get_env('DEBUGGING') || false
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
+ @headers = {}
+
+ yield(self) if block_given?
+ end
+
+ # The default Configuration object.
+ def self.default
+ @@default ||= Configuration.new
+ end
+
+ def configure
+ yield(self) if block_given?
+ end
+
+ def domain=(domain)
+ @domain = domain.sub(/\/+\z/, '')
+ end
+
+ def check
+ fail InvalidOptionError.new("Invalid authentication type: #{authentication_type}") unless [AUTHENTICATION_TYPE_API_KEY, AUTHENTICATION_TYPE_AES, AUTHENTICATION_TYPE_RSA].include?(authentication_type)
+ fail InvalidOptionError.new("as_api_key cannot be empty") unless as_api_key.to_s.size > 0
+ fail InvalidOptionError.new("Invalid base URL: #{domain}") unless valid_url?(domain)
+ fail InvalidOptionError.new("authentication type must not be API_KEY if as_api_secret is set") if as_api_secret.to_s.size > 0 && authentication_type == AUTHENTICATION_TYPE_API_KEY
+ fail InvalidOptionError.new("timeout cannot be negative, value #{timeout}") unless timeout.to_i >= 0
+ fail InvalidOptionError.new("max_retry must be in range 0..10, value #{max_retry}") unless (max_retry.to_i >= 0) && (max_retry.to_i <= 10)
+ fail InvalidOptionError.new("max_retry cannot be negative, value #{max_retry}") unless max_retry.to_i >= 0
+ end
+
+ def valid_url?(url)
+ uri = URI.parse(url)
+ uri.is_a?(URI::HTTP) || uri.is_a?(URI::HTTPS)
+ rescue URI::InvalidURIError
+ false
+ end
+ end
+end
+
\ No newline at end of file
diff --git a/lib/aftership-tracking-sdk/error.rb b/lib/aftership-tracking-sdk/error.rb
new file mode 100644
index 0000000..ea1f9c1
--- /dev/null
+++ b/lib/aftership-tracking-sdk/error.rb
@@ -0,0 +1,125 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+require 'json'
+
+module AftershipAPI
+ REQUEST_ERROR = 'REQUEST_ERROR'
+
+ # Common AfterShipError
+ INVALID_API_KEY = 'INVALID_API_KEY'.freeze
+ INVALID_OPTION = 'INVALID_OPTION'.freeze
+ RATE_LIMIT_EXCEEDED = 'RATE_LIMIT_EXCEEDED'.freeze
+ TIMED_OUT = "TIMED_OUT".freeze
+
+ INVALID_REQUEST = "INVALID_REQUEST".freeze
+ INVALID_JSON = "INVALID_JSON".freeze
+ TRACKING_ALREADY_EXIST = "TRACKING_ALREADY_EXIST".freeze
+ TRACKING_DOES_NOT_EXIST = "TRACKING_DOES_NOT_EXIST".freeze
+ TRACKING_NUMBER_INVALID = "TRACKING_NUMBER_INVALID".freeze
+ TRACKING_REQUIRED = "TRACKING_REQUIRED".freeze
+ TRACKING_NUMBER_REQUIRED = "TRACKING_NUMBER_REQUIRED".freeze
+ VALUE_INVALID = "VALUE_INVALID".freeze
+ VALUE_REQUIRED = "VALUE_REQUIRED".freeze
+ SLUG_INVALID = "SLUG_INVALID".freeze
+ MISSING_OR_INVALID_REQUIRED_FIELD = "MISSING_OR_INVALID_REQUIRED_FIELD".freeze
+ BAD_COURIER = "BAD_COURIER".freeze
+ INACTIVE_RETRACK_NOT_ALLOWED = "INACTIVE_RETRACK_NOT_ALLOWED".freeze
+ NOTIFICATION_REUQIRED = "NOTIFICATION_REUQIRED".freeze
+ ID_INVALID = "ID_INVALID".freeze
+ RETRACK_ONCE_ALLOWED = "RETRACK_ONCE_ALLOWED".freeze
+ TRACKING_NUMBER_FORMAT_INVALID = "TRACKING_NUMBER_FORMAT_INVALID".freeze
+ API_KEY_INVALID = "API_KEY_INVALID".freeze
+ REQUEST_NOT_ALLOWED = "REQUEST_NOT_ALLOWED".freeze
+ NOT_FOUND = "NOT_FOUND".freeze
+ TOO_MANY_REQUEST = "TOO_MANY_REQUEST".freeze
+ INTERNAL_ERROR = "INTERNAL_ERROR".freeze
+
+ ERROR_MAP = {
+ # Format: metaCode => ErrorCode
+ 400 => INVALID_REQUEST,
+ 4001 => INVALID_JSON,
+ 4003 => TRACKING_ALREADY_EXIST,
+ 4004 => TRACKING_DOES_NOT_EXIST,
+ 4005 => TRACKING_NUMBER_INVALID,
+ 4006 => TRACKING_REQUIRED,
+ 4007 => TRACKING_NUMBER_REQUIRED,
+ 4008 => VALUE_INVALID,
+ 4009 => VALUE_REQUIRED,
+ 4010 => SLUG_INVALID,
+ 4011 => MISSING_OR_INVALID_REQUIRED_FIELD,
+ 4012 => BAD_COURIER,
+ 4013 => INACTIVE_RETRACK_NOT_ALLOWED,
+ 4014 => NOTIFICATION_REUQIRED,
+ 4015 => ID_INVALID,
+ 4016 => RETRACK_ONCE_ALLOWED,
+ 4017 => TRACKING_NUMBER_FORMAT_INVALID,
+ 401 => API_KEY_INVALID,
+ 403 => REQUEST_NOT_ALLOWED,
+ 404 => NOT_FOUND,
+ 429 => TOO_MANY_REQUEST,
+ 500 => INTERNAL_ERROR,
+ 502 => INTERNAL_ERROR,
+ 503 => INTERNAL_ERROR,
+ 504 => INTERNAL_ERROR,
+ }
+
+
+ class ApiError < StandardError
+ attr_reader :status_code, :response_headers, :response_body, :meta_code, :error_code
+
+ # Usage examples:
+ # ApiError.new
+ # ApiError.new("message")
+ # ApiError.new(:status_code => 500, :response_headers => {}, :response_body => "")
+ # ApiError.new(:status_code => 404, :message => "Not Found")
+ def initialize(arg = nil)
+ if arg.is_a? Hash
+ if arg.key?(:message) || arg.key?('message')
+ super(arg[:message] || arg['message'])
+ else
+ super arg
+ end
+
+ response_body = JSON.parse(arg[:response_body], :symbolize_names => true) rescue nil
+ @message = REQUEST_ERROR
+ if response_body && response_body[:meta] && response_body[:meta][:code]
+ @meta_code = response_body[:meta][:code]
+ @error_code = ERROR_MAP[@meta_code] || REQUEST_ERROR
+ @message = response_body[:meta][:message] || REQUEST_ERROR
+ end
+ arg.each do |k, v|
+ instance_variable_set "@#{k}", v
+ end
+ else
+ super arg
+ @message = arg
+ end
+ end
+
+ # Override to_s to display a friendly error message
+ def to_s
+ message
+ end
+
+ def message
+ if @message.nil?
+ msg = "Error message: the server returns an error"
+ else
+ msg = @message
+ end
+
+ msg += "\nHTTP status code: #{status_code}" if status_code
+ msg += "\nError Code #{error_code}" if error_code
+ msg += "\nResponse headers: #{response_headers}" if response_headers
+ msg += "\nResponse body: #{response_body}" if response_body
+
+ msg
+ end
+ end
+
+ class InvalidOptionError < StandardError
+ end
+
+ class InvalidParamError < StandardError
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/additional_fields_v1.rb b/lib/aftership-tracking-sdk/models/additional_fields_v1.rb
new file mode 100644
index 0000000..aaaa947
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/additional_fields_v1.rb
@@ -0,0 +1,32 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+
+module AftershipAPI::Model
+ class AdditionalFieldsV1
+ TRACKING_ACCOUNT_NUMBER = "tracking_account_number".freeze
+ TRACKING_POSTAL_CODE = "tracking_postal_code".freeze
+ TRACKING_SHIP_DATE = "tracking_ship_date".freeze
+ TRACKING_KEY = "tracking_key".freeze
+ TRACKING_ORIGIN_COUNTRY = "tracking_origin_country".freeze
+ TRACKING_DESTINATION_COUNTRY = "tracking_destination_country".freeze
+ TRACKING_STATE = "tracking_state".freeze
+ def self.all_vars
+ @all_vars ||= [TRACKING_ACCOUNT_NUMBER, TRACKING_POSTAL_CODE, TRACKING_SHIP_DATE, TRACKING_KEY, TRACKING_ORIGIN_COUNTRY, TRACKING_DESTINATION_COUNTRY, TRACKING_STATE,].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 AdditionalFieldsV1.all_vars.include?(value)
+ raise "Invalid ENUM value #{value} for class #AdditionalFieldsV1"
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_tracking.rb b/lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_tracking.rb
new file mode 100644
index 0000000..84fea14
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_tracking.rb
@@ -0,0 +1,181 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class AftershipEstimatedDeliveryDateTracking
+ # The estimated arrival date of the shipment.
+ # estimated_delivery_date?: String;
+ attr_accessor :estimated_delivery_date
+
+ # Indicates the confidence level and associated reason for an AI EDD prediction request. For a comprehensive list of confidence codes, refer to .
+ # confidence_code?: Float;
+ attr_accessor :confidence_code
+
+ # Earliest estimated delivery date of the shipment.
+ # estimated_delivery_date_min?: String;
+ attr_accessor :estimated_delivery_date_min
+
+ # Latest estimated delivery date of the shipment.
+ # estimated_delivery_date_max?: String;
+ attr_accessor :estimated_delivery_date_max
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::AftershipEstimatedDeliveryDateTracking` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'estimated_delivery_date')
+ self.estimated_delivery_date = attributes[:'estimated_delivery_date']
+ end
+
+ if attributes.key?(:'confidence_code')
+ self.confidence_code = attributes[:'confidence_code']
+ end
+
+ if attributes.key?(:'estimated_delivery_date_min')
+ self.estimated_delivery_date_min = attributes[:'estimated_delivery_date_min']
+ end
+
+ if attributes.key?(:'estimated_delivery_date_max')
+ self.estimated_delivery_date_max = attributes[:'estimated_delivery_date_max']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'estimated_delivery_date' => :'String',
+ :'confidence_code' => :'Float',
+ :'estimated_delivery_date_min' => :'String',
+ :'estimated_delivery_date_max' => :'String',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'estimated_delivery_date' => :'estimated_delivery_date',
+ :'confidence_code' => :'confidence_code',
+ :'estimated_delivery_date_min' => :'estimated_delivery_date_min',
+ :'estimated_delivery_date_max' => :'estimated_delivery_date_max',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/carbon_emissions_tracking.rb b/lib/aftership-tracking-sdk/models/carbon_emissions_tracking.rb
new file mode 100644
index 0000000..b64d5ef
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/carbon_emissions_tracking.rb
@@ -0,0 +1,161 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class CarbonEmissionsTracking
+ # The unit in which the value field is expressed. Allowed values: kg
+ # unit?: String;
+ attr_accessor :unit
+
+ # The total amount of carbon emissions
+ # value?: Float;
+ attr_accessor :value
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::CarbonEmissionsTracking` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'unit')
+ self.unit = attributes[:'unit']
+ end
+
+ if attributes.key?(:'value')
+ self.value = attributes[:'value']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'unit' => :'String',
+ :'value' => :'Float',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'unit' => :'unit',
+ :'value' => :'value',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/checkpoint.rb b/lib/aftership-tracking-sdk/models/checkpoint.rb
new file mode 100644
index 0000000..afed933
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/checkpoint.rb
@@ -0,0 +1,301 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class Checkpoint
+ # The date and time of the checkpoint event was added to AfterShip. It uses the format `YYYY-MM-DDTHH:mm:ssZ` for the timezone GMT +0.
+ # created_at?: String;
+ attr_accessor :created_at
+
+ # The unique code of courier for this checkpoint. Get courier slug
+ # slug?: String;
+ attr_accessor :slug
+
+ # The date and time of the checkpoint event, provided by the carrier. It uses the timezone of the checkpoint. The format may differ depending on how the carrier provides it:- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ
+ # checkpoint_time?: String;
+ attr_accessor :checkpoint_time
+
+ # Location info provided by carrier
+ # location?: String;
+ attr_accessor :location
+
+ # City info provided by carrier
+ # city?: String;
+ attr_accessor :city
+
+ # State info provided by carrier
+ # state?: String;
+ attr_accessor :state
+
+ # Postal code info provided by carrier
+ # zip?: String;
+ attr_accessor :zip
+
+ # The latitude and longitude coordinates indicate the precise location of the shipments that are currently in transit.
+ # coordinate?: CoordinateCheckpoint;
+ attr_accessor :coordinate
+
+ # Country/Region ISO Alpha-3 (three letters) of the checkpoint
+ # country_iso3?: String;
+ attr_accessor :country_iso3
+
+ # Country/Region name of the checkpoint, may also contain other location info.
+ # country_name?: String;
+ attr_accessor :country_name
+
+ # Checkpoint message
+ # message?: String;
+ attr_accessor :message
+
+ # Current status of tracking. (
+ # tag?: TagV1;
+ attr_accessor :tag
+
+ # Current subtag of checkpoint. (
+ # subtag?: String;
+ attr_accessor :subtag
+
+ # Normalized checkpoint message. (
+ # subtag_message?: String;
+ attr_accessor :subtag_message
+
+ # Checkpoint raw status provided by courier
+ # raw_tag?: String;
+ attr_accessor :raw_tag
+
+ # The array provides details about specific event(s) that occurred to a shipment, such as "returned_to_sender". You can find the full list of events and reasons - The events' value for the same checkpoint message is subject to change as we consistently strive to enhance the performance of this feature.
+ # events?: EventsCheckpoint[];
+ attr_accessor :events
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::Checkpoint` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'created_at')
+ self.created_at = attributes[:'created_at']
+ end
+
+ if attributes.key?(:'slug')
+ self.slug = attributes[:'slug']
+ end
+
+ if attributes.key?(:'checkpoint_time')
+ self.checkpoint_time = attributes[:'checkpoint_time']
+ end
+
+ if attributes.key?(:'location')
+ self.location = attributes[:'location']
+ end
+
+ if attributes.key?(:'city')
+ self.city = attributes[:'city']
+ end
+
+ if attributes.key?(:'state')
+ self.state = attributes[:'state']
+ end
+
+ if attributes.key?(:'zip')
+ self.zip = attributes[:'zip']
+ end
+
+ if attributes.key?(:'coordinate')
+ self.coordinate = attributes[:'coordinate']
+ end
+
+ if attributes.key?(:'country_iso3')
+ self.country_iso3 = attributes[:'country_iso3']
+ end
+
+ if attributes.key?(:'country_name')
+ self.country_name = attributes[:'country_name']
+ end
+
+ if attributes.key?(:'message')
+ self.message = attributes[:'message']
+ end
+
+ if attributes.key?(:'tag')
+ self.tag = attributes[:'tag']
+ end
+
+ if attributes.key?(:'subtag')
+ self.subtag = attributes[:'subtag']
+ end
+
+ if attributes.key?(:'subtag_message')
+ self.subtag_message = attributes[:'subtag_message']
+ end
+
+ if attributes.key?(:'raw_tag')
+ self.raw_tag = attributes[:'raw_tag']
+ end
+
+ if attributes.key?(:'events')
+ self.events = attributes[:'events']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'created_at' => :'String',
+ :'slug' => :'String',
+ :'checkpoint_time' => :'String',
+ :'location' => :'String',
+ :'city' => :'String',
+ :'state' => :'String',
+ :'zip' => :'String',
+ :'coordinate' => :'CoordinateCheckpoint',
+ :'country_iso3' => :'String',
+ :'country_name' => :'String',
+ :'message' => :'String',
+ :'tag' => :'TagV1',
+ :'subtag' => :'String',
+ :'subtag_message' => :'String',
+ :'raw_tag' => :'String',
+ :'events' => :'Array',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'created_at' => :'created_at',
+ :'slug' => :'slug',
+ :'checkpoint_time' => :'checkpoint_time',
+ :'location' => :'location',
+ :'city' => :'city',
+ :'state' => :'state',
+ :'zip' => :'zip',
+ :'coordinate' => :'coordinate',
+ :'country_iso3' => :'country_iso3',
+ :'country_name' => :'country_name',
+ :'message' => :'message',
+ :'tag' => :'tag',
+ :'subtag' => :'subtag',
+ :'subtag_message' => :'subtag_message',
+ :'raw_tag' => :'raw_tag',
+ :'events' => :'events',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/coordinate_checkpoint.rb b/lib/aftership-tracking-sdk/models/coordinate_checkpoint.rb
new file mode 100644
index 0000000..50a2f53
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/coordinate_checkpoint.rb
@@ -0,0 +1,161 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class CoordinateCheckpoint
+ # Represents the latitude.
+ # latitude?: Float;
+ attr_accessor :latitude
+
+ # Represents the longitude.
+ # longitude?: Float;
+ attr_accessor :longitude
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::CoordinateCheckpoint` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'latitude')
+ self.latitude = attributes[:'latitude']
+ end
+
+ if attributes.key?(:'longitude')
+ self.longitude = attributes[:'longitude']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'latitude' => :'Float',
+ :'longitude' => :'Float',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'latitude' => :'latitude',
+ :'longitude' => :'longitude',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/courier.rb b/lib/aftership-tracking-sdk/models/courier.rb
new file mode 100644
index 0000000..7d93048
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/courier.rb
@@ -0,0 +1,241 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class Courier
+ # Unique code of courier. Get the slugs from .
+ # slug?: String;
+ attr_accessor :slug
+
+ # Name of courier
+ # name?: String;
+ attr_accessor :name
+
+ # Contact phone number of courier
+ # phone?: String;
+ attr_accessor :phone
+
+ # Other name of courier
+ # other_name?: String;
+ attr_accessor :other_name
+
+ # Website link of courier
+ # web_url?: String;
+ attr_accessor :web_url
+
+ # The extra fields need for tracking, such as `tracking_account_number`, `tracking_postal_code`, `tracking_ship_date`, `tracking_key`, `tracking_destination_country`
+ # required_fields?: String[];
+ attr_accessor :required_fields
+
+ # The extra fields which are optional for tracking. Basically it's the same as required_fields, but the difference is that only some of the tracking numbers require these fields.
+ # optional_fields?: String[];
+ attr_accessor :optional_fields
+
+ # Default language of tracking results
+ # default_language?: String;
+ attr_accessor :default_language
+
+ # Other supported languages
+ # support_languages?: String[];
+ attr_accessor :support_languages
+
+ # Country/Region code (ISO Alpha-3) where the courier provides service
+ # service_from_country_iso3?: String[];
+ attr_accessor :service_from_country_iso3
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::Courier` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'slug')
+ self.slug = attributes[:'slug']
+ end
+
+ if attributes.key?(:'name')
+ self.name = attributes[:'name']
+ end
+
+ if attributes.key?(:'phone')
+ self.phone = attributes[:'phone']
+ end
+
+ if attributes.key?(:'other_name')
+ self.other_name = attributes[:'other_name']
+ end
+
+ if attributes.key?(:'web_url')
+ self.web_url = attributes[:'web_url']
+ end
+
+ if attributes.key?(:'required_fields')
+ self.required_fields = attributes[:'required_fields']
+ end
+
+ if attributes.key?(:'optional_fields')
+ self.optional_fields = attributes[:'optional_fields']
+ end
+
+ if attributes.key?(:'default_language')
+ self.default_language = attributes[:'default_language']
+ end
+
+ if attributes.key?(:'support_languages')
+ self.support_languages = attributes[:'support_languages']
+ end
+
+ if attributes.key?(:'service_from_country_iso3')
+ self.service_from_country_iso3 = attributes[:'service_from_country_iso3']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'slug' => :'String',
+ :'name' => :'String',
+ :'phone' => :'String',
+ :'other_name' => :'String',
+ :'web_url' => :'String',
+ :'required_fields' => :'Array',
+ :'optional_fields' => :'Array',
+ :'default_language' => :'String',
+ :'support_languages' => :'Array',
+ :'service_from_country_iso3' => :'Array',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'slug' => :'slug',
+ :'name' => :'name',
+ :'phone' => :'phone',
+ :'other_name' => :'other_name',
+ :'web_url' => :'web_url',
+ :'required_fields' => :'required_fields',
+ :'optional_fields' => :'optional_fields',
+ :'default_language' => :'default_language',
+ :'support_languages' => :'support_languages',
+ :'service_from_country_iso3' => :'service_from_country_iso3',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/courier_response_v1.rb b/lib/aftership-tracking-sdk/models/courier_response_v1.rb
new file mode 100644
index 0000000..def95ca
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/courier_response_v1.rb
@@ -0,0 +1,161 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class CourierResponseV1
+ # Meta data
+ # meta: MetaV1;
+ attr_accessor :meta
+
+ #
+ # data: DataCourierResponseV1;
+ attr_accessor :data
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::CourierResponseV1` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'meta')
+ self.meta = attributes[:'meta']
+ end
+
+ if attributes.key?(:'data')
+ self.data = attributes[:'data']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'meta' => :'MetaV1',
+ :'data' => :'DataCourierResponseV1',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'meta' => :'meta',
+ :'data' => :'data',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_tracking.rb b/lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_tracking.rb
new file mode 100644
index 0000000..b2db7bc
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_tracking.rb
@@ -0,0 +1,181 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class CustomEstimatedDeliveryDateTracking
+ # The format of the EDD. Either a single date or a date range.
+ # type?: String;
+ attr_accessor :type
+
+ # The specific EDD date.
+ # datetime?: String;
+ attr_accessor :datetime
+
+ # For a date range EDD format, the date for the lower end of the range.
+ # datetime_min?: String;
+ attr_accessor :datetime_min
+
+ # For a date range EDD format, the date for the upper end of the range.
+ # datetime_max?: String;
+ attr_accessor :datetime_max
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::CustomEstimatedDeliveryDateTracking` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'type')
+ self.type = attributes[:'type']
+ end
+
+ if attributes.key?(:'datetime')
+ self.datetime = attributes[:'datetime']
+ end
+
+ if attributes.key?(:'datetime_min')
+ self.datetime_min = attributes[:'datetime_min']
+ end
+
+ if attributes.key?(:'datetime_max')
+ self.datetime_max = attributes[:'datetime_max']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'type' => :'String',
+ :'datetime' => :'String',
+ :'datetime_min' => :'String',
+ :'datetime_max' => :'String',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'type' => :'type',
+ :'datetime' => :'datetime',
+ :'datetime_min' => :'datetime_min',
+ :'datetime_max' => :'datetime_max',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/custom_fields_tracking_update_tracking_by_slug_tracking_number_request.rb b/lib/aftership-tracking-sdk/models/custom_fields_tracking_update_tracking_by_slug_tracking_number_request.rb
new file mode 100644
index 0000000..1e72e55
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/custom_fields_tracking_update_tracking_by_slug_tracking_number_request.rb
@@ -0,0 +1,139 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class CustomFieldsTrackingUpdateTrackingBySlugTrackingNumberRequest
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::CustomFieldsTrackingUpdateTrackingBySlugTrackingNumberRequest` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {}
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {}
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/data_courier_response_v1.rb b/lib/aftership-tracking-sdk/models/data_courier_response_v1.rb
new file mode 100644
index 0000000..e4589b0
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/data_courier_response_v1.rb
@@ -0,0 +1,161 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class DataCourierResponseV1
+ # Total count of courier objects
+ # total?: Integer;
+ attr_accessor :total
+
+ # Array of object.
+ # couriers?: Courier[];
+ attr_accessor :couriers
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::DataCourierResponseV1` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'total')
+ self.total = attributes[:'total']
+ end
+
+ if attributes.key?(:'couriers')
+ self.couriers = attributes[:'couriers']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'total' => :'Integer',
+ :'couriers' => :'Array',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'total' => :'total',
+ :'couriers' => :'couriers',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/data_notification_response_v1.rb b/lib/aftership-tracking-sdk/models/data_notification_response_v1.rb
new file mode 100644
index 0000000..21e9fb5
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/data_notification_response_v1.rb
@@ -0,0 +1,151 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class DataNotificationResponseV1
+ # Object describes the notification information.
+ # notification?: Notification;
+ attr_accessor :notification
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::DataNotificationResponseV1` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'notification')
+ self.notification = attributes[:'notification']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'notification' => :'Notification',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'notification' => :'notification',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/data_tracking_delete_response_v1.rb b/lib/aftership-tracking-sdk/models/data_tracking_delete_response_v1.rb
new file mode 100644
index 0000000..d42fab1
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/data_tracking_delete_response_v1.rb
@@ -0,0 +1,151 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class DataTrackingDeleteResponseV1
+ # Partial tracking model
+ # tracking?: PartialDeleteTracking;
+ attr_accessor :tracking
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::DataTrackingDeleteResponseV1` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'tracking')
+ self.tracking = attributes[:'tracking']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'tracking' => :'PartialDeleteTracking',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'tracking' => :'tracking',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/data_tracking_response_get_multiple_v1.rb b/lib/aftership-tracking-sdk/models/data_tracking_response_get_multiple_v1.rb
new file mode 100644
index 0000000..8e1a117
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/data_tracking_response_get_multiple_v1.rb
@@ -0,0 +1,281 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class DataTrackingResponseGetMultipleV1
+ # Page to show. (Default: 1)
+ # page?: Integer;
+ attr_accessor :page
+
+ # Number of trackings each page contain. (Default: 100, Max: 200)
+ # limit?: Integer;
+ attr_accessor :limit
+
+ # Number of returned trackings
+ # count?: Integer;
+ attr_accessor :count
+
+ # Search the content of the tracking record fields: `tracking_number`, `title`, `order_id`, `customer_name`, `custom_fields`, `order_id`, `emails`, `smses`
+ # keyword?: String;
+ attr_accessor :keyword
+
+ # Unique
+ # slug?: String;
+ attr_accessor :slug
+
+ # Origin country/region of trackings. Use
+ # origin?: String[];
+ attr_accessor :origin
+
+ # Destination country/region of trackings. Use
+ # destination?: String[];
+ attr_accessor :destination
+
+ # Current status of tracking. (
+ # tag?: TagV1;
+ attr_accessor :tag
+
+ # Start date and time of trackings created. AfterShip only stores data of 120 days.
+ # created_at_min?: String;
+ attr_accessor :created_at_min
+
+ # End date and time of trackings created.
+ # created_at_max?: String;
+ attr_accessor :created_at_max
+
+ # Date and time the tracking was last updated
+ # last_updated_at?: String;
+ attr_accessor :last_updated_at
+
+ # Whether or not the shipment is returned to sender. Value is `true` when any of its checkpoints has subtag `Exception_010` (returning to sender) or `Exception_011` (returned to sender). Otherwise value is `false`
+ # return_to_sender?: Boolean[];
+ attr_accessor :return_to_sender
+
+ # Destination country/region of the tracking detected from the courier. ISO Alpha-3 (three letters). Value will be `null` if the courier doesn't provide the destination country.
+ # courier_destination_country_iso3?: String[];
+ attr_accessor :courier_destination_country_iso3
+
+ # Array of
+ # trackings?: Tracking[];
+ attr_accessor :trackings
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::DataTrackingResponseGetMultipleV1` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'page')
+ self.page = attributes[:'page']
+ end
+
+ if attributes.key?(:'limit')
+ self.limit = attributes[:'limit']
+ end
+
+ if attributes.key?(:'count')
+ self.count = attributes[:'count']
+ end
+
+ if attributes.key?(:'keyword')
+ self.keyword = attributes[:'keyword']
+ end
+
+ if attributes.key?(:'slug')
+ self.slug = attributes[:'slug']
+ end
+
+ if attributes.key?(:'origin')
+ self.origin = attributes[:'origin']
+ end
+
+ if attributes.key?(:'destination')
+ self.destination = attributes[:'destination']
+ end
+
+ if attributes.key?(:'tag')
+ self.tag = attributes[:'tag']
+ end
+
+ if attributes.key?(:'created_at_min')
+ self.created_at_min = attributes[:'created_at_min']
+ end
+
+ if attributes.key?(:'created_at_max')
+ self.created_at_max = attributes[:'created_at_max']
+ end
+
+ if attributes.key?(:'last_updated_at')
+ self.last_updated_at = attributes[:'last_updated_at']
+ end
+
+ if attributes.key?(:'return_to_sender')
+ self.return_to_sender = attributes[:'return_to_sender']
+ end
+
+ if attributes.key?(:'courier_destination_country_iso3')
+ self.courier_destination_country_iso3 = attributes[:'courier_destination_country_iso3']
+ end
+
+ if attributes.key?(:'trackings')
+ self.trackings = attributes[:'trackings']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'page' => :'Integer',
+ :'limit' => :'Integer',
+ :'count' => :'Integer',
+ :'keyword' => :'String',
+ :'slug' => :'String',
+ :'origin' => :'Array',
+ :'destination' => :'Array',
+ :'tag' => :'TagV1',
+ :'created_at_min' => :'String',
+ :'created_at_max' => :'String',
+ :'last_updated_at' => :'String',
+ :'return_to_sender' => :'Array',
+ :'courier_destination_country_iso3' => :'Array',
+ :'trackings' => :'Array',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'page' => :'page',
+ :'limit' => :'limit',
+ :'count' => :'count',
+ :'keyword' => :'keyword',
+ :'slug' => :'slug',
+ :'origin' => :'origin',
+ :'destination' => :'destination',
+ :'tag' => :'tag',
+ :'created_at_min' => :'created_at_min',
+ :'created_at_max' => :'created_at_max',
+ :'last_updated_at' => :'last_updated_at',
+ :'return_to_sender' => :'return_to_sender',
+ :'courier_destination_country_iso3' => :'courier_destination_country_iso3',
+ :'trackings' => :'trackings',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/data_tracking_response_v1.rb b/lib/aftership-tracking-sdk/models/data_tracking_response_v1.rb
new file mode 100644
index 0000000..150f9c0
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/data_tracking_response_v1.rb
@@ -0,0 +1,151 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class DataTrackingResponseV1
+ # Object describes the tracking information.
+ # tracking?: Tracking;
+ attr_accessor :tracking
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::DataTrackingResponseV1` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'tracking')
+ self.tracking = attributes[:'tracking']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'tracking' => :'Tracking',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'tracking' => :'tracking',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/destination_address_estimated_delivery_date_request.rb b/lib/aftership-tracking-sdk/models/destination_address_estimated_delivery_date_request.rb
new file mode 100644
index 0000000..1de572a
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/destination_address_estimated_delivery_date_request.rb
@@ -0,0 +1,191 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class DestinationAddressEstimatedDeliveryDateRequest
+ # The country/region of the destination location where the package will be delivered. Use 3 letters of ISO 3166-1 country code.
+ # country: String;
+ attr_accessor :country
+
+ # 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?: 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?: String;
+ attr_accessor :postal_code
+
+ # Raw location of the destination address. A raw address will help AI to identify the accurate location of the destination address.
+ # raw_location?: String;
+ attr_accessor :raw_location
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::DestinationAddressEstimatedDeliveryDateRequest` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'country')
+ self.country = attributes[:'country']
+ end
+
+ if attributes.key?(:'state')
+ self.state = attributes[:'state']
+ end
+
+ if attributes.key?(:'city')
+ self.city = attributes[:'city']
+ end
+
+ if attributes.key?(:'postal_code')
+ self.postal_code = attributes[:'postal_code']
+ end
+
+ if attributes.key?(:'raw_location')
+ self.raw_location = attributes[:'raw_location']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'country' => :'String',
+ :'state' => :'String',
+ :'city' => :'String',
+ :'postal_code' => :'String',
+ :'raw_location' => :'String',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'country' => :'country',
+ :'state' => :'state',
+ :'city' => :'city',
+ :'postal_code' => :'postal_code',
+ :'raw_location' => :'raw_location',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/destination_address_estimated_delivery_date_response.rb b/lib/aftership-tracking-sdk/models/destination_address_estimated_delivery_date_response.rb
new file mode 100644
index 0000000..589109d
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/destination_address_estimated_delivery_date_response.rb
@@ -0,0 +1,191 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class DestinationAddressEstimatedDeliveryDateResponse
+ # The country/region of the destination location where the package will be delivered. Use 3 letters of ISO 3166-1 country code.
+ # country: String;
+ attr_accessor :country
+
+ # 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?: 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?: String;
+ attr_accessor :postal_code
+
+ # Raw location of the destination address. A raw address will help AI to identify the accurate location of the destination address.
+ # raw_location?: String;
+ attr_accessor :raw_location
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::DestinationAddressEstimatedDeliveryDateResponse` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'country')
+ self.country = attributes[:'country']
+ end
+
+ if attributes.key?(:'state')
+ self.state = attributes[:'state']
+ end
+
+ if attributes.key?(:'city')
+ self.city = attributes[:'city']
+ end
+
+ if attributes.key?(:'postal_code')
+ self.postal_code = attributes[:'postal_code']
+ end
+
+ if attributes.key?(:'raw_location')
+ self.raw_location = attributes[:'raw_location']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'country' => :'String',
+ :'state' => :'String',
+ :'city' => :'String',
+ :'postal_code' => :'String',
+ :'raw_location' => :'String',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'country' => :'country',
+ :'state' => :'state',
+ :'city' => :'city',
+ :'postal_code' => :'postal_code',
+ :'raw_location' => :'raw_location',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/detect_courier_response.rb b/lib/aftership-tracking-sdk/models/detect_courier_response.rb
new file mode 100644
index 0000000..35ca09e
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/detect_courier_response.rb
@@ -0,0 +1,161 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class DetectCourierResponse
+ # Total count of courier objects
+ # total?: Integer;
+ attr_accessor :total
+
+ # Array of object.
+ # couriers?: Courier[];
+ attr_accessor :couriers
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::DetectCourierResponse` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'total')
+ self.total = attributes[:'total']
+ end
+
+ if attributes.key?(:'couriers')
+ self.couriers = attributes[:'couriers']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'total' => :'Integer',
+ :'couriers' => :'Array',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'total' => :'total',
+ :'couriers' => :'couriers',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/estimated_delivery_date_request.rb b/lib/aftership-tracking-sdk/models/estimated_delivery_date_request.rb
new file mode 100644
index 0000000..2175ca1
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/estimated_delivery_date_request.rb
@@ -0,0 +1,221 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class EstimatedDeliveryDateRequest
+ # AfterShip's unique code of courier. Please refer to https://track.aftership.com/couriers/download.
+ # slug: String;
+ attr_accessor :slug
+
+ # AfterShip’s unique code represents carrier’s shipping and delivery options. Refer to .
+ # service_type_name?: String;
+ attr_accessor :service_type_name
+
+ # The location from where the package is picked up by the carrier to be delivered to the final destination.
+ # origin_address: OriginAddressEstimatedDeliveryDateRequest;
+ attr_accessor :origin_address
+
+ # The final destination of the customer where the delivery will be made.
+ # destination_address: DestinationAddressEstimatedDeliveryDateRequest;
+ attr_accessor :destination_address
+
+ # AfterShip uses this object to calculate the total weight of the order.
+ # weight?: WeightEstimatedDeliveryDateRequest;
+ attr_accessor :weight
+
+ # The number of packages.
+ # package_count?: Integer;
+ attr_accessor :package_count
+
+ # The local pickup time in the origin address time zone of the package.Either `pickup_time` or `estimated_pickup` is required.
+ # pickup_time?: String;
+ attr_accessor :pickup_time
+
+ # The local pickup time of the package.Either `pickup_time` or `estimated_pickup` is required.
+ # estimated_pickup?: EstimatedPickupEstimatedDeliveryDateRequest;
+ attr_accessor :estimated_pickup
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::EstimatedDeliveryDateRequest` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'slug')
+ self.slug = attributes[:'slug']
+ end
+
+ if attributes.key?(:'service_type_name')
+ self.service_type_name = attributes[:'service_type_name']
+ end
+
+ if attributes.key?(:'origin_address')
+ self.origin_address = attributes[:'origin_address']
+ end
+
+ if attributes.key?(:'destination_address')
+ self.destination_address = attributes[:'destination_address']
+ end
+
+ if attributes.key?(:'weight')
+ self.weight = attributes[:'weight']
+ end
+
+ if attributes.key?(:'package_count')
+ self.package_count = attributes[:'package_count']
+ end
+
+ if attributes.key?(:'pickup_time')
+ self.pickup_time = attributes[:'pickup_time']
+ end
+
+ if attributes.key?(:'estimated_pickup')
+ self.estimated_pickup = attributes[:'estimated_pickup']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'slug' => :'String',
+ :'service_type_name' => :'String',
+ :'origin_address' => :'OriginAddressEstimatedDeliveryDateRequest',
+ :'destination_address' => :'DestinationAddressEstimatedDeliveryDateRequest',
+ :'weight' => :'WeightEstimatedDeliveryDateRequest',
+ :'package_count' => :'Integer',
+ :'pickup_time' => :'String',
+ :'estimated_pickup' => :'EstimatedPickupEstimatedDeliveryDateRequest',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'slug' => :'slug',
+ :'service_type_name' => :'service_type_name',
+ :'origin_address' => :'origin_address',
+ :'destination_address' => :'destination_address',
+ :'weight' => :'weight',
+ :'package_count' => :'package_count',
+ :'pickup_time' => :'pickup_time',
+ :'estimated_pickup' => :'estimated_pickup',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/estimated_delivery_date_response.rb b/lib/aftership-tracking-sdk/models/estimated_delivery_date_response.rb
new file mode 100644
index 0000000..355f4d8
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/estimated_delivery_date_response.rb
@@ -0,0 +1,261 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class EstimatedDeliveryDateResponse
+ # AfterShip's unique code of courier. Please refer to https://track.aftership.com/couriers/download.
+ # slug: String;
+ attr_accessor :slug
+
+ # AfterShip’s unique code represents carrier’s shipping and delivery options. Refer to .
+ # service_type_name?: String;
+ attr_accessor :service_type_name
+
+ # The location from where the package is picked up by the carrier to be delivered to the final destination.
+ # origin_address: OriginAddressEstimatedDeliveryDateResponse;
+ attr_accessor :origin_address
+
+ # The final destination of the customer where the delivery will be made.
+ # destination_address: DestinationAddressEstimatedDeliveryDateResponse;
+ attr_accessor :destination_address
+
+ # AfterShip uses this object to calculate the total weight of the order.
+ # weight?: WeightEstimatedDeliveryDateResponse;
+ attr_accessor :weight
+
+ # The number of packages.
+ # package_count?: Integer;
+ attr_accessor :package_count
+
+ # The local pickup time in the origin address time zone of the package.Either `pickup_time` or `estimated_pickup` is required.
+ # pickup_time?: String;
+ attr_accessor :pickup_time
+
+ # The local pickup time of the package.Either `pickup_time` or `estimated_pickup` is required.
+ # estimated_pickup?: EstimatedPickupEstimatedDeliveryDateResponse;
+ attr_accessor :estimated_pickup
+
+ # The estimated arrival date of the shipment, provided by AfterShip.
+ # estimated_delivery_date?: String;
+ attr_accessor :estimated_delivery_date
+
+ # Indicates the confidence level and associated reason for an AI EDD prediction request. For a comprehensive list of confidence codes, refer to .
+ # confidence_code?: Float;
+ attr_accessor :confidence_code
+
+ # The earliest estimated delivery date of the shipment, provided by AfterShip.
+ # estimated_delivery_date_min?: String;
+ attr_accessor :estimated_delivery_date_min
+
+ # The latest estimated delivery date of the shipment, provided by AfterShip.
+ # estimated_delivery_date_max?: String;
+ attr_accessor :estimated_delivery_date_max
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::EstimatedDeliveryDateResponse` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'slug')
+ self.slug = attributes[:'slug']
+ end
+
+ if attributes.key?(:'service_type_name')
+ self.service_type_name = attributes[:'service_type_name']
+ end
+
+ if attributes.key?(:'origin_address')
+ self.origin_address = attributes[:'origin_address']
+ end
+
+ if attributes.key?(:'destination_address')
+ self.destination_address = attributes[:'destination_address']
+ end
+
+ if attributes.key?(:'weight')
+ self.weight = attributes[:'weight']
+ end
+
+ if attributes.key?(:'package_count')
+ self.package_count = attributes[:'package_count']
+ end
+
+ if attributes.key?(:'pickup_time')
+ self.pickup_time = attributes[:'pickup_time']
+ end
+
+ if attributes.key?(:'estimated_pickup')
+ self.estimated_pickup = attributes[:'estimated_pickup']
+ end
+
+ if attributes.key?(:'estimated_delivery_date')
+ self.estimated_delivery_date = attributes[:'estimated_delivery_date']
+ end
+
+ if attributes.key?(:'confidence_code')
+ self.confidence_code = attributes[:'confidence_code']
+ end
+
+ if attributes.key?(:'estimated_delivery_date_min')
+ self.estimated_delivery_date_min = attributes[:'estimated_delivery_date_min']
+ end
+
+ if attributes.key?(:'estimated_delivery_date_max')
+ self.estimated_delivery_date_max = attributes[:'estimated_delivery_date_max']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'slug' => :'String',
+ :'service_type_name' => :'String',
+ :'origin_address' => :'OriginAddressEstimatedDeliveryDateResponse',
+ :'destination_address' => :'DestinationAddressEstimatedDeliveryDateResponse',
+ :'weight' => :'WeightEstimatedDeliveryDateResponse',
+ :'package_count' => :'Integer',
+ :'pickup_time' => :'String',
+ :'estimated_pickup' => :'EstimatedPickupEstimatedDeliveryDateResponse',
+ :'estimated_delivery_date' => :'String',
+ :'confidence_code' => :'Float',
+ :'estimated_delivery_date_min' => :'String',
+ :'estimated_delivery_date_max' => :'String',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'slug' => :'slug',
+ :'service_type_name' => :'service_type_name',
+ :'origin_address' => :'origin_address',
+ :'destination_address' => :'destination_address',
+ :'weight' => :'weight',
+ :'package_count' => :'package_count',
+ :'pickup_time' => :'pickup_time',
+ :'estimated_pickup' => :'estimated_pickup',
+ :'estimated_delivery_date' => :'estimated_delivery_date',
+ :'confidence_code' => :'confidence_code',
+ :'estimated_delivery_date_min' => :'estimated_delivery_date_min',
+ :'estimated_delivery_date_max' => :'estimated_delivery_date_max',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/estimated_pickup_estimated_delivery_date_request.rb b/lib/aftership-tracking-sdk/models/estimated_pickup_estimated_delivery_date_request.rb
new file mode 100644
index 0000000..b62e29a
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/estimated_pickup_estimated_delivery_date_request.rb
@@ -0,0 +1,181 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class EstimatedPickupEstimatedDeliveryDateRequest
+ # The local order time in the origin address time zone of the package.
+ # order_time: String;
+ attr_accessor :order_time
+
+ # Order cut off time in the origin address time zone. The default value set by AfterShip is 18:00:00.
+ # order_cutoff_time?: String;
+ attr_accessor :order_cutoff_time
+
+ # Operating days in a week. Number refers to the weekday.E.g., [1,2,3,4,5] means operating days are from Monday to Friday.AfterShip will set [1,2,3,4,5] as the default value.
+ # business_days?: Integer[];
+ attr_accessor :business_days
+
+ #
+ # order_processing_time?: OrderProcessingTimeEstimatedPickupEstimatedDeliveryDateRequest;
+ attr_accessor :order_processing_time
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::EstimatedPickupEstimatedDeliveryDateRequest` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'order_time')
+ self.order_time = attributes[:'order_time']
+ end
+
+ if attributes.key?(:'order_cutoff_time')
+ self.order_cutoff_time = attributes[:'order_cutoff_time']
+ end
+
+ if attributes.key?(:'business_days')
+ self.business_days = attributes[:'business_days']
+ end
+
+ if attributes.key?(:'order_processing_time')
+ self.order_processing_time = attributes[:'order_processing_time']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'order_time' => :'String',
+ :'order_cutoff_time' => :'String',
+ :'business_days' => :'Array',
+ :'order_processing_time' => :'OrderProcessingTimeEstimatedPickupEstimatedDeliveryDateRequest',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'order_time' => :'order_time',
+ :'order_cutoff_time' => :'order_cutoff_time',
+ :'business_days' => :'business_days',
+ :'order_processing_time' => :'order_processing_time',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/estimated_pickup_estimated_delivery_date_response.rb b/lib/aftership-tracking-sdk/models/estimated_pickup_estimated_delivery_date_response.rb
new file mode 100644
index 0000000..82138b6
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/estimated_pickup_estimated_delivery_date_response.rb
@@ -0,0 +1,191 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class EstimatedPickupEstimatedDeliveryDateResponse
+ # The local order time in the origin address time zone of the package.
+ # order_time: String;
+ attr_accessor :order_time
+
+ # Order cut off time in the origin address time zone. The default value set by AfterShip is 18:00:00.
+ # order_cutoff_time?: String;
+ attr_accessor :order_cutoff_time
+
+ # Operating days in a week. Number refers to the weekday.E.g., [1,2,3,4,5] means operating days are from Monday to Friday.AfterShip will set [1,2,3,4,5] as the default value.
+ # business_days?: Integer[];
+ attr_accessor :business_days
+
+ #
+ # order_processing_time?: OrderProcessingTimeEstimatedPickupEstimatedDeliveryDateResponse;
+ attr_accessor :order_processing_time
+
+ # The local pickup time of the package.
+ # pickup_time?: String;
+ attr_accessor :pickup_time
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::EstimatedPickupEstimatedDeliveryDateResponse` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'order_time')
+ self.order_time = attributes[:'order_time']
+ end
+
+ if attributes.key?(:'order_cutoff_time')
+ self.order_cutoff_time = attributes[:'order_cutoff_time']
+ end
+
+ if attributes.key?(:'business_days')
+ self.business_days = attributes[:'business_days']
+ end
+
+ if attributes.key?(:'order_processing_time')
+ self.order_processing_time = attributes[:'order_processing_time']
+ end
+
+ if attributes.key?(:'pickup_time')
+ self.pickup_time = attributes[:'pickup_time']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'order_time' => :'String',
+ :'order_cutoff_time' => :'String',
+ :'business_days' => :'Array',
+ :'order_processing_time' => :'OrderProcessingTimeEstimatedPickupEstimatedDeliveryDateResponse',
+ :'pickup_time' => :'String',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'order_time' => :'order_time',
+ :'order_cutoff_time' => :'order_cutoff_time',
+ :'business_days' => :'business_days',
+ :'order_processing_time' => :'order_processing_time',
+ :'pickup_time' => :'pickup_time',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/events_checkpoint.rb b/lib/aftership-tracking-sdk/models/events_checkpoint.rb
new file mode 100644
index 0000000..4487994
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/events_checkpoint.rb
@@ -0,0 +1,161 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class EventsCheckpoint
+ # Represents the event code.
+ # code?: String;
+ attr_accessor :code
+
+ # Describes the specific reason that led to the event.
+ # reason?: ReasonEventsCheckpoint;
+ attr_accessor :reason
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::EventsCheckpoint` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'code')
+ self.code = attributes[:'code']
+ end
+
+ if attributes.key?(:'reason')
+ self.reason = attributes[:'reason']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'code' => :'String',
+ :'reason' => :'ReasonEventsCheckpoint',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'code' => :'code',
+ :'reason' => :'reason',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/first_estimated_delivery_tracking.rb b/lib/aftership-tracking-sdk/models/first_estimated_delivery_tracking.rb
new file mode 100644
index 0000000..e08ce38
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/first_estimated_delivery_tracking.rb
@@ -0,0 +1,191 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class FirstEstimatedDeliveryTracking
+ # The format of the EDD. Either a single date or a date range.
+ # type?: String;
+ attr_accessor :type
+
+ # The source of the EDD. Either the carrier, AfterShip AI, or based on your custom EDD settings.
+ # source?: String;
+ attr_accessor :source
+
+ # The latest EDD time.
+ # datetime?: String;
+ attr_accessor :datetime
+
+ # For a date range EDD format, the date and time for the lower end of the range.
+ # datetime_min?: String;
+ attr_accessor :datetime_min
+
+ # For a date range EDD format, the date and time for the upper end of the range.
+ # datetime_max?: String;
+ attr_accessor :datetime_max
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::FirstEstimatedDeliveryTracking` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'type')
+ self.type = attributes[:'type']
+ end
+
+ if attributes.key?(:'source')
+ self.source = attributes[:'source']
+ end
+
+ if attributes.key?(:'datetime')
+ self.datetime = attributes[:'datetime']
+ end
+
+ if attributes.key?(:'datetime_min')
+ self.datetime_min = attributes[:'datetime_min']
+ end
+
+ if attributes.key?(:'datetime_max')
+ self.datetime_max = attributes[:'datetime_max']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'type' => :'String',
+ :'source' => :'String',
+ :'datetime' => :'String',
+ :'datetime_min' => :'String',
+ :'datetime_max' => :'String',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'type' => :'type',
+ :'source' => :'source',
+ :'datetime' => :'datetime',
+ :'datetime_min' => :'datetime_min',
+ :'datetime_max' => :'datetime_max',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/get_all_couriers_response.rb b/lib/aftership-tracking-sdk/models/get_all_couriers_response.rb
new file mode 100644
index 0000000..6d20282
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/get_all_couriers_response.rb
@@ -0,0 +1,161 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class GetAllCouriersResponse
+ # Total count of courier objects
+ # total?: Integer;
+ attr_accessor :total
+
+ # Array of object.
+ # couriers?: Courier[];
+ attr_accessor :couriers
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::GetAllCouriersResponse` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'total')
+ self.total = attributes[:'total']
+ end
+
+ if attributes.key?(:'couriers')
+ self.couriers = attributes[:'couriers']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'total' => :'Integer',
+ :'couriers' => :'Array',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'total' => :'total',
+ :'couriers' => :'couriers',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/get_checkpoint_by_slug_tracking_number_response.rb b/lib/aftership-tracking-sdk/models/get_checkpoint_by_slug_tracking_number_response.rb
new file mode 100644
index 0000000..29565b0
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/get_checkpoint_by_slug_tracking_number_response.rb
@@ -0,0 +1,211 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class GetCheckpointBySlugTrackingNumberResponse
+ # Tracking id
+ # id?: String;
+ attr_accessor :id
+
+ # Tracking number.
+ # tracking_number?: String;
+ attr_accessor :tracking_number
+
+ # Unique code of courier.
+ # slug?: String;
+ attr_accessor :slug
+
+ # Current status of tracking. (
+ # tag?: TagV1;
+ attr_accessor :tag
+
+ # Current subtag of tracking. (
+ # subtag?: String;
+ attr_accessor :subtag
+
+ # Normalized tracking message. (
+ # subtag_message?: String;
+ attr_accessor :subtag_message
+
+ # Object describes checkpoint information.
+ # checkpoint?: Checkpoint;
+ attr_accessor :checkpoint
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::GetCheckpointBySlugTrackingNumberResponse` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'id')
+ self.id = attributes[:'id']
+ end
+
+ if attributes.key?(:'tracking_number')
+ self.tracking_number = attributes[:'tracking_number']
+ end
+
+ if attributes.key?(:'slug')
+ self.slug = attributes[:'slug']
+ end
+
+ if attributes.key?(:'tag')
+ self.tag = attributes[:'tag']
+ end
+
+ if attributes.key?(:'subtag')
+ self.subtag = attributes[:'subtag']
+ end
+
+ if attributes.key?(:'subtag_message')
+ self.subtag_message = attributes[:'subtag_message']
+ end
+
+ if attributes.key?(:'checkpoint')
+ self.checkpoint = attributes[:'checkpoint']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'id' => :'String',
+ :'tracking_number' => :'String',
+ :'slug' => :'String',
+ :'tag' => :'TagV1',
+ :'subtag' => :'String',
+ :'subtag_message' => :'String',
+ :'checkpoint' => :'Checkpoint',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'id' => :'id',
+ :'tracking_number' => :'tracking_number',
+ :'slug' => :'slug',
+ :'tag' => :'tag',
+ :'subtag' => :'subtag',
+ :'subtag_message' => :'subtag_message',
+ :'checkpoint' => :'checkpoint',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/get_checkpoint_by_tracking_id_response.rb b/lib/aftership-tracking-sdk/models/get_checkpoint_by_tracking_id_response.rb
new file mode 100644
index 0000000..33787a0
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/get_checkpoint_by_tracking_id_response.rb
@@ -0,0 +1,211 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class GetCheckpointByTrackingIdResponse
+ # Tracking id
+ # id?: String;
+ attr_accessor :id
+
+ # Tracking number.
+ # tracking_number?: String;
+ attr_accessor :tracking_number
+
+ # Unique code of courier.
+ # slug?: String;
+ attr_accessor :slug
+
+ # Current status of tracking. (
+ # tag?: TagV1;
+ attr_accessor :tag
+
+ # Current subtag of tracking. (
+ # subtag?: String;
+ attr_accessor :subtag
+
+ # Normalized tracking message. (
+ # subtag_message?: String;
+ attr_accessor :subtag_message
+
+ # Object describes checkpoint information.
+ # checkpoint?: Checkpoint;
+ attr_accessor :checkpoint
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::GetCheckpointByTrackingIdResponse` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'id')
+ self.id = attributes[:'id']
+ end
+
+ if attributes.key?(:'tracking_number')
+ self.tracking_number = attributes[:'tracking_number']
+ end
+
+ if attributes.key?(:'slug')
+ self.slug = attributes[:'slug']
+ end
+
+ if attributes.key?(:'tag')
+ self.tag = attributes[:'tag']
+ end
+
+ if attributes.key?(:'subtag')
+ self.subtag = attributes[:'subtag']
+ end
+
+ if attributes.key?(:'subtag_message')
+ self.subtag_message = attributes[:'subtag_message']
+ end
+
+ if attributes.key?(:'checkpoint')
+ self.checkpoint = attributes[:'checkpoint']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'id' => :'String',
+ :'tracking_number' => :'String',
+ :'slug' => :'String',
+ :'tag' => :'TagV1',
+ :'subtag' => :'String',
+ :'subtag_message' => :'String',
+ :'checkpoint' => :'Checkpoint',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'id' => :'id',
+ :'tracking_number' => :'tracking_number',
+ :'slug' => :'slug',
+ :'tag' => :'tag',
+ :'subtag' => :'subtag',
+ :'subtag_message' => :'subtag_message',
+ :'checkpoint' => :'checkpoint',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/get_trackings_response.rb b/lib/aftership-tracking-sdk/models/get_trackings_response.rb
new file mode 100644
index 0000000..d4eb78f
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/get_trackings_response.rb
@@ -0,0 +1,161 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class GetTrackingsResponse
+ #
+ # pagination: Pagination;
+ attr_accessor :pagination
+
+ # Array of
+ # trackings?: Tracking[];
+ attr_accessor :trackings
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::GetTrackingsResponse` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'pagination')
+ self.pagination = attributes[:'pagination']
+ end
+
+ if attributes.key?(:'trackings')
+ self.trackings = attributes[:'trackings']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'pagination' => :'Pagination',
+ :'trackings' => :'Array',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'pagination' => :'pagination',
+ :'trackings' => :'trackings',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/get_user_couriers_response.rb b/lib/aftership-tracking-sdk/models/get_user_couriers_response.rb
new file mode 100644
index 0000000..edb5b35
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/get_user_couriers_response.rb
@@ -0,0 +1,161 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class GetUserCouriersResponse
+ # Total count of courier objects
+ # total?: Integer;
+ attr_accessor :total
+
+ # Array of object.
+ # couriers?: Courier[];
+ attr_accessor :couriers
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::GetUserCouriersResponse` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'total')
+ self.total = attributes[:'total']
+ end
+
+ if attributes.key?(:'couriers')
+ self.couriers = attributes[:'couriers']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'total' => :'Integer',
+ :'couriers' => :'Array',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'total' => :'total',
+ :'couriers' => :'couriers',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/latest_estimated_delivery_tracking.rb b/lib/aftership-tracking-sdk/models/latest_estimated_delivery_tracking.rb
new file mode 100644
index 0000000..7c2ad42
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/latest_estimated_delivery_tracking.rb
@@ -0,0 +1,191 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class LatestEstimatedDeliveryTracking
+ # The format of the EDD. Either a single date or a date range.
+ # type?: String;
+ attr_accessor :type
+
+ # The source of the EDD. Either the carrier, AfterShip AI, or based on your custom EDD settings.
+ # source?: String;
+ attr_accessor :source
+
+ # The latest EDD time.
+ # datetime?: String;
+ attr_accessor :datetime
+
+ # For a date range EDD format, the date and time for the lower end of the range.
+ # datetime_min?: String;
+ attr_accessor :datetime_min
+
+ # For a date range EDD format, the date and time for the upper end of the range.
+ # datetime_max?: String;
+ attr_accessor :datetime_max
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::LatestEstimatedDeliveryTracking` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'type')
+ self.type = attributes[:'type']
+ end
+
+ if attributes.key?(:'source')
+ self.source = attributes[:'source']
+ end
+
+ if attributes.key?(:'datetime')
+ self.datetime = attributes[:'datetime']
+ end
+
+ if attributes.key?(:'datetime_min')
+ self.datetime_min = attributes[:'datetime_min']
+ end
+
+ if attributes.key?(:'datetime_max')
+ self.datetime_max = attributes[:'datetime_max']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'type' => :'String',
+ :'source' => :'String',
+ :'datetime' => :'String',
+ :'datetime_min' => :'String',
+ :'datetime_max' => :'String',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'type' => :'type',
+ :'source' => :'source',
+ :'datetime' => :'datetime',
+ :'datetime_min' => :'datetime_min',
+ :'datetime_max' => :'datetime_max',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/mark_tracking_completed_by_id_request.rb b/lib/aftership-tracking-sdk/models/mark_tracking_completed_by_id_request.rb
new file mode 100644
index 0000000..b812c92
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/mark_tracking_completed_by_id_request.rb
@@ -0,0 +1,151 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class MarkTrackingCompletedByIdRequest
+ # One of `DELIVERED`, `LOST` or `RETURNED_TO_SENDER`.- Mark the tracking as completed with `DELIVERED`. The tag of the tracking will be updated to `Delivered` and the subtag will be updated to `Delivered_001`.- Mark the tracking as completed with `LOST`. The tag of the tracking will be updated to `Exception` and the subtag will be updated to `Exception_013`.- Mark the tracking as completed with `RETURNED_TO_SENDER`. The tag of the tracking will be updated to `Exception` and the subtag will be updated to `Exception_011`.
+ # reason: String;
+ attr_accessor :reason
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::MarkTrackingCompletedByIdRequest` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'reason')
+ self.reason = attributes[:'reason']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'reason' => :'String',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'reason' => :'reason',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/mark_tracking_completed_by_slug_tracking_number_request.rb b/lib/aftership-tracking-sdk/models/mark_tracking_completed_by_slug_tracking_number_request.rb
new file mode 100644
index 0000000..c86b4df
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/mark_tracking_completed_by_slug_tracking_number_request.rb
@@ -0,0 +1,151 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class MarkTrackingCompletedBySlugTrackingNumberRequest
+ # One of `DELIVERED`, `LOST` or `RETURNED_TO_SENDER`.- Mark the tracking as completed with `DELIVERED`. The tag of the tracking will be updated to `Delivered` and the subtag will be updated to `Delivered_001`.- Mark the tracking as completed with `LOST`. The tag of the tracking will be updated to `Exception` and the subtag will be updated to `Exception_013`.- Mark the tracking as completed with `RETURNED_TO_SENDER`. The tag of the tracking will be updated to `Exception` and the subtag will be updated to `Exception_011`.
+ # reason: String;
+ attr_accessor :reason
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::MarkTrackingCompletedBySlugTrackingNumberRequest` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'reason')
+ self.reason = attributes[:'reason']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'reason' => :'String',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'reason' => :'reason',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/meta_v1.rb b/lib/aftership-tracking-sdk/models/meta_v1.rb
new file mode 100644
index 0000000..ccc24af
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/meta_v1.rb
@@ -0,0 +1,171 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class MetaV1
+ # meta code
+ # code: Integer;
+ attr_accessor :code
+
+ # error message, only exist if the response status is not 2xx
+ # message?: String;
+ attr_accessor :message
+
+ # error type, only exist if the response status is not 2xx
+ # type?: String;
+ attr_accessor :type
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::MetaV1` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'code')
+ self.code = attributes[:'code']
+ end
+
+ if attributes.key?(:'message')
+ self.message = attributes[:'message']
+ end
+
+ if attributes.key?(:'type')
+ self.type = attributes[:'type']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'code' => :'Integer',
+ :'message' => :'String',
+ :'type' => :'String',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'code' => :'code',
+ :'message' => :'message',
+ :'type' => :'type',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/next_couriers_tracking.rb b/lib/aftership-tracking-sdk/models/next_couriers_tracking.rb
new file mode 100644
index 0000000..ac27dd5
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/next_couriers_tracking.rb
@@ -0,0 +1,171 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class NextCouriersTracking
+ # Unique code of courier. Get courier
+ # slug: String;
+ attr_accessor :slug
+
+ # Tracking number.
+ # tracking_number: String;
+ attr_accessor :tracking_number
+
+ # Source of next couriers.
+ # source?: String;
+ attr_accessor :source
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::NextCouriersTracking` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'slug')
+ self.slug = attributes[:'slug']
+ end
+
+ if attributes.key?(:'tracking_number')
+ self.tracking_number = attributes[:'tracking_number']
+ end
+
+ if attributes.key?(:'source')
+ self.source = attributes[:'source']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'slug' => :'String',
+ :'tracking_number' => :'String',
+ :'source' => :'String',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'slug' => :'slug',
+ :'tracking_number' => :'tracking_number',
+ :'source' => :'source',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/next_couriers_tracking_create_tracking_request.rb b/lib/aftership-tracking-sdk/models/next_couriers_tracking_create_tracking_request.rb
new file mode 100644
index 0000000..1139e58
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/next_couriers_tracking_create_tracking_request.rb
@@ -0,0 +1,161 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class NextCouriersTrackingCreateTrackingRequest
+ #
+ # slug: String;
+ attr_accessor :slug
+
+ # Tracking number of a shipment.Duplicated tracking numbers, tracking numbers with invalid tracking number format will not be accepted.We only accept tracking numbers with length from 4 to 100We currently support the following characters in a tracking number:- A - Z- 0 - 9- `-` (Hyphen)- . (Period)- _ (Underscore)- / (Slash)
+ # tracking_number: String;
+ attr_accessor :tracking_number
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::NextCouriersTrackingCreateTrackingRequest` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'slug')
+ self.slug = attributes[:'slug']
+ end
+
+ if attributes.key?(:'tracking_number')
+ self.tracking_number = attributes[:'tracking_number']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'slug' => :'String',
+ :'tracking_number' => :'String',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'slug' => :'slug',
+ :'tracking_number' => :'tracking_number',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/notification.rb b/lib/aftership-tracking-sdk/models/notification.rb
new file mode 100644
index 0000000..45f13ef
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/notification.rb
@@ -0,0 +1,161 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class Notification
+ # Email address(es) to receive email notifications.
+ # emails?: String[];
+ attr_accessor :emails
+
+ # The phone number(s) to receive sms notifications.
+ # smses?: String[];
+ attr_accessor :smses
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::Notification` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'emails')
+ self.emails = attributes[:'emails']
+ end
+
+ if attributes.key?(:'smses')
+ self.smses = attributes[:'smses']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'emails' => :'Array',
+ :'smses' => :'Array',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'emails' => :'emails',
+ :'smses' => :'smses',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/notification_request_v1.rb b/lib/aftership-tracking-sdk/models/notification_request_v1.rb
new file mode 100644
index 0000000..ce1200d
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/notification_request_v1.rb
@@ -0,0 +1,161 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class NotificationRequestV1
+ # Email address(es) to receive email notifications.Accept either array or comma separated as input.
+ # emails?: String[];
+ attr_accessor :emails
+
+ # The phone number(s) to receive sms notifications. Enter `+` and `area code` before phone number.Accept either array or comma separated as input.
+ # smses?: String[];
+ attr_accessor :smses
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::NotificationRequestV1` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'emails')
+ self.emails = attributes[:'emails']
+ end
+
+ if attributes.key?(:'smses')
+ self.smses = attributes[:'smses']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'emails' => :'Array',
+ :'smses' => :'Array',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'emails' => :'emails',
+ :'smses' => :'smses',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/notification_response_v1.rb b/lib/aftership-tracking-sdk/models/notification_response_v1.rb
new file mode 100644
index 0000000..7c614b3
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/notification_response_v1.rb
@@ -0,0 +1,161 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class NotificationResponseV1
+ # Meta data
+ # meta?: MetaV1;
+ attr_accessor :meta
+
+ #
+ # data?: DataNotificationResponseV1;
+ attr_accessor :data
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::NotificationResponseV1` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'meta')
+ self.meta = attributes[:'meta']
+ end
+
+ if attributes.key?(:'data')
+ self.data = attributes[:'data']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'meta' => :'MetaV1',
+ :'data' => :'DataNotificationResponseV1',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'meta' => :'meta',
+ :'data' => :'data',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/order_processing_time_estimated_pickup_estimated_delivery_date_request.rb b/lib/aftership-tracking-sdk/models/order_processing_time_estimated_pickup_estimated_delivery_date_request.rb
new file mode 100644
index 0000000..4d67e28
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/order_processing_time_estimated_pickup_estimated_delivery_date_request.rb
@@ -0,0 +1,161 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class OrderProcessingTimeEstimatedPickupEstimatedDeliveryDateRequest
+ # Processing time of an order, from being placed to being picked up. Only support day as value now.AfterShip will set day as the default value.
+ # unit?: String;
+ attr_accessor :unit
+
+ # Processing time of an order, from being placed to being picked up.AfterShip will set 0 as the default value.
+ # value?: Float;
+ attr_accessor :value
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::OrderProcessingTimeEstimatedPickupEstimatedDeliveryDateRequest` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'unit')
+ self.unit = attributes[:'unit']
+ end
+
+ if attributes.key?(:'value')
+ self.value = attributes[:'value']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'unit' => :'String',
+ :'value' => :'Float',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'unit' => :'unit',
+ :'value' => :'value',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/order_processing_time_estimated_pickup_estimated_delivery_date_response.rb b/lib/aftership-tracking-sdk/models/order_processing_time_estimated_pickup_estimated_delivery_date_response.rb
new file mode 100644
index 0000000..696e486
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/order_processing_time_estimated_pickup_estimated_delivery_date_response.rb
@@ -0,0 +1,161 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class OrderProcessingTimeEstimatedPickupEstimatedDeliveryDateResponse
+ # Processing time of an order, from being placed to being picked up. Only support day as value now.AfterShip will set day as the default value.
+ # unit?: String;
+ attr_accessor :unit
+
+ # Processing time of an order, from being placed to being picked up.AfterShip will set 0 as the default value.
+ # value?: Float;
+ attr_accessor :value
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::OrderProcessingTimeEstimatedPickupEstimatedDeliveryDateResponse` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'unit')
+ self.unit = attributes[:'unit']
+ end
+
+ if attributes.key?(:'value')
+ self.value = attributes[:'value']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'unit' => :'String',
+ :'value' => :'Float',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'unit' => :'unit',
+ :'value' => :'value',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/origin_address_estimated_delivery_date_request.rb b/lib/aftership-tracking-sdk/models/origin_address_estimated_delivery_date_request.rb
new file mode 100644
index 0000000..7a1fbc0
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/origin_address_estimated_delivery_date_request.rb
@@ -0,0 +1,191 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class OriginAddressEstimatedDeliveryDateRequest
+ # The country/region of the origin location from where the package is picked up by the carrier to be delivered to the final destination. Use 3 letters of ISO 3166-1 country/region code.
+ # country: String;
+ attr_accessor :country
+
+ # 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?: 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?: String;
+ attr_accessor :postal_code
+
+ # Raw location of the origin address. A raw address will help AI to identify the accurate location of the origin address.
+ # raw_location?: String;
+ attr_accessor :raw_location
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::OriginAddressEstimatedDeliveryDateRequest` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'country')
+ self.country = attributes[:'country']
+ end
+
+ if attributes.key?(:'state')
+ self.state = attributes[:'state']
+ end
+
+ if attributes.key?(:'city')
+ self.city = attributes[:'city']
+ end
+
+ if attributes.key?(:'postal_code')
+ self.postal_code = attributes[:'postal_code']
+ end
+
+ if attributes.key?(:'raw_location')
+ self.raw_location = attributes[:'raw_location']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'country' => :'String',
+ :'state' => :'String',
+ :'city' => :'String',
+ :'postal_code' => :'String',
+ :'raw_location' => :'String',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'country' => :'country',
+ :'state' => :'state',
+ :'city' => :'city',
+ :'postal_code' => :'postal_code',
+ :'raw_location' => :'raw_location',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/origin_address_estimated_delivery_date_response.rb b/lib/aftership-tracking-sdk/models/origin_address_estimated_delivery_date_response.rb
new file mode 100644
index 0000000..7526012
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/origin_address_estimated_delivery_date_response.rb
@@ -0,0 +1,191 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class OriginAddressEstimatedDeliveryDateResponse
+ # The country/region of the origin location from where the package is picked up by the carrier to be delivered to the final destination. Use 3 letters of ISO 3166-1 country/region code.
+ # country: String;
+ attr_accessor :country
+
+ # 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?: 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?: String;
+ attr_accessor :postal_code
+
+ # Raw location of the origin address. A raw address will help AI to identify the accurate location of the origin address.
+ # raw_location?: String;
+ attr_accessor :raw_location
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::OriginAddressEstimatedDeliveryDateResponse` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'country')
+ self.country = attributes[:'country']
+ end
+
+ if attributes.key?(:'state')
+ self.state = attributes[:'state']
+ end
+
+ if attributes.key?(:'city')
+ self.city = attributes[:'city']
+ end
+
+ if attributes.key?(:'postal_code')
+ self.postal_code = attributes[:'postal_code']
+ end
+
+ if attributes.key?(:'raw_location')
+ self.raw_location = attributes[:'raw_location']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'country' => :'String',
+ :'state' => :'String',
+ :'city' => :'String',
+ :'postal_code' => :'String',
+ :'raw_location' => :'String',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'country' => :'country',
+ :'state' => :'state',
+ :'city' => :'city',
+ :'postal_code' => :'postal_code',
+ :'raw_location' => :'raw_location',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/pagination.rb b/lib/aftership-tracking-sdk/models/pagination.rb
new file mode 100644
index 0000000..8d68922
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/pagination.rb
@@ -0,0 +1,156 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class Pagination
+ attr_accessor :total, :page, :limit, :has_next_page
+ # Initializes the object
+ # @param attributes [Hash] Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::Pagination` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'total')
+ self.total = attributes[:'total']
+ end
+
+ if attributes.key?(:'page')
+ self.page = attributes[:'page']
+ end
+
+ if attributes.key?(:'limit')
+ self.limit = attributes[:'limit']
+ end
+
+ if attributes.key?(:'has_next_page')
+ self.has_next_page = attributes[:'has_next_page']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'total' => :'Integer',
+ :'page' => :'Integer',
+ :'limit' => :'Integer',
+ :'has_next_page' => :'Boolean'
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.openapi_types.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[attr] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/partial_delete_tracking.rb b/lib/aftership-tracking-sdk/models/partial_delete_tracking.rb
new file mode 100644
index 0000000..1086f62
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/partial_delete_tracking.rb
@@ -0,0 +1,241 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class PartialDeleteTracking
+ # Tracking id
+ # id?: String;
+ attr_accessor :id
+
+ # Tracking number
+ # tracking_number?: String;
+ attr_accessor :tracking_number
+
+ # Unique code of courier. Get the slugs from .
+ # slug?: String;
+ attr_accessor :slug
+
+ # Additional field required by some carriers to retrieve the tracking info. The shipper’s carrier account number. Refer to our article on for more details.
+ # tracking_account_number?: String;
+ attr_accessor :tracking_account_number
+
+ # Additional field required by some carriers to retrieve the tracking info. A type of tracking credential required by some carriers. Refer to our article on for more details.
+ # tracking_key?: String;
+ attr_accessor :tracking_key
+
+ # Additional field required by some carriers to retrieve the tracking info. The date the shipment was sent, using the format YYYYMMDD. Refer to our article on for more details.
+ # tracking_ship_date?: String;
+ attr_accessor :tracking_ship_date
+
+ # (Legacy) Additional field required by some carriers to retrieve the tracking info. The origin country/region of the shipment. Refer to our article on for more details.
+ # tracking_origin_country?: String;
+ attr_accessor :tracking_origin_country
+
+ # (Legacy) Additional field required by some carriers to retrieve the tracking info. The destination country/region of the shipment. Refer to our article on for more details.
+ # tracking_destination_country?: String;
+ attr_accessor :tracking_destination_country
+
+ # (Legacy) Additional field required by some carriers to retrieve the tracking info. The postal code of the recipient’s address. Refer to our article on for more details.
+ # tracking_postal_code?: String;
+ attr_accessor :tracking_postal_code
+
+ # (Legacy) Additional field required by some carriers to retrieve the tracking info. The state/province of the recipient’s address. Refer to our article on for more details.
+ # tracking_state?: String;
+ attr_accessor :tracking_state
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::PartialDeleteTracking` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'id')
+ self.id = attributes[:'id']
+ end
+
+ if attributes.key?(:'tracking_number')
+ self.tracking_number = attributes[:'tracking_number']
+ end
+
+ if attributes.key?(:'slug')
+ self.slug = attributes[:'slug']
+ end
+
+ if attributes.key?(:'tracking_account_number')
+ self.tracking_account_number = attributes[:'tracking_account_number']
+ end
+
+ if attributes.key?(:'tracking_key')
+ self.tracking_key = attributes[:'tracking_key']
+ end
+
+ if attributes.key?(:'tracking_ship_date')
+ self.tracking_ship_date = attributes[:'tracking_ship_date']
+ end
+
+ if attributes.key?(:'tracking_origin_country')
+ self.tracking_origin_country = attributes[:'tracking_origin_country']
+ end
+
+ if attributes.key?(:'tracking_destination_country')
+ self.tracking_destination_country = attributes[:'tracking_destination_country']
+ end
+
+ if attributes.key?(:'tracking_postal_code')
+ self.tracking_postal_code = attributes[:'tracking_postal_code']
+ end
+
+ if attributes.key?(:'tracking_state')
+ self.tracking_state = attributes[:'tracking_state']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'id' => :'String',
+ :'tracking_number' => :'String',
+ :'slug' => :'String',
+ :'tracking_account_number' => :'String',
+ :'tracking_key' => :'String',
+ :'tracking_ship_date' => :'String',
+ :'tracking_origin_country' => :'String',
+ :'tracking_destination_country' => :'String',
+ :'tracking_postal_code' => :'String',
+ :'tracking_state' => :'String',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'id' => :'id',
+ :'tracking_number' => :'tracking_number',
+ :'slug' => :'slug',
+ :'tracking_account_number' => :'tracking_account_number',
+ :'tracking_key' => :'tracking_key',
+ :'tracking_ship_date' => :'tracking_ship_date',
+ :'tracking_origin_country' => :'tracking_origin_country',
+ :'tracking_destination_country' => :'tracking_destination_country',
+ :'tracking_postal_code' => :'tracking_postal_code',
+ :'tracking_state' => :'tracking_state',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/partial_update_tracking.rb b/lib/aftership-tracking-sdk/models/partial_update_tracking.rb
new file mode 100644
index 0000000..15cd8f4
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/partial_update_tracking.rb
@@ -0,0 +1,251 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class PartialUpdateTracking
+ # A unique identifier generated by AfterShip for the tracking.
+ # id?: String;
+ attr_accessor :id
+
+ # Tracking number.
+ # tracking_number?: String;
+ attr_accessor :tracking_number
+
+ # Unique code of courier. Get the slugs from .
+ # slug?: String;
+ attr_accessor :slug
+
+ # Additional field required by some carriers to retrieve the tracking info. The shipper’s carrier account number. Refer to our article on for more details.
+ # tracking_account_number?: String;
+ attr_accessor :tracking_account_number
+
+ # Additional field required by some carriers to retrieve the tracking info. The origin country/region of the shipment. Refer to our article on for more details.
+ # tracking_origin_country?: String;
+ attr_accessor :tracking_origin_country
+
+ # Additional field required by some carriers to retrieve the tracking info. The destination country/region of the shipment. Refer to our article on for more details.
+ # tracking_destination_country?: String;
+ attr_accessor :tracking_destination_country
+
+ # Additional field required by some carriers to retrieve the tracking info. A type of tracking credential required by some carriers. Refer to our article on for more details.
+ # tracking_key?: String;
+ attr_accessor :tracking_key
+
+ # Additional field required by some carriers to retrieve the tracking info. The date the shipment was sent, using the format YYYYMMDD. Refer to our article on for more details.
+ # tracking_ship_date?: String;
+ attr_accessor :tracking_ship_date
+
+ # Additional field required by some carriers to retrieve the tracking info. The postal code of the recipient’s address. Refer to our article on for more details.
+ # tracking_postal_code?: String;
+ attr_accessor :tracking_postal_code
+
+ # Additional field required by some carriers to retrieve the tracking info. The state/province of the recipient’s address. Refer to our article on for more details.
+ # tracking_state?: String;
+ attr_accessor :tracking_state
+
+ # Whether or not AfterShip will continue tracking the shipments. Value is `false` when tag (status) is `Delivered`, `Expired`, or further updates for 30 days since last update.
+ # active?: Boolean;
+ attr_accessor :active
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::PartialUpdateTracking` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'id')
+ self.id = attributes[:'id']
+ end
+
+ if attributes.key?(:'tracking_number')
+ self.tracking_number = attributes[:'tracking_number']
+ end
+
+ if attributes.key?(:'slug')
+ self.slug = attributes[:'slug']
+ end
+
+ if attributes.key?(:'tracking_account_number')
+ self.tracking_account_number = attributes[:'tracking_account_number']
+ end
+
+ if attributes.key?(:'tracking_origin_country')
+ self.tracking_origin_country = attributes[:'tracking_origin_country']
+ end
+
+ if attributes.key?(:'tracking_destination_country')
+ self.tracking_destination_country = attributes[:'tracking_destination_country']
+ end
+
+ if attributes.key?(:'tracking_key')
+ self.tracking_key = attributes[:'tracking_key']
+ end
+
+ if attributes.key?(:'tracking_ship_date')
+ self.tracking_ship_date = attributes[:'tracking_ship_date']
+ end
+
+ if attributes.key?(:'tracking_postal_code')
+ self.tracking_postal_code = attributes[:'tracking_postal_code']
+ end
+
+ if attributes.key?(:'tracking_state')
+ self.tracking_state = attributes[:'tracking_state']
+ end
+
+ if attributes.key?(:'active')
+ self.active = attributes[:'active']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'id' => :'String',
+ :'tracking_number' => :'String',
+ :'slug' => :'String',
+ :'tracking_account_number' => :'String',
+ :'tracking_origin_country' => :'String',
+ :'tracking_destination_country' => :'String',
+ :'tracking_key' => :'String',
+ :'tracking_ship_date' => :'String',
+ :'tracking_postal_code' => :'String',
+ :'tracking_state' => :'String',
+ :'active' => :'Boolean',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'id' => :'id',
+ :'tracking_number' => :'tracking_number',
+ :'slug' => :'slug',
+ :'tracking_account_number' => :'tracking_account_number',
+ :'tracking_origin_country' => :'tracking_origin_country',
+ :'tracking_destination_country' => :'tracking_destination_country',
+ :'tracking_key' => :'tracking_key',
+ :'tracking_ship_date' => :'tracking_ship_date',
+ :'tracking_postal_code' => :'tracking_postal_code',
+ :'tracking_state' => :'tracking_state',
+ :'active' => :'active',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/predict_batch_request.rb b/lib/aftership-tracking-sdk/models/predict_batch_request.rb
new file mode 100644
index 0000000..60798d7
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/predict_batch_request.rb
@@ -0,0 +1,151 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class PredictBatchRequest
+ #
+ # estimated_delivery_dates: EstimatedDeliveryDateRequest[];
+ attr_accessor :estimated_delivery_dates
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::PredictBatchRequest` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'estimated_delivery_dates')
+ self.estimated_delivery_dates = attributes[:'estimated_delivery_dates']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'estimated_delivery_dates' => :'Array',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'estimated_delivery_dates' => :'estimated_delivery_dates',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/predict_batch_response.rb b/lib/aftership-tracking-sdk/models/predict_batch_response.rb
new file mode 100644
index 0000000..7f170dd
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/predict_batch_response.rb
@@ -0,0 +1,151 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class PredictBatchResponse
+ #
+ # estimated_delivery_dates: EstimatedDeliveryDateResponse[];
+ attr_accessor :estimated_delivery_dates
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::PredictBatchResponse` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'estimated_delivery_dates')
+ self.estimated_delivery_dates = attributes[:'estimated_delivery_dates']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'estimated_delivery_dates' => :'Array',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'estimated_delivery_dates' => :'estimated_delivery_dates',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/reason_events_checkpoint.rb b/lib/aftership-tracking-sdk/models/reason_events_checkpoint.rb
new file mode 100644
index 0000000..0bdac28
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/reason_events_checkpoint.rb
@@ -0,0 +1,151 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class ReasonEventsCheckpoint
+ # The code of the reason.
+ # code?: String;
+ attr_accessor :code
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::ReasonEventsCheckpoint` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'code')
+ self.code = attributes[:'code']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'code' => :'String',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'code' => :'code',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/slug_group_v1.rb b/lib/aftership-tracking-sdk/models/slug_group_v1.rb
new file mode 100644
index 0000000..99acc3f
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/slug_group_v1.rb
@@ -0,0 +1,37 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+
+module AftershipAPI::Model
+ class SlugGroupV1
+ AMAZON_GROUP = "amazon-group".freeze
+ FEDEX_GROUP = "fedex-group".freeze
+ TOLL_GROUP = "toll-group".freeze
+ TAQBIN_GROUP = "taqbin-group".freeze
+ TNT_GROUP = "tnt-group".freeze
+ CJ_GROUP = "cj-group".freeze
+ HERMES_GROUP = "hermes-group".freeze
+ DPD_GROUP = "dpd-group".freeze
+ GLS_GROUP = "gls-group".freeze
+ DHL_GROUP = "dhl-group".freeze
+ FASTWAY_GROUP = "fastway-group".freeze
+ ASENDIA_GROUP = "asendia-group".freeze
+ def self.all_vars
+ @all_vars ||= [AMAZON_GROUP, FEDEX_GROUP, TOLL_GROUP, TAQBIN_GROUP, TNT_GROUP, CJ_GROUP, HERMES_GROUP, DPD_GROUP, GLS_GROUP, DHL_GROUP, FASTWAY_GROUP, ASENDIA_GROUP,].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 SlugGroupV1.all_vars.include?(value)
+ raise "Invalid ENUM value #{value} for class #SlugGroupV1"
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/tag_v1.rb b/lib/aftership-tracking-sdk/models/tag_v1.rb
new file mode 100644
index 0000000..8a557d7
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/tag_v1.rb
@@ -0,0 +1,34 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+
+module AftershipAPI::Model
+ class TagV1
+ PENDING = "Pending".freeze
+ INFORECEIVED = "InfoReceived".freeze
+ INTRANSIT = "InTransit".freeze
+ OUTFORDELIVERY = "OutForDelivery".freeze
+ ATTEMPTFAIL = "AttemptFail".freeze
+ DELIVERED = "Delivered".freeze
+ AVAILABLEFORPICKUP = "AvailableForPickup".freeze
+ EXCEPTION = "Exception".freeze
+ EXPIRED = "Expired".freeze
+ def self.all_vars
+ @all_vars ||= [PENDING, INFORECEIVED, INTRANSIT, OUTFORDELIVERY, ATTEMPTFAIL, DELIVERED, AVAILABLEFORPICKUP, EXCEPTION, EXPIRED,].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 TagV1.all_vars.include?(value)
+ raise "Invalid ENUM value #{value} for class #TagV1"
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/tracking.rb b/lib/aftership-tracking-sdk/models/tracking.rb
new file mode 100644
index 0000000..2d9009d
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/tracking.rb
@@ -0,0 +1,921 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class Tracking
+ # Tracking ID.
+ # id?: String;
+ attr_accessor :id
+
+ # The date and time the shipment was imported or added to AfterShip. It uses the format `YYYY-MM-DDTHH:mm:ssZ` for the timezone GMT +0.
+ # created_at?: String;
+ attr_accessor :created_at
+
+ # The date and time the shipment was updated. It uses the format `YYYY-MM-DDTHH:mm:ssZ` for the timezone GMT +0.
+ # updated_at?: String;
+ attr_accessor :updated_at
+
+ # (Legacy) The date and time the shipment was updated. It uses the format `YYYY-MM-DDTHH:mm:ssZ` for the timezone GMT +0.
+ # last_updated_at?: String;
+ attr_accessor :last_updated_at
+
+ # Tracking number.
+ # tracking_number?: String;
+ attr_accessor :tracking_number
+
+ # Unique courier code. When importing a shipment with no courier slug and the tracking number can’t be recognized, the courier will be marked as `unrecognized`. Get courier codes .
+ # slug?: String;
+ attr_accessor :slug
+
+ # Whether or not AfterShip will continue tracking the shipments. Value is `false` when tag (status) is `Delivered`, `Expired`, or further updates for 30 days since last update.
+ # active?: Boolean;
+ attr_accessor :active
+
+ # Custom fields that accept an object with string field. In order to protect the privacy of your customers, do not include any in custom fields.
+ # custom_fields?: Object;
+ attr_accessor :custom_fields
+
+ # Customer name of the tracking.
+ # customer_name?: String;
+ attr_accessor :customer_name
+
+ # Total transit time in days.- For delivered shipments: Transit time (in days) = Delivered date - Pick-up date- For undelivered shipments: Transit time (in days) = Current date - Pick-up dateValue as `null` for the shipment without pick-up date.
+ # transit_time?: Integer;
+ attr_accessor :transit_time
+
+ # The for the origin country/region. E.g. USA for the United States.
+ # origin_country_iso3?: String;
+ attr_accessor :origin_country_iso3
+
+ # The state of the sender’s address.
+ # origin_state?: String;
+ attr_accessor :origin_state
+
+ # The city of the sender’s address.
+ # origin_city?: String;
+ attr_accessor :origin_city
+
+ # The postal code of the sender’s address.
+ # origin_postal_code?: String;
+ attr_accessor :origin_postal_code
+
+ # The sender address that the shipment is shipping from.
+ # origin_raw_location?: String;
+ attr_accessor :origin_raw_location
+
+ # The for the destination country/region. E.g. USA for the United States.
+ # destination_country_iso3?: String;
+ attr_accessor :destination_country_iso3
+
+ # The state of the recipient’s address.
+ # destination_state?: String;
+ attr_accessor :destination_state
+
+ # The city of the recipient’s address.
+ # destination_city?: String;
+ attr_accessor :destination_city
+
+ # The postal code of the recipient’s address.
+ # destination_postal_code?: String;
+ attr_accessor :destination_postal_code
+
+ # The shipping address that the shipment is shipping to.
+ # destination_raw_location?: String;
+ attr_accessor :destination_raw_location
+
+ # Destination country/region of the tracking detected from the courier. ISO Alpha-3 (three letters). Value will be `null` if the courier doesn't provide the destination country.
+ # courier_destination_country_iso3?: String;
+ attr_accessor :courier_destination_country_iso3
+
+ # Email address(es) to receive email notifications.
+ # emails?: String[];
+ attr_accessor :emails
+
+ # The estimated delivery date provided by the carrier. It uses the shipment recipient’s timezone and the format may differ depending on how the carrier provides it:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ
+ # expected_delivery?: String;
+ attr_accessor :expected_delivery
+
+ # Text field for the note.
+ # note?: String;
+ attr_accessor :note
+
+ # A globally-unique identifier for the order.
+ # order_id?: String;
+ attr_accessor :order_id
+
+ # The URL for the order in your system or store.
+ # order_id_path?: String;
+ attr_accessor :order_id_path
+
+ # The date and time the order was created in your system or store. It uses the format: `YYYY-MM-DDTHH:mm:ssZ` based on whichever timezone you provide.
+ # order_date?: String;
+ attr_accessor :order_date
+
+ # Number of packages under the tracking.
+ # shipment_package_count?: Float;
+ attr_accessor :shipment_package_count
+
+ # The date and time the shipment was picked up by the carrier. It uses the timezone where the pickup occured. The format may differ depending on how the carrier provides it:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ
+ # shipment_pickup_date?: String;
+ attr_accessor :shipment_pickup_date
+
+ # The date and time the shipment was delivered. It uses the shipment recipient’s timezone. The format may differ depending on how the carrier provides it:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ
+ # shipment_delivery_date?: String;
+ attr_accessor :shipment_delivery_date
+
+ # The carrier service type for the shipment.
+ # shipment_type?: String;
+ attr_accessor :shipment_type
+
+ # Shipment weight provied by carrier.
+ # shipment_weight?: Float;
+ attr_accessor :shipment_weight
+
+ # Weight unit provied by carrier.
+ # shipment_weight_unit?: String;
+ attr_accessor :shipment_weight_unit
+
+ # Signed by information for delivered shipment.
+ # signed_by?: String;
+ attr_accessor :signed_by
+
+ # The phone number(s) to receive sms notifications. Phone number should begin with `+` and `Area Code` before phone number. Comma separated for multiple values.
+ # smses?: String[];
+ attr_accessor :smses
+
+ # Source of how this tracking is added.
+ # source?: String;
+ attr_accessor :source
+
+ # Current status of tracking. (
+ # tag?: TagV1;
+ attr_accessor :tag
+
+ # Current subtag of tracking. (
+ # subtag?: String;
+ attr_accessor :subtag
+
+ # Normalized tracking message. (
+ # subtag_message?: String;
+ attr_accessor :subtag_message
+
+ # By default this field shows the `tracking_number`, but you can customize it as you wish with any info (e.g. the order number).
+ # title?: String;
+ attr_accessor :title
+
+ # Number of attempts AfterShip tracks at courier's system.
+ # tracked_count?: Float;
+ attr_accessor :tracked_count
+
+ # Indicates if the shipment is trackable till the final destination.Three possible values:- true- false- null
+ # last_mile_tracking_supported?: Boolean;
+ attr_accessor :last_mile_tracking_supported
+
+ # The recipient’s language. If you set up AfterShip notifications in different languages, we use this to send the recipient tracking updates in their preferred language.
+ # language?: String;
+ attr_accessor :language
+
+ # Deprecated
+ # unique_token?: String;
+ attr_accessor :unique_token
+
+ # Array of checkpoint object describes the checkpoint information.
+ # checkpoints?: Checkpoint[];
+ attr_accessor :checkpoints
+
+ # Phone number(s) subscribed to receive sms notifications. Comma separated for multiple values
+ # subscribed_smses?: String[];
+ attr_accessor :subscribed_smses
+
+ # Email address(es) subscribed to receive email notifications. Comma separated for multiple values
+ # subscribed_emails?: String[];
+ attr_accessor :subscribed_emails
+
+ # Whether or not the shipment is returned to sender. Value is `true` when any of its checkpoints has subtag `Exception_010` (returning to sender) or `Exception_011` (returned to sender). Otherwise value is `false`.
+ # return_to_sender?: Boolean;
+ attr_accessor :return_to_sender
+
+ # The promised delivery date of the order. It uses the format `YYYY-MM-DD`. This has no timezone and uses whatever date you provide.
+ # order_promised_delivery_date?: String;
+ attr_accessor :order_promised_delivery_date
+
+ # Shipment delivery type- pickup_at_store- pickup_at_courier- door_to_door
+ # delivery_type?: String;
+ attr_accessor :delivery_type
+
+ # Shipment pickup location for receiver
+ # pickup_location?: String;
+ attr_accessor :pickup_location
+
+ # Shipment pickup note for receiver
+ # pickup_note?: String;
+ attr_accessor :pickup_note
+
+ # Official tracking URL of the courier (if any). The language parameter of this link relies on the destination country/region and the language associated with the shipment, if the data regarding the destination country/region and language of the shipment is not available, AfterShip will set the language parameter of the link to "US" by default.
+ # courier_tracking_link?: String;
+ attr_accessor :courier_tracking_link
+
+ # The date and time of the carrier’s first attempt to deliver the package to the recipient. It uses the shipment recipient’s timezone. The format may differ depending on how the carrier provides it:- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ
+ # first_attempted_at?: String;
+ attr_accessor :first_attempted_at
+
+ # Delivery instructions (delivery date or address) can be modified by visiting the link if supported by a carrier. The language parameter of this link relies on the destination country/region and the language associated with the shipment, if the data regarding the destination country/region and language of the shipment is not available, AfterShip will set the language parameter of the link to "US" by default.
+ # courier_redirect_link?: String;
+ attr_accessor :courier_redirect_link
+
+ # Additional field required by some carriers to retrieve the tracking info. The shipper’s carrier account number. Refer to our article on for more details.
+ # tracking_account_number?: String;
+ attr_accessor :tracking_account_number
+
+ # Additional field required by some carriers to retrieve the tracking info. A type of tracking credential required by some carriers. Refer to our article on for more details.
+ # tracking_key?: String;
+ attr_accessor :tracking_key
+
+ # Additional field required by some carriers to retrieve the tracking info. The date the shipment was sent, using the format YYYYMMDD. Refer to our article on for more details.
+ # tracking_ship_date?: String;
+ attr_accessor :tracking_ship_date
+
+ # Whether the tracking is delivered on time or not.
+ # on_time_status?: String;
+ attr_accessor :on_time_status
+
+ # The difference days of the on time.
+ # on_time_difference?: Float;
+ attr_accessor :on_time_difference
+
+ # The tags of the order.
+ # order_tags?: String[];
+ attr_accessor :order_tags
+
+ # The estimated delivery date of the shipment provided by AfterShip’s AI and shown to the recipients. It uses the format `YYYY-MM-DD` based on the shipment recipient’s timezone.
+ # aftership_estimated_delivery_date?: AftershipEstimatedDeliveryDateTracking;
+ attr_accessor :aftership_estimated_delivery_date
+
+ # Estimated delivery time of the shipment based on your . It uses the format `YYYY-MM-DD` based on the shipment recipient’s timezone.
+ # custom_estimated_delivery_date?: CustomEstimatedDeliveryDateTracking;
+ attr_accessor :custom_estimated_delivery_date
+
+ # A unique, human-readable identifier for the order.
+ # order_number?: String;
+ attr_accessor :order_number
+
+ # The shipment’s original estimated delivery date. It could be provided by the carrier, AfterShip AI, or based on your custom settings. The format of carrier EDDs may differ depending on how the carrier provides it:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ AfterShip AI and custom EDDs always use the format `YYYY-MM-DD`. All EDDs use the shipment recipient’s timezone.
+ # first_estimated_delivery?: FirstEstimatedDeliveryTracking;
+ attr_accessor :first_estimated_delivery
+
+ # The most recently calculated estimated delivery date. It could be provided by the carrier, AfterShip AI, or based on your custom settings. The format of carrier EDDs may differ depending on how the carrier provides it:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ AfterShip AI and custom EDDs always use the format `YYYY-MM-DD`. All EDDs use the shipment recipient’s timezone.
+ # latest_estimated_delivery?: LatestEstimatedDeliveryTracking;
+ attr_accessor :latest_estimated_delivery
+
+ # Used to add tags to your shipments to help categorize and filter them easily.
+ # shipment_tags?: String[];
+ attr_accessor :shipment_tags
+
+ # If you have multiple accounts connected for a single carrier on AfterShip, we have introduced the courier_connection_id field to allow you to specify the carrier account associated with each shipment. By providing this information, you enable us to accurately track and monitor your shipments based on the correct carrier account.(In the event that you do not specify the courier_connection_id, we will handle your shipment using the connection that was created earliest among your connected accounts.
+ # courier_connection_id?: String;
+ attr_accessor :courier_connection_id
+
+ # The next couriers get the second carrier information from user or AfterShip.
+ # next_couriers?: NextCouriersTracking[];
+ attr_accessor :next_couriers
+
+ # (Legacy) Replaced by `origin_country_iso3`. Additional field required by some carriers to retrieve the tracking info. The origin country/region of the shipment. Refer to our article on for more details.
+ # tracking_origin_country?: String;
+ attr_accessor :tracking_origin_country
+
+ # (Legacy) Replaced by `destination_country_iso3`. Additional field required by some carriers to retrieve the tracking info. The destination country/region of the shipment. Refer to our article on for more details.
+ # tracking_destination_country?: String;
+ attr_accessor :tracking_destination_country
+
+ # (Legacy) Replaced by `destination_postal_code`. Additional field required by some carriers to retrieve the tracking info. The postal code of the recipient’s address. Refer to our article on for more details.
+ # tracking_postal_code?: String;
+ attr_accessor :tracking_postal_code
+
+ # (Legacy) Replaced by `destination_state`. Additional field required by some carriers to retrieve the tracking info. The state/province of the recipient’s address. Refer to our article on for more details.
+ # tracking_state?: String;
+ attr_accessor :tracking_state
+
+ # The model contains the total amount of carbon emissions generated by the shipment. - AfterShip will provide this data only when it is available, and its availability is contingent upon the location and weight information that AfterShip can obtain.- The values will be accessible solely for shipments that have been successfully delivered. However, in the event of a shipping update after the delivery status has been achieved, the value may change.- It’s a paid service and only for Tracking Enterprise users, please contact your customer success manager if you want to know more.
+ # carbon_emissions?: CarbonEmissionsTracking;
+ attr_accessor :carbon_emissions
+
+ # The location_id refers to the place where you fulfilled the items. - If you provide a location_id, the system will automatically use it as the tracking's origin address. However, passing both location_id and any origin address information simultaneously is not allowed.- Please make sure you add your locations .
+ # location_id?: String;
+ attr_accessor :location_id
+
+ # The shipping_method string refers to the chosen method for delivering the package. Merchants typically offer various shipping methods to consumers during the checkout process, such as, Local Delivery, Free Express Worldwide Shipping, etc.
+ # shipping_method?: String;
+ attr_accessor :shipping_method
+
+ # By dynamically tracking failed delivery attempts during shipment, this field allows you to pinpoint carriers accountable for the most failures. Analyzing the root cause of these failures enables you to improve carriers' delivery standard operating procedures (SOP), leading to an overall enhancement in delivery service quality.
+ # failed_delivery_attempts?: Integer;
+ attr_accessor :failed_delivery_attempts
+
+ # The signature_requirement field serves the purpose of validating the service option type, specifically proof of delivery. By collecting the recipient's signature upon delivery, it ensures the package reaches the intended recipient and prevents disputes related to non-delivery or lost packages.
+ # signature_requirement?: String;
+ attr_accessor :signature_requirement
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::Tracking` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'id')
+ self.id = attributes[:'id']
+ end
+
+ if attributes.key?(:'created_at')
+ self.created_at = attributes[:'created_at']
+ end
+
+ if attributes.key?(:'updated_at')
+ self.updated_at = attributes[:'updated_at']
+ end
+
+ if attributes.key?(:'last_updated_at')
+ self.last_updated_at = attributes[:'last_updated_at']
+ end
+
+ if attributes.key?(:'tracking_number')
+ self.tracking_number = attributes[:'tracking_number']
+ end
+
+ if attributes.key?(:'slug')
+ self.slug = attributes[:'slug']
+ end
+
+ if attributes.key?(:'active')
+ self.active = attributes[:'active']
+ end
+
+ if attributes.key?(:'custom_fields')
+ self.custom_fields = attributes[:'custom_fields']
+ end
+
+ if attributes.key?(:'customer_name')
+ self.customer_name = attributes[:'customer_name']
+ end
+
+ if attributes.key?(:'transit_time')
+ self.transit_time = attributes[:'transit_time']
+ end
+
+ if attributes.key?(:'origin_country_iso3')
+ self.origin_country_iso3 = attributes[:'origin_country_iso3']
+ end
+
+ if attributes.key?(:'origin_state')
+ self.origin_state = attributes[:'origin_state']
+ end
+
+ if attributes.key?(:'origin_city')
+ self.origin_city = attributes[:'origin_city']
+ end
+
+ if attributes.key?(:'origin_postal_code')
+ self.origin_postal_code = attributes[:'origin_postal_code']
+ end
+
+ if attributes.key?(:'origin_raw_location')
+ self.origin_raw_location = attributes[:'origin_raw_location']
+ end
+
+ if attributes.key?(:'destination_country_iso3')
+ self.destination_country_iso3 = attributes[:'destination_country_iso3']
+ end
+
+ if attributes.key?(:'destination_state')
+ self.destination_state = attributes[:'destination_state']
+ end
+
+ if attributes.key?(:'destination_city')
+ self.destination_city = attributes[:'destination_city']
+ end
+
+ if attributes.key?(:'destination_postal_code')
+ self.destination_postal_code = attributes[:'destination_postal_code']
+ end
+
+ if attributes.key?(:'destination_raw_location')
+ self.destination_raw_location = attributes[:'destination_raw_location']
+ end
+
+ if attributes.key?(:'courier_destination_country_iso3')
+ self.courier_destination_country_iso3 = attributes[:'courier_destination_country_iso3']
+ end
+
+ if attributes.key?(:'emails')
+ self.emails = attributes[:'emails']
+ end
+
+ if attributes.key?(:'expected_delivery')
+ self.expected_delivery = attributes[:'expected_delivery']
+ end
+
+ if attributes.key?(:'note')
+ self.note = attributes[:'note']
+ end
+
+ if attributes.key?(:'order_id')
+ self.order_id = attributes[:'order_id']
+ end
+
+ if attributes.key?(:'order_id_path')
+ self.order_id_path = attributes[:'order_id_path']
+ end
+
+ if attributes.key?(:'order_date')
+ self.order_date = attributes[:'order_date']
+ end
+
+ if attributes.key?(:'shipment_package_count')
+ self.shipment_package_count = attributes[:'shipment_package_count']
+ end
+
+ if attributes.key?(:'shipment_pickup_date')
+ self.shipment_pickup_date = attributes[:'shipment_pickup_date']
+ end
+
+ if attributes.key?(:'shipment_delivery_date')
+ self.shipment_delivery_date = attributes[:'shipment_delivery_date']
+ end
+
+ if attributes.key?(:'shipment_type')
+ self.shipment_type = attributes[:'shipment_type']
+ end
+
+ if attributes.key?(:'shipment_weight')
+ self.shipment_weight = attributes[:'shipment_weight']
+ end
+
+ if attributes.key?(:'shipment_weight_unit')
+ self.shipment_weight_unit = attributes[:'shipment_weight_unit']
+ end
+
+ if attributes.key?(:'signed_by')
+ self.signed_by = attributes[:'signed_by']
+ end
+
+ if attributes.key?(:'smses')
+ self.smses = attributes[:'smses']
+ end
+
+ if attributes.key?(:'source')
+ self.source = attributes[:'source']
+ end
+
+ if attributes.key?(:'tag')
+ self.tag = attributes[:'tag']
+ end
+
+ if attributes.key?(:'subtag')
+ self.subtag = attributes[:'subtag']
+ end
+
+ if attributes.key?(:'subtag_message')
+ self.subtag_message = attributes[:'subtag_message']
+ end
+
+ if attributes.key?(:'title')
+ self.title = attributes[:'title']
+ end
+
+ if attributes.key?(:'tracked_count')
+ self.tracked_count = attributes[:'tracked_count']
+ end
+
+ if attributes.key?(:'last_mile_tracking_supported')
+ self.last_mile_tracking_supported = attributes[:'last_mile_tracking_supported']
+ end
+
+ if attributes.key?(:'language')
+ self.language = attributes[:'language']
+ end
+
+ if attributes.key?(:'unique_token')
+ self.unique_token = attributes[:'unique_token']
+ end
+
+ if attributes.key?(:'checkpoints')
+ self.checkpoints = attributes[:'checkpoints']
+ end
+
+ if attributes.key?(:'subscribed_smses')
+ self.subscribed_smses = attributes[:'subscribed_smses']
+ end
+
+ if attributes.key?(:'subscribed_emails')
+ self.subscribed_emails = attributes[:'subscribed_emails']
+ end
+
+ if attributes.key?(:'return_to_sender')
+ self.return_to_sender = attributes[:'return_to_sender']
+ end
+
+ if attributes.key?(:'order_promised_delivery_date')
+ self.order_promised_delivery_date = attributes[:'order_promised_delivery_date']
+ end
+
+ if attributes.key?(:'delivery_type')
+ self.delivery_type = attributes[:'delivery_type']
+ end
+
+ if attributes.key?(:'pickup_location')
+ self.pickup_location = attributes[:'pickup_location']
+ end
+
+ if attributes.key?(:'pickup_note')
+ self.pickup_note = attributes[:'pickup_note']
+ end
+
+ if attributes.key?(:'courier_tracking_link')
+ self.courier_tracking_link = attributes[:'courier_tracking_link']
+ end
+
+ if attributes.key?(:'first_attempted_at')
+ self.first_attempted_at = attributes[:'first_attempted_at']
+ end
+
+ if attributes.key?(:'courier_redirect_link')
+ self.courier_redirect_link = attributes[:'courier_redirect_link']
+ end
+
+ if attributes.key?(:'tracking_account_number')
+ self.tracking_account_number = attributes[:'tracking_account_number']
+ end
+
+ if attributes.key?(:'tracking_key')
+ self.tracking_key = attributes[:'tracking_key']
+ end
+
+ if attributes.key?(:'tracking_ship_date')
+ self.tracking_ship_date = attributes[:'tracking_ship_date']
+ end
+
+ if attributes.key?(:'on_time_status')
+ self.on_time_status = attributes[:'on_time_status']
+ end
+
+ if attributes.key?(:'on_time_difference')
+ self.on_time_difference = attributes[:'on_time_difference']
+ end
+
+ if attributes.key?(:'order_tags')
+ self.order_tags = attributes[:'order_tags']
+ end
+
+ if attributes.key?(:'aftership_estimated_delivery_date')
+ self.aftership_estimated_delivery_date = attributes[:'aftership_estimated_delivery_date']
+ end
+
+ if attributes.key?(:'custom_estimated_delivery_date')
+ self.custom_estimated_delivery_date = attributes[:'custom_estimated_delivery_date']
+ end
+
+ if attributes.key?(:'order_number')
+ self.order_number = attributes[:'order_number']
+ end
+
+ if attributes.key?(:'first_estimated_delivery')
+ self.first_estimated_delivery = attributes[:'first_estimated_delivery']
+ end
+
+ if attributes.key?(:'latest_estimated_delivery')
+ self.latest_estimated_delivery = attributes[:'latest_estimated_delivery']
+ end
+
+ if attributes.key?(:'shipment_tags')
+ self.shipment_tags = attributes[:'shipment_tags']
+ end
+
+ if attributes.key?(:'courier_connection_id')
+ self.courier_connection_id = attributes[:'courier_connection_id']
+ end
+
+ if attributes.key?(:'next_couriers')
+ self.next_couriers = attributes[:'next_couriers']
+ end
+
+ if attributes.key?(:'tracking_origin_country')
+ self.tracking_origin_country = attributes[:'tracking_origin_country']
+ end
+
+ if attributes.key?(:'tracking_destination_country')
+ self.tracking_destination_country = attributes[:'tracking_destination_country']
+ end
+
+ if attributes.key?(:'tracking_postal_code')
+ self.tracking_postal_code = attributes[:'tracking_postal_code']
+ end
+
+ if attributes.key?(:'tracking_state')
+ self.tracking_state = attributes[:'tracking_state']
+ end
+
+ if attributes.key?(:'carbon_emissions')
+ self.carbon_emissions = attributes[:'carbon_emissions']
+ end
+
+ if attributes.key?(:'location_id')
+ self.location_id = attributes[:'location_id']
+ end
+
+ if attributes.key?(:'shipping_method')
+ self.shipping_method = attributes[:'shipping_method']
+ end
+
+ if attributes.key?(:'failed_delivery_attempts')
+ self.failed_delivery_attempts = attributes[:'failed_delivery_attempts']
+ end
+
+ if attributes.key?(:'signature_requirement')
+ self.signature_requirement = attributes[:'signature_requirement']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'id' => :'String',
+ :'created_at' => :'String',
+ :'updated_at' => :'String',
+ :'last_updated_at' => :'String',
+ :'tracking_number' => :'String',
+ :'slug' => :'String',
+ :'active' => :'Boolean',
+ :'custom_fields' => :'Object',
+ :'customer_name' => :'String',
+ :'transit_time' => :'Integer',
+ :'origin_country_iso3' => :'String',
+ :'origin_state' => :'String',
+ :'origin_city' => :'String',
+ :'origin_postal_code' => :'String',
+ :'origin_raw_location' => :'String',
+ :'destination_country_iso3' => :'String',
+ :'destination_state' => :'String',
+ :'destination_city' => :'String',
+ :'destination_postal_code' => :'String',
+ :'destination_raw_location' => :'String',
+ :'courier_destination_country_iso3' => :'String',
+ :'emails' => :'Array',
+ :'expected_delivery' => :'String',
+ :'note' => :'String',
+ :'order_id' => :'String',
+ :'order_id_path' => :'String',
+ :'order_date' => :'String',
+ :'shipment_package_count' => :'Float',
+ :'shipment_pickup_date' => :'String',
+ :'shipment_delivery_date' => :'String',
+ :'shipment_type' => :'String',
+ :'shipment_weight' => :'Float',
+ :'shipment_weight_unit' => :'String',
+ :'signed_by' => :'String',
+ :'smses' => :'Array',
+ :'source' => :'String',
+ :'tag' => :'TagV1',
+ :'subtag' => :'String',
+ :'subtag_message' => :'String',
+ :'title' => :'String',
+ :'tracked_count' => :'Float',
+ :'last_mile_tracking_supported' => :'Boolean',
+ :'language' => :'String',
+ :'unique_token' => :'String',
+ :'checkpoints' => :'Array',
+ :'subscribed_smses' => :'Array',
+ :'subscribed_emails' => :'Array',
+ :'return_to_sender' => :'Boolean',
+ :'order_promised_delivery_date' => :'String',
+ :'delivery_type' => :'String',
+ :'pickup_location' => :'String',
+ :'pickup_note' => :'String',
+ :'courier_tracking_link' => :'String',
+ :'first_attempted_at' => :'String',
+ :'courier_redirect_link' => :'String',
+ :'tracking_account_number' => :'String',
+ :'tracking_key' => :'String',
+ :'tracking_ship_date' => :'String',
+ :'on_time_status' => :'String',
+ :'on_time_difference' => :'Float',
+ :'order_tags' => :'Array',
+ :'aftership_estimated_delivery_date' => :'AftershipEstimatedDeliveryDateTracking',
+ :'custom_estimated_delivery_date' => :'CustomEstimatedDeliveryDateTracking',
+ :'order_number' => :'String',
+ :'first_estimated_delivery' => :'FirstEstimatedDeliveryTracking',
+ :'latest_estimated_delivery' => :'LatestEstimatedDeliveryTracking',
+ :'shipment_tags' => :'Array',
+ :'courier_connection_id' => :'String',
+ :'next_couriers' => :'Array',
+ :'tracking_origin_country' => :'String',
+ :'tracking_destination_country' => :'String',
+ :'tracking_postal_code' => :'String',
+ :'tracking_state' => :'String',
+ :'carbon_emissions' => :'CarbonEmissionsTracking',
+ :'location_id' => :'String',
+ :'shipping_method' => :'String',
+ :'failed_delivery_attempts' => :'Integer',
+ :'signature_requirement' => :'String',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'id' => :'id',
+ :'created_at' => :'created_at',
+ :'updated_at' => :'updated_at',
+ :'last_updated_at' => :'last_updated_at',
+ :'tracking_number' => :'tracking_number',
+ :'slug' => :'slug',
+ :'active' => :'active',
+ :'custom_fields' => :'custom_fields',
+ :'customer_name' => :'customer_name',
+ :'transit_time' => :'transit_time',
+ :'origin_country_iso3' => :'origin_country_iso3',
+ :'origin_state' => :'origin_state',
+ :'origin_city' => :'origin_city',
+ :'origin_postal_code' => :'origin_postal_code',
+ :'origin_raw_location' => :'origin_raw_location',
+ :'destination_country_iso3' => :'destination_country_iso3',
+ :'destination_state' => :'destination_state',
+ :'destination_city' => :'destination_city',
+ :'destination_postal_code' => :'destination_postal_code',
+ :'destination_raw_location' => :'destination_raw_location',
+ :'courier_destination_country_iso3' => :'courier_destination_country_iso3',
+ :'emails' => :'emails',
+ :'expected_delivery' => :'expected_delivery',
+ :'note' => :'note',
+ :'order_id' => :'order_id',
+ :'order_id_path' => :'order_id_path',
+ :'order_date' => :'order_date',
+ :'shipment_package_count' => :'shipment_package_count',
+ :'shipment_pickup_date' => :'shipment_pickup_date',
+ :'shipment_delivery_date' => :'shipment_delivery_date',
+ :'shipment_type' => :'shipment_type',
+ :'shipment_weight' => :'shipment_weight',
+ :'shipment_weight_unit' => :'shipment_weight_unit',
+ :'signed_by' => :'signed_by',
+ :'smses' => :'smses',
+ :'source' => :'source',
+ :'tag' => :'tag',
+ :'subtag' => :'subtag',
+ :'subtag_message' => :'subtag_message',
+ :'title' => :'title',
+ :'tracked_count' => :'tracked_count',
+ :'last_mile_tracking_supported' => :'last_mile_tracking_supported',
+ :'language' => :'language',
+ :'unique_token' => :'unique_token',
+ :'checkpoints' => :'checkpoints',
+ :'subscribed_smses' => :'subscribed_smses',
+ :'subscribed_emails' => :'subscribed_emails',
+ :'return_to_sender' => :'return_to_sender',
+ :'order_promised_delivery_date' => :'order_promised_delivery_date',
+ :'delivery_type' => :'delivery_type',
+ :'pickup_location' => :'pickup_location',
+ :'pickup_note' => :'pickup_note',
+ :'courier_tracking_link' => :'courier_tracking_link',
+ :'first_attempted_at' => :'first_attempted_at',
+ :'courier_redirect_link' => :'courier_redirect_link',
+ :'tracking_account_number' => :'tracking_account_number',
+ :'tracking_key' => :'tracking_key',
+ :'tracking_ship_date' => :'tracking_ship_date',
+ :'on_time_status' => :'on_time_status',
+ :'on_time_difference' => :'on_time_difference',
+ :'order_tags' => :'order_tags',
+ :'aftership_estimated_delivery_date' => :'aftership_estimated_delivery_date',
+ :'custom_estimated_delivery_date' => :'custom_estimated_delivery_date',
+ :'order_number' => :'order_number',
+ :'first_estimated_delivery' => :'first_estimated_delivery',
+ :'latest_estimated_delivery' => :'latest_estimated_delivery',
+ :'shipment_tags' => :'shipment_tags',
+ :'courier_connection_id' => :'courier_connection_id',
+ :'next_couriers' => :'next_couriers',
+ :'tracking_origin_country' => :'tracking_origin_country',
+ :'tracking_destination_country' => :'tracking_destination_country',
+ :'tracking_postal_code' => :'tracking_postal_code',
+ :'tracking_state' => :'tracking_state',
+ :'carbon_emissions' => :'carbon_emissions',
+ :'location_id' => :'location_id',
+ :'shipping_method' => :'shipping_method',
+ :'failed_delivery_attempts' => :'failed_delivery_attempts',
+ :'signature_requirement' => :'signature_requirement',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/tracking_create_tracking_request.rb b/lib/aftership-tracking-sdk/models/tracking_create_tracking_request.rb
new file mode 100644
index 0000000..cff8c12
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/tracking_create_tracking_request.rb
@@ -0,0 +1,551 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class TrackingCreateTrackingRequest
+ # Tracking number of a shipment.Duplicated tracking numbers, tracking numbers with invalid tracking number format will not be accepted.We only accept tracking numbers with length from 4 to 100We currently support the following characters in a tracking number:- A - Z- 0 - 9- `-` (Hyphen)- . (Period)- _ (Underscore)- / (Slash)
+ # tracking_number: String;
+ attr_accessor :tracking_number
+
+ # Unique courier code. Get courier codes .
+ # slug?: String;
+ attr_accessor :slug
+
+ # By default this field shows the `tracking_number`, but you can customize it as you wish with any info (e.g. the order number).
+ # title?: String;
+ attr_accessor :title
+
+ # A globally-unique identifier for the order.
+ # order_id?: String;
+ attr_accessor :order_id
+
+ # The URL for the order in your system or store.
+ # order_id_path?: String;
+ attr_accessor :order_id_path
+
+ # Custom fields that accept an object with string field. In order to protect the privacy of your customers, do not include any
+ # custom_fields?: Object;
+ attr_accessor :custom_fields
+
+ # The recipient’s language. If you set up AfterShip notifications in different languages, we use this to send the recipient tracking updates in their preferred language. Use an to specify the language.
+ # language?: String;
+ attr_accessor :language
+
+ # The promised delivery date of the order. It uses the format YYYY-MM-DD. This has no timezone and uses whatever date you provide. Since other EDDs use the shipment recipient’s timezone, we suggest following the same logic here.
+ # order_promised_delivery_date?: String;
+ attr_accessor :order_promised_delivery_date
+
+ # Shipment delivery type- pickup_at_store- pickup_at_courier- door_to_door
+ # delivery_type?: String;
+ attr_accessor :delivery_type
+
+ # Shipment pickup location for receiver
+ # pickup_location?: String;
+ attr_accessor :pickup_location
+
+ # Shipment pickup note for receiver
+ # pickup_note?: String;
+ attr_accessor :pickup_note
+
+ # Additional field required by some carriers to retrieve the tracking info. The shipper’s carrier account number. Refer to our article on for more details.
+ # tracking_account_number?: String;
+ attr_accessor :tracking_account_number
+
+ # Additional field required by some carriers to retrieve the tracking info. A type of tracking credential required by some carriers. Refer to our article on for more details.
+ # tracking_key?: String;
+ attr_accessor :tracking_key
+
+ # Additional field required by some carriers to retrieve the tracking info. The date the shipment was sent, using the format YYYYMMDD. Refer to our article on for more details.
+ # tracking_ship_date?: String;
+ attr_accessor :tracking_ship_date
+
+ # Email address(es) to receive email notifications. Accept either array or comma separated as input. Supports up to 3 email addresses.
+ # emails?: String[];
+ attr_accessor :emails
+
+ # The phone number(s) to receive sms notifications. Enter `+` andarea `code before` phone number. Accept either array or comma separated as input. Supports up to 3 phone numbers.
+ # smses?: String[];
+ attr_accessor :smses
+
+ # Customer name of the tracking.
+ # customer_name?: String;
+ attr_accessor :customer_name
+
+ # The for more details.
+ # origin_country_iso3?: String;
+ attr_accessor :origin_country_iso3
+
+ # The state of the sender’s address. This can help AfterShip with various functions like tracking, carrier auto-detection and auto-correction, calculating an EDD, etc.
+ # origin_state?: String;
+ attr_accessor :origin_state
+
+ # The city of the sender’s address. This can help AfterShip with various functions like tracking, carrier auto-detection and auto-correction, calculating an EDD, etc.
+ # origin_city?: String;
+ attr_accessor :origin_city
+
+ # The postal of the sender’s address. This can help AfterShip with various functions like tracking, carrier auto-detection and auto-correction, calculating an EDD, etc.
+ # origin_postal_code?: String;
+ attr_accessor :origin_postal_code
+
+ # The sender address that the shipment is shipping from. This can help AfterShip with various functions like tracking, carrier auto-detection and auto-correction, calculating an EDD, etc.
+ # origin_raw_location?: String;
+ attr_accessor :origin_raw_location
+
+ # The for more details.
+ # destination_country_iso3?: String;
+ attr_accessor :destination_country_iso3
+
+ # The state of the recipient’s address. This can help AfterShip with various functions like tracking, carrier auto-detection and auto-correction, calculating an EDD, etc. Also the additional field required by some carriers to retrieve the tracking info. The state/province of the recipient’s address. Refer to our article on for more details.
+ # destination_state?: String;
+ attr_accessor :destination_state
+
+ # The city of the recipient’s address. This can help AfterShip with various functions like tracking, carrier auto-detection and auto-correction, calculating an EDD, etc.
+ # destination_city?: String;
+ attr_accessor :destination_city
+
+ # The postal of the recipient’s address. This can help AfterShip with various functions like tracking, carrier auto-detection and auto-correction, calculating an EDD, etc. Also the additional field required by some carriers to retrieve the tracking info. The postal code of the recipient’s address. Refer to our article on for more details.
+ # destination_postal_code?: String;
+ attr_accessor :destination_postal_code
+
+ # The shipping address that the shipment is shipping to. This can help AfterShip with various functions like tracking, carrier auto-detection and auto-correction, calculating an EDD, etc.
+ # destination_raw_location?: String;
+ attr_accessor :destination_raw_location
+
+ # Text field for the note
+ # note?: String;
+ attr_accessor :note
+
+ # Slug group is a group of slugs which belong to same courier. For example, when you inpit "fedex-group" as slug_group, AfterShip will detect the tracking with "fedex-uk", "fedex-fims", and other slugs which belong to "fedex". It cannot be used with slug at the same time. (
+ # slug_group?: SlugGroupV1;
+ attr_accessor :slug_group
+
+ # Order date in YYYY-MM-DDTHH:mm:ssZ format. e.g. 2021-07-26T11:23:51-05:00
+ # order_date?: String;
+ attr_accessor :order_date
+
+ # A unique, human-readable identifier for the order.
+ # order_number?: String;
+ attr_accessor :order_number
+
+ # The carrier service type for the shipment. If you provide info for this field, AfterShip will not update it with info from the carrier.
+ # shipment_type?: String;
+ attr_accessor :shipment_type
+
+ # Used to add tags to your shipments to help categorize and filter them easily.
+ # shipment_tags?: String[];
+ attr_accessor :shipment_tags
+
+ # If you’ve connected multiple accounts for a single carrier on AfterShip, you can now use the courier_connection_id field to tell AfterShip which carrier account you’ve used to handle a shipment so we can track it. (
+ # courier_connection_id?: String;
+ attr_accessor :courier_connection_id
+
+ # If a shipment has multiple carriers, you can use the next_couriers field to tell AfterShip who the second carrier is. This is useful if the first carrier does not send us this information.
+ # next_couriers?: NextCouriersTrackingCreateTrackingRequest[];
+ attr_accessor :next_couriers
+
+ # (Legacy) Replaced by `origin_country_iso3`. Additional field required by some carriers to retrieve the tracking info. The origin country/region of the shipment. Refer to our article on for more details.
+ # tracking_origin_country?: String;
+ attr_accessor :tracking_origin_country
+
+ # (Legacy) Replaced by `destination_country_iso3`. Additional field required by some carriers to retrieve the tracking info. The destination country/region of the shipment. Refer to our article on for more details.
+ # tracking_destination_country?: String;
+ attr_accessor :tracking_destination_country
+
+ # (Legacy) Replaced by `destination_postal_code`. Additional field required by some carriers to retrieve the tracking info. The postal code of the recipient’s address. Refer to our article on for more details.
+ # tracking_postal_code?: String;
+ attr_accessor :tracking_postal_code
+
+ # (Legacy) Replaced by `destination_state`. Additional field required by some carriers to retrieve the tracking info. The state/province of the recipient’s address. Refer to our article on for more details.
+ # tracking_state?: String;
+ attr_accessor :tracking_state
+
+ # The location_id refers to the place where you fulfilled the items. - If you provide a location_id, the system will automatically use it as the tracking's origin address. However, passing both location_id and any origin address information simultaneously is not allowed.- Please make sure you add your locations .
+ # location_id?: String;
+ attr_accessor :location_id
+
+ # The shipping_method string refers to the chosen method for delivering the package. Merchants typically offer various shipping methods to consumers during the checkout process, such as, Local Delivery, Free Express Worldwide Shipping, etc
+ # shipping_method?: String;
+ attr_accessor :shipping_method
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::TrackingCreateTrackingRequest` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'tracking_number')
+ self.tracking_number = attributes[:'tracking_number']
+ end
+
+ if attributes.key?(:'slug')
+ self.slug = attributes[:'slug']
+ end
+
+ if attributes.key?(:'title')
+ self.title = attributes[:'title']
+ end
+
+ if attributes.key?(:'order_id')
+ self.order_id = attributes[:'order_id']
+ end
+
+ if attributes.key?(:'order_id_path')
+ self.order_id_path = attributes[:'order_id_path']
+ end
+
+ if attributes.key?(:'custom_fields')
+ self.custom_fields = attributes[:'custom_fields']
+ end
+
+ if attributes.key?(:'language')
+ self.language = attributes[:'language']
+ end
+
+ if attributes.key?(:'order_promised_delivery_date')
+ self.order_promised_delivery_date = attributes[:'order_promised_delivery_date']
+ end
+
+ if attributes.key?(:'delivery_type')
+ self.delivery_type = attributes[:'delivery_type']
+ end
+
+ if attributes.key?(:'pickup_location')
+ self.pickup_location = attributes[:'pickup_location']
+ end
+
+ if attributes.key?(:'pickup_note')
+ self.pickup_note = attributes[:'pickup_note']
+ end
+
+ if attributes.key?(:'tracking_account_number')
+ self.tracking_account_number = attributes[:'tracking_account_number']
+ end
+
+ if attributes.key?(:'tracking_key')
+ self.tracking_key = attributes[:'tracking_key']
+ end
+
+ if attributes.key?(:'tracking_ship_date')
+ self.tracking_ship_date = attributes[:'tracking_ship_date']
+ end
+
+ if attributes.key?(:'emails')
+ self.emails = attributes[:'emails']
+ end
+
+ if attributes.key?(:'smses')
+ self.smses = attributes[:'smses']
+ end
+
+ if attributes.key?(:'customer_name')
+ self.customer_name = attributes[:'customer_name']
+ end
+
+ if attributes.key?(:'origin_country_iso3')
+ self.origin_country_iso3 = attributes[:'origin_country_iso3']
+ end
+
+ if attributes.key?(:'origin_state')
+ self.origin_state = attributes[:'origin_state']
+ end
+
+ if attributes.key?(:'origin_city')
+ self.origin_city = attributes[:'origin_city']
+ end
+
+ if attributes.key?(:'origin_postal_code')
+ self.origin_postal_code = attributes[:'origin_postal_code']
+ end
+
+ if attributes.key?(:'origin_raw_location')
+ self.origin_raw_location = attributes[:'origin_raw_location']
+ end
+
+ if attributes.key?(:'destination_country_iso3')
+ self.destination_country_iso3 = attributes[:'destination_country_iso3']
+ end
+
+ if attributes.key?(:'destination_state')
+ self.destination_state = attributes[:'destination_state']
+ end
+
+ if attributes.key?(:'destination_city')
+ self.destination_city = attributes[:'destination_city']
+ end
+
+ if attributes.key?(:'destination_postal_code')
+ self.destination_postal_code = attributes[:'destination_postal_code']
+ end
+
+ if attributes.key?(:'destination_raw_location')
+ self.destination_raw_location = attributes[:'destination_raw_location']
+ end
+
+ if attributes.key?(:'note')
+ self.note = attributes[:'note']
+ end
+
+ if attributes.key?(:'slug_group')
+ self.slug_group = attributes[:'slug_group']
+ end
+
+ if attributes.key?(:'order_date')
+ self.order_date = attributes[:'order_date']
+ end
+
+ if attributes.key?(:'order_number')
+ self.order_number = attributes[:'order_number']
+ end
+
+ if attributes.key?(:'shipment_type')
+ self.shipment_type = attributes[:'shipment_type']
+ end
+
+ if attributes.key?(:'shipment_tags')
+ self.shipment_tags = attributes[:'shipment_tags']
+ end
+
+ if attributes.key?(:'courier_connection_id')
+ self.courier_connection_id = attributes[:'courier_connection_id']
+ end
+
+ if attributes.key?(:'next_couriers')
+ self.next_couriers = attributes[:'next_couriers']
+ end
+
+ if attributes.key?(:'tracking_origin_country')
+ self.tracking_origin_country = attributes[:'tracking_origin_country']
+ end
+
+ if attributes.key?(:'tracking_destination_country')
+ self.tracking_destination_country = attributes[:'tracking_destination_country']
+ end
+
+ if attributes.key?(:'tracking_postal_code')
+ self.tracking_postal_code = attributes[:'tracking_postal_code']
+ end
+
+ if attributes.key?(:'tracking_state')
+ self.tracking_state = attributes[:'tracking_state']
+ end
+
+ if attributes.key?(:'location_id')
+ self.location_id = attributes[:'location_id']
+ end
+
+ if attributes.key?(:'shipping_method')
+ self.shipping_method = attributes[:'shipping_method']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'tracking_number' => :'String',
+ :'slug' => :'String',
+ :'title' => :'String',
+ :'order_id' => :'String',
+ :'order_id_path' => :'String',
+ :'custom_fields' => :'Object',
+ :'language' => :'String',
+ :'order_promised_delivery_date' => :'String',
+ :'delivery_type' => :'String',
+ :'pickup_location' => :'String',
+ :'pickup_note' => :'String',
+ :'tracking_account_number' => :'String',
+ :'tracking_key' => :'String',
+ :'tracking_ship_date' => :'String',
+ :'emails' => :'Array',
+ :'smses' => :'Array',
+ :'customer_name' => :'String',
+ :'origin_country_iso3' => :'String',
+ :'origin_state' => :'String',
+ :'origin_city' => :'String',
+ :'origin_postal_code' => :'String',
+ :'origin_raw_location' => :'String',
+ :'destination_country_iso3' => :'String',
+ :'destination_state' => :'String',
+ :'destination_city' => :'String',
+ :'destination_postal_code' => :'String',
+ :'destination_raw_location' => :'String',
+ :'note' => :'String',
+ :'slug_group' => :'SlugGroupV1',
+ :'order_date' => :'String',
+ :'order_number' => :'String',
+ :'shipment_type' => :'String',
+ :'shipment_tags' => :'Array',
+ :'courier_connection_id' => :'String',
+ :'next_couriers' => :'Array',
+ :'tracking_origin_country' => :'String',
+ :'tracking_destination_country' => :'String',
+ :'tracking_postal_code' => :'String',
+ :'tracking_state' => :'String',
+ :'location_id' => :'String',
+ :'shipping_method' => :'String',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'tracking_number' => :'tracking_number',
+ :'slug' => :'slug',
+ :'title' => :'title',
+ :'order_id' => :'order_id',
+ :'order_id_path' => :'order_id_path',
+ :'custom_fields' => :'custom_fields',
+ :'language' => :'language',
+ :'order_promised_delivery_date' => :'order_promised_delivery_date',
+ :'delivery_type' => :'delivery_type',
+ :'pickup_location' => :'pickup_location',
+ :'pickup_note' => :'pickup_note',
+ :'tracking_account_number' => :'tracking_account_number',
+ :'tracking_key' => :'tracking_key',
+ :'tracking_ship_date' => :'tracking_ship_date',
+ :'emails' => :'emails',
+ :'smses' => :'smses',
+ :'customer_name' => :'customer_name',
+ :'origin_country_iso3' => :'origin_country_iso3',
+ :'origin_state' => :'origin_state',
+ :'origin_city' => :'origin_city',
+ :'origin_postal_code' => :'origin_postal_code',
+ :'origin_raw_location' => :'origin_raw_location',
+ :'destination_country_iso3' => :'destination_country_iso3',
+ :'destination_state' => :'destination_state',
+ :'destination_city' => :'destination_city',
+ :'destination_postal_code' => :'destination_postal_code',
+ :'destination_raw_location' => :'destination_raw_location',
+ :'note' => :'note',
+ :'slug_group' => :'slug_group',
+ :'order_date' => :'order_date',
+ :'order_number' => :'order_number',
+ :'shipment_type' => :'shipment_type',
+ :'shipment_tags' => :'shipment_tags',
+ :'courier_connection_id' => :'courier_connection_id',
+ :'next_couriers' => :'next_couriers',
+ :'tracking_origin_country' => :'tracking_origin_country',
+ :'tracking_destination_country' => :'tracking_destination_country',
+ :'tracking_postal_code' => :'tracking_postal_code',
+ :'tracking_state' => :'tracking_state',
+ :'location_id' => :'location_id',
+ :'shipping_method' => :'shipping_method',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/tracking_delete_response_v1.rb b/lib/aftership-tracking-sdk/models/tracking_delete_response_v1.rb
new file mode 100644
index 0000000..4acb38a
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/tracking_delete_response_v1.rb
@@ -0,0 +1,161 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class TrackingDeleteResponseV1
+ # Meta data
+ # meta: MetaV1;
+ attr_accessor :meta
+
+ #
+ # data: DataTrackingDeleteResponseV1;
+ attr_accessor :data
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::TrackingDeleteResponseV1` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'meta')
+ self.meta = attributes[:'meta']
+ end
+
+ if attributes.key?(:'data')
+ self.data = attributes[:'data']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'meta' => :'MetaV1',
+ :'data' => :'DataTrackingDeleteResponseV1',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'meta' => :'meta',
+ :'data' => :'data',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/tracking_detect_courier_request.rb b/lib/aftership-tracking-sdk/models/tracking_detect_courier_request.rb
new file mode 100644
index 0000000..77244f8
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/tracking_detect_courier_request.rb
@@ -0,0 +1,261 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class TrackingDetectCourierRequest
+ # Tracking number of a shipment.
+ # tracking_number: String;
+ attr_accessor :tracking_number
+
+ # If not specified, Aftership will automatically detect the courier based on the tracking number format and your . Use array or comma separated to input a list of couriers for auto detect. Cannot be used with slug_group at the same time.
+ # slug?: String[];
+ attr_accessor :slug
+
+ # The postal code of receiver's address. Required by some couriers. Refer to for more details
+ # tracking_postal_code?: String;
+ attr_accessor :tracking_postal_code
+
+ # Shipping date in `YYYYMMDD` format. Required by some couriers. Refer to for more details
+ # tracking_ship_date?: String;
+ attr_accessor :tracking_ship_date
+
+ # Account number of the shipper for a specific courier. Required by some couriers. Refer to for more details
+ # tracking_account_number?: String;
+ attr_accessor :tracking_account_number
+
+ # Key of the shipment for a specific courier. Required by some couriers. Refer to for more details
+ # tracking_key?: String;
+ attr_accessor :tracking_key
+
+ # Origin Country/Region of the shipment for a specific courier. Required by some couriers.
+ # tracking_origin_country?: String;
+ attr_accessor :tracking_origin_country
+
+ # Destination Country/Region of the shipment for a specific courier. Required by some couriers. Refer to for more details
+ # tracking_destination_country?: String;
+ attr_accessor :tracking_destination_country
+
+ # State of the destination shipping address of the shipment. Required by some couriers.
+ # tracking_state?: String;
+ attr_accessor :tracking_state
+
+ # Slug group is a group of slugs which belong to same courier. For example, when you inpit "fedex-group" as slug_group, AfterShip will detect the tracking with "fedex-uk", "fedex-fims", and other slugs which belong to "fedex". It cannot be used with slug at the same time. (
+ # slug_group?: SlugGroupV1;
+ attr_accessor :slug_group
+
+ # Enter .
+ # origin_country_iso3?: String;
+ attr_accessor :origin_country_iso3
+
+ # Enter .
+ # destination_country_iso3?: String;
+ attr_accessor :destination_country_iso3
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::TrackingDetectCourierRequest` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'tracking_number')
+ self.tracking_number = attributes[:'tracking_number']
+ end
+
+ if attributes.key?(:'slug')
+ self.slug = attributes[:'slug']
+ end
+
+ if attributes.key?(:'tracking_postal_code')
+ self.tracking_postal_code = attributes[:'tracking_postal_code']
+ end
+
+ if attributes.key?(:'tracking_ship_date')
+ self.tracking_ship_date = attributes[:'tracking_ship_date']
+ end
+
+ if attributes.key?(:'tracking_account_number')
+ self.tracking_account_number = attributes[:'tracking_account_number']
+ end
+
+ if attributes.key?(:'tracking_key')
+ self.tracking_key = attributes[:'tracking_key']
+ end
+
+ if attributes.key?(:'tracking_origin_country')
+ self.tracking_origin_country = attributes[:'tracking_origin_country']
+ end
+
+ if attributes.key?(:'tracking_destination_country')
+ self.tracking_destination_country = attributes[:'tracking_destination_country']
+ end
+
+ if attributes.key?(:'tracking_state')
+ self.tracking_state = attributes[:'tracking_state']
+ end
+
+ if attributes.key?(:'slug_group')
+ self.slug_group = attributes[:'slug_group']
+ end
+
+ if attributes.key?(:'origin_country_iso3')
+ self.origin_country_iso3 = attributes[:'origin_country_iso3']
+ end
+
+ if attributes.key?(:'destination_country_iso3')
+ self.destination_country_iso3 = attributes[:'destination_country_iso3']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'tracking_number' => :'String',
+ :'slug' => :'Array',
+ :'tracking_postal_code' => :'String',
+ :'tracking_ship_date' => :'String',
+ :'tracking_account_number' => :'String',
+ :'tracking_key' => :'String',
+ :'tracking_origin_country' => :'String',
+ :'tracking_destination_country' => :'String',
+ :'tracking_state' => :'String',
+ :'slug_group' => :'SlugGroupV1',
+ :'origin_country_iso3' => :'String',
+ :'destination_country_iso3' => :'String',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'tracking_number' => :'tracking_number',
+ :'slug' => :'slug',
+ :'tracking_postal_code' => :'tracking_postal_code',
+ :'tracking_ship_date' => :'tracking_ship_date',
+ :'tracking_account_number' => :'tracking_account_number',
+ :'tracking_key' => :'tracking_key',
+ :'tracking_origin_country' => :'tracking_origin_country',
+ :'tracking_destination_country' => :'tracking_destination_country',
+ :'tracking_state' => :'tracking_state',
+ :'slug_group' => :'slug_group',
+ :'origin_country_iso3' => :'origin_country_iso3',
+ :'destination_country_iso3' => :'destination_country_iso3',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/tracking_response_get_multiple_v1.rb b/lib/aftership-tracking-sdk/models/tracking_response_get_multiple_v1.rb
new file mode 100644
index 0000000..3a974ee
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/tracking_response_get_multiple_v1.rb
@@ -0,0 +1,161 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class TrackingResponseGetMultipleV1
+ # Meta data
+ # meta: MetaV1;
+ attr_accessor :meta
+
+ #
+ # data?: DataTrackingResponseGetMultipleV1;
+ attr_accessor :data
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::TrackingResponseGetMultipleV1` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'meta')
+ self.meta = attributes[:'meta']
+ end
+
+ if attributes.key?(:'data')
+ self.data = attributes[:'data']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'meta' => :'MetaV1',
+ :'data' => :'DataTrackingResponseGetMultipleV1',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'meta' => :'meta',
+ :'data' => :'data',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/tracking_response_v1.rb b/lib/aftership-tracking-sdk/models/tracking_response_v1.rb
new file mode 100644
index 0000000..91d36d7
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/tracking_response_v1.rb
@@ -0,0 +1,161 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class TrackingResponseV1
+ # Meta data
+ # meta: MetaV1;
+ attr_accessor :meta
+
+ #
+ # data: DataTrackingResponseV1;
+ attr_accessor :data
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::TrackingResponseV1` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'meta')
+ self.meta = attributes[:'meta']
+ end
+
+ if attributes.key?(:'data')
+ self.data = attributes[:'data']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'meta' => :'MetaV1',
+ :'data' => :'DataTrackingResponseV1',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'meta' => :'meta',
+ :'data' => :'data',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/tracking_update_tracking_by_id_request.rb b/lib/aftership-tracking-sdk/models/tracking_update_tracking_by_id_request.rb
new file mode 100644
index 0000000..ed5bbc0
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/tracking_update_tracking_by_id_request.rb
@@ -0,0 +1,501 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class TrackingUpdateTrackingByIdRequest
+ # The phone number(s) to receive sms notifications. Input `[]` to clear the value of this field. Supports up to 3 phone numbers.
+ # smses?: String[];
+ attr_accessor :smses
+
+ # Email address(es) to receive email notifications. Input `[]` to clear the value of this field. Supports up to 3 email addresses.
+ # emails?: String[];
+ attr_accessor :emails
+
+ # By default this field shows the `tracking_number`, but you can customize it as you wish with any info (e.g. the order number).
+ # title?: String;
+ attr_accessor :title
+
+ # Customer name of the tracking.
+ # customer_name?: String;
+ attr_accessor :customer_name
+
+ # A globally-unique identifier for the order.
+ # order_id?: String;
+ attr_accessor :order_id
+
+ # The URL for the order in your system or store.
+ # order_id_path?: String;
+ attr_accessor :order_id_path
+
+ # Custom fields that accept an object with string field. In order to protect the privacy of your customers, do not include any
+ # custom_fields?: Object;
+ attr_accessor :custom_fields
+
+ # Text field for the note.Input `""` to clear the value of this field.
+ # note?: String;
+ attr_accessor :note
+
+ # The recipient’s language. If you set up AfterShip notifications in different languages, we use this to send the recipient tracking updates in their preferred language. Use an to specify the language.
+ # language?: String;
+ attr_accessor :language
+
+ # The promised delivery date of the order. It uses the format YYYY-MM-DD. This has no timezone and uses whatever date you provide. Since other EDDs use the shipment recipient’s timezone, we suggest following the same logic here.
+ # order_promised_delivery_date?: String;
+ attr_accessor :order_promised_delivery_date
+
+ # Shipment delivery type- `pickup_at_store`- `pickup_at_courier`- `door_to_door`
+ # delivery_type?: String;
+ attr_accessor :delivery_type
+
+ # Shipment pickup location for receiver
+ # pickup_location?: String;
+ attr_accessor :pickup_location
+
+ # Shipment pickup note for receiver
+ # pickup_note?: String;
+ attr_accessor :pickup_note
+
+ # Unique code of each courier. Provide a single courier.(https://admin.aftership.com/settings/couriers). Get a list of courier slug using
+ # slug?: String;
+ attr_accessor :slug
+
+ # Additional field required by some carriers to retrieve the tracking info. The shipper’s carrier account number. Refer to our article on for more details.
+ # tracking_account_number?: String;
+ attr_accessor :tracking_account_number
+
+ # Additional field required by some carriers to retrieve the tracking info. A type of tracking credential required by some carriers. Refer to our article on for more details.
+ # tracking_key?: String;
+ attr_accessor :tracking_key
+
+ # Additional field required by some carriers to retrieve the tracking info. The date the shipment was sent, using the format YYYYMMDD. Refer to our article on for more details.
+ # tracking_ship_date?: String;
+ attr_accessor :tracking_ship_date
+
+ # A unique, human-readable identifier for the order.
+ # order_number?: String;
+ attr_accessor :order_number
+
+ # Order date in YYYY-MM-DDTHH:mm:ssZ format. e.g. 2021-07-26T11:23:51-05:00
+ # order_date?: String;
+ attr_accessor :order_date
+
+ # The carrier service type for the shipment. If you provide info for this field, AfterShip will not update it with info from the carrier.
+ # shipment_type?: String;
+ attr_accessor :shipment_type
+
+ # The for more details.
+ # origin_country_iso3?: String;
+ attr_accessor :origin_country_iso3
+
+ # The state of the sender’s address. This can help AfterShip with various functions like tracking, carrier auto-detection and auto-correction, calculating an EDD, etc.
+ # origin_state?: String;
+ attr_accessor :origin_state
+
+ # The city of the sender’s address. This can help AfterShip with various functions like tracking, carrier auto-detection and auto-correction, calculating an EDD, etc.
+ # origin_city?: String;
+ attr_accessor :origin_city
+
+ # The postal of the sender’s address. This can help AfterShip with various functions like tracking, carrier auto-detection and auto-correction, calculating an EDD, etc.
+ # origin_postal_code?: String;
+ attr_accessor :origin_postal_code
+
+ # The sender address that the shipment is shipping from. This can help AfterShip with various functions like tracking, carrier auto-detection and auto-correction, calculating an EDD, etc.
+ # origin_raw_location?: String;
+ attr_accessor :origin_raw_location
+
+ # The for more details.
+ # destination_country_iso3?: String;
+ attr_accessor :destination_country_iso3
+
+ # The state of the recipient’s address. This can help AfterShip with various functions like tracking, carrier auto-detection and auto-correction, calculating an EDD, etc. Also the additional field required by some carriers to retrieve the tracking info. The state/province of the recipient’s address. Refer to our article on for more details.
+ # destination_state?: String;
+ attr_accessor :destination_state
+
+ # The city of the recipient’s address. This can help AfterShip with various functions like tracking, carrier auto-detection and auto-correction, calculating an EDD, etc.
+ # destination_city?: String;
+ attr_accessor :destination_city
+
+ # The postal of the recipient’s address. This can help AfterShip with various functions like tracking, carrier auto-detection and auto-correction, calculating an EDD, etc. Also the additional field required by some carriers to retrieve the tracking info. The postal code of the recipient’s address. Refer to our article on for more details.
+ # destination_postal_code?: String;
+ attr_accessor :destination_postal_code
+
+ # The shipping address that the shipment is shipping to. This can help AfterShip with various functions like tracking, carrier auto-detection and auto-correction, calculating an EDD, etc.
+ # destination_raw_location?: String;
+ attr_accessor :destination_raw_location
+
+ # (Legacy) Replaced by `origin_country_iso3`. Additional field required by some carriers to retrieve the tracking info. The origin country/region of the shipment. Refer to our article on for more details.
+ # tracking_origin_country?: String;
+ attr_accessor :tracking_origin_country
+
+ # (Legacy) Replaced by `destination_country_iso3`. Additional field required by some carriers to retrieve the tracking info. The destination country/region of the shipment. Refer to our article on for more details.
+ # tracking_destination_country?: String;
+ attr_accessor :tracking_destination_country
+
+ # (Legacy) Replaced by `destination_postal_code`. Additional field required by some carriers to retrieve the tracking info. The postal code of the recipient’s address. Refer to our article on for more details.
+ # tracking_postal_code?: String;
+ attr_accessor :tracking_postal_code
+
+ # (Legacy) Replaced by `destination_state`. Additional field required by some carriers to retrieve the tracking info. The state/province of the recipient’s address. Refer to our article on for more details.
+ # tracking_state?: String;
+ attr_accessor :tracking_state
+
+ # The location_id refers to the place where you fulfilled the items. - If you provide a location_id, the system will automatically use it as the tracking's origin address. However, passing both location_id and any origin address information simultaneously is not allowed.- Please make sure you add your locations .
+ # location_id?: String;
+ attr_accessor :location_id
+
+ # The shipping_method string refers to the chosen method for delivering the package. Merchants typically offer various shipping methods to consumers during the checkout process, such as, Local Delivery, Free Express Worldwide Shipping, etc.
+ # shipping_method?: String;
+ attr_accessor :shipping_method
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::TrackingUpdateTrackingByIdRequest` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'smses')
+ self.smses = attributes[:'smses']
+ end
+
+ if attributes.key?(:'emails')
+ self.emails = attributes[:'emails']
+ end
+
+ if attributes.key?(:'title')
+ self.title = attributes[:'title']
+ end
+
+ if attributes.key?(:'customer_name')
+ self.customer_name = attributes[:'customer_name']
+ end
+
+ if attributes.key?(:'order_id')
+ self.order_id = attributes[:'order_id']
+ end
+
+ if attributes.key?(:'order_id_path')
+ self.order_id_path = attributes[:'order_id_path']
+ end
+
+ if attributes.key?(:'custom_fields')
+ self.custom_fields = attributes[:'custom_fields']
+ end
+
+ if attributes.key?(:'note')
+ self.note = attributes[:'note']
+ end
+
+ if attributes.key?(:'language')
+ self.language = attributes[:'language']
+ end
+
+ if attributes.key?(:'order_promised_delivery_date')
+ self.order_promised_delivery_date = attributes[:'order_promised_delivery_date']
+ end
+
+ if attributes.key?(:'delivery_type')
+ self.delivery_type = attributes[:'delivery_type']
+ end
+
+ if attributes.key?(:'pickup_location')
+ self.pickup_location = attributes[:'pickup_location']
+ end
+
+ if attributes.key?(:'pickup_note')
+ self.pickup_note = attributes[:'pickup_note']
+ end
+
+ if attributes.key?(:'slug')
+ self.slug = attributes[:'slug']
+ end
+
+ if attributes.key?(:'tracking_account_number')
+ self.tracking_account_number = attributes[:'tracking_account_number']
+ end
+
+ if attributes.key?(:'tracking_key')
+ self.tracking_key = attributes[:'tracking_key']
+ end
+
+ if attributes.key?(:'tracking_ship_date')
+ self.tracking_ship_date = attributes[:'tracking_ship_date']
+ end
+
+ if attributes.key?(:'order_number')
+ self.order_number = attributes[:'order_number']
+ end
+
+ if attributes.key?(:'order_date')
+ self.order_date = attributes[:'order_date']
+ end
+
+ if attributes.key?(:'shipment_type')
+ self.shipment_type = attributes[:'shipment_type']
+ end
+
+ if attributes.key?(:'origin_country_iso3')
+ self.origin_country_iso3 = attributes[:'origin_country_iso3']
+ end
+
+ if attributes.key?(:'origin_state')
+ self.origin_state = attributes[:'origin_state']
+ end
+
+ if attributes.key?(:'origin_city')
+ self.origin_city = attributes[:'origin_city']
+ end
+
+ if attributes.key?(:'origin_postal_code')
+ self.origin_postal_code = attributes[:'origin_postal_code']
+ end
+
+ if attributes.key?(:'origin_raw_location')
+ self.origin_raw_location = attributes[:'origin_raw_location']
+ end
+
+ if attributes.key?(:'destination_country_iso3')
+ self.destination_country_iso3 = attributes[:'destination_country_iso3']
+ end
+
+ if attributes.key?(:'destination_state')
+ self.destination_state = attributes[:'destination_state']
+ end
+
+ if attributes.key?(:'destination_city')
+ self.destination_city = attributes[:'destination_city']
+ end
+
+ if attributes.key?(:'destination_postal_code')
+ self.destination_postal_code = attributes[:'destination_postal_code']
+ end
+
+ if attributes.key?(:'destination_raw_location')
+ self.destination_raw_location = attributes[:'destination_raw_location']
+ end
+
+ if attributes.key?(:'tracking_origin_country')
+ self.tracking_origin_country = attributes[:'tracking_origin_country']
+ end
+
+ if attributes.key?(:'tracking_destination_country')
+ self.tracking_destination_country = attributes[:'tracking_destination_country']
+ end
+
+ if attributes.key?(:'tracking_postal_code')
+ self.tracking_postal_code = attributes[:'tracking_postal_code']
+ end
+
+ if attributes.key?(:'tracking_state')
+ self.tracking_state = attributes[:'tracking_state']
+ end
+
+ if attributes.key?(:'location_id')
+ self.location_id = attributes[:'location_id']
+ end
+
+ if attributes.key?(:'shipping_method')
+ self.shipping_method = attributes[:'shipping_method']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'smses' => :'Array',
+ :'emails' => :'Array',
+ :'title' => :'String',
+ :'customer_name' => :'String',
+ :'order_id' => :'String',
+ :'order_id_path' => :'String',
+ :'custom_fields' => :'Object',
+ :'note' => :'String',
+ :'language' => :'String',
+ :'order_promised_delivery_date' => :'String',
+ :'delivery_type' => :'String',
+ :'pickup_location' => :'String',
+ :'pickup_note' => :'String',
+ :'slug' => :'String',
+ :'tracking_account_number' => :'String',
+ :'tracking_key' => :'String',
+ :'tracking_ship_date' => :'String',
+ :'order_number' => :'String',
+ :'order_date' => :'String',
+ :'shipment_type' => :'String',
+ :'origin_country_iso3' => :'String',
+ :'origin_state' => :'String',
+ :'origin_city' => :'String',
+ :'origin_postal_code' => :'String',
+ :'origin_raw_location' => :'String',
+ :'destination_country_iso3' => :'String',
+ :'destination_state' => :'String',
+ :'destination_city' => :'String',
+ :'destination_postal_code' => :'String',
+ :'destination_raw_location' => :'String',
+ :'tracking_origin_country' => :'String',
+ :'tracking_destination_country' => :'String',
+ :'tracking_postal_code' => :'String',
+ :'tracking_state' => :'String',
+ :'location_id' => :'String',
+ :'shipping_method' => :'String',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'smses' => :'smses',
+ :'emails' => :'emails',
+ :'title' => :'title',
+ :'customer_name' => :'customer_name',
+ :'order_id' => :'order_id',
+ :'order_id_path' => :'order_id_path',
+ :'custom_fields' => :'custom_fields',
+ :'note' => :'note',
+ :'language' => :'language',
+ :'order_promised_delivery_date' => :'order_promised_delivery_date',
+ :'delivery_type' => :'delivery_type',
+ :'pickup_location' => :'pickup_location',
+ :'pickup_note' => :'pickup_note',
+ :'slug' => :'slug',
+ :'tracking_account_number' => :'tracking_account_number',
+ :'tracking_key' => :'tracking_key',
+ :'tracking_ship_date' => :'tracking_ship_date',
+ :'order_number' => :'order_number',
+ :'order_date' => :'order_date',
+ :'shipment_type' => :'shipment_type',
+ :'origin_country_iso3' => :'origin_country_iso3',
+ :'origin_state' => :'origin_state',
+ :'origin_city' => :'origin_city',
+ :'origin_postal_code' => :'origin_postal_code',
+ :'origin_raw_location' => :'origin_raw_location',
+ :'destination_country_iso3' => :'destination_country_iso3',
+ :'destination_state' => :'destination_state',
+ :'destination_city' => :'destination_city',
+ :'destination_postal_code' => :'destination_postal_code',
+ :'destination_raw_location' => :'destination_raw_location',
+ :'tracking_origin_country' => :'tracking_origin_country',
+ :'tracking_destination_country' => :'tracking_destination_country',
+ :'tracking_postal_code' => :'tracking_postal_code',
+ :'tracking_state' => :'tracking_state',
+ :'location_id' => :'location_id',
+ :'shipping_method' => :'shipping_method',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/tracking_update_tracking_by_slug_tracking_number_request.rb b/lib/aftership-tracking-sdk/models/tracking_update_tracking_by_slug_tracking_number_request.rb
new file mode 100644
index 0000000..200c3b1
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/tracking_update_tracking_by_slug_tracking_number_request.rb
@@ -0,0 +1,391 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class TrackingUpdateTrackingBySlugTrackingNumberRequest
+ # The phone number(s) to receive sms notifications. Supports up to 3 phone numbers.
+ # smses?: String[];
+ attr_accessor :smses
+
+ # Email address(es) to receive email notifications. Supports up to 3 email addresses.
+ # emails?: String[];
+ attr_accessor :emails
+
+ # By default this field shows the `tracking_number`, but you can customize it as you wish with any info (e.g. the order number).
+ # title?: String;
+ attr_accessor :title
+
+ # Customer name of the tracking.
+ # customer_name?: String;
+ attr_accessor :customer_name
+
+ # A globally-unique identifier for the order.
+ # order_id?: String;
+ attr_accessor :order_id
+
+ # The URL for the order in your system or store.
+ # order_id_path?: String;
+ attr_accessor :order_id_path
+
+ # Custom fields that accept an object with string field. In order to protect the privacy of your customers, do not include any
+ # custom_fields?: CustomFieldsTrackingUpdateTrackingBySlugTrackingNumberRequest;
+ attr_accessor :custom_fields
+
+ # Text field for the note
+ # note?: String;
+ attr_accessor :note
+
+ # The recipient’s language. If you set up AfterShip notifications in different languages, we use this to send the recipient tracking updates in their preferred language. Use an to specify the language.
+ # language?: String;
+ attr_accessor :language
+
+ # The promised delivery date of the order. It uses the format YYYY-MM-DD. This has no timezone and uses whatever date you provide. Since other EDDs use the shipment recipient’s timezone, we suggest following the same logic here.
+ # order_promised_delivery_date?: String;
+ attr_accessor :order_promised_delivery_date
+
+ # Shipment delivery type- `pickup_at_store`- `pickup_at_courier`- `door_to_door`
+ # delivery_type?: String;
+ attr_accessor :delivery_type
+
+ # Shipment pickup location for receiver
+ # pickup_location?: String;
+ attr_accessor :pickup_location
+
+ # Shipment pickup note for receiver
+ # pickup_note?: String;
+ attr_accessor :pickup_note
+
+ # Unique code of each courier. Provide a single courier.(https://admin.aftership.com/settings/couriers). Get a list of courier slug using
+ # slug?: String;
+ attr_accessor :slug
+
+ # Additional field required by some carriers to retrieve the tracking info. The shipper’s carrier account number. Refer to our article on for more details.
+ # tracking_account_number?: String;
+ attr_accessor :tracking_account_number
+
+ # Additional field required by some carriers to retrieve the tracking info. The origin country/region of the shipment. Refer to our article on for more details.
+ # tracking_origin_country?: String;
+ attr_accessor :tracking_origin_country
+
+ # Additional field required by some carriers to retrieve the tracking info. The destination country/region of the shipment. Refer to our article on for more details.
+ # tracking_destination_country?: String;
+ attr_accessor :tracking_destination_country
+
+ # Additional field required by some carriers to retrieve the tracking info. A type of tracking credential required by some carriers. Refer to our article on for more details.
+ # tracking_key?: String;
+ attr_accessor :tracking_key
+
+ # Additional field required by some carriers to retrieve the tracking info. The postal code of the recipient’s address. Refer to our article on for more details.
+ # tracking_postal_code?: String;
+ attr_accessor :tracking_postal_code
+
+ # Additional field required by some carriers to retrieve the tracking info. The date the shipment was sent, using the format YYYYMMDD. Refer to our article on for more details.
+ # tracking_ship_date?: String;
+ attr_accessor :tracking_ship_date
+
+ # Additional field required by some carriers to retrieve the tracking info. The state/province of the recipient’s address. Refer to our article on for more details.
+ # tracking_state?: String;
+ attr_accessor :tracking_state
+
+ # A unique, human-readable identifier for the order.
+ # order_number?: String;
+ attr_accessor :order_number
+
+ # Order date in YYYY-MM-DDTHH:mm:ssZ format. e.g. 2021-07-26T11:23:51-05:00
+ # order_date?: String;
+ attr_accessor :order_date
+
+ # The location_id refers to the place where you fulfilled the items. - If you provide a location_id, the system will automatically use it as the tracking's origin address. However, passing both location_id and any origin address information simultaneously is not allowed.- Please make sure you add your locations .
+ # location_id?: String;
+ attr_accessor :location_id
+
+ # The shipping_method string refers to the chosen method for delivering the package. Merchants typically offer various shipping methods to consumers during the checkout process, such as, Local Delivery, Free Express Worldwide Shipping, etc.
+ # shipping_method?: String;
+ attr_accessor :shipping_method
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::TrackingUpdateTrackingBySlugTrackingNumberRequest` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'smses')
+ self.smses = attributes[:'smses']
+ end
+
+ if attributes.key?(:'emails')
+ self.emails = attributes[:'emails']
+ end
+
+ if attributes.key?(:'title')
+ self.title = attributes[:'title']
+ end
+
+ if attributes.key?(:'customer_name')
+ self.customer_name = attributes[:'customer_name']
+ end
+
+ if attributes.key?(:'order_id')
+ self.order_id = attributes[:'order_id']
+ end
+
+ if attributes.key?(:'order_id_path')
+ self.order_id_path = attributes[:'order_id_path']
+ end
+
+ if attributes.key?(:'custom_fields')
+ self.custom_fields = attributes[:'custom_fields']
+ end
+
+ if attributes.key?(:'note')
+ self.note = attributes[:'note']
+ end
+
+ if attributes.key?(:'language')
+ self.language = attributes[:'language']
+ end
+
+ if attributes.key?(:'order_promised_delivery_date')
+ self.order_promised_delivery_date = attributes[:'order_promised_delivery_date']
+ end
+
+ if attributes.key?(:'delivery_type')
+ self.delivery_type = attributes[:'delivery_type']
+ end
+
+ if attributes.key?(:'pickup_location')
+ self.pickup_location = attributes[:'pickup_location']
+ end
+
+ if attributes.key?(:'pickup_note')
+ self.pickup_note = attributes[:'pickup_note']
+ end
+
+ if attributes.key?(:'slug')
+ self.slug = attributes[:'slug']
+ end
+
+ if attributes.key?(:'tracking_account_number')
+ self.tracking_account_number = attributes[:'tracking_account_number']
+ end
+
+ if attributes.key?(:'tracking_origin_country')
+ self.tracking_origin_country = attributes[:'tracking_origin_country']
+ end
+
+ if attributes.key?(:'tracking_destination_country')
+ self.tracking_destination_country = attributes[:'tracking_destination_country']
+ end
+
+ if attributes.key?(:'tracking_key')
+ self.tracking_key = attributes[:'tracking_key']
+ end
+
+ if attributes.key?(:'tracking_postal_code')
+ self.tracking_postal_code = attributes[:'tracking_postal_code']
+ end
+
+ if attributes.key?(:'tracking_ship_date')
+ self.tracking_ship_date = attributes[:'tracking_ship_date']
+ end
+
+ if attributes.key?(:'tracking_state')
+ self.tracking_state = attributes[:'tracking_state']
+ end
+
+ if attributes.key?(:'order_number')
+ self.order_number = attributes[:'order_number']
+ end
+
+ if attributes.key?(:'order_date')
+ self.order_date = attributes[:'order_date']
+ end
+
+ if attributes.key?(:'location_id')
+ self.location_id = attributes[:'location_id']
+ end
+
+ if attributes.key?(:'shipping_method')
+ self.shipping_method = attributes[:'shipping_method']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'smses' => :'Array',
+ :'emails' => :'Array',
+ :'title' => :'String',
+ :'customer_name' => :'String',
+ :'order_id' => :'String',
+ :'order_id_path' => :'String',
+ :'custom_fields' => :'CustomFieldsTrackingUpdateTrackingBySlugTrackingNumberRequest',
+ :'note' => :'String',
+ :'language' => :'String',
+ :'order_promised_delivery_date' => :'String',
+ :'delivery_type' => :'String',
+ :'pickup_location' => :'String',
+ :'pickup_note' => :'String',
+ :'slug' => :'String',
+ :'tracking_account_number' => :'String',
+ :'tracking_origin_country' => :'String',
+ :'tracking_destination_country' => :'String',
+ :'tracking_key' => :'String',
+ :'tracking_postal_code' => :'String',
+ :'tracking_ship_date' => :'String',
+ :'tracking_state' => :'String',
+ :'order_number' => :'String',
+ :'order_date' => :'String',
+ :'location_id' => :'String',
+ :'shipping_method' => :'String',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'smses' => :'smses',
+ :'emails' => :'emails',
+ :'title' => :'title',
+ :'customer_name' => :'customer_name',
+ :'order_id' => :'order_id',
+ :'order_id_path' => :'order_id_path',
+ :'custom_fields' => :'custom_fields',
+ :'note' => :'note',
+ :'language' => :'language',
+ :'order_promised_delivery_date' => :'order_promised_delivery_date',
+ :'delivery_type' => :'delivery_type',
+ :'pickup_location' => :'pickup_location',
+ :'pickup_note' => :'pickup_note',
+ :'slug' => :'slug',
+ :'tracking_account_number' => :'tracking_account_number',
+ :'tracking_origin_country' => :'tracking_origin_country',
+ :'tracking_destination_country' => :'tracking_destination_country',
+ :'tracking_key' => :'tracking_key',
+ :'tracking_postal_code' => :'tracking_postal_code',
+ :'tracking_ship_date' => :'tracking_ship_date',
+ :'tracking_state' => :'tracking_state',
+ :'order_number' => :'order_number',
+ :'order_date' => :'order_date',
+ :'location_id' => :'location_id',
+ :'shipping_method' => :'shipping_method',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/weight_estimated_delivery_date_request.rb b/lib/aftership-tracking-sdk/models/weight_estimated_delivery_date_request.rb
new file mode 100644
index 0000000..592ce7c
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/weight_estimated_delivery_date_request.rb
@@ -0,0 +1,161 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class WeightEstimatedDeliveryDateRequest
+ # The weight unit of the package.
+ # unit: String;
+ attr_accessor :unit
+
+ # The weight of the shipment.
+ # value: Float;
+ attr_accessor :value
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::WeightEstimatedDeliveryDateRequest` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'unit')
+ self.unit = attributes[:'unit']
+ end
+
+ if attributes.key?(:'value')
+ self.value = attributes[:'value']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'unit' => :'String',
+ :'value' => :'Float',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'unit' => :'unit',
+ :'value' => :'value',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/models/weight_estimated_delivery_date_response.rb b/lib/aftership-tracking-sdk/models/weight_estimated_delivery_date_response.rb
new file mode 100644
index 0000000..e1a7767
--- /dev/null
+++ b/lib/aftership-tracking-sdk/models/weight_estimated_delivery_date_response.rb
@@ -0,0 +1,161 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI::Model
+ class WeightEstimatedDeliveryDateResponse
+ # The weight unit of the package.
+ # unit: String;
+ attr_accessor :unit
+
+ # The weight of the shipment.
+ # value: Float;
+ attr_accessor :value
+
+ # Initializes the object
+ # @param [Hash] attributes Model attributes in the form of hash
+ def initialize(attributes = {})
+ if (!attributes.is_a?(Hash))
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::WeightEstimatedDeliveryDateResponse` initialize method"
+ end
+
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ h[k.to_sym] = v
+ }
+
+ if attributes.key?(:'unit')
+ self.unit = attributes[:'unit']
+ end
+
+ if attributes.key?(:'value')
+ self.value = attributes[:'value']
+ end
+ end
+
+ # Attribute type mapping.
+ def self.openapi_types
+ {
+ :'unit' => :'String',
+ :'value' => :'Float',
+ }
+ end
+
+ # Attribute mapping from ruby-style variable name to JSON key.
+ def self.attribute_map
+ {
+ :'unit' => :'unit',
+ :'value' => :'value',
+ }
+ end
+
+ # Builds the object from hash
+ # @param attributes [Hash] Model attributes in the form of hash
+ # @return [Object] Returns the model itself
+ def self.build_from_hash(attributes)
+ return nil unless attributes.is_a?(Hash)
+ attributes = attributes.transform_keys(&:to_sym)
+ transformed_hash = {}
+ openapi_types.each_pair do |key, type|
+ if attributes.key?(key) && attributes[key].nil?
+ transformed_hash["#{key}"] = nil
+ elsif type =~ /\AArray<(.*)>/i
+ # check to ensure the input is an array given that the attribute
+ # is documented as an array but the input is not
+ if attributes[key].is_a?(Array)
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
+ end
+ elsif !attributes[key].nil?
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
+ end
+ end
+ new(transformed_hash)
+ end
+
+ # Deserializes the data based on type
+ # @param type [String] Data type
+ # @param value [String] Value to be deserialized
+ # @return [Object] Deserialized data
+ def self._deserialize(type, value)
+ case type.to_sym
+ when :Time
+ Time.parse(value)
+ when :Date
+ Date.parse(value)
+ when :String
+ value.to_s
+ when :Integer
+ value.to_i
+ when :Float
+ value.to_f
+ when :Boolean
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
+ true
+ else
+ false
+ end
+ when :Object
+ # generic object (usually a Hash), return directly
+ value
+ when /\AArray<(?.+)>\z/
+ inner_type = Regexp.last_match[:inner_type]
+ value.map { |v| _deserialize(inner_type, v) }
+ when /\AHash<(?.+?), (?.+)>\z/
+ k_type = Regexp.last_match[:k_type]
+ v_type = Regexp.last_match[:v_type]
+ {}.tap do |hash|
+ value.each do |k, v|
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
+ end
+ end
+ else # model
+ klass = AftershipAPI::Model.const_get(type)
+ klass.build_from_hash(value)
+ end
+ end
+
+ # Returns the string representation of the object
+ # @return [String] String presentation of the object
+ def to_s
+ to_hash.to_s
+ end
+
+ # to_body is an alias to to_hash (backward compatibility)
+ # @return [Hash] Returns the object in the form of hash
+ def to_body
+ to_hash
+ end
+
+ # Returns the object in the form of hash
+ # @return [Hash] Returns the object in the form of hash
+ def to_hash
+ hash = {}
+ self.class.attribute_map.each_pair do |attr, param|
+ value = self.send(attr)
+ next if value.nil?
+
+ hash[param] = _to_hash(value)
+ end
+ hash
+ end
+
+ # Outputs non-array value in the form of hash
+ # For object, use to_hash. Otherwise, just return the value
+ # @param value [Object] Any valid value
+ # @return [Hash] Returns the value in the form of hash
+ def _to_hash(value)
+ if value.is_a?(Array)
+ value.compact.map { |v| _to_hash(v) }
+ elsif value.is_a?(Hash)
+ {}.tap do |hash|
+ value.each { |k, v| hash[k] = _to_hash(v) }
+ end
+ elsif value.respond_to? :to_hash
+ value.to_hash
+ else
+ value
+ end
+ end
+
+ def to_json(*a)
+ to_hash.to_json(*a)
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/sign_string.rb b/lib/aftership-tracking-sdk/sign_string.rb
new file mode 100644
index 0000000..9d21a53
--- /dev/null
+++ b/lib/aftership-tracking-sdk/sign_string.rb
@@ -0,0 +1,77 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+require 'openssl'
+require 'base64'
+require 'uri'
+
+module AftershipAPI
+ class SignString
+ class << self
+ def sign(params)
+ content_md5 = ''
+ content_type = ''
+ # Computed MD5 hash of the request body in uppercase hex format.
+ if params['body'].to_s != ''
+ content_md5 = Digest::MD5.hexdigest(params['body']).upcase
+ content_type = params['content_type']
+ end
+ # Extract all request headers with the as- prefix key
+ as_headers = params['headers'].select { |k, _| k.start_with?('as-') }
+
+ # Convert all the request header key to lowercase, sort the headers in ASCII code order
+ as_headers = as_headers.transform_keys(&:downcase).sort.to_h
+
+ # Remove leading spaces and trailing spaces from the header key and value
+ as_headers.transform_keys!(&:strip)
+ as_headers.transform_values!(&:strip)
+
+ # Concatenate each of the header key and value with :, to form a header pair
+ header_pairs = as_headers.map { |k, v| "#{k}:#{v}" }
+
+ # Concatenate all header pairs with the new line character (ASCII code 10)
+ canonicalized_headers = header_pairs.join("\n")
+
+ # canonicalized_resource is the path of the URL, including the query parameters
+ url = URI.parse params['url']
+ canonicalized_resource = url.path
+ if !params['query'].nil? && params['query'].length > 0
+ sorted_query = params['query'].sort_by { |k, v| [k, v] }
+ canonicalized_resource += '?' + URI.encode_www_form(sorted_query)
+ end
+
+ # Form the string to sign
+ string_to_sign = [
+ params['method'].upcase,
+ content_md5,
+ content_type,
+ params['date'],
+ canonicalized_headers,
+ canonicalized_resource
+ ].join("\n")
+
+ # Generate the signature
+ signature = ''
+ if params['auth_type'] == AUTHENTICATION_TYPE_AES
+ signature = sign_aes(string_to_sign, params['secret'])
+ elsif params['auth_type'] == AUTHENTICATION_TYPE_RSA
+ signature = sign_rsa(string_to_sign, params['secret'])
+ else
+ raise InvalidOptionError, "Invalid authentication type: #{params['auth_type']}"
+ end
+
+ signature
+ end
+
+ def sign_aes(msg, key)
+ digest = OpenSSL::HMAC.digest("SHA256", key, msg)
+ Base64.strict_encode64(digest).strip
+ end
+
+ def sign_rsa(msg, key)
+ private_key = OpenSSL::PKey::RSA.new(key)
+ signature = private_key.sign_pss('SHA256', msg, salt_length: :digest, mgf1_hash: 'SHA256')
+ Base64.strict_encode64(signature).strip
+ end
+ end
+ end
+end
diff --git a/lib/aftership-tracking-sdk/version.rb b/lib/aftership-tracking-sdk/version.rb
new file mode 100644
index 0000000..b23207c
--- /dev/null
+++ b/lib/aftership-tracking-sdk/version.rb
@@ -0,0 +1,5 @@
+# This code was auto generated by AfterShip SDK Generator.
+# Do not edit the class manually.
+module AftershipAPI
+ VERSION = '7.0.0'
+end