ultracart_api 4.1.236 → 4.1.238

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 (33) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +20 -2
  3. data/docs/SfvbApi.md +338 -0
  4. data/docs/SfvbApprovalCreateRequest.md +4 -0
  5. data/docs/SfvbDocsGap.md +28 -0
  6. data/docs/SfvbDocsGapReport.md +24 -0
  7. data/docs/SfvbDocsGapReportGap.md +26 -0
  8. data/docs/SfvbItemPreorder.md +36 -0
  9. data/docs/SfvbItemPreorderChange.md +24 -0
  10. data/docs/SfvbItemPreorderChildRow.md +20 -0
  11. data/docs/SfvbItemPreorderChildrenRequest.md +24 -0
  12. data/docs/SfvbItemPreorderListResponse.md +20 -0
  13. data/docs/SfvbItemPreorderOption.md +20 -0
  14. data/docs/SfvbItemPreorderRequest.md +22 -0
  15. data/docs/SfvbWhoamiResponse.md +4 -0
  16. data/docs/TaxJarConfig.md +2 -0
  17. data/lib/ultracart_api/api/sfvb_api.rb +451 -0
  18. data/lib/ultracart_api/models/sfvb_approval_create_request.rb +21 -3
  19. data/lib/ultracart_api/models/sfvb_docs_gap.rb +304 -0
  20. data/lib/ultracart_api/models/sfvb_docs_gap_report.rb +249 -0
  21. data/lib/ultracart_api/models/sfvb_docs_gap_report_gap.rb +262 -0
  22. data/lib/ultracart_api/models/sfvb_item_preorder.rb +347 -0
  23. data/lib/ultracart_api/models/sfvb_item_preorder_change.rb +250 -0
  24. data/lib/ultracart_api/models/sfvb_item_preorder_child_row.rb +230 -0
  25. data/lib/ultracart_api/models/sfvb_item_preorder_children_request.rb +252 -0
  26. data/lib/ultracart_api/models/sfvb_item_preorder_list_response.rb +231 -0
  27. data/lib/ultracart_api/models/sfvb_item_preorder_option.rb +230 -0
  28. data/lib/ultracart_api/models/sfvb_item_preorder_request.rb +240 -0
  29. data/lib/ultracart_api/models/sfvb_whoami_response.rb +21 -1
  30. data/lib/ultracart_api/models/tax_jar_config.rb +11 -1
  31. data/lib/ultracart_api/version.rb +1 -1
  32. data/lib/ultracart_api.rb +10 -0
  33. metadata +22 -2
@@ -34,6 +34,10 @@ module UltracartClient
34
34
  # 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.
35
35
  attr_accessor :item_attribute_rows
36
36
 
37
+ attr_accessor :item_preorder
38
+
39
+ attr_accessor :item_preorder_children
40
+
37
41
  attr_accessor :item_pricing
38
42
 
39
43
  attr_accessor :params
@@ -89,6 +93,8 @@ module UltracartClient
89
93
  :'experiment_start' => :'experiment_start',
90
94
  :'flow_backfill' => :'flow_backfill',
91
95
  :'item_attribute_rows' => :'item_attribute_rows',
96
+ :'item_preorder' => :'item_preorder',
97
+ :'item_preorder_children' => :'item_preorder_children',
92
98
  :'item_pricing' => :'item_pricing',
93
99
  :'params' => :'params',
94
100
  :'postcard_test_mail' => :'postcard_test_mail',
@@ -118,6 +124,8 @@ module UltracartClient
118
124
  :'experiment_start' => :'SfvbExperimentStartRequest',
119
125
  :'flow_backfill' => :'SfvbFlowBackfillRequest',
120
126
  :'item_attribute_rows' => :'Array<SfvbItemAttributeBatchRow>',
127
+ :'item_preorder' => :'SfvbItemPreorderRequest',
128
+ :'item_preorder_children' => :'SfvbItemPreorderChildrenRequest',
121
129
  :'item_pricing' => :'SfvbItemPricingRequest',
122
130
  :'params' => :'SfvbApprovalParams',
123
131
  :'postcard_test_mail' => :'SfvbCommsTestPostcardRequest',
@@ -186,6 +194,14 @@ module UltracartClient
186
194
  end
187
195
  end
188
196
 
197
+ if attributes.key?(:'item_preorder')
198
+ self.item_preorder = attributes[:'item_preorder']
199
+ end
200
+
201
+ if attributes.key?(:'item_preorder_children')
202
+ self.item_preorder_children = attributes[:'item_preorder_children']
203
+ end
204
+
189
205
  if attributes.key?(:'item_pricing')
190
206
  self.item_pricing = attributes[:'item_pricing']
191
207
  end
@@ -239,7 +255,7 @@ module UltracartClient
239
255
  # Check to see if the all the properties in the model are valid
240
256
  # @return true if the model is valid
241
257
  def valid?
242
- 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", "twilio_account.delete", "sending_domain.delete", "sequence_step.delete", "sequence_step.move", "sequence_step.enable_postcard", "segment.update", "smart_attribution.change", "smart_attribution.delete", "tracking_provider.change", "tracking_provider.clear", "tracking_html.put", "affiliate_network.change", "affiliate_network.delete", "site_seo.change", "transactional_email.update", "comms_settings.update", "comms_list.import", "postcard.test_mail", "flow.backfill"])
258
+ 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", "item.preorder", "twilio_account.delete", "sending_domain.delete", "sequence_step.delete", "sequence_step.move", "sequence_step.enable_postcard", "segment.update", "smart_attribution.change", "smart_attribution.delete", "tracking_provider.change", "tracking_provider.clear", "tracking_html.put", "affiliate_network.change", "affiliate_network.delete", "site_seo.change", "transactional_email.update", "comms_settings.update", "comms_list.import", "postcard.test_mail", "flow.backfill"])
243
259
  return false unless action_validator.valid?(@action)
244
260
  true
245
261
  end
@@ -247,7 +263,7 @@ module UltracartClient
247
263
  # Custom attribute writer method checking allowed values (enum).
248
264
  # @param [Object] action Object to be assigned
249
265
  def action=(action)
250
- 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", "twilio_account.delete", "sending_domain.delete", "sequence_step.delete", "sequence_step.move", "sequence_step.enable_postcard", "segment.update", "smart_attribution.change", "smart_attribution.delete", "tracking_provider.change", "tracking_provider.clear", "tracking_html.put", "affiliate_network.change", "affiliate_network.delete", "site_seo.change", "transactional_email.update", "comms_settings.update", "comms_list.import", "postcard.test_mail", "flow.backfill"])
266
+ 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", "item.preorder", "twilio_account.delete", "sending_domain.delete", "sequence_step.delete", "sequence_step.move", "sequence_step.enable_postcard", "segment.update", "smart_attribution.change", "smart_attribution.delete", "tracking_provider.change", "tracking_provider.clear", "tracking_html.put", "affiliate_network.change", "affiliate_network.delete", "site_seo.change", "transactional_email.update", "comms_settings.update", "comms_list.import", "postcard.test_mail", "flow.backfill"])
251
267
  unless validator.valid?(action)
252
268
  fail ArgumentError, "invalid value for \"action\", must be one of #{validator.allowable_values}."
253
269
  end
@@ -267,6 +283,8 @@ module UltracartClient
267
283
  experiment_start == o.experiment_start &&
268
284
  flow_backfill == o.flow_backfill &&
269
285
  item_attribute_rows == o.item_attribute_rows &&
286
+ item_preorder == o.item_preorder &&
287
+ item_preorder_children == o.item_preorder_children &&
270
288
  item_pricing == o.item_pricing &&
271
289
  params == o.params &&
272
290
  postcard_test_mail == o.postcard_test_mail &&
@@ -288,7 +306,7 @@ module UltracartClient
288
306
  # Calculates hash code according to all attributes.
289
307
  # @return [Integer] Hash code
290
308
  def hash
291
- [action, affiliate_network, comms_list_import, comms_settings, content, experiment_start, flow_backfill, item_attribute_rows, item_pricing, params, postcard_test_mail, reason, redirect_rows, segment_update, site_seo, smart_attribution, tracking_provider, transactional_email].hash
309
+ [action, affiliate_network, comms_list_import, comms_settings, content, experiment_start, flow_backfill, item_attribute_rows, item_preorder, item_preorder_children, item_pricing, params, postcard_test_mail, reason, redirect_rows, segment_update, site_seo, smart_attribution, tracking_provider, transactional_email].hash
292
310
  end
293
311
 
294
312
  # Builds the object from hash
@@ -0,0 +1,304 @@
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 SfvbDocsGap
18
+ # On submit, true when this account had already sent the same report. The earlier report_id is returned and nothing new is kept.
19
+ attr_accessor :duplicate
20
+
21
+ # When UltraCart received the report.
22
+ attr_accessor :received_at
23
+
24
+ # The report's id. Quote it to UltraCart, or look the report up with GET docs/gaps/{report_id}.
25
+ attr_accessor :report_id
26
+
27
+ # received until UltraCart staff look at it, then accepted, declined or fixed.
28
+ attr_accessor :status
29
+
30
+ # When the status last changed. Absent while the report is received.
31
+ attr_accessor :status_at
32
+
33
+ # The storefront named when the report was sent, if one was.
34
+ attr_accessor :storefront_oid
35
+
36
+ class EnumAttributeValidator
37
+ attr_reader :datatype
38
+ attr_reader :allowable_values
39
+
40
+ def initialize(datatype, allowable_values)
41
+ @allowable_values = allowable_values.map do |value|
42
+ case datatype.to_s
43
+ when /Integer/i
44
+ value.to_i
45
+ when /Float/i
46
+ value.to_f
47
+ else
48
+ value
49
+ end
50
+ end
51
+ end
52
+
53
+ def valid?(value)
54
+ !value || allowable_values.include?(value)
55
+ end
56
+ end
57
+
58
+ # Attribute mapping from ruby-style variable name to JSON key.
59
+ def self.attribute_map
60
+ {
61
+ :'duplicate' => :'duplicate',
62
+ :'received_at' => :'received_at',
63
+ :'report_id' => :'report_id',
64
+ :'status' => :'status',
65
+ :'status_at' => :'status_at',
66
+ :'storefront_oid' => :'storefront_oid'
67
+ }
68
+ end
69
+
70
+ # Returns all the JSON keys this model knows about
71
+ def self.acceptable_attributes
72
+ attribute_map.values
73
+ end
74
+
75
+ # Attribute type mapping.
76
+ def self.openapi_types
77
+ {
78
+ :'duplicate' => :'Boolean',
79
+ :'received_at' => :'String',
80
+ :'report_id' => :'String',
81
+ :'status' => :'String',
82
+ :'status_at' => :'String',
83
+ :'storefront_oid' => :'Integer'
84
+ }
85
+ end
86
+
87
+ # List of attributes with nullable: true
88
+ def self.openapi_nullable
89
+ Set.new([
90
+ ])
91
+ end
92
+
93
+ # Initializes the object
94
+ # @param [Hash] attributes Model attributes in the form of hash
95
+ def initialize(attributes = {})
96
+ if (!attributes.is_a?(Hash))
97
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::SfvbDocsGap` initialize method"
98
+ end
99
+
100
+ # check to see if the attribute exists and convert string to symbol for hash key
101
+ attributes = attributes.each_with_object({}) { |(k, v), h|
102
+ if (!self.class.attribute_map.key?(k.to_sym))
103
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::SfvbDocsGap`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
104
+ end
105
+ h[k.to_sym] = v
106
+ }
107
+
108
+ if attributes.key?(:'duplicate')
109
+ self.duplicate = attributes[:'duplicate']
110
+ end
111
+
112
+ if attributes.key?(:'received_at')
113
+ self.received_at = attributes[:'received_at']
114
+ end
115
+
116
+ if attributes.key?(:'report_id')
117
+ self.report_id = attributes[:'report_id']
118
+ end
119
+
120
+ if attributes.key?(:'status')
121
+ self.status = attributes[:'status']
122
+ end
123
+
124
+ if attributes.key?(:'status_at')
125
+ self.status_at = attributes[:'status_at']
126
+ end
127
+
128
+ if attributes.key?(:'storefront_oid')
129
+ self.storefront_oid = attributes[:'storefront_oid']
130
+ end
131
+ end
132
+
133
+ # Show invalid properties with the reasons. Usually used together with valid?
134
+ # @return Array for valid properties with the reasons
135
+ def list_invalid_properties
136
+ invalid_properties = Array.new
137
+ invalid_properties
138
+ end
139
+
140
+ # Check to see if the all the properties in the model are valid
141
+ # @return true if the model is valid
142
+ def valid?
143
+ status_validator = EnumAttributeValidator.new('String', ["received", "accepted", "declined", "fixed"])
144
+ return false unless status_validator.valid?(@status)
145
+ true
146
+ end
147
+
148
+ # Custom attribute writer method checking allowed values (enum).
149
+ # @param [Object] status Object to be assigned
150
+ def status=(status)
151
+ validator = EnumAttributeValidator.new('String', ["received", "accepted", "declined", "fixed"])
152
+ unless validator.valid?(status)
153
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
154
+ end
155
+ @status = status
156
+ end
157
+
158
+ # Checks equality by comparing each attribute.
159
+ # @param [Object] Object to be compared
160
+ def ==(o)
161
+ return true if self.equal?(o)
162
+ self.class == o.class &&
163
+ duplicate == o.duplicate &&
164
+ received_at == o.received_at &&
165
+ report_id == o.report_id &&
166
+ status == o.status &&
167
+ status_at == o.status_at &&
168
+ storefront_oid == o.storefront_oid
169
+ end
170
+
171
+ # @see the `==` method
172
+ # @param [Object] Object to be compared
173
+ def eql?(o)
174
+ self == o
175
+ end
176
+
177
+ # Calculates hash code according to all attributes.
178
+ # @return [Integer] Hash code
179
+ def hash
180
+ [duplicate, received_at, report_id, status, status_at, storefront_oid].hash
181
+ end
182
+
183
+ # Builds the object from hash
184
+ # @param [Hash] attributes Model attributes in the form of hash
185
+ # @return [Object] Returns the model itself
186
+ def self.build_from_hash(attributes)
187
+ new.build_from_hash(attributes)
188
+ end
189
+
190
+ # Builds the object from hash
191
+ # @param [Hash] attributes Model attributes in the form of hash
192
+ # @return [Object] Returns the model itself
193
+ def build_from_hash(attributes)
194
+ return nil unless attributes.is_a?(Hash)
195
+ attributes = attributes.transform_keys(&:to_sym)
196
+ self.class.openapi_types.each_pair do |key, type|
197
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
198
+ self.send("#{key}=", nil)
199
+ elsif type =~ /\AArray<(.*)>/i
200
+ # check to ensure the input is an array given that the attribute
201
+ # is documented as an array but the input is not
202
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
203
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
204
+ end
205
+ elsif !attributes[self.class.attribute_map[key]].nil?
206
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
207
+ end
208
+ end
209
+
210
+ self
211
+ end
212
+
213
+ # Deserializes the data based on type
214
+ # @param string type Data type
215
+ # @param string value Value to be deserialized
216
+ # @return [Object] Deserialized data
217
+ def _deserialize(type, value)
218
+ case type.to_sym
219
+ when :Time
220
+ Time.parse(value)
221
+ when :Date
222
+ Date.parse(value)
223
+ when :String
224
+ value.to_s
225
+ when :Integer
226
+ value.to_i
227
+ when :Float
228
+ value.to_f
229
+ when :Boolean
230
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
231
+ true
232
+ else
233
+ false
234
+ end
235
+ when :Object
236
+ # generic object (usually a Hash), return directly
237
+ value
238
+ when /\AArray<(?<inner_type>.+)>\z/
239
+ inner_type = Regexp.last_match[:inner_type]
240
+ value.map { |v| _deserialize(inner_type, v) }
241
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
242
+ k_type = Regexp.last_match[:k_type]
243
+ v_type = Regexp.last_match[:v_type]
244
+ {}.tap do |hash|
245
+ value.each do |k, v|
246
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
247
+ end
248
+ end
249
+ else # model
250
+ # models (e.g. Pet) or oneOf
251
+ klass = UltracartClient.const_get(type)
252
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
253
+ end
254
+ end
255
+
256
+ # Returns the string representation of the object
257
+ # @return [String] String presentation of the object
258
+ def to_s
259
+ to_hash.to_s
260
+ end
261
+
262
+ # to_body is an alias to to_hash (backward compatibility)
263
+ # @return [Hash] Returns the object in the form of hash
264
+ def to_body
265
+ to_hash
266
+ end
267
+
268
+ # Returns the object in the form of hash
269
+ # @return [Hash] Returns the object in the form of hash
270
+ def to_hash
271
+ hash = {}
272
+ self.class.attribute_map.each_pair do |attr, param|
273
+ value = self.send(attr)
274
+ if value.nil?
275
+ is_nullable = self.class.openapi_nullable.include?(attr)
276
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
277
+ end
278
+
279
+ hash[param] = _to_hash(value)
280
+ end
281
+ hash
282
+ end
283
+
284
+ # Outputs non-array value in the form of hash
285
+ # For object, use to_hash. Otherwise, just return the value
286
+ # @param [Object] value Any valid value
287
+ # @return [Hash] Returns the value in the form of hash
288
+ def _to_hash(value)
289
+ if value.is_a?(Array)
290
+ value.compact.map { |v| _to_hash(v) }
291
+ elsif value.is_a?(Hash)
292
+ {}.tap do |hash|
293
+ value.each { |k, v| hash[k] = _to_hash(v) }
294
+ end
295
+ elsif value.respond_to? :to_hash
296
+ value.to_hash
297
+ else
298
+ value
299
+ end
300
+ end
301
+
302
+ end
303
+
304
+ end
@@ -0,0 +1,249 @@
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 SfvbDocsGapReport
18
+ # When the report was captured, as a UTC ISO-8601 timestamp. Not more than a day ahead of the server's clock.
19
+ attr_accessor :created_at
20
+
21
+ # Always 1.
22
+ attr_accessor :format_version
23
+
24
+ attr_accessor :gap
25
+
26
+ # Always documentation-gap.
27
+ attr_accessor :kind
28
+
29
+ # Attribute mapping from ruby-style variable name to JSON key.
30
+ def self.attribute_map
31
+ {
32
+ :'created_at' => :'created_at',
33
+ :'format_version' => :'format_version',
34
+ :'gap' => :'gap',
35
+ :'kind' => :'kind'
36
+ }
37
+ end
38
+
39
+ # Returns all the JSON keys this model knows about
40
+ def self.acceptable_attributes
41
+ attribute_map.values
42
+ end
43
+
44
+ # Attribute type mapping.
45
+ def self.openapi_types
46
+ {
47
+ :'created_at' => :'String',
48
+ :'format_version' => :'Integer',
49
+ :'gap' => :'SfvbDocsGapReportGap',
50
+ :'kind' => :'String'
51
+ }
52
+ end
53
+
54
+ # List of attributes with nullable: true
55
+ def self.openapi_nullable
56
+ Set.new([
57
+ ])
58
+ end
59
+
60
+ # Initializes the object
61
+ # @param [Hash] attributes Model attributes in the form of hash
62
+ def initialize(attributes = {})
63
+ if (!attributes.is_a?(Hash))
64
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::SfvbDocsGapReport` initialize method"
65
+ end
66
+
67
+ # check to see if the attribute exists and convert string to symbol for hash key
68
+ attributes = attributes.each_with_object({}) { |(k, v), h|
69
+ if (!self.class.attribute_map.key?(k.to_sym))
70
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::SfvbDocsGapReport`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
71
+ end
72
+ h[k.to_sym] = v
73
+ }
74
+
75
+ if attributes.key?(:'created_at')
76
+ self.created_at = attributes[:'created_at']
77
+ end
78
+
79
+ if attributes.key?(:'format_version')
80
+ self.format_version = attributes[:'format_version']
81
+ end
82
+
83
+ if attributes.key?(:'gap')
84
+ self.gap = attributes[:'gap']
85
+ end
86
+
87
+ if attributes.key?(:'kind')
88
+ self.kind = attributes[:'kind']
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
+ created_at == o.created_at &&
111
+ format_version == o.format_version &&
112
+ gap == o.gap &&
113
+ kind == o.kind
114
+ end
115
+
116
+ # @see the `==` method
117
+ # @param [Object] Object to be compared
118
+ def eql?(o)
119
+ self == o
120
+ end
121
+
122
+ # Calculates hash code according to all attributes.
123
+ # @return [Integer] Hash code
124
+ def hash
125
+ [created_at, format_version, gap, kind].hash
126
+ end
127
+
128
+ # Builds the object from hash
129
+ # @param [Hash] attributes Model attributes in the form of hash
130
+ # @return [Object] Returns the model itself
131
+ def self.build_from_hash(attributes)
132
+ new.build_from_hash(attributes)
133
+ end
134
+
135
+ # Builds the object from hash
136
+ # @param [Hash] attributes Model attributes in the form of hash
137
+ # @return [Object] Returns the model itself
138
+ def build_from_hash(attributes)
139
+ return nil unless attributes.is_a?(Hash)
140
+ attributes = attributes.transform_keys(&:to_sym)
141
+ self.class.openapi_types.each_pair do |key, type|
142
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
143
+ self.send("#{key}=", nil)
144
+ elsif type =~ /\AArray<(.*)>/i
145
+ # check to ensure the input is an array given that the attribute
146
+ # is documented as an array but the input is not
147
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
148
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
149
+ end
150
+ elsif !attributes[self.class.attribute_map[key]].nil?
151
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
152
+ end
153
+ end
154
+
155
+ self
156
+ end
157
+
158
+ # Deserializes the data based on type
159
+ # @param string type Data type
160
+ # @param string value Value to be deserialized
161
+ # @return [Object] Deserialized data
162
+ def _deserialize(type, value)
163
+ case type.to_sym
164
+ when :Time
165
+ Time.parse(value)
166
+ when :Date
167
+ Date.parse(value)
168
+ when :String
169
+ value.to_s
170
+ when :Integer
171
+ value.to_i
172
+ when :Float
173
+ value.to_f
174
+ when :Boolean
175
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
176
+ true
177
+ else
178
+ false
179
+ end
180
+ when :Object
181
+ # generic object (usually a Hash), return directly
182
+ value
183
+ when /\AArray<(?<inner_type>.+)>\z/
184
+ inner_type = Regexp.last_match[:inner_type]
185
+ value.map { |v| _deserialize(inner_type, v) }
186
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
187
+ k_type = Regexp.last_match[:k_type]
188
+ v_type = Regexp.last_match[:v_type]
189
+ {}.tap do |hash|
190
+ value.each do |k, v|
191
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
192
+ end
193
+ end
194
+ else # model
195
+ # models (e.g. Pet) or oneOf
196
+ klass = UltracartClient.const_get(type)
197
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
198
+ end
199
+ end
200
+
201
+ # Returns the string representation of the object
202
+ # @return [String] String presentation of the object
203
+ def to_s
204
+ to_hash.to_s
205
+ end
206
+
207
+ # to_body is an alias to to_hash (backward compatibility)
208
+ # @return [Hash] Returns the object in the form of hash
209
+ def to_body
210
+ to_hash
211
+ end
212
+
213
+ # Returns the object in the form of hash
214
+ # @return [Hash] Returns the object in the form of hash
215
+ def to_hash
216
+ hash = {}
217
+ self.class.attribute_map.each_pair do |attr, param|
218
+ value = self.send(attr)
219
+ if value.nil?
220
+ is_nullable = self.class.openapi_nullable.include?(attr)
221
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
222
+ end
223
+
224
+ hash[param] = _to_hash(value)
225
+ end
226
+ hash
227
+ end
228
+
229
+ # Outputs non-array value in the form of hash
230
+ # For object, use to_hash. Otherwise, just return the value
231
+ # @param [Object] value Any valid value
232
+ # @return [Hash] Returns the value in the form of hash
233
+ def _to_hash(value)
234
+ if value.is_a?(Array)
235
+ value.compact.map { |v| _to_hash(v) }
236
+ elsif value.is_a?(Hash)
237
+ {}.tap do |hash|
238
+ value.each { |k, v| hash[k] = _to_hash(v) }
239
+ end
240
+ elsif value.respond_to? :to_hash
241
+ value.to_hash
242
+ else
243
+ value
244
+ end
245
+ end
246
+
247
+ end
248
+
249
+ end