tremendous_ruby 5.13.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.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tremendous/api/tremendous_api.rb +265 -7
  3. data/lib/tremendous/models/create_field.rb +320 -0
  4. data/lib/tremendous/models/create_field200_response.rb +237 -0
  5. data/lib/tremendous/models/create_field_request.rb +320 -0
  6. data/lib/tremendous/models/create_field_request_data.rb +224 -0
  7. data/lib/tremendous/models/create_invoice_request.rb +48 -2
  8. data/lib/tremendous/models/create_topup200_response.rb +220 -0
  9. data/lib/tremendous/models/create_topup_request.rb +292 -0
  10. data/lib/tremendous/models/field.rb +37 -5
  11. data/lib/tremendous/models/fraud_review.rb +66 -56
  12. data/lib/tremendous/models/fraud_review_base.rb +358 -0
  13. data/lib/tremendous/models/fraud_review_list_item.rb +85 -4
  14. data/lib/tremendous/models/fraud_review_redemption_method.rb +7 -5
  15. data/lib/tremendous/models/get_fraud_review200_response_fraud_review.rb +66 -56
  16. data/lib/tremendous/models/invoice.rb +26 -2
  17. data/lib/tremendous/models/list_fields200_response_fields_inner.rb +37 -5
  18. data/lib/tremendous/models/list_fields200_response_fields_inner_data.rb +236 -0
  19. data/lib/tremendous/models/list_fraud_reviews200_response_fraud_reviews_inner.rb +85 -4
  20. data/lib/tremendous/models/list_fraud_reviews200_response_fraud_reviews_inner_geo.rb +242 -0
  21. data/lib/tremendous/models/list_funding_sources200_response_funding_sources_inner_meta.rb +5 -0
  22. data/lib/tremendous/models/list_invoices200_response_invoices_inner.rb +26 -2
  23. data/lib/tremendous/models/list_topups200_response.rb +232 -0
  24. data/lib/tremendous/models/list_topups200_response_topups_inner.rb +326 -0
  25. data/lib/tremendous/models/topup.rb +326 -0
  26. data/lib/tremendous/models/topup_create_request.rb +292 -0
  27. data/lib/tremendous/version.rb +1 -1
  28. data/lib/tremendous.rb +13 -1
  29. metadata +14 -1
@@ -19,20 +19,9 @@ module Tremendous
19
19
  # The current status of the fraud review: * `flagged` - The reward has been flagged for and waiting manual review. * `blocked` - The reward was reviewed and blocked. * `released` - The reward was reviewed and released.
20
20
  attr_accessor :status
21
21
 
22
- # The fraud risk associated with the reward.
23
- attr_accessor :risk
24
-
25
22
  # The array may contain multiple reasons, depending on which rule(s) flagged the reward for review. Reasons can be any of the following: * `Disallowed IP` * `Disallowed email` * `Disallowed country` * `Over reward dollar limit` * `Over reward count limit` * `VPN detected` * `Device related to multiple emails` * `Device or account related to multiple emails` * `IP on a Tremendous fraud list` * `Bank account on a Tremendous fraud list` * `Fingerprint on a Tremendous fraud list` * `Email on a Tremendous fraud list` * `Phone on a Tremendous fraud list` * `IP related to a blocked reward` * `Device related to a blocked reward` * `Bank account related to a blocked reward` * `Fingerprint related to a blocked reward` * `Email related to a blocked reward` * `Phone related to a blocked reward` * `Allowed IP` * `Allowed email`
26
23
  attr_accessor :reasons
27
24
 
28
- # The name of the person who reviewed the reward, or `Automatic Review` if the reward was blocked automatically. Rewards can be automatically blocked if they remain in the flagged fraud queue for more than 30 days. This field is only present if the status is not `flagged`.
29
- attr_accessor :reviewed_by
30
-
31
- # When the reward was blocked or released following fraud review. This field is only present if the status is not `flagged`.
32
- attr_accessor :reviewed_at
33
-
34
- attr_accessor :related_rewards
35
-
36
25
  # The device fingerprint, if known.
37
26
  attr_accessor :device_id
38
27
 
@@ -46,6 +35,20 @@ module Tremendous
46
35
 
47
36
  attr_accessor :reward
48
37
 
38
+ # The name of the person who reviewed the reward, or `Automatic Review` if the reward was blocked automatically. Rewards can be automatically blocked if they remain in the flagged fraud queue for more than 30 days. This field is only present if the status is not `flagged`.
39
+ attr_accessor :reviewed_by
40
+
41
+ # When the reward was blocked or released following fraud review. This field is only present if the status is not `flagged`.
42
+ attr_accessor :reviewed_at
43
+
44
+ # A hash of the destination account for redemption methods that require providing 3rd party account details (e.g., PayPal, Venmo, ACH/CashApp, international bank transfers, etc.). The hash is globally unique by redemption method + account combination. This field is omitted for redemption methods that don't have a destination account (e.g., merchant cards, charities, etc.).
45
+ attr_accessor :redemption_method_account_hash
46
+
47
+ # The fraud risk associated with the reward.
48
+ attr_accessor :risk
49
+
50
+ attr_accessor :related_rewards
51
+
49
52
  class EnumAttributeValidator
50
53
  attr_reader :datatype
51
54
  attr_reader :allowable_values
@@ -72,16 +75,17 @@ module Tremendous
72
75
  def self.attribute_map
73
76
  {
74
77
  :'status' => :'status',
75
- :'risk' => :'risk',
76
78
  :'reasons' => :'reasons',
77
- :'reviewed_by' => :'reviewed_by',
78
- :'reviewed_at' => :'reviewed_at',
79
- :'related_rewards' => :'related_rewards',
80
79
  :'device_id' => :'device_id',
81
80
  :'redemption_method' => :'redemption_method',
82
81
  :'redeemed_at' => :'redeemed_at',
83
82
  :'geo' => :'geo',
84
- :'reward' => :'reward'
83
+ :'reward' => :'reward',
84
+ :'reviewed_by' => :'reviewed_by',
85
+ :'reviewed_at' => :'reviewed_at',
86
+ :'redemption_method_account_hash' => :'redemption_method_account_hash',
87
+ :'risk' => :'risk',
88
+ :'related_rewards' => :'related_rewards'
85
89
  }
86
90
  end
87
91
 
@@ -99,16 +103,17 @@ module Tremendous
99
103
  def self.openapi_types
100
104
  {
101
105
  :'status' => :'String',
102
- :'risk' => :'String',
103
106
  :'reasons' => :'Array<String>',
104
- :'reviewed_by' => :'String',
105
- :'reviewed_at' => :'Time',
106
- :'related_rewards' => :'GetFraudReview200ResponseFraudReviewRelatedRewards',
107
107
  :'device_id' => :'String',
108
108
  :'redemption_method' => :'String',
109
109
  :'redeemed_at' => :'Time',
110
- :'geo' => :'GetFraudReview200ResponseFraudReviewGeo',
111
- :'reward' => :'ListRewards200ResponseRewardsInner'
110
+ :'geo' => :'ListFraudReviews200ResponseFraudReviewsInnerGeo',
111
+ :'reward' => :'ListRewards200ResponseRewardsInner',
112
+ :'reviewed_by' => :'String',
113
+ :'reviewed_at' => :'Time',
114
+ :'redemption_method_account_hash' => :'String',
115
+ :'risk' => :'String',
116
+ :'related_rewards' => :'GetFraudReview200ResponseFraudReviewRelatedRewards'
112
117
  }
113
118
  end
114
119
 
@@ -138,28 +143,12 @@ module Tremendous
138
143
  self.status = attributes[:'status']
139
144
  end
140
145
 
141
- if attributes.key?(:'risk')
142
- self.risk = attributes[:'risk']
143
- end
144
-
145
146
  if attributes.key?(:'reasons')
146
147
  if (value = attributes[:'reasons']).is_a?(Array)
147
148
  self.reasons = value
148
149
  end
149
150
  end
150
151
 
151
- if attributes.key?(:'reviewed_by')
152
- self.reviewed_by = attributes[:'reviewed_by']
153
- end
154
-
155
- if attributes.key?(:'reviewed_at')
156
- self.reviewed_at = attributes[:'reviewed_at']
157
- end
158
-
159
- if attributes.key?(:'related_rewards')
160
- self.related_rewards = attributes[:'related_rewards']
161
- end
162
-
163
152
  if attributes.key?(:'device_id')
164
153
  self.device_id = attributes[:'device_id']
165
154
  end
@@ -179,6 +168,26 @@ module Tremendous
179
168
  if attributes.key?(:'reward')
180
169
  self.reward = attributes[:'reward']
181
170
  end
171
+
172
+ if attributes.key?(:'reviewed_by')
173
+ self.reviewed_by = attributes[:'reviewed_by']
174
+ end
175
+
176
+ if attributes.key?(:'reviewed_at')
177
+ self.reviewed_at = attributes[:'reviewed_at']
178
+ end
179
+
180
+ if attributes.key?(:'redemption_method_account_hash')
181
+ self.redemption_method_account_hash = attributes[:'redemption_method_account_hash']
182
+ end
183
+
184
+ if attributes.key?(:'risk')
185
+ self.risk = attributes[:'risk']
186
+ end
187
+
188
+ if attributes.key?(:'related_rewards')
189
+ self.related_rewards = attributes[:'related_rewards']
190
+ end
182
191
  end
183
192
 
184
193
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -195,10 +204,10 @@ module Tremendous
195
204
  warn '[DEPRECATED] the `valid?` method is obsolete'
196
205
  status_validator = EnumAttributeValidator.new('String', ["flagged", "blocked", "released"])
197
206
  return false unless status_validator.valid?(@status)
207
+ redemption_method_validator = EnumAttributeValidator.new('String', ["bank transfer", "charity", "instant debit transfer", "international bank transfer", "merchant card", "paypal", "venmo", "visa card"])
208
+ return false unless redemption_method_validator.valid?(@redemption_method)
198
209
  risk_validator = EnumAttributeValidator.new('String', ["high", "medium", "low"])
199
210
  return false unless risk_validator.valid?(@risk)
200
- redemption_method_validator = EnumAttributeValidator.new('String', ["paypal", "bank", "merchant card", "visa card", "charity", "venmo"])
201
- return false unless redemption_method_validator.valid?(@redemption_method)
202
211
  true
203
212
  end
204
213
 
@@ -212,6 +221,16 @@ module Tremendous
212
221
  @status = status
213
222
  end
214
223
 
224
+ # Custom attribute writer method checking allowed values (enum).
225
+ # @param [Object] redemption_method Object to be assigned
226
+ def redemption_method=(redemption_method)
227
+ validator = EnumAttributeValidator.new('String', ["bank transfer", "charity", "instant debit transfer", "international bank transfer", "merchant card", "paypal", "venmo", "visa card"])
228
+ unless validator.valid?(redemption_method)
229
+ fail ArgumentError, "invalid value for \"redemption_method\", must be one of #{validator.allowable_values}."
230
+ end
231
+ @redemption_method = redemption_method
232
+ end
233
+
215
234
  # Custom attribute writer method checking allowed values (enum).
216
235
  # @param [Object] risk Object to be assigned
217
236
  def risk=(risk)
@@ -222,32 +241,23 @@ module Tremendous
222
241
  @risk = risk
223
242
  end
224
243
 
225
- # Custom attribute writer method checking allowed values (enum).
226
- # @param [Object] redemption_method Object to be assigned
227
- def redemption_method=(redemption_method)
228
- validator = EnumAttributeValidator.new('String', ["paypal", "bank", "merchant card", "visa card", "charity", "venmo"])
229
- unless validator.valid?(redemption_method)
230
- fail ArgumentError, "invalid value for \"redemption_method\", must be one of #{validator.allowable_values}."
231
- end
232
- @redemption_method = redemption_method
233
- end
234
-
235
244
  # Checks equality by comparing each attribute.
236
245
  # @param [Object] Object to be compared
237
246
  def ==(o)
238
247
  return true if self.equal?(o)
239
248
  self.class == o.class &&
240
249
  status == o.status &&
241
- risk == o.risk &&
242
250
  reasons == o.reasons &&
243
- reviewed_by == o.reviewed_by &&
244
- reviewed_at == o.reviewed_at &&
245
- related_rewards == o.related_rewards &&
246
251
  device_id == o.device_id &&
247
252
  redemption_method == o.redemption_method &&
248
253
  redeemed_at == o.redeemed_at &&
249
254
  geo == o.geo &&
250
- reward == o.reward
255
+ reward == o.reward &&
256
+ reviewed_by == o.reviewed_by &&
257
+ reviewed_at == o.reviewed_at &&
258
+ redemption_method_account_hash == o.redemption_method_account_hash &&
259
+ risk == o.risk &&
260
+ related_rewards == o.related_rewards
251
261
  end
252
262
 
253
263
  # @see the `==` method
@@ -259,7 +269,7 @@ module Tremendous
259
269
  # Calculates hash code according to all attributes.
260
270
  # @return [Integer] Hash code
261
271
  def hash
262
- [status, risk, reasons, reviewed_by, reviewed_at, related_rewards, device_id, redemption_method, redeemed_at, geo, reward].hash
272
+ [status, reasons, device_id, redemption_method, redeemed_at, geo, reward, reviewed_by, reviewed_at, redemption_method_account_hash, risk, related_rewards].hash
263
273
  end
264
274
 
265
275
  # Builds the object from hash
@@ -22,9 +22,12 @@ module Tremendous
22
22
  # Reference to the purchase order number within your organization
23
23
  attr_accessor :po_number
24
24
 
25
- # Amount of the invoice in USD
25
+ # Amount of the invoice
26
26
  attr_accessor :amount
27
27
 
28
+ # Currency of the invoice
29
+ attr_accessor :currency
30
+
28
31
  attr_accessor :international
29
32
 
30
33
  # Status of this invoice <table> <thead> <tr> <th>Status</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code>DELETED</code></td> <td>Invoice has been deleted by your organization</td> </tr> <tr> <td><code>PAID</code></td> <td>Invoice has been paid by your organization</td> </tr> <tr> <td><code>OPEN</code></td> <td>Invoice has been created by your organization but has not been paid, yet</td> </tr> </tbody> </table>
@@ -70,6 +73,7 @@ module Tremendous
70
73
  :'id' => :'id',
71
74
  :'po_number' => :'po_number',
72
75
  :'amount' => :'amount',
76
+ :'currency' => :'currency',
73
77
  :'international' => :'international',
74
78
  :'status' => :'status',
75
79
  :'orders' => :'orders',
@@ -95,6 +99,7 @@ module Tremendous
95
99
  :'id' => :'String',
96
100
  :'po_number' => :'String',
97
101
  :'amount' => :'Float',
102
+ :'currency' => :'String',
98
103
  :'international' => :'Boolean',
99
104
  :'status' => :'String',
100
105
  :'orders' => :'Array<String>',
@@ -144,6 +149,12 @@ module Tremendous
144
149
  self.amount = nil
145
150
  end
146
151
 
152
+ if attributes.key?(:'currency')
153
+ self.currency = attributes[:'currency']
154
+ else
155
+ self.currency = 'USD'
156
+ end
157
+
147
158
  if attributes.key?(:'international')
148
159
  self.international = attributes[:'international']
149
160
  end
@@ -209,6 +220,8 @@ module Tremendous
209
220
  warn '[DEPRECATED] the `valid?` method is obsolete'
210
221
  return false if @id.nil?
211
222
  return false if @amount.nil?
223
+ currency_validator = EnumAttributeValidator.new('String', ["USD", "EUR", "GBP"])
224
+ return false unless currency_validator.valid?(@currency)
212
225
  return false if @status.nil?
213
226
  status_validator = EnumAttributeValidator.new('String', ["DELETED", "PAID", "OPEN", "MARKED_AS_PAID"])
214
227
  return false unless status_validator.valid?(@status)
@@ -236,6 +249,16 @@ module Tremendous
236
249
  @amount = amount
237
250
  end
238
251
 
252
+ # Custom attribute writer method checking allowed values (enum).
253
+ # @param [Object] currency Object to be assigned
254
+ def currency=(currency)
255
+ validator = EnumAttributeValidator.new('String', ["USD", "EUR", "GBP"])
256
+ unless validator.valid?(currency)
257
+ fail ArgumentError, "invalid value for \"currency\", must be one of #{validator.allowable_values}."
258
+ end
259
+ @currency = currency
260
+ end
261
+
239
262
  # Custom attribute writer method checking allowed values (enum).
240
263
  # @param [Object] status Object to be assigned
241
264
  def status=(status)
@@ -264,6 +287,7 @@ module Tremendous
264
287
  id == o.id &&
265
288
  po_number == o.po_number &&
266
289
  amount == o.amount &&
290
+ currency == o.currency &&
267
291
  international == o.international &&
268
292
  status == o.status &&
269
293
  orders == o.orders &&
@@ -281,7 +305,7 @@ module Tremendous
281
305
  # Calculates hash code according to all attributes.
282
306
  # @return [Integer] Hash code
283
307
  def hash
284
- [id, po_number, amount, international, status, orders, rewards, created_at, paid_at].hash
308
+ [id, po_number, amount, currency, international, status, orders, rewards, created_at, paid_at].hash
285
309
  end
286
310
 
287
311
  # Builds the object from hash
@@ -20,7 +20,7 @@ module Tremendous
20
20
  # Label of the field
21
21
  attr_accessor :label
22
22
 
23
- # Type of the values of the field
23
+ # 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>
24
24
  attr_accessor :data_type
25
25
 
26
26
  attr_accessor :data
@@ -31,6 +31,28 @@ module Tremendous
31
31
  # Type of objects this field gets associated with
32
32
  attr_accessor :scope
33
33
 
34
+ class EnumAttributeValidator
35
+ attr_reader :datatype
36
+ attr_reader :allowable_values
37
+
38
+ def initialize(datatype, allowable_values)
39
+ @allowable_values = allowable_values.map do |value|
40
+ case datatype.to_s
41
+ when /Integer/i
42
+ value.to_i
43
+ when /Float/i
44
+ value.to_f
45
+ else
46
+ value
47
+ end
48
+ end
49
+ end
50
+
51
+ def valid?(value)
52
+ !value || allowable_values.include?(value)
53
+ end
54
+ end
55
+
34
56
  # Attribute mapping from ruby-style variable name to JSON key.
35
57
  def self.attribute_map
36
58
  {
@@ -59,7 +81,7 @@ module Tremendous
59
81
  :'id' => :'String',
60
82
  :'label' => :'String',
61
83
  :'data_type' => :'String',
62
- :'data' => :'Hash<String, Object>',
84
+ :'data' => :'ListFields200ResponseFieldsInnerData',
63
85
  :'required' => :'Boolean',
64
86
  :'scope' => :'String'
65
87
  }
@@ -100,9 +122,7 @@ module Tremendous
100
122
  end
101
123
 
102
124
  if attributes.key?(:'data')
103
- if (value = attributes[:'data']).is_a?(Hash)
104
- self.data = value
105
- end
125
+ self.data = attributes[:'data']
106
126
  end
107
127
 
108
128
  if attributes.key?(:'required')
@@ -132,6 +152,8 @@ module Tremendous
132
152
  def valid?
133
153
  warn '[DEPRECATED] the `valid?` method is obsolete'
134
154
  return false if !@id.nil? && @id !~ Regexp.new(/[A-Z0-9]{4,20}/)
155
+ data_type_validator = EnumAttributeValidator.new('String', ["Checkbox", "Currency", "Date", "Dropdown", "Email", "List", "Number", "Phone", "Text", "TextArea"])
156
+ return false unless data_type_validator.valid?(@data_type)
135
157
  true
136
158
  end
137
159
 
@@ -150,6 +172,16 @@ module Tremendous
150
172
  @id = id
151
173
  end
152
174
 
175
+ # Custom attribute writer method checking allowed values (enum).
176
+ # @param [Object] data_type Object to be assigned
177
+ def data_type=(data_type)
178
+ validator = EnumAttributeValidator.new('String', ["Checkbox", "Currency", "Date", "Dropdown", "Email", "List", "Number", "Phone", "Text", "TextArea"])
179
+ unless validator.valid?(data_type)
180
+ fail ArgumentError, "invalid value for \"data_type\", must be one of #{validator.allowable_values}."
181
+ end
182
+ @data_type = data_type
183
+ end
184
+
153
185
  # Checks equality by comparing each attribute.
154
186
  # @param [Object] Object to be compared
155
187
  def ==(o)
@@ -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 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
+ # Additional configuration for the field. Only used for `Dropdown` and `List` data types.
18
+ class ListFields200ResponseFieldsInnerData
19
+ # List of valid options for `Dropdown` and `List` field types. For `Dropdown`, the user selects one option. For `List`, the user can select multiple options.
20
+ attr_accessor :options
21
+
22
+ # Optional human-readable labels for each option. Keys are the option values, values are the display labels. If not provided, the option values are used as labels.
23
+ attr_accessor :labels
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'options' => :'options',
29
+ :'labels' => :'labels'
30
+ }
31
+ end
32
+
33
+ # Returns attribute mapping this model knows about
34
+ def self.acceptable_attribute_map
35
+ attribute_map
36
+ end
37
+
38
+ # Returns all the JSON keys this model knows about
39
+ def self.acceptable_attributes
40
+ acceptable_attribute_map.values
41
+ end
42
+
43
+ # Attribute type mapping.
44
+ def self.openapi_types
45
+ {
46
+ :'options' => :'Array<String>',
47
+ :'labels' => :'Hash<String, 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::ListFields200ResponseFieldsInnerData` initialize method"
62
+ end
63
+
64
+ # check to see if the attribute exists and convert string to symbol for hash key
65
+ acceptable_attribute_map = self.class.acceptable_attribute_map
66
+ attributes = attributes.each_with_object({}) { |(k, v), h|
67
+ if (!acceptable_attribute_map.key?(k.to_sym))
68
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::ListFields200ResponseFieldsInnerData`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
69
+ end
70
+ h[k.to_sym] = v
71
+ }
72
+
73
+ if attributes.key?(:'options')
74
+ if (value = attributes[:'options']).is_a?(Array)
75
+ self.options = value
76
+ end
77
+ end
78
+
79
+ if attributes.key?(:'labels')
80
+ if (value = attributes[:'labels']).is_a?(Hash)
81
+ self.labels = value
82
+ end
83
+ end
84
+ end
85
+
86
+ # Show invalid properties with the reasons. Usually used together with valid?
87
+ # @return Array for valid properties with the reasons
88
+ def list_invalid_properties
89
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
90
+ invalid_properties = Array.new
91
+ invalid_properties
92
+ end
93
+
94
+ # Check to see if the all the properties in the model are valid
95
+ # @return true if the model is valid
96
+ def valid?
97
+ warn '[DEPRECATED] the `valid?` method is obsolete'
98
+ true
99
+ end
100
+
101
+ # Checks equality by comparing each attribute.
102
+ # @param [Object] Object to be compared
103
+ def ==(o)
104
+ return true if self.equal?(o)
105
+ self.class == o.class &&
106
+ options == o.options &&
107
+ labels == o.labels
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
+ [options, labels].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