diff --git a/README.md b/README.md index aeac799..66bbfe9 100644 --- a/README.md +++ b/README.md @@ -38,8 +38,8 @@ Before you begin to integrate: ### API and SDK Version -- SDK Version: 14.0.0 -- API Version: 2026-01 +- SDK Version: 15.0.0 +- API Version: 2026-07 ## Quick Start ### Installation @@ -50,7 +50,7 @@ gem install aftership-tracking-sdk Or add a line to your Gemfile ```bash -gem 'aftership-tracking-sdk', '~> 14.0.0' +gem 'aftership-tracking-sdk', '~> 15.0.0' ``` ## Constructor @@ -89,6 +89,27 @@ end See the [Rate Limit](https://www.aftership.com/docs/tracking/quickstart/rate-limit) to understand the AfterShip rate limit policy. +The API returns its current rate limit status in the headers of every response, and the SDK exposes these headers on both successful responses and rate-limited errors, so you can monitor your consumption proactively instead of waiting for `429` errors. + +| Header | Description | +| ----------------------- | ---------------------------------------------------------- | +| `X-RateLimit-Limit` | The rate limit ceiling for the current endpoint per second | +| `X-RateLimit-Remaining` | The number of requests left for the 1-second window | +| `X-RateLimit-Reset` | The Unix timestamp when the rate limit will be reset | + +Every successful response exposes a `response_header` hash (case-insensitive lookup) alongside `data`. Taking the Quick Start example above: + +```ruby +remaining = response.response_header['x-ratelimit-remaining'].to_i +reset_at = response.response_header['x-ratelimit-reset'].to_i + +if remaining <= 1 + # Throttle or defer lower-priority requests until reset_at +end +``` + +When the rate limit is exceeded, the request fails with a `429` error that carries the same headers — see [Error Handling](#error-handling). + ## Error Handling The SDK will return an error object when there is any error during the request, with the following specification: diff --git a/lib/aftership-tracking-sdk/api/courier.rb b/lib/aftership-tracking-sdk/api/courier.rb index abf7b75..3935df7 100644 --- a/lib/aftership-tracking-sdk/api/courier.rb +++ b/lib/aftership-tracking-sdk/api/courier.rb @@ -23,7 +23,7 @@ def get_couriers(opts: {}) # resource path - local_var_path = "/tracking/2026-01/couriers" + local_var_path = "/tracking/2026-07/couriers" method = :'GET' # query parameters @@ -72,7 +72,7 @@ def detect_courier(body:, opts: {}) # resource path - local_var_path = "/tracking/2026-01/couriers/detect" + local_var_path = "/tracking/2026-07/couriers/detect" method = :'POST' # query parameters diff --git a/lib/aftership-tracking-sdk/api/courier_connection.rb b/lib/aftership-tracking-sdk/api/courier_connection.rb index e96d891..1b3f511 100644 --- a/lib/aftership-tracking-sdk/api/courier_connection.rb +++ b/lib/aftership-tracking-sdk/api/courier_connection.rb @@ -24,7 +24,7 @@ def get_courier_connections(opts: {}) # resource path - local_var_path = "/tracking/2026-01/courier-connections" + local_var_path = "/tracking/2026-07/courier-connections" method = :'GET' # query parameters @@ -74,7 +74,7 @@ def post_courier_connections(body:, opts: {}) # resource path - local_var_path = "/tracking/2026-01/courier-connections" + local_var_path = "/tracking/2026-07/courier-connections" method = :'POST' # query parameters @@ -122,7 +122,7 @@ def get_courier_connections_by_id(id:, opts: {}) # resource path - local_var_path = "/tracking/2026-01/courier-connections/#{id}" + local_var_path = "/tracking/2026-07/courier-connections/#{id}" method = :'GET' # query parameters @@ -173,7 +173,7 @@ def put_courier_connections_by_id(id:, body:, opts: {}) # resource path - local_var_path = "/tracking/2026-01/courier-connections/#{id}" + local_var_path = "/tracking/2026-07/courier-connections/#{id}" method = :'PATCH' # query parameters @@ -221,7 +221,7 @@ def delete_courier_connections_by_id(id:, opts: {}) # resource path - local_var_path = "/tracking/2026-01/courier-connections/#{id}" + local_var_path = "/tracking/2026-07/courier-connections/#{id}" method = :'DELETE' # query parameters diff --git a/lib/aftership-tracking-sdk/api/estimated_delivery_date.rb b/lib/aftership-tracking-sdk/api/estimated_delivery_date.rb index b2c1443..84d1193 100644 --- a/lib/aftership-tracking-sdk/api/estimated_delivery_date.rb +++ b/lib/aftership-tracking-sdk/api/estimated_delivery_date.rb @@ -24,7 +24,7 @@ def predict(body:, opts: {}) # resource path - local_var_path = "/tracking/2026-01/estimated-delivery-date/predict" + local_var_path = "/tracking/2026-07/estimated-delivery-date/predict" method = :'POST' # query parameters @@ -71,7 +71,7 @@ def predict_batch(body:, opts: {}) # resource path - local_var_path = "/tracking/2026-01/estimated-delivery-date/predict-batch" + local_var_path = "/tracking/2026-07/estimated-delivery-date/predict-batch" method = :'POST' # query parameters diff --git a/lib/aftership-tracking-sdk/api/tracking.rb b/lib/aftership-tracking-sdk/api/tracking.rb index c030da6..9113237 100644 --- a/lib/aftership-tracking-sdk/api/tracking.rb +++ b/lib/aftership-tracking-sdk/api/tracking.rb @@ -39,7 +39,7 @@ def get_trackings(opts: {}) # resource path - local_var_path = "/tracking/2026-01/trackings" + local_var_path = "/tracking/2026-07/trackings" method = :'GET' # query parameters @@ -104,7 +104,7 @@ def create_tracking(body:, opts: {}) # resource path - local_var_path = "/tracking/2026-01/trackings" + local_var_path = "/tracking/2026-07/trackings" method = :'POST' # query parameters @@ -154,7 +154,7 @@ def get_tracking_by_id(id:, opts: {}) # resource path - local_var_path = "/tracking/2026-01/trackings/#{id}" + local_var_path = "/tracking/2026-07/trackings/#{id}" method = :'GET' # query parameters @@ -207,7 +207,7 @@ def update_tracking_by_id(id:, body:, opts: {}) # resource path - local_var_path = "/tracking/2026-01/trackings/#{id}" + local_var_path = "/tracking/2026-07/trackings/#{id}" method = :'PUT' # query parameters @@ -255,7 +255,7 @@ def delete_tracking_by_id(id:, opts: {}) # resource path - local_var_path = "/tracking/2026-01/trackings/#{id}" + local_var_path = "/tracking/2026-07/trackings/#{id}" method = :'DELETE' # query parameters @@ -303,7 +303,7 @@ def retrack_tracking_by_id(id:, opts: {}) # resource path - local_var_path = "/tracking/2026-01/trackings/#{id}/retrack" + local_var_path = "/tracking/2026-07/trackings/#{id}/retrack" method = :'POST' # query parameters @@ -354,7 +354,7 @@ def mark_tracking_completed_by_id(id:, body:, opts: {}) # resource path - local_var_path = "/tracking/2026-01/trackings/#{id}/mark-as-completed" + local_var_path = "/tracking/2026-07/trackings/#{id}/mark-as-completed" method = :'POST' # query parameters diff --git a/lib/aftership-tracking-sdk/models/checkpoint.rb b/lib/aftership-tracking-sdk/models/checkpoint.rb index 4d431f6..aafdc74 100644 --- a/lib/aftership-tracking-sdk/models/checkpoint.rb +++ b/lib/aftership-tracking-sdk/models/checkpoint.rb @@ -70,6 +70,10 @@ class Checkpoint # source?: CheckpointSource; attr_accessor :source + # Unique hash identifier for each checkpoint event, could be used for deduplication. + # hash?: String; + attr_accessor :hash + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -148,6 +152,10 @@ def initialize(attributes = {}) if attributes.key?(:'source') self.source = attributes[:'source'] end + + if attributes.key?(:'hash') + self.hash = attributes[:'hash'] + end end # Attribute type mapping. @@ -170,6 +178,7 @@ def self.openapi_types :'raw_tag' => :'String', :'events' => :'Array', :'source' => :'CheckpointSource', + :'hash' => :'String', } end @@ -193,6 +202,7 @@ def self.attribute_map :'raw_tag' => :'raw_tag', :'events' => :'events', :'source' => :'source', + :'hash' => :'hash', } end diff --git a/lib/aftership-tracking-sdk/models/create_tracking_request.rb b/lib/aftership-tracking-sdk/models/create_tracking_request.rb index 02cb222..7db5936 100644 --- a/lib/aftership-tracking-sdk/models/create_tracking_request.rb +++ b/lib/aftership-tracking-sdk/models/create_tracking_request.rb @@ -146,6 +146,10 @@ class CreateTrackingRequest # customers?: CreateTrackingRequestCustomers[]; attr_accessor :customers + # Indicates the business direction of the shipment in the e-commerce fulfillment lifecycle.Possible values:- `forward`: A forward (outbound-to-customer) shipment created for order fulfillment.- `return`: A return (customer-to-merchant) shipment created for after-sales return or exchange.When provided, this field gives AfterShip additional context about the shipment's intent, enabling more accurate status identification. + # shipment_direction?: CreateTrackingRequestShipmentDirection; + attr_accessor :shipment_direction + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -300,6 +304,10 @@ def initialize(attributes = {}) if attributes.key?(:'customers') self.customers = attributes[:'customers'] end + + if attributes.key?(:'shipment_direction') + self.shipment_direction = attributes[:'shipment_direction'] + end end # Attribute type mapping. @@ -341,6 +349,7 @@ def self.openapi_types :'shipping_method' => :'String', :'last_mile' => :'CreateTrackingRequestLastMile', :'customers' => :'Array', + :'shipment_direction' => :'CreateTrackingRequestShipmentDirection', } end @@ -383,6 +392,7 @@ def self.attribute_map :'shipping_method' => :'shipping_method', :'last_mile' => :'last_mile', :'customers' => :'customers', + :'shipment_direction' => :'shipment_direction', } end diff --git a/lib/aftership-tracking-sdk/models/create_tracking_request_customers.rb b/lib/aftership-tracking-sdk/models/create_tracking_request_customers.rb index 9a27ead..f363f4f 100644 --- a/lib/aftership-tracking-sdk/models/create_tracking_request_customers.rb +++ b/lib/aftership-tracking-sdk/models/create_tracking_request_customers.rb @@ -22,6 +22,10 @@ class CreateTrackingRequestCustomers # language?: String; attr_accessor :language + # The customer's identifier on the merchant or platform (for example, Shopify) side. + # id?: String; + attr_accessor :id + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -52,6 +56,10 @@ def initialize(attributes = {}) if attributes.key?(:'language') self.language = attributes[:'language'] end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end end # Attribute type mapping. @@ -62,6 +70,7 @@ def self.openapi_types :'phone_number' => :'String', :'email' => :'String', :'language' => :'String', + :'id' => :'String', } end @@ -73,6 +82,7 @@ def self.attribute_map :'phone_number' => :'phone_number', :'email' => :'email', :'language' => :'language', + :'id' => :'id', } end diff --git a/lib/aftership-tracking-sdk/models/create_tracking_request_shipment_direction.rb b/lib/aftership-tracking-sdk/models/create_tracking_request_shipment_direction.rb new file mode 100644 index 0000000..0682eba --- /dev/null +++ b/lib/aftership-tracking-sdk/models/create_tracking_request_shipment_direction.rb @@ -0,0 +1,26 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CreateTrackingRequestShipmentDirection + FORWARD = "forward".freeze + RETURN = "return".freeze + def self.all_vars + @all_vars ||= [FORWARD, RETURN,].freeze + end + + # Builds the enum from string + # @param value [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param value [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if CreateTrackingRequestShipmentDirection.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #CreateTrackingRequestShipmentDirection" + end + end +end diff --git a/lib/aftership-tracking-sdk/models/estimated_delivery_date_request_destination_address.rb b/lib/aftership-tracking-sdk/models/estimated_delivery_date_request_destination_address.rb index 613fb07..e4eab6f 100644 --- a/lib/aftership-tracking-sdk/models/estimated_delivery_date_request_destination_address.rb +++ b/lib/aftership-tracking-sdk/models/estimated_delivery_date_request_destination_address.rb @@ -6,7 +6,7 @@ class EstimatedDeliveryDateRequestDestinationAddress # country_region: String; attr_accessor :country_region - # State, province, or the equivalent location of the destination address where the package will be delivered.Either `destination_address.state` or `destination_address.postal_code` is required. + # State, province, or the equivalent location of the destination address where the package will be delivered.
**Either `destination_address.state` or `destination_address.postal_code` is required.** # state?: String; attr_accessor :state @@ -14,7 +14,7 @@ class EstimatedDeliveryDateRequestDestinationAddress # city?: String; attr_accessor :city - # Postal code of the destination address.Either `destination_address.state` or `destination_address.postal_code` is required. + # Postal code of the destination address.
**Either `destination_address.state` or `destination_address.postal_code` is required.** # postal_code?: String; attr_accessor :postal_code diff --git a/lib/aftership-tracking-sdk/models/estimated_delivery_date_request_origin_address.rb b/lib/aftership-tracking-sdk/models/estimated_delivery_date_request_origin_address.rb index 12a1e2e..20f82ac 100644 --- a/lib/aftership-tracking-sdk/models/estimated_delivery_date_request_origin_address.rb +++ b/lib/aftership-tracking-sdk/models/estimated_delivery_date_request_origin_address.rb @@ -6,7 +6,7 @@ class EstimatedDeliveryDateRequestOriginAddress # country_region: String; attr_accessor :country_region - # State, province, or the equivalent location of the origin address. Use 3 letters of ISO 3166-1 country/region code for countries/regions without state. Either `origin_address.state` or `origin_address.postal_code` is required. + # State, province, or the equivalent location of the origin address. Use 3 letters of ISO 3166-1 country/region code for countries/regions without state.
**Either `origin_address.state` or `origin_address.postal_code` is required.** # state?: String; attr_accessor :state @@ -14,7 +14,7 @@ class EstimatedDeliveryDateRequestOriginAddress # city?: String; attr_accessor :city - # Postal code of the origin address. Use 3 letters of ISO 3166-1 country/region code for countries/regions without postal code. Either `origin_address.state` or `origin_address.postal_code` is required. + # Postal code of the origin address. Use 3 letters of ISO 3166-1 country/region code for countries/regions without postal code.
**Either `origin_address.state` or `origin_address.postal_code` is required.** # postal_code?: String; attr_accessor :postal_code diff --git a/lib/aftership-tracking-sdk/models/tracking.rb b/lib/aftership-tracking-sdk/models/tracking.rb index 7ff11a4..4acbdd9 100644 --- a/lib/aftership-tracking-sdk/models/tracking.rb +++ b/lib/aftership-tracking-sdk/models/tracking.rb @@ -122,6 +122,10 @@ class Tracking # shipment_weight?: TrackingShipmentWeight; attr_accessor :shipment_weight + # Physical dimensions of the package (length, width and height). + # shipment_dimensions?: TrackingShipmentDimensions; + attr_accessor :shipment_dimensions + # Signed by information for delivered shipment. # signed_by?: String; attr_accessor :signed_by @@ -298,6 +302,26 @@ class Tracking # customers?: TrackingCustomers[]; attr_accessor :customers + # An array of proof of delivery (POD) records, such as a signature or photo captured upon successful delivery.This field returns a value only after the feature is enabled. Please contact your customer success manager if you'd like to know more. + # proof_of_delivery?: TrackingProofOfDelivery[]; + attr_accessor :proof_of_delivery + + # Multi-piece shipment refers to a scenario where a single shipment order is fulfilled by multiple physical packages. Each piece has its own carrier-assigned tracking number, but all pieces belong to the same shipment. This commonly occurs when an order is too large to fit in one box, or when items are packed separately for handling reasons.This field contains multi-piece shipment metadata describing a group of packages that belong to the same shipment.This field returns a value only when your subscription plan includes a multi-piece feature. To enable, go to . + # multi_piece_info?: TrackingMultiPieceInfo; + attr_accessor :multi_piece_info + + # Indicates the business direction of the shipment in the e-commerce fulfillment lifecycle.Possible values:- `forward`: A forward (outbound-to-customer) shipment created for order fulfillment.- `return`: A return (customer-to-merchant) shipment created for after-sales return or exchange.This field is populated in either of the following cases:1. You explicitly provided it when creating the tracking.2. AfterShip automatically detected a linked forward or return shipment.It also determines which related shipment object (`forward_shipment` or `return_shipment`) may appear in the response. + # shipment_direction?: TrackingShipmentDirection; + attr_accessor :shipment_direction + + # The associated return shipment linked to the current outbound shipment.This field is only present when `shipment_direction = "forward"` and AfterShip has detected a linked return shipment. + # return_shipment?: TrackingReturnShipment; + attr_accessor :return_shipment + + # The original outbound shipment linked to this return. Use this to trace a return back to its source delivery.This field is only present when `shipment_direction = "return"` and AfterShip has detected a linked forward shipment. + # forward_shipment?: TrackingForwardShipment; + attr_accessor :forward_shipment + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -429,6 +453,10 @@ def initialize(attributes = {}) self.shipment_weight = attributes[:'shipment_weight'] end + if attributes.key?(:'shipment_dimensions') + self.shipment_dimensions = attributes[:'shipment_dimensions'] + end + if attributes.key?(:'signed_by') self.signed_by = attributes[:'signed_by'] end @@ -604,6 +632,26 @@ def initialize(attributes = {}) if attributes.key?(:'customers') self.customers = attributes[:'customers'] end + + if attributes.key?(:'proof_of_delivery') + self.proof_of_delivery = attributes[:'proof_of_delivery'] + end + + if attributes.key?(:'multi_piece_info') + self.multi_piece_info = attributes[:'multi_piece_info'] + end + + if attributes.key?(:'shipment_direction') + self.shipment_direction = attributes[:'shipment_direction'] + end + + if attributes.key?(:'return_shipment') + self.return_shipment = attributes[:'return_shipment'] + end + + if attributes.key?(:'forward_shipment') + self.forward_shipment = attributes[:'forward_shipment'] + end end # Attribute type mapping. @@ -639,6 +687,7 @@ def self.openapi_types :'shipment_delivery_date' => :'String', :'shipment_type' => :'String', :'shipment_weight' => :'TrackingShipmentWeight', + :'shipment_dimensions' => :'TrackingShipmentDimensions', :'signed_by' => :'String', :'source' => :'String', :'tag' => :'Tag', @@ -683,6 +732,11 @@ def self.openapi_types :'first_mile' => :'TrackingFirstMile', :'last_mile' => :'TrackingLastMile', :'customers' => :'Array', + :'proof_of_delivery' => :'Array', + :'multi_piece_info' => :'TrackingMultiPieceInfo', + :'shipment_direction' => :'TrackingShipmentDirection', + :'return_shipment' => :'TrackingReturnShipment', + :'forward_shipment' => :'TrackingForwardShipment', } end @@ -719,6 +773,7 @@ def self.attribute_map :'shipment_delivery_date' => :'shipment_delivery_date', :'shipment_type' => :'shipment_type', :'shipment_weight' => :'shipment_weight', + :'shipment_dimensions' => :'shipment_dimensions', :'signed_by' => :'signed_by', :'source' => :'source', :'tag' => :'tag', @@ -763,6 +818,11 @@ def self.attribute_map :'first_mile' => :'first_mile', :'last_mile' => :'last_mile', :'customers' => :'customers', + :'proof_of_delivery' => :'proof_of_delivery', + :'multi_piece_info' => :'multi_piece_info', + :'shipment_direction' => :'shipment_direction', + :'return_shipment' => :'return_shipment', + :'forward_shipment' => :'forward_shipment', } end diff --git a/lib/aftership-tracking-sdk/models/tracking_customers.rb b/lib/aftership-tracking-sdk/models/tracking_customers.rb index 2087e3a..0ecc9a0 100644 --- a/lib/aftership-tracking-sdk/models/tracking_customers.rb +++ b/lib/aftership-tracking-sdk/models/tracking_customers.rb @@ -22,6 +22,10 @@ class TrackingCustomers # language?: String; attr_accessor :language + # The customer's identifier on the merchant or platform (for example, Shopify) side. + # id?: String; + attr_accessor :id + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -52,6 +56,10 @@ def initialize(attributes = {}) if attributes.key?(:'language') self.language = attributes[:'language'] end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end end # Attribute type mapping. @@ -62,6 +70,7 @@ def self.openapi_types :'phone_number' => :'String', :'email' => :'String', :'language' => :'String', + :'id' => :'String', } end @@ -73,6 +82,7 @@ def self.attribute_map :'phone_number' => :'phone_number', :'email' => :'email', :'language' => :'language', + :'id' => :'id', } end diff --git a/lib/aftership-tracking-sdk/models/tracking_forward_shipment.rb b/lib/aftership-tracking-sdk/models/tracking_forward_shipment.rb new file mode 100644 index 0000000..f0881c9 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/tracking_forward_shipment.rb @@ -0,0 +1,151 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class TrackingForwardShipment + # AfterShip system-assigned unique identifier of the linked outbound shipment. + # id?: String; + attr_accessor :id + + # 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::TrackingForwardShipment` 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 + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + } + 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_multi_piece_info.rb b/lib/aftership-tracking-sdk/models/tracking_multi_piece_info.rb new file mode 100644 index 0000000..e4710c8 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/tracking_multi_piece_info.rb @@ -0,0 +1,161 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class TrackingMultiPieceInfo + # Indicates the role of the current tracking object within the multi-piece shipment.Possible values:- `master`: The main tracking number representing the entire shipment. It may not always exist.- `child`: A sub-tracking number belonging to one of the pieces in the shipment. + # type?: TrackingMultiPieceInfoType; + attr_accessor :type + + # List of all pieces in the MPS, including the master and all child pieces. + # pieces?: TrackingMultiPieceInfoPieces[]; + attr_accessor :pieces + + # 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::TrackingMultiPieceInfo` 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?(:'pieces') + self.pieces = attributes[:'pieces'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'TrackingMultiPieceInfoType', + :'pieces' => :'Array', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'pieces' => :'pieces', + } + 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_multi_piece_info_pieces.rb b/lib/aftership-tracking-sdk/models/tracking_multi_piece_info_pieces.rb new file mode 100644 index 0000000..cc0f5dc --- /dev/null +++ b/lib/aftership-tracking-sdk/models/tracking_multi_piece_info_pieces.rb @@ -0,0 +1,181 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class TrackingMultiPieceInfoPieces + # AfterShip system-assigned unique identifier for the piece. + # tracking_id?: String; + attr_accessor :tracking_id + + # Carrier-assigned tracking number for the piece. + # tracking_number?: String; + attr_accessor :tracking_number + + # Type of the piece within the MPS: `master` or `child`. + # type?: TrackingMultiPieceInfoPiecesType; + attr_accessor :type + + # Indicates whether the tracking number can be used to retrieve tracking updates on the carrier's side. If not, it means the carrier can only return a child tracking number, but cannot independently provide tracking updates for the sub-shipment. In this case, it is not recommended for you to import this tracking number into AfterShip for tracking. + # trackable?: Boolean; + attr_accessor :trackable + + # 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::TrackingMultiPieceInfoPieces` initialize method" + end + + attributes = attributes.each_with_object({}) { |(k, v), h| + h[k.to_sym] = v + } + + if attributes.key?(:'tracking_id') + self.tracking_id = attributes[:'tracking_id'] + end + + if attributes.key?(:'tracking_number') + self.tracking_number = attributes[:'tracking_number'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + + if attributes.key?(:'trackable') + self.trackable = attributes[:'trackable'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'tracking_id' => :'String', + :'tracking_number' => :'String', + :'type' => :'TrackingMultiPieceInfoPiecesType', + :'trackable' => :'Boolean', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'tracking_id' => :'tracking_id', + :'tracking_number' => :'tracking_number', + :'type' => :'type', + :'trackable' => :'trackable', + } + 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_multi_piece_info_pieces_type.rb b/lib/aftership-tracking-sdk/models/tracking_multi_piece_info_pieces_type.rb new file mode 100644 index 0000000..88daf33 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/tracking_multi_piece_info_pieces_type.rb @@ -0,0 +1,26 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class TrackingMultiPieceInfoPiecesType + MASTER = "master".freeze + CHILD = "child".freeze + def self.all_vars + @all_vars ||= [MASTER, CHILD,].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 TrackingMultiPieceInfoPiecesType.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #TrackingMultiPieceInfoPiecesType" + end + end +end diff --git a/lib/aftership-tracking-sdk/models/tracking_multi_piece_info_type.rb b/lib/aftership-tracking-sdk/models/tracking_multi_piece_info_type.rb new file mode 100644 index 0000000..f25512a --- /dev/null +++ b/lib/aftership-tracking-sdk/models/tracking_multi_piece_info_type.rb @@ -0,0 +1,26 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class TrackingMultiPieceInfoType + MASTER = "master".freeze + CHILD = "child".freeze + def self.all_vars + @all_vars ||= [MASTER, CHILD,].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 TrackingMultiPieceInfoType.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #TrackingMultiPieceInfoType" + end + end +end diff --git a/lib/aftership-tracking-sdk/models/tracking_proof_of_delivery.rb b/lib/aftership-tracking-sdk/models/tracking_proof_of_delivery.rb new file mode 100644 index 0000000..0698988 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/tracking_proof_of_delivery.rb @@ -0,0 +1,161 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class TrackingProofOfDelivery + # The file type of the proof of delivery record. Currently, only images are supported. + # type?: String; + attr_accessor :type + + # The URL of the proof of delivery record. + # url?: String; + attr_accessor :url + + # 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::TrackingProofOfDelivery` 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?(:'url') + self.url = attributes[:'url'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'type' => :'String', + :'url' => :'String', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'type' => :'type', + :'url' => :'url', + } + 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.rb b/lib/aftership-tracking-sdk/models/tracking_response.rb index 81ea612..2fc9c40 100644 --- a/lib/aftership-tracking-sdk/models/tracking_response.rb +++ b/lib/aftership-tracking-sdk/models/tracking_response.rb @@ -6,7 +6,7 @@ class TrackingResponse # meta: Meta; attr_accessor :meta - # Object describes the tracking information.
+ # Object describes the tracking information.
# data: Tracking; attr_accessor :data diff --git a/lib/aftership-tracking-sdk/models/tracking_return_shipment.rb b/lib/aftership-tracking-sdk/models/tracking_return_shipment.rb new file mode 100644 index 0000000..7725a3c --- /dev/null +++ b/lib/aftership-tracking-sdk/models/tracking_return_shipment.rb @@ -0,0 +1,171 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class TrackingReturnShipment + # AfterShip system-assigned unique identifier of the linked return shipment.This field is only returned when both of the following conditions are met:1. AfterShip has detected a linked return shipment.2. The Auto-import for return shipments feature is enabled in your AfterShip account.When auto-import is disabled, `id` will not be returned, but `tracking_number` and `slug` may still be present.To enable this feature, go to . + # id?: String; + attr_accessor :id + + # Carrier-assigned tracking number of the linked return shipment. Can be used together with `return_shipment.slug` to create a new tracking subscription and retrieve the return shipment's checkpoints. + # tracking_number?: String; + attr_accessor :tracking_number + + # Carrier slug (identifier) of the linked return shipment. Can be used together with `return_shipment.tracking_number` to subscribe to tracking updates for the return shipment. + # slug?: String; + attr_accessor :slug + + # 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::TrackingReturnShipment` 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 + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'tracking_number' => :'String', + :'slug' => :'String', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'tracking_number' => :'tracking_number', + :'slug' => :'slug', + } + 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_shipment_dimensions.rb b/lib/aftership-tracking-sdk/models/tracking_shipment_dimensions.rb new file mode 100644 index 0000000..04988fd --- /dev/null +++ b/lib/aftership-tracking-sdk/models/tracking_shipment_dimensions.rb @@ -0,0 +1,181 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class TrackingShipmentDimensions + # The unit in which the dimension values are expressed. Allowed values: cm, in + # unit?: String; + attr_accessor :unit + + # The length of the shipment package. + # length?: Float; + attr_accessor :length + + # The width of the shipment package. + # width?: Float; + attr_accessor :width + + # The height of the shipment package. + # height?: Float; + attr_accessor :height + + # 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::TrackingShipmentDimensions` 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?(:'length') + self.length = attributes[:'length'] + end + + if attributes.key?(:'width') + self.width = attributes[:'width'] + end + + if attributes.key?(:'height') + self.height = attributes[:'height'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'unit' => :'String', + :'length' => :'Float', + :'width' => :'Float', + :'height' => :'Float', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'unit' => :'unit', + :'length' => :'length', + :'width' => :'width', + :'height' => :'height', + } + 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_shipment_direction.rb b/lib/aftership-tracking-sdk/models/tracking_shipment_direction.rb new file mode 100644 index 0000000..b3a4e95 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/tracking_shipment_direction.rb @@ -0,0 +1,27 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class TrackingShipmentDirection + FORWARD = "forward".freeze + RETURN = "return".freeze + NULL = "null".freeze + def self.all_vars + @all_vars ||= [FORWARD, RETURN, NULL,].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 TrackingShipmentDirection.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #TrackingShipmentDirection" + end + end +end diff --git a/lib/aftership-tracking-sdk/models/update_tracking_by_id_request.rb b/lib/aftership-tracking-sdk/models/update_tracking_by_id_request.rb index 888e81a..d5337ef 100644 --- a/lib/aftership-tracking-sdk/models/update_tracking_by_id_request.rb +++ b/lib/aftership-tracking-sdk/models/update_tracking_by_id_request.rb @@ -122,6 +122,10 @@ class UpdateTrackingByIdRequest # customers?: UpdateTrackingByIdRequestCustomers[]; attr_accessor :customers + # Indicates the business direction of the shipment in the e-commerce fulfillment lifecycle.Possible values:- `forward`: A forward (outbound-to-customer) shipment created for order fulfillment.- `return`: A return (customer-to-merchant) shipment created for after-sales return or exchange.When provided, this field gives AfterShip additional context about the shipment's intent, enabling more accurate status identification. + # shipment_direction?: UpdateTrackingByIdRequestShipmentDirection; + attr_accessor :shipment_direction + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -252,6 +256,10 @@ def initialize(attributes = {}) if attributes.key?(:'customers') self.customers = attributes[:'customers'] end + + if attributes.key?(:'shipment_direction') + self.shipment_direction = attributes[:'shipment_direction'] + end end # Attribute type mapping. @@ -287,6 +295,7 @@ def self.openapi_types :'location_id' => :'String', :'shipping_method' => :'String', :'customers' => :'Array', + :'shipment_direction' => :'UpdateTrackingByIdRequestShipmentDirection', } end @@ -323,6 +332,7 @@ def self.attribute_map :'location_id' => :'location_id', :'shipping_method' => :'shipping_method', :'customers' => :'customers', + :'shipment_direction' => :'shipment_direction', } end diff --git a/lib/aftership-tracking-sdk/models/update_tracking_by_id_request_customers.rb b/lib/aftership-tracking-sdk/models/update_tracking_by_id_request_customers.rb index 55662c8..bbdb661 100644 --- a/lib/aftership-tracking-sdk/models/update_tracking_by_id_request_customers.rb +++ b/lib/aftership-tracking-sdk/models/update_tracking_by_id_request_customers.rb @@ -22,6 +22,10 @@ class UpdateTrackingByIdRequestCustomers # language?: String; attr_accessor :language + # The customer's identifier on the merchant or platform (for example, Shopify) side. + # id?: String; + attr_accessor :id + # Initializes the object # @param [Hash] attributes Model attributes in the form of hash def initialize(attributes = {}) @@ -52,6 +56,10 @@ def initialize(attributes = {}) if attributes.key?(:'language') self.language = attributes[:'language'] end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end end # Attribute type mapping. @@ -62,6 +70,7 @@ def self.openapi_types :'phone_number' => :'String', :'email' => :'String', :'language' => :'String', + :'id' => :'String', } end @@ -73,6 +82,7 @@ def self.attribute_map :'phone_number' => :'phone_number', :'email' => :'email', :'language' => :'language', + :'id' => :'id', } end diff --git a/lib/aftership-tracking-sdk/models/update_tracking_by_id_request_shipment_direction.rb b/lib/aftership-tracking-sdk/models/update_tracking_by_id_request_shipment_direction.rb new file mode 100644 index 0000000..b3fd399 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/update_tracking_by_id_request_shipment_direction.rb @@ -0,0 +1,26 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class UpdateTrackingByIdRequestShipmentDirection + FORWARD = "forward".freeze + RETURN = "return".freeze + def self.all_vars + @all_vars ||= [FORWARD, RETURN,].freeze + end + + # Builds the enum from string + # @param value [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param value [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + return value if UpdateTrackingByIdRequestShipmentDirection.all_vars.include?(value) + raise "Invalid ENUM value #{value} for class #UpdateTrackingByIdRequestShipmentDirection" + end + end +end diff --git a/lib/aftership-tracking-sdk/version.rb b/lib/aftership-tracking-sdk/version.rb index e4a0a13..dcee71f 100644 --- a/lib/aftership-tracking-sdk/version.rb +++ b/lib/aftership-tracking-sdk/version.rb @@ -1,5 +1,5 @@ # This code was auto generated by AfterShip SDK Generator. # Do not edit the class manually. module AftershipAPI - VERSION = '14.0.0' + VERSION = '15.0.0' end