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