ultracart_api 4.0.181 → 4.0.182

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +26 -4
  3. data/docs/WorkflowApi.md +603 -0
  4. data/docs/WorkflowAttachment.md +26 -0
  5. data/docs/WorkflowAttachmentUploadUrl.md +20 -0
  6. data/docs/WorkflowAttachmentUploadUrlResponse.md +26 -0
  7. data/docs/WorkflowGroup.md +20 -0
  8. data/docs/WorkflowGroupsResponse.md +26 -0
  9. data/docs/WorkflowNote.md +28 -0
  10. data/docs/WorkflowTask.md +60 -0
  11. data/docs/WorkflowTaskHistory.md +24 -0
  12. data/docs/WorkflowTaskResponse.md +26 -0
  13. data/docs/WorkflowTasksRequest.md +48 -0
  14. data/docs/WorkflowTasksResponse.md +26 -0
  15. data/docs/WorkflowUser.md +22 -0
  16. data/docs/WorkflowUsersResponse.md +26 -0
  17. data/lib/ultracart_api/api/workflow_api.rb +583 -0
  18. data/lib/ultracart_api/models/workflow_attachment.rb +260 -0
  19. data/lib/ultracart_api/models/workflow_attachment_upload_url.rb +228 -0
  20. data/lib/ultracart_api/models/workflow_attachment_upload_url_response.rb +256 -0
  21. data/lib/ultracart_api/models/workflow_group.rb +230 -0
  22. data/lib/ultracart_api/models/workflow_groups_response.rb +259 -0
  23. data/lib/ultracart_api/models/workflow_note.rb +271 -0
  24. data/lib/ultracart_api/models/workflow_task.rb +493 -0
  25. data/lib/ultracart_api/models/workflow_task_history.rb +249 -0
  26. data/lib/ultracart_api/models/workflow_task_response.rb +256 -0
  27. data/lib/ultracart_api/models/workflow_tasks_request.rb +427 -0
  28. data/lib/ultracart_api/models/workflow_tasks_response.rb +259 -0
  29. data/lib/ultracart_api/models/workflow_user.rb +240 -0
  30. data/lib/ultracart_api/models/workflow_users_response.rb +259 -0
  31. data/lib/ultracart_api/version.rb +1 -1
  32. data/lib/ultracart_api.rb +14 -0
  33. metadata +29 -1
@@ -0,0 +1,427 @@
1
+ =begin
2
+ #UltraCart Rest API V2
3
+
4
+ #UltraCart REST API Version 2
5
+
6
+ The version of the OpenAPI document: 2.0.0
7
+ Contact: support@ultracart.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module UltracartClient
17
+ class WorkflowTasksRequest
18
+ # Assigned to group ID
19
+ attr_accessor :assigned_to_group_id
20
+
21
+ # Tasks are assigned to me either by direct user id or a group that the user is a member of
22
+ attr_accessor :assigned_to_me
23
+
24
+ # Assigned to user ID
25
+ attr_accessor :assigned_to_user_id
26
+
27
+ attr_accessor :created_by
28
+
29
+ # Date/time that the workflow task was created
30
+ attr_accessor :created_dts_begin
31
+
32
+ # Date/time that the workflow task was created
33
+ attr_accessor :created_dts_end
34
+
35
+ # Date/time that the workflow task should delay until
36
+ attr_accessor :delay_until_dts
37
+
38
+ # Date/time that the workflow task is due
39
+ attr_accessor :due_dts_begin
40
+
41
+ # Date/time that the workflow task is due
42
+ attr_accessor :due_dts_end
43
+
44
+ # Date/time that the workflow task was last updated
45
+ attr_accessor :last_update_dts_begin
46
+
47
+ # Date/time that the workflow task was last updated
48
+ attr_accessor :last_update_dts_end
49
+
50
+ # Object is associated with customer email
51
+ attr_accessor :object_email
52
+
53
+ # Object Type
54
+ attr_accessor :object_type
55
+
56
+ # Priority
57
+ attr_accessor :priority
58
+
59
+ # Status of the workflow task
60
+ attr_accessor :status
61
+
62
+ # Tasks that are unassigned to a user or group
63
+ attr_accessor :unassigned
64
+
65
+ class EnumAttributeValidator
66
+ attr_reader :datatype
67
+ attr_reader :allowable_values
68
+
69
+ def initialize(datatype, allowable_values)
70
+ @allowable_values = allowable_values.map do |value|
71
+ case datatype.to_s
72
+ when /Integer/i
73
+ value.to_i
74
+ when /Float/i
75
+ value.to_f
76
+ else
77
+ value
78
+ end
79
+ end
80
+ end
81
+
82
+ def valid?(value)
83
+ !value || allowable_values.include?(value)
84
+ end
85
+ end
86
+
87
+ # Attribute mapping from ruby-style variable name to JSON key.
88
+ def self.attribute_map
89
+ {
90
+ :'assigned_to_group_id' => :'assigned_to_group_id',
91
+ :'assigned_to_me' => :'assigned_to_me',
92
+ :'assigned_to_user_id' => :'assigned_to_user_id',
93
+ :'created_by' => :'created_by',
94
+ :'created_dts_begin' => :'created_dts_begin',
95
+ :'created_dts_end' => :'created_dts_end',
96
+ :'delay_until_dts' => :'delay_until_dts',
97
+ :'due_dts_begin' => :'due_dts_begin',
98
+ :'due_dts_end' => :'due_dts_end',
99
+ :'last_update_dts_begin' => :'last_update_dts_begin',
100
+ :'last_update_dts_end' => :'last_update_dts_end',
101
+ :'object_email' => :'object_email',
102
+ :'object_type' => :'object_type',
103
+ :'priority' => :'priority',
104
+ :'status' => :'status',
105
+ :'unassigned' => :'unassigned'
106
+ }
107
+ end
108
+
109
+ # Returns all the JSON keys this model knows about
110
+ def self.acceptable_attributes
111
+ attribute_map.values
112
+ end
113
+
114
+ # Attribute type mapping.
115
+ def self.openapi_types
116
+ {
117
+ :'assigned_to_group_id' => :'Integer',
118
+ :'assigned_to_me' => :'Boolean',
119
+ :'assigned_to_user_id' => :'Integer',
120
+ :'created_by' => :'WorkflowUser',
121
+ :'created_dts_begin' => :'String',
122
+ :'created_dts_end' => :'String',
123
+ :'delay_until_dts' => :'String',
124
+ :'due_dts_begin' => :'String',
125
+ :'due_dts_end' => :'String',
126
+ :'last_update_dts_begin' => :'String',
127
+ :'last_update_dts_end' => :'String',
128
+ :'object_email' => :'String',
129
+ :'object_type' => :'String',
130
+ :'priority' => :'String',
131
+ :'status' => :'String',
132
+ :'unassigned' => :'Boolean'
133
+ }
134
+ end
135
+
136
+ # List of attributes with nullable: true
137
+ def self.openapi_nullable
138
+ Set.new([
139
+ ])
140
+ end
141
+
142
+ # Initializes the object
143
+ # @param [Hash] attributes Model attributes in the form of hash
144
+ def initialize(attributes = {})
145
+ if (!attributes.is_a?(Hash))
146
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::WorkflowTasksRequest` initialize method"
147
+ end
148
+
149
+ # check to see if the attribute exists and convert string to symbol for hash key
150
+ attributes = attributes.each_with_object({}) { |(k, v), h|
151
+ if (!self.class.attribute_map.key?(k.to_sym))
152
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::WorkflowTasksRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
153
+ end
154
+ h[k.to_sym] = v
155
+ }
156
+
157
+ if attributes.key?(:'assigned_to_group_id')
158
+ self.assigned_to_group_id = attributes[:'assigned_to_group_id']
159
+ end
160
+
161
+ if attributes.key?(:'assigned_to_me')
162
+ self.assigned_to_me = attributes[:'assigned_to_me']
163
+ end
164
+
165
+ if attributes.key?(:'assigned_to_user_id')
166
+ self.assigned_to_user_id = attributes[:'assigned_to_user_id']
167
+ end
168
+
169
+ if attributes.key?(:'created_by')
170
+ self.created_by = attributes[:'created_by']
171
+ end
172
+
173
+ if attributes.key?(:'created_dts_begin')
174
+ self.created_dts_begin = attributes[:'created_dts_begin']
175
+ end
176
+
177
+ if attributes.key?(:'created_dts_end')
178
+ self.created_dts_end = attributes[:'created_dts_end']
179
+ end
180
+
181
+ if attributes.key?(:'delay_until_dts')
182
+ self.delay_until_dts = attributes[:'delay_until_dts']
183
+ end
184
+
185
+ if attributes.key?(:'due_dts_begin')
186
+ self.due_dts_begin = attributes[:'due_dts_begin']
187
+ end
188
+
189
+ if attributes.key?(:'due_dts_end')
190
+ self.due_dts_end = attributes[:'due_dts_end']
191
+ end
192
+
193
+ if attributes.key?(:'last_update_dts_begin')
194
+ self.last_update_dts_begin = attributes[:'last_update_dts_begin']
195
+ end
196
+
197
+ if attributes.key?(:'last_update_dts_end')
198
+ self.last_update_dts_end = attributes[:'last_update_dts_end']
199
+ end
200
+
201
+ if attributes.key?(:'object_email')
202
+ self.object_email = attributes[:'object_email']
203
+ end
204
+
205
+ if attributes.key?(:'object_type')
206
+ self.object_type = attributes[:'object_type']
207
+ end
208
+
209
+ if attributes.key?(:'priority')
210
+ self.priority = attributes[:'priority']
211
+ end
212
+
213
+ if attributes.key?(:'status')
214
+ self.status = attributes[:'status']
215
+ end
216
+
217
+ if attributes.key?(:'unassigned')
218
+ self.unassigned = attributes[:'unassigned']
219
+ end
220
+ end
221
+
222
+ # Show invalid properties with the reasons. Usually used together with valid?
223
+ # @return Array for valid properties with the reasons
224
+ def list_invalid_properties
225
+ invalid_properties = Array.new
226
+ invalid_properties
227
+ end
228
+
229
+ # Check to see if the all the properties in the model are valid
230
+ # @return true if the model is valid
231
+ def valid?
232
+ object_type_validator = EnumAttributeValidator.new('String', ["order", "auto order", "item", "customer profile"])
233
+ return false unless object_type_validator.valid?(@object_type)
234
+ priority_validator = EnumAttributeValidator.new('String', ["1 - low", "2 - medium", "3 - high", "4 - critical"])
235
+ return false unless priority_validator.valid?(@priority)
236
+ status_validator = EnumAttributeValidator.new('String', ["open", "closed", "delayed", "awaiting customer feedback"])
237
+ return false unless status_validator.valid?(@status)
238
+ true
239
+ end
240
+
241
+ # Custom attribute writer method checking allowed values (enum).
242
+ # @param [Object] object_type Object to be assigned
243
+ def object_type=(object_type)
244
+ validator = EnumAttributeValidator.new('String', ["order", "auto order", "item", "customer profile"])
245
+ unless validator.valid?(object_type)
246
+ fail ArgumentError, "invalid value for \"object_type\", must be one of #{validator.allowable_values}."
247
+ end
248
+ @object_type = object_type
249
+ end
250
+
251
+ # Custom attribute writer method checking allowed values (enum).
252
+ # @param [Object] priority Object to be assigned
253
+ def priority=(priority)
254
+ validator = EnumAttributeValidator.new('String', ["1 - low", "2 - medium", "3 - high", "4 - critical"])
255
+ unless validator.valid?(priority)
256
+ fail ArgumentError, "invalid value for \"priority\", must be one of #{validator.allowable_values}."
257
+ end
258
+ @priority = priority
259
+ end
260
+
261
+ # Custom attribute writer method checking allowed values (enum).
262
+ # @param [Object] status Object to be assigned
263
+ def status=(status)
264
+ validator = EnumAttributeValidator.new('String', ["open", "closed", "delayed", "awaiting customer feedback"])
265
+ unless validator.valid?(status)
266
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
267
+ end
268
+ @status = status
269
+ end
270
+
271
+ # Checks equality by comparing each attribute.
272
+ # @param [Object] Object to be compared
273
+ def ==(o)
274
+ return true if self.equal?(o)
275
+ self.class == o.class &&
276
+ assigned_to_group_id == o.assigned_to_group_id &&
277
+ assigned_to_me == o.assigned_to_me &&
278
+ assigned_to_user_id == o.assigned_to_user_id &&
279
+ created_by == o.created_by &&
280
+ created_dts_begin == o.created_dts_begin &&
281
+ created_dts_end == o.created_dts_end &&
282
+ delay_until_dts == o.delay_until_dts &&
283
+ due_dts_begin == o.due_dts_begin &&
284
+ due_dts_end == o.due_dts_end &&
285
+ last_update_dts_begin == o.last_update_dts_begin &&
286
+ last_update_dts_end == o.last_update_dts_end &&
287
+ object_email == o.object_email &&
288
+ object_type == o.object_type &&
289
+ priority == o.priority &&
290
+ status == o.status &&
291
+ unassigned == o.unassigned
292
+ end
293
+
294
+ # @see the `==` method
295
+ # @param [Object] Object to be compared
296
+ def eql?(o)
297
+ self == o
298
+ end
299
+
300
+ # Calculates hash code according to all attributes.
301
+ # @return [Integer] Hash code
302
+ def hash
303
+ [assigned_to_group_id, assigned_to_me, assigned_to_user_id, created_by, created_dts_begin, created_dts_end, delay_until_dts, due_dts_begin, due_dts_end, last_update_dts_begin, last_update_dts_end, object_email, object_type, priority, status, unassigned].hash
304
+ end
305
+
306
+ # Builds the object from hash
307
+ # @param [Hash] attributes Model attributes in the form of hash
308
+ # @return [Object] Returns the model itself
309
+ def self.build_from_hash(attributes)
310
+ new.build_from_hash(attributes)
311
+ end
312
+
313
+ # Builds the object from hash
314
+ # @param [Hash] attributes Model attributes in the form of hash
315
+ # @return [Object] Returns the model itself
316
+ def build_from_hash(attributes)
317
+ return nil unless attributes.is_a?(Hash)
318
+ attributes = attributes.transform_keys(&:to_sym)
319
+ self.class.openapi_types.each_pair do |key, type|
320
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
321
+ self.send("#{key}=", nil)
322
+ elsif type =~ /\AArray<(.*)>/i
323
+ # check to ensure the input is an array given that the attribute
324
+ # is documented as an array but the input is not
325
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
326
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
327
+ end
328
+ elsif !attributes[self.class.attribute_map[key]].nil?
329
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
330
+ end
331
+ end
332
+
333
+ self
334
+ end
335
+
336
+ # Deserializes the data based on type
337
+ # @param string type Data type
338
+ # @param string value Value to be deserialized
339
+ # @return [Object] Deserialized data
340
+ def _deserialize(type, value)
341
+ case type.to_sym
342
+ when :Time
343
+ Time.parse(value)
344
+ when :Date
345
+ Date.parse(value)
346
+ when :String
347
+ value.to_s
348
+ when :Integer
349
+ value.to_i
350
+ when :Float
351
+ value.to_f
352
+ when :Boolean
353
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
354
+ true
355
+ else
356
+ false
357
+ end
358
+ when :Object
359
+ # generic object (usually a Hash), return directly
360
+ value
361
+ when /\AArray<(?<inner_type>.+)>\z/
362
+ inner_type = Regexp.last_match[:inner_type]
363
+ value.map { |v| _deserialize(inner_type, v) }
364
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
365
+ k_type = Regexp.last_match[:k_type]
366
+ v_type = Regexp.last_match[:v_type]
367
+ {}.tap do |hash|
368
+ value.each do |k, v|
369
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
370
+ end
371
+ end
372
+ else # model
373
+ # models (e.g. Pet) or oneOf
374
+ klass = UltracartClient.const_get(type)
375
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
376
+ end
377
+ end
378
+
379
+ # Returns the string representation of the object
380
+ # @return [String] String presentation of the object
381
+ def to_s
382
+ to_hash.to_s
383
+ end
384
+
385
+ # to_body is an alias to to_hash (backward compatibility)
386
+ # @return [Hash] Returns the object in the form of hash
387
+ def to_body
388
+ to_hash
389
+ end
390
+
391
+ # Returns the object in the form of hash
392
+ # @return [Hash] Returns the object in the form of hash
393
+ def to_hash
394
+ hash = {}
395
+ self.class.attribute_map.each_pair do |attr, param|
396
+ value = self.send(attr)
397
+ if value.nil?
398
+ is_nullable = self.class.openapi_nullable.include?(attr)
399
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
400
+ end
401
+
402
+ hash[param] = _to_hash(value)
403
+ end
404
+ hash
405
+ end
406
+
407
+ # Outputs non-array value in the form of hash
408
+ # For object, use to_hash. Otherwise, just return the value
409
+ # @param [Object] value Any valid value
410
+ # @return [Hash] Returns the value in the form of hash
411
+ def _to_hash(value)
412
+ if value.is_a?(Array)
413
+ value.compact.map { |v| _to_hash(v) }
414
+ elsif value.is_a?(Hash)
415
+ {}.tap do |hash|
416
+ value.each { |k, v| hash[k] = _to_hash(v) }
417
+ end
418
+ elsif value.respond_to? :to_hash
419
+ value.to_hash
420
+ else
421
+ value
422
+ end
423
+ end
424
+
425
+ end
426
+
427
+ end
@@ -0,0 +1,259 @@
1
+ =begin
2
+ #UltraCart Rest API V2
3
+
4
+ #UltraCart REST API Version 2
5
+
6
+ The version of the OpenAPI document: 2.0.0
7
+ Contact: support@ultracart.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module UltracartClient
17
+ class WorkflowTasksResponse
18
+ attr_accessor :error
19
+
20
+ attr_accessor :metadata
21
+
22
+ # Indicates if API call was successful
23
+ attr_accessor :success
24
+
25
+ # tasks
26
+ attr_accessor :tasks
27
+
28
+ attr_accessor :warning
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'error' => :'error',
34
+ :'metadata' => :'metadata',
35
+ :'success' => :'success',
36
+ :'tasks' => :'tasks',
37
+ :'warning' => :'warning'
38
+ }
39
+ end
40
+
41
+ # Returns all the JSON keys this model knows about
42
+ def self.acceptable_attributes
43
+ attribute_map.values
44
+ end
45
+
46
+ # Attribute type mapping.
47
+ def self.openapi_types
48
+ {
49
+ :'error' => :'Error',
50
+ :'metadata' => :'ResponseMetadata',
51
+ :'success' => :'Boolean',
52
+ :'tasks' => :'Array<WorkflowTask>',
53
+ :'warning' => :'Warning'
54
+ }
55
+ end
56
+
57
+ # List of attributes with nullable: true
58
+ def self.openapi_nullable
59
+ Set.new([
60
+ ])
61
+ end
62
+
63
+ # Initializes the object
64
+ # @param [Hash] attributes Model attributes in the form of hash
65
+ def initialize(attributes = {})
66
+ if (!attributes.is_a?(Hash))
67
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::WorkflowTasksResponse` initialize method"
68
+ end
69
+
70
+ # check to see if the attribute exists and convert string to symbol for hash key
71
+ attributes = attributes.each_with_object({}) { |(k, v), h|
72
+ if (!self.class.attribute_map.key?(k.to_sym))
73
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::WorkflowTasksResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
74
+ end
75
+ h[k.to_sym] = v
76
+ }
77
+
78
+ if attributes.key?(:'error')
79
+ self.error = attributes[:'error']
80
+ end
81
+
82
+ if attributes.key?(:'metadata')
83
+ self.metadata = attributes[:'metadata']
84
+ end
85
+
86
+ if attributes.key?(:'success')
87
+ self.success = attributes[:'success']
88
+ end
89
+
90
+ if attributes.key?(:'tasks')
91
+ if (value = attributes[:'tasks']).is_a?(Array)
92
+ self.tasks = value
93
+ end
94
+ end
95
+
96
+ if attributes.key?(:'warning')
97
+ self.warning = attributes[:'warning']
98
+ end
99
+ end
100
+
101
+ # Show invalid properties with the reasons. Usually used together with valid?
102
+ # @return Array for valid properties with the reasons
103
+ def list_invalid_properties
104
+ invalid_properties = Array.new
105
+ invalid_properties
106
+ end
107
+
108
+ # Check to see if the all the properties in the model are valid
109
+ # @return true if the model is valid
110
+ def valid?
111
+ true
112
+ end
113
+
114
+ # Checks equality by comparing each attribute.
115
+ # @param [Object] Object to be compared
116
+ def ==(o)
117
+ return true if self.equal?(o)
118
+ self.class == o.class &&
119
+ error == o.error &&
120
+ metadata == o.metadata &&
121
+ success == o.success &&
122
+ tasks == o.tasks &&
123
+ warning == o.warning
124
+ end
125
+
126
+ # @see the `==` method
127
+ # @param [Object] Object to be compared
128
+ def eql?(o)
129
+ self == o
130
+ end
131
+
132
+ # Calculates hash code according to all attributes.
133
+ # @return [Integer] Hash code
134
+ def hash
135
+ [error, metadata, success, tasks, warning].hash
136
+ end
137
+
138
+ # Builds the object from hash
139
+ # @param [Hash] attributes Model attributes in the form of hash
140
+ # @return [Object] Returns the model itself
141
+ def self.build_from_hash(attributes)
142
+ new.build_from_hash(attributes)
143
+ end
144
+
145
+ # Builds the object from hash
146
+ # @param [Hash] attributes Model attributes in the form of hash
147
+ # @return [Object] Returns the model itself
148
+ def build_from_hash(attributes)
149
+ return nil unless attributes.is_a?(Hash)
150
+ attributes = attributes.transform_keys(&:to_sym)
151
+ self.class.openapi_types.each_pair do |key, type|
152
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
153
+ self.send("#{key}=", nil)
154
+ elsif type =~ /\AArray<(.*)>/i
155
+ # check to ensure the input is an array given that the attribute
156
+ # is documented as an array but the input is not
157
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
158
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
159
+ end
160
+ elsif !attributes[self.class.attribute_map[key]].nil?
161
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
162
+ end
163
+ end
164
+
165
+ self
166
+ end
167
+
168
+ # Deserializes the data based on type
169
+ # @param string type Data type
170
+ # @param string value Value to be deserialized
171
+ # @return [Object] Deserialized data
172
+ def _deserialize(type, value)
173
+ case type.to_sym
174
+ when :Time
175
+ Time.parse(value)
176
+ when :Date
177
+ Date.parse(value)
178
+ when :String
179
+ value.to_s
180
+ when :Integer
181
+ value.to_i
182
+ when :Float
183
+ value.to_f
184
+ when :Boolean
185
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
186
+ true
187
+ else
188
+ false
189
+ end
190
+ when :Object
191
+ # generic object (usually a Hash), return directly
192
+ value
193
+ when /\AArray<(?<inner_type>.+)>\z/
194
+ inner_type = Regexp.last_match[:inner_type]
195
+ value.map { |v| _deserialize(inner_type, v) }
196
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
197
+ k_type = Regexp.last_match[:k_type]
198
+ v_type = Regexp.last_match[:v_type]
199
+ {}.tap do |hash|
200
+ value.each do |k, v|
201
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
202
+ end
203
+ end
204
+ else # model
205
+ # models (e.g. Pet) or oneOf
206
+ klass = UltracartClient.const_get(type)
207
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
208
+ end
209
+ end
210
+
211
+ # Returns the string representation of the object
212
+ # @return [String] String presentation of the object
213
+ def to_s
214
+ to_hash.to_s
215
+ end
216
+
217
+ # to_body is an alias to to_hash (backward compatibility)
218
+ # @return [Hash] Returns the object in the form of hash
219
+ def to_body
220
+ to_hash
221
+ end
222
+
223
+ # Returns the object in the form of hash
224
+ # @return [Hash] Returns the object in the form of hash
225
+ def to_hash
226
+ hash = {}
227
+ self.class.attribute_map.each_pair do |attr, param|
228
+ value = self.send(attr)
229
+ if value.nil?
230
+ is_nullable = self.class.openapi_nullable.include?(attr)
231
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
232
+ end
233
+
234
+ hash[param] = _to_hash(value)
235
+ end
236
+ hash
237
+ end
238
+
239
+ # Outputs non-array value in the form of hash
240
+ # For object, use to_hash. Otherwise, just return the value
241
+ # @param [Object] value Any valid value
242
+ # @return [Hash] Returns the value in the form of hash
243
+ def _to_hash(value)
244
+ if value.is_a?(Array)
245
+ value.compact.map { |v| _to_hash(v) }
246
+ elsif value.is_a?(Hash)
247
+ {}.tap do |hash|
248
+ value.each { |k, v| hash[k] = _to_hash(v) }
249
+ end
250
+ elsif value.respond_to? :to_hash
251
+ value.to_hash
252
+ else
253
+ value
254
+ end
255
+ end
256
+
257
+ end
258
+
259
+ end