tremendous_ruby 5.14.0 → 5.15.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c5dd6664a6eefcc985f6a14c06479a546be0159faa9ec89c9de1453a464ee5b
4
- data.tar.gz: 64512c466b295d0cd90efac6774506d6dcc94f32a2f6a587d5fe4f25596e001c
3
+ metadata.gz: 8eaeb1b57c85cd5112378f641e50ca2c7e37600857fe56116146e0e3a47b951c
4
+ data.tar.gz: 07a62d978ad70d5c8c2e4ec020b1535258fbf1dd014d04124f2c8a4ca9f40446
5
5
  SHA512:
6
- metadata.gz: b971bd05346daf9744ad93b796b3101d0e62df5b8f3b6023da23f0443f58a6e809c7318324f1f71b0d7e40551d5d1b4666c6322066e1c0c6a4db147be1a786e8
7
- data.tar.gz: 4f2489025b53b3b4b5eb28830b1913e3b7faf67dc46463757e624423b827f81c6e6da68463d8b1cb98da720eb139dabc225e74a17c2ec3e7c7a6d98521066a6c
6
+ metadata.gz: 18007403ac4a6dc63966de049f0033a9e455296e070ec349bb4f5b0da0078aa1568eea6aefb0461e0e6cb98aa04c88203750d356116975c0912e686cba4c3378
7
+ data.tar.gz: a55869240fef9138b37e2f35c93ea99ecd9ff21133b10c0c3cdf97ff4c1073e1b5a5958bcb1ccc26f8def68f481ebeefd500c4ed9e44cbb171caab900440a0d9
@@ -551,6 +551,74 @@ module Tremendous
551
551
  return data, status_code, headers
552
552
  end
553
553
 
554
+ # Create field
555
+ # Create a custom field to be associated with rewards. Custom fields can be used for reporting and analytics purposes.
556
+ # @param create_field_request [CreateFieldRequest] Field details
557
+ # @param [Hash] opts the optional parameters
558
+ # @return [CreateField200Response]
559
+ def create_field(create_field_request, opts = {})
560
+ data, _status_code, _headers = create_field_with_http_info(create_field_request, opts)
561
+ data
562
+ end
563
+
564
+ # Create field
565
+ # Create a custom field to be associated with rewards. Custom fields can be used for reporting and analytics purposes.
566
+ # @param create_field_request [CreateFieldRequest] Field details
567
+ # @param [Hash] opts the optional parameters
568
+ # @return [Array<(CreateField200Response, Integer, Hash)>] CreateField200Response data, response status code and response headers
569
+ def create_field_with_http_info(create_field_request, opts = {})
570
+ if @api_client.config.debugging
571
+ @api_client.config.logger.debug 'Calling API: TremendousApi.create_field ...'
572
+ end
573
+ # verify the required parameter 'create_field_request' is set
574
+ if @api_client.config.client_side_validation && create_field_request.nil?
575
+ fail ArgumentError, "Missing the required parameter 'create_field_request' when calling TremendousApi.create_field"
576
+ end
577
+ # resource path
578
+ local_var_path = '/fields'
579
+
580
+ # query parameters
581
+ query_params = opts[:query_params] || {}
582
+
583
+ # header parameters
584
+ header_params = opts[:header_params] || {}
585
+ # HTTP header 'Accept' (if needed)
586
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
587
+ # HTTP header 'Content-Type'
588
+ content_type = @api_client.select_header_content_type(['application/json'])
589
+ if !content_type.nil?
590
+ header_params['Content-Type'] = content_type
591
+ end
592
+
593
+ # form parameters
594
+ form_params = opts[:form_params] || {}
595
+
596
+ # http body (model)
597
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(create_field_request)
598
+
599
+ # return_type
600
+ return_type = opts[:debug_return_type] || 'CreateField200Response'
601
+
602
+ # auth_names
603
+ auth_names = opts[:debug_auth_names] || ['BearerApiKey']
604
+
605
+ new_options = opts.merge(
606
+ :operation => :"TremendousApi.create_field",
607
+ :header_params => header_params,
608
+ :query_params => query_params,
609
+ :form_params => form_params,
610
+ :body => post_body,
611
+ :auth_names => auth_names,
612
+ :return_type => return_type
613
+ )
614
+
615
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
616
+ if @api_client.config.debugging
617
+ @api_client.config.logger.debug "API called: TremendousApi#create_field\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
618
+ end
619
+ return data, status_code, headers
620
+ end
621
+
554
622
  # Create invoice
555
623
  # Creating an invoice is the way for your organization to fund your account's balance. 1. Create an invoice 2. Pay the invoice 3. Funds get added to your account's balance ## Request body <div class=\"object-schema-request-schema\"> <table> <thead> <tr> <th>Property</th> <th>Type</th> <th>Description</th> </tr> </thead> <tbody class=\"object-schema-table-body\"> <tr class=\"\"><td><div class=\"property-name\"> <code class=\"property-name\">po_number</code> </div> </td><td><span class=\"property-type\">string</span></td><td><p>Reference to the purchase order number within your organization</p> </td></tr> <tr class=\"\"><td><div class=\"property-name\"> <code class=\"property-name\">amount</code> </div> </td><td><span class=\"property-type\">number</span> <span class=\"property-format\">double</span></td><td><p>Amount of the invoice</p> </td></tr> <tr class=\"\"><td><div class=\"property-name\"> <code class=\"property-name\">currency</code> </div> </td><td><span class=\"property-type\">string</span></td><td><p>Currency of the invoice</p> </td></tr> <tr class=\"\"><td><div class=\"property-name\"> <code class=\"property-name\">memo</code> </div> </td><td><span class=\"property-type\">string</span></td><td><p>A note to be included in the invoice. This is for your internal use and will not be visible to the recipient.</p> </td></tr> </tbody> </table> </div>
556
624
  # @param create_invoice_request [CreateInvoiceRequest] Invoice details
@@ -0,0 +1,320 @@
1
+ =begin
2
+ #API Endpoints
3
+
4
+ #Deliver monetary rewards and incentives to employees, customers, survey participants, and more through the Tremendous API. For organizational tasks, like managing your organization and its members within Tremendous, please see the Tremendous Organizational API.
5
+
6
+ The version of the OpenAPI document: 2
7
+ Contact: developers@tremendous.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.12.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Tremendous
17
+ class CreateField
18
+ # A human-readable name for the field. Can contain letters, numbers, spaces, and underscores. The field's `label` (a reference name used in API requests) will be automatically derived from this value.
19
+ attr_accessor :display_name
20
+
21
+ # Type of the values of the field <table> <thead> <tr> <th>Type</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code>Checkbox</code></td> <td>A boolean value (true/false)</td> </tr> <tr> <td><code>Currency</code></td> <td>A monetary value</td> </tr> <tr> <td><code>Date</code></td> <td>A date value</td> </tr> <tr> <td><code>Dropdown</code></td> <td>A single selection from predefined options (see <code>data.options</code>)</td> </tr> <tr> <td><code>Email</code></td> <td>An email address</td> </tr> <tr> <td><code>List</code></td> <td>Multiple selections from predefined options (see <code>data.options</code>)</td> </tr> <tr> <td><code>Number</code></td> <td>A numeric value</td> </tr> <tr> <td><code>Phone</code></td> <td>A phone number</td> </tr> <tr> <td><code>Text</code></td> <td>A single-line text value</td> </tr> <tr> <td><code>TextArea</code></td> <td>A multi-line text value</td> </tr> </tbody> </table>
22
+ attr_accessor :data_type
23
+
24
+ attr_accessor :data
25
+
26
+ # Is this field required (true) or optional (false). Defaults to false.
27
+ attr_accessor :required
28
+
29
+ # A description of the field's purpose
30
+ attr_accessor :description
31
+
32
+ class EnumAttributeValidator
33
+ attr_reader :datatype
34
+ attr_reader :allowable_values
35
+
36
+ def initialize(datatype, allowable_values)
37
+ @allowable_values = allowable_values.map do |value|
38
+ case datatype.to_s
39
+ when /Integer/i
40
+ value.to_i
41
+ when /Float/i
42
+ value.to_f
43
+ else
44
+ value
45
+ end
46
+ end
47
+ end
48
+
49
+ def valid?(value)
50
+ !value || allowable_values.include?(value)
51
+ end
52
+ end
53
+
54
+ # Attribute mapping from ruby-style variable name to JSON key.
55
+ def self.attribute_map
56
+ {
57
+ :'display_name' => :'display_name',
58
+ :'data_type' => :'data_type',
59
+ :'data' => :'data',
60
+ :'required' => :'required',
61
+ :'description' => :'description'
62
+ }
63
+ end
64
+
65
+ # Returns attribute mapping this model knows about
66
+ def self.acceptable_attribute_map
67
+ attribute_map
68
+ end
69
+
70
+ # Returns all the JSON keys this model knows about
71
+ def self.acceptable_attributes
72
+ acceptable_attribute_map.values
73
+ end
74
+
75
+ # Attribute type mapping.
76
+ def self.openapi_types
77
+ {
78
+ :'display_name' => :'String',
79
+ :'data_type' => :'String',
80
+ :'data' => :'CreateFieldRequestData',
81
+ :'required' => :'Boolean',
82
+ :'description' => :'String'
83
+ }
84
+ end
85
+
86
+ # List of attributes with nullable: true
87
+ def self.openapi_nullable
88
+ Set.new([
89
+ ])
90
+ end
91
+
92
+ # Initializes the object
93
+ # @param [Hash] attributes Model attributes in the form of hash
94
+ def initialize(attributes = {})
95
+ if (!attributes.is_a?(Hash))
96
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::CreateField` initialize method"
97
+ end
98
+
99
+ # check to see if the attribute exists and convert string to symbol for hash key
100
+ acceptable_attribute_map = self.class.acceptable_attribute_map
101
+ attributes = attributes.each_with_object({}) { |(k, v), h|
102
+ if (!acceptable_attribute_map.key?(k.to_sym))
103
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::CreateField`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
104
+ end
105
+ h[k.to_sym] = v
106
+ }
107
+
108
+ if attributes.key?(:'display_name')
109
+ self.display_name = attributes[:'display_name']
110
+ else
111
+ self.display_name = nil
112
+ end
113
+
114
+ if attributes.key?(:'data_type')
115
+ self.data_type = attributes[:'data_type']
116
+ else
117
+ self.data_type = nil
118
+ end
119
+
120
+ if attributes.key?(:'data')
121
+ self.data = attributes[:'data']
122
+ end
123
+
124
+ if attributes.key?(:'required')
125
+ self.required = attributes[:'required']
126
+ else
127
+ self.required = false
128
+ end
129
+
130
+ if attributes.key?(:'description')
131
+ self.description = attributes[:'description']
132
+ end
133
+ end
134
+
135
+ # Show invalid properties with the reasons. Usually used together with valid?
136
+ # @return Array for valid properties with the reasons
137
+ def list_invalid_properties
138
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
139
+ invalid_properties = Array.new
140
+ if @display_name.nil?
141
+ invalid_properties.push('invalid value for "display_name", display_name cannot be nil.')
142
+ end
143
+
144
+ if @data_type.nil?
145
+ invalid_properties.push('invalid value for "data_type", data_type cannot be nil.')
146
+ end
147
+
148
+ invalid_properties
149
+ end
150
+
151
+ # Check to see if the all the properties in the model are valid
152
+ # @return true if the model is valid
153
+ def valid?
154
+ warn '[DEPRECATED] the `valid?` method is obsolete'
155
+ return false if @display_name.nil?
156
+ return false if @data_type.nil?
157
+ data_type_validator = EnumAttributeValidator.new('String', ["Checkbox", "Currency", "Date", "Dropdown", "Email", "List", "Number", "Phone", "Text", "TextArea"])
158
+ return false unless data_type_validator.valid?(@data_type)
159
+ true
160
+ end
161
+
162
+ # Custom attribute writer method with validation
163
+ # @param [Object] display_name Value to be assigned
164
+ def display_name=(display_name)
165
+ if display_name.nil?
166
+ fail ArgumentError, 'display_name cannot be nil'
167
+ end
168
+
169
+ @display_name = display_name
170
+ end
171
+
172
+ # Custom attribute writer method checking allowed values (enum).
173
+ # @param [Object] data_type Object to be assigned
174
+ def data_type=(data_type)
175
+ validator = EnumAttributeValidator.new('String', ["Checkbox", "Currency", "Date", "Dropdown", "Email", "List", "Number", "Phone", "Text", "TextArea"])
176
+ unless validator.valid?(data_type)
177
+ fail ArgumentError, "invalid value for \"data_type\", must be one of #{validator.allowable_values}."
178
+ end
179
+ @data_type = data_type
180
+ end
181
+
182
+ # Checks equality by comparing each attribute.
183
+ # @param [Object] Object to be compared
184
+ def ==(o)
185
+ return true if self.equal?(o)
186
+ self.class == o.class &&
187
+ display_name == o.display_name &&
188
+ data_type == o.data_type &&
189
+ data == o.data &&
190
+ required == o.required &&
191
+ description == o.description
192
+ end
193
+
194
+ # @see the `==` method
195
+ # @param [Object] Object to be compared
196
+ def eql?(o)
197
+ self == o
198
+ end
199
+
200
+ # Calculates hash code according to all attributes.
201
+ # @return [Integer] Hash code
202
+ def hash
203
+ [display_name, data_type, data, required, description].hash
204
+ end
205
+
206
+ # Builds the object from hash
207
+ # @param [Hash] attributes Model attributes in the form of hash
208
+ # @return [Object] Returns the model itself
209
+ def self.build_from_hash(attributes)
210
+ return nil unless attributes.is_a?(Hash)
211
+ attributes = attributes.transform_keys(&:to_sym)
212
+ transformed_hash = {}
213
+ openapi_types.each_pair do |key, type|
214
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
215
+ transformed_hash["#{key}"] = nil
216
+ elsif type =~ /\AArray<(.*)>/i
217
+ # check to ensure the input is an array given that the attribute
218
+ # is documented as an array but the input is not
219
+ if attributes[attribute_map[key]].is_a?(Array)
220
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
221
+ end
222
+ elsif !attributes[attribute_map[key]].nil?
223
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
224
+ end
225
+ end
226
+ new(transformed_hash)
227
+ end
228
+
229
+ # Deserializes the data based on type
230
+ # @param string type Data type
231
+ # @param string value Value to be deserialized
232
+ # @return [Object] Deserialized data
233
+ def self._deserialize(type, value)
234
+ case type.to_sym
235
+ when :Time
236
+ Time.parse(value)
237
+ when :Date
238
+ Date.parse(value)
239
+ when :String
240
+ value.to_s
241
+ when :Integer
242
+ value.to_i
243
+ when :Float
244
+ value.to_f
245
+ when :Boolean
246
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
247
+ true
248
+ else
249
+ false
250
+ end
251
+ when :Object
252
+ # generic object (usually a Hash), return directly
253
+ value
254
+ when /\AArray<(?<inner_type>.+)>\z/
255
+ inner_type = Regexp.last_match[:inner_type]
256
+ value.map { |v| _deserialize(inner_type, v) }
257
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
258
+ k_type = Regexp.last_match[:k_type]
259
+ v_type = Regexp.last_match[:v_type]
260
+ {}.tap do |hash|
261
+ value.each do |k, v|
262
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
263
+ end
264
+ end
265
+ else # model
266
+ # models (e.g. Pet) or oneOf
267
+ klass = Tremendous.const_get(type)
268
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
269
+ end
270
+ end
271
+
272
+ # Returns the string representation of the object
273
+ # @return [String] String presentation of the object
274
+ def to_s
275
+ to_hash.to_s
276
+ end
277
+
278
+ # to_body is an alias to to_hash (backward compatibility)
279
+ # @return [Hash] Returns the object in the form of hash
280
+ def to_body
281
+ to_hash
282
+ end
283
+
284
+ # Returns the object in the form of hash
285
+ # @return [Hash] Returns the object in the form of hash
286
+ def to_hash
287
+ hash = {}
288
+ self.class.attribute_map.each_pair do |attr, param|
289
+ value = self.send(attr)
290
+ if value.nil?
291
+ is_nullable = self.class.openapi_nullable.include?(attr)
292
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
293
+ end
294
+
295
+ hash[param] = _to_hash(value)
296
+ end
297
+ hash
298
+ end
299
+
300
+ # Outputs non-array value in the form of hash
301
+ # For object, use to_hash. Otherwise, just return the value
302
+ # @param [Object] value Any valid value
303
+ # @return [Hash] Returns the value in the form of hash
304
+ def _to_hash(value)
305
+ if value.is_a?(Array)
306
+ value.compact.map { |v| _to_hash(v) }
307
+ elsif value.is_a?(Hash)
308
+ {}.tap do |hash|
309
+ value.each { |k, v| hash[k] = _to_hash(v) }
310
+ end
311
+ elsif value.respond_to? :to_hash
312
+ value.to_hash
313
+ else
314
+ value
315
+ end
316
+ end
317
+
318
+ end
319
+
320
+ end
@@ -0,0 +1,237 @@
1
+ =begin
2
+ #API Endpoints
3
+
4
+ #Deliver monetary rewards and incentives to employees, customers, survey participants, and more through the Tremendous API. For organizational tasks, like managing your organization and its members within Tremendous, please see the Tremendous Organizational API.
5
+
6
+ The version of the OpenAPI document: 2
7
+ Contact: developers@tremendous.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.12.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Tremendous
17
+ class CreateField200Response
18
+ attr_accessor :field
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'field' => :'field'
24
+ }
25
+ end
26
+
27
+ # Returns attribute mapping this model knows about
28
+ def self.acceptable_attribute_map
29
+ attribute_map
30
+ end
31
+
32
+ # Returns all the JSON keys this model knows about
33
+ def self.acceptable_attributes
34
+ acceptable_attribute_map.values
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.openapi_types
39
+ {
40
+ :'field' => :'ListFields200ResponseFieldsInner'
41
+ }
42
+ end
43
+
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new([
47
+ ])
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::CreateField200Response` initialize method"
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ acceptable_attribute_map = self.class.acceptable_attribute_map
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!acceptable_attribute_map.key?(k.to_sym))
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::CreateField200Response`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
62
+ end
63
+ h[k.to_sym] = v
64
+ }
65
+
66
+ if attributes.key?(:'field')
67
+ self.field = attributes[:'field']
68
+ else
69
+ self.field = nil
70
+ end
71
+ end
72
+
73
+ # Show invalid properties with the reasons. Usually used together with valid?
74
+ # @return Array for valid properties with the reasons
75
+ def list_invalid_properties
76
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
77
+ invalid_properties = Array.new
78
+ if @field.nil?
79
+ invalid_properties.push('invalid value for "field", field cannot be nil.')
80
+ end
81
+
82
+ invalid_properties
83
+ end
84
+
85
+ # Check to see if the all the properties in the model are valid
86
+ # @return true if the model is valid
87
+ def valid?
88
+ warn '[DEPRECATED] the `valid?` method is obsolete'
89
+ return false if @field.nil?
90
+ true
91
+ end
92
+
93
+ # Custom attribute writer method with validation
94
+ # @param [Object] field Value to be assigned
95
+ def field=(field)
96
+ if field.nil?
97
+ fail ArgumentError, 'field cannot be nil'
98
+ end
99
+
100
+ @field = field
101
+ end
102
+
103
+ # Checks equality by comparing each attribute.
104
+ # @param [Object] Object to be compared
105
+ def ==(o)
106
+ return true if self.equal?(o)
107
+ self.class == o.class &&
108
+ field == o.field
109
+ end
110
+
111
+ # @see the `==` method
112
+ # @param [Object] Object to be compared
113
+ def eql?(o)
114
+ self == o
115
+ end
116
+
117
+ # Calculates hash code according to all attributes.
118
+ # @return [Integer] Hash code
119
+ def hash
120
+ [field].hash
121
+ end
122
+
123
+ # Builds the object from hash
124
+ # @param [Hash] attributes Model attributes in the form of hash
125
+ # @return [Object] Returns the model itself
126
+ def self.build_from_hash(attributes)
127
+ return nil unless attributes.is_a?(Hash)
128
+ attributes = attributes.transform_keys(&:to_sym)
129
+ transformed_hash = {}
130
+ openapi_types.each_pair do |key, type|
131
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
132
+ transformed_hash["#{key}"] = nil
133
+ elsif type =~ /\AArray<(.*)>/i
134
+ # check to ensure the input is an array given that the attribute
135
+ # is documented as an array but the input is not
136
+ if attributes[attribute_map[key]].is_a?(Array)
137
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
138
+ end
139
+ elsif !attributes[attribute_map[key]].nil?
140
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
141
+ end
142
+ end
143
+ new(transformed_hash)
144
+ end
145
+
146
+ # Deserializes the data based on type
147
+ # @param string type Data type
148
+ # @param string value Value to be deserialized
149
+ # @return [Object] Deserialized data
150
+ def self._deserialize(type, value)
151
+ case type.to_sym
152
+ when :Time
153
+ Time.parse(value)
154
+ when :Date
155
+ Date.parse(value)
156
+ when :String
157
+ value.to_s
158
+ when :Integer
159
+ value.to_i
160
+ when :Float
161
+ value.to_f
162
+ when :Boolean
163
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
164
+ true
165
+ else
166
+ false
167
+ end
168
+ when :Object
169
+ # generic object (usually a Hash), return directly
170
+ value
171
+ when /\AArray<(?<inner_type>.+)>\z/
172
+ inner_type = Regexp.last_match[:inner_type]
173
+ value.map { |v| _deserialize(inner_type, v) }
174
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
175
+ k_type = Regexp.last_match[:k_type]
176
+ v_type = Regexp.last_match[:v_type]
177
+ {}.tap do |hash|
178
+ value.each do |k, v|
179
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
180
+ end
181
+ end
182
+ else # model
183
+ # models (e.g. Pet) or oneOf
184
+ klass = Tremendous.const_get(type)
185
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
186
+ end
187
+ end
188
+
189
+ # Returns the string representation of the object
190
+ # @return [String] String presentation of the object
191
+ def to_s
192
+ to_hash.to_s
193
+ end
194
+
195
+ # to_body is an alias to to_hash (backward compatibility)
196
+ # @return [Hash] Returns the object in the form of hash
197
+ def to_body
198
+ to_hash
199
+ end
200
+
201
+ # Returns the object in the form of hash
202
+ # @return [Hash] Returns the object in the form of hash
203
+ def to_hash
204
+ hash = {}
205
+ self.class.attribute_map.each_pair do |attr, param|
206
+ value = self.send(attr)
207
+ if value.nil?
208
+ is_nullable = self.class.openapi_nullable.include?(attr)
209
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
210
+ end
211
+
212
+ hash[param] = _to_hash(value)
213
+ end
214
+ hash
215
+ end
216
+
217
+ # Outputs non-array value in the form of hash
218
+ # For object, use to_hash. Otherwise, just return the value
219
+ # @param [Object] value Any valid value
220
+ # @return [Hash] Returns the value in the form of hash
221
+ def _to_hash(value)
222
+ if value.is_a?(Array)
223
+ value.compact.map { |v| _to_hash(v) }
224
+ elsif value.is_a?(Hash)
225
+ {}.tap do |hash|
226
+ value.each { |k, v| hash[k] = _to_hash(v) }
227
+ end
228
+ elsif value.respond_to? :to_hash
229
+ value.to_hash
230
+ else
231
+ value
232
+ end
233
+ end
234
+
235
+ end
236
+
237
+ end