tremendous_ruby 5.3.0 → 5.4.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.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tremendous/api/tremendous_api.rb +571 -9
  3. data/lib/tremendous/models/allow_email.rb +225 -0
  4. data/lib/tremendous/models/allow_email1.rb +225 -0
  5. data/lib/tremendous/models/allow_ip.rb +225 -0
  6. data/lib/tremendous/models/allow_ip1.rb +225 -0
  7. data/lib/tremendous/models/base_order_for_create.rb +232 -0
  8. data/lib/tremendous/models/create_order200_response.rb +1 -1
  9. data/lib/tremendous/models/create_order_request.rb +73 -217
  10. data/lib/tremendous/models/delete_fraud_rule200_response.rb +222 -0
  11. data/lib/tremendous/models/fraud_config_allow_email.rb +224 -0
  12. data/lib/tremendous/models/fraud_config_country.rb +275 -0
  13. data/lib/tremendous/models/fraud_config_country_update_list.rb +224 -0
  14. data/lib/tremendous/models/fraud_config_ip.rb +224 -0
  15. data/lib/tremendous/models/fraud_config_redeemed_rewards_amount.rb +292 -0
  16. data/lib/tremendous/models/fraud_config_redeemed_rewards_count.rb +292 -0
  17. data/lib/tremendous/models/fraud_config_review_email.rb +229 -0
  18. data/lib/tremendous/models/fraud_generic_response.rb +222 -0
  19. data/lib/tremendous/models/fraud_review.rb +351 -0
  20. data/lib/tremendous/models/fraud_review_geo.rb +235 -0
  21. data/lib/tremendous/models/{reward_with_link_delivery.rb → fraud_review_list_item.rb} +26 -51
  22. data/lib/tremendous/models/fraud_review_reason.rb +58 -0
  23. data/lib/tremendous/models/fraud_review_redemption_method.rb +44 -0
  24. data/lib/tremendous/models/fraud_review_related_rewards.rb +304 -0
  25. data/lib/tremendous/models/fraud_review_status.rb +41 -0
  26. data/lib/tremendous/models/fraud_rule200_response.rb +222 -0
  27. data/lib/tremendous/models/fraud_rule400_response.rb +221 -0
  28. data/lib/tremendous/models/fraud_rule422_response.rb +221 -0
  29. data/lib/tremendous/models/fraud_rule_request.rb +214 -0
  30. data/lib/tremendous/models/fraud_rule_request_config.rb +110 -0
  31. data/lib/tremendous/models/fraud_rule_type.rb +49 -0
  32. data/lib/tremendous/models/fraud_rules_list_item.rb +261 -0
  33. data/lib/tremendous/models/get_fraud_review200_response.rb +221 -0
  34. data/lib/tremendous/models/get_fraud_review200_response_fraud_review.rb +351 -0
  35. data/lib/tremendous/models/get_fraud_review200_response_fraud_review_geo.rb +236 -0
  36. data/lib/tremendous/models/get_fraud_review200_response_fraud_review_related_rewards.rb +305 -0
  37. data/lib/tremendous/models/list_campaigns200_response_campaigns_inner_email_style.rb +2 -0
  38. data/lib/tremendous/models/list_campaigns200_response_campaigns_inner_webpage_style.rb +1 -0
  39. data/lib/tremendous/models/list_fraud_reviews200_response.rb +223 -0
  40. data/lib/tremendous/models/{delivery_details_with_link.rb → list_fraud_reviews200_response_fraud_reviews_inner.rb} +26 -51
  41. data/lib/tremendous/models/list_fraud_rules200_response.rb +223 -0
  42. data/lib/tremendous/models/{create_order200_response_order_rewards_inner_delivery.rb → list_fraud_rules200_response_fraud_rules_inner.rb} +28 -63
  43. data/lib/tremendous/models/list_rewards200_response_rewards_inner.rb +0 -21
  44. data/lib/tremendous/models/list_rewards200_response_rewards_inner_value.rb +1 -6
  45. data/lib/tremendous/models/order_without_link_reward.rb +0 -21
  46. data/lib/tremendous/models/public_key.rb +1 -1
  47. data/lib/tremendous/models/public_keys_response_public_keys_inner.rb +1 -1
  48. data/lib/tremendous/models/review_country.rb +276 -0
  49. data/lib/tremendous/models/review_country1.rb +225 -0
  50. data/lib/tremendous/models/review_email.rb +230 -0
  51. data/lib/tremendous/models/review_email1.rb +230 -0
  52. data/lib/tremendous/models/review_ip.rb +225 -0
  53. data/lib/tremendous/models/review_ip1.rb +225 -0
  54. data/lib/tremendous/models/review_redeemed_rewards_amount.rb +293 -0
  55. data/lib/tremendous/models/review_redeemed_rewards_count.rb +293 -0
  56. data/lib/tremendous/models/reward.rb +0 -21
  57. data/lib/tremendous/models/reward_base.rb +0 -21
  58. data/lib/tremendous/models/reward_for_order_create.rb +1 -22
  59. data/lib/tremendous/models/reward_value.rb +1 -6
  60. data/lib/tremendous/models/reward_without_link.rb +0 -21
  61. data/lib/tremendous/models/{order_for_create.rb → single_reward_order.rb} +6 -12
  62. data/lib/tremendous/models/single_reward_order1.rb +242 -0
  63. data/lib/tremendous/models/{create_order_request_payment.rb → single_reward_order1_payment.rb} +3 -3
  64. data/lib/tremendous/models/{create_order_request_reward.rb → single_reward_order1_reward.rb} +5 -26
  65. data/lib/tremendous/models/{create_order_request_reward_custom_fields_inner.rb → single_reward_order1_reward_custom_fields_inner.rb} +3 -3
  66. data/lib/tremendous/models/{create_order_request_reward_delivery.rb → single_reward_order1_reward_delivery.rb} +3 -3
  67. data/lib/tremendous/models/{order_for_create_reward.rb → single_reward_order_reward.rb} +4 -25
  68. data/lib/tremendous/models/{create_order201_response.rb → single_reward_order_without_link.rb} +4 -4
  69. data/lib/tremendous/models/{order_with_link.rb → single_reward_order_without_link_order.rb} +10 -31
  70. data/lib/tremendous/models/update_fraud_rule_list200_response.rb +222 -0
  71. data/lib/tremendous/models/update_fraud_rule_list_request.rb +272 -0
  72. data/lib/tremendous/models/update_fraud_rule_list_request_config.rb +108 -0
  73. data/lib/tremendous/version.rb +1 -1
  74. data/lib/tremendous.rb +56 -15
  75. metadata +59 -18
  76. data/lib/tremendous/models/create_order200_response_order.rb +0 -400
  77. data/lib/tremendous/models/create_order200_response_order_rewards_inner.rb +0 -347
  78. data/lib/tremendous/models/order_with_link_rewards_inner.rb +0 -406
  79. data/lib/tremendous/models/reward_with_link.rb +0 -406
@@ -0,0 +1,292 @@
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 it's 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
+ OpenAPI Generator version: 7.3.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Tremendous
17
+ class FraudConfigRedeemedRewardsAmount
18
+ # The total amount in USD of redeemed rewards to use as a threshold.
19
+ attr_accessor :amount
20
+
21
+ # The period, in days, to consider for the count. Use `all_time` to consider any redeemed rewards.
22
+ attr_accessor :period
23
+
24
+ class EnumAttributeValidator
25
+ attr_reader :datatype
26
+ attr_reader :allowable_values
27
+
28
+ def initialize(datatype, allowable_values)
29
+ @allowable_values = allowable_values.map do |value|
30
+ case datatype.to_s
31
+ when /Integer/i
32
+ value.to_i
33
+ when /Float/i
34
+ value.to_f
35
+ else
36
+ value
37
+ end
38
+ end
39
+ end
40
+
41
+ def valid?(value)
42
+ !value || allowable_values.include?(value)
43
+ end
44
+ end
45
+
46
+ # Attribute mapping from ruby-style variable name to JSON key.
47
+ def self.attribute_map
48
+ {
49
+ :'amount' => :'amount',
50
+ :'period' => :'period'
51
+ }
52
+ end
53
+
54
+ # Returns all the JSON keys this model knows about
55
+ def self.acceptable_attributes
56
+ attribute_map.values
57
+ end
58
+
59
+ # Attribute type mapping.
60
+ def self.openapi_types
61
+ {
62
+ :'amount' => :'Float',
63
+ :'period' => :'String'
64
+ }
65
+ end
66
+
67
+ # List of attributes with nullable: true
68
+ def self.openapi_nullable
69
+ Set.new([
70
+ ])
71
+ end
72
+
73
+ # Initializes the object
74
+ # @param [Hash] attributes Model attributes in the form of hash
75
+ def initialize(attributes = {})
76
+ if (!attributes.is_a?(Hash))
77
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::FraudConfigRedeemedRewardsAmount` initialize method"
78
+ end
79
+
80
+ # check to see if the attribute exists and convert string to symbol for hash key
81
+ attributes = attributes.each_with_object({}) { |(k, v), h|
82
+ if (!self.class.attribute_map.key?(k.to_sym))
83
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::FraudConfigRedeemedRewardsAmount`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
84
+ end
85
+ h[k.to_sym] = v
86
+ }
87
+
88
+ if attributes.key?(:'amount')
89
+ self.amount = attributes[:'amount']
90
+ else
91
+ self.amount = nil
92
+ end
93
+
94
+ if attributes.key?(:'period')
95
+ self.period = attributes[:'period']
96
+ else
97
+ self.period = nil
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
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
105
+ invalid_properties = Array.new
106
+ if @amount.nil?
107
+ invalid_properties.push('invalid value for "amount", amount cannot be nil.')
108
+ end
109
+
110
+ if @amount < 1
111
+ invalid_properties.push('invalid value for "amount", must be greater than or equal to 1.')
112
+ end
113
+
114
+ if @period.nil?
115
+ invalid_properties.push('invalid value for "period", period cannot be nil.')
116
+ end
117
+
118
+ invalid_properties
119
+ end
120
+
121
+ # Check to see if the all the properties in the model are valid
122
+ # @return true if the model is valid
123
+ def valid?
124
+ warn '[DEPRECATED] the `valid?` method is obsolete'
125
+ return false if @amount.nil?
126
+ return false if @amount < 1
127
+ return false if @period.nil?
128
+ period_validator = EnumAttributeValidator.new('String', ["7", "30", "90", "120", "365", "all_time"])
129
+ return false unless period_validator.valid?(@period)
130
+ true
131
+ end
132
+
133
+ # Custom attribute writer method with validation
134
+ # @param [Object] amount Value to be assigned
135
+ def amount=(amount)
136
+ if amount.nil?
137
+ fail ArgumentError, 'amount cannot be nil'
138
+ end
139
+
140
+ if amount < 1
141
+ fail ArgumentError, 'invalid value for "amount", must be greater than or equal to 1.'
142
+ end
143
+
144
+ @amount = amount
145
+ end
146
+
147
+ # Custom attribute writer method checking allowed values (enum).
148
+ # @param [Object] period Object to be assigned
149
+ def period=(period)
150
+ validator = EnumAttributeValidator.new('String', ["7", "30", "90", "120", "365", "all_time"])
151
+ unless validator.valid?(period)
152
+ fail ArgumentError, "invalid value for \"period\", must be one of #{validator.allowable_values}."
153
+ end
154
+ @period = period
155
+ end
156
+
157
+ # Checks equality by comparing each attribute.
158
+ # @param [Object] Object to be compared
159
+ def ==(o)
160
+ return true if self.equal?(o)
161
+ self.class == o.class &&
162
+ amount == o.amount &&
163
+ period == o.period
164
+ end
165
+
166
+ # @see the `==` method
167
+ # @param [Object] Object to be compared
168
+ def eql?(o)
169
+ self == o
170
+ end
171
+
172
+ # Calculates hash code according to all attributes.
173
+ # @return [Integer] Hash code
174
+ def hash
175
+ [amount, period].hash
176
+ end
177
+
178
+ # Builds the object from hash
179
+ # @param [Hash] attributes Model attributes in the form of hash
180
+ # @return [Object] Returns the model itself
181
+ def self.build_from_hash(attributes)
182
+ return nil unless attributes.is_a?(Hash)
183
+ attributes = attributes.transform_keys(&:to_sym)
184
+ transformed_hash = {}
185
+ openapi_types.each_pair do |key, type|
186
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
187
+ transformed_hash["#{key}"] = nil
188
+ elsif type =~ /\AArray<(.*)>/i
189
+ # check to ensure the input is an array given that the attribute
190
+ # is documented as an array but the input is not
191
+ if attributes[attribute_map[key]].is_a?(Array)
192
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
193
+ end
194
+ elsif !attributes[attribute_map[key]].nil?
195
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
196
+ end
197
+ end
198
+ new(transformed_hash)
199
+ end
200
+
201
+ # Deserializes the data based on type
202
+ # @param string type Data type
203
+ # @param string value Value to be deserialized
204
+ # @return [Object] Deserialized data
205
+ def self._deserialize(type, value)
206
+ case type.to_sym
207
+ when :Time
208
+ Time.parse(value)
209
+ when :Date
210
+ Date.parse(value)
211
+ when :String
212
+ value.to_s
213
+ when :Integer
214
+ value.to_i
215
+ when :Float
216
+ value.to_f
217
+ when :Boolean
218
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
219
+ true
220
+ else
221
+ false
222
+ end
223
+ when :Object
224
+ # generic object (usually a Hash), return directly
225
+ value
226
+ when /\AArray<(?<inner_type>.+)>\z/
227
+ inner_type = Regexp.last_match[:inner_type]
228
+ value.map { |v| _deserialize(inner_type, v) }
229
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
230
+ k_type = Regexp.last_match[:k_type]
231
+ v_type = Regexp.last_match[:v_type]
232
+ {}.tap do |hash|
233
+ value.each do |k, v|
234
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
235
+ end
236
+ end
237
+ else # model
238
+ # models (e.g. Pet) or oneOf
239
+ klass = Tremendous.const_get(type)
240
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
241
+ end
242
+ end
243
+
244
+ # Returns the string representation of the object
245
+ # @return [String] String presentation of the object
246
+ def to_s
247
+ to_hash.to_s
248
+ end
249
+
250
+ # to_body is an alias to to_hash (backward compatibility)
251
+ # @return [Hash] Returns the object in the form of hash
252
+ def to_body
253
+ to_hash
254
+ end
255
+
256
+ # Returns the object in the form of hash
257
+ # @return [Hash] Returns the object in the form of hash
258
+ def to_hash
259
+ hash = {}
260
+ self.class.attribute_map.each_pair do |attr, param|
261
+ value = self.send(attr)
262
+ if value.nil?
263
+ is_nullable = self.class.openapi_nullable.include?(attr)
264
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
265
+ end
266
+
267
+ hash[param] = _to_hash(value)
268
+ end
269
+ hash
270
+ end
271
+
272
+ # Outputs non-array value in the form of hash
273
+ # For object, use to_hash. Otherwise, just return the value
274
+ # @param [Object] value Any valid value
275
+ # @return [Hash] Returns the value in the form of hash
276
+ def _to_hash(value)
277
+ if value.is_a?(Array)
278
+ value.compact.map { |v| _to_hash(v) }
279
+ elsif value.is_a?(Hash)
280
+ {}.tap do |hash|
281
+ value.each { |k, v| hash[k] = _to_hash(v) }
282
+ end
283
+ elsif value.respond_to? :to_hash
284
+ value.to_hash
285
+ else
286
+ value
287
+ end
288
+ end
289
+
290
+ end
291
+
292
+ end
@@ -0,0 +1,292 @@
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 it's 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
+ OpenAPI Generator version: 7.3.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Tremendous
17
+ class FraudConfigRedeemedRewardsCount
18
+ # The number of redeemed rewards to use as a threshold.
19
+ attr_accessor :amount
20
+
21
+ # The period, in days, to consider for the count. Use `all_time` to consider any redeemed rewards.
22
+ attr_accessor :period
23
+
24
+ class EnumAttributeValidator
25
+ attr_reader :datatype
26
+ attr_reader :allowable_values
27
+
28
+ def initialize(datatype, allowable_values)
29
+ @allowable_values = allowable_values.map do |value|
30
+ case datatype.to_s
31
+ when /Integer/i
32
+ value.to_i
33
+ when /Float/i
34
+ value.to_f
35
+ else
36
+ value
37
+ end
38
+ end
39
+ end
40
+
41
+ def valid?(value)
42
+ !value || allowable_values.include?(value)
43
+ end
44
+ end
45
+
46
+ # Attribute mapping from ruby-style variable name to JSON key.
47
+ def self.attribute_map
48
+ {
49
+ :'amount' => :'amount',
50
+ :'period' => :'period'
51
+ }
52
+ end
53
+
54
+ # Returns all the JSON keys this model knows about
55
+ def self.acceptable_attributes
56
+ attribute_map.values
57
+ end
58
+
59
+ # Attribute type mapping.
60
+ def self.openapi_types
61
+ {
62
+ :'amount' => :'Integer',
63
+ :'period' => :'String'
64
+ }
65
+ end
66
+
67
+ # List of attributes with nullable: true
68
+ def self.openapi_nullable
69
+ Set.new([
70
+ ])
71
+ end
72
+
73
+ # Initializes the object
74
+ # @param [Hash] attributes Model attributes in the form of hash
75
+ def initialize(attributes = {})
76
+ if (!attributes.is_a?(Hash))
77
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::FraudConfigRedeemedRewardsCount` initialize method"
78
+ end
79
+
80
+ # check to see if the attribute exists and convert string to symbol for hash key
81
+ attributes = attributes.each_with_object({}) { |(k, v), h|
82
+ if (!self.class.attribute_map.key?(k.to_sym))
83
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::FraudConfigRedeemedRewardsCount`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
84
+ end
85
+ h[k.to_sym] = v
86
+ }
87
+
88
+ if attributes.key?(:'amount')
89
+ self.amount = attributes[:'amount']
90
+ else
91
+ self.amount = nil
92
+ end
93
+
94
+ if attributes.key?(:'period')
95
+ self.period = attributes[:'period']
96
+ else
97
+ self.period = nil
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
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
105
+ invalid_properties = Array.new
106
+ if @amount.nil?
107
+ invalid_properties.push('invalid value for "amount", amount cannot be nil.')
108
+ end
109
+
110
+ if @amount < 1
111
+ invalid_properties.push('invalid value for "amount", must be greater than or equal to 1.')
112
+ end
113
+
114
+ if @period.nil?
115
+ invalid_properties.push('invalid value for "period", period cannot be nil.')
116
+ end
117
+
118
+ invalid_properties
119
+ end
120
+
121
+ # Check to see if the all the properties in the model are valid
122
+ # @return true if the model is valid
123
+ def valid?
124
+ warn '[DEPRECATED] the `valid?` method is obsolete'
125
+ return false if @amount.nil?
126
+ return false if @amount < 1
127
+ return false if @period.nil?
128
+ period_validator = EnumAttributeValidator.new('String', ["7", "30", "90", "120", "365", "all_time"])
129
+ return false unless period_validator.valid?(@period)
130
+ true
131
+ end
132
+
133
+ # Custom attribute writer method with validation
134
+ # @param [Object] amount Value to be assigned
135
+ def amount=(amount)
136
+ if amount.nil?
137
+ fail ArgumentError, 'amount cannot be nil'
138
+ end
139
+
140
+ if amount < 1
141
+ fail ArgumentError, 'invalid value for "amount", must be greater than or equal to 1.'
142
+ end
143
+
144
+ @amount = amount
145
+ end
146
+
147
+ # Custom attribute writer method checking allowed values (enum).
148
+ # @param [Object] period Object to be assigned
149
+ def period=(period)
150
+ validator = EnumAttributeValidator.new('String', ["7", "30", "90", "120", "365", "all_time"])
151
+ unless validator.valid?(period)
152
+ fail ArgumentError, "invalid value for \"period\", must be one of #{validator.allowable_values}."
153
+ end
154
+ @period = period
155
+ end
156
+
157
+ # Checks equality by comparing each attribute.
158
+ # @param [Object] Object to be compared
159
+ def ==(o)
160
+ return true if self.equal?(o)
161
+ self.class == o.class &&
162
+ amount == o.amount &&
163
+ period == o.period
164
+ end
165
+
166
+ # @see the `==` method
167
+ # @param [Object] Object to be compared
168
+ def eql?(o)
169
+ self == o
170
+ end
171
+
172
+ # Calculates hash code according to all attributes.
173
+ # @return [Integer] Hash code
174
+ def hash
175
+ [amount, period].hash
176
+ end
177
+
178
+ # Builds the object from hash
179
+ # @param [Hash] attributes Model attributes in the form of hash
180
+ # @return [Object] Returns the model itself
181
+ def self.build_from_hash(attributes)
182
+ return nil unless attributes.is_a?(Hash)
183
+ attributes = attributes.transform_keys(&:to_sym)
184
+ transformed_hash = {}
185
+ openapi_types.each_pair do |key, type|
186
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
187
+ transformed_hash["#{key}"] = nil
188
+ elsif type =~ /\AArray<(.*)>/i
189
+ # check to ensure the input is an array given that the attribute
190
+ # is documented as an array but the input is not
191
+ if attributes[attribute_map[key]].is_a?(Array)
192
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
193
+ end
194
+ elsif !attributes[attribute_map[key]].nil?
195
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
196
+ end
197
+ end
198
+ new(transformed_hash)
199
+ end
200
+
201
+ # Deserializes the data based on type
202
+ # @param string type Data type
203
+ # @param string value Value to be deserialized
204
+ # @return [Object] Deserialized data
205
+ def self._deserialize(type, value)
206
+ case type.to_sym
207
+ when :Time
208
+ Time.parse(value)
209
+ when :Date
210
+ Date.parse(value)
211
+ when :String
212
+ value.to_s
213
+ when :Integer
214
+ value.to_i
215
+ when :Float
216
+ value.to_f
217
+ when :Boolean
218
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
219
+ true
220
+ else
221
+ false
222
+ end
223
+ when :Object
224
+ # generic object (usually a Hash), return directly
225
+ value
226
+ when /\AArray<(?<inner_type>.+)>\z/
227
+ inner_type = Regexp.last_match[:inner_type]
228
+ value.map { |v| _deserialize(inner_type, v) }
229
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
230
+ k_type = Regexp.last_match[:k_type]
231
+ v_type = Regexp.last_match[:v_type]
232
+ {}.tap do |hash|
233
+ value.each do |k, v|
234
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
235
+ end
236
+ end
237
+ else # model
238
+ # models (e.g. Pet) or oneOf
239
+ klass = Tremendous.const_get(type)
240
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
241
+ end
242
+ end
243
+
244
+ # Returns the string representation of the object
245
+ # @return [String] String presentation of the object
246
+ def to_s
247
+ to_hash.to_s
248
+ end
249
+
250
+ # to_body is an alias to to_hash (backward compatibility)
251
+ # @return [Hash] Returns the object in the form of hash
252
+ def to_body
253
+ to_hash
254
+ end
255
+
256
+ # Returns the object in the form of hash
257
+ # @return [Hash] Returns the object in the form of hash
258
+ def to_hash
259
+ hash = {}
260
+ self.class.attribute_map.each_pair do |attr, param|
261
+ value = self.send(attr)
262
+ if value.nil?
263
+ is_nullable = self.class.openapi_nullable.include?(attr)
264
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
265
+ end
266
+
267
+ hash[param] = _to_hash(value)
268
+ end
269
+ hash
270
+ end
271
+
272
+ # Outputs non-array value in the form of hash
273
+ # For object, use to_hash. Otherwise, just return the value
274
+ # @param [Object] value Any valid value
275
+ # @return [Hash] Returns the value in the form of hash
276
+ def _to_hash(value)
277
+ if value.is_a?(Array)
278
+ value.compact.map { |v| _to_hash(v) }
279
+ elsif value.is_a?(Hash)
280
+ {}.tap do |hash|
281
+ value.each { |k, v| hash[k] = _to_hash(v) }
282
+ end
283
+ elsif value.respond_to? :to_hash
284
+ value.to_hash
285
+ else
286
+ value
287
+ end
288
+ end
289
+
290
+ end
291
+
292
+ end