aftership-tracking-sdk 9.0.0 → 10.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +14 -13
  4. data/lib/aftership-tracking-sdk/api/courier.rb +3 -3
  5. data/lib/aftership-tracking-sdk/api/estimated_delivery_date.rb +55 -1
  6. data/lib/aftership-tracking-sdk/api/tracking.rb +16 -16
  7. data/lib/aftership-tracking-sdk/models/additional_fields_v1.rb +3 -3
  8. data/lib/aftership-tracking-sdk/models/checkpoint.rb +22 -12
  9. data/lib/aftership-tracking-sdk/models/courier.rb +7 -7
  10. data/lib/aftership-tracking-sdk/models/create_tracking_request.rb +47 -67
  11. data/lib/aftership-tracking-sdk/models/create_tracking_response.rb +63 -83
  12. data/lib/aftership-tracking-sdk/models/{next_couriers_tracking.rb → customers_create_tracking_request.rb} +37 -37
  13. data/lib/aftership-tracking-sdk/models/customers_create_tracking_response.rb +193 -0
  14. data/lib/aftership-tracking-sdk/models/customers_delete_tracking_by_id_response.rb +193 -0
  15. data/lib/aftership-tracking-sdk/models/customers_get_tracking_by_id_response.rb +193 -0
  16. data/lib/aftership-tracking-sdk/models/customers_mark_tracking_completed_by_id_response.rb +193 -0
  17. data/lib/aftership-tracking-sdk/models/customers_retrack_tracking_by_id_response.rb +193 -0
  18. data/lib/aftership-tracking-sdk/models/customers_tracking.rb +193 -0
  19. data/lib/aftership-tracking-sdk/models/customers_update_tracking_by_id_request.rb +193 -0
  20. data/lib/aftership-tracking-sdk/models/customers_update_tracking_by_id_response.rb +193 -0
  21. data/lib/aftership-tracking-sdk/models/delete_tracking_by_id_response.rb +63 -83
  22. data/lib/aftership-tracking-sdk/models/destination_address_estimated_delivery_date_request.rb +6 -6
  23. data/lib/aftership-tracking-sdk/models/destination_address_estimated_delivery_date_response.rb +6 -6
  24. data/lib/aftership-tracking-sdk/models/destination_address_predict_request.rb +193 -0
  25. data/lib/aftership-tracking-sdk/models/destination_address_predict_response.rb +193 -0
  26. data/lib/aftership-tracking-sdk/models/detect_courier_request.rb +24 -24
  27. data/lib/aftership-tracking-sdk/models/estimated_pickup_predict_request.rb +183 -0
  28. data/lib/aftership-tracking-sdk/models/estimated_pickup_predict_response.rb +193 -0
  29. data/lib/aftership-tracking-sdk/models/{next_couriers_delete_tracking_by_id_response.rb → first_mile_create_tracking_response.rb} +29 -29
  30. data/lib/aftership-tracking-sdk/models/{next_couriers_get_tracking_by_id_response.rb → first_mile_delete_tracking_by_id_response.rb} +29 -29
  31. data/lib/aftership-tracking-sdk/models/first_mile_get_tracking_by_id_response.rb +193 -0
  32. data/lib/aftership-tracking-sdk/models/first_mile_mark_tracking_completed_by_id_response.rb +193 -0
  33. data/lib/aftership-tracking-sdk/models/first_mile_retrack_tracking_by_id_response.rb +193 -0
  34. data/lib/aftership-tracking-sdk/models/{next_couriers_mark_tracking_completed_by_id_response.rb → first_mile_tracking.rb} +29 -29
  35. data/lib/aftership-tracking-sdk/models/first_mile_update_tracking_by_id_response.rb +193 -0
  36. data/lib/aftership-tracking-sdk/models/get_tracking_by_id_response.rb +63 -83
  37. data/lib/aftership-tracking-sdk/models/{next_couriers_create_tracking_request.rb → last_mile_create_tracking_request.rb} +13 -13
  38. data/lib/aftership-tracking-sdk/models/last_mile_create_tracking_response.rb +203 -0
  39. data/lib/aftership-tracking-sdk/models/last_mile_delete_tracking_by_id_response.rb +203 -0
  40. data/lib/aftership-tracking-sdk/models/last_mile_get_tracking_by_id_response.rb +203 -0
  41. data/lib/aftership-tracking-sdk/models/last_mile_mark_tracking_completed_by_id_response.rb +203 -0
  42. data/lib/aftership-tracking-sdk/models/last_mile_retrack_tracking_by_id_response.rb +203 -0
  43. data/lib/aftership-tracking-sdk/models/{next_couriers_create_tracking_response.rb → last_mile_tracking.rb} +33 -23
  44. data/lib/aftership-tracking-sdk/models/last_mile_update_tracking_by_id_response.rb +203 -0
  45. data/lib/aftership-tracking-sdk/models/mark_tracking_completed_by_id_response.rb +63 -83
  46. data/lib/aftership-tracking-sdk/models/order_processing_time_estimated_pickup_predict_request.rb +163 -0
  47. data/lib/aftership-tracking-sdk/models/order_processing_time_estimated_pickup_predict_response.rb +163 -0
  48. data/lib/aftership-tracking-sdk/models/origin_address_estimated_delivery_date_request.rb +6 -6
  49. data/lib/aftership-tracking-sdk/models/origin_address_estimated_delivery_date_response.rb +6 -6
  50. data/lib/aftership-tracking-sdk/models/origin_address_predict_request.rb +193 -0
  51. data/lib/aftership-tracking-sdk/models/origin_address_predict_response.rb +193 -0
  52. data/lib/aftership-tracking-sdk/models/predict_request.rb +223 -0
  53. data/lib/aftership-tracking-sdk/models/predict_response.rb +273 -0
  54. data/lib/aftership-tracking-sdk/models/retrack_tracking_by_id_response.rb +63 -83
  55. data/lib/aftership-tracking-sdk/models/tracking.rb +63 -83
  56. data/lib/aftership-tracking-sdk/models/update_tracking_by_id_request.rb +37 -57
  57. data/lib/aftership-tracking-sdk/models/update_tracking_by_id_response.rb +63 -83
  58. data/lib/aftership-tracking-sdk/models/weight_predict_request.rb +163 -0
  59. data/lib/aftership-tracking-sdk/models/weight_predict_response.rb +163 -0
  60. data/lib/aftership-tracking-sdk/version.rb +1 -1
  61. metadata +41 -13
  62. data/lib/aftership-tracking-sdk/models/next_couriers_retrack_tracking_by_id_response.rb +0 -193
  63. data/lib/aftership-tracking-sdk/models/next_couriers_update_tracking_by_id_response.rb +0 -193
@@ -0,0 +1,203 @@
1
+ # This code was auto generated by AfterShip SDK Generator.
2
+ # Do not edit the class manually.
3
+ module AftershipAPI::Model
4
+ class LastMileDeleteTrackingByIdResponse
5
+
6
+ # The tracking number of the last-mile carrier.
7
+ # tracking_number?: String;
8
+ attr_accessor :tracking_number
9
+
10
+ # The unique code of the carrier responsible for the last-mile of the shipment. Find all the courier slugs .
11
+ # slug?: String;
12
+ attr_accessor :slug
13
+
14
+ # 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
15
+ # transit_time?: String;
16
+ attr_accessor :transit_time
17
+
18
+ # 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".
19
+ # courier_tracking_link?: String;
20
+ attr_accessor :courier_tracking_link
21
+
22
+ # 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".
23
+ # courier_redirect_link?: String;
24
+ attr_accessor :courier_redirect_link
25
+
26
+ # The field indicates the source of last-mile carrier.
27
+ # source?: String;
28
+ attr_accessor :source
29
+
30
+ # Initializes the object
31
+ # @param [Hash] attributes Model attributes in the form of hash
32
+ def initialize(attributes = {})
33
+ if (!attributes.is_a?(Hash))
34
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::LastMileDeleteTrackingByIdResponse` initialize method"
35
+ end
36
+
37
+ attributes = attributes.each_with_object({}) { |(k, v), h|
38
+ h[k.to_sym] = v
39
+ }
40
+
41
+ if attributes.key?(:'tracking_number')
42
+ self.tracking_number = attributes[:'tracking_number']
43
+ end
44
+
45
+ if attributes.key?(:'slug')
46
+ self.slug = attributes[:'slug']
47
+ end
48
+
49
+ if attributes.key?(:'transit_time')
50
+ self.transit_time = attributes[:'transit_time']
51
+ end
52
+
53
+ if attributes.key?(:'courier_tracking_link')
54
+ self.courier_tracking_link = attributes[:'courier_tracking_link']
55
+ end
56
+
57
+ if attributes.key?(:'courier_redirect_link')
58
+ self.courier_redirect_link = attributes[:'courier_redirect_link']
59
+ end
60
+
61
+ if attributes.key?(:'source')
62
+ self.source = attributes[:'source']
63
+ end
64
+ end
65
+
66
+ # Attribute type mapping.
67
+ def self.openapi_types
68
+ {
69
+ :'tracking_number' => :'String',
70
+ :'slug' => :'String',
71
+ :'transit_time' => :'String',
72
+ :'courier_tracking_link' => :'String',
73
+ :'courier_redirect_link' => :'String',
74
+ :'source' => :'String',
75
+ }
76
+ end
77
+
78
+ # Attribute mapping from ruby-style variable name to JSON key.
79
+ def self.attribute_map
80
+ {
81
+ :'tracking_number' => :'tracking_number',
82
+ :'slug' => :'slug',
83
+ :'transit_time' => :'transit_time',
84
+ :'courier_tracking_link' => :'courier_tracking_link',
85
+ :'courier_redirect_link' => :'courier_redirect_link',
86
+ :'source' => :'source',
87
+ }
88
+ end
89
+
90
+ # Builds the object from hash
91
+ # @param attributes [Hash] Model attributes in the form of hash
92
+ # @return [Object] Returns the model itself
93
+ def self.build_from_hash(attributes)
94
+ return nil unless attributes.is_a?(Hash)
95
+ attributes = attributes.transform_keys(&:to_sym)
96
+ transformed_hash = {}
97
+ openapi_types.each_pair do |key, type|
98
+ if attributes.key?(key) && attributes[key].nil?
99
+ transformed_hash["#{key}"] = nil
100
+ elsif type =~ /\AArray<(.*)>/i
101
+ # check to ensure the input is an array given that the attribute
102
+ # is documented as an array but the input is not
103
+ if attributes[key].is_a?(Array)
104
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
105
+ end
106
+ elsif !attributes[key].nil?
107
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
108
+ end
109
+ end
110
+ new(transformed_hash)
111
+ end
112
+
113
+ # Deserializes the data based on type
114
+ # @param type [String] Data type
115
+ # @param value [String] Value to be deserialized
116
+ # @return [Object] Deserialized data
117
+ def self._deserialize(type, value)
118
+ case type.to_sym
119
+ when :Time
120
+ Time.parse(value)
121
+ when :Date
122
+ Date.parse(value)
123
+ when :String
124
+ value.to_s
125
+ when :Integer
126
+ value.to_i
127
+ when :Float
128
+ value.to_f
129
+ when :Boolean
130
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
131
+ true
132
+ else
133
+ false
134
+ end
135
+ when :Object
136
+ # generic object (usually a Hash), return directly
137
+ value
138
+ when /\AArray<(?<inner_type>.+)>\z/
139
+ inner_type = Regexp.last_match[:inner_type]
140
+ value.map { |v| _deserialize(inner_type, v) }
141
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
142
+ k_type = Regexp.last_match[:k_type]
143
+ v_type = Regexp.last_match[:v_type]
144
+ {}.tap do |hash|
145
+ value.each do |k, v|
146
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
147
+ end
148
+ end
149
+ else # model
150
+ klass = AftershipAPI::Model.const_get(type)
151
+ klass.build_from_hash(value)
152
+ end
153
+ end
154
+
155
+ # Returns the string representation of the object
156
+ # @return [String] String presentation of the object
157
+ def to_s
158
+ to_hash.to_s
159
+ end
160
+
161
+ # to_body is an alias to to_hash (backward compatibility)
162
+ # @return [Hash] Returns the object in the form of hash
163
+ def to_body
164
+ to_hash
165
+ end
166
+
167
+ # Returns the object in the form of hash
168
+ # @return [Hash] Returns the object in the form of hash
169
+ def to_hash
170
+ hash = {}
171
+ self.class.attribute_map.each_pair do |attr, param|
172
+ value = self.send(attr)
173
+ next if value.nil?
174
+
175
+ hash[param] = _to_hash(value)
176
+ end
177
+ hash
178
+ end
179
+
180
+ # Outputs non-array value in the form of hash
181
+ # For object, use to_hash. Otherwise, just return the value
182
+ # @param value [Object] Any valid value
183
+ # @return [Hash] Returns the value in the form of hash
184
+ def _to_hash(value)
185
+ if value.is_a?(Array)
186
+ value.compact.map { |v| _to_hash(v) }
187
+ elsif value.is_a?(Hash)
188
+ {}.tap do |hash|
189
+ value.each { |k, v| hash[k] = _to_hash(v) }
190
+ end
191
+ elsif value.respond_to? :to_hash
192
+ value.to_hash
193
+ else
194
+ value
195
+ end
196
+ end
197
+
198
+ def to_json(*a)
199
+ to_hash.to_json(*a)
200
+ end
201
+ end
202
+ end
203
+
@@ -0,0 +1,203 @@
1
+ # This code was auto generated by AfterShip SDK Generator.
2
+ # Do not edit the class manually.
3
+ module AftershipAPI::Model
4
+ class LastMileGetTrackingByIdResponse
5
+
6
+ # The tracking number of the last-mile carrier.
7
+ # tracking_number?: String;
8
+ attr_accessor :tracking_number
9
+
10
+ # The unique code of the carrier responsible for the last-mile of the shipment. Find all the courier slugs .
11
+ # slug?: String;
12
+ attr_accessor :slug
13
+
14
+ # 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
15
+ # transit_time?: String;
16
+ attr_accessor :transit_time
17
+
18
+ # 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".
19
+ # courier_tracking_link?: String;
20
+ attr_accessor :courier_tracking_link
21
+
22
+ # 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".
23
+ # courier_redirect_link?: String;
24
+ attr_accessor :courier_redirect_link
25
+
26
+ # The field indicates the source of last-mile carrier.
27
+ # source?: String;
28
+ attr_accessor :source
29
+
30
+ # Initializes the object
31
+ # @param [Hash] attributes Model attributes in the form of hash
32
+ def initialize(attributes = {})
33
+ if (!attributes.is_a?(Hash))
34
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::LastMileGetTrackingByIdResponse` initialize method"
35
+ end
36
+
37
+ attributes = attributes.each_with_object({}) { |(k, v), h|
38
+ h[k.to_sym] = v
39
+ }
40
+
41
+ if attributes.key?(:'tracking_number')
42
+ self.tracking_number = attributes[:'tracking_number']
43
+ end
44
+
45
+ if attributes.key?(:'slug')
46
+ self.slug = attributes[:'slug']
47
+ end
48
+
49
+ if attributes.key?(:'transit_time')
50
+ self.transit_time = attributes[:'transit_time']
51
+ end
52
+
53
+ if attributes.key?(:'courier_tracking_link')
54
+ self.courier_tracking_link = attributes[:'courier_tracking_link']
55
+ end
56
+
57
+ if attributes.key?(:'courier_redirect_link')
58
+ self.courier_redirect_link = attributes[:'courier_redirect_link']
59
+ end
60
+
61
+ if attributes.key?(:'source')
62
+ self.source = attributes[:'source']
63
+ end
64
+ end
65
+
66
+ # Attribute type mapping.
67
+ def self.openapi_types
68
+ {
69
+ :'tracking_number' => :'String',
70
+ :'slug' => :'String',
71
+ :'transit_time' => :'String',
72
+ :'courier_tracking_link' => :'String',
73
+ :'courier_redirect_link' => :'String',
74
+ :'source' => :'String',
75
+ }
76
+ end
77
+
78
+ # Attribute mapping from ruby-style variable name to JSON key.
79
+ def self.attribute_map
80
+ {
81
+ :'tracking_number' => :'tracking_number',
82
+ :'slug' => :'slug',
83
+ :'transit_time' => :'transit_time',
84
+ :'courier_tracking_link' => :'courier_tracking_link',
85
+ :'courier_redirect_link' => :'courier_redirect_link',
86
+ :'source' => :'source',
87
+ }
88
+ end
89
+
90
+ # Builds the object from hash
91
+ # @param attributes [Hash] Model attributes in the form of hash
92
+ # @return [Object] Returns the model itself
93
+ def self.build_from_hash(attributes)
94
+ return nil unless attributes.is_a?(Hash)
95
+ attributes = attributes.transform_keys(&:to_sym)
96
+ transformed_hash = {}
97
+ openapi_types.each_pair do |key, type|
98
+ if attributes.key?(key) && attributes[key].nil?
99
+ transformed_hash["#{key}"] = nil
100
+ elsif type =~ /\AArray<(.*)>/i
101
+ # check to ensure the input is an array given that the attribute
102
+ # is documented as an array but the input is not
103
+ if attributes[key].is_a?(Array)
104
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
105
+ end
106
+ elsif !attributes[key].nil?
107
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
108
+ end
109
+ end
110
+ new(transformed_hash)
111
+ end
112
+
113
+ # Deserializes the data based on type
114
+ # @param type [String] Data type
115
+ # @param value [String] Value to be deserialized
116
+ # @return [Object] Deserialized data
117
+ def self._deserialize(type, value)
118
+ case type.to_sym
119
+ when :Time
120
+ Time.parse(value)
121
+ when :Date
122
+ Date.parse(value)
123
+ when :String
124
+ value.to_s
125
+ when :Integer
126
+ value.to_i
127
+ when :Float
128
+ value.to_f
129
+ when :Boolean
130
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
131
+ true
132
+ else
133
+ false
134
+ end
135
+ when :Object
136
+ # generic object (usually a Hash), return directly
137
+ value
138
+ when /\AArray<(?<inner_type>.+)>\z/
139
+ inner_type = Regexp.last_match[:inner_type]
140
+ value.map { |v| _deserialize(inner_type, v) }
141
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
142
+ k_type = Regexp.last_match[:k_type]
143
+ v_type = Regexp.last_match[:v_type]
144
+ {}.tap do |hash|
145
+ value.each do |k, v|
146
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
147
+ end
148
+ end
149
+ else # model
150
+ klass = AftershipAPI::Model.const_get(type)
151
+ klass.build_from_hash(value)
152
+ end
153
+ end
154
+
155
+ # Returns the string representation of the object
156
+ # @return [String] String presentation of the object
157
+ def to_s
158
+ to_hash.to_s
159
+ end
160
+
161
+ # to_body is an alias to to_hash (backward compatibility)
162
+ # @return [Hash] Returns the object in the form of hash
163
+ def to_body
164
+ to_hash
165
+ end
166
+
167
+ # Returns the object in the form of hash
168
+ # @return [Hash] Returns the object in the form of hash
169
+ def to_hash
170
+ hash = {}
171
+ self.class.attribute_map.each_pair do |attr, param|
172
+ value = self.send(attr)
173
+ next if value.nil?
174
+
175
+ hash[param] = _to_hash(value)
176
+ end
177
+ hash
178
+ end
179
+
180
+ # Outputs non-array value in the form of hash
181
+ # For object, use to_hash. Otherwise, just return the value
182
+ # @param value [Object] Any valid value
183
+ # @return [Hash] Returns the value in the form of hash
184
+ def _to_hash(value)
185
+ if value.is_a?(Array)
186
+ value.compact.map { |v| _to_hash(v) }
187
+ elsif value.is_a?(Hash)
188
+ {}.tap do |hash|
189
+ value.each { |k, v| hash[k] = _to_hash(v) }
190
+ end
191
+ elsif value.respond_to? :to_hash
192
+ value.to_hash
193
+ else
194
+ value
195
+ end
196
+ end
197
+
198
+ def to_json(*a)
199
+ to_hash.to_json(*a)
200
+ end
201
+ end
202
+ end
203
+
@@ -0,0 +1,203 @@
1
+ # This code was auto generated by AfterShip SDK Generator.
2
+ # Do not edit the class manually.
3
+ module AftershipAPI::Model
4
+ class LastMileMarkTrackingCompletedByIdResponse
5
+
6
+ # The tracking number of the last-mile carrier.
7
+ # tracking_number?: String;
8
+ attr_accessor :tracking_number
9
+
10
+ # The unique code of the carrier responsible for the last-mile of the shipment. Find all the courier slugs .
11
+ # slug?: String;
12
+ attr_accessor :slug
13
+
14
+ # 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
15
+ # transit_time?: String;
16
+ attr_accessor :transit_time
17
+
18
+ # 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".
19
+ # courier_tracking_link?: String;
20
+ attr_accessor :courier_tracking_link
21
+
22
+ # 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".
23
+ # courier_redirect_link?: String;
24
+ attr_accessor :courier_redirect_link
25
+
26
+ # The field indicates the source of last-mile carrier.
27
+ # source?: String;
28
+ attr_accessor :source
29
+
30
+ # Initializes the object
31
+ # @param [Hash] attributes Model attributes in the form of hash
32
+ def initialize(attributes = {})
33
+ if (!attributes.is_a?(Hash))
34
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::LastMileMarkTrackingCompletedByIdResponse` initialize method"
35
+ end
36
+
37
+ attributes = attributes.each_with_object({}) { |(k, v), h|
38
+ h[k.to_sym] = v
39
+ }
40
+
41
+ if attributes.key?(:'tracking_number')
42
+ self.tracking_number = attributes[:'tracking_number']
43
+ end
44
+
45
+ if attributes.key?(:'slug')
46
+ self.slug = attributes[:'slug']
47
+ end
48
+
49
+ if attributes.key?(:'transit_time')
50
+ self.transit_time = attributes[:'transit_time']
51
+ end
52
+
53
+ if attributes.key?(:'courier_tracking_link')
54
+ self.courier_tracking_link = attributes[:'courier_tracking_link']
55
+ end
56
+
57
+ if attributes.key?(:'courier_redirect_link')
58
+ self.courier_redirect_link = attributes[:'courier_redirect_link']
59
+ end
60
+
61
+ if attributes.key?(:'source')
62
+ self.source = attributes[:'source']
63
+ end
64
+ end
65
+
66
+ # Attribute type mapping.
67
+ def self.openapi_types
68
+ {
69
+ :'tracking_number' => :'String',
70
+ :'slug' => :'String',
71
+ :'transit_time' => :'String',
72
+ :'courier_tracking_link' => :'String',
73
+ :'courier_redirect_link' => :'String',
74
+ :'source' => :'String',
75
+ }
76
+ end
77
+
78
+ # Attribute mapping from ruby-style variable name to JSON key.
79
+ def self.attribute_map
80
+ {
81
+ :'tracking_number' => :'tracking_number',
82
+ :'slug' => :'slug',
83
+ :'transit_time' => :'transit_time',
84
+ :'courier_tracking_link' => :'courier_tracking_link',
85
+ :'courier_redirect_link' => :'courier_redirect_link',
86
+ :'source' => :'source',
87
+ }
88
+ end
89
+
90
+ # Builds the object from hash
91
+ # @param attributes [Hash] Model attributes in the form of hash
92
+ # @return [Object] Returns the model itself
93
+ def self.build_from_hash(attributes)
94
+ return nil unless attributes.is_a?(Hash)
95
+ attributes = attributes.transform_keys(&:to_sym)
96
+ transformed_hash = {}
97
+ openapi_types.each_pair do |key, type|
98
+ if attributes.key?(key) && attributes[key].nil?
99
+ transformed_hash["#{key}"] = nil
100
+ elsif type =~ /\AArray<(.*)>/i
101
+ # check to ensure the input is an array given that the attribute
102
+ # is documented as an array but the input is not
103
+ if attributes[key].is_a?(Array)
104
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
105
+ end
106
+ elsif !attributes[key].nil?
107
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
108
+ end
109
+ end
110
+ new(transformed_hash)
111
+ end
112
+
113
+ # Deserializes the data based on type
114
+ # @param type [String] Data type
115
+ # @param value [String] Value to be deserialized
116
+ # @return [Object] Deserialized data
117
+ def self._deserialize(type, value)
118
+ case type.to_sym
119
+ when :Time
120
+ Time.parse(value)
121
+ when :Date
122
+ Date.parse(value)
123
+ when :String
124
+ value.to_s
125
+ when :Integer
126
+ value.to_i
127
+ when :Float
128
+ value.to_f
129
+ when :Boolean
130
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
131
+ true
132
+ else
133
+ false
134
+ end
135
+ when :Object
136
+ # generic object (usually a Hash), return directly
137
+ value
138
+ when /\AArray<(?<inner_type>.+)>\z/
139
+ inner_type = Regexp.last_match[:inner_type]
140
+ value.map { |v| _deserialize(inner_type, v) }
141
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
142
+ k_type = Regexp.last_match[:k_type]
143
+ v_type = Regexp.last_match[:v_type]
144
+ {}.tap do |hash|
145
+ value.each do |k, v|
146
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
147
+ end
148
+ end
149
+ else # model
150
+ klass = AftershipAPI::Model.const_get(type)
151
+ klass.build_from_hash(value)
152
+ end
153
+ end
154
+
155
+ # Returns the string representation of the object
156
+ # @return [String] String presentation of the object
157
+ def to_s
158
+ to_hash.to_s
159
+ end
160
+
161
+ # to_body is an alias to to_hash (backward compatibility)
162
+ # @return [Hash] Returns the object in the form of hash
163
+ def to_body
164
+ to_hash
165
+ end
166
+
167
+ # Returns the object in the form of hash
168
+ # @return [Hash] Returns the object in the form of hash
169
+ def to_hash
170
+ hash = {}
171
+ self.class.attribute_map.each_pair do |attr, param|
172
+ value = self.send(attr)
173
+ next if value.nil?
174
+
175
+ hash[param] = _to_hash(value)
176
+ end
177
+ hash
178
+ end
179
+
180
+ # Outputs non-array value in the form of hash
181
+ # For object, use to_hash. Otherwise, just return the value
182
+ # @param value [Object] Any valid value
183
+ # @return [Hash] Returns the value in the form of hash
184
+ def _to_hash(value)
185
+ if value.is_a?(Array)
186
+ value.compact.map { |v| _to_hash(v) }
187
+ elsif value.is_a?(Hash)
188
+ {}.tap do |hash|
189
+ value.each { |k, v| hash[k] = _to_hash(v) }
190
+ end
191
+ elsif value.respond_to? :to_hash
192
+ value.to_hash
193
+ else
194
+ value
195
+ end
196
+ end
197
+
198
+ def to_json(*a)
199
+ to_hash.to_json(*a)
200
+ end
201
+ end
202
+ end
203
+