aftership-tracking-sdk 7.0.0 → 9.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -0
  3. data/README.md +68 -83
  4. data/lib/aftership-tracking-sdk/api/courier.rb +8 -8
  5. data/lib/aftership-tracking-sdk/api/estimated_delivery_date.rb +4 -4
  6. data/lib/aftership-tracking-sdk/api/tracking.rb +50 -416
  7. data/lib/aftership-tracking-sdk/api_client.rb +2 -2
  8. data/lib/aftership-tracking-sdk/configuration.rb +108 -108
  9. data/lib/aftership-tracking-sdk/models/additional_fields_v1.rb +1 -1
  10. data/lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_create_tracking_response.rb +183 -0
  11. data/lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_delete_tracking_by_id_response.rb +183 -0
  12. data/lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_get_tracking_by_id_response.rb +183 -0
  13. data/lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_mark_tracking_completed_by_id_response.rb +183 -0
  14. data/lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_retrack_tracking_by_id_response.rb +183 -0
  15. data/lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_tracking.rb +2 -0
  16. data/lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_update_tracking_by_id_response.rb +183 -0
  17. data/lib/aftership-tracking-sdk/models/carbon_emissions_create_tracking_response.rb +163 -0
  18. data/lib/aftership-tracking-sdk/models/carbon_emissions_delete_tracking_by_id_response.rb +163 -0
  19. data/lib/aftership-tracking-sdk/models/carbon_emissions_get_tracking_by_id_response.rb +163 -0
  20. data/lib/aftership-tracking-sdk/models/carbon_emissions_mark_tracking_completed_by_id_response.rb +163 -0
  21. data/lib/aftership-tracking-sdk/models/carbon_emissions_retrack_tracking_by_id_response.rb +163 -0
  22. data/lib/aftership-tracking-sdk/models/carbon_emissions_tracking.rb +2 -0
  23. data/lib/aftership-tracking-sdk/models/carbon_emissions_update_tracking_by_id_response.rb +163 -0
  24. data/lib/aftership-tracking-sdk/models/checkpoint.rb +2 -0
  25. data/lib/aftership-tracking-sdk/models/coordinate_checkpoint.rb +2 -0
  26. data/lib/aftership-tracking-sdk/models/courier.rb +2 -0
  27. data/lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_create_tracking_response.rb +173 -0
  28. data/lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_delete_tracking_by_id_response.rb +173 -0
  29. data/lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_get_tracking_by_id_response.rb +173 -0
  30. data/lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_mark_tracking_completed_by_id_response.rb +173 -0
  31. data/lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_retrack_tracking_by_id_response.rb +173 -0
  32. data/lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_tracking.rb +173 -0
  33. data/lib/aftership-tracking-sdk/models/courier_estimated_delivery_date_update_tracking_by_id_response.rb +173 -0
  34. data/lib/aftership-tracking-sdk/models/courier_response_v1.rb +2 -0
  35. data/lib/aftership-tracking-sdk/models/{tracking_create_tracking_request.rb → create_tracking_request.rb} +9 -7
  36. data/lib/aftership-tracking-sdk/models/create_tracking_response.rb +953 -0
  37. data/lib/aftership-tracking-sdk/models/{mark_tracking_completed_by_slug_tracking_number_request.rb → custom_estimated_delivery_date_create_tracking_response.rb} +41 -9
  38. data/lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_delete_tracking_by_id_response.rb +183 -0
  39. data/lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_get_tracking_by_id_response.rb +183 -0
  40. data/lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_mark_tracking_completed_by_id_response.rb +183 -0
  41. data/lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_retrack_tracking_by_id_response.rb +183 -0
  42. data/lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_tracking.rb +2 -0
  43. data/lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_update_tracking_by_id_response.rb +183 -0
  44. data/lib/aftership-tracking-sdk/models/data_courier_response_v1.rb +2 -0
  45. data/lib/aftership-tracking-sdk/models/data_tracking_response_get_multiple_v1.rb +8 -126
  46. data/lib/aftership-tracking-sdk/models/delete_tracking_by_id_response.rb +953 -0
  47. data/lib/aftership-tracking-sdk/models/destination_address_estimated_delivery_date_request.rb +2 -0
  48. data/lib/aftership-tracking-sdk/models/destination_address_estimated_delivery_date_response.rb +2 -0
  49. data/lib/aftership-tracking-sdk/models/{tracking_detect_courier_request.rb → detect_courier_request.rb} +5 -3
  50. data/lib/aftership-tracking-sdk/models/detect_courier_response.rb +2 -0
  51. data/lib/aftership-tracking-sdk/models/estimated_delivery_date_request.rb +2 -0
  52. data/lib/aftership-tracking-sdk/models/estimated_delivery_date_response.rb +12 -0
  53. data/lib/aftership-tracking-sdk/models/estimated_pickup_estimated_delivery_date_request.rb +2 -0
  54. data/lib/aftership-tracking-sdk/models/estimated_pickup_estimated_delivery_date_response.rb +2 -0
  55. data/lib/aftership-tracking-sdk/models/events_checkpoint.rb +2 -0
  56. data/lib/aftership-tracking-sdk/models/first_estimated_delivery_create_tracking_response.rb +193 -0
  57. data/lib/aftership-tracking-sdk/models/first_estimated_delivery_delete_tracking_by_id_response.rb +193 -0
  58. data/lib/aftership-tracking-sdk/models/first_estimated_delivery_get_tracking_by_id_response.rb +193 -0
  59. data/lib/aftership-tracking-sdk/models/first_estimated_delivery_mark_tracking_completed_by_id_response.rb +193 -0
  60. data/lib/aftership-tracking-sdk/models/first_estimated_delivery_retrack_tracking_by_id_response.rb +193 -0
  61. data/lib/aftership-tracking-sdk/models/first_estimated_delivery_tracking.rb +2 -0
  62. data/lib/aftership-tracking-sdk/models/first_estimated_delivery_update_tracking_by_id_response.rb +193 -0
  63. data/lib/aftership-tracking-sdk/models/get_all_couriers_response.rb +2 -0
  64. data/lib/aftership-tracking-sdk/models/get_tracking_by_id_response.rb +953 -0
  65. data/lib/aftership-tracking-sdk/models/get_trackings_response.rb +5 -3
  66. data/lib/aftership-tracking-sdk/models/get_user_couriers_response.rb +2 -0
  67. data/lib/aftership-tracking-sdk/models/latest_estimated_delivery_create_tracking_response.rb +193 -0
  68. data/lib/aftership-tracking-sdk/models/latest_estimated_delivery_delete_tracking_by_id_response.rb +193 -0
  69. data/lib/aftership-tracking-sdk/models/latest_estimated_delivery_get_tracking_by_id_response.rb +193 -0
  70. data/lib/aftership-tracking-sdk/models/latest_estimated_delivery_mark_tracking_completed_by_id_response.rb +193 -0
  71. data/lib/aftership-tracking-sdk/models/latest_estimated_delivery_retrack_tracking_by_id_response.rb +193 -0
  72. data/lib/aftership-tracking-sdk/models/latest_estimated_delivery_tracking.rb +2 -0
  73. data/lib/aftership-tracking-sdk/models/latest_estimated_delivery_update_tracking_by_id_response.rb +193 -0
  74. data/lib/aftership-tracking-sdk/models/mark_tracking_completed_by_id_request.rb +2 -0
  75. data/lib/aftership-tracking-sdk/models/mark_tracking_completed_by_id_response.rb +953 -0
  76. data/lib/aftership-tracking-sdk/models/meta_v1.rb +2 -0
  77. data/lib/aftership-tracking-sdk/models/{next_couriers_tracking_create_tracking_request.rb → next_couriers_create_tracking_request.rb} +4 -2
  78. data/lib/aftership-tracking-sdk/models/{get_checkpoint_by_tracking_id_response.rb → next_couriers_create_tracking_response.rb} +33 -51
  79. data/lib/aftership-tracking-sdk/models/next_couriers_delete_tracking_by_id_response.rb +193 -0
  80. data/lib/aftership-tracking-sdk/models/{get_checkpoint_by_slug_tracking_number_response.rb → next_couriers_get_tracking_by_id_response.rb} +33 -51
  81. data/lib/aftership-tracking-sdk/models/next_couriers_mark_tracking_completed_by_id_response.rb +193 -0
  82. data/lib/aftership-tracking-sdk/models/next_couriers_retrack_tracking_by_id_response.rb +193 -0
  83. data/lib/aftership-tracking-sdk/models/next_couriers_tracking.rb +22 -0
  84. data/lib/aftership-tracking-sdk/models/next_couriers_update_tracking_by_id_response.rb +193 -0
  85. data/lib/aftership-tracking-sdk/models/order_processing_time_estimated_pickup_estimated_delivery_date_request.rb +2 -0
  86. data/lib/aftership-tracking-sdk/models/order_processing_time_estimated_pickup_estimated_delivery_date_response.rb +2 -0
  87. data/lib/aftership-tracking-sdk/models/origin_address_estimated_delivery_date_request.rb +2 -0
  88. data/lib/aftership-tracking-sdk/models/origin_address_estimated_delivery_date_response.rb +2 -0
  89. data/lib/aftership-tracking-sdk/models/pagination.rb +14 -6
  90. data/lib/aftership-tracking-sdk/models/pagination_data_tracking_response_get_multiple_v1.rb +173 -0
  91. data/lib/aftership-tracking-sdk/models/{notification_request_v1.rb → pagination_get_trackings_response.rb} +28 -16
  92. data/lib/aftership-tracking-sdk/models/predict_batch_request.rb +2 -0
  93. data/lib/aftership-tracking-sdk/models/predict_batch_response.rb +2 -0
  94. data/lib/aftership-tracking-sdk/models/reason_events_checkpoint.rb +2 -0
  95. data/lib/aftership-tracking-sdk/models/retrack_tracking_by_id_response.rb +953 -0
  96. data/lib/aftership-tracking-sdk/models/{tracking_delete_response_v1.rb → shipment_weight_create_tracking_response.rb} +18 -16
  97. data/lib/aftership-tracking-sdk/models/{data_notification_response_v1.rb → shipment_weight_delete_tracking_by_id_response.rb} +21 -9
  98. data/lib/aftership-tracking-sdk/models/{notification.rb → shipment_weight_get_tracking_by_id_response.rb} +18 -16
  99. data/lib/aftership-tracking-sdk/models/shipment_weight_mark_tracking_completed_by_id_response.rb +163 -0
  100. data/lib/aftership-tracking-sdk/models/shipment_weight_retrack_tracking_by_id_response.rb +163 -0
  101. data/lib/aftership-tracking-sdk/models/{notification_response_v1.rb → shipment_weight_tracking.rb} +18 -16
  102. data/lib/aftership-tracking-sdk/models/shipment_weight_update_tracking_by_id_response.rb +163 -0
  103. data/lib/aftership-tracking-sdk/models/slug_group_v1.rb +1 -1
  104. data/lib/aftership-tracking-sdk/models/tag_v1.rb +1 -1
  105. data/lib/aftership-tracking-sdk/models/tracking.rb +56 -24
  106. data/lib/aftership-tracking-sdk/models/tracking_response_get_multiple_v1.rb +2 -0
  107. data/lib/aftership-tracking-sdk/models/tracking_response_v1.rb +5 -3
  108. data/lib/aftership-tracking-sdk/models/{tracking_update_tracking_by_id_request.rb → update_tracking_by_id_request.rb} +5 -3
  109. data/lib/aftership-tracking-sdk/models/update_tracking_by_id_response.rb +953 -0
  110. data/lib/aftership-tracking-sdk/models/weight_estimated_delivery_date_request.rb +2 -0
  111. data/lib/aftership-tracking-sdk/models/weight_estimated_delivery_date_response.rb +2 -0
  112. data/lib/aftership-tracking-sdk/version.rb +1 -1
  113. metadata +64 -22
  114. data/lib/aftership-tracking-sdk/api/last_checkpoint.rb +0 -143
  115. data/lib/aftership-tracking-sdk/api/notification.rb +0 -403
  116. data/lib/aftership-tracking-sdk/models/custom_fields_tracking_update_tracking_by_slug_tracking_number_request.rb +0 -139
  117. data/lib/aftership-tracking-sdk/models/data_tracking_delete_response_v1.rb +0 -151
  118. data/lib/aftership-tracking-sdk/models/data_tracking_response_v1.rb +0 -151
  119. data/lib/aftership-tracking-sdk/models/partial_delete_tracking.rb +0 -241
  120. data/lib/aftership-tracking-sdk/models/partial_update_tracking.rb +0 -251
  121. data/lib/aftership-tracking-sdk/models/tracking_update_tracking_by_slug_tracking_number_request.rb +0 -391
@@ -44,7 +44,7 @@ module AftershipAPI
44
44
  begin
45
45
  call_api_internal(http_method, path, opts)
46
46
  rescue ApiError => e
47
- if retries > 0 && (e.error_code == AftershipAPI::TIMED_OUT || e.status_code >= 500)
47
+ if retries > 0 && (e.error_code == AftershipAPI::TIMED_OUT || e.status_code >= 500 )
48
48
  retries -= 1
49
49
  delay_with_jitter
50
50
  retry
@@ -109,7 +109,7 @@ module AftershipAPI
109
109
  url = build_request_url(path, opts)
110
110
  http_method = http_method.to_sym.downcase
111
111
 
112
- header_params = @default_headers.merge(opts[:header_params] || {}).merge({ 'as-api-key' => config.as_api_key })
112
+ header_params = @default_headers.merge(opts[:header_params] || {}).merge({'as-api-key' => config.as_api_key})
113
113
  query_params = opts[:query_params] || {}
114
114
  form_params = opts[:form_params] || {}
115
115
  follow_location = opts[:follow_location] || true
@@ -4,119 +4,119 @@ require 'uri'
4
4
  require 'typhoeus'
5
5
 
6
6
  module AftershipAPI
7
- AUTHENTICATION_TYPE_API_KEY = 'API_KEY'
8
- AUTHENTICATION_TYPE_AES = 'AES'
9
- AUTHENTICATION_TYPE_RSA = 'RSA'
10
-
11
- SDK_PREFIX = 'AFTERSHIP_TRACKING_SDK'
12
-
13
-
14
- class Configuration
15
- def get_env(key)
16
- ENV[SDK_PREFIX + '_' + key]
17
- end
18
-
19
- # Defines domain
20
- attr_accessor :domain
21
-
22
- # Defines the authentication type used in the API.
23
- #
24
- # @return ["API_KEY", "AES", "RSA"]
25
- attr_accessor :authentication_type
26
-
27
- # Defines API keys used with API Key authentications.
28
- #
29
- # @return [string]
30
- attr_accessor :as_api_key
31
-
32
- # Defines AES secret or RSA private key used with AES or RSA authentications.
33
- #
34
- # @return [string]
35
- attr_accessor :as_api_secret
36
-
37
- # Defines the user agent used in the API requests.
38
- # Default to 'aftership-sdk-ruby/$VERSION'
39
- #
40
- # @return [string]
41
- attr_accessor :user_agent
42
-
43
- # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
44
- # details will be logged with `logger.debug` (see the `logger` attribute).
45
- # Default to false.
46
- #
47
- # @return [true, false]
48
- attr_accessor :debugging
49
-
50
- # Defines the logger used for debugging.
51
- # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
52
- #
53
- # @return [#debug]
54
- attr_accessor :logger
55
-
56
- # The time limit for HTTP request in seconds.
57
- # Default to 30
58
- attr_accessor :timeout
59
-
60
- # When response is a retryable error, retry current request
61
- # Default to 2
62
- attr_accessor :max_retry
63
-
64
- # HTTP proxy
65
- attr_accessor :proxy
7
+ AUTHENTICATION_TYPE_API_KEY = 'API_KEY'
8
+ AUTHENTICATION_TYPE_AES = 'AES'
9
+ AUTHENTICATION_TYPE_RSA = 'RSA'
10
+
11
+ SDK_PREFIX = 'AFTERSHIP_TRACKING_SDK'
12
+
13
+
14
+ class Configuration
15
+ def get_env(key)
16
+ ENV[SDK_PREFIX + '_' + key]
17
+ end
18
+
19
+ # Defines domain
20
+ attr_accessor :domain
21
+
22
+ # Defines the authentication type used in the API.
23
+ #
24
+ # @return ["API_KEY", "AES", "RSA"]
25
+ attr_accessor :authentication_type
26
+
27
+ # Defines API keys used with API Key authentications.
28
+ #
29
+ # @return [string]
30
+ attr_accessor :as_api_key
31
+
32
+ # Defines AES secret or RSA private key used with AES or RSA authentications.
33
+ #
34
+ # @return [string]
35
+ attr_accessor :as_api_secret
36
+
37
+ # Defines the user agent used in the API requests.
38
+ # Default to 'aftership-sdk-ruby/$VERSION'
39
+ #
40
+ # @return [string]
41
+ attr_accessor :user_agent
42
+
43
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
44
+ # details will be logged with `logger.debug` (see the `logger` attribute).
45
+ # Default to false.
46
+ #
47
+ # @return [true, false]
48
+ attr_accessor :debugging
49
+
50
+ # Defines the logger used for debugging.
51
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
52
+ #
53
+ # @return [#debug]
54
+ attr_accessor :logger
55
+
56
+ # The time limit for HTTP request in seconds.
57
+ # Default to 30
58
+ attr_accessor :timeout
59
+
60
+ # When response is a retryable error, retry current request
61
+ # Default to 2
62
+ attr_accessor :max_retry
63
+
64
+ # HTTP proxy
65
+ attr_accessor :proxy
66
66
 
67
- attr_accessor :aftership_client
67
+ attr_accessor :aftership_client
68
68
 
69
- attr_accessor :headers
69
+ attr_accessor :headers
70
70
 
71
71
 
72
- def initialize
73
- default_user_agent = "aftership-sdk-ruby/#{AftershipAPI::VERSION} (https://www.aftership.com) typhoeus/#{Typhoeus::VERSION}"
72
+ def initialize
73
+ default_user_agent = "aftership-sdk-ruby/#{AftershipAPI::VERSION} (https://www.aftership.com) typhoeus/#{Typhoeus::VERSION}"
74
74
 
75
- @domain = get_env('DOMAIN') || 'https://api.aftership.com'
76
- @authentication_type = get_env('AUTHENTICATION_TYPE') || AUTHENTICATION_TYPE_API_KEY
77
- @as_api_key = get_env('API_KEY') || ''
78
- @as_api_secret = get_env('API_SECRET') || ''
79
- @user_agent = get_env('USER_AGENT') || default_user_agent
80
- @aftership_client = default_user_agent
81
- @timeout = (get_env('TIMEOUT') || 30).to_i
82
- @max_retry = (get_env('MAX_RETRY') || 2).to_i
83
- @proxy = get_env('PROXY')
84
- @debugging = get_env('DEBUGGING') || false
85
- @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
86
- @headers = {}
75
+ @domain = get_env('DOMAIN') || 'https://api.aftership.com'
76
+ @authentication_type = get_env('AUTHENTICATION_TYPE') || AUTHENTICATION_TYPE_API_KEY
77
+ @as_api_key = get_env('API_KEY') || ''
78
+ @as_api_secret = get_env('API_SECRET') || ''
79
+ @user_agent = get_env('USER_AGENT') || default_user_agent
80
+ @aftership_client = default_user_agent
81
+ @timeout = (get_env('TIMEOUT') || 30).to_i
82
+ @max_retry = (get_env('MAX_RETRY') || 2).to_i
83
+ @proxy = get_env('PROXY')
84
+ @debugging = get_env('DEBUGGING') || false
85
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
86
+ @headers = {}
87
87
 
88
- yield(self) if block_given?
89
- end
90
-
91
- # The default Configuration object.
92
- def self.default
93
- @@default ||= Configuration.new
94
- end
95
-
96
- def configure
97
- yield(self) if block_given?
98
- end
99
-
100
- def domain=(domain)
101
- @domain = domain.sub(/\/+\z/, '')
102
- end
103
-
104
- def check
105
- fail InvalidOptionError.new("Invalid authentication type: #{authentication_type}") unless [AUTHENTICATION_TYPE_API_KEY, AUTHENTICATION_TYPE_AES, AUTHENTICATION_TYPE_RSA].include?(authentication_type)
106
- fail InvalidOptionError.new("as_api_key cannot be empty") unless as_api_key.to_s.size > 0
107
- fail InvalidOptionError.new("Invalid base URL: #{domain}") unless valid_url?(domain)
108
- 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
109
- fail InvalidOptionError.new("timeout cannot be negative, value #{timeout}") unless timeout.to_i >= 0
110
- fail InvalidOptionError.new("max_retry must be in range 0..10, value #{max_retry}") unless (max_retry.to_i >= 0) && (max_retry.to_i <= 10)
111
- fail InvalidOptionError.new("max_retry cannot be negative, value #{max_retry}") unless max_retry.to_i >= 0
112
- end
113
-
114
- def valid_url?(url)
115
- uri = URI.parse(url)
116
- uri.is_a?(URI::HTTP) || uri.is_a?(URI::HTTPS)
117
- rescue URI::InvalidURIError
118
- false
119
- end
88
+ yield(self) if block_given?
89
+ end
90
+
91
+ # The default Configuration object.
92
+ def self.default
93
+ @@default ||= Configuration.new
94
+ end
95
+
96
+ def configure
97
+ yield(self) if block_given?
98
+ end
99
+
100
+ def domain=(domain)
101
+ @domain = domain.sub(/\/+\z/, '')
102
+ end
103
+
104
+ def check
105
+ fail InvalidOptionError.new("Invalid authentication type: #{authentication_type}") unless [AUTHENTICATION_TYPE_API_KEY, AUTHENTICATION_TYPE_AES, AUTHENTICATION_TYPE_RSA].include?(authentication_type)
106
+ fail InvalidOptionError.new("as_api_key cannot be empty") unless as_api_key.to_s.size > 0
107
+ fail InvalidOptionError.new("Invalid base URL: #{domain}") unless valid_url?(domain)
108
+ 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
109
+ fail InvalidOptionError.new("timeout cannot be negative, value #{timeout}") unless timeout.to_i >= 0
110
+ 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
111
+ fail InvalidOptionError.new("max_retry cannot be negative, value #{max_retry}") unless max_retry.to_i >= 0
112
+ end
113
+
114
+ def valid_url?(url)
115
+ uri = URI.parse(url)
116
+ uri.is_a?(URI::HTTP) || uri.is_a?(URI::HTTPS)
117
+ rescue URI::InvalidURIError
118
+ false
119
+ end
120
+ end
120
121
  end
121
- end
122
122
 
@@ -11,7 +11,7 @@ module AftershipAPI::Model
11
11
  TRACKING_DESTINATION_COUNTRY = "tracking_destination_country".freeze
12
12
  TRACKING_STATE = "tracking_state".freeze
13
13
  def self.all_vars
14
- @all_vars ||= [TRACKING_ACCOUNT_NUMBER, TRACKING_POSTAL_CODE, TRACKING_SHIP_DATE, TRACKING_KEY, TRACKING_ORIGIN_COUNTRY, TRACKING_DESTINATION_COUNTRY, TRACKING_STATE,].freeze
14
+ @all_vars ||= [TRACKING_ACCOUNT_NUMBER,TRACKING_POSTAL_CODE,TRACKING_SHIP_DATE,TRACKING_KEY,TRACKING_ORIGIN_COUNTRY,TRACKING_DESTINATION_COUNTRY,TRACKING_STATE,].freeze
15
15
  end
16
16
 
17
17
  # Builds the enum from string
@@ -0,0 +1,183 @@
1
+ # This code was auto generated by AfterShip SDK Generator.
2
+ # Do not edit the class manually.
3
+ module AftershipAPI::Model
4
+ class AftershipEstimatedDeliveryDateCreateTrackingResponse
5
+
6
+ # The estimated arrival date of the shipment.
7
+ # estimated_delivery_date?: String;
8
+ attr_accessor :estimated_delivery_date
9
+
10
+ # Indicates the confidence level and associated reason for an AI EDD prediction request. For a comprehensive list of confidence codes, refer to .
11
+ # confidence_code?: Float;
12
+ attr_accessor :confidence_code
13
+
14
+ # Earliest estimated delivery date of the shipment.
15
+ # estimated_delivery_date_min?: String;
16
+ attr_accessor :estimated_delivery_date_min
17
+
18
+ # Latest estimated delivery date of the shipment.
19
+ # estimated_delivery_date_max?: String;
20
+ attr_accessor :estimated_delivery_date_max
21
+
22
+ # Initializes the object
23
+ # @param [Hash] attributes Model attributes in the form of hash
24
+ def initialize(attributes = {})
25
+ if (!attributes.is_a?(Hash))
26
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::AftershipEstimatedDeliveryDateCreateTrackingResponse` initialize method"
27
+ end
28
+
29
+ attributes = attributes.each_with_object({}) { |(k, v), h|
30
+ h[k.to_sym] = v
31
+ }
32
+
33
+ if attributes.key?(:'estimated_delivery_date')
34
+ self.estimated_delivery_date = attributes[:'estimated_delivery_date']
35
+ end
36
+
37
+ if attributes.key?(:'confidence_code')
38
+ self.confidence_code = attributes[:'confidence_code']
39
+ end
40
+
41
+ if attributes.key?(:'estimated_delivery_date_min')
42
+ self.estimated_delivery_date_min = attributes[:'estimated_delivery_date_min']
43
+ end
44
+
45
+ if attributes.key?(:'estimated_delivery_date_max')
46
+ self.estimated_delivery_date_max = attributes[:'estimated_delivery_date_max']
47
+ end
48
+ end
49
+
50
+ # Attribute type mapping.
51
+ def self.openapi_types
52
+ {
53
+ :'estimated_delivery_date' => :'String',
54
+ :'confidence_code' => :'Float',
55
+ :'estimated_delivery_date_min' => :'String',
56
+ :'estimated_delivery_date_max' => :'String',
57
+ }
58
+ end
59
+
60
+ # Attribute mapping from ruby-style variable name to JSON key.
61
+ def self.attribute_map
62
+ {
63
+ :'estimated_delivery_date' => :'estimated_delivery_date',
64
+ :'confidence_code' => :'confidence_code',
65
+ :'estimated_delivery_date_min' => :'estimated_delivery_date_min',
66
+ :'estimated_delivery_date_max' => :'estimated_delivery_date_max',
67
+ }
68
+ end
69
+
70
+ # Builds the object from hash
71
+ # @param attributes [Hash] Model attributes in the form of hash
72
+ # @return [Object] Returns the model itself
73
+ def self.build_from_hash(attributes)
74
+ return nil unless attributes.is_a?(Hash)
75
+ attributes = attributes.transform_keys(&:to_sym)
76
+ transformed_hash = {}
77
+ openapi_types.each_pair do |key, type|
78
+ if attributes.key?(key) && attributes[key].nil?
79
+ transformed_hash["#{key}"] = nil
80
+ elsif type =~ /\AArray<(.*)>/i
81
+ # check to ensure the input is an array given that the attribute
82
+ # is documented as an array but the input is not
83
+ if attributes[key].is_a?(Array)
84
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
85
+ end
86
+ elsif !attributes[key].nil?
87
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
88
+ end
89
+ end
90
+ new(transformed_hash)
91
+ end
92
+
93
+ # Deserializes the data based on type
94
+ # @param type [String] Data type
95
+ # @param value [String] Value to be deserialized
96
+ # @return [Object] Deserialized data
97
+ def self._deserialize(type, value)
98
+ case type.to_sym
99
+ when :Time
100
+ Time.parse(value)
101
+ when :Date
102
+ Date.parse(value)
103
+ when :String
104
+ value.to_s
105
+ when :Integer
106
+ value.to_i
107
+ when :Float
108
+ value.to_f
109
+ when :Boolean
110
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
111
+ true
112
+ else
113
+ false
114
+ end
115
+ when :Object
116
+ # generic object (usually a Hash), return directly
117
+ value
118
+ when /\AArray<(?<inner_type>.+)>\z/
119
+ inner_type = Regexp.last_match[:inner_type]
120
+ value.map { |v| _deserialize(inner_type, v) }
121
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
122
+ k_type = Regexp.last_match[:k_type]
123
+ v_type = Regexp.last_match[:v_type]
124
+ {}.tap do |hash|
125
+ value.each do |k, v|
126
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
127
+ end
128
+ end
129
+ else # model
130
+ klass = AftershipAPI::Model.const_get(type)
131
+ klass.build_from_hash(value)
132
+ end
133
+ end
134
+
135
+ # Returns the string representation of the object
136
+ # @return [String] String presentation of the object
137
+ def to_s
138
+ to_hash.to_s
139
+ end
140
+
141
+ # to_body is an alias to to_hash (backward compatibility)
142
+ # @return [Hash] Returns the object in the form of hash
143
+ def to_body
144
+ to_hash
145
+ end
146
+
147
+ # Returns the object in the form of hash
148
+ # @return [Hash] Returns the object in the form of hash
149
+ def to_hash
150
+ hash = {}
151
+ self.class.attribute_map.each_pair do |attr, param|
152
+ value = self.send(attr)
153
+ next if value.nil?
154
+
155
+ hash[param] = _to_hash(value)
156
+ end
157
+ hash
158
+ end
159
+
160
+ # Outputs non-array value in the form of hash
161
+ # For object, use to_hash. Otherwise, just return the value
162
+ # @param value [Object] Any valid value
163
+ # @return [Hash] Returns the value in the form of hash
164
+ def _to_hash(value)
165
+ if value.is_a?(Array)
166
+ value.compact.map { |v| _to_hash(v) }
167
+ elsif value.is_a?(Hash)
168
+ {}.tap do |hash|
169
+ value.each { |k, v| hash[k] = _to_hash(v) }
170
+ end
171
+ elsif value.respond_to? :to_hash
172
+ value.to_hash
173
+ else
174
+ value
175
+ end
176
+ end
177
+
178
+ def to_json(*a)
179
+ to_hash.to_json(*a)
180
+ end
181
+ end
182
+ end
183
+
@@ -0,0 +1,183 @@
1
+ # This code was auto generated by AfterShip SDK Generator.
2
+ # Do not edit the class manually.
3
+ module AftershipAPI::Model
4
+ class AftershipEstimatedDeliveryDateDeleteTrackingByIdResponse
5
+
6
+ # The estimated arrival date of the shipment.
7
+ # estimated_delivery_date?: String;
8
+ attr_accessor :estimated_delivery_date
9
+
10
+ # Indicates the confidence level and associated reason for an AI EDD prediction request. For a comprehensive list of confidence codes, refer to .
11
+ # confidence_code?: Float;
12
+ attr_accessor :confidence_code
13
+
14
+ # Earliest estimated delivery date of the shipment.
15
+ # estimated_delivery_date_min?: String;
16
+ attr_accessor :estimated_delivery_date_min
17
+
18
+ # Latest estimated delivery date of the shipment.
19
+ # estimated_delivery_date_max?: String;
20
+ attr_accessor :estimated_delivery_date_max
21
+
22
+ # Initializes the object
23
+ # @param [Hash] attributes Model attributes in the form of hash
24
+ def initialize(attributes = {})
25
+ if (!attributes.is_a?(Hash))
26
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::AftershipEstimatedDeliveryDateDeleteTrackingByIdResponse` initialize method"
27
+ end
28
+
29
+ attributes = attributes.each_with_object({}) { |(k, v), h|
30
+ h[k.to_sym] = v
31
+ }
32
+
33
+ if attributes.key?(:'estimated_delivery_date')
34
+ self.estimated_delivery_date = attributes[:'estimated_delivery_date']
35
+ end
36
+
37
+ if attributes.key?(:'confidence_code')
38
+ self.confidence_code = attributes[:'confidence_code']
39
+ end
40
+
41
+ if attributes.key?(:'estimated_delivery_date_min')
42
+ self.estimated_delivery_date_min = attributes[:'estimated_delivery_date_min']
43
+ end
44
+
45
+ if attributes.key?(:'estimated_delivery_date_max')
46
+ self.estimated_delivery_date_max = attributes[:'estimated_delivery_date_max']
47
+ end
48
+ end
49
+
50
+ # Attribute type mapping.
51
+ def self.openapi_types
52
+ {
53
+ :'estimated_delivery_date' => :'String',
54
+ :'confidence_code' => :'Float',
55
+ :'estimated_delivery_date_min' => :'String',
56
+ :'estimated_delivery_date_max' => :'String',
57
+ }
58
+ end
59
+
60
+ # Attribute mapping from ruby-style variable name to JSON key.
61
+ def self.attribute_map
62
+ {
63
+ :'estimated_delivery_date' => :'estimated_delivery_date',
64
+ :'confidence_code' => :'confidence_code',
65
+ :'estimated_delivery_date_min' => :'estimated_delivery_date_min',
66
+ :'estimated_delivery_date_max' => :'estimated_delivery_date_max',
67
+ }
68
+ end
69
+
70
+ # Builds the object from hash
71
+ # @param attributes [Hash] Model attributes in the form of hash
72
+ # @return [Object] Returns the model itself
73
+ def self.build_from_hash(attributes)
74
+ return nil unless attributes.is_a?(Hash)
75
+ attributes = attributes.transform_keys(&:to_sym)
76
+ transformed_hash = {}
77
+ openapi_types.each_pair do |key, type|
78
+ if attributes.key?(key) && attributes[key].nil?
79
+ transformed_hash["#{key}"] = nil
80
+ elsif type =~ /\AArray<(.*)>/i
81
+ # check to ensure the input is an array given that the attribute
82
+ # is documented as an array but the input is not
83
+ if attributes[key].is_a?(Array)
84
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
85
+ end
86
+ elsif !attributes[key].nil?
87
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
88
+ end
89
+ end
90
+ new(transformed_hash)
91
+ end
92
+
93
+ # Deserializes the data based on type
94
+ # @param type [String] Data type
95
+ # @param value [String] Value to be deserialized
96
+ # @return [Object] Deserialized data
97
+ def self._deserialize(type, value)
98
+ case type.to_sym
99
+ when :Time
100
+ Time.parse(value)
101
+ when :Date
102
+ Date.parse(value)
103
+ when :String
104
+ value.to_s
105
+ when :Integer
106
+ value.to_i
107
+ when :Float
108
+ value.to_f
109
+ when :Boolean
110
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
111
+ true
112
+ else
113
+ false
114
+ end
115
+ when :Object
116
+ # generic object (usually a Hash), return directly
117
+ value
118
+ when /\AArray<(?<inner_type>.+)>\z/
119
+ inner_type = Regexp.last_match[:inner_type]
120
+ value.map { |v| _deserialize(inner_type, v) }
121
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
122
+ k_type = Regexp.last_match[:k_type]
123
+ v_type = Regexp.last_match[:v_type]
124
+ {}.tap do |hash|
125
+ value.each do |k, v|
126
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
127
+ end
128
+ end
129
+ else # model
130
+ klass = AftershipAPI::Model.const_get(type)
131
+ klass.build_from_hash(value)
132
+ end
133
+ end
134
+
135
+ # Returns the string representation of the object
136
+ # @return [String] String presentation of the object
137
+ def to_s
138
+ to_hash.to_s
139
+ end
140
+
141
+ # to_body is an alias to to_hash (backward compatibility)
142
+ # @return [Hash] Returns the object in the form of hash
143
+ def to_body
144
+ to_hash
145
+ end
146
+
147
+ # Returns the object in the form of hash
148
+ # @return [Hash] Returns the object in the form of hash
149
+ def to_hash
150
+ hash = {}
151
+ self.class.attribute_map.each_pair do |attr, param|
152
+ value = self.send(attr)
153
+ next if value.nil?
154
+
155
+ hash[param] = _to_hash(value)
156
+ end
157
+ hash
158
+ end
159
+
160
+ # Outputs non-array value in the form of hash
161
+ # For object, use to_hash. Otherwise, just return the value
162
+ # @param value [Object] Any valid value
163
+ # @return [Hash] Returns the value in the form of hash
164
+ def _to_hash(value)
165
+ if value.is_a?(Array)
166
+ value.compact.map { |v| _to_hash(v) }
167
+ elsif value.is_a?(Hash)
168
+ {}.tap do |hash|
169
+ value.each { |k, v| hash[k] = _to_hash(v) }
170
+ end
171
+ elsif value.respond_to? :to_hash
172
+ value.to_hash
173
+ else
174
+ value
175
+ end
176
+ end
177
+
178
+ def to_json(*a)
179
+ to_hash.to_json(*a)
180
+ end
181
+ end
182
+ end
183
+