ultracart_api 4.1.199 → 4.1.201

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +28 -2
  3. data/docs/SfvbApi.md +578 -13
  4. data/docs/SfvbApprovalCreateRequest.md +6 -0
  5. data/docs/SfvbApprovalParams.md +23 -3
  6. data/docs/SfvbContainerVersion.md +1 -1
  7. data/docs/SfvbEvent.md +28 -0
  8. data/docs/SfvbEventsAuthRequest.md +18 -0
  9. data/docs/SfvbEventsAuthResponse.md +22 -0
  10. data/docs/SfvbEventsResponse.md +22 -0
  11. data/docs/SfvbI18nMessageValue.md +1 -1
  12. data/docs/SfvbItemAttributeBatchRequest.md +20 -0
  13. data/docs/SfvbItemAttributeBatchResponse.md +40 -0
  14. data/docs/SfvbItemAttributeBatchRow.md +30 -0
  15. data/docs/SfvbItemAttributeBatchRowResult.md +36 -0
  16. data/docs/SfvbItemPricing.md +38 -0
  17. data/docs/SfvbItemPricingRequest.md +32 -0
  18. data/docs/SfvbItemRelated.md +28 -0
  19. data/docs/SfvbItemRelatedItem.md +22 -0
  20. data/docs/SfvbItemRelatedRequest.md +22 -0
  21. data/docs/SfvbItemVolumeDiscount.md +20 -0
  22. data/docs/SfvbThemeJobResponse.md +3 -3
  23. data/lib/ultracart_api/api/sfvb_api.rb +831 -72
  24. data/lib/ultracart_api/models/sfvb_approval_create_request.rb +33 -3
  25. data/lib/ultracart_api/models/sfvb_approval_params.rb +142 -6
  26. data/lib/ultracart_api/models/sfvb_container_version.rb +1 -1
  27. data/lib/ultracart_api/models/sfvb_event.rb +270 -0
  28. data/lib/ultracart_api/models/sfvb_events_auth_request.rb +222 -0
  29. data/lib/ultracart_api/models/sfvb_events_auth_response.rb +240 -0
  30. data/lib/ultracart_api/models/sfvb_events_response.rb +242 -0
  31. data/lib/ultracart_api/models/sfvb_i18n_message_value.rb +1 -1
  32. data/lib/ultracart_api/models/sfvb_item_attribute_batch_request.rb +232 -0
  33. data/lib/ultracart_api/models/sfvb_item_attribute_batch_response.rb +332 -0
  34. data/lib/ultracart_api/models/sfvb_item_attribute_batch_row.rb +280 -0
  35. data/lib/ultracart_api/models/sfvb_item_attribute_batch_row_result.rb +344 -0
  36. data/lib/ultracart_api/models/sfvb_item_pricing.rb +322 -0
  37. data/lib/ultracart_api/models/sfvb_item_pricing_request.rb +292 -0
  38. data/lib/ultracart_api/models/sfvb_item_related.rb +272 -0
  39. data/lib/ultracart_api/models/sfvb_item_related_item.rb +274 -0
  40. data/lib/ultracart_api/models/sfvb_item_related_request.rb +242 -0
  41. data/lib/ultracart_api/models/sfvb_item_volume_discount.rb +230 -0
  42. data/lib/ultracart_api/models/sfvb_theme_job_response.rb +3 -3
  43. data/lib/ultracart_api/version.rb +1 -1
  44. data/lib/ultracart_api.rb +14 -0
  45. metadata +30 -2
@@ -21,6 +21,13 @@ module UltracartClient
21
21
  # For a file.put_script write, the exact script to be written, at most 256 KB. UltraCart reviews it and keeps only its hash, so send the same bytes again on the write. Leave it out for a revert, which names params.version.
22
22
  attr_accessor :content
23
23
 
24
+ attr_accessor :experiment_start
25
+
26
+ # For item.attribute_batch, exactly the rows the batch will send - the dry run's change rows, each with merchant_item_oid and current_sha256. UltraCart keeps only their hash.
27
+ attr_accessor :item_attribute_rows
28
+
29
+ attr_accessor :item_pricing
30
+
24
31
  attr_accessor :params
25
32
 
26
33
  # Why the agent wants to do this, in a sentence. Shown to the person as unverified text, capped at 500 characters.
@@ -56,6 +63,9 @@ module UltracartClient
56
63
  {
57
64
  :'action' => :'action',
58
65
  :'content' => :'content',
66
+ :'experiment_start' => :'experiment_start',
67
+ :'item_attribute_rows' => :'item_attribute_rows',
68
+ :'item_pricing' => :'item_pricing',
59
69
  :'params' => :'params',
60
70
  :'reason' => :'reason',
61
71
  :'redirect_rows' => :'redirect_rows'
@@ -72,6 +82,9 @@ module UltracartClient
72
82
  {
73
83
  :'action' => :'String',
74
84
  :'content' => :'String',
85
+ :'experiment_start' => :'SfvbExperimentStartRequest',
86
+ :'item_attribute_rows' => :'Array<SfvbItemAttributeBatchRow>',
87
+ :'item_pricing' => :'SfvbItemPricingRequest',
75
88
  :'params' => :'SfvbApprovalParams',
76
89
  :'reason' => :'String',
77
90
  :'redirect_rows' => :'Array<SfvbRedirectDeleteRow>'
@@ -107,6 +120,20 @@ module UltracartClient
107
120
  self.content = attributes[:'content']
108
121
  end
109
122
 
123
+ if attributes.key?(:'experiment_start')
124
+ self.experiment_start = attributes[:'experiment_start']
125
+ end
126
+
127
+ if attributes.key?(:'item_attribute_rows')
128
+ if (value = attributes[:'item_attribute_rows']).is_a?(Array)
129
+ self.item_attribute_rows = value
130
+ end
131
+ end
132
+
133
+ if attributes.key?(:'item_pricing')
134
+ self.item_pricing = attributes[:'item_pricing']
135
+ end
136
+
110
137
  if attributes.key?(:'params')
111
138
  self.params = attributes[:'params']
112
139
  end
@@ -132,7 +159,7 @@ module UltracartClient
132
159
  # Check to see if the all the properties in the model are valid
133
160
  # @return true if the model is valid
134
161
  def valid?
135
- action_validator = EnumAttributeValidator.new('String', ["file.delete", "blog_post.delete", "file.put_script", "redirect.delete_batch"])
162
+ action_validator = EnumAttributeValidator.new('String', ["file.delete", "blog_post.delete", "file.put_script", "redirect.delete_batch", "experiment.start", "experiment.end", "upsell.enable", "item.attribute_batch", "item.pricing"])
136
163
  return false unless action_validator.valid?(@action)
137
164
  true
138
165
  end
@@ -140,7 +167,7 @@ module UltracartClient
140
167
  # Custom attribute writer method checking allowed values (enum).
141
168
  # @param [Object] action Object to be assigned
142
169
  def action=(action)
143
- validator = EnumAttributeValidator.new('String', ["file.delete", "blog_post.delete", "file.put_script", "redirect.delete_batch"])
170
+ validator = EnumAttributeValidator.new('String', ["file.delete", "blog_post.delete", "file.put_script", "redirect.delete_batch", "experiment.start", "experiment.end", "upsell.enable", "item.attribute_batch", "item.pricing"])
144
171
  unless validator.valid?(action)
145
172
  fail ArgumentError, "invalid value for \"action\", must be one of #{validator.allowable_values}."
146
173
  end
@@ -154,6 +181,9 @@ module UltracartClient
154
181
  self.class == o.class &&
155
182
  action == o.action &&
156
183
  content == o.content &&
184
+ experiment_start == o.experiment_start &&
185
+ item_attribute_rows == o.item_attribute_rows &&
186
+ item_pricing == o.item_pricing &&
157
187
  params == o.params &&
158
188
  reason == o.reason &&
159
189
  redirect_rows == o.redirect_rows
@@ -168,7 +198,7 @@ module UltracartClient
168
198
  # Calculates hash code according to all attributes.
169
199
  # @return [Integer] Hash code
170
200
  def hash
171
- [action, content, params, reason, redirect_rows].hash
201
+ [action, content, experiment_start, item_attribute_rows, item_pricing, params, reason, redirect_rows].hash
172
202
  end
173
203
 
174
204
  # Builds the object from hash
@@ -15,33 +15,95 @@ require 'time'
15
15
 
16
16
  module UltracartClient
17
17
  class SfvbApprovalParams
18
+ # For item.attribute_batch, the attributes the batch would change. Set by the server.
19
+ attr_accessor :attribute_names
20
+
18
21
  # The blog post, for blog_post.delete.
19
22
  attr_accessor :blog_post_oid
20
23
 
21
24
  # For file.put_script, the SHA-256 of the exact bytes approved. Set by the server, never by the caller. The write must send bytes with this hash.
22
25
  attr_accessor :content_sha256
23
26
 
24
- # The file path, for file.delete and file.put_script. Exactly as the gated call will send it.
27
+ # For experiment.end, the experiment to end.
28
+ attr_accessor :experiment_oid
29
+
30
+ # For item.attribute_batch, how many items the batch would change when it was requested. Set by the server.
31
+ attr_accessor :item_count
32
+
33
+ # For item.pricing, the item whose pricing changes.
34
+ attr_accessor :merchant_item_oid
35
+
36
+ # The file path, for file.delete and file.put_script, or the page path for experiment.start of a page experiment. Exactly as the gated call will send it.
25
37
  attr_accessor :path
26
38
 
27
- # For redirect.delete_batch, the plan_hash of the exact rows approved. Set by the server. The batch delete must send rows with this hash.
39
+ # For experiment.start of a url experiment, the hash of the checked experiment approved, and for item.pricing the hash of the change. Set by the server. The gated call must send the same.
40
+ attr_accessor :request_sha256
41
+
42
+ # For redirect.delete_batch and item.attribute_batch, the plan_hash of the exact rows approved. Set by the server. The batch must send rows with this hash.
28
43
  attr_accessor :rows_sha256
29
44
 
30
45
  # For redirect.delete_batch, how many rules the batch would delete when it was requested. Set by the server.
31
46
  attr_accessor :rule_count
32
47
 
48
+ # For experiment.start of a page experiment, the page body name. Defaults to body.
49
+ attr_accessor :slot
50
+
51
+ # For upsell.enable, what to switch on.
52
+ attr_accessor :upsell_kind
53
+
54
+ # For upsell.enable, the oid of the offer or path to switch on.
55
+ attr_accessor :upsell_oid
56
+
33
57
  # For file.put_script, the history version a revert restores. Leave it out, and send content instead, for a write.
34
58
  attr_accessor :version
35
59
 
60
+ # For experiment.start of a page experiment, the id of the experiment element.
61
+ attr_accessor :widget_id
62
+
63
+ # For experiment.end, the winning variation. Leave it out to end without a winner, and leave it out of the end call too.
64
+ attr_accessor :winner_variation_number
65
+
66
+ class EnumAttributeValidator
67
+ attr_reader :datatype
68
+ attr_reader :allowable_values
69
+
70
+ def initialize(datatype, allowable_values)
71
+ @allowable_values = allowable_values.map do |value|
72
+ case datatype.to_s
73
+ when /Integer/i
74
+ value.to_i
75
+ when /Float/i
76
+ value.to_f
77
+ else
78
+ value
79
+ end
80
+ end
81
+ end
82
+
83
+ def valid?(value)
84
+ !value || allowable_values.include?(value)
85
+ end
86
+ end
87
+
36
88
  # Attribute mapping from ruby-style variable name to JSON key.
37
89
  def self.attribute_map
38
90
  {
91
+ :'attribute_names' => :'attribute_names',
39
92
  :'blog_post_oid' => :'blog_post_oid',
40
93
  :'content_sha256' => :'content_sha256',
94
+ :'experiment_oid' => :'experiment_oid',
95
+ :'item_count' => :'item_count',
96
+ :'merchant_item_oid' => :'merchant_item_oid',
41
97
  :'path' => :'path',
98
+ :'request_sha256' => :'request_sha256',
42
99
  :'rows_sha256' => :'rows_sha256',
43
100
  :'rule_count' => :'rule_count',
44
- :'version' => :'version'
101
+ :'slot' => :'slot',
102
+ :'upsell_kind' => :'upsell_kind',
103
+ :'upsell_oid' => :'upsell_oid',
104
+ :'version' => :'version',
105
+ :'widget_id' => :'widget_id',
106
+ :'winner_variation_number' => :'winner_variation_number'
45
107
  }
46
108
  end
47
109
 
@@ -53,12 +115,22 @@ module UltracartClient
53
115
  # Attribute type mapping.
54
116
  def self.openapi_types
55
117
  {
118
+ :'attribute_names' => :'Array<String>',
56
119
  :'blog_post_oid' => :'Integer',
57
120
  :'content_sha256' => :'String',
121
+ :'experiment_oid' => :'Integer',
122
+ :'item_count' => :'Integer',
123
+ :'merchant_item_oid' => :'Integer',
58
124
  :'path' => :'String',
125
+ :'request_sha256' => :'String',
59
126
  :'rows_sha256' => :'String',
60
127
  :'rule_count' => :'Integer',
61
- :'version' => :'Integer'
128
+ :'slot' => :'String',
129
+ :'upsell_kind' => :'String',
130
+ :'upsell_oid' => :'Integer',
131
+ :'version' => :'Integer',
132
+ :'widget_id' => :'String',
133
+ :'winner_variation_number' => :'Integer'
62
134
  }
63
135
  end
64
136
 
@@ -83,6 +155,12 @@ module UltracartClient
83
155
  h[k.to_sym] = v
84
156
  }
85
157
 
158
+ if attributes.key?(:'attribute_names')
159
+ if (value = attributes[:'attribute_names']).is_a?(Array)
160
+ self.attribute_names = value
161
+ end
162
+ end
163
+
86
164
  if attributes.key?(:'blog_post_oid')
87
165
  self.blog_post_oid = attributes[:'blog_post_oid']
88
166
  end
@@ -91,10 +169,26 @@ module UltracartClient
91
169
  self.content_sha256 = attributes[:'content_sha256']
92
170
  end
93
171
 
172
+ if attributes.key?(:'experiment_oid')
173
+ self.experiment_oid = attributes[:'experiment_oid']
174
+ end
175
+
176
+ if attributes.key?(:'item_count')
177
+ self.item_count = attributes[:'item_count']
178
+ end
179
+
180
+ if attributes.key?(:'merchant_item_oid')
181
+ self.merchant_item_oid = attributes[:'merchant_item_oid']
182
+ end
183
+
94
184
  if attributes.key?(:'path')
95
185
  self.path = attributes[:'path']
96
186
  end
97
187
 
188
+ if attributes.key?(:'request_sha256')
189
+ self.request_sha256 = attributes[:'request_sha256']
190
+ end
191
+
98
192
  if attributes.key?(:'rows_sha256')
99
193
  self.rows_sha256 = attributes[:'rows_sha256']
100
194
  end
@@ -103,9 +197,29 @@ module UltracartClient
103
197
  self.rule_count = attributes[:'rule_count']
104
198
  end
105
199
 
200
+ if attributes.key?(:'slot')
201
+ self.slot = attributes[:'slot']
202
+ end
203
+
204
+ if attributes.key?(:'upsell_kind')
205
+ self.upsell_kind = attributes[:'upsell_kind']
206
+ end
207
+
208
+ if attributes.key?(:'upsell_oid')
209
+ self.upsell_oid = attributes[:'upsell_oid']
210
+ end
211
+
106
212
  if attributes.key?(:'version')
107
213
  self.version = attributes[:'version']
108
214
  end
215
+
216
+ if attributes.key?(:'widget_id')
217
+ self.widget_id = attributes[:'widget_id']
218
+ end
219
+
220
+ if attributes.key?(:'winner_variation_number')
221
+ self.winner_variation_number = attributes[:'winner_variation_number']
222
+ end
109
223
  end
110
224
 
111
225
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -118,20 +232,42 @@ module UltracartClient
118
232
  # Check to see if the all the properties in the model are valid
119
233
  # @return true if the model is valid
120
234
  def valid?
235
+ upsell_kind_validator = EnumAttributeValidator.new('String', ["offer", "path"])
236
+ return false unless upsell_kind_validator.valid?(@upsell_kind)
121
237
  true
122
238
  end
123
239
 
240
+ # Custom attribute writer method checking allowed values (enum).
241
+ # @param [Object] upsell_kind Object to be assigned
242
+ def upsell_kind=(upsell_kind)
243
+ validator = EnumAttributeValidator.new('String', ["offer", "path"])
244
+ unless validator.valid?(upsell_kind)
245
+ fail ArgumentError, "invalid value for \"upsell_kind\", must be one of #{validator.allowable_values}."
246
+ end
247
+ @upsell_kind = upsell_kind
248
+ end
249
+
124
250
  # Checks equality by comparing each attribute.
125
251
  # @param [Object] Object to be compared
126
252
  def ==(o)
127
253
  return true if self.equal?(o)
128
254
  self.class == o.class &&
255
+ attribute_names == o.attribute_names &&
129
256
  blog_post_oid == o.blog_post_oid &&
130
257
  content_sha256 == o.content_sha256 &&
258
+ experiment_oid == o.experiment_oid &&
259
+ item_count == o.item_count &&
260
+ merchant_item_oid == o.merchant_item_oid &&
131
261
  path == o.path &&
262
+ request_sha256 == o.request_sha256 &&
132
263
  rows_sha256 == o.rows_sha256 &&
133
264
  rule_count == o.rule_count &&
134
- version == o.version
265
+ slot == o.slot &&
266
+ upsell_kind == o.upsell_kind &&
267
+ upsell_oid == o.upsell_oid &&
268
+ version == o.version &&
269
+ widget_id == o.widget_id &&
270
+ winner_variation_number == o.winner_variation_number
135
271
  end
136
272
 
137
273
  # @see the `==` method
@@ -143,7 +279,7 @@ module UltracartClient
143
279
  # Calculates hash code according to all attributes.
144
280
  # @return [Integer] Hash code
145
281
  def hash
146
- [blog_post_oid, content_sha256, path, rows_sha256, rule_count, version].hash
282
+ [attribute_names, blog_post_oid, content_sha256, experiment_oid, item_count, merchant_item_oid, path, request_sha256, rows_sha256, rule_count, slot, upsell_kind, upsell_oid, version, widget_id, winner_variation_number].hash
147
283
  end
148
284
 
149
285
  # Builds the object from hash
@@ -27,7 +27,7 @@ module UltracartClient
27
27
  # Container name, where the owner has more than one container.
28
28
  attr_accessor :container_name
29
29
 
30
- # When this snapshot was taken.
30
+ # When this snapshot was taken, ISO 8601 UTC.
31
31
  attr_accessor :created_dts
32
32
 
33
33
  # True for the value currently stored.
@@ -0,0 +1,270 @@
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 SfvbEvent
18
+ # When it happened, ISO 8601.
19
+ attr_accessor :event_dts
20
+
21
+ # Time-ordered id. Pass the last one seen as after to replay what came since.
22
+ attr_accessor :event_id
23
+
24
+ # The id of what changed, such as the approval_id.
25
+ attr_accessor :object_id
26
+
27
+ # What changed, such as approval.
28
+ attr_accessor :object_type
29
+
30
+ # The storefront it concerns. Empty for merchant-level objects.
31
+ attr_accessor :storefront_oid
32
+
33
+ # approval.decided (approved, denied, cancelled or refused by the script review) or approval.ready (the review finished and the person can decide).
34
+ attr_accessor :type
35
+
36
+ # Attribute mapping from ruby-style variable name to JSON key.
37
+ def self.attribute_map
38
+ {
39
+ :'event_dts' => :'event_dts',
40
+ :'event_id' => :'event_id',
41
+ :'object_id' => :'object_id',
42
+ :'object_type' => :'object_type',
43
+ :'storefront_oid' => :'storefront_oid',
44
+ :'type' => :'type'
45
+ }
46
+ end
47
+
48
+ # Returns all the JSON keys this model knows about
49
+ def self.acceptable_attributes
50
+ attribute_map.values
51
+ end
52
+
53
+ # Attribute type mapping.
54
+ def self.openapi_types
55
+ {
56
+ :'event_dts' => :'String',
57
+ :'event_id' => :'String',
58
+ :'object_id' => :'String',
59
+ :'object_type' => :'String',
60
+ :'storefront_oid' => :'Integer',
61
+ :'type' => :'String'
62
+ }
63
+ end
64
+
65
+ # List of attributes with nullable: true
66
+ def self.openapi_nullable
67
+ Set.new([
68
+ ])
69
+ end
70
+
71
+ # Initializes the object
72
+ # @param [Hash] attributes Model attributes in the form of hash
73
+ def initialize(attributes = {})
74
+ if (!attributes.is_a?(Hash))
75
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::SfvbEvent` initialize method"
76
+ end
77
+
78
+ # check to see if the attribute exists and convert string to symbol for hash key
79
+ attributes = attributes.each_with_object({}) { |(k, v), h|
80
+ if (!self.class.attribute_map.key?(k.to_sym))
81
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::SfvbEvent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
82
+ end
83
+ h[k.to_sym] = v
84
+ }
85
+
86
+ if attributes.key?(:'event_dts')
87
+ self.event_dts = attributes[:'event_dts']
88
+ end
89
+
90
+ if attributes.key?(:'event_id')
91
+ self.event_id = attributes[:'event_id']
92
+ end
93
+
94
+ if attributes.key?(:'object_id')
95
+ self.object_id = attributes[:'object_id']
96
+ end
97
+
98
+ if attributes.key?(:'object_type')
99
+ self.object_type = attributes[:'object_type']
100
+ end
101
+
102
+ if attributes.key?(:'storefront_oid')
103
+ self.storefront_oid = attributes[:'storefront_oid']
104
+ end
105
+
106
+ if attributes.key?(:'type')
107
+ self.type = attributes[:'type']
108
+ end
109
+ end
110
+
111
+ # Show invalid properties with the reasons. Usually used together with valid?
112
+ # @return Array for valid properties with the reasons
113
+ def list_invalid_properties
114
+ invalid_properties = Array.new
115
+ invalid_properties
116
+ end
117
+
118
+ # Check to see if the all the properties in the model are valid
119
+ # @return true if the model is valid
120
+ def valid?
121
+ true
122
+ end
123
+
124
+ # Checks equality by comparing each attribute.
125
+ # @param [Object] Object to be compared
126
+ def ==(o)
127
+ return true if self.equal?(o)
128
+ self.class == o.class &&
129
+ event_dts == o.event_dts &&
130
+ event_id == o.event_id &&
131
+ object_id == o.object_id &&
132
+ object_type == o.object_type &&
133
+ storefront_oid == o.storefront_oid &&
134
+ type == o.type
135
+ end
136
+
137
+ # @see the `==` method
138
+ # @param [Object] Object to be compared
139
+ def eql?(o)
140
+ self == o
141
+ end
142
+
143
+ # Calculates hash code according to all attributes.
144
+ # @return [Integer] Hash code
145
+ def hash
146
+ [event_dts, event_id, object_id, object_type, storefront_oid, type].hash
147
+ end
148
+
149
+ # Builds the object from hash
150
+ # @param [Hash] attributes Model attributes in the form of hash
151
+ # @return [Object] Returns the model itself
152
+ def self.build_from_hash(attributes)
153
+ new.build_from_hash(attributes)
154
+ end
155
+
156
+ # Builds the object from hash
157
+ # @param [Hash] attributes Model attributes in the form of hash
158
+ # @return [Object] Returns the model itself
159
+ def build_from_hash(attributes)
160
+ return nil unless attributes.is_a?(Hash)
161
+ attributes = attributes.transform_keys(&:to_sym)
162
+ self.class.openapi_types.each_pair do |key, type|
163
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
164
+ self.send("#{key}=", nil)
165
+ elsif type =~ /\AArray<(.*)>/i
166
+ # check to ensure the input is an array given that the attribute
167
+ # is documented as an array but the input is not
168
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
169
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
170
+ end
171
+ elsif !attributes[self.class.attribute_map[key]].nil?
172
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
173
+ end
174
+ end
175
+
176
+ self
177
+ end
178
+
179
+ # Deserializes the data based on type
180
+ # @param string type Data type
181
+ # @param string value Value to be deserialized
182
+ # @return [Object] Deserialized data
183
+ def _deserialize(type, value)
184
+ case type.to_sym
185
+ when :Time
186
+ Time.parse(value)
187
+ when :Date
188
+ Date.parse(value)
189
+ when :String
190
+ value.to_s
191
+ when :Integer
192
+ value.to_i
193
+ when :Float
194
+ value.to_f
195
+ when :Boolean
196
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
197
+ true
198
+ else
199
+ false
200
+ end
201
+ when :Object
202
+ # generic object (usually a Hash), return directly
203
+ value
204
+ when /\AArray<(?<inner_type>.+)>\z/
205
+ inner_type = Regexp.last_match[:inner_type]
206
+ value.map { |v| _deserialize(inner_type, v) }
207
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
208
+ k_type = Regexp.last_match[:k_type]
209
+ v_type = Regexp.last_match[:v_type]
210
+ {}.tap do |hash|
211
+ value.each do |k, v|
212
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
213
+ end
214
+ end
215
+ else # model
216
+ # models (e.g. Pet) or oneOf
217
+ klass = UltracartClient.const_get(type)
218
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
219
+ end
220
+ end
221
+
222
+ # Returns the string representation of the object
223
+ # @return [String] String presentation of the object
224
+ def to_s
225
+ to_hash.to_s
226
+ end
227
+
228
+ # to_body is an alias to to_hash (backward compatibility)
229
+ # @return [Hash] Returns the object in the form of hash
230
+ def to_body
231
+ to_hash
232
+ end
233
+
234
+ # Returns the object in the form of hash
235
+ # @return [Hash] Returns the object in the form of hash
236
+ def to_hash
237
+ hash = {}
238
+ self.class.attribute_map.each_pair do |attr, param|
239
+ value = self.send(attr)
240
+ if value.nil?
241
+ is_nullable = self.class.openapi_nullable.include?(attr)
242
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
243
+ end
244
+
245
+ hash[param] = _to_hash(value)
246
+ end
247
+ hash
248
+ end
249
+
250
+ # Outputs non-array value in the form of hash
251
+ # For object, use to_hash. Otherwise, just return the value
252
+ # @param [Object] value Any valid value
253
+ # @return [Hash] Returns the value in the form of hash
254
+ def _to_hash(value)
255
+ if value.is_a?(Array)
256
+ value.compact.map { |v| _to_hash(v) }
257
+ elsif value.is_a?(Hash)
258
+ {}.tap do |hash|
259
+ value.each { |k, v| hash[k] = _to_hash(v) }
260
+ end
261
+ elsif value.respond_to? :to_hash
262
+ value.to_hash
263
+ else
264
+ value
265
+ end
266
+ end
267
+
268
+ end
269
+
270
+ end