aftership-tracking-sdk 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +11 -0
  3. data/LICENSE +21 -0
  4. data/README.md +285 -0
  5. data/aftership-tracking-sdk.gemspec +27 -0
  6. data/lib/aftership-tracking-sdk/api/courier.rb +163 -0
  7. data/lib/aftership-tracking-sdk/api/estimated_delivery_date.rb +67 -0
  8. data/lib/aftership-tracking-sdk/api/last_checkpoint.rb +143 -0
  9. data/lib/aftership-tracking-sdk/api/notification.rb +403 -0
  10. data/lib/aftership-tracking-sdk/api/tracking.rb +793 -0
  11. data/lib/aftership-tracking-sdk/api_client.rb +426 -0
  12. data/lib/aftership-tracking-sdk/configuration.rb +122 -0
  13. data/lib/aftership-tracking-sdk/error.rb +125 -0
  14. data/lib/aftership-tracking-sdk/models/additional_fields_v1.rb +32 -0
  15. data/lib/aftership-tracking-sdk/models/aftership_estimated_delivery_date_tracking.rb +181 -0
  16. data/lib/aftership-tracking-sdk/models/carbon_emissions_tracking.rb +161 -0
  17. data/lib/aftership-tracking-sdk/models/checkpoint.rb +301 -0
  18. data/lib/aftership-tracking-sdk/models/coordinate_checkpoint.rb +161 -0
  19. data/lib/aftership-tracking-sdk/models/courier.rb +241 -0
  20. data/lib/aftership-tracking-sdk/models/courier_response_v1.rb +161 -0
  21. data/lib/aftership-tracking-sdk/models/custom_estimated_delivery_date_tracking.rb +181 -0
  22. data/lib/aftership-tracking-sdk/models/custom_fields_tracking_update_tracking_by_slug_tracking_number_request.rb +139 -0
  23. data/lib/aftership-tracking-sdk/models/data_courier_response_v1.rb +161 -0
  24. data/lib/aftership-tracking-sdk/models/data_notification_response_v1.rb +151 -0
  25. data/lib/aftership-tracking-sdk/models/data_tracking_delete_response_v1.rb +151 -0
  26. data/lib/aftership-tracking-sdk/models/data_tracking_response_get_multiple_v1.rb +281 -0
  27. data/lib/aftership-tracking-sdk/models/data_tracking_response_v1.rb +151 -0
  28. data/lib/aftership-tracking-sdk/models/destination_address_estimated_delivery_date_request.rb +191 -0
  29. data/lib/aftership-tracking-sdk/models/destination_address_estimated_delivery_date_response.rb +191 -0
  30. data/lib/aftership-tracking-sdk/models/detect_courier_response.rb +161 -0
  31. data/lib/aftership-tracking-sdk/models/estimated_delivery_date_request.rb +221 -0
  32. data/lib/aftership-tracking-sdk/models/estimated_delivery_date_response.rb +261 -0
  33. data/lib/aftership-tracking-sdk/models/estimated_pickup_estimated_delivery_date_request.rb +181 -0
  34. data/lib/aftership-tracking-sdk/models/estimated_pickup_estimated_delivery_date_response.rb +191 -0
  35. data/lib/aftership-tracking-sdk/models/events_checkpoint.rb +161 -0
  36. data/lib/aftership-tracking-sdk/models/first_estimated_delivery_tracking.rb +191 -0
  37. data/lib/aftership-tracking-sdk/models/get_all_couriers_response.rb +161 -0
  38. data/lib/aftership-tracking-sdk/models/get_checkpoint_by_slug_tracking_number_response.rb +211 -0
  39. data/lib/aftership-tracking-sdk/models/get_checkpoint_by_tracking_id_response.rb +211 -0
  40. data/lib/aftership-tracking-sdk/models/get_trackings_response.rb +161 -0
  41. data/lib/aftership-tracking-sdk/models/get_user_couriers_response.rb +161 -0
  42. data/lib/aftership-tracking-sdk/models/latest_estimated_delivery_tracking.rb +191 -0
  43. data/lib/aftership-tracking-sdk/models/mark_tracking_completed_by_id_request.rb +151 -0
  44. data/lib/aftership-tracking-sdk/models/mark_tracking_completed_by_slug_tracking_number_request.rb +151 -0
  45. data/lib/aftership-tracking-sdk/models/meta_v1.rb +171 -0
  46. data/lib/aftership-tracking-sdk/models/next_couriers_tracking.rb +171 -0
  47. data/lib/aftership-tracking-sdk/models/next_couriers_tracking_create_tracking_request.rb +161 -0
  48. data/lib/aftership-tracking-sdk/models/notification.rb +161 -0
  49. data/lib/aftership-tracking-sdk/models/notification_request_v1.rb +161 -0
  50. data/lib/aftership-tracking-sdk/models/notification_response_v1.rb +161 -0
  51. data/lib/aftership-tracking-sdk/models/order_processing_time_estimated_pickup_estimated_delivery_date_request.rb +161 -0
  52. data/lib/aftership-tracking-sdk/models/order_processing_time_estimated_pickup_estimated_delivery_date_response.rb +161 -0
  53. data/lib/aftership-tracking-sdk/models/origin_address_estimated_delivery_date_request.rb +191 -0
  54. data/lib/aftership-tracking-sdk/models/origin_address_estimated_delivery_date_response.rb +191 -0
  55. data/lib/aftership-tracking-sdk/models/pagination.rb +156 -0
  56. data/lib/aftership-tracking-sdk/models/partial_delete_tracking.rb +241 -0
  57. data/lib/aftership-tracking-sdk/models/partial_update_tracking.rb +251 -0
  58. data/lib/aftership-tracking-sdk/models/predict_batch_request.rb +151 -0
  59. data/lib/aftership-tracking-sdk/models/predict_batch_response.rb +151 -0
  60. data/lib/aftership-tracking-sdk/models/reason_events_checkpoint.rb +151 -0
  61. data/lib/aftership-tracking-sdk/models/slug_group_v1.rb +37 -0
  62. data/lib/aftership-tracking-sdk/models/tag_v1.rb +34 -0
  63. data/lib/aftership-tracking-sdk/models/tracking.rb +921 -0
  64. data/lib/aftership-tracking-sdk/models/tracking_create_tracking_request.rb +551 -0
  65. data/lib/aftership-tracking-sdk/models/tracking_delete_response_v1.rb +161 -0
  66. data/lib/aftership-tracking-sdk/models/tracking_detect_courier_request.rb +261 -0
  67. data/lib/aftership-tracking-sdk/models/tracking_response_get_multiple_v1.rb +161 -0
  68. data/lib/aftership-tracking-sdk/models/tracking_response_v1.rb +161 -0
  69. data/lib/aftership-tracking-sdk/models/tracking_update_tracking_by_id_request.rb +501 -0
  70. data/lib/aftership-tracking-sdk/models/tracking_update_tracking_by_slug_tracking_number_request.rb +391 -0
  71. data/lib/aftership-tracking-sdk/models/weight_estimated_delivery_date_request.rb +161 -0
  72. data/lib/aftership-tracking-sdk/models/weight_estimated_delivery_date_response.rb +161 -0
  73. data/lib/aftership-tracking-sdk/sign_string.rb +77 -0
  74. data/lib/aftership-tracking-sdk/version.rb +5 -0
  75. data/lib/aftership-tracking-sdk.rb +47 -0
  76. metadata +157 -0
@@ -0,0 +1,161 @@
1
+ # This code was auto generated by AfterShip SDK Generator.
2
+ # Do not edit the class manually.
3
+ module AftershipAPI::Model
4
+ class TrackingResponseV1
5
+ # Meta data
6
+ # meta: MetaV1;
7
+ attr_accessor :meta
8
+
9
+ #
10
+ # data: DataTrackingResponseV1;
11
+ attr_accessor :data
12
+
13
+ # Initializes the object
14
+ # @param [Hash] attributes Model attributes in the form of hash
15
+ def initialize(attributes = {})
16
+ if (!attributes.is_a?(Hash))
17
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::TrackingResponseV1` initialize method"
18
+ end
19
+
20
+ attributes = attributes.each_with_object({}) { |(k, v), h|
21
+ h[k.to_sym] = v
22
+ }
23
+
24
+ if attributes.key?(:'meta')
25
+ self.meta = attributes[:'meta']
26
+ end
27
+
28
+ if attributes.key?(:'data')
29
+ self.data = attributes[:'data']
30
+ end
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.openapi_types
35
+ {
36
+ :'meta' => :'MetaV1',
37
+ :'data' => :'DataTrackingResponseV1',
38
+ }
39
+ end
40
+
41
+ # Attribute mapping from ruby-style variable name to JSON key.
42
+ def self.attribute_map
43
+ {
44
+ :'meta' => :'meta',
45
+ :'data' => :'data',
46
+ }
47
+ end
48
+
49
+ # Builds the object from hash
50
+ # @param attributes [Hash] Model attributes in the form of hash
51
+ # @return [Object] Returns the model itself
52
+ def self.build_from_hash(attributes)
53
+ return nil unless attributes.is_a?(Hash)
54
+ attributes = attributes.transform_keys(&:to_sym)
55
+ transformed_hash = {}
56
+ openapi_types.each_pair do |key, type|
57
+ if attributes.key?(key) && attributes[key].nil?
58
+ transformed_hash["#{key}"] = nil
59
+ elsif type =~ /\AArray<(.*)>/i
60
+ # check to ensure the input is an array given that the attribute
61
+ # is documented as an array but the input is not
62
+ if attributes[key].is_a?(Array)
63
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
64
+ end
65
+ elsif !attributes[key].nil?
66
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
67
+ end
68
+ end
69
+ new(transformed_hash)
70
+ end
71
+
72
+ # Deserializes the data based on type
73
+ # @param type [String] Data type
74
+ # @param value [String] Value to be deserialized
75
+ # @return [Object] Deserialized data
76
+ def self._deserialize(type, value)
77
+ case type.to_sym
78
+ when :Time
79
+ Time.parse(value)
80
+ when :Date
81
+ Date.parse(value)
82
+ when :String
83
+ value.to_s
84
+ when :Integer
85
+ value.to_i
86
+ when :Float
87
+ value.to_f
88
+ when :Boolean
89
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
90
+ true
91
+ else
92
+ false
93
+ end
94
+ when :Object
95
+ # generic object (usually a Hash), return directly
96
+ value
97
+ when /\AArray<(?<inner_type>.+)>\z/
98
+ inner_type = Regexp.last_match[:inner_type]
99
+ value.map { |v| _deserialize(inner_type, v) }
100
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
101
+ k_type = Regexp.last_match[:k_type]
102
+ v_type = Regexp.last_match[:v_type]
103
+ {}.tap do |hash|
104
+ value.each do |k, v|
105
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
106
+ end
107
+ end
108
+ else # model
109
+ klass = AftershipAPI::Model.const_get(type)
110
+ klass.build_from_hash(value)
111
+ end
112
+ end
113
+
114
+ # Returns the string representation of the object
115
+ # @return [String] String presentation of the object
116
+ def to_s
117
+ to_hash.to_s
118
+ end
119
+
120
+ # to_body is an alias to to_hash (backward compatibility)
121
+ # @return [Hash] Returns the object in the form of hash
122
+ def to_body
123
+ to_hash
124
+ end
125
+
126
+ # Returns the object in the form of hash
127
+ # @return [Hash] Returns the object in the form of hash
128
+ def to_hash
129
+ hash = {}
130
+ self.class.attribute_map.each_pair do |attr, param|
131
+ value = self.send(attr)
132
+ next if value.nil?
133
+
134
+ hash[param] = _to_hash(value)
135
+ end
136
+ hash
137
+ end
138
+
139
+ # Outputs non-array value in the form of hash
140
+ # For object, use to_hash. Otherwise, just return the value
141
+ # @param value [Object] Any valid value
142
+ # @return [Hash] Returns the value in the form of hash
143
+ def _to_hash(value)
144
+ if value.is_a?(Array)
145
+ value.compact.map { |v| _to_hash(v) }
146
+ elsif value.is_a?(Hash)
147
+ {}.tap do |hash|
148
+ value.each { |k, v| hash[k] = _to_hash(v) }
149
+ end
150
+ elsif value.respond_to? :to_hash
151
+ value.to_hash
152
+ else
153
+ value
154
+ end
155
+ end
156
+
157
+ def to_json(*a)
158
+ to_hash.to_json(*a)
159
+ end
160
+ end
161
+ end
@@ -0,0 +1,501 @@
1
+ # This code was auto generated by AfterShip SDK Generator.
2
+ # Do not edit the class manually.
3
+ module AftershipAPI::Model
4
+ class TrackingUpdateTrackingByIdRequest
5
+ # The phone number(s) to receive sms notifications. Input `[]` to clear the value of this field. Supports up to 3 phone numbers.
6
+ # smses?: String[];
7
+ attr_accessor :smses
8
+
9
+ # Email address(es) to receive email notifications. Input `[]` to clear the value of this field. Supports up to 3 email addresses.
10
+ # emails?: String[];
11
+ attr_accessor :emails
12
+
13
+ # By default this field shows the `tracking_number`, but you can customize it as you wish with any info (e.g. the order number).
14
+ # title?: String;
15
+ attr_accessor :title
16
+
17
+ # Customer name of the tracking.
18
+ # customer_name?: String;
19
+ attr_accessor :customer_name
20
+
21
+ # A globally-unique identifier for the order.
22
+ # order_id?: String;
23
+ attr_accessor :order_id
24
+
25
+ # The URL for the order in your system or store.
26
+ # order_id_path?: String;
27
+ attr_accessor :order_id_path
28
+
29
+ # Custom fields that accept an object with string field. In order to protect the privacy of your customers, do not include any
30
+ # custom_fields?: Object;
31
+ attr_accessor :custom_fields
32
+
33
+ # Text field for the note.Input `""` to clear the value of this field.
34
+ # note?: String;
35
+ attr_accessor :note
36
+
37
+ # 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.
38
+ # language?: String;
39
+ attr_accessor :language
40
+
41
+ # The promised delivery date of the order. It uses the format YYYY-MM-DD. This has no timezone and uses whatever date you provide. Since other EDDs use the shipment recipient’s timezone, we suggest following the same logic here.
42
+ # order_promised_delivery_date?: String;
43
+ attr_accessor :order_promised_delivery_date
44
+
45
+ # Shipment delivery type- `pickup_at_store`- `pickup_at_courier`- `door_to_door`
46
+ # delivery_type?: String;
47
+ attr_accessor :delivery_type
48
+
49
+ # Shipment pickup location for receiver
50
+ # pickup_location?: String;
51
+ attr_accessor :pickup_location
52
+
53
+ # Shipment pickup note for receiver
54
+ # pickup_note?: String;
55
+ attr_accessor :pickup_note
56
+
57
+ # Unique code of each courier. Provide a single courier.(https://admin.aftership.com/settings/couriers). Get a list of courier slug using
58
+ # slug?: String;
59
+ attr_accessor :slug
60
+
61
+ # 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.
62
+ # tracking_account_number?: String;
63
+ attr_accessor :tracking_account_number
64
+
65
+ # 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.
66
+ # tracking_key?: String;
67
+ attr_accessor :tracking_key
68
+
69
+ # Additional field required by some carriers to retrieve the tracking info. The date the shipment was sent, using the format YYYYMMDD. Refer to our article on for more details.
70
+ # tracking_ship_date?: String;
71
+ attr_accessor :tracking_ship_date
72
+
73
+ # A unique, human-readable identifier for the order.
74
+ # order_number?: String;
75
+ attr_accessor :order_number
76
+
77
+ # Order date in YYYY-MM-DDTHH:mm:ssZ format. e.g. 2021-07-26T11:23:51-05:00
78
+ # order_date?: String;
79
+ attr_accessor :order_date
80
+
81
+ # The carrier service type for the shipment. If you provide info for this field, AfterShip will not update it with info from the carrier.
82
+ # shipment_type?: String;
83
+ attr_accessor :shipment_type
84
+
85
+ # The for more details.
86
+ # origin_country_iso3?: String;
87
+ attr_accessor :origin_country_iso3
88
+
89
+ # 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.
90
+ # origin_state?: String;
91
+ attr_accessor :origin_state
92
+
93
+ # 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.
94
+ # origin_city?: String;
95
+ attr_accessor :origin_city
96
+
97
+ # 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.
98
+ # origin_postal_code?: String;
99
+ attr_accessor :origin_postal_code
100
+
101
+ # 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.
102
+ # origin_raw_location?: String;
103
+ attr_accessor :origin_raw_location
104
+
105
+ # The for more details.
106
+ # destination_country_iso3?: String;
107
+ attr_accessor :destination_country_iso3
108
+
109
+ # 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.
110
+ # destination_state?: String;
111
+ attr_accessor :destination_state
112
+
113
+ # 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.
114
+ # destination_city?: String;
115
+ attr_accessor :destination_city
116
+
117
+ # 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.
118
+ # destination_postal_code?: String;
119
+ attr_accessor :destination_postal_code
120
+
121
+ # 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.
122
+ # destination_raw_location?: String;
123
+ attr_accessor :destination_raw_location
124
+
125
+ # (Legacy) Replaced by `origin_country_iso3`. Additional field required by some carriers to retrieve the tracking info. The origin country/region of the shipment. Refer to our article on for more details.
126
+ # tracking_origin_country?: String;
127
+ attr_accessor :tracking_origin_country
128
+
129
+ # (Legacy) Replaced by `destination_country_iso3`. Additional field required by some carriers to retrieve the tracking info. The destination country/region of the shipment. Refer to our article on for more details.
130
+ # tracking_destination_country?: String;
131
+ attr_accessor :tracking_destination_country
132
+
133
+ # (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.
134
+ # tracking_postal_code?: String;
135
+ attr_accessor :tracking_postal_code
136
+
137
+ # (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.
138
+ # tracking_state?: String;
139
+ attr_accessor :tracking_state
140
+
141
+ # 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 .
142
+ # location_id?: String;
143
+ attr_accessor :location_id
144
+
145
+ # 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.
146
+ # shipping_method?: String;
147
+ attr_accessor :shipping_method
148
+
149
+ # Initializes the object
150
+ # @param [Hash] attributes Model attributes in the form of hash
151
+ def initialize(attributes = {})
152
+ if (!attributes.is_a?(Hash))
153
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::TrackingUpdateTrackingByIdRequest` initialize method"
154
+ end
155
+
156
+ attributes = attributes.each_with_object({}) { |(k, v), h|
157
+ h[k.to_sym] = v
158
+ }
159
+
160
+ if attributes.key?(:'smses')
161
+ self.smses = attributes[:'smses']
162
+ end
163
+
164
+ if attributes.key?(:'emails')
165
+ self.emails = attributes[:'emails']
166
+ end
167
+
168
+ if attributes.key?(:'title')
169
+ self.title = attributes[:'title']
170
+ end
171
+
172
+ if attributes.key?(:'customer_name')
173
+ self.customer_name = attributes[:'customer_name']
174
+ end
175
+
176
+ if attributes.key?(:'order_id')
177
+ self.order_id = attributes[:'order_id']
178
+ end
179
+
180
+ if attributes.key?(:'order_id_path')
181
+ self.order_id_path = attributes[:'order_id_path']
182
+ end
183
+
184
+ if attributes.key?(:'custom_fields')
185
+ self.custom_fields = attributes[:'custom_fields']
186
+ end
187
+
188
+ if attributes.key?(:'note')
189
+ self.note = attributes[:'note']
190
+ end
191
+
192
+ if attributes.key?(:'language')
193
+ self.language = attributes[:'language']
194
+ end
195
+
196
+ if attributes.key?(:'order_promised_delivery_date')
197
+ self.order_promised_delivery_date = attributes[:'order_promised_delivery_date']
198
+ end
199
+
200
+ if attributes.key?(:'delivery_type')
201
+ self.delivery_type = attributes[:'delivery_type']
202
+ end
203
+
204
+ if attributes.key?(:'pickup_location')
205
+ self.pickup_location = attributes[:'pickup_location']
206
+ end
207
+
208
+ if attributes.key?(:'pickup_note')
209
+ self.pickup_note = attributes[:'pickup_note']
210
+ end
211
+
212
+ if attributes.key?(:'slug')
213
+ self.slug = attributes[:'slug']
214
+ end
215
+
216
+ if attributes.key?(:'tracking_account_number')
217
+ self.tracking_account_number = attributes[:'tracking_account_number']
218
+ end
219
+
220
+ if attributes.key?(:'tracking_key')
221
+ self.tracking_key = attributes[:'tracking_key']
222
+ end
223
+
224
+ if attributes.key?(:'tracking_ship_date')
225
+ self.tracking_ship_date = attributes[:'tracking_ship_date']
226
+ end
227
+
228
+ if attributes.key?(:'order_number')
229
+ self.order_number = attributes[:'order_number']
230
+ end
231
+
232
+ if attributes.key?(:'order_date')
233
+ self.order_date = attributes[:'order_date']
234
+ end
235
+
236
+ if attributes.key?(:'shipment_type')
237
+ self.shipment_type = attributes[:'shipment_type']
238
+ end
239
+
240
+ if attributes.key?(:'origin_country_iso3')
241
+ self.origin_country_iso3 = attributes[:'origin_country_iso3']
242
+ end
243
+
244
+ if attributes.key?(:'origin_state')
245
+ self.origin_state = attributes[:'origin_state']
246
+ end
247
+
248
+ if attributes.key?(:'origin_city')
249
+ self.origin_city = attributes[:'origin_city']
250
+ end
251
+
252
+ if attributes.key?(:'origin_postal_code')
253
+ self.origin_postal_code = attributes[:'origin_postal_code']
254
+ end
255
+
256
+ if attributes.key?(:'origin_raw_location')
257
+ self.origin_raw_location = attributes[:'origin_raw_location']
258
+ end
259
+
260
+ if attributes.key?(:'destination_country_iso3')
261
+ self.destination_country_iso3 = attributes[:'destination_country_iso3']
262
+ end
263
+
264
+ if attributes.key?(:'destination_state')
265
+ self.destination_state = attributes[:'destination_state']
266
+ end
267
+
268
+ if attributes.key?(:'destination_city')
269
+ self.destination_city = attributes[:'destination_city']
270
+ end
271
+
272
+ if attributes.key?(:'destination_postal_code')
273
+ self.destination_postal_code = attributes[:'destination_postal_code']
274
+ end
275
+
276
+ if attributes.key?(:'destination_raw_location')
277
+ self.destination_raw_location = attributes[:'destination_raw_location']
278
+ end
279
+
280
+ if attributes.key?(:'tracking_origin_country')
281
+ self.tracking_origin_country = attributes[:'tracking_origin_country']
282
+ end
283
+
284
+ if attributes.key?(:'tracking_destination_country')
285
+ self.tracking_destination_country = attributes[:'tracking_destination_country']
286
+ end
287
+
288
+ if attributes.key?(:'tracking_postal_code')
289
+ self.tracking_postal_code = attributes[:'tracking_postal_code']
290
+ end
291
+
292
+ if attributes.key?(:'tracking_state')
293
+ self.tracking_state = attributes[:'tracking_state']
294
+ end
295
+
296
+ if attributes.key?(:'location_id')
297
+ self.location_id = attributes[:'location_id']
298
+ end
299
+
300
+ if attributes.key?(:'shipping_method')
301
+ self.shipping_method = attributes[:'shipping_method']
302
+ end
303
+ end
304
+
305
+ # Attribute type mapping.
306
+ def self.openapi_types
307
+ {
308
+ :'smses' => :'Array<String>',
309
+ :'emails' => :'Array<String>',
310
+ :'title' => :'String',
311
+ :'customer_name' => :'String',
312
+ :'order_id' => :'String',
313
+ :'order_id_path' => :'String',
314
+ :'custom_fields' => :'Object',
315
+ :'note' => :'String',
316
+ :'language' => :'String',
317
+ :'order_promised_delivery_date' => :'String',
318
+ :'delivery_type' => :'String',
319
+ :'pickup_location' => :'String',
320
+ :'pickup_note' => :'String',
321
+ :'slug' => :'String',
322
+ :'tracking_account_number' => :'String',
323
+ :'tracking_key' => :'String',
324
+ :'tracking_ship_date' => :'String',
325
+ :'order_number' => :'String',
326
+ :'order_date' => :'String',
327
+ :'shipment_type' => :'String',
328
+ :'origin_country_iso3' => :'String',
329
+ :'origin_state' => :'String',
330
+ :'origin_city' => :'String',
331
+ :'origin_postal_code' => :'String',
332
+ :'origin_raw_location' => :'String',
333
+ :'destination_country_iso3' => :'String',
334
+ :'destination_state' => :'String',
335
+ :'destination_city' => :'String',
336
+ :'destination_postal_code' => :'String',
337
+ :'destination_raw_location' => :'String',
338
+ :'tracking_origin_country' => :'String',
339
+ :'tracking_destination_country' => :'String',
340
+ :'tracking_postal_code' => :'String',
341
+ :'tracking_state' => :'String',
342
+ :'location_id' => :'String',
343
+ :'shipping_method' => :'String',
344
+ }
345
+ end
346
+
347
+ # Attribute mapping from ruby-style variable name to JSON key.
348
+ def self.attribute_map
349
+ {
350
+ :'smses' => :'smses',
351
+ :'emails' => :'emails',
352
+ :'title' => :'title',
353
+ :'customer_name' => :'customer_name',
354
+ :'order_id' => :'order_id',
355
+ :'order_id_path' => :'order_id_path',
356
+ :'custom_fields' => :'custom_fields',
357
+ :'note' => :'note',
358
+ :'language' => :'language',
359
+ :'order_promised_delivery_date' => :'order_promised_delivery_date',
360
+ :'delivery_type' => :'delivery_type',
361
+ :'pickup_location' => :'pickup_location',
362
+ :'pickup_note' => :'pickup_note',
363
+ :'slug' => :'slug',
364
+ :'tracking_account_number' => :'tracking_account_number',
365
+ :'tracking_key' => :'tracking_key',
366
+ :'tracking_ship_date' => :'tracking_ship_date',
367
+ :'order_number' => :'order_number',
368
+ :'order_date' => :'order_date',
369
+ :'shipment_type' => :'shipment_type',
370
+ :'origin_country_iso3' => :'origin_country_iso3',
371
+ :'origin_state' => :'origin_state',
372
+ :'origin_city' => :'origin_city',
373
+ :'origin_postal_code' => :'origin_postal_code',
374
+ :'origin_raw_location' => :'origin_raw_location',
375
+ :'destination_country_iso3' => :'destination_country_iso3',
376
+ :'destination_state' => :'destination_state',
377
+ :'destination_city' => :'destination_city',
378
+ :'destination_postal_code' => :'destination_postal_code',
379
+ :'destination_raw_location' => :'destination_raw_location',
380
+ :'tracking_origin_country' => :'tracking_origin_country',
381
+ :'tracking_destination_country' => :'tracking_destination_country',
382
+ :'tracking_postal_code' => :'tracking_postal_code',
383
+ :'tracking_state' => :'tracking_state',
384
+ :'location_id' => :'location_id',
385
+ :'shipping_method' => :'shipping_method',
386
+ }
387
+ end
388
+
389
+ # Builds the object from hash
390
+ # @param attributes [Hash] Model attributes in the form of hash
391
+ # @return [Object] Returns the model itself
392
+ def self.build_from_hash(attributes)
393
+ return nil unless attributes.is_a?(Hash)
394
+ attributes = attributes.transform_keys(&:to_sym)
395
+ transformed_hash = {}
396
+ openapi_types.each_pair do |key, type|
397
+ if attributes.key?(key) && attributes[key].nil?
398
+ transformed_hash["#{key}"] = nil
399
+ elsif type =~ /\AArray<(.*)>/i
400
+ # check to ensure the input is an array given that the attribute
401
+ # is documented as an array but the input is not
402
+ if attributes[key].is_a?(Array)
403
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
404
+ end
405
+ elsif !attributes[key].nil?
406
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
407
+ end
408
+ end
409
+ new(transformed_hash)
410
+ end
411
+
412
+ # Deserializes the data based on type
413
+ # @param type [String] Data type
414
+ # @param value [String] Value to be deserialized
415
+ # @return [Object] Deserialized data
416
+ def self._deserialize(type, value)
417
+ case type.to_sym
418
+ when :Time
419
+ Time.parse(value)
420
+ when :Date
421
+ Date.parse(value)
422
+ when :String
423
+ value.to_s
424
+ when :Integer
425
+ value.to_i
426
+ when :Float
427
+ value.to_f
428
+ when :Boolean
429
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
430
+ true
431
+ else
432
+ false
433
+ end
434
+ when :Object
435
+ # generic object (usually a Hash), return directly
436
+ value
437
+ when /\AArray<(?<inner_type>.+)>\z/
438
+ inner_type = Regexp.last_match[:inner_type]
439
+ value.map { |v| _deserialize(inner_type, v) }
440
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
441
+ k_type = Regexp.last_match[:k_type]
442
+ v_type = Regexp.last_match[:v_type]
443
+ {}.tap do |hash|
444
+ value.each do |k, v|
445
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
446
+ end
447
+ end
448
+ else # model
449
+ klass = AftershipAPI::Model.const_get(type)
450
+ klass.build_from_hash(value)
451
+ end
452
+ end
453
+
454
+ # Returns the string representation of the object
455
+ # @return [String] String presentation of the object
456
+ def to_s
457
+ to_hash.to_s
458
+ end
459
+
460
+ # to_body is an alias to to_hash (backward compatibility)
461
+ # @return [Hash] Returns the object in the form of hash
462
+ def to_body
463
+ to_hash
464
+ end
465
+
466
+ # Returns the object in the form of hash
467
+ # @return [Hash] Returns the object in the form of hash
468
+ def to_hash
469
+ hash = {}
470
+ self.class.attribute_map.each_pair do |attr, param|
471
+ value = self.send(attr)
472
+ next if value.nil?
473
+
474
+ hash[param] = _to_hash(value)
475
+ end
476
+ hash
477
+ end
478
+
479
+ # Outputs non-array value in the form of hash
480
+ # For object, use to_hash. Otherwise, just return the value
481
+ # @param value [Object] Any valid value
482
+ # @return [Hash] Returns the value in the form of hash
483
+ def _to_hash(value)
484
+ if value.is_a?(Array)
485
+ value.compact.map { |v| _to_hash(v) }
486
+ elsif value.is_a?(Hash)
487
+ {}.tap do |hash|
488
+ value.each { |k, v| hash[k] = _to_hash(v) }
489
+ end
490
+ elsif value.respond_to? :to_hash
491
+ value.to_hash
492
+ else
493
+ value
494
+ end
495
+ end
496
+
497
+ def to_json(*a)
498
+ to_hash.to_json(*a)
499
+ end
500
+ end
501
+ end