ultracart_api 3.10.164 → 3.10.166

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +29 -4
  3. data/docs/CartPayment.md +1 -0
  4. data/docs/CartPaymentHealthBenefitCard.md +13 -0
  5. data/docs/OrderPayment.md +1 -0
  6. data/docs/OrderPaymentHealthBenefitCard.md +13 -0
  7. data/docs/WorkflowApi.md +436 -0
  8. data/docs/WorkflowAttachment.md +12 -0
  9. data/docs/WorkflowAttachmentUploadUrl.md +9 -0
  10. data/docs/WorkflowAttachmentUploadUrlResponse.md +12 -0
  11. data/docs/WorkflowGroup.md +9 -0
  12. data/docs/WorkflowGroupsResponse.md +12 -0
  13. data/docs/WorkflowNote.md +13 -0
  14. data/docs/WorkflowTask.md +29 -0
  15. data/docs/WorkflowTaskHistory.md +11 -0
  16. data/docs/WorkflowTaskResponse.md +12 -0
  17. data/docs/WorkflowTasksRequest.md +24 -0
  18. data/docs/WorkflowTasksResponse.md +12 -0
  19. data/docs/WorkflowUser.md +10 -0
  20. data/docs/WorkflowUsersResponse.md +12 -0
  21. data/lib/ultracart_api/api/workflow_api.rb +497 -0
  22. data/lib/ultracart_api/models/cart_payment.rb +10 -1
  23. data/lib/ultracart_api/models/cart_payment_health_benefit_card.rb +235 -0
  24. data/lib/ultracart_api/models/order_payment.rb +12 -3
  25. data/lib/ultracart_api/models/order_payment_health_benefit_card.rb +235 -0
  26. data/lib/ultracart_api/models/workflow_attachment.rb +225 -0
  27. data/lib/ultracart_api/models/workflow_attachment_upload_url.rb +193 -0
  28. data/lib/ultracart_api/models/workflow_attachment_upload_url_response.rb +221 -0
  29. data/lib/ultracart_api/models/workflow_group.rb +195 -0
  30. data/lib/ultracart_api/models/workflow_groups_response.rb +224 -0
  31. data/lib/ultracart_api/models/workflow_note.rb +236 -0
  32. data/lib/ultracart_api/models/workflow_task.rb +458 -0
  33. data/lib/ultracart_api/models/workflow_task_history.rb +214 -0
  34. data/lib/ultracart_api/models/workflow_task_response.rb +221 -0
  35. data/lib/ultracart_api/models/workflow_tasks_request.rb +402 -0
  36. data/lib/ultracart_api/models/workflow_tasks_response.rb +224 -0
  37. data/lib/ultracart_api/models/workflow_user.rb +205 -0
  38. data/lib/ultracart_api/models/workflow_users_response.rb +224 -0
  39. data/lib/ultracart_api/version.rb +1 -1
  40. data/lib/ultracart_api.rb +16 -0
  41. metadata +34 -2
@@ -0,0 +1,235 @@
1
+ =begin
2
+ #UltraCart Rest API V2
3
+
4
+ #UltraCart REST API Version 2
5
+
6
+ OpenAPI spec version: 2.0.0
7
+ Contact: support@ultracart.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.15-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module UltracartClient
16
+ class CartPaymentHealthBenefitCard
17
+ # Health benefit expiration month (1-12)
18
+ attr_accessor :health_benefit_card_expiration_month
19
+
20
+ # Health benefit card expiration year (four digit year)
21
+ attr_accessor :health_benefit_card_expiration_year
22
+
23
+ # Health benefit card number (masked to the last 4)
24
+ attr_accessor :health_benefit_card_number
25
+
26
+ # Hosted field token for the card number
27
+ attr_accessor :health_benefit_card_number_token
28
+
29
+ # Health benefit card verification number (masked)
30
+ attr_accessor :health_benefit_card_verification_number
31
+
32
+ # Hosted field token for the health benefit card verification number
33
+ attr_accessor :health_benefit_card_verification_number_token
34
+
35
+ # Attribute mapping from ruby-style variable name to JSON key.
36
+ def self.attribute_map
37
+ {
38
+ :'health_benefit_card_expiration_month' => :'health_benefit_card_expiration_month',
39
+ :'health_benefit_card_expiration_year' => :'health_benefit_card_expiration_year',
40
+ :'health_benefit_card_number' => :'health_benefit_card_number',
41
+ :'health_benefit_card_number_token' => :'health_benefit_card_number_token',
42
+ :'health_benefit_card_verification_number' => :'health_benefit_card_verification_number',
43
+ :'health_benefit_card_verification_number_token' => :'health_benefit_card_verification_number_token'
44
+ }
45
+ end
46
+
47
+ # Attribute type mapping.
48
+ def self.swagger_types
49
+ {
50
+ :'health_benefit_card_expiration_month' => :'Integer',
51
+ :'health_benefit_card_expiration_year' => :'Integer',
52
+ :'health_benefit_card_number' => :'String',
53
+ :'health_benefit_card_number_token' => :'String',
54
+ :'health_benefit_card_verification_number' => :'String',
55
+ :'health_benefit_card_verification_number_token' => :'String'
56
+ }
57
+ end
58
+
59
+ # Initializes the object
60
+ # @param [Hash] attributes Model attributes in the form of hash
61
+ def initialize(attributes = {})
62
+ return unless attributes.is_a?(Hash)
63
+
64
+ # convert string to symbol for hash key
65
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
66
+
67
+ if attributes.has_key?(:'health_benefit_card_expiration_month')
68
+ self.health_benefit_card_expiration_month = attributes[:'health_benefit_card_expiration_month']
69
+ end
70
+
71
+ if attributes.has_key?(:'health_benefit_card_expiration_year')
72
+ self.health_benefit_card_expiration_year = attributes[:'health_benefit_card_expiration_year']
73
+ end
74
+
75
+ if attributes.has_key?(:'health_benefit_card_number')
76
+ self.health_benefit_card_number = attributes[:'health_benefit_card_number']
77
+ end
78
+
79
+ if attributes.has_key?(:'health_benefit_card_number_token')
80
+ self.health_benefit_card_number_token = attributes[:'health_benefit_card_number_token']
81
+ end
82
+
83
+ if attributes.has_key?(:'health_benefit_card_verification_number')
84
+ self.health_benefit_card_verification_number = attributes[:'health_benefit_card_verification_number']
85
+ end
86
+
87
+ if attributes.has_key?(:'health_benefit_card_verification_number_token')
88
+ self.health_benefit_card_verification_number_token = attributes[:'health_benefit_card_verification_number_token']
89
+ end
90
+ end
91
+
92
+ # Show invalid properties with the reasons. Usually used together with valid?
93
+ # @return Array for valid properties with the reasons
94
+ def list_invalid_properties
95
+ invalid_properties = Array.new
96
+ invalid_properties
97
+ end
98
+
99
+ # Check to see if the all the properties in the model are valid
100
+ # @return true if the model is valid
101
+ def valid?
102
+ true
103
+ end
104
+
105
+ # Checks equality by comparing each attribute.
106
+ # @param [Object] Object to be compared
107
+ def ==(o)
108
+ return true if self.equal?(o)
109
+ self.class == o.class &&
110
+ health_benefit_card_expiration_month == o.health_benefit_card_expiration_month &&
111
+ health_benefit_card_expiration_year == o.health_benefit_card_expiration_year &&
112
+ health_benefit_card_number == o.health_benefit_card_number &&
113
+ health_benefit_card_number_token == o.health_benefit_card_number_token &&
114
+ health_benefit_card_verification_number == o.health_benefit_card_verification_number &&
115
+ health_benefit_card_verification_number_token == o.health_benefit_card_verification_number_token
116
+ end
117
+
118
+ # @see the `==` method
119
+ # @param [Object] Object to be compared
120
+ def eql?(o)
121
+ self == o
122
+ end
123
+
124
+ # Calculates hash code according to all attributes.
125
+ # @return [Fixnum] Hash code
126
+ def hash
127
+ [health_benefit_card_expiration_month, health_benefit_card_expiration_year, health_benefit_card_number, health_benefit_card_number_token, health_benefit_card_verification_number, health_benefit_card_verification_number_token].hash
128
+ end
129
+
130
+ # Builds the object from hash
131
+ # @param [Hash] attributes Model attributes in the form of hash
132
+ # @return [Object] Returns the model itself
133
+ def build_from_hash(attributes)
134
+ return nil unless attributes.is_a?(Hash)
135
+ self.class.swagger_types.each_pair do |key, type|
136
+ if type =~ /\AArray<(.*)>/i
137
+ # check to ensure the input is an array given that the attribute
138
+ # is documented as an array but the input is not
139
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
140
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
141
+ end
142
+ elsif !attributes[self.class.attribute_map[key]].nil?
143
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
144
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
145
+ end
146
+
147
+ self
148
+ end
149
+
150
+ # Deserializes the data based on type
151
+ # @param string type Data type
152
+ # @param string value Value to be deserialized
153
+ # @return [Object] Deserialized data
154
+ def _deserialize(type, value)
155
+ case type.to_sym
156
+ when :DateTime
157
+ DateTime.parse(value)
158
+ when :Date
159
+ Date.parse(value)
160
+ when :String
161
+ value.to_s
162
+ when :Integer
163
+ value.to_i
164
+ when :Float
165
+ value.to_f
166
+ when :BOOLEAN
167
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
168
+ true
169
+ else
170
+ false
171
+ end
172
+ when :Object
173
+ # generic object (usually a Hash), return directly
174
+ value
175
+ when /\AArray<(?<inner_type>.+)>\z/
176
+ inner_type = Regexp.last_match[:inner_type]
177
+ value.map { |v| _deserialize(inner_type, v) }
178
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
179
+ k_type = Regexp.last_match[:k_type]
180
+ v_type = Regexp.last_match[:v_type]
181
+ {}.tap do |hash|
182
+ value.each do |k, v|
183
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
184
+ end
185
+ end
186
+ else # model
187
+ temp_model = UltracartClient.const_get(type).new
188
+ temp_model.build_from_hash(value)
189
+ end
190
+ end
191
+
192
+ # Returns the string representation of the object
193
+ # @return [String] String presentation of the object
194
+ def to_s
195
+ to_hash.to_s
196
+ end
197
+
198
+ # to_body is an alias to to_hash (backward compatibility)
199
+ # @return [Hash] Returns the object in the form of hash
200
+ def to_body
201
+ to_hash
202
+ end
203
+
204
+ # Returns the object in the form of hash
205
+ # @return [Hash] Returns the object in the form of hash
206
+ def to_hash
207
+ hash = {}
208
+ self.class.attribute_map.each_pair do |attr, param|
209
+ value = self.send(attr)
210
+ next if value.nil?
211
+ hash[param] = _to_hash(value)
212
+ end
213
+ hash
214
+ end
215
+
216
+ # Outputs non-array value in the form of hash
217
+ # For object, use to_hash. Otherwise, just return the value
218
+ # @param [Object] value Any valid value
219
+ # @return [Hash] Returns the value in the form of hash
220
+ def _to_hash(value)
221
+ if value.is_a?(Array)
222
+ value.compact.map { |v| _to_hash(v) }
223
+ elsif value.is_a?(Hash)
224
+ {}.tap do |hash|
225
+ value.each { |k, v| hash[k] = _to_hash(v) }
226
+ end
227
+ elsif value.respond_to? :to_hash
228
+ value.to_hash
229
+ else
230
+ value
231
+ end
232
+ end
233
+
234
+ end
235
+ end
@@ -20,6 +20,8 @@ module UltracartClient
20
20
 
21
21
  attr_accessor :echeck
22
22
 
23
+ attr_accessor :health_benefit_card
24
+
23
25
  # True if order has been held for fraud review
24
26
  attr_accessor :hold_for_fraud_review
25
27
 
@@ -90,6 +92,7 @@ module UltracartClient
90
92
  :'check' => :'check',
91
93
  :'credit_card' => :'credit_card',
92
94
  :'echeck' => :'echeck',
95
+ :'health_benefit_card' => :'health_benefit_card',
93
96
  :'hold_for_fraud_review' => :'hold_for_fraud_review',
94
97
  :'insurance' => :'insurance',
95
98
  :'payment_dts' => :'payment_dts',
@@ -114,6 +117,7 @@ module UltracartClient
114
117
  :'check' => :'OrderPaymentCheck',
115
118
  :'credit_card' => :'OrderPaymentCreditCard',
116
119
  :'echeck' => :'OrderPaymentECheck',
120
+ :'health_benefit_card' => :'OrderPaymentHealthBenefitCard',
117
121
  :'hold_for_fraud_review' => :'BOOLEAN',
118
122
  :'insurance' => :'OrderPaymentInsurance',
119
123
  :'payment_dts' => :'String',
@@ -152,6 +156,10 @@ module UltracartClient
152
156
  self.echeck = attributes[:'echeck']
153
157
  end
154
158
 
159
+ if attributes.has_key?(:'health_benefit_card')
160
+ self.health_benefit_card = attributes[:'health_benefit_card']
161
+ end
162
+
155
163
  if attributes.has_key?(:'hold_for_fraud_review')
156
164
  self.hold_for_fraud_review = attributes[:'hold_for_fraud_review']
157
165
  end
@@ -225,7 +233,7 @@ module UltracartClient
225
233
  # Check to see if the all the properties in the model are valid
226
234
  # @return true if the model is valid
227
235
  def valid?
228
- payment_method_validator = EnumAttributeValidator.new('String', ['Affirm', 'Amazon', 'Amazon SC', 'Cash', 'Check', 'COD', 'Credit Card', 'eBay', 'eCheck', 'Google Shopping', 'Insurance', 'LoanHero', 'Money Order', 'PayPal', 'Purchase Order', 'Quote Request', 'Unknown', 'Wire Transfer', 'Walmart', 'Shop.com', 'Sezzle', 'Venmo', 'Apple Pay', 'Google Pay'])
236
+ payment_method_validator = EnumAttributeValidator.new('String', ['Affirm', 'Amazon', 'Amazon SC', 'Cash', 'Check', 'COD', 'Credit Card', 'eBay', 'eCheck', 'Google Shopping', 'Insurance', 'LoanHero', 'Money Order', 'PayPal', 'Purchase Order', 'Quote Request', 'Unknown', 'Wire Transfer', 'Walmart', 'Shop.com', 'Sezzle', 'Venmo', 'Apple Pay', 'Google Pay', 'Health Benefit Card'])
229
237
  return false unless payment_method_validator.valid?(@payment_method)
230
238
  payment_status_validator = EnumAttributeValidator.new('String', ['Unprocessed', 'Authorized', 'Capture Failed', 'Processed', 'Declined', 'Voided', 'Refunded', 'Skipped'])
231
239
  return false unless payment_status_validator.valid?(@payment_status)
@@ -235,7 +243,7 @@ module UltracartClient
235
243
  # Custom attribute writer method checking allowed values (enum).
236
244
  # @param [Object] payment_method Object to be assigned
237
245
  def payment_method=(payment_method)
238
- validator = EnumAttributeValidator.new('String', ['Affirm', 'Amazon', 'Amazon SC', 'Cash', 'Check', 'COD', 'Credit Card', 'eBay', 'eCheck', 'Google Shopping', 'Insurance', 'LoanHero', 'Money Order', 'PayPal', 'Purchase Order', 'Quote Request', 'Unknown', 'Wire Transfer', 'Walmart', 'Shop.com', 'Sezzle', 'Venmo', 'Apple Pay', 'Google Pay'])
246
+ validator = EnumAttributeValidator.new('String', ['Affirm', 'Amazon', 'Amazon SC', 'Cash', 'Check', 'COD', 'Credit Card', 'eBay', 'eCheck', 'Google Shopping', 'Insurance', 'LoanHero', 'Money Order', 'PayPal', 'Purchase Order', 'Quote Request', 'Unknown', 'Wire Transfer', 'Walmart', 'Shop.com', 'Sezzle', 'Venmo', 'Apple Pay', 'Google Pay', 'Health Benefit Card'])
239
247
  unless validator.valid?(payment_method)
240
248
  fail ArgumentError, 'invalid value for "payment_method", must be one of #{validator.allowable_values}.'
241
249
  end
@@ -260,6 +268,7 @@ module UltracartClient
260
268
  check == o.check &&
261
269
  credit_card == o.credit_card &&
262
270
  echeck == o.echeck &&
271
+ health_benefit_card == o.health_benefit_card &&
263
272
  hold_for_fraud_review == o.hold_for_fraud_review &&
264
273
  insurance == o.insurance &&
265
274
  payment_dts == o.payment_dts &&
@@ -286,7 +295,7 @@ module UltracartClient
286
295
  # Calculates hash code according to all attributes.
287
296
  # @return [Fixnum] Hash code
288
297
  def hash
289
- [check, credit_card, echeck, hold_for_fraud_review, insurance, payment_dts, payment_method, payment_method_accounting_code, payment_method_deposit_to_account, payment_status, purchase_order, rotating_transaction_gateway_code, surcharge, surcharge_accounting_code, surcharge_transaction_fee, surcharge_transaction_percentage, test_order, transactions].hash
298
+ [check, credit_card, echeck, health_benefit_card, hold_for_fraud_review, insurance, payment_dts, payment_method, payment_method_accounting_code, payment_method_deposit_to_account, payment_status, purchase_order, rotating_transaction_gateway_code, surcharge, surcharge_accounting_code, surcharge_transaction_fee, surcharge_transaction_percentage, test_order, transactions].hash
290
299
  end
291
300
 
292
301
  # Builds the object from hash
@@ -0,0 +1,235 @@
1
+ =begin
2
+ #UltraCart Rest API V2
3
+
4
+ #UltraCart REST API Version 2
5
+
6
+ OpenAPI spec version: 2.0.0
7
+ Contact: support@ultracart.com
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.15-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module UltracartClient
16
+ class OrderPaymentHealthBenefitCard
17
+ # Health benefit card expiration month (1-12)
18
+ attr_accessor :health_benefit_card_expiration_month
19
+
20
+ # Health benefit card expiration year (Four digit year)
21
+ attr_accessor :health_benefit_card_expiration_year
22
+
23
+ # Health benefit card number (masked to last 4)
24
+ attr_accessor :health_benefit_card_number
25
+
26
+ # Health benefit card number token from hosted fields used to update the health benefit card number
27
+ attr_accessor :health_benefit_card_number_token
28
+
29
+ # True if the health benefit card has been truncated
30
+ attr_accessor :health_benefit_card_number_truncated
31
+
32
+ # Health benefit card verification number token from hosted fields, only for import/insert of new orders, completely ignored for updates, and always null/empty for queries
33
+ attr_accessor :health_benefit_card_verification_number_token
34
+
35
+ # Attribute mapping from ruby-style variable name to JSON key.
36
+ def self.attribute_map
37
+ {
38
+ :'health_benefit_card_expiration_month' => :'health_benefit_card_expiration_month',
39
+ :'health_benefit_card_expiration_year' => :'health_benefit_card_expiration_year',
40
+ :'health_benefit_card_number' => :'health_benefit_card_number',
41
+ :'health_benefit_card_number_token' => :'health_benefit_card_number_token',
42
+ :'health_benefit_card_number_truncated' => :'health_benefit_card_number_truncated',
43
+ :'health_benefit_card_verification_number_token' => :'health_benefit_card_verification_number_token'
44
+ }
45
+ end
46
+
47
+ # Attribute type mapping.
48
+ def self.swagger_types
49
+ {
50
+ :'health_benefit_card_expiration_month' => :'Integer',
51
+ :'health_benefit_card_expiration_year' => :'Integer',
52
+ :'health_benefit_card_number' => :'String',
53
+ :'health_benefit_card_number_token' => :'String',
54
+ :'health_benefit_card_number_truncated' => :'BOOLEAN',
55
+ :'health_benefit_card_verification_number_token' => :'String'
56
+ }
57
+ end
58
+
59
+ # Initializes the object
60
+ # @param [Hash] attributes Model attributes in the form of hash
61
+ def initialize(attributes = {})
62
+ return unless attributes.is_a?(Hash)
63
+
64
+ # convert string to symbol for hash key
65
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
66
+
67
+ if attributes.has_key?(:'health_benefit_card_expiration_month')
68
+ self.health_benefit_card_expiration_month = attributes[:'health_benefit_card_expiration_month']
69
+ end
70
+
71
+ if attributes.has_key?(:'health_benefit_card_expiration_year')
72
+ self.health_benefit_card_expiration_year = attributes[:'health_benefit_card_expiration_year']
73
+ end
74
+
75
+ if attributes.has_key?(:'health_benefit_card_number')
76
+ self.health_benefit_card_number = attributes[:'health_benefit_card_number']
77
+ end
78
+
79
+ if attributes.has_key?(:'health_benefit_card_number_token')
80
+ self.health_benefit_card_number_token = attributes[:'health_benefit_card_number_token']
81
+ end
82
+
83
+ if attributes.has_key?(:'health_benefit_card_number_truncated')
84
+ self.health_benefit_card_number_truncated = attributes[:'health_benefit_card_number_truncated']
85
+ end
86
+
87
+ if attributes.has_key?(:'health_benefit_card_verification_number_token')
88
+ self.health_benefit_card_verification_number_token = attributes[:'health_benefit_card_verification_number_token']
89
+ end
90
+ end
91
+
92
+ # Show invalid properties with the reasons. Usually used together with valid?
93
+ # @return Array for valid properties with the reasons
94
+ def list_invalid_properties
95
+ invalid_properties = Array.new
96
+ invalid_properties
97
+ end
98
+
99
+ # Check to see if the all the properties in the model are valid
100
+ # @return true if the model is valid
101
+ def valid?
102
+ true
103
+ end
104
+
105
+ # Checks equality by comparing each attribute.
106
+ # @param [Object] Object to be compared
107
+ def ==(o)
108
+ return true if self.equal?(o)
109
+ self.class == o.class &&
110
+ health_benefit_card_expiration_month == o.health_benefit_card_expiration_month &&
111
+ health_benefit_card_expiration_year == o.health_benefit_card_expiration_year &&
112
+ health_benefit_card_number == o.health_benefit_card_number &&
113
+ health_benefit_card_number_token == o.health_benefit_card_number_token &&
114
+ health_benefit_card_number_truncated == o.health_benefit_card_number_truncated &&
115
+ health_benefit_card_verification_number_token == o.health_benefit_card_verification_number_token
116
+ end
117
+
118
+ # @see the `==` method
119
+ # @param [Object] Object to be compared
120
+ def eql?(o)
121
+ self == o
122
+ end
123
+
124
+ # Calculates hash code according to all attributes.
125
+ # @return [Fixnum] Hash code
126
+ def hash
127
+ [health_benefit_card_expiration_month, health_benefit_card_expiration_year, health_benefit_card_number, health_benefit_card_number_token, health_benefit_card_number_truncated, health_benefit_card_verification_number_token].hash
128
+ end
129
+
130
+ # Builds the object from hash
131
+ # @param [Hash] attributes Model attributes in the form of hash
132
+ # @return [Object] Returns the model itself
133
+ def build_from_hash(attributes)
134
+ return nil unless attributes.is_a?(Hash)
135
+ self.class.swagger_types.each_pair do |key, type|
136
+ if type =~ /\AArray<(.*)>/i
137
+ # check to ensure the input is an array given that the attribute
138
+ # is documented as an array but the input is not
139
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
140
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
141
+ end
142
+ elsif !attributes[self.class.attribute_map[key]].nil?
143
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
144
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
145
+ end
146
+
147
+ self
148
+ end
149
+
150
+ # Deserializes the data based on type
151
+ # @param string type Data type
152
+ # @param string value Value to be deserialized
153
+ # @return [Object] Deserialized data
154
+ def _deserialize(type, value)
155
+ case type.to_sym
156
+ when :DateTime
157
+ DateTime.parse(value)
158
+ when :Date
159
+ Date.parse(value)
160
+ when :String
161
+ value.to_s
162
+ when :Integer
163
+ value.to_i
164
+ when :Float
165
+ value.to_f
166
+ when :BOOLEAN
167
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
168
+ true
169
+ else
170
+ false
171
+ end
172
+ when :Object
173
+ # generic object (usually a Hash), return directly
174
+ value
175
+ when /\AArray<(?<inner_type>.+)>\z/
176
+ inner_type = Regexp.last_match[:inner_type]
177
+ value.map { |v| _deserialize(inner_type, v) }
178
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
179
+ k_type = Regexp.last_match[:k_type]
180
+ v_type = Regexp.last_match[:v_type]
181
+ {}.tap do |hash|
182
+ value.each do |k, v|
183
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
184
+ end
185
+ end
186
+ else # model
187
+ temp_model = UltracartClient.const_get(type).new
188
+ temp_model.build_from_hash(value)
189
+ end
190
+ end
191
+
192
+ # Returns the string representation of the object
193
+ # @return [String] String presentation of the object
194
+ def to_s
195
+ to_hash.to_s
196
+ end
197
+
198
+ # to_body is an alias to to_hash (backward compatibility)
199
+ # @return [Hash] Returns the object in the form of hash
200
+ def to_body
201
+ to_hash
202
+ end
203
+
204
+ # Returns the object in the form of hash
205
+ # @return [Hash] Returns the object in the form of hash
206
+ def to_hash
207
+ hash = {}
208
+ self.class.attribute_map.each_pair do |attr, param|
209
+ value = self.send(attr)
210
+ next if value.nil?
211
+ hash[param] = _to_hash(value)
212
+ end
213
+ hash
214
+ end
215
+
216
+ # Outputs non-array value in the form of hash
217
+ # For object, use to_hash. Otherwise, just return the value
218
+ # @param [Object] value Any valid value
219
+ # @return [Hash] Returns the value in the form of hash
220
+ def _to_hash(value)
221
+ if value.is_a?(Array)
222
+ value.compact.map { |v| _to_hash(v) }
223
+ elsif value.is_a?(Hash)
224
+ {}.tap do |hash|
225
+ value.each { |k, v| hash[k] = _to_hash(v) }
226
+ end
227
+ elsif value.respond_to? :to_hash
228
+ value.to_hash
229
+ else
230
+ value
231
+ end
232
+ end
233
+
234
+ end
235
+ end