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
@@ -4,8 +4,8 @@ module AftershipAPI::Model
4
4
  class OriginAddressEstimatedDeliveryDateRequest
5
5
 
6
6
  # 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.
7
- # country: String;
8
- attr_accessor :country
7
+ # country_region: String;
8
+ attr_accessor :country_region
9
9
 
10
10
  # 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.
11
11
  # state?: String;
@@ -34,8 +34,8 @@ module AftershipAPI::Model
34
34
  h[k.to_sym] = v
35
35
  }
36
36
 
37
- if attributes.key?(:'country')
38
- self.country = attributes[:'country']
37
+ if attributes.key?(:'country_region')
38
+ self.country_region = attributes[:'country_region']
39
39
  end
40
40
 
41
41
  if attributes.key?(:'state')
@@ -58,7 +58,7 @@ module AftershipAPI::Model
58
58
  # Attribute type mapping.
59
59
  def self.openapi_types
60
60
  {
61
- :'country' => :'String',
61
+ :'country_region' => :'String',
62
62
  :'state' => :'String',
63
63
  :'city' => :'String',
64
64
  :'postal_code' => :'String',
@@ -69,7 +69,7 @@ module AftershipAPI::Model
69
69
  # Attribute mapping from ruby-style variable name to JSON key.
70
70
  def self.attribute_map
71
71
  {
72
- :'country' => :'country',
72
+ :'country_region' => :'country_region',
73
73
  :'state' => :'state',
74
74
  :'city' => :'city',
75
75
  :'postal_code' => :'postal_code',
@@ -4,8 +4,8 @@ module AftershipAPI::Model
4
4
  class OriginAddressEstimatedDeliveryDateResponse
5
5
 
6
6
  # 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.
7
- # country: String;
8
- attr_accessor :country
7
+ # country_region: String;
8
+ attr_accessor :country_region
9
9
 
10
10
  # 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.
11
11
  # state?: String;
@@ -34,8 +34,8 @@ module AftershipAPI::Model
34
34
  h[k.to_sym] = v
35
35
  }
36
36
 
37
- if attributes.key?(:'country')
38
- self.country = attributes[:'country']
37
+ if attributes.key?(:'country_region')
38
+ self.country_region = attributes[:'country_region']
39
39
  end
40
40
 
41
41
  if attributes.key?(:'state')
@@ -58,7 +58,7 @@ module AftershipAPI::Model
58
58
  # Attribute type mapping.
59
59
  def self.openapi_types
60
60
  {
61
- :'country' => :'String',
61
+ :'country_region' => :'String',
62
62
  :'state' => :'String',
63
63
  :'city' => :'String',
64
64
  :'postal_code' => :'String',
@@ -69,7 +69,7 @@ module AftershipAPI::Model
69
69
  # Attribute mapping from ruby-style variable name to JSON key.
70
70
  def self.attribute_map
71
71
  {
72
- :'country' => :'country',
72
+ :'country_region' => :'country_region',
73
73
  :'state' => :'state',
74
74
  :'city' => :'city',
75
75
  :'postal_code' => :'postal_code',
@@ -0,0 +1,193 @@
1
+ # This code was auto generated by AfterShip SDK Generator.
2
+ # Do not edit the class manually.
3
+ module AftershipAPI::Model
4
+ class OriginAddressPredictRequest
5
+
6
+ # 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.
7
+ # country_region: String;
8
+ attr_accessor :country_region
9
+
10
+ # 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.
11
+ # state?: String;
12
+ attr_accessor :state
13
+
14
+ # City of the origin address. Use 3 letters of ISO 3166-1 country/region code for countries/regions without City.
15
+ # city?: String;
16
+ attr_accessor :city
17
+
18
+ # 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.
19
+ # postal_code?: String;
20
+ attr_accessor :postal_code
21
+
22
+ # Raw location of the origin address. A raw address will help AI to identify the accurate location of the origin address.
23
+ # raw_location?: String;
24
+ attr_accessor :raw_location
25
+
26
+ # Initializes the object
27
+ # @param [Hash] attributes Model attributes in the form of hash
28
+ def initialize(attributes = {})
29
+ if (!attributes.is_a?(Hash))
30
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::OriginAddressPredictRequest` initialize method"
31
+ end
32
+
33
+ attributes = attributes.each_with_object({}) { |(k, v), h|
34
+ h[k.to_sym] = v
35
+ }
36
+
37
+ if attributes.key?(:'country_region')
38
+ self.country_region = attributes[:'country_region']
39
+ end
40
+
41
+ if attributes.key?(:'state')
42
+ self.state = attributes[:'state']
43
+ end
44
+
45
+ if attributes.key?(:'city')
46
+ self.city = attributes[:'city']
47
+ end
48
+
49
+ if attributes.key?(:'postal_code')
50
+ self.postal_code = attributes[:'postal_code']
51
+ end
52
+
53
+ if attributes.key?(:'raw_location')
54
+ self.raw_location = attributes[:'raw_location']
55
+ end
56
+ end
57
+
58
+ # Attribute type mapping.
59
+ def self.openapi_types
60
+ {
61
+ :'country_region' => :'String',
62
+ :'state' => :'String',
63
+ :'city' => :'String',
64
+ :'postal_code' => :'String',
65
+ :'raw_location' => :'String',
66
+ }
67
+ end
68
+
69
+ # Attribute mapping from ruby-style variable name to JSON key.
70
+ def self.attribute_map
71
+ {
72
+ :'country_region' => :'country_region',
73
+ :'state' => :'state',
74
+ :'city' => :'city',
75
+ :'postal_code' => :'postal_code',
76
+ :'raw_location' => :'raw_location',
77
+ }
78
+ end
79
+
80
+ # Builds the object from hash
81
+ # @param attributes [Hash] Model attributes in the form of hash
82
+ # @return [Object] Returns the model itself
83
+ def self.build_from_hash(attributes)
84
+ return nil unless attributes.is_a?(Hash)
85
+ attributes = attributes.transform_keys(&:to_sym)
86
+ transformed_hash = {}
87
+ openapi_types.each_pair do |key, type|
88
+ if attributes.key?(key) && attributes[key].nil?
89
+ transformed_hash["#{key}"] = nil
90
+ elsif type =~ /\AArray<(.*)>/i
91
+ # check to ensure the input is an array given that the attribute
92
+ # is documented as an array but the input is not
93
+ if attributes[key].is_a?(Array)
94
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
95
+ end
96
+ elsif !attributes[key].nil?
97
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
98
+ end
99
+ end
100
+ new(transformed_hash)
101
+ end
102
+
103
+ # Deserializes the data based on type
104
+ # @param type [String] Data type
105
+ # @param value [String] Value to be deserialized
106
+ # @return [Object] Deserialized data
107
+ def self._deserialize(type, value)
108
+ case type.to_sym
109
+ when :Time
110
+ Time.parse(value)
111
+ when :Date
112
+ Date.parse(value)
113
+ when :String
114
+ value.to_s
115
+ when :Integer
116
+ value.to_i
117
+ when :Float
118
+ value.to_f
119
+ when :Boolean
120
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
121
+ true
122
+ else
123
+ false
124
+ end
125
+ when :Object
126
+ # generic object (usually a Hash), return directly
127
+ value
128
+ when /\AArray<(?<inner_type>.+)>\z/
129
+ inner_type = Regexp.last_match[:inner_type]
130
+ value.map { |v| _deserialize(inner_type, v) }
131
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
132
+ k_type = Regexp.last_match[:k_type]
133
+ v_type = Regexp.last_match[:v_type]
134
+ {}.tap do |hash|
135
+ value.each do |k, v|
136
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
137
+ end
138
+ end
139
+ else # model
140
+ klass = AftershipAPI::Model.const_get(type)
141
+ klass.build_from_hash(value)
142
+ end
143
+ end
144
+
145
+ # Returns the string representation of the object
146
+ # @return [String] String presentation of the object
147
+ def to_s
148
+ to_hash.to_s
149
+ end
150
+
151
+ # to_body is an alias to to_hash (backward compatibility)
152
+ # @return [Hash] Returns the object in the form of hash
153
+ def to_body
154
+ to_hash
155
+ end
156
+
157
+ # Returns the object in the form of hash
158
+ # @return [Hash] Returns the object in the form of hash
159
+ def to_hash
160
+ hash = {}
161
+ self.class.attribute_map.each_pair do |attr, param|
162
+ value = self.send(attr)
163
+ next if value.nil?
164
+
165
+ hash[param] = _to_hash(value)
166
+ end
167
+ hash
168
+ end
169
+
170
+ # Outputs non-array value in the form of hash
171
+ # For object, use to_hash. Otherwise, just return the value
172
+ # @param value [Object] Any valid value
173
+ # @return [Hash] Returns the value in the form of hash
174
+ def _to_hash(value)
175
+ if value.is_a?(Array)
176
+ value.compact.map { |v| _to_hash(v) }
177
+ elsif value.is_a?(Hash)
178
+ {}.tap do |hash|
179
+ value.each { |k, v| hash[k] = _to_hash(v) }
180
+ end
181
+ elsif value.respond_to? :to_hash
182
+ value.to_hash
183
+ else
184
+ value
185
+ end
186
+ end
187
+
188
+ def to_json(*a)
189
+ to_hash.to_json(*a)
190
+ end
191
+ end
192
+ end
193
+
@@ -0,0 +1,193 @@
1
+ # This code was auto generated by AfterShip SDK Generator.
2
+ # Do not edit the class manually.
3
+ module AftershipAPI::Model
4
+ class OriginAddressPredictResponse
5
+
6
+ # 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.
7
+ # country_region: String;
8
+ attr_accessor :country_region
9
+
10
+ # 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.
11
+ # state?: String;
12
+ attr_accessor :state
13
+
14
+ # City of the origin address. Use 3 letters of ISO 3166-1 country/region code for countries/regions without City.
15
+ # city?: String;
16
+ attr_accessor :city
17
+
18
+ # 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.
19
+ # postal_code?: String;
20
+ attr_accessor :postal_code
21
+
22
+ # Raw location of the origin address. A raw address will help AI to identify the accurate location of the origin address.
23
+ # raw_location?: String;
24
+ attr_accessor :raw_location
25
+
26
+ # Initializes the object
27
+ # @param [Hash] attributes Model attributes in the form of hash
28
+ def initialize(attributes = {})
29
+ if (!attributes.is_a?(Hash))
30
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::OriginAddressPredictResponse` initialize method"
31
+ end
32
+
33
+ attributes = attributes.each_with_object({}) { |(k, v), h|
34
+ h[k.to_sym] = v
35
+ }
36
+
37
+ if attributes.key?(:'country_region')
38
+ self.country_region = attributes[:'country_region']
39
+ end
40
+
41
+ if attributes.key?(:'state')
42
+ self.state = attributes[:'state']
43
+ end
44
+
45
+ if attributes.key?(:'city')
46
+ self.city = attributes[:'city']
47
+ end
48
+
49
+ if attributes.key?(:'postal_code')
50
+ self.postal_code = attributes[:'postal_code']
51
+ end
52
+
53
+ if attributes.key?(:'raw_location')
54
+ self.raw_location = attributes[:'raw_location']
55
+ end
56
+ end
57
+
58
+ # Attribute type mapping.
59
+ def self.openapi_types
60
+ {
61
+ :'country_region' => :'String',
62
+ :'state' => :'String',
63
+ :'city' => :'String',
64
+ :'postal_code' => :'String',
65
+ :'raw_location' => :'String',
66
+ }
67
+ end
68
+
69
+ # Attribute mapping from ruby-style variable name to JSON key.
70
+ def self.attribute_map
71
+ {
72
+ :'country_region' => :'country_region',
73
+ :'state' => :'state',
74
+ :'city' => :'city',
75
+ :'postal_code' => :'postal_code',
76
+ :'raw_location' => :'raw_location',
77
+ }
78
+ end
79
+
80
+ # Builds the object from hash
81
+ # @param attributes [Hash] Model attributes in the form of hash
82
+ # @return [Object] Returns the model itself
83
+ def self.build_from_hash(attributes)
84
+ return nil unless attributes.is_a?(Hash)
85
+ attributes = attributes.transform_keys(&:to_sym)
86
+ transformed_hash = {}
87
+ openapi_types.each_pair do |key, type|
88
+ if attributes.key?(key) && attributes[key].nil?
89
+ transformed_hash["#{key}"] = nil
90
+ elsif type =~ /\AArray<(.*)>/i
91
+ # check to ensure the input is an array given that the attribute
92
+ # is documented as an array but the input is not
93
+ if attributes[key].is_a?(Array)
94
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
95
+ end
96
+ elsif !attributes[key].nil?
97
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
98
+ end
99
+ end
100
+ new(transformed_hash)
101
+ end
102
+
103
+ # Deserializes the data based on type
104
+ # @param type [String] Data type
105
+ # @param value [String] Value to be deserialized
106
+ # @return [Object] Deserialized data
107
+ def self._deserialize(type, value)
108
+ case type.to_sym
109
+ when :Time
110
+ Time.parse(value)
111
+ when :Date
112
+ Date.parse(value)
113
+ when :String
114
+ value.to_s
115
+ when :Integer
116
+ value.to_i
117
+ when :Float
118
+ value.to_f
119
+ when :Boolean
120
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
121
+ true
122
+ else
123
+ false
124
+ end
125
+ when :Object
126
+ # generic object (usually a Hash), return directly
127
+ value
128
+ when /\AArray<(?<inner_type>.+)>\z/
129
+ inner_type = Regexp.last_match[:inner_type]
130
+ value.map { |v| _deserialize(inner_type, v) }
131
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
132
+ k_type = Regexp.last_match[:k_type]
133
+ v_type = Regexp.last_match[:v_type]
134
+ {}.tap do |hash|
135
+ value.each do |k, v|
136
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
137
+ end
138
+ end
139
+ else # model
140
+ klass = AftershipAPI::Model.const_get(type)
141
+ klass.build_from_hash(value)
142
+ end
143
+ end
144
+
145
+ # Returns the string representation of the object
146
+ # @return [String] String presentation of the object
147
+ def to_s
148
+ to_hash.to_s
149
+ end
150
+
151
+ # to_body is an alias to to_hash (backward compatibility)
152
+ # @return [Hash] Returns the object in the form of hash
153
+ def to_body
154
+ to_hash
155
+ end
156
+
157
+ # Returns the object in the form of hash
158
+ # @return [Hash] Returns the object in the form of hash
159
+ def to_hash
160
+ hash = {}
161
+ self.class.attribute_map.each_pair do |attr, param|
162
+ value = self.send(attr)
163
+ next if value.nil?
164
+
165
+ hash[param] = _to_hash(value)
166
+ end
167
+ hash
168
+ end
169
+
170
+ # Outputs non-array value in the form of hash
171
+ # For object, use to_hash. Otherwise, just return the value
172
+ # @param value [Object] Any valid value
173
+ # @return [Hash] Returns the value in the form of hash
174
+ def _to_hash(value)
175
+ if value.is_a?(Array)
176
+ value.compact.map { |v| _to_hash(v) }
177
+ elsif value.is_a?(Hash)
178
+ {}.tap do |hash|
179
+ value.each { |k, v| hash[k] = _to_hash(v) }
180
+ end
181
+ elsif value.respond_to? :to_hash
182
+ value.to_hash
183
+ else
184
+ value
185
+ end
186
+ end
187
+
188
+ def to_json(*a)
189
+ to_hash.to_json(*a)
190
+ end
191
+ end
192
+ end
193
+
@@ -0,0 +1,223 @@
1
+ # This code was auto generated by AfterShip SDK Generator.
2
+ # Do not edit the class manually.
3
+ module AftershipAPI::Model
4
+ class PredictRequest
5
+
6
+ # AfterShip's unique code of courier. Please refer to https://track.aftership.com/couriers/download.
7
+ # slug: String;
8
+ attr_accessor :slug
9
+
10
+ # AfterShip’s unique code represents carrier’s shipping and delivery options. Refer to .
11
+ # service_type_name?: String;
12
+ attr_accessor :service_type_name
13
+
14
+ # The location from where the package is picked up by the carrier to be delivered to the final destination.
15
+ # origin_address: OriginAddressPredictRequest;
16
+ attr_accessor :origin_address
17
+
18
+ # The final destination of the customer where the delivery will be made.
19
+ # destination_address: DestinationAddressPredictRequest;
20
+ attr_accessor :destination_address
21
+
22
+ # AfterShip uses this object to calculate the total weight of the order.
23
+ # weight?: WeightPredictRequest;
24
+ attr_accessor :weight
25
+
26
+ # The number of packages.
27
+ # package_count?: Integer;
28
+ attr_accessor :package_count
29
+
30
+ # The local pickup time in the origin address time zone of the package.Either `pickup_time` or `estimated_pickup` is required.
31
+ # pickup_time?: String;
32
+ attr_accessor :pickup_time
33
+
34
+ # The local pickup time of the package.Either `pickup_time` or `estimated_pickup` is required.
35
+ # estimated_pickup?: EstimatedPickupPredictRequest;
36
+ attr_accessor :estimated_pickup
37
+
38
+ # Initializes the object
39
+ # @param [Hash] attributes Model attributes in the form of hash
40
+ def initialize(attributes = {})
41
+ if (!attributes.is_a?(Hash))
42
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AftershipAPI::PredictRequest` initialize method"
43
+ end
44
+
45
+ attributes = attributes.each_with_object({}) { |(k, v), h|
46
+ h[k.to_sym] = v
47
+ }
48
+
49
+ if attributes.key?(:'slug')
50
+ self.slug = attributes[:'slug']
51
+ end
52
+
53
+ if attributes.key?(:'service_type_name')
54
+ self.service_type_name = attributes[:'service_type_name']
55
+ end
56
+
57
+ if attributes.key?(:'origin_address')
58
+ self.origin_address = attributes[:'origin_address']
59
+ end
60
+
61
+ if attributes.key?(:'destination_address')
62
+ self.destination_address = attributes[:'destination_address']
63
+ end
64
+
65
+ if attributes.key?(:'weight')
66
+ self.weight = attributes[:'weight']
67
+ end
68
+
69
+ if attributes.key?(:'package_count')
70
+ self.package_count = attributes[:'package_count']
71
+ end
72
+
73
+ if attributes.key?(:'pickup_time')
74
+ self.pickup_time = attributes[:'pickup_time']
75
+ end
76
+
77
+ if attributes.key?(:'estimated_pickup')
78
+ self.estimated_pickup = attributes[:'estimated_pickup']
79
+ end
80
+ end
81
+
82
+ # Attribute type mapping.
83
+ def self.openapi_types
84
+ {
85
+ :'slug' => :'String',
86
+ :'service_type_name' => :'String',
87
+ :'origin_address' => :'OriginAddressPredictRequest',
88
+ :'destination_address' => :'DestinationAddressPredictRequest',
89
+ :'weight' => :'WeightPredictRequest',
90
+ :'package_count' => :'Integer',
91
+ :'pickup_time' => :'String',
92
+ :'estimated_pickup' => :'EstimatedPickupPredictRequest',
93
+ }
94
+ end
95
+
96
+ # Attribute mapping from ruby-style variable name to JSON key.
97
+ def self.attribute_map
98
+ {
99
+ :'slug' => :'slug',
100
+ :'service_type_name' => :'service_type_name',
101
+ :'origin_address' => :'origin_address',
102
+ :'destination_address' => :'destination_address',
103
+ :'weight' => :'weight',
104
+ :'package_count' => :'package_count',
105
+ :'pickup_time' => :'pickup_time',
106
+ :'estimated_pickup' => :'estimated_pickup',
107
+ }
108
+ end
109
+
110
+ # Builds the object from hash
111
+ # @param attributes [Hash] Model attributes in the form of hash
112
+ # @return [Object] Returns the model itself
113
+ def self.build_from_hash(attributes)
114
+ return nil unless attributes.is_a?(Hash)
115
+ attributes = attributes.transform_keys(&:to_sym)
116
+ transformed_hash = {}
117
+ openapi_types.each_pair do |key, type|
118
+ if attributes.key?(key) && attributes[key].nil?
119
+ transformed_hash["#{key}"] = nil
120
+ elsif type =~ /\AArray<(.*)>/i
121
+ # check to ensure the input is an array given that the attribute
122
+ # is documented as an array but the input is not
123
+ if attributes[key].is_a?(Array)
124
+ transformed_hash["#{key}"] = attributes[key].map { |v| _deserialize($1, v) }
125
+ end
126
+ elsif !attributes[key].nil?
127
+ transformed_hash["#{key}"] = _deserialize(type, attributes[key])
128
+ end
129
+ end
130
+ new(transformed_hash)
131
+ end
132
+
133
+ # Deserializes the data based on type
134
+ # @param type [String] Data type
135
+ # @param value [String] Value to be deserialized
136
+ # @return [Object] Deserialized data
137
+ def self._deserialize(type, value)
138
+ case type.to_sym
139
+ when :Time
140
+ Time.parse(value)
141
+ when :Date
142
+ Date.parse(value)
143
+ when :String
144
+ value.to_s
145
+ when :Integer
146
+ value.to_i
147
+ when :Float
148
+ value.to_f
149
+ when :Boolean
150
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
151
+ true
152
+ else
153
+ false
154
+ end
155
+ when :Object
156
+ # generic object (usually a Hash), return directly
157
+ value
158
+ when /\AArray<(?<inner_type>.+)>\z/
159
+ inner_type = Regexp.last_match[:inner_type]
160
+ value.map { |v| _deserialize(inner_type, v) }
161
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
162
+ k_type = Regexp.last_match[:k_type]
163
+ v_type = Regexp.last_match[:v_type]
164
+ {}.tap do |hash|
165
+ value.each do |k, v|
166
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
167
+ end
168
+ end
169
+ else # model
170
+ klass = AftershipAPI::Model.const_get(type)
171
+ klass.build_from_hash(value)
172
+ end
173
+ end
174
+
175
+ # Returns the string representation of the object
176
+ # @return [String] String presentation of the object
177
+ def to_s
178
+ to_hash.to_s
179
+ end
180
+
181
+ # to_body is an alias to to_hash (backward compatibility)
182
+ # @return [Hash] Returns the object in the form of hash
183
+ def to_body
184
+ to_hash
185
+ end
186
+
187
+ # Returns the object in the form of hash
188
+ # @return [Hash] Returns the object in the form of hash
189
+ def to_hash
190
+ hash = {}
191
+ self.class.attribute_map.each_pair do |attr, param|
192
+ value = self.send(attr)
193
+ next if value.nil?
194
+
195
+ hash[param] = _to_hash(value)
196
+ end
197
+ hash
198
+ end
199
+
200
+ # Outputs non-array value in the form of hash
201
+ # For object, use to_hash. Otherwise, just return the value
202
+ # @param value [Object] Any valid value
203
+ # @return [Hash] Returns the value in the form of hash
204
+ def _to_hash(value)
205
+ if value.is_a?(Array)
206
+ value.compact.map { |v| _to_hash(v) }
207
+ elsif value.is_a?(Hash)
208
+ {}.tap do |hash|
209
+ value.each { |k, v| hash[k] = _to_hash(v) }
210
+ end
211
+ elsif value.respond_to? :to_hash
212
+ value.to_hash
213
+ else
214
+ value
215
+ end
216
+ end
217
+
218
+ def to_json(*a)
219
+ to_hash.to_json(*a)
220
+ end
221
+ end
222
+ end
223
+