tremendous_ruby 5.0.0 → 5.1.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 (139) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tremendous/api/tremendous_api.rb +2508 -0
  3. data/lib/tremendous/api_client.rb +431 -0
  4. data/lib/tremendous/api_error.rb +58 -0
  5. data/lib/tremendous/configuration.rb +389 -0
  6. data/lib/tremendous/models/balance_transaction.rb +256 -0
  7. data/lib/tremendous/models/campaign.rb +303 -0
  8. data/lib/tremendous/models/create_api_key200_response.rb +215 -0
  9. data/lib/tremendous/models/create_campaign201_response.rb +221 -0
  10. data/lib/tremendous/models/create_campaign_request.rb +273 -0
  11. data/lib/tremendous/models/create_invoice.rb +244 -0
  12. data/lib/tremendous/models/create_invoice200_response.rb +221 -0
  13. data/lib/tremendous/models/create_invoice_request.rb +244 -0
  14. data/lib/tremendous/models/create_member.rb +273 -0
  15. data/lib/tremendous/models/create_member200_response.rb +221 -0
  16. data/lib/tremendous/models/create_member_request.rb +273 -0
  17. data/lib/tremendous/models/create_order200_response.rb +221 -0
  18. data/lib/tremendous/models/create_order200_response_order.rb +400 -0
  19. data/lib/tremendous/models/create_order200_response_order_rewards_inner.rb +347 -0
  20. data/lib/tremendous/models/create_order200_response_order_rewards_inner_delivery.rb +296 -0
  21. data/lib/tremendous/models/create_order201_response.rb +221 -0
  22. data/lib/tremendous/models/create_order_request.rb +248 -0
  23. data/lib/tremendous/models/create_order_request_payment.rb +222 -0
  24. data/lib/tremendous/models/create_order_request_reward.rb +344 -0
  25. data/lib/tremendous/models/create_order_request_reward_custom_fields_inner.rb +248 -0
  26. data/lib/tremendous/models/create_order_request_reward_delivery.rb +250 -0
  27. data/lib/tremendous/models/create_organization.rb +268 -0
  28. data/lib/tremendous/models/create_organization200_response.rb +214 -0
  29. data/lib/tremendous/models/create_organization200_response_organization.rb +334 -0
  30. data/lib/tremendous/models/create_organization_request.rb +268 -0
  31. data/lib/tremendous/models/create_organization_request_copy_settings.rb +290 -0
  32. data/lib/tremendous/models/create_webhook200_response.rb +214 -0
  33. data/lib/tremendous/models/create_webhook_request.rb +222 -0
  34. data/lib/tremendous/models/currency_codes.rb +154 -0
  35. data/lib/tremendous/models/custom_field.rb +258 -0
  36. data/lib/tremendous/models/delivery_details.rb +286 -0
  37. data/lib/tremendous/models/delivery_details_with_link.rb +296 -0
  38. data/lib/tremendous/models/delivery_method.rb +41 -0
  39. data/lib/tremendous/models/delivery_status.rb +42 -0
  40. data/lib/tremendous/models/error_model.rb +221 -0
  41. data/lib/tremendous/models/field.rb +286 -0
  42. data/lib/tremendous/models/funding_source.rb +332 -0
  43. data/lib/tremendous/models/generate_reward_link200_response.rb +221 -0
  44. data/lib/tremendous/models/generate_reward_link200_response_reward.rb +247 -0
  45. data/lib/tremendous/models/generate_reward_link403_response.rb +221 -0
  46. data/lib/tremendous/models/generate_reward_token200_response.rb +221 -0
  47. data/lib/tremendous/models/generate_reward_token200_response_reward.rb +257 -0
  48. data/lib/tremendous/models/get_funding_source200_response.rb +221 -0
  49. data/lib/tremendous/models/get_member200_response.rb +221 -0
  50. data/lib/tremendous/models/get_member200_response_member.rb +375 -0
  51. data/lib/tremendous/models/get_member200_response_member_events_inner.rb +260 -0
  52. data/lib/tremendous/models/get_organization200_response.rb +214 -0
  53. data/lib/tremendous/models/get_product_response.rb +221 -0
  54. data/lib/tremendous/models/get_reward200_response.rb +221 -0
  55. data/lib/tremendous/models/invoice.rb +356 -0
  56. data/lib/tremendous/models/list_balance_transactions200_response.rb +216 -0
  57. data/lib/tremendous/models/list_balance_transactions200_response_invoices_inner.rb +256 -0
  58. data/lib/tremendous/models/list_campaigns200_response.rb +223 -0
  59. data/lib/tremendous/models/list_campaigns200_response_campaigns_inner.rb +303 -0
  60. data/lib/tremendous/models/list_campaigns200_response_campaigns_inner_email_style.rb +270 -0
  61. data/lib/tremendous/models/list_campaigns200_response_campaigns_inner_webpage_style.rb +270 -0
  62. data/lib/tremendous/models/list_fields200_response.rb +216 -0
  63. data/lib/tremendous/models/list_fields200_response_fields_inner.rb +286 -0
  64. data/lib/tremendous/models/list_funding_sources200_response.rb +223 -0
  65. data/lib/tremendous/models/list_funding_sources200_response_funding_sources_inner.rb +332 -0
  66. data/lib/tremendous/models/list_funding_sources200_response_funding_sources_inner_meta.rb +436 -0
  67. data/lib/tremendous/models/list_invoices200_response.rb +240 -0
  68. data/lib/tremendous/models/list_invoices200_response_invoices_inner.rb +356 -0
  69. data/lib/tremendous/models/list_members200_response.rb +223 -0
  70. data/lib/tremendous/models/list_members200_response_members_inner.rb +384 -0
  71. data/lib/tremendous/models/list_orders200_response.rb +240 -0
  72. data/lib/tremendous/models/list_orders200_response_orders_inner.rb +379 -0
  73. data/lib/tremendous/models/list_orders200_response_orders_inner_payment.rb +346 -0
  74. data/lib/tremendous/models/list_orders200_response_orders_inner_payment_refund.rb +242 -0
  75. data/lib/tremendous/models/list_organizations200_response.rb +216 -0
  76. data/lib/tremendous/models/list_organizations200_response_organizations_inner.rb +324 -0
  77. data/lib/tremendous/models/list_products_response.rb +223 -0
  78. data/lib/tremendous/models/list_products_response_products_inner.rb +457 -0
  79. data/lib/tremendous/models/list_products_response_products_inner_countries_inner.rb +222 -0
  80. data/lib/tremendous/models/list_products_response_products_inner_images_inner.rb +273 -0
  81. data/lib/tremendous/models/list_products_response_products_inner_skus_inner.rb +277 -0
  82. data/lib/tremendous/models/list_rewards200_response.rb +226 -0
  83. data/lib/tremendous/models/list_rewards200_response_rewards_inner.rb +347 -0
  84. data/lib/tremendous/models/list_rewards200_response_rewards_inner_custom_fields_inner.rb +258 -0
  85. data/lib/tremendous/models/list_rewards200_response_rewards_inner_delivery.rb +286 -0
  86. data/lib/tremendous/models/list_rewards200_response_rewards_inner_recipient.rb +236 -0
  87. data/lib/tremendous/models/list_rewards200_response_rewards_inner_value.rb +273 -0
  88. data/lib/tremendous/models/list_rewards401_response.rb +221 -0
  89. data/lib/tremendous/models/list_rewards401_response_errors.rb +225 -0
  90. data/lib/tremendous/models/list_rewards429_response.rb +221 -0
  91. data/lib/tremendous/models/list_webhook_events200_response.rb +216 -0
  92. data/lib/tremendous/models/list_webhooks200_response.rb +216 -0
  93. data/lib/tremendous/models/list_webhooks200_response_webhooks_inner.rb +258 -0
  94. data/lib/tremendous/models/member.rb +384 -0
  95. data/lib/tremendous/models/member_base.rb +363 -0
  96. data/lib/tremendous/models/member_with_events.rb +375 -0
  97. data/lib/tremendous/models/member_without_events.rb +384 -0
  98. data/lib/tremendous/models/order.rb +379 -0
  99. data/lib/tremendous/models/order_base.rb +370 -0
  100. data/lib/tremendous/models/order_base_payment.rb +346 -0
  101. data/lib/tremendous/models/order_for_create.rb +248 -0
  102. data/lib/tremendous/models/order_for_create_reward.rb +416 -0
  103. data/lib/tremendous/models/order_status.rb +44 -0
  104. data/lib/tremendous/models/order_with_link.rb +400 -0
  105. data/lib/tremendous/models/order_with_link_rewards_inner.rb +406 -0
  106. data/lib/tremendous/models/order_without_link.rb +379 -0
  107. data/lib/tremendous/models/order_without_link_reward.rb +406 -0
  108. data/lib/tremendous/models/organization.rb +324 -0
  109. data/lib/tremendous/models/payment_details.rb +345 -0
  110. data/lib/tremendous/models/payment_details_refund.rb +242 -0
  111. data/lib/tremendous/models/product.rb +457 -0
  112. data/lib/tremendous/models/recipient.rb +236 -0
  113. data/lib/tremendous/models/refund_details.rb +241 -0
  114. data/lib/tremendous/models/resend_reward422_response.rb +221 -0
  115. data/lib/tremendous/models/reward.rb +406 -0
  116. data/lib/tremendous/models/reward_base.rb +397 -0
  117. data/lib/tremendous/models/reward_base_custom_fields_inner.rb +258 -0
  118. data/lib/tremendous/models/reward_for_order_create.rb +416 -0
  119. data/lib/tremendous/models/reward_link.rb +247 -0
  120. data/lib/tremendous/models/reward_token.rb +257 -0
  121. data/lib/tremendous/models/reward_value.rb +273 -0
  122. data/lib/tremendous/models/reward_with_link.rb +406 -0
  123. data/lib/tremendous/models/reward_with_link_delivery.rb +296 -0
  124. data/lib/tremendous/models/reward_without_link.rb +406 -0
  125. data/lib/tremendous/models/reward_without_link_delivery.rb +286 -0
  126. data/lib/tremendous/models/simulate_webhook_request.rb +222 -0
  127. data/lib/tremendous/models/webhook.rb +258 -0
  128. data/lib/tremendous/models/webhook_post.rb +222 -0
  129. data/lib/tremendous/version.rb +3 -0
  130. data/lib/tremendous.rb +163 -0
  131. metadata +132 -11
  132. data/spec/integration/campaigns_spec.rb +0 -27
  133. data/spec/integration/funding_sources_spec.rb +0 -18
  134. data/spec/integration/invoices_spec.rb +0 -19
  135. data/spec/integration/members_spec.rb +0 -19
  136. data/spec/integration/orders_spec.rb +0 -53
  137. data/spec/integration/products_spec.rb +0 -26
  138. data/spec/spec_helper.rb +0 -111
  139. data/spec/support/setup.rb +0 -10
@@ -0,0 +1,286 @@
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
+ # Details on how the reward is delivered to the recipient.
18
+ class ListRewards200ResponseRewardsInnerDelivery
19
+ # How to deliver the reward to the recipient. <table> <thead> <tr> <th>Delivery Method</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code>EMAIL</code></td> <td>Deliver the reward to the recipient by email</td> </tr> <tr> <td><code>LINK</code></td> <td> <p>Deliver the reward to the recipient via a link.</p> <p>The link can be retrieved on a successfully ordered reward via the <code>/rewards</code> or <code>/rewards/{id}</code> endpoint. That link must then be delivered to the recipient out-of-band.</p> </td> </tr> <tr> <td><code>PHONE</code></td> <td>Deliver the reward to the recipient by SMS</td> </tr> </tbody> </table>
20
+ attr_accessor :method
21
+
22
+ # Current status of the delivery of the reward: * `SCHEDULED` - Reward is scheduled for delivery and will be delivered soon. * `FAILED` - Delivery of reward failed (e.g. email bounced). * `SUCCEEDED` - Reward was successfully delivered (email or text message delivered or reward link opened). * `PENDING` - Delivery is pending but not yet scheduled.
23
+ attr_accessor :status
24
+
25
+ class EnumAttributeValidator
26
+ attr_reader :datatype
27
+ attr_reader :allowable_values
28
+
29
+ def initialize(datatype, allowable_values)
30
+ @allowable_values = allowable_values.map do |value|
31
+ case datatype.to_s
32
+ when /Integer/i
33
+ value.to_i
34
+ when /Float/i
35
+ value.to_f
36
+ else
37
+ value
38
+ end
39
+ end
40
+ end
41
+
42
+ def valid?(value)
43
+ !value || allowable_values.include?(value)
44
+ end
45
+ end
46
+
47
+ # Attribute mapping from ruby-style variable name to JSON key.
48
+ def self.attribute_map
49
+ {
50
+ :'method' => :'method',
51
+ :'status' => :'status'
52
+ }
53
+ end
54
+
55
+ # Returns all the JSON keys this model knows about
56
+ def self.acceptable_attributes
57
+ attribute_map.values
58
+ end
59
+
60
+ # Attribute type mapping.
61
+ def self.openapi_types
62
+ {
63
+ :'method' => :'String',
64
+ :'status' => :'String'
65
+ }
66
+ end
67
+
68
+ # List of attributes with nullable: true
69
+ def self.openapi_nullable
70
+ Set.new([
71
+ ])
72
+ end
73
+
74
+ # Initializes the object
75
+ # @param [Hash] attributes Model attributes in the form of hash
76
+ def initialize(attributes = {})
77
+ if (!attributes.is_a?(Hash))
78
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::ListRewards200ResponseRewardsInnerDelivery` initialize method"
79
+ end
80
+
81
+ # check to see if the attribute exists and convert string to symbol for hash key
82
+ attributes = attributes.each_with_object({}) { |(k, v), h|
83
+ if (!self.class.attribute_map.key?(k.to_sym))
84
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::ListRewards200ResponseRewardsInnerDelivery`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
85
+ end
86
+ h[k.to_sym] = v
87
+ }
88
+
89
+ if attributes.key?(:'method')
90
+ self.method = attributes[:'method']
91
+ else
92
+ self.method = nil
93
+ end
94
+
95
+ if attributes.key?(:'status')
96
+ self.status = attributes[:'status']
97
+ else
98
+ self.status = nil
99
+ end
100
+ end
101
+
102
+ # Show invalid properties with the reasons. Usually used together with valid?
103
+ # @return Array for valid properties with the reasons
104
+ def list_invalid_properties
105
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
106
+ invalid_properties = Array.new
107
+ if @method.nil?
108
+ invalid_properties.push('invalid value for "method", method cannot be nil.')
109
+ end
110
+
111
+ if @status.nil?
112
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
113
+ end
114
+
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
+ warn '[DEPRECATED] the `valid?` method is obsolete'
122
+ return false if @method.nil?
123
+ method_validator = EnumAttributeValidator.new('String', ["EMAIL", "LINK", "PHONE"])
124
+ return false unless method_validator.valid?(@method)
125
+ return false if @status.nil?
126
+ status_validator = EnumAttributeValidator.new('String', ["SCHEDULED", "FAILED", "SUCCEEDED", "PENDING"])
127
+ return false unless status_validator.valid?(@status)
128
+ true
129
+ end
130
+
131
+ # Custom attribute writer method checking allowed values (enum).
132
+ # @param [Object] method Object to be assigned
133
+ def method=(method)
134
+ validator = EnumAttributeValidator.new('String', ["EMAIL", "LINK", "PHONE"])
135
+ unless validator.valid?(method)
136
+ fail ArgumentError, "invalid value for \"method\", must be one of #{validator.allowable_values}."
137
+ end
138
+ @method = method
139
+ end
140
+
141
+ # Custom attribute writer method checking allowed values (enum).
142
+ # @param [Object] status Object to be assigned
143
+ def status=(status)
144
+ validator = EnumAttributeValidator.new('String', ["SCHEDULED", "FAILED", "SUCCEEDED", "PENDING"])
145
+ unless validator.valid?(status)
146
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
147
+ end
148
+ @status = status
149
+ end
150
+
151
+ # Checks equality by comparing each attribute.
152
+ # @param [Object] Object to be compared
153
+ def ==(o)
154
+ return true if self.equal?(o)
155
+ self.class == o.class &&
156
+ method == o.method &&
157
+ status == o.status
158
+ end
159
+
160
+ # @see the `==` method
161
+ # @param [Object] Object to be compared
162
+ def eql?(o)
163
+ self == o
164
+ end
165
+
166
+ # Calculates hash code according to all attributes.
167
+ # @return [Integer] Hash code
168
+ def hash
169
+ [method, status].hash
170
+ end
171
+
172
+ # Builds the object from hash
173
+ # @param [Hash] attributes Model attributes in the form of hash
174
+ # @return [Object] Returns the model itself
175
+ def self.build_from_hash(attributes)
176
+ return nil unless attributes.is_a?(Hash)
177
+ attributes = attributes.transform_keys(&:to_sym)
178
+ transformed_hash = {}
179
+ openapi_types.each_pair do |key, type|
180
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
181
+ transformed_hash["#{key}"] = nil
182
+ elsif type =~ /\AArray<(.*)>/i
183
+ # check to ensure the input is an array given that the attribute
184
+ # is documented as an array but the input is not
185
+ if attributes[attribute_map[key]].is_a?(Array)
186
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
187
+ end
188
+ elsif !attributes[attribute_map[key]].nil?
189
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
190
+ end
191
+ end
192
+ new(transformed_hash)
193
+ end
194
+
195
+ # Deserializes the data based on type
196
+ # @param string type Data type
197
+ # @param string value Value to be deserialized
198
+ # @return [Object] Deserialized data
199
+ def self._deserialize(type, value)
200
+ case type.to_sym
201
+ when :Time
202
+ Time.parse(value)
203
+ when :Date
204
+ Date.parse(value)
205
+ when :String
206
+ value.to_s
207
+ when :Integer
208
+ value.to_i
209
+ when :Float
210
+ value.to_f
211
+ when :Boolean
212
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
213
+ true
214
+ else
215
+ false
216
+ end
217
+ when :Object
218
+ # generic object (usually a Hash), return directly
219
+ value
220
+ when /\AArray<(?<inner_type>.+)>\z/
221
+ inner_type = Regexp.last_match[:inner_type]
222
+ value.map { |v| _deserialize(inner_type, v) }
223
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
224
+ k_type = Regexp.last_match[:k_type]
225
+ v_type = Regexp.last_match[:v_type]
226
+ {}.tap do |hash|
227
+ value.each do |k, v|
228
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
229
+ end
230
+ end
231
+ else # model
232
+ # models (e.g. Pet) or oneOf
233
+ klass = Tremendous.const_get(type)
234
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
235
+ end
236
+ end
237
+
238
+ # Returns the string representation of the object
239
+ # @return [String] String presentation of the object
240
+ def to_s
241
+ to_hash.to_s
242
+ end
243
+
244
+ # to_body is an alias to to_hash (backward compatibility)
245
+ # @return [Hash] Returns the object in the form of hash
246
+ def to_body
247
+ to_hash
248
+ end
249
+
250
+ # Returns the object in the form of hash
251
+ # @return [Hash] Returns the object in the form of hash
252
+ def to_hash
253
+ hash = {}
254
+ self.class.attribute_map.each_pair do |attr, param|
255
+ value = self.send(attr)
256
+ if value.nil?
257
+ is_nullable = self.class.openapi_nullable.include?(attr)
258
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
259
+ end
260
+
261
+ hash[param] = _to_hash(value)
262
+ end
263
+ hash
264
+ end
265
+
266
+ # Outputs non-array value in the form of hash
267
+ # For object, use to_hash. Otherwise, just return the value
268
+ # @param [Object] value Any valid value
269
+ # @return [Hash] Returns the value in the form of hash
270
+ def _to_hash(value)
271
+ if value.is_a?(Array)
272
+ value.compact.map { |v| _to_hash(v) }
273
+ elsif value.is_a?(Hash)
274
+ {}.tap do |hash|
275
+ value.each { |k, v| hash[k] = _to_hash(v) }
276
+ end
277
+ elsif value.respond_to? :to_hash
278
+ value.to_hash
279
+ else
280
+ value
281
+ end
282
+ end
283
+
284
+ end
285
+
286
+ end
@@ -0,0 +1,236 @@
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
+ # Details of the recipient of the reward
18
+ class ListRewards200ResponseRewardsInnerRecipient
19
+ # Name of the recipient
20
+ attr_accessor :name
21
+
22
+ # Email address of the recipient
23
+ attr_accessor :email
24
+
25
+ # Phone number of the recipient. For non-US phone numbers, specify the country code (prefixed with +).
26
+ attr_accessor :phone
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'name' => :'name',
32
+ :'email' => :'email',
33
+ :'phone' => :'phone'
34
+ }
35
+ end
36
+
37
+ # Returns all the JSON keys this model knows about
38
+ def self.acceptable_attributes
39
+ attribute_map.values
40
+ end
41
+
42
+ # Attribute type mapping.
43
+ def self.openapi_types
44
+ {
45
+ :'name' => :'String',
46
+ :'email' => :'String',
47
+ :'phone' => :'String'
48
+ }
49
+ end
50
+
51
+ # List of attributes with nullable: true
52
+ def self.openapi_nullable
53
+ Set.new([
54
+ ])
55
+ end
56
+
57
+ # Initializes the object
58
+ # @param [Hash] attributes Model attributes in the form of hash
59
+ def initialize(attributes = {})
60
+ if (!attributes.is_a?(Hash))
61
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::ListRewards200ResponseRewardsInnerRecipient` initialize method"
62
+ end
63
+
64
+ # check to see if the attribute exists and convert string to symbol for hash key
65
+ attributes = attributes.each_with_object({}) { |(k, v), h|
66
+ if (!self.class.attribute_map.key?(k.to_sym))
67
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::ListRewards200ResponseRewardsInnerRecipient`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
68
+ end
69
+ h[k.to_sym] = v
70
+ }
71
+
72
+ if attributes.key?(:'name')
73
+ self.name = attributes[:'name']
74
+ end
75
+
76
+ if attributes.key?(:'email')
77
+ self.email = attributes[:'email']
78
+ end
79
+
80
+ if attributes.key?(:'phone')
81
+ self.phone = attributes[:'phone']
82
+ end
83
+ end
84
+
85
+ # Show invalid properties with the reasons. Usually used together with valid?
86
+ # @return Array for valid properties with the reasons
87
+ def list_invalid_properties
88
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
89
+ invalid_properties = Array.new
90
+ invalid_properties
91
+ end
92
+
93
+ # Check to see if the all the properties in the model are valid
94
+ # @return true if the model is valid
95
+ def valid?
96
+ warn '[DEPRECATED] the `valid?` method is obsolete'
97
+ true
98
+ end
99
+
100
+ # Checks equality by comparing each attribute.
101
+ # @param [Object] Object to be compared
102
+ def ==(o)
103
+ return true if self.equal?(o)
104
+ self.class == o.class &&
105
+ name == o.name &&
106
+ email == o.email &&
107
+ phone == o.phone
108
+ end
109
+
110
+ # @see the `==` method
111
+ # @param [Object] Object to be compared
112
+ def eql?(o)
113
+ self == o
114
+ end
115
+
116
+ # Calculates hash code according to all attributes.
117
+ # @return [Integer] Hash code
118
+ def hash
119
+ [name, email, phone].hash
120
+ end
121
+
122
+ # Builds the object from hash
123
+ # @param [Hash] attributes Model attributes in the form of hash
124
+ # @return [Object] Returns the model itself
125
+ def self.build_from_hash(attributes)
126
+ return nil unless attributes.is_a?(Hash)
127
+ attributes = attributes.transform_keys(&:to_sym)
128
+ transformed_hash = {}
129
+ openapi_types.each_pair do |key, type|
130
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
131
+ transformed_hash["#{key}"] = nil
132
+ elsif type =~ /\AArray<(.*)>/i
133
+ # check to ensure the input is an array given that the attribute
134
+ # is documented as an array but the input is not
135
+ if attributes[attribute_map[key]].is_a?(Array)
136
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
137
+ end
138
+ elsif !attributes[attribute_map[key]].nil?
139
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
140
+ end
141
+ end
142
+ new(transformed_hash)
143
+ end
144
+
145
+ # Deserializes the data based on type
146
+ # @param string type Data type
147
+ # @param string value Value to be deserialized
148
+ # @return [Object] Deserialized data
149
+ def self._deserialize(type, value)
150
+ case type.to_sym
151
+ when :Time
152
+ Time.parse(value)
153
+ when :Date
154
+ Date.parse(value)
155
+ when :String
156
+ value.to_s
157
+ when :Integer
158
+ value.to_i
159
+ when :Float
160
+ value.to_f
161
+ when :Boolean
162
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
163
+ true
164
+ else
165
+ false
166
+ end
167
+ when :Object
168
+ # generic object (usually a Hash), return directly
169
+ value
170
+ when /\AArray<(?<inner_type>.+)>\z/
171
+ inner_type = Regexp.last_match[:inner_type]
172
+ value.map { |v| _deserialize(inner_type, v) }
173
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
174
+ k_type = Regexp.last_match[:k_type]
175
+ v_type = Regexp.last_match[:v_type]
176
+ {}.tap do |hash|
177
+ value.each do |k, v|
178
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
179
+ end
180
+ end
181
+ else # model
182
+ # models (e.g. Pet) or oneOf
183
+ klass = Tremendous.const_get(type)
184
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
185
+ end
186
+ end
187
+
188
+ # Returns the string representation of the object
189
+ # @return [String] String presentation of the object
190
+ def to_s
191
+ to_hash.to_s
192
+ end
193
+
194
+ # to_body is an alias to to_hash (backward compatibility)
195
+ # @return [Hash] Returns the object in the form of hash
196
+ def to_body
197
+ to_hash
198
+ end
199
+
200
+ # Returns the object in the form of hash
201
+ # @return [Hash] Returns the object in the form of hash
202
+ def to_hash
203
+ hash = {}
204
+ self.class.attribute_map.each_pair do |attr, param|
205
+ value = self.send(attr)
206
+ if value.nil?
207
+ is_nullable = self.class.openapi_nullable.include?(attr)
208
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
209
+ end
210
+
211
+ hash[param] = _to_hash(value)
212
+ end
213
+ hash
214
+ end
215
+
216
+ # Outputs non-array value in the form of hash
217
+ # For object, use to_hash. Otherwise, just return the value
218
+ # @param [Object] value Any valid value
219
+ # @return [Hash] Returns the value in the form of hash
220
+ def _to_hash(value)
221
+ if value.is_a?(Array)
222
+ value.compact.map { |v| _to_hash(v) }
223
+ elsif value.is_a?(Hash)
224
+ {}.tap do |hash|
225
+ value.each { |k, v| hash[k] = _to_hash(v) }
226
+ end
227
+ elsif value.respond_to? :to_hash
228
+ value.to_hash
229
+ else
230
+ value
231
+ end
232
+ end
233
+
234
+ end
235
+
236
+ end