From 4e7b9fc3b2d1b4a6128a8be5150c76401d2f95b4 Mon Sep 17 00:00:00 2001 From: panxl6 Date: Mon, 20 Jan 2025 13:45:16 +0800 Subject: [PATCH] feat: supporting 2025-01 version. --- .gitignore | 63 ++ .rubocop.yml | 145 +++ Gemfile | 12 + LICENSE | 21 + README.md | 272 ++++- aftership-tracking-sdk.gemspec | 27 + lib/aftership-tracking-sdk.rb | 47 + lib/aftership-tracking-sdk/api/courier.rb | 163 +++ .../api/estimated_delivery_date.rb | 121 +++ lib/aftership-tracking-sdk/api/tracking.rb | 427 ++++++++ lib/aftership-tracking-sdk/api_client.rb | 426 ++++++++ lib/aftership-tracking-sdk/configuration.rb | 122 +++ lib/aftership-tracking-sdk/error.rb | 125 +++ .../models/additional_fields_v1.rb | 32 + ..._delivery_date_create_tracking_response.rb | 183 ++++ ...ery_date_delete_tracking_by_id_response.rb | 183 ++++ ...livery_date_get_tracking_by_id_response.rb | 183 ++++ ..._mark_tracking_completed_by_id_response.rb | 183 ++++ ...ry_date_retrack_tracking_by_id_response.rb | 183 ++++ ...ership_estimated_delivery_date_tracking.rb | 183 ++++ ...ery_date_update_tracking_by_id_response.rb | 183 ++++ ...rbon_emissions_create_tracking_response.rb | 163 +++ ...missions_delete_tracking_by_id_response.rb | 163 +++ ...n_emissions_get_tracking_by_id_response.rb | 163 +++ ..._mark_tracking_completed_by_id_response.rb | 163 +++ ...issions_retrack_tracking_by_id_response.rb | 163 +++ .../models/carbon_emissions_tracking.rb | 163 +++ ...missions_update_tracking_by_id_response.rb | 163 +++ .../models/checkpoint.rb | 313 ++++++ .../models/coordinate_checkpoint.rb | 163 +++ lib/aftership-tracking-sdk/models/courier.rb | 243 +++++ ..._delivery_date_create_tracking_response.rb | 173 ++++ ...ery_date_delete_tracking_by_id_response.rb | 173 ++++ ...livery_date_get_tracking_by_id_response.rb | 173 ++++ ..._mark_tracking_completed_by_id_response.rb | 173 ++++ ...ry_date_retrack_tracking_by_id_response.rb | 173 ++++ ...ourier_estimated_delivery_date_tracking.rb | 173 ++++ ...ery_date_update_tracking_by_id_response.rb | 173 ++++ .../models/courier_response_v1.rb | 163 +++ .../models/create_tracking_request.rb | 533 ++++++++++ .../models/create_tracking_response.rb | 933 ++++++++++++++++++ ..._delivery_date_create_tracking_response.rb | 183 ++++ ...ery_date_delete_tracking_by_id_response.rb | 183 ++++ ...livery_date_get_tracking_by_id_response.rb | 183 ++++ ..._mark_tracking_completed_by_id_response.rb | 183 ++++ ...ry_date_retrack_tracking_by_id_response.rb | 183 ++++ ...custom_estimated_delivery_date_tracking.rb | 183 ++++ ...ery_date_update_tracking_by_id_response.rb | 183 ++++ .../customers_create_tracking_request.rb | 193 ++++ .../customers_create_tracking_response.rb | 193 ++++ ...ustomers_delete_tracking_by_id_response.rb | 193 ++++ .../customers_get_tracking_by_id_response.rb | 193 ++++ ..._mark_tracking_completed_by_id_response.rb | 193 ++++ ...stomers_retrack_tracking_by_id_response.rb | 193 ++++ .../models/customers_tracking.rb | 193 ++++ ...customers_update_tracking_by_id_request.rb | 193 ++++ ...ustomers_update_tracking_by_id_response.rb | 193 ++++ .../models/data_courier_response_v1.rb | 163 +++ .../data_tracking_response_get_multiple_v1.rb | 163 +++ .../models/delete_tracking_by_id_response.rb | 933 ++++++++++++++++++ ...address_estimated_delivery_date_request.rb | 193 ++++ ...ddress_estimated_delivery_date_response.rb | 193 ++++ .../destination_address_predict_request.rb | 193 ++++ .../destination_address_predict_response.rb | 193 ++++ .../models/detect_courier_request.rb | 263 +++++ .../models/detect_courier_response.rb | 163 +++ .../models/estimated_delivery_date_request.rb | 223 +++++ .../estimated_delivery_date_response.rb | 273 +++++ ..._pickup_estimated_delivery_date_request.rb | 183 ++++ ...pickup_estimated_delivery_date_response.rb | 193 ++++ .../estimated_pickup_predict_request.rb | 183 ++++ .../estimated_pickup_predict_response.rb | 193 ++++ .../models/events_checkpoint.rb | 163 +++ ...mated_delivery_create_tracking_response.rb | 193 ++++ ...delivery_delete_tracking_by_id_response.rb | 193 ++++ ...ed_delivery_get_tracking_by_id_response.rb | 193 ++++ ..._mark_tracking_completed_by_id_response.rb | 193 ++++ ...elivery_retrack_tracking_by_id_response.rb | 193 ++++ .../first_estimated_delivery_tracking.rb | 193 ++++ ...delivery_update_tracking_by_id_response.rb | 193 ++++ .../first_mile_create_tracking_response.rb | 193 ++++ ...rst_mile_delete_tracking_by_id_response.rb | 193 ++++ .../first_mile_get_tracking_by_id_response.rb | 193 ++++ ..._mark_tracking_completed_by_id_response.rb | 193 ++++ ...st_mile_retrack_tracking_by_id_response.rb | 193 ++++ .../models/first_mile_tracking.rb | 193 ++++ ...rst_mile_update_tracking_by_id_response.rb | 193 ++++ .../models/get_all_couriers_response.rb | 163 +++ .../models/get_tracking_by_id_response.rb | 933 ++++++++++++++++++ .../models/get_trackings_response.rb | 163 +++ .../models/get_user_couriers_response.rb | 163 +++ .../last_mile_create_tracking_request.rb | 163 +++ .../last_mile_create_tracking_response.rb | 203 ++++ ...ast_mile_delete_tracking_by_id_response.rb | 203 ++++ .../last_mile_get_tracking_by_id_response.rb | 203 ++++ ..._mark_tracking_completed_by_id_response.rb | 203 ++++ ...st_mile_retrack_tracking_by_id_response.rb | 203 ++++ .../models/last_mile_tracking.rb | 203 ++++ ...ast_mile_update_tracking_by_id_response.rb | 203 ++++ ...mated_delivery_create_tracking_response.rb | 193 ++++ ...delivery_delete_tracking_by_id_response.rb | 193 ++++ ...ed_delivery_get_tracking_by_id_response.rb | 193 ++++ ..._mark_tracking_completed_by_id_response.rb | 193 ++++ ...elivery_retrack_tracking_by_id_response.rb | 193 ++++ .../latest_estimated_delivery_tracking.rb | 193 ++++ ...delivery_update_tracking_by_id_response.rb | 193 ++++ .../mark_tracking_completed_by_id_request.rb | 153 +++ .../mark_tracking_completed_by_id_response.rb | 933 ++++++++++++++++++ lib/aftership-tracking-sdk/models/meta_v1.rb | 173 ++++ ..._pickup_estimated_delivery_date_request.rb | 163 +++ ...pickup_estimated_delivery_date_response.rb | 163 +++ ...g_time_estimated_pickup_predict_request.rb | 163 +++ ..._time_estimated_pickup_predict_response.rb | 163 +++ ...address_estimated_delivery_date_request.rb | 193 ++++ ...ddress_estimated_delivery_date_response.rb | 193 ++++ .../models/origin_address_predict_request.rb | 193 ++++ .../models/origin_address_predict_response.rb | 193 ++++ .../models/pagination.rb | 164 +++ ..._data_tracking_response_get_multiple_v1.rb | 173 ++++ .../pagination_get_trackings_response.rb | 173 ++++ .../models/predict_batch_request.rb | 153 +++ .../models/predict_batch_response.rb | 153 +++ .../models/predict_request.rb | 223 +++++ .../models/predict_response.rb | 273 +++++ .../models/reason_events_checkpoint.rb | 153 +++ .../models/retrack_tracking_by_id_response.rb | 933 ++++++++++++++++++ ...hipment_weight_create_tracking_response.rb | 163 +++ ...t_weight_delete_tracking_by_id_response.rb | 163 +++ ...ment_weight_get_tracking_by_id_response.rb | 163 +++ ..._mark_tracking_completed_by_id_response.rb | 163 +++ ..._weight_retrack_tracking_by_id_response.rb | 163 +++ .../models/shipment_weight_tracking.rb | 163 +++ ...t_weight_update_tracking_by_id_response.rb | 163 +++ .../models/slug_group_v1.rb | 37 + lib/aftership-tracking-sdk/models/tag_v1.rb | 34 + lib/aftership-tracking-sdk/models/tracking.rb | 933 ++++++++++++++++++ .../tracking_response_get_multiple_v1.rb | 163 +++ .../models/tracking_response_v1.rb | 163 +++ .../models/update_tracking_by_id_request.rb | 483 +++++++++ .../models/update_tracking_by_id_response.rb | 933 ++++++++++++++++++ .../weight_estimated_delivery_date_request.rb | 163 +++ ...weight_estimated_delivery_date_response.rb | 163 +++ .../models/weight_predict_request.rb | 163 +++ .../models/weight_predict_response.rb | 163 +++ lib/aftership-tracking-sdk/sign_string.rb | 77 ++ lib/aftership-tracking-sdk/version.rb | 5 + 146 files changed, 31630 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 .rubocop.yml create mode 100644 Gemfile create mode 100644 LICENSE create mode 100644 aftership-tracking-sdk.gemspec create mode 100644 lib/aftership-tracking-sdk.rb create mode 100644 lib/aftership-tracking-sdk/api/courier.rb create mode 100644 lib/aftership-tracking-sdk/api/estimated_delivery_date.rb create mode 100644 lib/aftership-tracking-sdk/api/tracking.rb create mode 100644 lib/aftership-tracking-sdk/api_client.rb create mode 100644 lib/aftership-tracking-sdk/configuration.rb create mode 100644 lib/aftership-tracking-sdk/error.rb create mode 100644 lib/aftership-tracking-sdk/models/additional_fields_v1.rb create mode 100644 lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_create_tracking_response.rb create mode 100644 lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_delete_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_get_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_mark_tracking_completed_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_retrack_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_tracking.rb create mode 100644 lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_update_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/carbon_emissions_create_tracking_response.rb create mode 100644 lib/aftership-tracking-sdk/models/carbon_emissions_delete_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/carbon_emissions_get_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/carbon_emissions_mark_tracking_completed_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/carbon_emissions_retrack_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/carbon_emissions_tracking.rb create mode 100644 lib/aftership-tracking-sdk/models/carbon_emissions_update_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/checkpoint.rb create mode 100644 lib/aftership-tracking-sdk/models/coordinate_checkpoint.rb create mode 100644 lib/aftership-tracking-sdk/models/courier.rb create mode 100644 lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_create_tracking_response.rb create mode 100644 lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_delete_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_get_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_mark_tracking_completed_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_retrack_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_tracking.rb create mode 100644 lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_update_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/courier_response_v1.rb create mode 100644 lib/aftership-tracking-sdk/models/create_tracking_request.rb create mode 100644 lib/aftership-tracking-sdk/models/create_tracking_response.rb create mode 100644 lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_create_tracking_response.rb create mode 100644 lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_delete_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_get_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_mark_tracking_completed_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_retrack_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_tracking.rb create mode 100644 lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_update_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/customers_create_tracking_request.rb create mode 100644 lib/aftership-tracking-sdk/models/customers_create_tracking_response.rb create mode 100644 lib/aftership-tracking-sdk/models/customers_delete_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/customers_get_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/customers_mark_tracking_completed_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/customers_retrack_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/customers_tracking.rb create mode 100644 lib/aftership-tracking-sdk/models/customers_update_tracking_by_id_request.rb create mode 100644 lib/aftership-tracking-sdk/models/customers_update_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/data_courier_response_v1.rb create mode 100644 lib/aftership-tracking-sdk/models/data_tracking_response_get_multiple_v1.rb create mode 100644 lib/aftership-tracking-sdk/models/delete_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/destination_address_estimated_delivery_date_request.rb create mode 100644 lib/aftership-tracking-sdk/models/destination_address_estimated_delivery_date_response.rb create mode 100644 lib/aftership-tracking-sdk/models/destination_address_predict_request.rb create mode 100644 lib/aftership-tracking-sdk/models/destination_address_predict_response.rb create mode 100644 lib/aftership-tracking-sdk/models/detect_courier_request.rb create mode 100644 lib/aftership-tracking-sdk/models/detect_courier_response.rb create mode 100644 lib/aftership-tracking-sdk/models/estimated_delivery_date_request.rb create mode 100644 lib/aftership-tracking-sdk/models/estimated_delivery_date_response.rb create mode 100644 lib/aftership-tracking-sdk/models/estimated_pickup_estimated_delivery_date_request.rb create mode 100644 lib/aftership-tracking-sdk/models/estimated_pickup_estimated_delivery_date_response.rb create mode 100644 lib/aftership-tracking-sdk/models/estimated_pickup_predict_request.rb create mode 100644 lib/aftership-tracking-sdk/models/estimated_pickup_predict_response.rb create mode 100644 lib/aftership-tracking-sdk/models/events_checkpoint.rb create mode 100644 lib/aftership-tracking-sdk/models/first_estimated_delivery_create_tracking_response.rb create mode 100644 lib/aftership-tracking-sdk/models/first_estimated_delivery_delete_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/first_estimated_delivery_get_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/first_estimated_delivery_mark_tracking_completed_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/first_estimated_delivery_retrack_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/first_estimated_delivery_tracking.rb create mode 100644 lib/aftership-tracking-sdk/models/first_estimated_delivery_update_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/first_mile_create_tracking_response.rb create mode 100644 lib/aftership-tracking-sdk/models/first_mile_delete_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/first_mile_get_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/first_mile_mark_tracking_completed_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/first_mile_retrack_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/first_mile_tracking.rb create mode 100644 lib/aftership-tracking-sdk/models/first_mile_update_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/get_all_couriers_response.rb create mode 100644 lib/aftership-tracking-sdk/models/get_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/get_trackings_response.rb create mode 100644 lib/aftership-tracking-sdk/models/get_user_couriers_response.rb create mode 100644 lib/aftership-tracking-sdk/models/last_mile_create_tracking_request.rb create mode 100644 lib/aftership-tracking-sdk/models/last_mile_create_tracking_response.rb create mode 100644 lib/aftership-tracking-sdk/models/last_mile_delete_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/last_mile_get_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/last_mile_mark_tracking_completed_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/last_mile_retrack_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/last_mile_tracking.rb create mode 100644 lib/aftership-tracking-sdk/models/last_mile_update_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/latest_estimated_delivery_create_tracking_response.rb create mode 100644 lib/aftership-tracking-sdk/models/latest_estimated_delivery_delete_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/latest_estimated_delivery_get_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/latest_estimated_delivery_mark_tracking_completed_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/latest_estimated_delivery_retrack_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/latest_estimated_delivery_tracking.rb create mode 100644 lib/aftership-tracking-sdk/models/latest_estimated_delivery_update_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/mark_tracking_completed_by_id_request.rb create mode 100644 lib/aftership-tracking-sdk/models/mark_tracking_completed_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/meta_v1.rb create mode 100644 lib/aftership-tracking-sdk/models/order_processing_time_estimated_pickup_estimated_delivery_date_request.rb create mode 100644 lib/aftership-tracking-sdk/models/order_processing_time_estimated_pickup_estimated_delivery_date_response.rb create mode 100644 lib/aftership-tracking-sdk/models/order_processing_time_estimated_pickup_predict_request.rb create mode 100644 lib/aftership-tracking-sdk/models/order_processing_time_estimated_pickup_predict_response.rb create mode 100644 lib/aftership-tracking-sdk/models/origin_address_estimated_delivery_date_request.rb create mode 100644 lib/aftership-tracking-sdk/models/origin_address_estimated_delivery_date_response.rb create mode 100644 lib/aftership-tracking-sdk/models/origin_address_predict_request.rb create mode 100644 lib/aftership-tracking-sdk/models/origin_address_predict_response.rb create mode 100644 lib/aftership-tracking-sdk/models/pagination.rb create mode 100644 lib/aftership-tracking-sdk/models/pagination_data_tracking_response_get_multiple_v1.rb create mode 100644 lib/aftership-tracking-sdk/models/pagination_get_trackings_response.rb create mode 100644 lib/aftership-tracking-sdk/models/predict_batch_request.rb create mode 100644 lib/aftership-tracking-sdk/models/predict_batch_response.rb create mode 100644 lib/aftership-tracking-sdk/models/predict_request.rb create mode 100644 lib/aftership-tracking-sdk/models/predict_response.rb create mode 100644 lib/aftership-tracking-sdk/models/reason_events_checkpoint.rb create mode 100644 lib/aftership-tracking-sdk/models/retrack_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/shipment_weight_create_tracking_response.rb create mode 100644 lib/aftership-tracking-sdk/models/shipment_weight_delete_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/shipment_weight_get_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/shipment_weight_mark_tracking_completed_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/shipment_weight_retrack_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/shipment_weight_tracking.rb create mode 100644 lib/aftership-tracking-sdk/models/shipment_weight_update_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/slug_group_v1.rb create mode 100644 lib/aftership-tracking-sdk/models/tag_v1.rb create mode 100644 lib/aftership-tracking-sdk/models/tracking.rb create mode 100644 lib/aftership-tracking-sdk/models/tracking_response_get_multiple_v1.rb create mode 100644 lib/aftership-tracking-sdk/models/tracking_response_v1.rb create mode 100644 lib/aftership-tracking-sdk/models/update_tracking_by_id_request.rb create mode 100644 lib/aftership-tracking-sdk/models/update_tracking_by_id_response.rb create mode 100644 lib/aftership-tracking-sdk/models/weight_estimated_delivery_date_request.rb create mode 100644 lib/aftership-tracking-sdk/models/weight_estimated_delivery_date_response.rb create mode 100644 lib/aftership-tracking-sdk/models/weight_predict_request.rb create mode 100644 lib/aftership-tracking-sdk/models/weight_predict_response.rb create mode 100644 lib/aftership-tracking-sdk/sign_string.rb create mode 100644 lib/aftership-tracking-sdk/version.rb 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..d655afe --- /dev/null +++ b/Gemfile @@ -0,0 +1,12 @@ +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..39025bd --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 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..1c1cdaa 100644 --- a/README.md +++ b/README.md @@ -1 +1,271 @@ -# 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 Ruby. + +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) + - [API and SDK Version](#api-and-sdk-version) + - [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) + - [/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. + + +### API and SDK Version + +Each SDK version is designed to work with a specific API version. Please refer to the table below to identify the supported API versions for each SDK version, ensuring you select the appropriate SDK version for the API version you intend to use. + +| SDK Version | Supported API Version | Branch | +| ----------- | --------------------- | ----------------------------------------------------------- | +| 10.x.x | 2025-01 | https://github.com/AfterShip/tracking-sdk-ruby/tree/2025-01 | +| 9.x.x | 2024-10 | https://github.com/AfterShip/tracking-sdk-ruby/tree/2024-10 | +| 8.x.x | 2024-07 | https://github.com/AfterShip/tracking-sdk-ruby/tree/2024-07 | +| 7.x.x | 2024-04 | https://github.com/AfterShip/tracking-sdk-ruby/tree/2024-04 | +| <=6.x.x | Legacy API | https://github.com/AfterShip/aftership-sdk-ruby | + +## Quick Start + +### Installation +```bash +gem install aftership-tracking-sdk +``` + +Or add a line to your Gemfile + +```bash +gem 'aftership-tracking-sdk', '~> 10.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::ApiError => e + p e.message +end +``` + +## Rate Limiter + +See the [Rate Limit](https://www.aftership.com/docs/tracking/2025-01/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. | +| response_headers | object | API response header. | + +### 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. +- estimated-delivery-date - Get estimated delivery date for your order. + + +### /trackings + +**POST** /trackings + +```ruby +begin + req = AftershipAPI::Model::CreateTrackingRequest. new + req.tracking_number = "" + req.slug = "" + + resp = AftershipAPI::Tracking.create_tracking(body: req) + p resp +rescue AftershipAPI::ApiError => e + p e.message +end +``` + +**DELETE** /trackings/:id + +```ruby +resp = AftershipAPI::Tracking.delete_tracking_by_id(id: "") +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: "") +p resp.to_json +``` + +**PUT** /trackings/:id + +```ruby +req = AftershipAPI::Model::UpdateTrackingByIdRequest.new +req.note = "test update" +resp = AftershipAPI::Tracking.update_tracking_by_id(id: "", body: req) +p resp.to_json +``` + +**POST** /trackings/:id/retrack + +```ruby +resp = AftershipAPI::Tracking.retrack_tracking_by_id(id: "") +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: "", 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::DetectCourierRequest.new +req.tracking_number = "" +resp = AftershipAPI::Courier.detect_courier(body: req) +p resp.to_json +``` + +### /estimated-delivery-date + +**POST** /estimated-delivery-date/predict-batch + +```ruby +edd = AftershipAPI::Model::EstimatedDeliveryDateRequest.new +edd.slug = "" +edd.pickup_time = "2024-08-01 06:42:30" +origin = AftershipAPI::Model::OriginAddressEstimatedDeliveryDateRequest.new +origin.country_region = "" +origin.state = "" + +dest = AftershipAPI::Model::DestinationAddressEstimatedDeliveryDateRequest.new +dest.country_region = "" +dest.state = "" + +edd.origin_address = origin +edd.destination_address = dest + +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) 2025 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..c747128 --- /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::DetectCourierRequest] + # @param [Hash] opts the optional parameters + # @return [Model::DetectCourierResponse] + def detect_courier(body:,opts: {}) + if "" != "" + body = {:'' => 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/2025-01/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/2025-01/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/2025-01/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 \ No newline at end of file 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..4f9adcb --- /dev/null +++ b/lib/aftership-tracking-sdk/api/estimated_delivery_date.rb @@ -0,0 +1,121 @@ +# 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 + # > 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. + + # @param body [Model::PredictRequest] + # @param [Hash] opts the optional parameters + # @return [Model::PredictResponse] + def predict(body:,opts: {}) + if "" != "" + body = {:'' => body} + end + opts[:body] = body + data, _status_code, _headers = predict_with_http_info(opts: opts) + data + end + + def predict_with_http_info(opts: {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: EstimatedDeliveryDateApi.predict ...' + end + + + + # resource path + local_var_path = "/tracking/2025-01/estimated-delivery-date/predict" + 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 = 'PredictResponse' + + new_options = opts.merge( + :operation => :"EstimatedDeliveryDateApi.predict", + :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\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + 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/2025-01/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 \ No newline at end of file diff --git a/lib/aftership-tracking-sdk/api/tracking.rb b/lib/aftership-tracking-sdk/api/tracking.rb new file mode 100644 index 0000000..2dedbe0 --- /dev/null +++ b/lib/aftership-tracking-sdk/api/tracking.rb @@ -0,0 +1,427 @@ +# 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::CreateTrackingRequest] + # @param [Hash] opts the optional parameters + # @return [Model::CreateTrackingResponse] + def create_tracking(body:,opts: {}) + if "" != "" + body = {:'' => 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/2025-01/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 = 'CreateTrackingResponse' + + 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 => "", + :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::DeleteTrackingByIdResponse] + 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? or id.to_s == '' + raise InvalidParamError.new "id cannot be nil or empty" + end + + + # resource path + local_var_path = "/tracking/2025-01/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 = 'DeleteTrackingByIdResponse' + + 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 => "", + :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 + + # 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_region`, `tracking_destination_country_region`, `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::GetTrackingByIdResponse] + 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? or id.to_s == '' + raise InvalidParamError.new "id cannot be nil or empty" + end + + + # resource path + local_var_path = "/tracking/2025-01/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 = 'GetTrackingByIdResponse' + + 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 => "", + :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_trackings + # Get tracking results of multiple trackings.
+ # @param [Hash] opts the optional parameters + # @option opts [String] :cursor A string representing the cursor value for the current page of results. + # @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`, `customers[x].name`, `custom_fields`, `customers[x].email`, `customers[x].phone_number` + # @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. Please make sure the value of the parameter is properly escaped in + # @option opts [String] :created_at_max End date and time of trackings created. Please make sure the value of the parameter is properly escaped in + # @option opts [String] :updated_at_min Start date and time of trackings updated. Please make sure the value of the parameter is properly escaped in + # @option opts [String] :updated_at_max End date and time of trackings updated. Please make sure the value of the parameter is properly escaped in + # @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_region 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/2025-01/trackings" + method = :'GET' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].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_region'] = opts[:'courier_destination_country_region'] if !opts[:'courier_destination_country_region'].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 => "", + :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::MarkTrackingCompletedByIdResponse] + 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? or id.to_s == '' + raise InvalidParamError.new "id cannot be nil or empty" + end + + + # resource path + local_var_path = "/tracking/2025-01/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 = 'MarkTrackingCompletedByIdResponse' + + 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 => "", + :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 + + # 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::RetrackTrackingByIdResponse] + 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? or id.to_s == '' + raise InvalidParamError.new "id cannot be nil or empty" + end + + + # resource path + local_var_path = "/tracking/2025-01/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 = 'RetrackTrackingByIdResponse' + + 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 => "", + :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 + + # update_tracking_by_id + # Update a tracking. + # @param id [String] tracking ID + + # @param body [Model::UpdateTrackingByIdRequest] + # @param [Hash] opts the optional parameters + # @return [Model::UpdateTrackingByIdResponse] + def update_tracking_by_id(id:, body:,opts: {}) + if "" != "" + body = {:'' => 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? or id.to_s == '' + raise InvalidParamError.new "id cannot be nil or empty" + end + + + # resource path + local_var_path = "/tracking/2025-01/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 = 'UpdateTrackingByIdResponse' + + 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 => "", + :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 + end +end \ No newline at end of file diff --git a/lib/aftership-tracking-sdk/api_client.rb b/lib/aftership-tracking-sdk/api_client.rb new file mode 100644 index 0000000..846924b --- /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..b79868d --- /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 and 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..50ae174 --- /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_REGION = "tracking_origin_country_region".freeze + TRACKING_DESTINATION_COUNTRY_REGION = "tracking_destination_country_region".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_REGION,TRACKING_DESTINATION_COUNTRY_REGION,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_create_tracking_response.rb b/lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_create_tracking_response.rb new file mode 100644 index 0000000..820a9e1 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_create_tracking_response.rb @@ -0,0 +1,183 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class AftershipEstimatedDeliveryDateCreateTrackingResponse + + # 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::AftershipEstimatedDeliveryDateCreateTrackingResponse` 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/aftership_estimated_delivery_date_delete_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_delete_tracking_by_id_response.rb new file mode 100644 index 0000000..198f4c1 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_delete_tracking_by_id_response.rb @@ -0,0 +1,183 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class AftershipEstimatedDeliveryDateDeleteTrackingByIdResponse + + # 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::AftershipEstimatedDeliveryDateDeleteTrackingByIdResponse` 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/aftership_estimated_delivery_date_get_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_get_tracking_by_id_response.rb new file mode 100644 index 0000000..4279c53 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_get_tracking_by_id_response.rb @@ -0,0 +1,183 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class AftershipEstimatedDeliveryDateGetTrackingByIdResponse + + # 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::AftershipEstimatedDeliveryDateGetTrackingByIdResponse` 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/aftership_estimated_delivery_date_mark_tracking_completed_by_id_response.rb b/lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_mark_tracking_completed_by_id_response.rb new file mode 100644 index 0000000..ee48640 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_mark_tracking_completed_by_id_response.rb @@ -0,0 +1,183 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class AftershipEstimatedDeliveryDateMarkTrackingCompletedByIdResponse + + # 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::AftershipEstimatedDeliveryDateMarkTrackingCompletedByIdResponse` 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/aftership_estimated_delivery_date_retrack_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_retrack_tracking_by_id_response.rb new file mode 100644 index 0000000..08dfb23 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_retrack_tracking_by_id_response.rb @@ -0,0 +1,183 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class AftershipEstimatedDeliveryDateRetrackTrackingByIdResponse + + # 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::AftershipEstimatedDeliveryDateRetrackTrackingByIdResponse` 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/aftership_estimated_delivery_date_tracking.rb b/lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_tracking.rb new file mode 100644 index 0000000..3dec298 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_tracking.rb @@ -0,0 +1,183 @@ +# 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/aftership_estimated_delivery_date_update_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_update_tracking_by_id_response.rb new file mode 100644 index 0000000..524e67a --- /dev/null +++ b/lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_update_tracking_by_id_response.rb @@ -0,0 +1,183 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class AftershipEstimatedDeliveryDateUpdateTrackingByIdResponse + + # 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::AftershipEstimatedDeliveryDateUpdateTrackingByIdResponse` 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_create_tracking_response.rb b/lib/aftership-tracking-sdk/models/carbon_emissions_create_tracking_response.rb new file mode 100644 index 0000000..f543003 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/carbon_emissions_create_tracking_response.rb @@ -0,0 +1,163 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CarbonEmissionsCreateTrackingResponse + + # 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::CarbonEmissionsCreateTrackingResponse` 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/carbon_emissions_delete_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/carbon_emissions_delete_tracking_by_id_response.rb new file mode 100644 index 0000000..68f1ee7 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/carbon_emissions_delete_tracking_by_id_response.rb @@ -0,0 +1,163 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CarbonEmissionsDeleteTrackingByIdResponse + + # 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::CarbonEmissionsDeleteTrackingByIdResponse` 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/carbon_emissions_get_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/carbon_emissions_get_tracking_by_id_response.rb new file mode 100644 index 0000000..db76852 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/carbon_emissions_get_tracking_by_id_response.rb @@ -0,0 +1,163 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CarbonEmissionsGetTrackingByIdResponse + + # 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::CarbonEmissionsGetTrackingByIdResponse` 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/carbon_emissions_mark_tracking_completed_by_id_response.rb b/lib/aftership-tracking-sdk/models/carbon_emissions_mark_tracking_completed_by_id_response.rb new file mode 100644 index 0000000..fb47c99 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/carbon_emissions_mark_tracking_completed_by_id_response.rb @@ -0,0 +1,163 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CarbonEmissionsMarkTrackingCompletedByIdResponse + + # 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::CarbonEmissionsMarkTrackingCompletedByIdResponse` 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/carbon_emissions_retrack_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/carbon_emissions_retrack_tracking_by_id_response.rb new file mode 100644 index 0000000..448dff0 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/carbon_emissions_retrack_tracking_by_id_response.rb @@ -0,0 +1,163 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CarbonEmissionsRetrackTrackingByIdResponse + + # 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::CarbonEmissionsRetrackTrackingByIdResponse` 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/carbon_emissions_tracking.rb b/lib/aftership-tracking-sdk/models/carbon_emissions_tracking.rb new file mode 100644 index 0000000..c6e8c19 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/carbon_emissions_tracking.rb @@ -0,0 +1,163 @@ +# 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/carbon_emissions_update_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/carbon_emissions_update_tracking_by_id_response.rb new file mode 100644 index 0000000..a002760 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/carbon_emissions_update_tracking_by_id_response.rb @@ -0,0 +1,163 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CarbonEmissionsUpdateTrackingByIdResponse + + # 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::CarbonEmissionsUpdateTrackingByIdResponse` 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..268aee2 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/checkpoint.rb @@ -0,0 +1,313 @@ +# 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_region?: String; + attr_accessor :country_region + + # Country/Region name of the checkpoint, may also contain other location info. + # country_region_name?: String; + attr_accessor :country_region_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 + + # The source of the checkpoint, which can either be from the carrier or when the user marks the tracking as completed. + # 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::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_region') + self.country_region = attributes[:'country_region'] + end + + if attributes.key?(:'country_region_name') + self.country_region_name = attributes[:'country_region_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 + + if attributes.key?(:'source') + self.source = attributes[:'source'] + 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_region' => :'String', + :'country_region_name' => :'String', + :'message' => :'String', + :'tag' => :'TagV1', + :'subtag' => :'String', + :'subtag_message' => :'String', + :'raw_tag' => :'String', + :'events' => :'Array', + :'source' => :'String', + } + 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_region' => :'country_region', + :'country_region_name' => :'country_region_name', + :'message' => :'message', + :'tag' => :'tag', + :'subtag' => :'subtag', + :'subtag_message' => :'subtag_message', + :'raw_tag' => :'raw_tag', + :'events' => :'events', + :'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/coordinate_checkpoint.rb b/lib/aftership-tracking-sdk/models/coordinate_checkpoint.rb new file mode 100644 index 0000000..90a0f60 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/coordinate_checkpoint.rb @@ -0,0 +1,163 @@ +# 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..52b1d27 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/courier.rb @@ -0,0 +1,243 @@ +# 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_region` + # 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_regions?: String[]; + attr_accessor :service_from_country_regions + + # 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_regions') + self.service_from_country_regions = attributes[:'service_from_country_regions'] + 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_regions' => :'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_regions' => :'service_from_country_regions', + } + 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_estimated_delivery_date_create_tracking_response.rb b/lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_create_tracking_response.rb new file mode 100644 index 0000000..2088de8 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_create_tracking_response.rb @@ -0,0 +1,173 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CourierEstimatedDeliveryDateCreateTrackingResponse + + # The estimated arrival date of the shipment. It reflects the shipment recipient’s timezone and the format may vary based on how the carrier provides it:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # estimated_delivery_date?: String; + attr_accessor :estimated_delivery_date + + # The earliest estimated delivery date of the shipment. It reflects the shipment recipient’s timezone and the format may vary based on how the carrier provides it:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # estimated_delivery_date_min?: String; + attr_accessor :estimated_delivery_date_min + + # The Latest estimated delivery date of the shipment. It reflects the shipment recipient’s timezone and the format may vary based on how the carrier provides it:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # 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::CourierEstimatedDeliveryDateCreateTrackingResponse` 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?(:'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', + :'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', + :'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/courier_estimated_delivery_date_delete_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_delete_tracking_by_id_response.rb new file mode 100644 index 0000000..cf5d11c --- /dev/null +++ b/lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_delete_tracking_by_id_response.rb @@ -0,0 +1,173 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CourierEstimatedDeliveryDateDeleteTrackingByIdResponse + + # The estimated arrival date of the shipment. It reflects the shipment recipient’s timezone and the format may vary based on how the carrier provides it:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # estimated_delivery_date?: String; + attr_accessor :estimated_delivery_date + + # The earliest estimated delivery date of the shipment. It reflects the shipment recipient’s timezone and the format may vary based on how the carrier provides it:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # estimated_delivery_date_min?: String; + attr_accessor :estimated_delivery_date_min + + # The Latest estimated delivery date of the shipment. It reflects the shipment recipient’s timezone and the format may vary based on how the carrier provides it:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # 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::CourierEstimatedDeliveryDateDeleteTrackingByIdResponse` 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?(:'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', + :'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', + :'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/courier_estimated_delivery_date_get_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_get_tracking_by_id_response.rb new file mode 100644 index 0000000..55fcdba --- /dev/null +++ b/lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_get_tracking_by_id_response.rb @@ -0,0 +1,173 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CourierEstimatedDeliveryDateGetTrackingByIdResponse + + # The estimated arrival date of the shipment. It reflects the shipment recipient’s timezone and the format may vary based on how the carrier provides it:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # estimated_delivery_date?: String; + attr_accessor :estimated_delivery_date + + # The earliest estimated delivery date of the shipment. It reflects the shipment recipient’s timezone and the format may vary based on how the carrier provides it:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # estimated_delivery_date_min?: String; + attr_accessor :estimated_delivery_date_min + + # The Latest estimated delivery date of the shipment. It reflects the shipment recipient’s timezone and the format may vary based on how the carrier provides it:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # 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::CourierEstimatedDeliveryDateGetTrackingByIdResponse` 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?(:'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', + :'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', + :'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/courier_estimated_delivery_date_mark_tracking_completed_by_id_response.rb b/lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_mark_tracking_completed_by_id_response.rb new file mode 100644 index 0000000..066f0e3 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_mark_tracking_completed_by_id_response.rb @@ -0,0 +1,173 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CourierEstimatedDeliveryDateMarkTrackingCompletedByIdResponse + + # The estimated arrival date of the shipment. It reflects the shipment recipient’s timezone and the format may vary based on how the carrier provides it:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # estimated_delivery_date?: String; + attr_accessor :estimated_delivery_date + + # The earliest estimated delivery date of the shipment. It reflects the shipment recipient’s timezone and the format may vary based on how the carrier provides it:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # estimated_delivery_date_min?: String; + attr_accessor :estimated_delivery_date_min + + # The Latest estimated delivery date of the shipment. It reflects the shipment recipient’s timezone and the format may vary based on how the carrier provides it:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # 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::CourierEstimatedDeliveryDateMarkTrackingCompletedByIdResponse` 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?(:'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', + :'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', + :'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/courier_estimated_delivery_date_retrack_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_retrack_tracking_by_id_response.rb new file mode 100644 index 0000000..147aa16 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_retrack_tracking_by_id_response.rb @@ -0,0 +1,173 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CourierEstimatedDeliveryDateRetrackTrackingByIdResponse + + # The estimated arrival date of the shipment. It reflects the shipment recipient’s timezone and the format may vary based on how the carrier provides it:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # estimated_delivery_date?: String; + attr_accessor :estimated_delivery_date + + # The earliest estimated delivery date of the shipment. It reflects the shipment recipient’s timezone and the format may vary based on how the carrier provides it:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # estimated_delivery_date_min?: String; + attr_accessor :estimated_delivery_date_min + + # The Latest estimated delivery date of the shipment. It reflects the shipment recipient’s timezone and the format may vary based on how the carrier provides it:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # 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::CourierEstimatedDeliveryDateRetrackTrackingByIdResponse` 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?(:'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', + :'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', + :'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/courier_estimated_delivery_date_tracking.rb b/lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_tracking.rb new file mode 100644 index 0000000..9fcf30a --- /dev/null +++ b/lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_tracking.rb @@ -0,0 +1,173 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CourierEstimatedDeliveryDateTracking + + # The estimated arrival date of the shipment. It reflects the shipment recipient’s timezone and the format may vary based on how the carrier provides it:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # estimated_delivery_date?: String; + attr_accessor :estimated_delivery_date + + # The earliest estimated delivery date of the shipment. It reflects the shipment recipient’s timezone and the format may vary based on how the carrier provides it:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # estimated_delivery_date_min?: String; + attr_accessor :estimated_delivery_date_min + + # The Latest estimated delivery date of the shipment. It reflects the shipment recipient’s timezone and the format may vary based on how the carrier provides it:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # 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::CourierEstimatedDeliveryDateTracking` 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?(:'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', + :'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', + :'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/courier_estimated_delivery_date_update_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_update_tracking_by_id_response.rb new file mode 100644 index 0000000..ab4540e --- /dev/null +++ b/lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_update_tracking_by_id_response.rb @@ -0,0 +1,173 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CourierEstimatedDeliveryDateUpdateTrackingByIdResponse + + # The estimated arrival date of the shipment. It reflects the shipment recipient’s timezone and the format may vary based on how the carrier provides it:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # estimated_delivery_date?: String; + attr_accessor :estimated_delivery_date + + # The earliest estimated delivery date of the shipment. It reflects the shipment recipient’s timezone and the format may vary based on how the carrier provides it:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # estimated_delivery_date_min?: String; + attr_accessor :estimated_delivery_date_min + + # The Latest estimated delivery date of the shipment. It reflects the shipment recipient’s timezone and the format may vary based on how the carrier provides it:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # 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::CourierEstimatedDeliveryDateUpdateTrackingByIdResponse` 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?(:'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', + :'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', + :'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/courier_response_v1.rb b/lib/aftership-tracking-sdk/models/courier_response_v1.rb new file mode 100644 index 0000000..469988f --- /dev/null +++ b/lib/aftership-tracking-sdk/models/courier_response_v1.rb @@ -0,0 +1,163 @@ +# 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/create_tracking_request.rb b/lib/aftership-tracking-sdk/models/create_tracking_request.rb new file mode 100644 index 0000000..f8d03f9 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/create_tracking_request.rb @@ -0,0 +1,533 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CreateTrackingRequest + + # 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 formats:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # 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 + + # The date and time when the shipment is shipped by the merchant and ready for pickup by the carrier. The field supports the following formats:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZThe field serves two key purposes:- Calculate processing time metrics in the Order-to-delivery Analytics dashboard. To ensure accurate analytics, it's recommended to include timezone information when configuring this value- Required by certain carriers to retrieve tracking information as an additional tracking field. + # tracking_ship_date?: String; + attr_accessor :tracking_ship_date + + # The for more details. + # origin_country_region?: String; + attr_accessor :origin_country_region + + # 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_region?: String; + attr_accessor :destination_country_region + + # 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 + + # (Legacy) Replaced by `origin_country_region`. 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_region?: String; + attr_accessor :tracking_origin_country_region + + # (Legacy) Replaced by `destination_country_region`. 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_region?: String; + attr_accessor :tracking_destination_country_region + + # (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 + + # This field contains information about the last leg of the shipment, starting from the carrier who hands it over to the last-mile carrier, all the way to delivery. Once AfterShip detects that the shipment involves multiple legs and identifies the last-mile carrier, we will populate the last-mile carrier information in this object. Alternatively, the user can provide this information in this field to specify the last-mile carrier, which is helpful if AfterShip is unable to detect it automatically. + # last_mile?: LastMileCreateTrackingRequest; + attr_accessor :last_mile + + # The field contains the customer information associated with the tracking. A maximum of three customer objects are allowed. + # customers?: CustomersCreateTrackingRequest[]; + attr_accessor :customers + + # 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::CreateTrackingRequest` 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?(:'origin_country_region') + self.origin_country_region = attributes[:'origin_country_region'] + 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_region') + self.destination_country_region = attributes[:'destination_country_region'] + 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?(:'tracking_origin_country_region') + self.tracking_origin_country_region = attributes[:'tracking_origin_country_region'] + end + + if attributes.key?(:'tracking_destination_country_region') + self.tracking_destination_country_region = attributes[:'tracking_destination_country_region'] + 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 + + if attributes.key?(:'last_mile') + self.last_mile = attributes[:'last_mile'] + end + + if attributes.key?(:'customers') + self.customers = attributes[:'customers'] + 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', + :'origin_country_region' => :'String', + :'origin_state' => :'String', + :'origin_city' => :'String', + :'origin_postal_code' => :'String', + :'origin_raw_location' => :'String', + :'destination_country_region' => :'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', + :'tracking_origin_country_region' => :'String', + :'tracking_destination_country_region' => :'String', + :'tracking_postal_code' => :'String', + :'tracking_state' => :'String', + :'location_id' => :'String', + :'shipping_method' => :'String', + :'last_mile' => :'LastMileCreateTrackingRequest', + :'customers' => :'Array', + } + 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', + :'origin_country_region' => :'origin_country_region', + :'origin_state' => :'origin_state', + :'origin_city' => :'origin_city', + :'origin_postal_code' => :'origin_postal_code', + :'origin_raw_location' => :'origin_raw_location', + :'destination_country_region' => :'destination_country_region', + :'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', + :'tracking_origin_country_region' => :'tracking_origin_country_region', + :'tracking_destination_country_region' => :'tracking_destination_country_region', + :'tracking_postal_code' => :'tracking_postal_code', + :'tracking_state' => :'tracking_state', + :'location_id' => :'location_id', + :'shipping_method' => :'shipping_method', + :'last_mile' => :'last_mile', + :'customers' => :'customers', + } + 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/create_tracking_response.rb b/lib/aftership-tracking-sdk/models/create_tracking_response.rb new file mode 100644 index 0000000..0f2c92b --- /dev/null +++ b/lib/aftership-tracking-sdk/models/create_tracking_response.rb @@ -0,0 +1,933 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CreateTrackingResponse + + # Tracking ID. + # id?: String; + attr_accessor :id + + # The length of the tracking ID has been increased from 24 characters to 32 characters. We will use the legacy_id field to store the original 24-character tracking ID to maintain compatibility with existing data. Therefore, all tracking endpoints will continue to work with the legacy_id field as before. + # legacy_id?: String; + attr_accessor :legacy_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 + + # 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 + + # 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_region?: String; + attr_accessor :origin_country_region + + # 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_region?: String; + attr_accessor :destination_country_region + + # 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_region?: String; + attr_accessor :courier_destination_country_region + + # The field contains the estimated delivery date provided by the carrier. + # courier_estimated_delivery_date?: CourierEstimatedDeliveryDateCreateTrackingResponse; + attr_accessor :courier_estimated_delivery_date + + # 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 + + # The shipment_weight field represents the total weight of the shipment. In scenarios where the carrier does not provide this information, you can provide the weight to AfterShip. We will prioritize the data provided by the carrier, if available. The shipment weight will be included in the Response and accessed through the GET API, Webhook, and CSV export. It will also be displayed on the AfterShip Tracking admin. Additionally, it plays a significant role in error-free shipment handling and carbon emission calculations, ensuring accurate and informed decision-making + # shipment_weight?: ShipmentWeightCreateTrackingResponse; + attr_accessor :shipment_weight + + # Signed by information for delivered shipment. + # signed_by?: String; + attr_accessor :signed_by + + # 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. + # subscribed_smses?: String[]; + attr_accessor :subscribed_smses + + # Email address(es) subscribed to receive email notifications. + # 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 formats:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # 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 + + # The date and time when the shipment is shipped by the merchant and ready for pickup by the carrier. The field supports the following formats:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZThe field serves two key purposes:- Calculate processing time metrics in the Order-to-delivery Analytics dashboard. To ensure accurate analytics, it's recommended to include timezone information when configuring this value- Required by certain carriers to retrieve tracking information as an additional tracking field. + # 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?: AftershipEstimatedDeliveryDateCreateTrackingResponse; + 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?: CustomEstimatedDeliveryDateCreateTrackingResponse; + 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?: FirstEstimatedDeliveryCreateTrackingResponse; + 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?: LatestEstimatedDeliveryCreateTrackingResponse; + 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 + + # (Legacy) Replaced by `origin_country_region`. 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_region?: String; + attr_accessor :tracking_origin_country_region + + # (Legacy) Replaced by `destination_country_region`. 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_region?: String; + attr_accessor :tracking_destination_country_region + + # (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?: CarbonEmissionsCreateTrackingResponse; + 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 + + # The delivery location type represents the secure area where the carrier leaves the package, such as a safe place, locker, mailbox, front porch, etc. This information helps ensure the shipment reaches the intended recipient efficiently, minimizing the risk of theft or damage. + # delivery_location_type?: String; + attr_accessor :delivery_location_type + + # The tracking URL directs your customers to the shipment tracking page which can display either the default or a customized page based on segmentation rules.- The universal URL is used by default, but you can opt for a custom domain if you have one. Learn how to set up a custom domain .The field is not automatically enabled in API & Webhook. Please contact support if you’d like to enable it. + # aftership_tracking_url?: String; + attr_accessor :aftership_tracking_url + + # The order URL directs your customers to the order tracking page, which includes all shipments. It can display either the default or a customized page based on segmentation rules.- The universal URL is used by default, but you can opt for a custom domain if you have one. Learn how to set up a custom domain .The field is not automatically enabled in API & Webhook. Please contact support if you’d like to enable it. + # aftership_tracking_order_url?: String; + attr_accessor :aftership_tracking_order_url + + # The field contains information about the first leg of the shipping starting from the carrier picking up the shipment from the shipper to the point where they hand it over to the last-mile carrier. Once AfterShip detects the shipment is multi-leg, we will populate the first-mile information under this object. + # first_mile?: FirstMileCreateTrackingResponse; + attr_accessor :first_mile + + # This field contains information about the last leg of the shipment, starting from the carrier who hands it over to the last-mile carrier, all the way to delivery. Once AfterShip detects that the shipment involves multiple legs and identifies the last-mile carrier, we will populate the last-mile carrier information in this object. Alternatively, the user can provide this information in this field to specify the last-mile carrier, which is helpful if AfterShip is unable to detect it automatically. + # last_mile?: LastMileCreateTrackingResponse; + attr_accessor :last_mile + + # The field contains the customer information associated with the tracking. A maximum of three customer objects are allowed. + # customers?: CustomersCreateTrackingResponse[]; + attr_accessor :customers + + # 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::CreateTrackingResponse` 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?(:'legacy_id') + self.legacy_id = attributes[:'legacy_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?(:'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?(:'transit_time') + self.transit_time = attributes[:'transit_time'] + end + + if attributes.key?(:'origin_country_region') + self.origin_country_region = attributes[:'origin_country_region'] + 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_region') + self.destination_country_region = attributes[:'destination_country_region'] + 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_region') + self.courier_destination_country_region = attributes[:'courier_destination_country_region'] + end + + if attributes.key?(:'courier_estimated_delivery_date') + self.courier_estimated_delivery_date = attributes[:'courier_estimated_delivery_date'] + 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?(:'signed_by') + self.signed_by = attributes[:'signed_by'] + 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?(:'tracking_origin_country_region') + self.tracking_origin_country_region = attributes[:'tracking_origin_country_region'] + end + + if attributes.key?(:'tracking_destination_country_region') + self.tracking_destination_country_region = attributes[:'tracking_destination_country_region'] + 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 + + if attributes.key?(:'delivery_location_type') + self.delivery_location_type = attributes[:'delivery_location_type'] + end + + if attributes.key?(:'aftership_tracking_url') + self.aftership_tracking_url = attributes[:'aftership_tracking_url'] + end + + if attributes.key?(:'aftership_tracking_order_url') + self.aftership_tracking_order_url = attributes[:'aftership_tracking_order_url'] + end + + if attributes.key?(:'first_mile') + self.first_mile = attributes[:'first_mile'] + end + + if attributes.key?(:'last_mile') + self.last_mile = attributes[:'last_mile'] + end + + if attributes.key?(:'customers') + self.customers = attributes[:'customers'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'legacy_id' => :'String', + :'created_at' => :'String', + :'updated_at' => :'String', + :'tracking_number' => :'String', + :'slug' => :'String', + :'active' => :'Boolean', + :'custom_fields' => :'Object', + :'transit_time' => :'Integer', + :'origin_country_region' => :'String', + :'origin_state' => :'String', + :'origin_city' => :'String', + :'origin_postal_code' => :'String', + :'origin_raw_location' => :'String', + :'destination_country_region' => :'String', + :'destination_state' => :'String', + :'destination_city' => :'String', + :'destination_postal_code' => :'String', + :'destination_raw_location' => :'String', + :'courier_destination_country_region' => :'String', + :'courier_estimated_delivery_date' => :'CourierEstimatedDeliveryDateCreateTrackingResponse', + :'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' => :'ShipmentWeightCreateTrackingResponse', + :'signed_by' => :'String', + :'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' => :'AftershipEstimatedDeliveryDateCreateTrackingResponse', + :'custom_estimated_delivery_date' => :'CustomEstimatedDeliveryDateCreateTrackingResponse', + :'order_number' => :'String', + :'first_estimated_delivery' => :'FirstEstimatedDeliveryCreateTrackingResponse', + :'latest_estimated_delivery' => :'LatestEstimatedDeliveryCreateTrackingResponse', + :'shipment_tags' => :'Array', + :'courier_connection_id' => :'String', + :'tracking_origin_country_region' => :'String', + :'tracking_destination_country_region' => :'String', + :'tracking_postal_code' => :'String', + :'tracking_state' => :'String', + :'carbon_emissions' => :'CarbonEmissionsCreateTrackingResponse', + :'location_id' => :'String', + :'shipping_method' => :'String', + :'failed_delivery_attempts' => :'Integer', + :'signature_requirement' => :'String', + :'delivery_location_type' => :'String', + :'aftership_tracking_url' => :'String', + :'aftership_tracking_order_url' => :'String', + :'first_mile' => :'FirstMileCreateTrackingResponse', + :'last_mile' => :'LastMileCreateTrackingResponse', + :'customers' => :'Array', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'legacy_id' => :'legacy_id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'tracking_number' => :'tracking_number', + :'slug' => :'slug', + :'active' => :'active', + :'custom_fields' => :'custom_fields', + :'transit_time' => :'transit_time', + :'origin_country_region' => :'origin_country_region', + :'origin_state' => :'origin_state', + :'origin_city' => :'origin_city', + :'origin_postal_code' => :'origin_postal_code', + :'origin_raw_location' => :'origin_raw_location', + :'destination_country_region' => :'destination_country_region', + :'destination_state' => :'destination_state', + :'destination_city' => :'destination_city', + :'destination_postal_code' => :'destination_postal_code', + :'destination_raw_location' => :'destination_raw_location', + :'courier_destination_country_region' => :'courier_destination_country_region', + :'courier_estimated_delivery_date' => :'courier_estimated_delivery_date', + :'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', + :'signed_by' => :'signed_by', + :'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', + :'tracking_origin_country_region' => :'tracking_origin_country_region', + :'tracking_destination_country_region' => :'tracking_destination_country_region', + :'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', + :'delivery_location_type' => :'delivery_location_type', + :'aftership_tracking_url' => :'aftership_tracking_url', + :'aftership_tracking_order_url' => :'aftership_tracking_order_url', + :'first_mile' => :'first_mile', + :'last_mile' => :'last_mile', + :'customers' => :'customers', + } + 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_create_tracking_response.rb b/lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_create_tracking_response.rb new file mode 100644 index 0000000..7739f68 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_create_tracking_response.rb @@ -0,0 +1,183 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CustomEstimatedDeliveryDateCreateTrackingResponse + + # 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::CustomEstimatedDeliveryDateCreateTrackingResponse` 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_estimated_delivery_date_delete_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_delete_tracking_by_id_response.rb new file mode 100644 index 0000000..8af235d --- /dev/null +++ b/lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_delete_tracking_by_id_response.rb @@ -0,0 +1,183 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CustomEstimatedDeliveryDateDeleteTrackingByIdResponse + + # 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::CustomEstimatedDeliveryDateDeleteTrackingByIdResponse` 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_estimated_delivery_date_get_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_get_tracking_by_id_response.rb new file mode 100644 index 0000000..ea92c34 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_get_tracking_by_id_response.rb @@ -0,0 +1,183 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CustomEstimatedDeliveryDateGetTrackingByIdResponse + + # 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::CustomEstimatedDeliveryDateGetTrackingByIdResponse` 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_estimated_delivery_date_mark_tracking_completed_by_id_response.rb b/lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_mark_tracking_completed_by_id_response.rb new file mode 100644 index 0000000..b4f0a94 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_mark_tracking_completed_by_id_response.rb @@ -0,0 +1,183 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CustomEstimatedDeliveryDateMarkTrackingCompletedByIdResponse + + # 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::CustomEstimatedDeliveryDateMarkTrackingCompletedByIdResponse` 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_estimated_delivery_date_retrack_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_retrack_tracking_by_id_response.rb new file mode 100644 index 0000000..9e7909c --- /dev/null +++ b/lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_retrack_tracking_by_id_response.rb @@ -0,0 +1,183 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CustomEstimatedDeliveryDateRetrackTrackingByIdResponse + + # 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::CustomEstimatedDeliveryDateRetrackTrackingByIdResponse` 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_estimated_delivery_date_tracking.rb b/lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_tracking.rb new file mode 100644 index 0000000..a9c9609 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_tracking.rb @@ -0,0 +1,183 @@ +# 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_estimated_delivery_date_update_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_update_tracking_by_id_response.rb new file mode 100644 index 0000000..fa2568e --- /dev/null +++ b/lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_update_tracking_by_id_response.rb @@ -0,0 +1,183 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CustomEstimatedDeliveryDateUpdateTrackingByIdResponse + + # 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::CustomEstimatedDeliveryDateUpdateTrackingByIdResponse` 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/customers_create_tracking_request.rb b/lib/aftership-tracking-sdk/models/customers_create_tracking_request.rb new file mode 100644 index 0000000..cee7bdb --- /dev/null +++ b/lib/aftership-tracking-sdk/models/customers_create_tracking_request.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CustomersCreateTrackingRequest + + # The role of the customer, indicating whether the customer is an individual or a company. + # role?: String; + attr_accessor :role + + # Customer name associated with the tracking. + # name?: String; + attr_accessor :name + + # The phone number(s) to receive SMS notifications. Phone numbers should begin with a `+` sign and include the area code. + # phone_number?: String; + attr_accessor :phone_number + + # Email address(es) to receive email notifications. + # email?: String; + attr_accessor :email + + # The preferred language of the customer. If you have set up AfterShip notifications in different languages, we use this to send the tracking updates to the customer in their preferred language. + # language?: String; + attr_accessor :language + + # 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::CustomersCreateTrackingRequest` initialize method" + end + + attributes = attributes.each_with_object({}) { |(k, v), h| + h[k.to_sym] = v + } + + if attributes.key?(:'role') + self.role = attributes[:'role'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'phone_number') + self.phone_number = attributes[:'phone_number'] + end + + if attributes.key?(:'email') + self.email = attributes[:'email'] + end + + if attributes.key?(:'language') + self.language = attributes[:'language'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'role' => :'String', + :'name' => :'String', + :'phone_number' => :'String', + :'email' => :'String', + :'language' => :'String', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'role' => :'role', + :'name' => :'name', + :'phone_number' => :'phone_number', + :'email' => :'email', + :'language' => :'language', + } + 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/customers_create_tracking_response.rb b/lib/aftership-tracking-sdk/models/customers_create_tracking_response.rb new file mode 100644 index 0000000..2aedea2 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/customers_create_tracking_response.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CustomersCreateTrackingResponse + + # The role of the customer, indicating whether the customer is an individual or a company. + # role?: String; + attr_accessor :role + + # Customer name associated with the tracking. + # name?: String; + attr_accessor :name + + # The phone number(s) to receive SMS notifications. Phone numbers should begin with a `+` sign and include the area code. + # phone_number?: String; + attr_accessor :phone_number + + # Email address(es) to receive email notifications. + # email?: String; + attr_accessor :email + + # The preferred language of the customer. If you have set up AfterShip notifications in different languages, we use this to send the tracking updates to the customer in their preferred language. + # language?: String; + attr_accessor :language + + # 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::CustomersCreateTrackingResponse` initialize method" + end + + attributes = attributes.each_with_object({}) { |(k, v), h| + h[k.to_sym] = v + } + + if attributes.key?(:'role') + self.role = attributes[:'role'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'phone_number') + self.phone_number = attributes[:'phone_number'] + end + + if attributes.key?(:'email') + self.email = attributes[:'email'] + end + + if attributes.key?(:'language') + self.language = attributes[:'language'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'role' => :'String', + :'name' => :'String', + :'phone_number' => :'String', + :'email' => :'String', + :'language' => :'String', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'role' => :'role', + :'name' => :'name', + :'phone_number' => :'phone_number', + :'email' => :'email', + :'language' => :'language', + } + 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/customers_delete_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/customers_delete_tracking_by_id_response.rb new file mode 100644 index 0000000..3ca7d0d --- /dev/null +++ b/lib/aftership-tracking-sdk/models/customers_delete_tracking_by_id_response.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CustomersDeleteTrackingByIdResponse + + # The role of the customer, indicating whether the customer is an individual or a company. + # role?: String; + attr_accessor :role + + # Customer name associated with the tracking. + # name?: String; + attr_accessor :name + + # The phone number(s) to receive SMS notifications. Phone numbers should begin with a `+` sign and include the area code. + # phone_number?: String; + attr_accessor :phone_number + + # Email address(es) to receive email notifications. + # email?: String; + attr_accessor :email + + # The preferred language of the customer. If you have set up AfterShip notifications in different languages, we use this to send the tracking updates to the customer in their preferred language. + # language?: String; + attr_accessor :language + + # 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::CustomersDeleteTrackingByIdResponse` initialize method" + end + + attributes = attributes.each_with_object({}) { |(k, v), h| + h[k.to_sym] = v + } + + if attributes.key?(:'role') + self.role = attributes[:'role'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'phone_number') + self.phone_number = attributes[:'phone_number'] + end + + if attributes.key?(:'email') + self.email = attributes[:'email'] + end + + if attributes.key?(:'language') + self.language = attributes[:'language'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'role' => :'String', + :'name' => :'String', + :'phone_number' => :'String', + :'email' => :'String', + :'language' => :'String', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'role' => :'role', + :'name' => :'name', + :'phone_number' => :'phone_number', + :'email' => :'email', + :'language' => :'language', + } + 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/customers_get_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/customers_get_tracking_by_id_response.rb new file mode 100644 index 0000000..06e55b0 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/customers_get_tracking_by_id_response.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CustomersGetTrackingByIdResponse + + # The role of the customer, indicating whether the customer is an individual or a company. + # role?: String; + attr_accessor :role + + # Customer name associated with the tracking. + # name?: String; + attr_accessor :name + + # The phone number(s) to receive SMS notifications. Phone numbers should begin with a `+` sign and include the area code. + # phone_number?: String; + attr_accessor :phone_number + + # Email address(es) to receive email notifications. + # email?: String; + attr_accessor :email + + # The preferred language of the customer. If you have set up AfterShip notifications in different languages, we use this to send the tracking updates to the customer in their preferred language. + # language?: String; + attr_accessor :language + + # 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::CustomersGetTrackingByIdResponse` initialize method" + end + + attributes = attributes.each_with_object({}) { |(k, v), h| + h[k.to_sym] = v + } + + if attributes.key?(:'role') + self.role = attributes[:'role'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'phone_number') + self.phone_number = attributes[:'phone_number'] + end + + if attributes.key?(:'email') + self.email = attributes[:'email'] + end + + if attributes.key?(:'language') + self.language = attributes[:'language'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'role' => :'String', + :'name' => :'String', + :'phone_number' => :'String', + :'email' => :'String', + :'language' => :'String', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'role' => :'role', + :'name' => :'name', + :'phone_number' => :'phone_number', + :'email' => :'email', + :'language' => :'language', + } + 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/customers_mark_tracking_completed_by_id_response.rb b/lib/aftership-tracking-sdk/models/customers_mark_tracking_completed_by_id_response.rb new file mode 100644 index 0000000..7862785 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/customers_mark_tracking_completed_by_id_response.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CustomersMarkTrackingCompletedByIdResponse + + # The role of the customer, indicating whether the customer is an individual or a company. + # role?: String; + attr_accessor :role + + # Customer name associated with the tracking. + # name?: String; + attr_accessor :name + + # The phone number(s) to receive SMS notifications. Phone numbers should begin with a `+` sign and include the area code. + # phone_number?: String; + attr_accessor :phone_number + + # Email address(es) to receive email notifications. + # email?: String; + attr_accessor :email + + # The preferred language of the customer. If you have set up AfterShip notifications in different languages, we use this to send the tracking updates to the customer in their preferred language. + # language?: String; + attr_accessor :language + + # 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::CustomersMarkTrackingCompletedByIdResponse` initialize method" + end + + attributes = attributes.each_with_object({}) { |(k, v), h| + h[k.to_sym] = v + } + + if attributes.key?(:'role') + self.role = attributes[:'role'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'phone_number') + self.phone_number = attributes[:'phone_number'] + end + + if attributes.key?(:'email') + self.email = attributes[:'email'] + end + + if attributes.key?(:'language') + self.language = attributes[:'language'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'role' => :'String', + :'name' => :'String', + :'phone_number' => :'String', + :'email' => :'String', + :'language' => :'String', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'role' => :'role', + :'name' => :'name', + :'phone_number' => :'phone_number', + :'email' => :'email', + :'language' => :'language', + } + 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/customers_retrack_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/customers_retrack_tracking_by_id_response.rb new file mode 100644 index 0000000..a292285 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/customers_retrack_tracking_by_id_response.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CustomersRetrackTrackingByIdResponse + + # The role of the customer, indicating whether the customer is an individual or a company. + # role?: String; + attr_accessor :role + + # Customer name associated with the tracking. + # name?: String; + attr_accessor :name + + # The phone number(s) to receive SMS notifications. Phone numbers should begin with a `+` sign and include the area code. + # phone_number?: String; + attr_accessor :phone_number + + # Email address(es) to receive email notifications. + # email?: String; + attr_accessor :email + + # The preferred language of the customer. If you have set up AfterShip notifications in different languages, we use this to send the tracking updates to the customer in their preferred language. + # language?: String; + attr_accessor :language + + # 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::CustomersRetrackTrackingByIdResponse` initialize method" + end + + attributes = attributes.each_with_object({}) { |(k, v), h| + h[k.to_sym] = v + } + + if attributes.key?(:'role') + self.role = attributes[:'role'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'phone_number') + self.phone_number = attributes[:'phone_number'] + end + + if attributes.key?(:'email') + self.email = attributes[:'email'] + end + + if attributes.key?(:'language') + self.language = attributes[:'language'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'role' => :'String', + :'name' => :'String', + :'phone_number' => :'String', + :'email' => :'String', + :'language' => :'String', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'role' => :'role', + :'name' => :'name', + :'phone_number' => :'phone_number', + :'email' => :'email', + :'language' => :'language', + } + 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/customers_tracking.rb b/lib/aftership-tracking-sdk/models/customers_tracking.rb new file mode 100644 index 0000000..9382071 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/customers_tracking.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CustomersTracking + + # The role of the customer, indicating whether the customer is an individual or a company. + # role?: String; + attr_accessor :role + + # Customer name associated with the tracking. + # name?: String; + attr_accessor :name + + # The phone number(s) to receive SMS notifications. Phone numbers should begin with a `+` sign and include the area code. + # phone_number?: String; + attr_accessor :phone_number + + # Email address(es) to receive email notifications. + # email?: String; + attr_accessor :email + + # The preferred language of the customer. If you have set up AfterShip notifications in different languages, we use this to send the tracking updates to the customer in their preferred language. + # language?: String; + attr_accessor :language + + # 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::CustomersTracking` initialize method" + end + + attributes = attributes.each_with_object({}) { |(k, v), h| + h[k.to_sym] = v + } + + if attributes.key?(:'role') + self.role = attributes[:'role'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'phone_number') + self.phone_number = attributes[:'phone_number'] + end + + if attributes.key?(:'email') + self.email = attributes[:'email'] + end + + if attributes.key?(:'language') + self.language = attributes[:'language'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'role' => :'String', + :'name' => :'String', + :'phone_number' => :'String', + :'email' => :'String', + :'language' => :'String', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'role' => :'role', + :'name' => :'name', + :'phone_number' => :'phone_number', + :'email' => :'email', + :'language' => :'language', + } + 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/customers_update_tracking_by_id_request.rb b/lib/aftership-tracking-sdk/models/customers_update_tracking_by_id_request.rb new file mode 100644 index 0000000..27f3355 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/customers_update_tracking_by_id_request.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CustomersUpdateTrackingByIdRequest + + # The role of the customer, indicating whether the customer is an individual or a company. + # role?: String; + attr_accessor :role + + # Customer name associated with the tracking. + # name?: String; + attr_accessor :name + + # The phone number(s) to receive SMS notifications. Phone numbers should begin with a `+` sign and include the area code. + # phone_number?: String; + attr_accessor :phone_number + + # Email address(es) to receive email notifications. + # email?: String; + attr_accessor :email + + # The preferred language of the customer. If you have set up AfterShip notifications in different languages, we use this to send the tracking updates to the customer in their preferred language. + # language?: String; + attr_accessor :language + + # 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::CustomersUpdateTrackingByIdRequest` initialize method" + end + + attributes = attributes.each_with_object({}) { |(k, v), h| + h[k.to_sym] = v + } + + if attributes.key?(:'role') + self.role = attributes[:'role'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'phone_number') + self.phone_number = attributes[:'phone_number'] + end + + if attributes.key?(:'email') + self.email = attributes[:'email'] + end + + if attributes.key?(:'language') + self.language = attributes[:'language'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'role' => :'String', + :'name' => :'String', + :'phone_number' => :'String', + :'email' => :'String', + :'language' => :'String', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'role' => :'role', + :'name' => :'name', + :'phone_number' => :'phone_number', + :'email' => :'email', + :'language' => :'language', + } + 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/customers_update_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/customers_update_tracking_by_id_response.rb new file mode 100644 index 0000000..5ac915e --- /dev/null +++ b/lib/aftership-tracking-sdk/models/customers_update_tracking_by_id_response.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class CustomersUpdateTrackingByIdResponse + + # The role of the customer, indicating whether the customer is an individual or a company. + # role?: String; + attr_accessor :role + + # Customer name associated with the tracking. + # name?: String; + attr_accessor :name + + # The phone number(s) to receive SMS notifications. Phone numbers should begin with a `+` sign and include the area code. + # phone_number?: String; + attr_accessor :phone_number + + # Email address(es) to receive email notifications. + # email?: String; + attr_accessor :email + + # The preferred language of the customer. If you have set up AfterShip notifications in different languages, we use this to send the tracking updates to the customer in their preferred language. + # language?: String; + attr_accessor :language + + # 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::CustomersUpdateTrackingByIdResponse` initialize method" + end + + attributes = attributes.each_with_object({}) { |(k, v), h| + h[k.to_sym] = v + } + + if attributes.key?(:'role') + self.role = attributes[:'role'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'phone_number') + self.phone_number = attributes[:'phone_number'] + end + + if attributes.key?(:'email') + self.email = attributes[:'email'] + end + + if attributes.key?(:'language') + self.language = attributes[:'language'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'role' => :'String', + :'name' => :'String', + :'phone_number' => :'String', + :'email' => :'String', + :'language' => :'String', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'role' => :'role', + :'name' => :'name', + :'phone_number' => :'phone_number', + :'email' => :'email', + :'language' => :'language', + } + 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..f8a8899 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/data_courier_response_v1.rb @@ -0,0 +1,163 @@ +# 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_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..8bcbbf9 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/data_tracking_response_get_multiple_v1.rb @@ -0,0 +1,163 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class DataTrackingResponseGetMultipleV1 + + # The Pagination holds the information for the pagination when the response contains multiple objects. + # pagination?: PaginationDataTrackingResponseGetMultipleV1; + 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::DataTrackingResponseGetMultipleV1` 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' => :'PaginationDataTrackingResponseGetMultipleV1', + :'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/delete_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/delete_tracking_by_id_response.rb new file mode 100644 index 0000000..05fc294 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/delete_tracking_by_id_response.rb @@ -0,0 +1,933 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class DeleteTrackingByIdResponse + + # Tracking ID. + # id?: String; + attr_accessor :id + + # The length of the tracking ID has been increased from 24 characters to 32 characters. We will use the legacy_id field to store the original 24-character tracking ID to maintain compatibility with existing data. Therefore, all tracking endpoints will continue to work with the legacy_id field as before. + # legacy_id?: String; + attr_accessor :legacy_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 + + # 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 + + # 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_region?: String; + attr_accessor :origin_country_region + + # 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_region?: String; + attr_accessor :destination_country_region + + # 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_region?: String; + attr_accessor :courier_destination_country_region + + # The field contains the estimated delivery date provided by the carrier. + # courier_estimated_delivery_date?: CourierEstimatedDeliveryDateDeleteTrackingByIdResponse; + attr_accessor :courier_estimated_delivery_date + + # 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 + + # The shipment_weight field represents the total weight of the shipment. In scenarios where the carrier does not provide this information, you can provide the weight to AfterShip. We will prioritize the data provided by the carrier, if available. The shipment weight will be included in the Response and accessed through the GET API, Webhook, and CSV export. It will also be displayed on the AfterShip Tracking admin. Additionally, it plays a significant role in error-free shipment handling and carbon emission calculations, ensuring accurate and informed decision-making + # shipment_weight?: ShipmentWeightDeleteTrackingByIdResponse; + attr_accessor :shipment_weight + + # Signed by information for delivered shipment. + # signed_by?: String; + attr_accessor :signed_by + + # 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. + # subscribed_smses?: String[]; + attr_accessor :subscribed_smses + + # Email address(es) subscribed to receive email notifications. + # 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 formats:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # 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 + + # The date and time when the shipment is shipped by the merchant and ready for pickup by the carrier. The field supports the following formats:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZThe field serves two key purposes:- Calculate processing time metrics in the Order-to-delivery Analytics dashboard. To ensure accurate analytics, it's recommended to include timezone information when configuring this value- Required by certain carriers to retrieve tracking information as an additional tracking field. + # 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?: AftershipEstimatedDeliveryDateDeleteTrackingByIdResponse; + 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?: CustomEstimatedDeliveryDateDeleteTrackingByIdResponse; + 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?: FirstEstimatedDeliveryDeleteTrackingByIdResponse; + 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?: LatestEstimatedDeliveryDeleteTrackingByIdResponse; + 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 + + # (Legacy) Replaced by `origin_country_region`. 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_region?: String; + attr_accessor :tracking_origin_country_region + + # (Legacy) Replaced by `destination_country_region`. 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_region?: String; + attr_accessor :tracking_destination_country_region + + # (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?: CarbonEmissionsDeleteTrackingByIdResponse; + 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 + + # The delivery location type represents the secure area where the carrier leaves the package, such as a safe place, locker, mailbox, front porch, etc. This information helps ensure the shipment reaches the intended recipient efficiently, minimizing the risk of theft or damage. + # delivery_location_type?: String; + attr_accessor :delivery_location_type + + # The tracking URL directs your customers to the shipment tracking page which can display either the default or a customized page based on segmentation rules.- The universal URL is used by default, but you can opt for a custom domain if you have one. Learn how to set up a custom domain .The field is not automatically enabled in API & Webhook. Please contact support if you’d like to enable it. + # aftership_tracking_url?: String; + attr_accessor :aftership_tracking_url + + # The order URL directs your customers to the order tracking page, which includes all shipments. It can display either the default or a customized page based on segmentation rules.- The universal URL is used by default, but you can opt for a custom domain if you have one. Learn how to set up a custom domain .The field is not automatically enabled in API & Webhook. Please contact support if you’d like to enable it. + # aftership_tracking_order_url?: String; + attr_accessor :aftership_tracking_order_url + + # The field contains information about the first leg of the shipping starting from the carrier picking up the shipment from the shipper to the point where they hand it over to the last-mile carrier. Once AfterShip detects the shipment is multi-leg, we will populate the first-mile information under this object. + # first_mile?: FirstMileDeleteTrackingByIdResponse; + attr_accessor :first_mile + + # This field contains information about the last leg of the shipment, starting from the carrier who hands it over to the last-mile carrier, all the way to delivery. Once AfterShip detects that the shipment involves multiple legs and identifies the last-mile carrier, we will populate the last-mile carrier information in this object. Alternatively, the user can provide this information in this field to specify the last-mile carrier, which is helpful if AfterShip is unable to detect it automatically. + # last_mile?: LastMileDeleteTrackingByIdResponse; + attr_accessor :last_mile + + # The field contains the customer information associated with the tracking. A maximum of three customer objects are allowed. + # customers?: CustomersDeleteTrackingByIdResponse[]; + attr_accessor :customers + + # 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::DeleteTrackingByIdResponse` 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?(:'legacy_id') + self.legacy_id = attributes[:'legacy_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?(:'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?(:'transit_time') + self.transit_time = attributes[:'transit_time'] + end + + if attributes.key?(:'origin_country_region') + self.origin_country_region = attributes[:'origin_country_region'] + 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_region') + self.destination_country_region = attributes[:'destination_country_region'] + 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_region') + self.courier_destination_country_region = attributes[:'courier_destination_country_region'] + end + + if attributes.key?(:'courier_estimated_delivery_date') + self.courier_estimated_delivery_date = attributes[:'courier_estimated_delivery_date'] + 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?(:'signed_by') + self.signed_by = attributes[:'signed_by'] + 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?(:'tracking_origin_country_region') + self.tracking_origin_country_region = attributes[:'tracking_origin_country_region'] + end + + if attributes.key?(:'tracking_destination_country_region') + self.tracking_destination_country_region = attributes[:'tracking_destination_country_region'] + 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 + + if attributes.key?(:'delivery_location_type') + self.delivery_location_type = attributes[:'delivery_location_type'] + end + + if attributes.key?(:'aftership_tracking_url') + self.aftership_tracking_url = attributes[:'aftership_tracking_url'] + end + + if attributes.key?(:'aftership_tracking_order_url') + self.aftership_tracking_order_url = attributes[:'aftership_tracking_order_url'] + end + + if attributes.key?(:'first_mile') + self.first_mile = attributes[:'first_mile'] + end + + if attributes.key?(:'last_mile') + self.last_mile = attributes[:'last_mile'] + end + + if attributes.key?(:'customers') + self.customers = attributes[:'customers'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'legacy_id' => :'String', + :'created_at' => :'String', + :'updated_at' => :'String', + :'tracking_number' => :'String', + :'slug' => :'String', + :'active' => :'Boolean', + :'custom_fields' => :'Object', + :'transit_time' => :'Integer', + :'origin_country_region' => :'String', + :'origin_state' => :'String', + :'origin_city' => :'String', + :'origin_postal_code' => :'String', + :'origin_raw_location' => :'String', + :'destination_country_region' => :'String', + :'destination_state' => :'String', + :'destination_city' => :'String', + :'destination_postal_code' => :'String', + :'destination_raw_location' => :'String', + :'courier_destination_country_region' => :'String', + :'courier_estimated_delivery_date' => :'CourierEstimatedDeliveryDateDeleteTrackingByIdResponse', + :'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' => :'ShipmentWeightDeleteTrackingByIdResponse', + :'signed_by' => :'String', + :'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' => :'AftershipEstimatedDeliveryDateDeleteTrackingByIdResponse', + :'custom_estimated_delivery_date' => :'CustomEstimatedDeliveryDateDeleteTrackingByIdResponse', + :'order_number' => :'String', + :'first_estimated_delivery' => :'FirstEstimatedDeliveryDeleteTrackingByIdResponse', + :'latest_estimated_delivery' => :'LatestEstimatedDeliveryDeleteTrackingByIdResponse', + :'shipment_tags' => :'Array', + :'courier_connection_id' => :'String', + :'tracking_origin_country_region' => :'String', + :'tracking_destination_country_region' => :'String', + :'tracking_postal_code' => :'String', + :'tracking_state' => :'String', + :'carbon_emissions' => :'CarbonEmissionsDeleteTrackingByIdResponse', + :'location_id' => :'String', + :'shipping_method' => :'String', + :'failed_delivery_attempts' => :'Integer', + :'signature_requirement' => :'String', + :'delivery_location_type' => :'String', + :'aftership_tracking_url' => :'String', + :'aftership_tracking_order_url' => :'String', + :'first_mile' => :'FirstMileDeleteTrackingByIdResponse', + :'last_mile' => :'LastMileDeleteTrackingByIdResponse', + :'customers' => :'Array', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'legacy_id' => :'legacy_id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'tracking_number' => :'tracking_number', + :'slug' => :'slug', + :'active' => :'active', + :'custom_fields' => :'custom_fields', + :'transit_time' => :'transit_time', + :'origin_country_region' => :'origin_country_region', + :'origin_state' => :'origin_state', + :'origin_city' => :'origin_city', + :'origin_postal_code' => :'origin_postal_code', + :'origin_raw_location' => :'origin_raw_location', + :'destination_country_region' => :'destination_country_region', + :'destination_state' => :'destination_state', + :'destination_city' => :'destination_city', + :'destination_postal_code' => :'destination_postal_code', + :'destination_raw_location' => :'destination_raw_location', + :'courier_destination_country_region' => :'courier_destination_country_region', + :'courier_estimated_delivery_date' => :'courier_estimated_delivery_date', + :'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', + :'signed_by' => :'signed_by', + :'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', + :'tracking_origin_country_region' => :'tracking_origin_country_region', + :'tracking_destination_country_region' => :'tracking_destination_country_region', + :'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', + :'delivery_location_type' => :'delivery_location_type', + :'aftership_tracking_url' => :'aftership_tracking_url', + :'aftership_tracking_order_url' => :'aftership_tracking_order_url', + :'first_mile' => :'first_mile', + :'last_mile' => :'last_mile', + :'customers' => :'customers', + } + 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..ef5032c --- /dev/null +++ b/lib/aftership-tracking-sdk/models/destination_address_estimated_delivery_date_request.rb @@ -0,0 +1,193 @@ +# 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_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?: 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_region') + self.country_region = attributes[:'country_region'] + 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_region' => :'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_region' => :'country_region', + :'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..b64712c --- /dev/null +++ b/lib/aftership-tracking-sdk/models/destination_address_estimated_delivery_date_response.rb @@ -0,0 +1,193 @@ +# 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_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?: 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_region') + self.country_region = attributes[:'country_region'] + 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_region' => :'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_region' => :'country_region', + :'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_predict_request.rb b/lib/aftership-tracking-sdk/models/destination_address_predict_request.rb new file mode 100644 index 0000000..0e32bc5 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/destination_address_predict_request.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class DestinationAddressPredictRequest + + # The country/region of the destination location where the package will be delivered. Use 3 letters of ISO 3166-1 country code. + # 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?: 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::DestinationAddressPredictRequest` initialize method" + end + + attributes = attributes.each_with_object({}) { |(k, v), h| + h[k.to_sym] = v + } + + if attributes.key?(:'country_region') + self.country_region = attributes[:'country_region'] + 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_region' => :'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_region' => :'country_region', + :'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_predict_response.rb b/lib/aftership-tracking-sdk/models/destination_address_predict_response.rb new file mode 100644 index 0000000..b6e7c32 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/destination_address_predict_response.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class DestinationAddressPredictResponse + + # The country/region of the destination location where the package will be delivered. Use 3 letters of ISO 3166-1 country code. + # 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?: 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::DestinationAddressPredictResponse` initialize method" + end + + attributes = attributes.each_with_object({}) { |(k, v), h| + h[k.to_sym] = v + } + + if attributes.key?(:'country_region') + self.country_region = attributes[:'country_region'] + 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_region' => :'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_region' => :'country_region', + :'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_request.rb b/lib/aftership-tracking-sdk/models/detect_courier_request.rb new file mode 100644 index 0000000..d121f07 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/detect_courier_request.rb @@ -0,0 +1,263 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class DetectCourierRequest + + # 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 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_region?: String; + attr_accessor :tracking_origin_country_region + + # Destination Country/Region of the shipment for a specific courier. Required by some couriers. Refer to for more details + # tracking_destination_country_region?: String; + attr_accessor :tracking_destination_country_region + + # 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_region?: String; + attr_accessor :origin_country_region + + # Enter . + # destination_country_region?: String; + attr_accessor :destination_country_region + + # 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::DetectCourierRequest` 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_region') + self.tracking_origin_country_region = attributes[:'tracking_origin_country_region'] + end + + if attributes.key?(:'tracking_destination_country_region') + self.tracking_destination_country_region = attributes[:'tracking_destination_country_region'] + 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_region') + self.origin_country_region = attributes[:'origin_country_region'] + end + + if attributes.key?(:'destination_country_region') + self.destination_country_region = attributes[:'destination_country_region'] + 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_region' => :'String', + :'tracking_destination_country_region' => :'String', + :'tracking_state' => :'String', + :'slug_group' => :'SlugGroupV1', + :'origin_country_region' => :'String', + :'destination_country_region' => :'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_region' => :'tracking_origin_country_region', + :'tracking_destination_country_region' => :'tracking_destination_country_region', + :'tracking_state' => :'tracking_state', + :'slug_group' => :'slug_group', + :'origin_country_region' => :'origin_country_region', + :'destination_country_region' => :'destination_country_region', + } + 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..d6f4260 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/detect_courier_response.rb @@ -0,0 +1,163 @@ +# 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..316d26d --- /dev/null +++ b/lib/aftership-tracking-sdk/models/estimated_delivery_date_request.rb @@ -0,0 +1,223 @@ +# 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..5b050b2 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/estimated_delivery_date_response.rb @@ -0,0 +1,273 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class EstimatedDeliveryDateResponse + + # A string that acts as a unique identifier for the estimated delivery date value generated by AfterShip Predict API + # id: String; + attr_accessor :id + + # 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?(:'id') + self.id = attributes[:'id'] + end + + 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 + { + :'id' => :'String', + :'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 + { + :'id' => :'id', + :'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..3d7bc75 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/estimated_pickup_estimated_delivery_date_request.rb @@ -0,0 +1,183 @@ +# 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..4f70c49 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/estimated_pickup_estimated_delivery_date_response.rb @@ -0,0 +1,193 @@ +# 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/estimated_pickup_predict_request.rb b/lib/aftership-tracking-sdk/models/estimated_pickup_predict_request.rb new file mode 100644 index 0000000..eacf8b1 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/estimated_pickup_predict_request.rb @@ -0,0 +1,183 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class EstimatedPickupPredictRequest + + # 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?: OrderProcessingTimeEstimatedPickupPredictRequest; + 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::EstimatedPickupPredictRequest` 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' => :'OrderProcessingTimeEstimatedPickupPredictRequest', + } + 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_predict_response.rb b/lib/aftership-tracking-sdk/models/estimated_pickup_predict_response.rb new file mode 100644 index 0000000..0ac06a7 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/estimated_pickup_predict_response.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class EstimatedPickupPredictResponse + + # 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?: OrderProcessingTimeEstimatedPickupPredictResponse; + 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::EstimatedPickupPredictResponse` 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' => :'OrderProcessingTimeEstimatedPickupPredictResponse', + :'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..caba529 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/events_checkpoint.rb @@ -0,0 +1,163 @@ +# 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_create_tracking_response.rb b/lib/aftership-tracking-sdk/models/first_estimated_delivery_create_tracking_response.rb new file mode 100644 index 0000000..19172bd --- /dev/null +++ b/lib/aftership-tracking-sdk/models/first_estimated_delivery_create_tracking_response.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class FirstEstimatedDeliveryCreateTrackingResponse + + # 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::FirstEstimatedDeliveryCreateTrackingResponse` 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/first_estimated_delivery_delete_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/first_estimated_delivery_delete_tracking_by_id_response.rb new file mode 100644 index 0000000..2a10d55 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/first_estimated_delivery_delete_tracking_by_id_response.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class FirstEstimatedDeliveryDeleteTrackingByIdResponse + + # 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::FirstEstimatedDeliveryDeleteTrackingByIdResponse` 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/first_estimated_delivery_get_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/first_estimated_delivery_get_tracking_by_id_response.rb new file mode 100644 index 0000000..b9d1feb --- /dev/null +++ b/lib/aftership-tracking-sdk/models/first_estimated_delivery_get_tracking_by_id_response.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class FirstEstimatedDeliveryGetTrackingByIdResponse + + # 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::FirstEstimatedDeliveryGetTrackingByIdResponse` 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/first_estimated_delivery_mark_tracking_completed_by_id_response.rb b/lib/aftership-tracking-sdk/models/first_estimated_delivery_mark_tracking_completed_by_id_response.rb new file mode 100644 index 0000000..317c3d5 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/first_estimated_delivery_mark_tracking_completed_by_id_response.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class FirstEstimatedDeliveryMarkTrackingCompletedByIdResponse + + # 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::FirstEstimatedDeliveryMarkTrackingCompletedByIdResponse` 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/first_estimated_delivery_retrack_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/first_estimated_delivery_retrack_tracking_by_id_response.rb new file mode 100644 index 0000000..bfe0b3f --- /dev/null +++ b/lib/aftership-tracking-sdk/models/first_estimated_delivery_retrack_tracking_by_id_response.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class FirstEstimatedDeliveryRetrackTrackingByIdResponse + + # 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::FirstEstimatedDeliveryRetrackTrackingByIdResponse` 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/first_estimated_delivery_tracking.rb b/lib/aftership-tracking-sdk/models/first_estimated_delivery_tracking.rb new file mode 100644 index 0000000..b34ba1f --- /dev/null +++ b/lib/aftership-tracking-sdk/models/first_estimated_delivery_tracking.rb @@ -0,0 +1,193 @@ +# 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/first_estimated_delivery_update_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/first_estimated_delivery_update_tracking_by_id_response.rb new file mode 100644 index 0000000..3e48c25 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/first_estimated_delivery_update_tracking_by_id_response.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class FirstEstimatedDeliveryUpdateTrackingByIdResponse + + # 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::FirstEstimatedDeliveryUpdateTrackingByIdResponse` 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/first_mile_create_tracking_response.rb b/lib/aftership-tracking-sdk/models/first_mile_create_tracking_response.rb new file mode 100644 index 0000000..48554a5 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/first_mile_create_tracking_response.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class FirstMileCreateTrackingResponse + + # The tracking number of the first-mile carrier. + # tracking_number?: String; + attr_accessor :tracking_number + + # The unique code of the carrier responsible for the first-mile of the shipment. Find all the courier slugs . + # slug?: String; + attr_accessor :slug + + # The transit time for the first-mile of a shipment in days. This field is calculated based on whether the handed_over_to_last_mile_carrier or received_by_last_mile_carrier event is detected by AfterShip. The handover event date is used to calculate the first-mile transit time.- First mile transit time (in days) = Handover date - Pickup date + # transit_time?: String; + attr_accessor :transit_time + + # The field provides the link for modifying delivery instructions (such as delivery date and shipping address), if supported by the first-mile carrier. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_redirect_link?: String; + attr_accessor :courier_redirect_link + + # The field contains the official tracking URL of the first-mile carrier, if available. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_tracking_link?: String; + attr_accessor :courier_tracking_link + + # 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::FirstMileCreateTrackingResponse` 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?(:'transit_time') + self.transit_time = attributes[:'transit_time'] + end + + if attributes.key?(:'courier_redirect_link') + self.courier_redirect_link = attributes[:'courier_redirect_link'] + end + + if attributes.key?(:'courier_tracking_link') + self.courier_tracking_link = attributes[:'courier_tracking_link'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'tracking_number' => :'String', + :'slug' => :'String', + :'transit_time' => :'String', + :'courier_redirect_link' => :'String', + :'courier_tracking_link' => :'String', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'tracking_number' => :'tracking_number', + :'slug' => :'slug', + :'transit_time' => :'transit_time', + :'courier_redirect_link' => :'courier_redirect_link', + :'courier_tracking_link' => :'courier_tracking_link', + } + 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_mile_delete_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/first_mile_delete_tracking_by_id_response.rb new file mode 100644 index 0000000..f588734 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/first_mile_delete_tracking_by_id_response.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class FirstMileDeleteTrackingByIdResponse + + # The tracking number of the first-mile carrier. + # tracking_number?: String; + attr_accessor :tracking_number + + # The unique code of the carrier responsible for the first-mile of the shipment. Find all the courier slugs . + # slug?: String; + attr_accessor :slug + + # The transit time for the first-mile of a shipment in days. This field is calculated based on whether the handed_over_to_last_mile_carrier or received_by_last_mile_carrier event is detected by AfterShip. The handover event date is used to calculate the first-mile transit time.- First mile transit time (in days) = Handover date - Pickup date + # transit_time?: String; + attr_accessor :transit_time + + # The field provides the link for modifying delivery instructions (such as delivery date and shipping address), if supported by the first-mile carrier. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_redirect_link?: String; + attr_accessor :courier_redirect_link + + # The field contains the official tracking URL of the first-mile carrier, if available. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_tracking_link?: String; + attr_accessor :courier_tracking_link + + # 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::FirstMileDeleteTrackingByIdResponse` 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?(:'transit_time') + self.transit_time = attributes[:'transit_time'] + end + + if attributes.key?(:'courier_redirect_link') + self.courier_redirect_link = attributes[:'courier_redirect_link'] + end + + if attributes.key?(:'courier_tracking_link') + self.courier_tracking_link = attributes[:'courier_tracking_link'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'tracking_number' => :'String', + :'slug' => :'String', + :'transit_time' => :'String', + :'courier_redirect_link' => :'String', + :'courier_tracking_link' => :'String', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'tracking_number' => :'tracking_number', + :'slug' => :'slug', + :'transit_time' => :'transit_time', + :'courier_redirect_link' => :'courier_redirect_link', + :'courier_tracking_link' => :'courier_tracking_link', + } + 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_mile_get_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/first_mile_get_tracking_by_id_response.rb new file mode 100644 index 0000000..2901083 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/first_mile_get_tracking_by_id_response.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class FirstMileGetTrackingByIdResponse + + # The tracking number of the first-mile carrier. + # tracking_number?: String; + attr_accessor :tracking_number + + # The unique code of the carrier responsible for the first-mile of the shipment. Find all the courier slugs . + # slug?: String; + attr_accessor :slug + + # The transit time for the first-mile of a shipment in days. This field is calculated based on whether the handed_over_to_last_mile_carrier or received_by_last_mile_carrier event is detected by AfterShip. The handover event date is used to calculate the first-mile transit time.- First mile transit time (in days) = Handover date - Pickup date + # transit_time?: String; + attr_accessor :transit_time + + # The field provides the link for modifying delivery instructions (such as delivery date and shipping address), if supported by the first-mile carrier. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_redirect_link?: String; + attr_accessor :courier_redirect_link + + # The field contains the official tracking URL of the first-mile carrier, if available. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_tracking_link?: String; + attr_accessor :courier_tracking_link + + # 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::FirstMileGetTrackingByIdResponse` 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?(:'transit_time') + self.transit_time = attributes[:'transit_time'] + end + + if attributes.key?(:'courier_redirect_link') + self.courier_redirect_link = attributes[:'courier_redirect_link'] + end + + if attributes.key?(:'courier_tracking_link') + self.courier_tracking_link = attributes[:'courier_tracking_link'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'tracking_number' => :'String', + :'slug' => :'String', + :'transit_time' => :'String', + :'courier_redirect_link' => :'String', + :'courier_tracking_link' => :'String', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'tracking_number' => :'tracking_number', + :'slug' => :'slug', + :'transit_time' => :'transit_time', + :'courier_redirect_link' => :'courier_redirect_link', + :'courier_tracking_link' => :'courier_tracking_link', + } + 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_mile_mark_tracking_completed_by_id_response.rb b/lib/aftership-tracking-sdk/models/first_mile_mark_tracking_completed_by_id_response.rb new file mode 100644 index 0000000..858fde2 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/first_mile_mark_tracking_completed_by_id_response.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class FirstMileMarkTrackingCompletedByIdResponse + + # The tracking number of the first-mile carrier. + # tracking_number?: String; + attr_accessor :tracking_number + + # The unique code of the carrier responsible for the first-mile of the shipment. Find all the courier slugs . + # slug?: String; + attr_accessor :slug + + # The transit time for the first-mile of a shipment in days. This field is calculated based on whether the handed_over_to_last_mile_carrier or received_by_last_mile_carrier event is detected by AfterShip. The handover event date is used to calculate the first-mile transit time.- First mile transit time (in days) = Handover date - Pickup date + # transit_time?: String; + attr_accessor :transit_time + + # The field provides the link for modifying delivery instructions (such as delivery date and shipping address), if supported by the first-mile carrier. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_redirect_link?: String; + attr_accessor :courier_redirect_link + + # The field contains the official tracking URL of the first-mile carrier, if available. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_tracking_link?: String; + attr_accessor :courier_tracking_link + + # 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::FirstMileMarkTrackingCompletedByIdResponse` 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?(:'transit_time') + self.transit_time = attributes[:'transit_time'] + end + + if attributes.key?(:'courier_redirect_link') + self.courier_redirect_link = attributes[:'courier_redirect_link'] + end + + if attributes.key?(:'courier_tracking_link') + self.courier_tracking_link = attributes[:'courier_tracking_link'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'tracking_number' => :'String', + :'slug' => :'String', + :'transit_time' => :'String', + :'courier_redirect_link' => :'String', + :'courier_tracking_link' => :'String', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'tracking_number' => :'tracking_number', + :'slug' => :'slug', + :'transit_time' => :'transit_time', + :'courier_redirect_link' => :'courier_redirect_link', + :'courier_tracking_link' => :'courier_tracking_link', + } + 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_mile_retrack_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/first_mile_retrack_tracking_by_id_response.rb new file mode 100644 index 0000000..2dd7cbc --- /dev/null +++ b/lib/aftership-tracking-sdk/models/first_mile_retrack_tracking_by_id_response.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class FirstMileRetrackTrackingByIdResponse + + # The tracking number of the first-mile carrier. + # tracking_number?: String; + attr_accessor :tracking_number + + # The unique code of the carrier responsible for the first-mile of the shipment. Find all the courier slugs . + # slug?: String; + attr_accessor :slug + + # The transit time for the first-mile of a shipment in days. This field is calculated based on whether the handed_over_to_last_mile_carrier or received_by_last_mile_carrier event is detected by AfterShip. The handover event date is used to calculate the first-mile transit time.- First mile transit time (in days) = Handover date - Pickup date + # transit_time?: String; + attr_accessor :transit_time + + # The field provides the link for modifying delivery instructions (such as delivery date and shipping address), if supported by the first-mile carrier. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_redirect_link?: String; + attr_accessor :courier_redirect_link + + # The field contains the official tracking URL of the first-mile carrier, if available. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_tracking_link?: String; + attr_accessor :courier_tracking_link + + # 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::FirstMileRetrackTrackingByIdResponse` 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?(:'transit_time') + self.transit_time = attributes[:'transit_time'] + end + + if attributes.key?(:'courier_redirect_link') + self.courier_redirect_link = attributes[:'courier_redirect_link'] + end + + if attributes.key?(:'courier_tracking_link') + self.courier_tracking_link = attributes[:'courier_tracking_link'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'tracking_number' => :'String', + :'slug' => :'String', + :'transit_time' => :'String', + :'courier_redirect_link' => :'String', + :'courier_tracking_link' => :'String', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'tracking_number' => :'tracking_number', + :'slug' => :'slug', + :'transit_time' => :'transit_time', + :'courier_redirect_link' => :'courier_redirect_link', + :'courier_tracking_link' => :'courier_tracking_link', + } + 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_mile_tracking.rb b/lib/aftership-tracking-sdk/models/first_mile_tracking.rb new file mode 100644 index 0000000..90c7cf9 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/first_mile_tracking.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class FirstMileTracking + + # The tracking number of the first-mile carrier. + # tracking_number?: String; + attr_accessor :tracking_number + + # The unique code of the carrier responsible for the first-mile of the shipment. Find all the courier slugs . + # slug?: String; + attr_accessor :slug + + # The transit time for the first-mile of a shipment in days. This field is calculated based on whether the handed_over_to_last_mile_carrier or received_by_last_mile_carrier event is detected by AfterShip. The handover event date is used to calculate the first-mile transit time.- First mile transit time (in days) = Handover date - Pickup date + # transit_time?: String; + attr_accessor :transit_time + + # The field provides the link for modifying delivery instructions (such as delivery date and shipping address), if supported by the first-mile carrier. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_redirect_link?: String; + attr_accessor :courier_redirect_link + + # The field contains the official tracking URL of the first-mile carrier, if available. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_tracking_link?: String; + attr_accessor :courier_tracking_link + + # 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::FirstMileTracking` 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?(:'transit_time') + self.transit_time = attributes[:'transit_time'] + end + + if attributes.key?(:'courier_redirect_link') + self.courier_redirect_link = attributes[:'courier_redirect_link'] + end + + if attributes.key?(:'courier_tracking_link') + self.courier_tracking_link = attributes[:'courier_tracking_link'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'tracking_number' => :'String', + :'slug' => :'String', + :'transit_time' => :'String', + :'courier_redirect_link' => :'String', + :'courier_tracking_link' => :'String', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'tracking_number' => :'tracking_number', + :'slug' => :'slug', + :'transit_time' => :'transit_time', + :'courier_redirect_link' => :'courier_redirect_link', + :'courier_tracking_link' => :'courier_tracking_link', + } + 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_mile_update_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/first_mile_update_tracking_by_id_response.rb new file mode 100644 index 0000000..f3c27a1 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/first_mile_update_tracking_by_id_response.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class FirstMileUpdateTrackingByIdResponse + + # The tracking number of the first-mile carrier. + # tracking_number?: String; + attr_accessor :tracking_number + + # The unique code of the carrier responsible for the first-mile of the shipment. Find all the courier slugs . + # slug?: String; + attr_accessor :slug + + # The transit time for the first-mile of a shipment in days. This field is calculated based on whether the handed_over_to_last_mile_carrier or received_by_last_mile_carrier event is detected by AfterShip. The handover event date is used to calculate the first-mile transit time.- First mile transit time (in days) = Handover date - Pickup date + # transit_time?: String; + attr_accessor :transit_time + + # The field provides the link for modifying delivery instructions (such as delivery date and shipping address), if supported by the first-mile carrier. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_redirect_link?: String; + attr_accessor :courier_redirect_link + + # The field contains the official tracking URL of the first-mile carrier, if available. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_tracking_link?: String; + attr_accessor :courier_tracking_link + + # 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::FirstMileUpdateTrackingByIdResponse` 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?(:'transit_time') + self.transit_time = attributes[:'transit_time'] + end + + if attributes.key?(:'courier_redirect_link') + self.courier_redirect_link = attributes[:'courier_redirect_link'] + end + + if attributes.key?(:'courier_tracking_link') + self.courier_tracking_link = attributes[:'courier_tracking_link'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'tracking_number' => :'String', + :'slug' => :'String', + :'transit_time' => :'String', + :'courier_redirect_link' => :'String', + :'courier_tracking_link' => :'String', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'tracking_number' => :'tracking_number', + :'slug' => :'slug', + :'transit_time' => :'transit_time', + :'courier_redirect_link' => :'courier_redirect_link', + :'courier_tracking_link' => :'courier_tracking_link', + } + 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..7ccb382 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/get_all_couriers_response.rb @@ -0,0 +1,163 @@ +# 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_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/get_tracking_by_id_response.rb new file mode 100644 index 0000000..0b7fa1f --- /dev/null +++ b/lib/aftership-tracking-sdk/models/get_tracking_by_id_response.rb @@ -0,0 +1,933 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class GetTrackingByIdResponse + + # Tracking ID. + # id?: String; + attr_accessor :id + + # The length of the tracking ID has been increased from 24 characters to 32 characters. We will use the legacy_id field to store the original 24-character tracking ID to maintain compatibility with existing data. Therefore, all tracking endpoints will continue to work with the legacy_id field as before. + # legacy_id?: String; + attr_accessor :legacy_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 + + # 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 + + # 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_region?: String; + attr_accessor :origin_country_region + + # 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_region?: String; + attr_accessor :destination_country_region + + # 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_region?: String; + attr_accessor :courier_destination_country_region + + # The field contains the estimated delivery date provided by the carrier. + # courier_estimated_delivery_date?: CourierEstimatedDeliveryDateGetTrackingByIdResponse; + attr_accessor :courier_estimated_delivery_date + + # 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 + + # The shipment_weight field represents the total weight of the shipment. In scenarios where the carrier does not provide this information, you can provide the weight to AfterShip. We will prioritize the data provided by the carrier, if available. The shipment weight will be included in the Response and accessed through the GET API, Webhook, and CSV export. It will also be displayed on the AfterShip Tracking admin. Additionally, it plays a significant role in error-free shipment handling and carbon emission calculations, ensuring accurate and informed decision-making + # shipment_weight?: ShipmentWeightGetTrackingByIdResponse; + attr_accessor :shipment_weight + + # Signed by information for delivered shipment. + # signed_by?: String; + attr_accessor :signed_by + + # 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. + # subscribed_smses?: String[]; + attr_accessor :subscribed_smses + + # Email address(es) subscribed to receive email notifications. + # 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 formats:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # 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 + + # The date and time when the shipment is shipped by the merchant and ready for pickup by the carrier. The field supports the following formats:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZThe field serves two key purposes:- Calculate processing time metrics in the Order-to-delivery Analytics dashboard. To ensure accurate analytics, it's recommended to include timezone information when configuring this value- Required by certain carriers to retrieve tracking information as an additional tracking field. + # 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?: AftershipEstimatedDeliveryDateGetTrackingByIdResponse; + 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?: CustomEstimatedDeliveryDateGetTrackingByIdResponse; + 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?: FirstEstimatedDeliveryGetTrackingByIdResponse; + 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?: LatestEstimatedDeliveryGetTrackingByIdResponse; + 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 + + # (Legacy) Replaced by `origin_country_region`. 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_region?: String; + attr_accessor :tracking_origin_country_region + + # (Legacy) Replaced by `destination_country_region`. 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_region?: String; + attr_accessor :tracking_destination_country_region + + # (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?: CarbonEmissionsGetTrackingByIdResponse; + 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 + + # The delivery location type represents the secure area where the carrier leaves the package, such as a safe place, locker, mailbox, front porch, etc. This information helps ensure the shipment reaches the intended recipient efficiently, minimizing the risk of theft or damage. + # delivery_location_type?: String; + attr_accessor :delivery_location_type + + # The tracking URL directs your customers to the shipment tracking page which can display either the default or a customized page based on segmentation rules.- The universal URL is used by default, but you can opt for a custom domain if you have one. Learn how to set up a custom domain .The field is not automatically enabled in API & Webhook. Please contact support if you’d like to enable it. + # aftership_tracking_url?: String; + attr_accessor :aftership_tracking_url + + # The order URL directs your customers to the order tracking page, which includes all shipments. It can display either the default or a customized page based on segmentation rules.- The universal URL is used by default, but you can opt for a custom domain if you have one. Learn how to set up a custom domain .The field is not automatically enabled in API & Webhook. Please contact support if you’d like to enable it. + # aftership_tracking_order_url?: String; + attr_accessor :aftership_tracking_order_url + + # The field contains information about the first leg of the shipping starting from the carrier picking up the shipment from the shipper to the point where they hand it over to the last-mile carrier. Once AfterShip detects the shipment is multi-leg, we will populate the first-mile information under this object. + # first_mile?: FirstMileGetTrackingByIdResponse; + attr_accessor :first_mile + + # This field contains information about the last leg of the shipment, starting from the carrier who hands it over to the last-mile carrier, all the way to delivery. Once AfterShip detects that the shipment involves multiple legs and identifies the last-mile carrier, we will populate the last-mile carrier information in this object. Alternatively, the user can provide this information in this field to specify the last-mile carrier, which is helpful if AfterShip is unable to detect it automatically. + # last_mile?: LastMileGetTrackingByIdResponse; + attr_accessor :last_mile + + # The field contains the customer information associated with the tracking. A maximum of three customer objects are allowed. + # customers?: CustomersGetTrackingByIdResponse[]; + attr_accessor :customers + + # 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::GetTrackingByIdResponse` 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?(:'legacy_id') + self.legacy_id = attributes[:'legacy_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?(:'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?(:'transit_time') + self.transit_time = attributes[:'transit_time'] + end + + if attributes.key?(:'origin_country_region') + self.origin_country_region = attributes[:'origin_country_region'] + 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_region') + self.destination_country_region = attributes[:'destination_country_region'] + 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_region') + self.courier_destination_country_region = attributes[:'courier_destination_country_region'] + end + + if attributes.key?(:'courier_estimated_delivery_date') + self.courier_estimated_delivery_date = attributes[:'courier_estimated_delivery_date'] + 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?(:'signed_by') + self.signed_by = attributes[:'signed_by'] + 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?(:'tracking_origin_country_region') + self.tracking_origin_country_region = attributes[:'tracking_origin_country_region'] + end + + if attributes.key?(:'tracking_destination_country_region') + self.tracking_destination_country_region = attributes[:'tracking_destination_country_region'] + 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 + + if attributes.key?(:'delivery_location_type') + self.delivery_location_type = attributes[:'delivery_location_type'] + end + + if attributes.key?(:'aftership_tracking_url') + self.aftership_tracking_url = attributes[:'aftership_tracking_url'] + end + + if attributes.key?(:'aftership_tracking_order_url') + self.aftership_tracking_order_url = attributes[:'aftership_tracking_order_url'] + end + + if attributes.key?(:'first_mile') + self.first_mile = attributes[:'first_mile'] + end + + if attributes.key?(:'last_mile') + self.last_mile = attributes[:'last_mile'] + end + + if attributes.key?(:'customers') + self.customers = attributes[:'customers'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'legacy_id' => :'String', + :'created_at' => :'String', + :'updated_at' => :'String', + :'tracking_number' => :'String', + :'slug' => :'String', + :'active' => :'Boolean', + :'custom_fields' => :'Object', + :'transit_time' => :'Integer', + :'origin_country_region' => :'String', + :'origin_state' => :'String', + :'origin_city' => :'String', + :'origin_postal_code' => :'String', + :'origin_raw_location' => :'String', + :'destination_country_region' => :'String', + :'destination_state' => :'String', + :'destination_city' => :'String', + :'destination_postal_code' => :'String', + :'destination_raw_location' => :'String', + :'courier_destination_country_region' => :'String', + :'courier_estimated_delivery_date' => :'CourierEstimatedDeliveryDateGetTrackingByIdResponse', + :'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' => :'ShipmentWeightGetTrackingByIdResponse', + :'signed_by' => :'String', + :'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' => :'AftershipEstimatedDeliveryDateGetTrackingByIdResponse', + :'custom_estimated_delivery_date' => :'CustomEstimatedDeliveryDateGetTrackingByIdResponse', + :'order_number' => :'String', + :'first_estimated_delivery' => :'FirstEstimatedDeliveryGetTrackingByIdResponse', + :'latest_estimated_delivery' => :'LatestEstimatedDeliveryGetTrackingByIdResponse', + :'shipment_tags' => :'Array', + :'courier_connection_id' => :'String', + :'tracking_origin_country_region' => :'String', + :'tracking_destination_country_region' => :'String', + :'tracking_postal_code' => :'String', + :'tracking_state' => :'String', + :'carbon_emissions' => :'CarbonEmissionsGetTrackingByIdResponse', + :'location_id' => :'String', + :'shipping_method' => :'String', + :'failed_delivery_attempts' => :'Integer', + :'signature_requirement' => :'String', + :'delivery_location_type' => :'String', + :'aftership_tracking_url' => :'String', + :'aftership_tracking_order_url' => :'String', + :'first_mile' => :'FirstMileGetTrackingByIdResponse', + :'last_mile' => :'LastMileGetTrackingByIdResponse', + :'customers' => :'Array', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'legacy_id' => :'legacy_id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'tracking_number' => :'tracking_number', + :'slug' => :'slug', + :'active' => :'active', + :'custom_fields' => :'custom_fields', + :'transit_time' => :'transit_time', + :'origin_country_region' => :'origin_country_region', + :'origin_state' => :'origin_state', + :'origin_city' => :'origin_city', + :'origin_postal_code' => :'origin_postal_code', + :'origin_raw_location' => :'origin_raw_location', + :'destination_country_region' => :'destination_country_region', + :'destination_state' => :'destination_state', + :'destination_city' => :'destination_city', + :'destination_postal_code' => :'destination_postal_code', + :'destination_raw_location' => :'destination_raw_location', + :'courier_destination_country_region' => :'courier_destination_country_region', + :'courier_estimated_delivery_date' => :'courier_estimated_delivery_date', + :'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', + :'signed_by' => :'signed_by', + :'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', + :'tracking_origin_country_region' => :'tracking_origin_country_region', + :'tracking_destination_country_region' => :'tracking_destination_country_region', + :'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', + :'delivery_location_type' => :'delivery_location_type', + :'aftership_tracking_url' => :'aftership_tracking_url', + :'aftership_tracking_order_url' => :'aftership_tracking_order_url', + :'first_mile' => :'first_mile', + :'last_mile' => :'last_mile', + :'customers' => :'customers', + } + 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..4146ca9 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/get_trackings_response.rb @@ -0,0 +1,163 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class GetTrackingsResponse + + # The Pagination holds the information for the pagination when the response contains multiple objects. + # pagination?: PaginationGetTrackingsResponse; + 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' => :'PaginationGetTrackingsResponse', + :'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..e618e93 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/get_user_couriers_response.rb @@ -0,0 +1,163 @@ +# 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/last_mile_create_tracking_request.rb b/lib/aftership-tracking-sdk/models/last_mile_create_tracking_request.rb new file mode 100644 index 0000000..4e3ebc7 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/last_mile_create_tracking_request.rb @@ -0,0 +1,163 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class LastMileCreateTrackingRequest + + # The tracking number of the last-mile carrier. + # tracking_number: String; + attr_accessor :tracking_number + + # The unique code of the carrier responsible for the last-mile of the shipment. Find all the courier slugs . + # 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::LastMileCreateTrackingRequest` 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 + end + + # Attribute type mapping. + def self.openapi_types + { + :'tracking_number' => :'String', + :'slug' => :'String', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'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/last_mile_create_tracking_response.rb b/lib/aftership-tracking-sdk/models/last_mile_create_tracking_response.rb new file mode 100644 index 0000000..69b6c0f --- /dev/null +++ b/lib/aftership-tracking-sdk/models/last_mile_create_tracking_response.rb @@ -0,0 +1,203 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class LastMileCreateTrackingResponse + + # The tracking number of the last-mile carrier. + # tracking_number?: String; + attr_accessor :tracking_number + + # The unique code of the carrier responsible for the last-mile of the shipment. Find all the courier slugs . + # slug?: String; + attr_accessor :slug + + # The transit time for the last-mile of a shipment in days. This field is calculated based on whether the handed_over_to_last_mile_carrier or the received_by_last_mile_carrier event is detected by AfterShip. The handover event date is used to calculate the last-mile transit time.- Last mile transit time (in days)= Delivered date - Handover date + # transit_time?: String; + attr_accessor :transit_time + + # The field contains the official tracking URL of the last-mile carrier, if available. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_tracking_link?: String; + attr_accessor :courier_tracking_link + + # The field provides the link for modifying delivery instructions (such as delivery date and shipping address), if supported by the last-mile carrier. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_redirect_link?: String; + attr_accessor :courier_redirect_link + + # The field indicates the source of last-mile carrier. + # 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::LastMileCreateTrackingResponse` 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?(:'transit_time') + self.transit_time = attributes[:'transit_time'] + end + + if attributes.key?(:'courier_tracking_link') + self.courier_tracking_link = attributes[:'courier_tracking_link'] + end + + if attributes.key?(:'courier_redirect_link') + self.courier_redirect_link = attributes[:'courier_redirect_link'] + end + + if attributes.key?(:'source') + self.source = attributes[:'source'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'tracking_number' => :'String', + :'slug' => :'String', + :'transit_time' => :'String', + :'courier_tracking_link' => :'String', + :'courier_redirect_link' => :'String', + :'source' => :'String', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'tracking_number' => :'tracking_number', + :'slug' => :'slug', + :'transit_time' => :'transit_time', + :'courier_tracking_link' => :'courier_tracking_link', + :'courier_redirect_link' => :'courier_redirect_link', + :'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/last_mile_delete_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/last_mile_delete_tracking_by_id_response.rb new file mode 100644 index 0000000..c236db8 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/last_mile_delete_tracking_by_id_response.rb @@ -0,0 +1,203 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class LastMileDeleteTrackingByIdResponse + + # The tracking number of the last-mile carrier. + # tracking_number?: String; + attr_accessor :tracking_number + + # The unique code of the carrier responsible for the last-mile of the shipment. Find all the courier slugs . + # slug?: String; + attr_accessor :slug + + # The transit time for the last-mile of a shipment in days. This field is calculated based on whether the handed_over_to_last_mile_carrier or the received_by_last_mile_carrier event is detected by AfterShip. The handover event date is used to calculate the last-mile transit time.- Last mile transit time (in days)= Delivered date - Handover date + # transit_time?: String; + attr_accessor :transit_time + + # The field contains the official tracking URL of the last-mile carrier, if available. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_tracking_link?: String; + attr_accessor :courier_tracking_link + + # The field provides the link for modifying delivery instructions (such as delivery date and shipping address), if supported by the last-mile carrier. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_redirect_link?: String; + attr_accessor :courier_redirect_link + + # The field indicates the source of last-mile carrier. + # 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::LastMileDeleteTrackingByIdResponse` 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?(:'transit_time') + self.transit_time = attributes[:'transit_time'] + end + + if attributes.key?(:'courier_tracking_link') + self.courier_tracking_link = attributes[:'courier_tracking_link'] + end + + if attributes.key?(:'courier_redirect_link') + self.courier_redirect_link = attributes[:'courier_redirect_link'] + end + + if attributes.key?(:'source') + self.source = attributes[:'source'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'tracking_number' => :'String', + :'slug' => :'String', + :'transit_time' => :'String', + :'courier_tracking_link' => :'String', + :'courier_redirect_link' => :'String', + :'source' => :'String', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'tracking_number' => :'tracking_number', + :'slug' => :'slug', + :'transit_time' => :'transit_time', + :'courier_tracking_link' => :'courier_tracking_link', + :'courier_redirect_link' => :'courier_redirect_link', + :'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/last_mile_get_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/last_mile_get_tracking_by_id_response.rb new file mode 100644 index 0000000..a5ed7fe --- /dev/null +++ b/lib/aftership-tracking-sdk/models/last_mile_get_tracking_by_id_response.rb @@ -0,0 +1,203 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class LastMileGetTrackingByIdResponse + + # The tracking number of the last-mile carrier. + # tracking_number?: String; + attr_accessor :tracking_number + + # The unique code of the carrier responsible for the last-mile of the shipment. Find all the courier slugs . + # slug?: String; + attr_accessor :slug + + # The transit time for the last-mile of a shipment in days. This field is calculated based on whether the handed_over_to_last_mile_carrier or the received_by_last_mile_carrier event is detected by AfterShip. The handover event date is used to calculate the last-mile transit time.- Last mile transit time (in days)= Delivered date - Handover date + # transit_time?: String; + attr_accessor :transit_time + + # The field contains the official tracking URL of the last-mile carrier, if available. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_tracking_link?: String; + attr_accessor :courier_tracking_link + + # The field provides the link for modifying delivery instructions (such as delivery date and shipping address), if supported by the last-mile carrier. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_redirect_link?: String; + attr_accessor :courier_redirect_link + + # The field indicates the source of last-mile carrier. + # 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::LastMileGetTrackingByIdResponse` 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?(:'transit_time') + self.transit_time = attributes[:'transit_time'] + end + + if attributes.key?(:'courier_tracking_link') + self.courier_tracking_link = attributes[:'courier_tracking_link'] + end + + if attributes.key?(:'courier_redirect_link') + self.courier_redirect_link = attributes[:'courier_redirect_link'] + end + + if attributes.key?(:'source') + self.source = attributes[:'source'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'tracking_number' => :'String', + :'slug' => :'String', + :'transit_time' => :'String', + :'courier_tracking_link' => :'String', + :'courier_redirect_link' => :'String', + :'source' => :'String', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'tracking_number' => :'tracking_number', + :'slug' => :'slug', + :'transit_time' => :'transit_time', + :'courier_tracking_link' => :'courier_tracking_link', + :'courier_redirect_link' => :'courier_redirect_link', + :'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/last_mile_mark_tracking_completed_by_id_response.rb b/lib/aftership-tracking-sdk/models/last_mile_mark_tracking_completed_by_id_response.rb new file mode 100644 index 0000000..2744bc9 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/last_mile_mark_tracking_completed_by_id_response.rb @@ -0,0 +1,203 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class LastMileMarkTrackingCompletedByIdResponse + + # The tracking number of the last-mile carrier. + # tracking_number?: String; + attr_accessor :tracking_number + + # The unique code of the carrier responsible for the last-mile of the shipment. Find all the courier slugs . + # slug?: String; + attr_accessor :slug + + # The transit time for the last-mile of a shipment in days. This field is calculated based on whether the handed_over_to_last_mile_carrier or the received_by_last_mile_carrier event is detected by AfterShip. The handover event date is used to calculate the last-mile transit time.- Last mile transit time (in days)= Delivered date - Handover date + # transit_time?: String; + attr_accessor :transit_time + + # The field contains the official tracking URL of the last-mile carrier, if available. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_tracking_link?: String; + attr_accessor :courier_tracking_link + + # The field provides the link for modifying delivery instructions (such as delivery date and shipping address), if supported by the last-mile carrier. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_redirect_link?: String; + attr_accessor :courier_redirect_link + + # The field indicates the source of last-mile carrier. + # 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::LastMileMarkTrackingCompletedByIdResponse` 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?(:'transit_time') + self.transit_time = attributes[:'transit_time'] + end + + if attributes.key?(:'courier_tracking_link') + self.courier_tracking_link = attributes[:'courier_tracking_link'] + end + + if attributes.key?(:'courier_redirect_link') + self.courier_redirect_link = attributes[:'courier_redirect_link'] + end + + if attributes.key?(:'source') + self.source = attributes[:'source'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'tracking_number' => :'String', + :'slug' => :'String', + :'transit_time' => :'String', + :'courier_tracking_link' => :'String', + :'courier_redirect_link' => :'String', + :'source' => :'String', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'tracking_number' => :'tracking_number', + :'slug' => :'slug', + :'transit_time' => :'transit_time', + :'courier_tracking_link' => :'courier_tracking_link', + :'courier_redirect_link' => :'courier_redirect_link', + :'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/last_mile_retrack_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/last_mile_retrack_tracking_by_id_response.rb new file mode 100644 index 0000000..3e4ee93 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/last_mile_retrack_tracking_by_id_response.rb @@ -0,0 +1,203 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class LastMileRetrackTrackingByIdResponse + + # The tracking number of the last-mile carrier. + # tracking_number?: String; + attr_accessor :tracking_number + + # The unique code of the carrier responsible for the last-mile of the shipment. Find all the courier slugs . + # slug?: String; + attr_accessor :slug + + # The transit time for the last-mile of a shipment in days. This field is calculated based on whether the handed_over_to_last_mile_carrier or the received_by_last_mile_carrier event is detected by AfterShip. The handover event date is used to calculate the last-mile transit time.- Last mile transit time (in days)= Delivered date - Handover date + # transit_time?: String; + attr_accessor :transit_time + + # The field contains the official tracking URL of the last-mile carrier, if available. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_tracking_link?: String; + attr_accessor :courier_tracking_link + + # The field provides the link for modifying delivery instructions (such as delivery date and shipping address), if supported by the last-mile carrier. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_redirect_link?: String; + attr_accessor :courier_redirect_link + + # The field indicates the source of last-mile carrier. + # 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::LastMileRetrackTrackingByIdResponse` 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?(:'transit_time') + self.transit_time = attributes[:'transit_time'] + end + + if attributes.key?(:'courier_tracking_link') + self.courier_tracking_link = attributes[:'courier_tracking_link'] + end + + if attributes.key?(:'courier_redirect_link') + self.courier_redirect_link = attributes[:'courier_redirect_link'] + end + + if attributes.key?(:'source') + self.source = attributes[:'source'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'tracking_number' => :'String', + :'slug' => :'String', + :'transit_time' => :'String', + :'courier_tracking_link' => :'String', + :'courier_redirect_link' => :'String', + :'source' => :'String', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'tracking_number' => :'tracking_number', + :'slug' => :'slug', + :'transit_time' => :'transit_time', + :'courier_tracking_link' => :'courier_tracking_link', + :'courier_redirect_link' => :'courier_redirect_link', + :'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/last_mile_tracking.rb b/lib/aftership-tracking-sdk/models/last_mile_tracking.rb new file mode 100644 index 0000000..9dff197 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/last_mile_tracking.rb @@ -0,0 +1,203 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class LastMileTracking + + # The tracking number of the last-mile carrier. + # tracking_number?: String; + attr_accessor :tracking_number + + # The unique code of the carrier responsible for the last-mile of the shipment. Find all the courier slugs . + # slug?: String; + attr_accessor :slug + + # The transit time for the last-mile of a shipment in days. This field is calculated based on whether the handed_over_to_last_mile_carrier or the received_by_last_mile_carrier event is detected by AfterShip. The handover event date is used to calculate the last-mile transit time.- Last mile transit time (in days)= Delivered date - Handover date + # transit_time?: String; + attr_accessor :transit_time + + # The field contains the official tracking URL of the last-mile carrier, if available. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_tracking_link?: String; + attr_accessor :courier_tracking_link + + # The field provides the link for modifying delivery instructions (such as delivery date and shipping address), if supported by the last-mile carrier. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_redirect_link?: String; + attr_accessor :courier_redirect_link + + # The field indicates the source of last-mile carrier. + # 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::LastMileTracking` 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?(:'transit_time') + self.transit_time = attributes[:'transit_time'] + end + + if attributes.key?(:'courier_tracking_link') + self.courier_tracking_link = attributes[:'courier_tracking_link'] + end + + if attributes.key?(:'courier_redirect_link') + self.courier_redirect_link = attributes[:'courier_redirect_link'] + end + + if attributes.key?(:'source') + self.source = attributes[:'source'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'tracking_number' => :'String', + :'slug' => :'String', + :'transit_time' => :'String', + :'courier_tracking_link' => :'String', + :'courier_redirect_link' => :'String', + :'source' => :'String', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'tracking_number' => :'tracking_number', + :'slug' => :'slug', + :'transit_time' => :'transit_time', + :'courier_tracking_link' => :'courier_tracking_link', + :'courier_redirect_link' => :'courier_redirect_link', + :'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/last_mile_update_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/last_mile_update_tracking_by_id_response.rb new file mode 100644 index 0000000..f0dd577 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/last_mile_update_tracking_by_id_response.rb @@ -0,0 +1,203 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class LastMileUpdateTrackingByIdResponse + + # The tracking number of the last-mile carrier. + # tracking_number?: String; + attr_accessor :tracking_number + + # The unique code of the carrier responsible for the last-mile of the shipment. Find all the courier slugs . + # slug?: String; + attr_accessor :slug + + # The transit time for the last-mile of a shipment in days. This field is calculated based on whether the handed_over_to_last_mile_carrier or the received_by_last_mile_carrier event is detected by AfterShip. The handover event date is used to calculate the last-mile transit time.- Last mile transit time (in days)= Delivered date - Handover date + # transit_time?: String; + attr_accessor :transit_time + + # The field contains the official tracking URL of the last-mile carrier, if available. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_tracking_link?: String; + attr_accessor :courier_tracking_link + + # The field provides the link for modifying delivery instructions (such as delivery date and shipping address), if supported by the last-mile carrier. The language parameter of this link is determined by the destination country/region and the language associated with the shipment. If the destination country/region and language data is unavailable, AfterShip will default the language parameter to "US". + # courier_redirect_link?: String; + attr_accessor :courier_redirect_link + + # The field indicates the source of last-mile carrier. + # 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::LastMileUpdateTrackingByIdResponse` 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?(:'transit_time') + self.transit_time = attributes[:'transit_time'] + end + + if attributes.key?(:'courier_tracking_link') + self.courier_tracking_link = attributes[:'courier_tracking_link'] + end + + if attributes.key?(:'courier_redirect_link') + self.courier_redirect_link = attributes[:'courier_redirect_link'] + end + + if attributes.key?(:'source') + self.source = attributes[:'source'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'tracking_number' => :'String', + :'slug' => :'String', + :'transit_time' => :'String', + :'courier_tracking_link' => :'String', + :'courier_redirect_link' => :'String', + :'source' => :'String', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'tracking_number' => :'tracking_number', + :'slug' => :'slug', + :'transit_time' => :'transit_time', + :'courier_tracking_link' => :'courier_tracking_link', + :'courier_redirect_link' => :'courier_redirect_link', + :'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/latest_estimated_delivery_create_tracking_response.rb b/lib/aftership-tracking-sdk/models/latest_estimated_delivery_create_tracking_response.rb new file mode 100644 index 0000000..d71b9c8 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/latest_estimated_delivery_create_tracking_response.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class LatestEstimatedDeliveryCreateTrackingResponse + + # 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::LatestEstimatedDeliveryCreateTrackingResponse` 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/latest_estimated_delivery_delete_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/latest_estimated_delivery_delete_tracking_by_id_response.rb new file mode 100644 index 0000000..764f399 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/latest_estimated_delivery_delete_tracking_by_id_response.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class LatestEstimatedDeliveryDeleteTrackingByIdResponse + + # 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::LatestEstimatedDeliveryDeleteTrackingByIdResponse` 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/latest_estimated_delivery_get_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/latest_estimated_delivery_get_tracking_by_id_response.rb new file mode 100644 index 0000000..0faa5d9 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/latest_estimated_delivery_get_tracking_by_id_response.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class LatestEstimatedDeliveryGetTrackingByIdResponse + + # 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::LatestEstimatedDeliveryGetTrackingByIdResponse` 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/latest_estimated_delivery_mark_tracking_completed_by_id_response.rb b/lib/aftership-tracking-sdk/models/latest_estimated_delivery_mark_tracking_completed_by_id_response.rb new file mode 100644 index 0000000..592339b --- /dev/null +++ b/lib/aftership-tracking-sdk/models/latest_estimated_delivery_mark_tracking_completed_by_id_response.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class LatestEstimatedDeliveryMarkTrackingCompletedByIdResponse + + # 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::LatestEstimatedDeliveryMarkTrackingCompletedByIdResponse` 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/latest_estimated_delivery_retrack_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/latest_estimated_delivery_retrack_tracking_by_id_response.rb new file mode 100644 index 0000000..9432d99 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/latest_estimated_delivery_retrack_tracking_by_id_response.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class LatestEstimatedDeliveryRetrackTrackingByIdResponse + + # 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::LatestEstimatedDeliveryRetrackTrackingByIdResponse` 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/latest_estimated_delivery_tracking.rb b/lib/aftership-tracking-sdk/models/latest_estimated_delivery_tracking.rb new file mode 100644 index 0000000..40d0930 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/latest_estimated_delivery_tracking.rb @@ -0,0 +1,193 @@ +# 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/latest_estimated_delivery_update_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/latest_estimated_delivery_update_tracking_by_id_response.rb new file mode 100644 index 0000000..3f08f2c --- /dev/null +++ b/lib/aftership-tracking-sdk/models/latest_estimated_delivery_update_tracking_by_id_response.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class LatestEstimatedDeliveryUpdateTrackingByIdResponse + + # 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::LatestEstimatedDeliveryUpdateTrackingByIdResponse` 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..2f838bc --- /dev/null +++ b/lib/aftership-tracking-sdk/models/mark_tracking_completed_by_id_request.rb @@ -0,0 +1,153 @@ +# 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_id_response.rb b/lib/aftership-tracking-sdk/models/mark_tracking_completed_by_id_response.rb new file mode 100644 index 0000000..07d2de8 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/mark_tracking_completed_by_id_response.rb @@ -0,0 +1,933 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class MarkTrackingCompletedByIdResponse + + # Tracking ID. + # id?: String; + attr_accessor :id + + # The length of the tracking ID has been increased from 24 characters to 32 characters. We will use the legacy_id field to store the original 24-character tracking ID to maintain compatibility with existing data. Therefore, all tracking endpoints will continue to work with the legacy_id field as before. + # legacy_id?: String; + attr_accessor :legacy_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 + + # 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 + + # 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_region?: String; + attr_accessor :origin_country_region + + # 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_region?: String; + attr_accessor :destination_country_region + + # 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_region?: String; + attr_accessor :courier_destination_country_region + + # The field contains the estimated delivery date provided by the carrier. + # courier_estimated_delivery_date?: CourierEstimatedDeliveryDateMarkTrackingCompletedByIdResponse; + attr_accessor :courier_estimated_delivery_date + + # 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 + + # The shipment_weight field represents the total weight of the shipment. In scenarios where the carrier does not provide this information, you can provide the weight to AfterShip. We will prioritize the data provided by the carrier, if available. The shipment weight will be included in the Response and accessed through the GET API, Webhook, and CSV export. It will also be displayed on the AfterShip Tracking admin. Additionally, it plays a significant role in error-free shipment handling and carbon emission calculations, ensuring accurate and informed decision-making + # shipment_weight?: ShipmentWeightMarkTrackingCompletedByIdResponse; + attr_accessor :shipment_weight + + # Signed by information for delivered shipment. + # signed_by?: String; + attr_accessor :signed_by + + # 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. + # subscribed_smses?: String[]; + attr_accessor :subscribed_smses + + # Email address(es) subscribed to receive email notifications. + # 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 formats:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # 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 + + # The date and time when the shipment is shipped by the merchant and ready for pickup by the carrier. The field supports the following formats:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZThe field serves two key purposes:- Calculate processing time metrics in the Order-to-delivery Analytics dashboard. To ensure accurate analytics, it's recommended to include timezone information when configuring this value- Required by certain carriers to retrieve tracking information as an additional tracking field. + # 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?: AftershipEstimatedDeliveryDateMarkTrackingCompletedByIdResponse; + 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?: CustomEstimatedDeliveryDateMarkTrackingCompletedByIdResponse; + 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?: FirstEstimatedDeliveryMarkTrackingCompletedByIdResponse; + 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?: LatestEstimatedDeliveryMarkTrackingCompletedByIdResponse; + 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 + + # (Legacy) Replaced by `origin_country_region`. 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_region?: String; + attr_accessor :tracking_origin_country_region + + # (Legacy) Replaced by `destination_country_region`. 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_region?: String; + attr_accessor :tracking_destination_country_region + + # (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?: CarbonEmissionsMarkTrackingCompletedByIdResponse; + 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 + + # The delivery location type represents the secure area where the carrier leaves the package, such as a safe place, locker, mailbox, front porch, etc. This information helps ensure the shipment reaches the intended recipient efficiently, minimizing the risk of theft or damage. + # delivery_location_type?: String; + attr_accessor :delivery_location_type + + # The tracking URL directs your customers to the shipment tracking page which can display either the default or a customized page based on segmentation rules.- The universal URL is used by default, but you can opt for a custom domain if you have one. Learn how to set up a custom domain .The field is not automatically enabled in API & Webhook. Please contact support if you’d like to enable it. + # aftership_tracking_url?: String; + attr_accessor :aftership_tracking_url + + # The order URL directs your customers to the order tracking page, which includes all shipments. It can display either the default or a customized page based on segmentation rules.- The universal URL is used by default, but you can opt for a custom domain if you have one. Learn how to set up a custom domain .The field is not automatically enabled in API & Webhook. Please contact support if you’d like to enable it. + # aftership_tracking_order_url?: String; + attr_accessor :aftership_tracking_order_url + + # The field contains information about the first leg of the shipping starting from the carrier picking up the shipment from the shipper to the point where they hand it over to the last-mile carrier. Once AfterShip detects the shipment is multi-leg, we will populate the first-mile information under this object. + # first_mile?: FirstMileMarkTrackingCompletedByIdResponse; + attr_accessor :first_mile + + # This field contains information about the last leg of the shipment, starting from the carrier who hands it over to the last-mile carrier, all the way to delivery. Once AfterShip detects that the shipment involves multiple legs and identifies the last-mile carrier, we will populate the last-mile carrier information in this object. Alternatively, the user can provide this information in this field to specify the last-mile carrier, which is helpful if AfterShip is unable to detect it automatically. + # last_mile?: LastMileMarkTrackingCompletedByIdResponse; + attr_accessor :last_mile + + # The field contains the customer information associated with the tracking. A maximum of three customer objects are allowed. + # customers?: CustomersMarkTrackingCompletedByIdResponse[]; + attr_accessor :customers + + # 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::MarkTrackingCompletedByIdResponse` 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?(:'legacy_id') + self.legacy_id = attributes[:'legacy_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?(:'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?(:'transit_time') + self.transit_time = attributes[:'transit_time'] + end + + if attributes.key?(:'origin_country_region') + self.origin_country_region = attributes[:'origin_country_region'] + 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_region') + self.destination_country_region = attributes[:'destination_country_region'] + 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_region') + self.courier_destination_country_region = attributes[:'courier_destination_country_region'] + end + + if attributes.key?(:'courier_estimated_delivery_date') + self.courier_estimated_delivery_date = attributes[:'courier_estimated_delivery_date'] + 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?(:'signed_by') + self.signed_by = attributes[:'signed_by'] + 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?(:'tracking_origin_country_region') + self.tracking_origin_country_region = attributes[:'tracking_origin_country_region'] + end + + if attributes.key?(:'tracking_destination_country_region') + self.tracking_destination_country_region = attributes[:'tracking_destination_country_region'] + 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 + + if attributes.key?(:'delivery_location_type') + self.delivery_location_type = attributes[:'delivery_location_type'] + end + + if attributes.key?(:'aftership_tracking_url') + self.aftership_tracking_url = attributes[:'aftership_tracking_url'] + end + + if attributes.key?(:'aftership_tracking_order_url') + self.aftership_tracking_order_url = attributes[:'aftership_tracking_order_url'] + end + + if attributes.key?(:'first_mile') + self.first_mile = attributes[:'first_mile'] + end + + if attributes.key?(:'last_mile') + self.last_mile = attributes[:'last_mile'] + end + + if attributes.key?(:'customers') + self.customers = attributes[:'customers'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'legacy_id' => :'String', + :'created_at' => :'String', + :'updated_at' => :'String', + :'tracking_number' => :'String', + :'slug' => :'String', + :'active' => :'Boolean', + :'custom_fields' => :'Object', + :'transit_time' => :'Integer', + :'origin_country_region' => :'String', + :'origin_state' => :'String', + :'origin_city' => :'String', + :'origin_postal_code' => :'String', + :'origin_raw_location' => :'String', + :'destination_country_region' => :'String', + :'destination_state' => :'String', + :'destination_city' => :'String', + :'destination_postal_code' => :'String', + :'destination_raw_location' => :'String', + :'courier_destination_country_region' => :'String', + :'courier_estimated_delivery_date' => :'CourierEstimatedDeliveryDateMarkTrackingCompletedByIdResponse', + :'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' => :'ShipmentWeightMarkTrackingCompletedByIdResponse', + :'signed_by' => :'String', + :'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' => :'AftershipEstimatedDeliveryDateMarkTrackingCompletedByIdResponse', + :'custom_estimated_delivery_date' => :'CustomEstimatedDeliveryDateMarkTrackingCompletedByIdResponse', + :'order_number' => :'String', + :'first_estimated_delivery' => :'FirstEstimatedDeliveryMarkTrackingCompletedByIdResponse', + :'latest_estimated_delivery' => :'LatestEstimatedDeliveryMarkTrackingCompletedByIdResponse', + :'shipment_tags' => :'Array', + :'courier_connection_id' => :'String', + :'tracking_origin_country_region' => :'String', + :'tracking_destination_country_region' => :'String', + :'tracking_postal_code' => :'String', + :'tracking_state' => :'String', + :'carbon_emissions' => :'CarbonEmissionsMarkTrackingCompletedByIdResponse', + :'location_id' => :'String', + :'shipping_method' => :'String', + :'failed_delivery_attempts' => :'Integer', + :'signature_requirement' => :'String', + :'delivery_location_type' => :'String', + :'aftership_tracking_url' => :'String', + :'aftership_tracking_order_url' => :'String', + :'first_mile' => :'FirstMileMarkTrackingCompletedByIdResponse', + :'last_mile' => :'LastMileMarkTrackingCompletedByIdResponse', + :'customers' => :'Array', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'legacy_id' => :'legacy_id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'tracking_number' => :'tracking_number', + :'slug' => :'slug', + :'active' => :'active', + :'custom_fields' => :'custom_fields', + :'transit_time' => :'transit_time', + :'origin_country_region' => :'origin_country_region', + :'origin_state' => :'origin_state', + :'origin_city' => :'origin_city', + :'origin_postal_code' => :'origin_postal_code', + :'origin_raw_location' => :'origin_raw_location', + :'destination_country_region' => :'destination_country_region', + :'destination_state' => :'destination_state', + :'destination_city' => :'destination_city', + :'destination_postal_code' => :'destination_postal_code', + :'destination_raw_location' => :'destination_raw_location', + :'courier_destination_country_region' => :'courier_destination_country_region', + :'courier_estimated_delivery_date' => :'courier_estimated_delivery_date', + :'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', + :'signed_by' => :'signed_by', + :'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', + :'tracking_origin_country_region' => :'tracking_origin_country_region', + :'tracking_destination_country_region' => :'tracking_destination_country_region', + :'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', + :'delivery_location_type' => :'delivery_location_type', + :'aftership_tracking_url' => :'aftership_tracking_url', + :'aftership_tracking_order_url' => :'aftership_tracking_order_url', + :'first_mile' => :'first_mile', + :'last_mile' => :'last_mile', + :'customers' => :'customers', + } + 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..00e1d92 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/meta_v1.rb @@ -0,0 +1,173 @@ +# 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/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..bb09e15 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/order_processing_time_estimated_pickup_estimated_delivery_date_request.rb @@ -0,0 +1,163 @@ +# 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..dc4f18f --- /dev/null +++ b/lib/aftership-tracking-sdk/models/order_processing_time_estimated_pickup_estimated_delivery_date_response.rb @@ -0,0 +1,163 @@ +# 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/order_processing_time_estimated_pickup_predict_request.rb b/lib/aftership-tracking-sdk/models/order_processing_time_estimated_pickup_predict_request.rb new file mode 100644 index 0000000..bd9f92a --- /dev/null +++ b/lib/aftership-tracking-sdk/models/order_processing_time_estimated_pickup_predict_request.rb @@ -0,0 +1,163 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class OrderProcessingTimeEstimatedPickupPredictRequest + + # 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::OrderProcessingTimeEstimatedPickupPredictRequest` 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_predict_response.rb b/lib/aftership-tracking-sdk/models/order_processing_time_estimated_pickup_predict_response.rb new file mode 100644 index 0000000..0a9c926 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/order_processing_time_estimated_pickup_predict_response.rb @@ -0,0 +1,163 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class OrderProcessingTimeEstimatedPickupPredictResponse + + # 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::OrderProcessingTimeEstimatedPickupPredictResponse` 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..abccfd2 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/origin_address_estimated_delivery_date_request.rb @@ -0,0 +1,193 @@ +# 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_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?: 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_region') + self.country_region = attributes[:'country_region'] + 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_region' => :'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_region' => :'country_region', + :'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..3603c78 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/origin_address_estimated_delivery_date_response.rb @@ -0,0 +1,193 @@ +# 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_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?: 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_region') + self.country_region = attributes[:'country_region'] + 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_region' => :'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_region' => :'country_region', + :'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_predict_request.rb b/lib/aftership-tracking-sdk/models/origin_address_predict_request.rb new file mode 100644 index 0000000..4c84e2d --- /dev/null +++ b/lib/aftership-tracking-sdk/models/origin_address_predict_request.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class OriginAddressPredictRequest + + # 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_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?: 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::OriginAddressPredictRequest` initialize method" + end + + attributes = attributes.each_with_object({}) { |(k, v), h| + h[k.to_sym] = v + } + + if attributes.key?(:'country_region') + self.country_region = attributes[:'country_region'] + 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_region' => :'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_region' => :'country_region', + :'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_predict_response.rb b/lib/aftership-tracking-sdk/models/origin_address_predict_response.rb new file mode 100644 index 0000000..3f40055 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/origin_address_predict_response.rb @@ -0,0 +1,193 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class OriginAddressPredictResponse + + # 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_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?: 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::OriginAddressPredictResponse` initialize method" + end + + attributes = attributes.each_with_object({}) { |(k, v), h| + h[k.to_sym] = v + } + + if attributes.key?(:'country_region') + self.country_region = attributes[:'country_region'] + 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_region' => :'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_region' => :'country_region', + :'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..e37ea0c --- /dev/null +++ b/lib/aftership-tracking-sdk/models/pagination.rb @@ -0,0 +1,164 @@ +# 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, :next_cursor + # 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 + + if attributes.key?(:'next_cursor') + self.next_cursor = attributes[:'next_cursor'] + end + + end + + # Attribute type mapping. + def self.openapi_types + { + :'total' => :'Integer', + :'page' => :'Integer', + :'limit' => :'Integer', + :'has_next_page' => :'Boolean', + :'next_cursor' => :'String' + } + 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/pagination_data_tracking_response_get_multiple_v1.rb b/lib/aftership-tracking-sdk/models/pagination_data_tracking_response_get_multiple_v1.rb new file mode 100644 index 0000000..23fc5b2 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/pagination_data_tracking_response_get_multiple_v1.rb @@ -0,0 +1,173 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class PaginationDataTrackingResponseGetMultipleV1 + + # The total number of trackings. + # total?: Integer; + attr_accessor :total + + # A string representing the cursor value for the next page of results. + # next_cursor?: String; + attr_accessor :next_cursor + + # To indicate if next page is available. + # has_next_page?: Boolean; + attr_accessor :has_next_page + + # 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::PaginationDataTrackingResponseGetMultipleV1` 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?(:'next_cursor') + self.next_cursor = attributes[:'next_cursor'] + 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', + :'next_cursor' => :'String', + :'has_next_page' => :'Boolean', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'total' => :'total', + :'next_cursor' => :'next_cursor', + :'has_next_page' => :'has_next_page', + } + 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_get_trackings_response.rb b/lib/aftership-tracking-sdk/models/pagination_get_trackings_response.rb new file mode 100644 index 0000000..bdd2d8d --- /dev/null +++ b/lib/aftership-tracking-sdk/models/pagination_get_trackings_response.rb @@ -0,0 +1,173 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class PaginationGetTrackingsResponse + + # The total number of trackings. + # total?: Integer; + attr_accessor :total + + # A string representing the cursor value for the next page of results. + # next_cursor?: String; + attr_accessor :next_cursor + + # To indicate if next page is available. + # has_next_page?: Boolean; + attr_accessor :has_next_page + + # 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::PaginationGetTrackingsResponse` 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?(:'next_cursor') + self.next_cursor = attributes[:'next_cursor'] + 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', + :'next_cursor' => :'String', + :'has_next_page' => :'Boolean', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'total' => :'total', + :'next_cursor' => :'next_cursor', + :'has_next_page' => :'has_next_page', + } + 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..994a30f --- /dev/null +++ b/lib/aftership-tracking-sdk/models/predict_batch_request.rb @@ -0,0 +1,153 @@ +# 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..d648d90 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/predict_batch_response.rb @@ -0,0 +1,153 @@ +# 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/predict_request.rb b/lib/aftership-tracking-sdk/models/predict_request.rb new file mode 100644 index 0000000..b40856e --- /dev/null +++ b/lib/aftership-tracking-sdk/models/predict_request.rb @@ -0,0 +1,223 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class PredictRequest + + # 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: OriginAddressPredictRequest; + attr_accessor :origin_address + + # The final destination of the customer where the delivery will be made. + # destination_address: DestinationAddressPredictRequest; + attr_accessor :destination_address + + # AfterShip uses this object to calculate the total weight of the order. + # weight?: WeightPredictRequest; + 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?: EstimatedPickupPredictRequest; + 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::PredictRequest` 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' => :'OriginAddressPredictRequest', + :'destination_address' => :'DestinationAddressPredictRequest', + :'weight' => :'WeightPredictRequest', + :'package_count' => :'Integer', + :'pickup_time' => :'String', + :'estimated_pickup' => :'EstimatedPickupPredictRequest', + } + 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/predict_response.rb b/lib/aftership-tracking-sdk/models/predict_response.rb new file mode 100644 index 0000000..c2ec094 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/predict_response.rb @@ -0,0 +1,273 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class PredictResponse + + # A string that acts as a unique identifier for the estimated delivery date value generated by AfterShip Predict API + # id: String; + attr_accessor :id + + # 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: OriginAddressPredictResponse; + attr_accessor :origin_address + + # The final destination of the customer where the delivery will be made. + # destination_address: DestinationAddressPredictResponse; + attr_accessor :destination_address + + # AfterShip uses this object to calculate the total weight of the order. + # weight?: WeightPredictResponse; + 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?: EstimatedPickupPredictResponse; + 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::PredictResponse` 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?(:'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 + { + :'id' => :'String', + :'slug' => :'String', + :'service_type_name' => :'String', + :'origin_address' => :'OriginAddressPredictResponse', + :'destination_address' => :'DestinationAddressPredictResponse', + :'weight' => :'WeightPredictResponse', + :'package_count' => :'Integer', + :'pickup_time' => :'String', + :'estimated_pickup' => :'EstimatedPickupPredictResponse', + :'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 + { + :'id' => :'id', + :'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/reason_events_checkpoint.rb b/lib/aftership-tracking-sdk/models/reason_events_checkpoint.rb new file mode 100644 index 0000000..ce0810d --- /dev/null +++ b/lib/aftership-tracking-sdk/models/reason_events_checkpoint.rb @@ -0,0 +1,153 @@ +# 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/retrack_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/retrack_tracking_by_id_response.rb new file mode 100644 index 0000000..75c6152 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/retrack_tracking_by_id_response.rb @@ -0,0 +1,933 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class RetrackTrackingByIdResponse + + # Tracking ID. + # id?: String; + attr_accessor :id + + # The length of the tracking ID has been increased from 24 characters to 32 characters. We will use the legacy_id field to store the original 24-character tracking ID to maintain compatibility with existing data. Therefore, all tracking endpoints will continue to work with the legacy_id field as before. + # legacy_id?: String; + attr_accessor :legacy_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 + + # 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 + + # 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_region?: String; + attr_accessor :origin_country_region + + # 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_region?: String; + attr_accessor :destination_country_region + + # 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_region?: String; + attr_accessor :courier_destination_country_region + + # The field contains the estimated delivery date provided by the carrier. + # courier_estimated_delivery_date?: CourierEstimatedDeliveryDateRetrackTrackingByIdResponse; + attr_accessor :courier_estimated_delivery_date + + # 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 + + # The shipment_weight field represents the total weight of the shipment. In scenarios where the carrier does not provide this information, you can provide the weight to AfterShip. We will prioritize the data provided by the carrier, if available. The shipment weight will be included in the Response and accessed through the GET API, Webhook, and CSV export. It will also be displayed on the AfterShip Tracking admin. Additionally, it plays a significant role in error-free shipment handling and carbon emission calculations, ensuring accurate and informed decision-making + # shipment_weight?: ShipmentWeightRetrackTrackingByIdResponse; + attr_accessor :shipment_weight + + # Signed by information for delivered shipment. + # signed_by?: String; + attr_accessor :signed_by + + # 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. + # subscribed_smses?: String[]; + attr_accessor :subscribed_smses + + # Email address(es) subscribed to receive email notifications. + # 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 formats:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # 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 + + # The date and time when the shipment is shipped by the merchant and ready for pickup by the carrier. The field supports the following formats:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZThe field serves two key purposes:- Calculate processing time metrics in the Order-to-delivery Analytics dashboard. To ensure accurate analytics, it's recommended to include timezone information when configuring this value- Required by certain carriers to retrieve tracking information as an additional tracking field. + # 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?: AftershipEstimatedDeliveryDateRetrackTrackingByIdResponse; + 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?: CustomEstimatedDeliveryDateRetrackTrackingByIdResponse; + 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?: FirstEstimatedDeliveryRetrackTrackingByIdResponse; + 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?: LatestEstimatedDeliveryRetrackTrackingByIdResponse; + 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 + + # (Legacy) Replaced by `origin_country_region`. 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_region?: String; + attr_accessor :tracking_origin_country_region + + # (Legacy) Replaced by `destination_country_region`. 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_region?: String; + attr_accessor :tracking_destination_country_region + + # (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?: CarbonEmissionsRetrackTrackingByIdResponse; + 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 + + # The delivery location type represents the secure area where the carrier leaves the package, such as a safe place, locker, mailbox, front porch, etc. This information helps ensure the shipment reaches the intended recipient efficiently, minimizing the risk of theft or damage. + # delivery_location_type?: String; + attr_accessor :delivery_location_type + + # The tracking URL directs your customers to the shipment tracking page which can display either the default or a customized page based on segmentation rules.- The universal URL is used by default, but you can opt for a custom domain if you have one. Learn how to set up a custom domain .The field is not automatically enabled in API & Webhook. Please contact support if you’d like to enable it. + # aftership_tracking_url?: String; + attr_accessor :aftership_tracking_url + + # The order URL directs your customers to the order tracking page, which includes all shipments. It can display either the default or a customized page based on segmentation rules.- The universal URL is used by default, but you can opt for a custom domain if you have one. Learn how to set up a custom domain .The field is not automatically enabled in API & Webhook. Please contact support if you’d like to enable it. + # aftership_tracking_order_url?: String; + attr_accessor :aftership_tracking_order_url + + # The field contains information about the first leg of the shipping starting from the carrier picking up the shipment from the shipper to the point where they hand it over to the last-mile carrier. Once AfterShip detects the shipment is multi-leg, we will populate the first-mile information under this object. + # first_mile?: FirstMileRetrackTrackingByIdResponse; + attr_accessor :first_mile + + # This field contains information about the last leg of the shipment, starting from the carrier who hands it over to the last-mile carrier, all the way to delivery. Once AfterShip detects that the shipment involves multiple legs and identifies the last-mile carrier, we will populate the last-mile carrier information in this object. Alternatively, the user can provide this information in this field to specify the last-mile carrier, which is helpful if AfterShip is unable to detect it automatically. + # last_mile?: LastMileRetrackTrackingByIdResponse; + attr_accessor :last_mile + + # The field contains the customer information associated with the tracking. A maximum of three customer objects are allowed. + # customers?: CustomersRetrackTrackingByIdResponse[]; + attr_accessor :customers + + # 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::RetrackTrackingByIdResponse` 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?(:'legacy_id') + self.legacy_id = attributes[:'legacy_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?(:'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?(:'transit_time') + self.transit_time = attributes[:'transit_time'] + end + + if attributes.key?(:'origin_country_region') + self.origin_country_region = attributes[:'origin_country_region'] + 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_region') + self.destination_country_region = attributes[:'destination_country_region'] + 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_region') + self.courier_destination_country_region = attributes[:'courier_destination_country_region'] + end + + if attributes.key?(:'courier_estimated_delivery_date') + self.courier_estimated_delivery_date = attributes[:'courier_estimated_delivery_date'] + 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?(:'signed_by') + self.signed_by = attributes[:'signed_by'] + 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?(:'tracking_origin_country_region') + self.tracking_origin_country_region = attributes[:'tracking_origin_country_region'] + end + + if attributes.key?(:'tracking_destination_country_region') + self.tracking_destination_country_region = attributes[:'tracking_destination_country_region'] + 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 + + if attributes.key?(:'delivery_location_type') + self.delivery_location_type = attributes[:'delivery_location_type'] + end + + if attributes.key?(:'aftership_tracking_url') + self.aftership_tracking_url = attributes[:'aftership_tracking_url'] + end + + if attributes.key?(:'aftership_tracking_order_url') + self.aftership_tracking_order_url = attributes[:'aftership_tracking_order_url'] + end + + if attributes.key?(:'first_mile') + self.first_mile = attributes[:'first_mile'] + end + + if attributes.key?(:'last_mile') + self.last_mile = attributes[:'last_mile'] + end + + if attributes.key?(:'customers') + self.customers = attributes[:'customers'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'legacy_id' => :'String', + :'created_at' => :'String', + :'updated_at' => :'String', + :'tracking_number' => :'String', + :'slug' => :'String', + :'active' => :'Boolean', + :'custom_fields' => :'Object', + :'transit_time' => :'Integer', + :'origin_country_region' => :'String', + :'origin_state' => :'String', + :'origin_city' => :'String', + :'origin_postal_code' => :'String', + :'origin_raw_location' => :'String', + :'destination_country_region' => :'String', + :'destination_state' => :'String', + :'destination_city' => :'String', + :'destination_postal_code' => :'String', + :'destination_raw_location' => :'String', + :'courier_destination_country_region' => :'String', + :'courier_estimated_delivery_date' => :'CourierEstimatedDeliveryDateRetrackTrackingByIdResponse', + :'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' => :'ShipmentWeightRetrackTrackingByIdResponse', + :'signed_by' => :'String', + :'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' => :'AftershipEstimatedDeliveryDateRetrackTrackingByIdResponse', + :'custom_estimated_delivery_date' => :'CustomEstimatedDeliveryDateRetrackTrackingByIdResponse', + :'order_number' => :'String', + :'first_estimated_delivery' => :'FirstEstimatedDeliveryRetrackTrackingByIdResponse', + :'latest_estimated_delivery' => :'LatestEstimatedDeliveryRetrackTrackingByIdResponse', + :'shipment_tags' => :'Array', + :'courier_connection_id' => :'String', + :'tracking_origin_country_region' => :'String', + :'tracking_destination_country_region' => :'String', + :'tracking_postal_code' => :'String', + :'tracking_state' => :'String', + :'carbon_emissions' => :'CarbonEmissionsRetrackTrackingByIdResponse', + :'location_id' => :'String', + :'shipping_method' => :'String', + :'failed_delivery_attempts' => :'Integer', + :'signature_requirement' => :'String', + :'delivery_location_type' => :'String', + :'aftership_tracking_url' => :'String', + :'aftership_tracking_order_url' => :'String', + :'first_mile' => :'FirstMileRetrackTrackingByIdResponse', + :'last_mile' => :'LastMileRetrackTrackingByIdResponse', + :'customers' => :'Array', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'legacy_id' => :'legacy_id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'tracking_number' => :'tracking_number', + :'slug' => :'slug', + :'active' => :'active', + :'custom_fields' => :'custom_fields', + :'transit_time' => :'transit_time', + :'origin_country_region' => :'origin_country_region', + :'origin_state' => :'origin_state', + :'origin_city' => :'origin_city', + :'origin_postal_code' => :'origin_postal_code', + :'origin_raw_location' => :'origin_raw_location', + :'destination_country_region' => :'destination_country_region', + :'destination_state' => :'destination_state', + :'destination_city' => :'destination_city', + :'destination_postal_code' => :'destination_postal_code', + :'destination_raw_location' => :'destination_raw_location', + :'courier_destination_country_region' => :'courier_destination_country_region', + :'courier_estimated_delivery_date' => :'courier_estimated_delivery_date', + :'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', + :'signed_by' => :'signed_by', + :'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', + :'tracking_origin_country_region' => :'tracking_origin_country_region', + :'tracking_destination_country_region' => :'tracking_destination_country_region', + :'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', + :'delivery_location_type' => :'delivery_location_type', + :'aftership_tracking_url' => :'aftership_tracking_url', + :'aftership_tracking_order_url' => :'aftership_tracking_order_url', + :'first_mile' => :'first_mile', + :'last_mile' => :'last_mile', + :'customers' => :'customers', + } + 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/shipment_weight_create_tracking_response.rb b/lib/aftership-tracking-sdk/models/shipment_weight_create_tracking_response.rb new file mode 100644 index 0000000..f838f3e --- /dev/null +++ b/lib/aftership-tracking-sdk/models/shipment_weight_create_tracking_response.rb @@ -0,0 +1,163 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class ShipmentWeightCreateTrackingResponse + + # The unit in which the value field is expressed. + # unit?: String; + attr_accessor :unit + + # The total amount of shipment weight. + # 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::ShipmentWeightCreateTrackingResponse` 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/shipment_weight_delete_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/shipment_weight_delete_tracking_by_id_response.rb new file mode 100644 index 0000000..46de57f --- /dev/null +++ b/lib/aftership-tracking-sdk/models/shipment_weight_delete_tracking_by_id_response.rb @@ -0,0 +1,163 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class ShipmentWeightDeleteTrackingByIdResponse + + # The unit in which the value field is expressed. + # unit?: String; + attr_accessor :unit + + # The total amount of shipment weight. + # 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::ShipmentWeightDeleteTrackingByIdResponse` 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/shipment_weight_get_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/shipment_weight_get_tracking_by_id_response.rb new file mode 100644 index 0000000..f6bbfb3 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/shipment_weight_get_tracking_by_id_response.rb @@ -0,0 +1,163 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class ShipmentWeightGetTrackingByIdResponse + + # The unit in which the value field is expressed. + # unit?: String; + attr_accessor :unit + + # The total amount of shipment weight. + # 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::ShipmentWeightGetTrackingByIdResponse` 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/shipment_weight_mark_tracking_completed_by_id_response.rb b/lib/aftership-tracking-sdk/models/shipment_weight_mark_tracking_completed_by_id_response.rb new file mode 100644 index 0000000..c98c0c7 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/shipment_weight_mark_tracking_completed_by_id_response.rb @@ -0,0 +1,163 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class ShipmentWeightMarkTrackingCompletedByIdResponse + + # The unit in which the value field is expressed. + # unit?: String; + attr_accessor :unit + + # The total amount of shipment weight. + # 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::ShipmentWeightMarkTrackingCompletedByIdResponse` 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/shipment_weight_retrack_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/shipment_weight_retrack_tracking_by_id_response.rb new file mode 100644 index 0000000..3ef6f67 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/shipment_weight_retrack_tracking_by_id_response.rb @@ -0,0 +1,163 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class ShipmentWeightRetrackTrackingByIdResponse + + # The unit in which the value field is expressed. + # unit?: String; + attr_accessor :unit + + # The total amount of shipment weight. + # 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::ShipmentWeightRetrackTrackingByIdResponse` 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/shipment_weight_tracking.rb b/lib/aftership-tracking-sdk/models/shipment_weight_tracking.rb new file mode 100644 index 0000000..9443b18 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/shipment_weight_tracking.rb @@ -0,0 +1,163 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class ShipmentWeightTracking + + # The unit in which the value field is expressed. + # unit?: String; + attr_accessor :unit + + # The total amount of shipment weight. + # 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::ShipmentWeightTracking` 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/shipment_weight_update_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/shipment_weight_update_tracking_by_id_response.rb new file mode 100644 index 0000000..763d4ef --- /dev/null +++ b/lib/aftership-tracking-sdk/models/shipment_weight_update_tracking_by_id_response.rb @@ -0,0 +1,163 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class ShipmentWeightUpdateTrackingByIdResponse + + # The unit in which the value field is expressed. + # unit?: String; + attr_accessor :unit + + # The total amount of shipment weight. + # 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::ShipmentWeightUpdateTrackingByIdResponse` 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/slug_group_v1.rb b/lib/aftership-tracking-sdk/models/slug_group_v1.rb new file mode 100644 index 0000000..6f6b3ef --- /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..7120446 --- /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..94edbca --- /dev/null +++ b/lib/aftership-tracking-sdk/models/tracking.rb @@ -0,0 +1,933 @@ +# 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 length of the tracking ID has been increased from 24 characters to 32 characters. We will use the legacy_id field to store the original 24-character tracking ID to maintain compatibility with existing data. Therefore, all tracking endpoints will continue to work with the legacy_id field as before. + # legacy_id?: String; + attr_accessor :legacy_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 + + # 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 + + # 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_region?: String; + attr_accessor :origin_country_region + + # 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_region?: String; + attr_accessor :destination_country_region + + # 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_region?: String; + attr_accessor :courier_destination_country_region + + # The field contains the estimated delivery date provided by the carrier. + # courier_estimated_delivery_date?: CourierEstimatedDeliveryDateTracking; + attr_accessor :courier_estimated_delivery_date + + # 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 + + # The shipment_weight field represents the total weight of the shipment. In scenarios where the carrier does not provide this information, you can provide the weight to AfterShip. We will prioritize the data provided by the carrier, if available. The shipment weight will be included in the Response and accessed through the GET API, Webhook, and CSV export. It will also be displayed on the AfterShip Tracking admin. Additionally, it plays a significant role in error-free shipment handling and carbon emission calculations, ensuring accurate and informed decision-making + # shipment_weight?: ShipmentWeightTracking; + attr_accessor :shipment_weight + + # Signed by information for delivered shipment. + # signed_by?: String; + attr_accessor :signed_by + + # 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. + # subscribed_smses?: String[]; + attr_accessor :subscribed_smses + + # Email address(es) subscribed to receive email notifications. + # 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 formats:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # 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 + + # The date and time when the shipment is shipped by the merchant and ready for pickup by the carrier. The field supports the following formats:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZThe field serves two key purposes:- Calculate processing time metrics in the Order-to-delivery Analytics dashboard. To ensure accurate analytics, it's recommended to include timezone information when configuring this value- Required by certain carriers to retrieve tracking information as an additional tracking field. + # 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 + + # (Legacy) Replaced by `origin_country_region`. 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_region?: String; + attr_accessor :tracking_origin_country_region + + # (Legacy) Replaced by `destination_country_region`. 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_region?: String; + attr_accessor :tracking_destination_country_region + + # (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 + + # The delivery location type represents the secure area where the carrier leaves the package, such as a safe place, locker, mailbox, front porch, etc. This information helps ensure the shipment reaches the intended recipient efficiently, minimizing the risk of theft or damage. + # delivery_location_type?: String; + attr_accessor :delivery_location_type + + # The tracking URL directs your customers to the shipment tracking page which can display either the default or a customized page based on segmentation rules.- The universal URL is used by default, but you can opt for a custom domain if you have one. Learn how to set up a custom domain .The field is not automatically enabled in API & Webhook. Please contact support if you’d like to enable it. + # aftership_tracking_url?: String; + attr_accessor :aftership_tracking_url + + # The order URL directs your customers to the order tracking page, which includes all shipments. It can display either the default or a customized page based on segmentation rules.- The universal URL is used by default, but you can opt for a custom domain if you have one. Learn how to set up a custom domain .The field is not automatically enabled in API & Webhook. Please contact support if you’d like to enable it. + # aftership_tracking_order_url?: String; + attr_accessor :aftership_tracking_order_url + + # The field contains information about the first leg of the shipping starting from the carrier picking up the shipment from the shipper to the point where they hand it over to the last-mile carrier. Once AfterShip detects the shipment is multi-leg, we will populate the first-mile information under this object. + # first_mile?: FirstMileTracking; + attr_accessor :first_mile + + # This field contains information about the last leg of the shipment, starting from the carrier who hands it over to the last-mile carrier, all the way to delivery. Once AfterShip detects that the shipment involves multiple legs and identifies the last-mile carrier, we will populate the last-mile carrier information in this object. Alternatively, the user can provide this information in this field to specify the last-mile carrier, which is helpful if AfterShip is unable to detect it automatically. + # last_mile?: LastMileTracking; + attr_accessor :last_mile + + # The field contains the customer information associated with the tracking. A maximum of three customer objects are allowed. + # customers?: CustomersTracking[]; + attr_accessor :customers + + # 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?(:'legacy_id') + self.legacy_id = attributes[:'legacy_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?(:'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?(:'transit_time') + self.transit_time = attributes[:'transit_time'] + end + + if attributes.key?(:'origin_country_region') + self.origin_country_region = attributes[:'origin_country_region'] + 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_region') + self.destination_country_region = attributes[:'destination_country_region'] + 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_region') + self.courier_destination_country_region = attributes[:'courier_destination_country_region'] + end + + if attributes.key?(:'courier_estimated_delivery_date') + self.courier_estimated_delivery_date = attributes[:'courier_estimated_delivery_date'] + 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?(:'signed_by') + self.signed_by = attributes[:'signed_by'] + 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?(:'tracking_origin_country_region') + self.tracking_origin_country_region = attributes[:'tracking_origin_country_region'] + end + + if attributes.key?(:'tracking_destination_country_region') + self.tracking_destination_country_region = attributes[:'tracking_destination_country_region'] + 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 + + if attributes.key?(:'delivery_location_type') + self.delivery_location_type = attributes[:'delivery_location_type'] + end + + if attributes.key?(:'aftership_tracking_url') + self.aftership_tracking_url = attributes[:'aftership_tracking_url'] + end + + if attributes.key?(:'aftership_tracking_order_url') + self.aftership_tracking_order_url = attributes[:'aftership_tracking_order_url'] + end + + if attributes.key?(:'first_mile') + self.first_mile = attributes[:'first_mile'] + end + + if attributes.key?(:'last_mile') + self.last_mile = attributes[:'last_mile'] + end + + if attributes.key?(:'customers') + self.customers = attributes[:'customers'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'legacy_id' => :'String', + :'created_at' => :'String', + :'updated_at' => :'String', + :'tracking_number' => :'String', + :'slug' => :'String', + :'active' => :'Boolean', + :'custom_fields' => :'Object', + :'transit_time' => :'Integer', + :'origin_country_region' => :'String', + :'origin_state' => :'String', + :'origin_city' => :'String', + :'origin_postal_code' => :'String', + :'origin_raw_location' => :'String', + :'destination_country_region' => :'String', + :'destination_state' => :'String', + :'destination_city' => :'String', + :'destination_postal_code' => :'String', + :'destination_raw_location' => :'String', + :'courier_destination_country_region' => :'String', + :'courier_estimated_delivery_date' => :'CourierEstimatedDeliveryDateTracking', + :'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' => :'ShipmentWeightTracking', + :'signed_by' => :'String', + :'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', + :'tracking_origin_country_region' => :'String', + :'tracking_destination_country_region' => :'String', + :'tracking_postal_code' => :'String', + :'tracking_state' => :'String', + :'carbon_emissions' => :'CarbonEmissionsTracking', + :'location_id' => :'String', + :'shipping_method' => :'String', + :'failed_delivery_attempts' => :'Integer', + :'signature_requirement' => :'String', + :'delivery_location_type' => :'String', + :'aftership_tracking_url' => :'String', + :'aftership_tracking_order_url' => :'String', + :'first_mile' => :'FirstMileTracking', + :'last_mile' => :'LastMileTracking', + :'customers' => :'Array', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'legacy_id' => :'legacy_id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'tracking_number' => :'tracking_number', + :'slug' => :'slug', + :'active' => :'active', + :'custom_fields' => :'custom_fields', + :'transit_time' => :'transit_time', + :'origin_country_region' => :'origin_country_region', + :'origin_state' => :'origin_state', + :'origin_city' => :'origin_city', + :'origin_postal_code' => :'origin_postal_code', + :'origin_raw_location' => :'origin_raw_location', + :'destination_country_region' => :'destination_country_region', + :'destination_state' => :'destination_state', + :'destination_city' => :'destination_city', + :'destination_postal_code' => :'destination_postal_code', + :'destination_raw_location' => :'destination_raw_location', + :'courier_destination_country_region' => :'courier_destination_country_region', + :'courier_estimated_delivery_date' => :'courier_estimated_delivery_date', + :'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', + :'signed_by' => :'signed_by', + :'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', + :'tracking_origin_country_region' => :'tracking_origin_country_region', + :'tracking_destination_country_region' => :'tracking_destination_country_region', + :'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', + :'delivery_location_type' => :'delivery_location_type', + :'aftership_tracking_url' => :'aftership_tracking_url', + :'aftership_tracking_order_url' => :'aftership_tracking_order_url', + :'first_mile' => :'first_mile', + :'last_mile' => :'last_mile', + :'customers' => :'customers', + } + 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..b72714f --- /dev/null +++ b/lib/aftership-tracking-sdk/models/tracking_response_get_multiple_v1.rb @@ -0,0 +1,163 @@ +# 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..85f6911 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/tracking_response_v1.rb @@ -0,0 +1,163 @@ +# 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 + + # Object describes the tracking information.
+ # data: Tracking; + 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' => :'Tracking', + } + 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/update_tracking_by_id_request.rb b/lib/aftership-tracking-sdk/models/update_tracking_by_id_request.rb new file mode 100644 index 0000000..62deef2 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/update_tracking_by_id_request.rb @@ -0,0 +1,483 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class UpdateTrackingByIdRequest + + # 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 + + # 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 formats:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # 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 + + # The date and time when the shipment is shipped by the merchant and ready for pickup by the carrier. The field supports the following formats:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZThe field serves two key purposes:- Calculate processing time metrics in the Order-to-delivery Analytics dashboard. To ensure accurate analytics, it's recommended to include timezone information when configuring this value- Required by certain carriers to retrieve tracking information as an additional tracking field. + # 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_region?: String; + attr_accessor :origin_country_region + + # 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_region?: String; + attr_accessor :destination_country_region + + # 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_region`. 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_region?: String; + attr_accessor :tracking_origin_country_region + + # (Legacy) Replaced by `destination_country_region`. 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_region?: String; + attr_accessor :tracking_destination_country_region + + # (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 + + # The field contains the customer information associated with the tracking. A maximum of three customer objects are allowed. + # customers?: CustomersUpdateTrackingByIdRequest[]; + attr_accessor :customers + + # 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::UpdateTrackingByIdRequest` initialize method" + end + + attributes = attributes.each_with_object({}) { |(k, v), h| + h[k.to_sym] = v + } + + 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?(:'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_region') + self.origin_country_region = attributes[:'origin_country_region'] + 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_region') + self.destination_country_region = attributes[:'destination_country_region'] + 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_region') + self.tracking_origin_country_region = attributes[:'tracking_origin_country_region'] + end + + if attributes.key?(:'tracking_destination_country_region') + self.tracking_destination_country_region = attributes[:'tracking_destination_country_region'] + 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 + + if attributes.key?(:'customers') + self.customers = attributes[:'customers'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'title' => :'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_region' => :'String', + :'origin_state' => :'String', + :'origin_city' => :'String', + :'origin_postal_code' => :'String', + :'origin_raw_location' => :'String', + :'destination_country_region' => :'String', + :'destination_state' => :'String', + :'destination_city' => :'String', + :'destination_postal_code' => :'String', + :'destination_raw_location' => :'String', + :'tracking_origin_country_region' => :'String', + :'tracking_destination_country_region' => :'String', + :'tracking_postal_code' => :'String', + :'tracking_state' => :'String', + :'location_id' => :'String', + :'shipping_method' => :'String', + :'customers' => :'Array', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'title' => :'title', + :'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_region' => :'origin_country_region', + :'origin_state' => :'origin_state', + :'origin_city' => :'origin_city', + :'origin_postal_code' => :'origin_postal_code', + :'origin_raw_location' => :'origin_raw_location', + :'destination_country_region' => :'destination_country_region', + :'destination_state' => :'destination_state', + :'destination_city' => :'destination_city', + :'destination_postal_code' => :'destination_postal_code', + :'destination_raw_location' => :'destination_raw_location', + :'tracking_origin_country_region' => :'tracking_origin_country_region', + :'tracking_destination_country_region' => :'tracking_destination_country_region', + :'tracking_postal_code' => :'tracking_postal_code', + :'tracking_state' => :'tracking_state', + :'location_id' => :'location_id', + :'shipping_method' => :'shipping_method', + :'customers' => :'customers', + } + 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/update_tracking_by_id_response.rb b/lib/aftership-tracking-sdk/models/update_tracking_by_id_response.rb new file mode 100644 index 0000000..ff4e566 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/update_tracking_by_id_response.rb @@ -0,0 +1,933 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class UpdateTrackingByIdResponse + + # Tracking ID. + # id?: String; + attr_accessor :id + + # The length of the tracking ID has been increased from 24 characters to 32 characters. We will use the legacy_id field to store the original 24-character tracking ID to maintain compatibility with existing data. Therefore, all tracking endpoints will continue to work with the legacy_id field as before. + # legacy_id?: String; + attr_accessor :legacy_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 + + # 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 + + # 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_region?: String; + attr_accessor :origin_country_region + + # 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_region?: String; + attr_accessor :destination_country_region + + # 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_region?: String; + attr_accessor :courier_destination_country_region + + # The field contains the estimated delivery date provided by the carrier. + # courier_estimated_delivery_date?: CourierEstimatedDeliveryDateUpdateTrackingByIdResponse; + attr_accessor :courier_estimated_delivery_date + + # 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 + + # The shipment_weight field represents the total weight of the shipment. In scenarios where the carrier does not provide this information, you can provide the weight to AfterShip. We will prioritize the data provided by the carrier, if available. The shipment weight will be included in the Response and accessed through the GET API, Webhook, and CSV export. It will also be displayed on the AfterShip Tracking admin. Additionally, it plays a significant role in error-free shipment handling and carbon emission calculations, ensuring accurate and informed decision-making + # shipment_weight?: ShipmentWeightUpdateTrackingByIdResponse; + attr_accessor :shipment_weight + + # Signed by information for delivered shipment. + # signed_by?: String; + attr_accessor :signed_by + + # 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. + # subscribed_smses?: String[]; + attr_accessor :subscribed_smses + + # Email address(es) subscribed to receive email notifications. + # 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 formats:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZ + # 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 + + # The date and time when the shipment is shipped by the merchant and ready for pickup by the carrier. The field supports the following formats:- YYYY-MM-DD- YYYY-MM-DDTHH:mm:ss- YYYY-MM-DDTHH:mm:ssZThe field serves two key purposes:- Calculate processing time metrics in the Order-to-delivery Analytics dashboard. To ensure accurate analytics, it's recommended to include timezone information when configuring this value- Required by certain carriers to retrieve tracking information as an additional tracking field. + # 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?: AftershipEstimatedDeliveryDateUpdateTrackingByIdResponse; + 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?: CustomEstimatedDeliveryDateUpdateTrackingByIdResponse; + 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?: FirstEstimatedDeliveryUpdateTrackingByIdResponse; + 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?: LatestEstimatedDeliveryUpdateTrackingByIdResponse; + 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 + + # (Legacy) Replaced by `origin_country_region`. 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_region?: String; + attr_accessor :tracking_origin_country_region + + # (Legacy) Replaced by `destination_country_region`. 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_region?: String; + attr_accessor :tracking_destination_country_region + + # (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?: CarbonEmissionsUpdateTrackingByIdResponse; + 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 + + # The delivery location type represents the secure area where the carrier leaves the package, such as a safe place, locker, mailbox, front porch, etc. This information helps ensure the shipment reaches the intended recipient efficiently, minimizing the risk of theft or damage. + # delivery_location_type?: String; + attr_accessor :delivery_location_type + + # The tracking URL directs your customers to the shipment tracking page which can display either the default or a customized page based on segmentation rules.- The universal URL is used by default, but you can opt for a custom domain if you have one. Learn how to set up a custom domain .The field is not automatically enabled in API & Webhook. Please contact support if you’d like to enable it. + # aftership_tracking_url?: String; + attr_accessor :aftership_tracking_url + + # The order URL directs your customers to the order tracking page, which includes all shipments. It can display either the default or a customized page based on segmentation rules.- The universal URL is used by default, but you can opt for a custom domain if you have one. Learn how to set up a custom domain .The field is not automatically enabled in API & Webhook. Please contact support if you’d like to enable it. + # aftership_tracking_order_url?: String; + attr_accessor :aftership_tracking_order_url + + # The field contains information about the first leg of the shipping starting from the carrier picking up the shipment from the shipper to the point where they hand it over to the last-mile carrier. Once AfterShip detects the shipment is multi-leg, we will populate the first-mile information under this object. + # first_mile?: FirstMileUpdateTrackingByIdResponse; + attr_accessor :first_mile + + # This field contains information about the last leg of the shipment, starting from the carrier who hands it over to the last-mile carrier, all the way to delivery. Once AfterShip detects that the shipment involves multiple legs and identifies the last-mile carrier, we will populate the last-mile carrier information in this object. Alternatively, the user can provide this information in this field to specify the last-mile carrier, which is helpful if AfterShip is unable to detect it automatically. + # last_mile?: LastMileUpdateTrackingByIdResponse; + attr_accessor :last_mile + + # The field contains the customer information associated with the tracking. A maximum of three customer objects are allowed. + # customers?: CustomersUpdateTrackingByIdResponse[]; + attr_accessor :customers + + # 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::UpdateTrackingByIdResponse` 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?(:'legacy_id') + self.legacy_id = attributes[:'legacy_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?(:'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?(:'transit_time') + self.transit_time = attributes[:'transit_time'] + end + + if attributes.key?(:'origin_country_region') + self.origin_country_region = attributes[:'origin_country_region'] + 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_region') + self.destination_country_region = attributes[:'destination_country_region'] + 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_region') + self.courier_destination_country_region = attributes[:'courier_destination_country_region'] + end + + if attributes.key?(:'courier_estimated_delivery_date') + self.courier_estimated_delivery_date = attributes[:'courier_estimated_delivery_date'] + 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?(:'signed_by') + self.signed_by = attributes[:'signed_by'] + 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?(:'tracking_origin_country_region') + self.tracking_origin_country_region = attributes[:'tracking_origin_country_region'] + end + + if attributes.key?(:'tracking_destination_country_region') + self.tracking_destination_country_region = attributes[:'tracking_destination_country_region'] + 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 + + if attributes.key?(:'delivery_location_type') + self.delivery_location_type = attributes[:'delivery_location_type'] + end + + if attributes.key?(:'aftership_tracking_url') + self.aftership_tracking_url = attributes[:'aftership_tracking_url'] + end + + if attributes.key?(:'aftership_tracking_order_url') + self.aftership_tracking_order_url = attributes[:'aftership_tracking_order_url'] + end + + if attributes.key?(:'first_mile') + self.first_mile = attributes[:'first_mile'] + end + + if attributes.key?(:'last_mile') + self.last_mile = attributes[:'last_mile'] + end + + if attributes.key?(:'customers') + self.customers = attributes[:'customers'] + end + end + + # Attribute type mapping. + def self.openapi_types + { + :'id' => :'String', + :'legacy_id' => :'String', + :'created_at' => :'String', + :'updated_at' => :'String', + :'tracking_number' => :'String', + :'slug' => :'String', + :'active' => :'Boolean', + :'custom_fields' => :'Object', + :'transit_time' => :'Integer', + :'origin_country_region' => :'String', + :'origin_state' => :'String', + :'origin_city' => :'String', + :'origin_postal_code' => :'String', + :'origin_raw_location' => :'String', + :'destination_country_region' => :'String', + :'destination_state' => :'String', + :'destination_city' => :'String', + :'destination_postal_code' => :'String', + :'destination_raw_location' => :'String', + :'courier_destination_country_region' => :'String', + :'courier_estimated_delivery_date' => :'CourierEstimatedDeliveryDateUpdateTrackingByIdResponse', + :'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' => :'ShipmentWeightUpdateTrackingByIdResponse', + :'signed_by' => :'String', + :'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' => :'AftershipEstimatedDeliveryDateUpdateTrackingByIdResponse', + :'custom_estimated_delivery_date' => :'CustomEstimatedDeliveryDateUpdateTrackingByIdResponse', + :'order_number' => :'String', + :'first_estimated_delivery' => :'FirstEstimatedDeliveryUpdateTrackingByIdResponse', + :'latest_estimated_delivery' => :'LatestEstimatedDeliveryUpdateTrackingByIdResponse', + :'shipment_tags' => :'Array', + :'courier_connection_id' => :'String', + :'tracking_origin_country_region' => :'String', + :'tracking_destination_country_region' => :'String', + :'tracking_postal_code' => :'String', + :'tracking_state' => :'String', + :'carbon_emissions' => :'CarbonEmissionsUpdateTrackingByIdResponse', + :'location_id' => :'String', + :'shipping_method' => :'String', + :'failed_delivery_attempts' => :'Integer', + :'signature_requirement' => :'String', + :'delivery_location_type' => :'String', + :'aftership_tracking_url' => :'String', + :'aftership_tracking_order_url' => :'String', + :'first_mile' => :'FirstMileUpdateTrackingByIdResponse', + :'last_mile' => :'LastMileUpdateTrackingByIdResponse', + :'customers' => :'Array', + } + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'id' => :'id', + :'legacy_id' => :'legacy_id', + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'tracking_number' => :'tracking_number', + :'slug' => :'slug', + :'active' => :'active', + :'custom_fields' => :'custom_fields', + :'transit_time' => :'transit_time', + :'origin_country_region' => :'origin_country_region', + :'origin_state' => :'origin_state', + :'origin_city' => :'origin_city', + :'origin_postal_code' => :'origin_postal_code', + :'origin_raw_location' => :'origin_raw_location', + :'destination_country_region' => :'destination_country_region', + :'destination_state' => :'destination_state', + :'destination_city' => :'destination_city', + :'destination_postal_code' => :'destination_postal_code', + :'destination_raw_location' => :'destination_raw_location', + :'courier_destination_country_region' => :'courier_destination_country_region', + :'courier_estimated_delivery_date' => :'courier_estimated_delivery_date', + :'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', + :'signed_by' => :'signed_by', + :'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', + :'tracking_origin_country_region' => :'tracking_origin_country_region', + :'tracking_destination_country_region' => :'tracking_destination_country_region', + :'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', + :'delivery_location_type' => :'delivery_location_type', + :'aftership_tracking_url' => :'aftership_tracking_url', + :'aftership_tracking_order_url' => :'aftership_tracking_order_url', + :'first_mile' => :'first_mile', + :'last_mile' => :'last_mile', + :'customers' => :'customers', + } + 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..c9db7bc --- /dev/null +++ b/lib/aftership-tracking-sdk/models/weight_estimated_delivery_date_request.rb @@ -0,0 +1,163 @@ +# 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..9e291e6 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/weight_estimated_delivery_date_response.rb @@ -0,0 +1,163 @@ +# 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/models/weight_predict_request.rb b/lib/aftership-tracking-sdk/models/weight_predict_request.rb new file mode 100644 index 0000000..b9efc5a --- /dev/null +++ b/lib/aftership-tracking-sdk/models/weight_predict_request.rb @@ -0,0 +1,163 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class WeightPredictRequest + + # 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::WeightPredictRequest` 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_predict_response.rb b/lib/aftership-tracking-sdk/models/weight_predict_response.rb new file mode 100644 index 0000000..4cac011 --- /dev/null +++ b/lib/aftership-tracking-sdk/models/weight_predict_response.rb @@ -0,0 +1,163 @@ +# This code was auto generated by AfterShip SDK Generator. +# Do not edit the class manually. +module AftershipAPI::Model + class WeightPredictResponse + + # 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::WeightPredictResponse` 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..84863d3 --- /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 = '10.0.0' +end