tremendous_ruby 5.12.0 → 5.14.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 (41) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tremendous/api/tremendous_api.rb +202 -9
  3. data/lib/tremendous/models/allow_email.rb +9 -0
  4. data/lib/tremendous/models/allow_email1.rb +9 -0
  5. data/lib/tremendous/models/allow_ip.rb +9 -0
  6. data/lib/tremendous/models/allow_ip1.rb +9 -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/custom_field.rb +1 -1
  11. data/lib/tremendous/models/fraud_config_allow_email.rb +9 -0
  12. data/lib/tremendous/models/fraud_config_ip.rb +9 -0
  13. data/lib/tremendous/models/fraud_config_review_email.rb +19 -0
  14. data/lib/tremendous/models/fraud_review.rb +66 -56
  15. data/lib/tremendous/models/fraud_review_base.rb +358 -0
  16. data/lib/tremendous/models/fraud_review_list_item.rb +85 -4
  17. data/lib/tremendous/models/fraud_review_redemption_method.rb +7 -5
  18. data/lib/tremendous/models/funding_source.rb +3 -3
  19. data/lib/tremendous/models/get_fraud_review200_response_fraud_review.rb +66 -56
  20. data/lib/tremendous/models/invoice.rb +26 -2
  21. data/lib/tremendous/models/list_fraud_reviews200_response_fraud_reviews_inner.rb +85 -4
  22. data/lib/tremendous/models/list_fraud_reviews200_response_fraud_reviews_inner_geo.rb +242 -0
  23. data/lib/tremendous/models/list_funding_sources200_response_funding_sources_inner.rb +3 -3
  24. data/lib/tremendous/models/list_funding_sources200_response_funding_sources_inner_meta.rb +7 -2
  25. data/lib/tremendous/models/list_invoices200_response_invoices_inner.rb +26 -2
  26. data/lib/tremendous/models/list_products_response_products_inner.rb +24 -2
  27. data/lib/tremendous/models/list_rewards200_response_rewards_inner_custom_fields_inner.rb +1 -1
  28. data/lib/tremendous/models/list_topups200_response.rb +232 -0
  29. data/lib/tremendous/models/list_topups200_response_topups_inner.rb +326 -0
  30. data/lib/tremendous/models/product.rb +24 -2
  31. data/lib/tremendous/models/review_email.rb +19 -0
  32. data/lib/tremendous/models/review_email1.rb +19 -0
  33. data/lib/tremendous/models/review_ip.rb +9 -0
  34. data/lib/tremendous/models/review_ip1.rb +9 -0
  35. data/lib/tremendous/models/reward_base_custom_fields_inner.rb +1 -1
  36. data/lib/tremendous/models/single_reward_order_reward_custom_fields_inner.rb +1 -1
  37. data/lib/tremendous/models/topup.rb +326 -0
  38. data/lib/tremendous/models/topup_create_request.rb +292 -0
  39. data/lib/tremendous/version.rb +1 -1
  40. data/lib/tremendous.rb +8 -1
  41. metadata +9 -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' => :'OrderWithoutLinkRewardsInner'
110
+ :'geo' => :'ListFraudReviews200ResponseFraudReviewsInnerGeo',
111
+ :'reward' => :'OrderWithoutLinkRewardsInner',
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
@@ -0,0 +1,358 @@
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
+ # The fraud review associated with a reward.
18
+ class FraudReviewBase
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
+ attr_accessor :status
21
+
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`
23
+ attr_accessor :reasons
24
+
25
+ # The device fingerprint, if known.
26
+ attr_accessor :device_id
27
+
28
+ # The product selected to claim the reward
29
+ attr_accessor :redemption_method
30
+
31
+ # Date the reward was redeemed
32
+ attr_accessor :redeemed_at
33
+
34
+ attr_accessor :geo
35
+
36
+ attr_accessor :reward
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
+ class EnumAttributeValidator
48
+ attr_reader :datatype
49
+ attr_reader :allowable_values
50
+
51
+ def initialize(datatype, allowable_values)
52
+ @allowable_values = allowable_values.map do |value|
53
+ case datatype.to_s
54
+ when /Integer/i
55
+ value.to_i
56
+ when /Float/i
57
+ value.to_f
58
+ else
59
+ value
60
+ end
61
+ end
62
+ end
63
+
64
+ def valid?(value)
65
+ !value || allowable_values.include?(value)
66
+ end
67
+ end
68
+
69
+ # Attribute mapping from ruby-style variable name to JSON key.
70
+ def self.attribute_map
71
+ {
72
+ :'status' => :'status',
73
+ :'reasons' => :'reasons',
74
+ :'device_id' => :'device_id',
75
+ :'redemption_method' => :'redemption_method',
76
+ :'redeemed_at' => :'redeemed_at',
77
+ :'geo' => :'geo',
78
+ :'reward' => :'reward',
79
+ :'reviewed_by' => :'reviewed_by',
80
+ :'reviewed_at' => :'reviewed_at',
81
+ :'redemption_method_account_hash' => :'redemption_method_account_hash'
82
+ }
83
+ end
84
+
85
+ # Returns attribute mapping this model knows about
86
+ def self.acceptable_attribute_map
87
+ attribute_map
88
+ end
89
+
90
+ # Returns all the JSON keys this model knows about
91
+ def self.acceptable_attributes
92
+ acceptable_attribute_map.values
93
+ end
94
+
95
+ # Attribute type mapping.
96
+ def self.openapi_types
97
+ {
98
+ :'status' => :'String',
99
+ :'reasons' => :'Array<String>',
100
+ :'device_id' => :'String',
101
+ :'redemption_method' => :'String',
102
+ :'redeemed_at' => :'Time',
103
+ :'geo' => :'ListFraudReviews200ResponseFraudReviewsInnerGeo',
104
+ :'reward' => :'OrderWithoutLinkRewardsInner',
105
+ :'reviewed_by' => :'String',
106
+ :'reviewed_at' => :'Time',
107
+ :'redemption_method_account_hash' => :'String'
108
+ }
109
+ end
110
+
111
+ # List of attributes with nullable: true
112
+ def self.openapi_nullable
113
+ Set.new([
114
+ ])
115
+ end
116
+
117
+ # Initializes the object
118
+ # @param [Hash] attributes Model attributes in the form of hash
119
+ def initialize(attributes = {})
120
+ if (!attributes.is_a?(Hash))
121
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::FraudReviewBase` initialize method"
122
+ end
123
+
124
+ # check to see if the attribute exists and convert string to symbol for hash key
125
+ acceptable_attribute_map = self.class.acceptable_attribute_map
126
+ attributes = attributes.each_with_object({}) { |(k, v), h|
127
+ if (!acceptable_attribute_map.key?(k.to_sym))
128
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::FraudReviewBase`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
129
+ end
130
+ h[k.to_sym] = v
131
+ }
132
+
133
+ if attributes.key?(:'status')
134
+ self.status = attributes[:'status']
135
+ end
136
+
137
+ if attributes.key?(:'reasons')
138
+ if (value = attributes[:'reasons']).is_a?(Array)
139
+ self.reasons = value
140
+ end
141
+ end
142
+
143
+ if attributes.key?(:'device_id')
144
+ self.device_id = attributes[:'device_id']
145
+ end
146
+
147
+ if attributes.key?(:'redemption_method')
148
+ self.redemption_method = attributes[:'redemption_method']
149
+ end
150
+
151
+ if attributes.key?(:'redeemed_at')
152
+ self.redeemed_at = attributes[:'redeemed_at']
153
+ end
154
+
155
+ if attributes.key?(:'geo')
156
+ self.geo = attributes[:'geo']
157
+ end
158
+
159
+ if attributes.key?(:'reward')
160
+ self.reward = attributes[:'reward']
161
+ end
162
+
163
+ if attributes.key?(:'reviewed_by')
164
+ self.reviewed_by = attributes[:'reviewed_by']
165
+ end
166
+
167
+ if attributes.key?(:'reviewed_at')
168
+ self.reviewed_at = attributes[:'reviewed_at']
169
+ end
170
+
171
+ if attributes.key?(:'redemption_method_account_hash')
172
+ self.redemption_method_account_hash = attributes[:'redemption_method_account_hash']
173
+ end
174
+ end
175
+
176
+ # Show invalid properties with the reasons. Usually used together with valid?
177
+ # @return Array for valid properties with the reasons
178
+ def list_invalid_properties
179
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
180
+ invalid_properties = Array.new
181
+ invalid_properties
182
+ end
183
+
184
+ # Check to see if the all the properties in the model are valid
185
+ # @return true if the model is valid
186
+ def valid?
187
+ warn '[DEPRECATED] the `valid?` method is obsolete'
188
+ status_validator = EnumAttributeValidator.new('String', ["flagged", "blocked", "released"])
189
+ return false unless status_validator.valid?(@status)
190
+ redemption_method_validator = EnumAttributeValidator.new('String', ["bank transfer", "charity", "instant debit transfer", "international bank transfer", "merchant card", "paypal", "venmo", "visa card"])
191
+ return false unless redemption_method_validator.valid?(@redemption_method)
192
+ true
193
+ end
194
+
195
+ # Custom attribute writer method checking allowed values (enum).
196
+ # @param [Object] status Object to be assigned
197
+ def status=(status)
198
+ validator = EnumAttributeValidator.new('String', ["flagged", "blocked", "released"])
199
+ unless validator.valid?(status)
200
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
201
+ end
202
+ @status = status
203
+ end
204
+
205
+ # Custom attribute writer method checking allowed values (enum).
206
+ # @param [Object] redemption_method Object to be assigned
207
+ def redemption_method=(redemption_method)
208
+ validator = EnumAttributeValidator.new('String', ["bank transfer", "charity", "instant debit transfer", "international bank transfer", "merchant card", "paypal", "venmo", "visa card"])
209
+ unless validator.valid?(redemption_method)
210
+ fail ArgumentError, "invalid value for \"redemption_method\", must be one of #{validator.allowable_values}."
211
+ end
212
+ @redemption_method = redemption_method
213
+ end
214
+
215
+ # Checks equality by comparing each attribute.
216
+ # @param [Object] Object to be compared
217
+ def ==(o)
218
+ return true if self.equal?(o)
219
+ self.class == o.class &&
220
+ status == o.status &&
221
+ reasons == o.reasons &&
222
+ device_id == o.device_id &&
223
+ redemption_method == o.redemption_method &&
224
+ redeemed_at == o.redeemed_at &&
225
+ geo == o.geo &&
226
+ reward == o.reward &&
227
+ reviewed_by == o.reviewed_by &&
228
+ reviewed_at == o.reviewed_at &&
229
+ redemption_method_account_hash == o.redemption_method_account_hash
230
+ end
231
+
232
+ # @see the `==` method
233
+ # @param [Object] Object to be compared
234
+ def eql?(o)
235
+ self == o
236
+ end
237
+
238
+ # Calculates hash code according to all attributes.
239
+ # @return [Integer] Hash code
240
+ def hash
241
+ [status, reasons, device_id, redemption_method, redeemed_at, geo, reward, reviewed_by, reviewed_at, redemption_method_account_hash].hash
242
+ end
243
+
244
+ # Builds the object from hash
245
+ # @param [Hash] attributes Model attributes in the form of hash
246
+ # @return [Object] Returns the model itself
247
+ def self.build_from_hash(attributes)
248
+ return nil unless attributes.is_a?(Hash)
249
+ attributes = attributes.transform_keys(&:to_sym)
250
+ transformed_hash = {}
251
+ openapi_types.each_pair do |key, type|
252
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
253
+ transformed_hash["#{key}"] = nil
254
+ elsif type =~ /\AArray<(.*)>/i
255
+ # check to ensure the input is an array given that the attribute
256
+ # is documented as an array but the input is not
257
+ if attributes[attribute_map[key]].is_a?(Array)
258
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
259
+ end
260
+ elsif !attributes[attribute_map[key]].nil?
261
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
262
+ end
263
+ end
264
+ new(transformed_hash)
265
+ end
266
+
267
+ # Deserializes the data based on type
268
+ # @param string type Data type
269
+ # @param string value Value to be deserialized
270
+ # @return [Object] Deserialized data
271
+ def self._deserialize(type, value)
272
+ case type.to_sym
273
+ when :Time
274
+ Time.parse(value)
275
+ when :Date
276
+ Date.parse(value)
277
+ when :String
278
+ value.to_s
279
+ when :Integer
280
+ value.to_i
281
+ when :Float
282
+ value.to_f
283
+ when :Boolean
284
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
285
+ true
286
+ else
287
+ false
288
+ end
289
+ when :Object
290
+ # generic object (usually a Hash), return directly
291
+ value
292
+ when /\AArray<(?<inner_type>.+)>\z/
293
+ inner_type = Regexp.last_match[:inner_type]
294
+ value.map { |v| _deserialize(inner_type, v) }
295
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
296
+ k_type = Regexp.last_match[:k_type]
297
+ v_type = Regexp.last_match[:v_type]
298
+ {}.tap do |hash|
299
+ value.each do |k, v|
300
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
301
+ end
302
+ end
303
+ else # model
304
+ # models (e.g. Pet) or oneOf
305
+ klass = Tremendous.const_get(type)
306
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
307
+ end
308
+ end
309
+
310
+ # Returns the string representation of the object
311
+ # @return [String] String presentation of the object
312
+ def to_s
313
+ to_hash.to_s
314
+ end
315
+
316
+ # to_body is an alias to to_hash (backward compatibility)
317
+ # @return [Hash] Returns the object in the form of hash
318
+ def to_body
319
+ to_hash
320
+ end
321
+
322
+ # Returns the object in the form of hash
323
+ # @return [Hash] Returns the object in the form of hash
324
+ def to_hash
325
+ hash = {}
326
+ self.class.attribute_map.each_pair do |attr, param|
327
+ value = self.send(attr)
328
+ if value.nil?
329
+ is_nullable = self.class.openapi_nullable.include?(attr)
330
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
331
+ end
332
+
333
+ hash[param] = _to_hash(value)
334
+ end
335
+ hash
336
+ end
337
+
338
+ # Outputs non-array value in the form of hash
339
+ # For object, use to_hash. Otherwise, just return the value
340
+ # @param [Object] value Any valid value
341
+ # @return [Hash] Returns the value in the form of hash
342
+ def _to_hash(value)
343
+ if value.is_a?(Array)
344
+ value.compact.map { |v| _to_hash(v) }
345
+ elsif value.is_a?(Hash)
346
+ {}.tap do |hash|
347
+ value.each { |k, v| hash[k] = _to_hash(v) }
348
+ end
349
+ elsif value.respond_to? :to_hash
350
+ value.to_hash
351
+ else
352
+ value
353
+ end
354
+ end
355
+
356
+ end
357
+
358
+ end