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
@@ -14,16 +14,13 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module Tremendous
17
- # Details on how the reward is delivered to the recipient.
18
- class CreateOrder200ResponseOrderRewardsInnerDelivery
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
17
+ # An active fraud rule
18
+ class ListFraudRules200ResponseFraudRulesInner
19
+ # * `review_country` - Flags when the recipient's IP country matches the criteria in the rule * `review_ip` - Flags when recipient's IP matches one in the list * `review_email` - Flags when the recipient's email matches one in the list * `review_redeemed_rewards_count` - Flags when the recipient redeemed more than the number of rewards specified in the config * `review_redeemed_rewards_amount` - Flags when the recipient redeemed more than the total amount specified in the config * `review_multiple_emails` - Flags when recipient's device or account has multiple emails associated * `review_vpn` - Flags when VPN is suspected * `review_tremendous_flag_list` - Flags rewards when redemption attributes match at least one criteria defined by the Tremendous flag list * `review_previously_blocked_recipients` - Flags rewards when the recipient has been blocked before * `allow_ip` - Releases a reward when a recipient's IP matches one in the list * `allow_email` - Releases a reward when the recipient's email matches one in the list
20
+ attr_accessor :rule_type
21
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
- # Link to redeem the reward at. You need to deliver this link to the recipient. Only available for rewards for which the `method` for delivery is set to `LINK`.
26
- attr_accessor :link
22
+ # The configuration associated with the rule. The properties allowed depend on the type of rule. This property is only present for rules that require configuration.
23
+ attr_accessor :config
27
24
 
28
25
  class EnumAttributeValidator
29
26
  attr_reader :datatype
@@ -50,9 +47,8 @@ module Tremendous
50
47
  # Attribute mapping from ruby-style variable name to JSON key.
51
48
  def self.attribute_map
52
49
  {
53
- :'method' => :'method',
54
- :'status' => :'status',
55
- :'link' => :'link'
50
+ :'rule_type' => :'rule_type',
51
+ :'config' => :'config'
56
52
  }
57
53
  end
58
54
 
@@ -64,15 +60,15 @@ module Tremendous
64
60
  # Attribute type mapping.
65
61
  def self.openapi_types
66
62
  {
67
- :'method' => :'String',
68
- :'status' => :'String',
69
- :'link' => :'String'
63
+ :'rule_type' => :'String',
64
+ :'config' => :'Object'
70
65
  }
71
66
  end
72
67
 
73
68
  # List of attributes with nullable: true
74
69
  def self.openapi_nullable
75
70
  Set.new([
71
+ :'config'
76
72
  ])
77
73
  end
78
74
 
@@ -80,31 +76,23 @@ module Tremendous
80
76
  # @param [Hash] attributes Model attributes in the form of hash
81
77
  def initialize(attributes = {})
82
78
  if (!attributes.is_a?(Hash))
83
- fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::CreateOrder200ResponseOrderRewardsInnerDelivery` initialize method"
79
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::ListFraudRules200ResponseFraudRulesInner` initialize method"
84
80
  end
85
81
 
86
82
  # check to see if the attribute exists and convert string to symbol for hash key
87
83
  attributes = attributes.each_with_object({}) { |(k, v), h|
88
84
  if (!self.class.attribute_map.key?(k.to_sym))
89
- fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::CreateOrder200ResponseOrderRewardsInnerDelivery`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
85
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::ListFraudRules200ResponseFraudRulesInner`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
90
86
  end
91
87
  h[k.to_sym] = v
92
88
  }
93
89
 
94
- if attributes.key?(:'method')
95
- self.method = attributes[:'method']
96
- else
97
- self.method = nil
90
+ if attributes.key?(:'rule_type')
91
+ self.rule_type = attributes[:'rule_type']
98
92
  end
99
93
 
100
- if attributes.key?(:'status')
101
- self.status = attributes[:'status']
102
- else
103
- self.status = nil
104
- end
105
-
106
- if attributes.key?(:'link')
107
- self.link = attributes[:'link']
94
+ if attributes.key?(:'config')
95
+ self.config = attributes[:'config']
108
96
  end
109
97
  end
110
98
 
@@ -113,14 +101,6 @@ module Tremendous
113
101
  def list_invalid_properties
114
102
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
115
103
  invalid_properties = Array.new
116
- if @method.nil?
117
- invalid_properties.push('invalid value for "method", method cannot be nil.')
118
- end
119
-
120
- if @status.nil?
121
- invalid_properties.push('invalid value for "status", status cannot be nil.')
122
- end
123
-
124
104
  invalid_properties
125
105
  end
126
106
 
@@ -128,33 +108,19 @@ module Tremendous
128
108
  # @return true if the model is valid
129
109
  def valid?
130
110
  warn '[DEPRECATED] the `valid?` method is obsolete'
131
- return false if @method.nil?
132
- method_validator = EnumAttributeValidator.new('String', ["EMAIL", "LINK", "PHONE"])
133
- return false unless method_validator.valid?(@method)
134
- return false if @status.nil?
135
- status_validator = EnumAttributeValidator.new('String', ["SCHEDULED", "FAILED", "SUCCEEDED", "PENDING"])
136
- return false unless status_validator.valid?(@status)
111
+ rule_type_validator = EnumAttributeValidator.new('String', ["review_country", "review_ip", "review_email", "review_redeemed_rewards_count", "review_redeemed_rewards_amount", "review_multiple_emails", "review_vpn", "review_tremendous_flag_list", "review_previously_blocked_recipients", "allow_ip", "allow_email"])
112
+ return false unless rule_type_validator.valid?(@rule_type)
137
113
  true
138
114
  end
139
115
 
140
116
  # Custom attribute writer method checking allowed values (enum).
141
- # @param [Object] method Object to be assigned
142
- def method=(method)
143
- validator = EnumAttributeValidator.new('String', ["EMAIL", "LINK", "PHONE"])
144
- unless validator.valid?(method)
145
- fail ArgumentError, "invalid value for \"method\", must be one of #{validator.allowable_values}."
146
- end
147
- @method = method
148
- end
149
-
150
- # Custom attribute writer method checking allowed values (enum).
151
- # @param [Object] status Object to be assigned
152
- def status=(status)
153
- validator = EnumAttributeValidator.new('String', ["SCHEDULED", "FAILED", "SUCCEEDED", "PENDING"])
154
- unless validator.valid?(status)
155
- fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
117
+ # @param [Object] rule_type Object to be assigned
118
+ def rule_type=(rule_type)
119
+ validator = EnumAttributeValidator.new('String', ["review_country", "review_ip", "review_email", "review_redeemed_rewards_count", "review_redeemed_rewards_amount", "review_multiple_emails", "review_vpn", "review_tremendous_flag_list", "review_previously_blocked_recipients", "allow_ip", "allow_email"])
120
+ unless validator.valid?(rule_type)
121
+ fail ArgumentError, "invalid value for \"rule_type\", must be one of #{validator.allowable_values}."
156
122
  end
157
- @status = status
123
+ @rule_type = rule_type
158
124
  end
159
125
 
160
126
  # Checks equality by comparing each attribute.
@@ -162,9 +128,8 @@ module Tremendous
162
128
  def ==(o)
163
129
  return true if self.equal?(o)
164
130
  self.class == o.class &&
165
- method == o.method &&
166
- status == o.status &&
167
- link == o.link
131
+ rule_type == o.rule_type &&
132
+ config == o.config
168
133
  end
169
134
 
170
135
  # @see the `==` method
@@ -176,7 +141,7 @@ module Tremendous
176
141
  # Calculates hash code according to all attributes.
177
142
  # @return [Integer] Hash code
178
143
  def hash
179
- [method, status, link].hash
144
+ [rule_type, config].hash
180
145
  end
181
146
 
182
147
  # Builds the object from hash
@@ -140,11 +140,6 @@ module Tremendous
140
140
  invalid_properties.push("invalid value for \"order_id\", must conform to the pattern #{pattern}.")
141
141
  end
142
142
 
143
- pattern = Regexp.new(/YYYY-MM-DD/)
144
- if !@deliver_at.nil? && @deliver_at !~ pattern
145
- invalid_properties.push("invalid value for \"deliver_at\", must conform to the pattern #{pattern}.")
146
- end
147
-
148
143
  invalid_properties
149
144
  end
150
145
 
@@ -154,7 +149,6 @@ module Tremendous
154
149
  warn '[DEPRECATED] the `valid?` method is obsolete'
155
150
  return false if !@id.nil? && @id !~ Regexp.new(/[A-Z0-9]{4,20}/)
156
151
  return false if !@order_id.nil? && @order_id !~ Regexp.new(/[A-Z0-9]{4,20}/)
157
- return false if !@deliver_at.nil? && @deliver_at !~ Regexp.new(/YYYY-MM-DD/)
158
152
  true
159
153
  end
160
154
 
@@ -188,21 +182,6 @@ module Tremendous
188
182
  @order_id = order_id
189
183
  end
190
184
 
191
- # Custom attribute writer method with validation
192
- # @param [Object] deliver_at Value to be assigned
193
- def deliver_at=(deliver_at)
194
- if deliver_at.nil?
195
- fail ArgumentError, 'deliver_at cannot be nil'
196
- end
197
-
198
- pattern = Regexp.new(/YYYY-MM-DD/)
199
- if deliver_at !~ pattern
200
- fail ArgumentError, "invalid value for \"deliver_at\", must conform to the pattern #{pattern}."
201
- end
202
-
203
- @deliver_at = deliver_at
204
- end
205
-
206
185
  # Checks equality by comparing each attribute.
207
186
  # @param [Object] Object to be compared
208
187
  def ==(o)
@@ -94,7 +94,7 @@ module Tremendous
94
94
  if attributes.key?(:'currency_code')
95
95
  self.currency_code = attributes[:'currency_code']
96
96
  else
97
- self.currency_code = nil
97
+ self.currency_code = 'USD'
98
98
  end
99
99
  end
100
100
 
@@ -107,10 +107,6 @@ module Tremendous
107
107
  invalid_properties.push('invalid value for "denomination", denomination cannot be nil.')
108
108
  end
109
109
 
110
- if @currency_code.nil?
111
- invalid_properties.push('invalid value for "currency_code", currency_code cannot be nil.')
112
- end
113
-
114
110
  invalid_properties
115
111
  end
116
112
 
@@ -119,7 +115,6 @@ module Tremendous
119
115
  def valid?
120
116
  warn '[DEPRECATED] the `valid?` method is obsolete'
121
117
  return false if @denomination.nil?
122
- return false if @currency_code.nil?
123
118
  currency_code_validator = EnumAttributeValidator.new('String', ["USD", "CAD", "EUR", "AED", "AFN", "ALL", "AMD", "ARS", "AUD", "AZN", "BAM", "BDT", "BGN", "BHD", "BIF", "BND", "BOB", "BRL", "BWP", "BYR", "BZD", "CDF", "CHF", "CLP", "CNY", "COP", "CRC", "CVE", "CZK", "DJF", "DKK", "DOP", "DZD", "EEK", "EGP", "ERN", "ETB", "GBP", "GEL", "GHS", "GNF", "GTQ", "HKD", "HNL", "HRK", "HUF", "IDR", "ILS", "INR", "IQD", "IRR", "ISK", "JMD", "JOD", "JPY", "KES", "KHR", "KRW", "KWD", "KZT", "LBP", "LKR", "LTL", "LVL", "MAD", "MDL", "MGA", "MKD", "MMK", "MOP", "MUR", "MXN", "MYR", "MZN", "NAD", "NGN", "NIO", "NOK", "NPR", "NZD", "OMR", "PAB", "PEN", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SDG", "SEK", "SGD", "SOS", "SYP", "THB", "TND", "TOP", "TRY", "TTD", "TWD", "TZS", "UAH", "UGX", "UYU", "UZS", "VEF", "VND", "XAF", "XOF", "YER", "ZAR", "ZMK"])
124
119
  return false unless currency_code_validator.valid?(@currency_code)
125
120
  true
@@ -170,11 +170,6 @@ module Tremendous
170
170
  invalid_properties.push('invalid value for "products", number of items must be greater than or equal to 1.')
171
171
  end
172
172
 
173
- pattern = Regexp.new(/YYYY-MM-DD/)
174
- if !@deliver_at.nil? && @deliver_at !~ pattern
175
- invalid_properties.push("invalid value for \"deliver_at\", must conform to the pattern #{pattern}.")
176
- end
177
-
178
173
  invalid_properties
179
174
  end
180
175
 
@@ -186,7 +181,6 @@ module Tremendous
186
181
  return false if !@order_id.nil? && @order_id !~ Regexp.new(/[A-Z0-9]{4,20}/)
187
182
  return false if !@campaign_id.nil? && @campaign_id !~ Regexp.new(/[A-Z0-9]{4,20}/)
188
183
  return false if !@products.nil? && @products.length < 1
189
- return false if !@deliver_at.nil? && @deliver_at !~ Regexp.new(/YYYY-MM-DD/)
190
184
  true
191
185
  end
192
186
 
@@ -245,21 +239,6 @@ module Tremendous
245
239
  @products = products
246
240
  end
247
241
 
248
- # Custom attribute writer method with validation
249
- # @param [Object] deliver_at Value to be assigned
250
- def deliver_at=(deliver_at)
251
- if deliver_at.nil?
252
- fail ArgumentError, 'deliver_at cannot be nil'
253
- end
254
-
255
- pattern = Regexp.new(/YYYY-MM-DD/)
256
- if deliver_at !~ pattern
257
- fail ArgumentError, "invalid value for \"deliver_at\", must conform to the pattern #{pattern}."
258
- end
259
-
260
- @deliver_at = deliver_at
261
- end
262
-
263
242
  # Checks equality by comparing each attribute.
264
243
  # @param [Object] Object to be compared
265
244
  def ==(o)
@@ -14,7 +14,7 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module Tremendous
17
- # To authenticate your requests using asymmetric key pairs (e.g., for signing embed requests), you need to share your public key with us. The public key resource allows you to manage your active public keys and track their last usage.
17
+ # To authenticate your requests using asymmetric key pairs (e.g., for signing embed requests), you need to share your public key with us. The public key resource allows you to manage your active public keys and track their last usage.
18
18
  class PublicKey
19
19
  attr_accessor :id
20
20
 
@@ -14,7 +14,7 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module Tremendous
17
- # To authenticate your requests using asymmetric key pairs (e.g., for signing embed requests), you need to share your public key with us. The public key resource allows you to manage your active public keys and track their last usage.
17
+ # To authenticate your requests using asymmetric key pairs (e.g., for signing embed requests), you need to share your public key with us. The public key resource allows you to manage your active public keys and track their last usage.
18
18
  class PublicKeysResponsePublicKeysInner
19
19
  attr_accessor :id
20
20
 
@@ -0,0 +1,276 @@
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
+ # Flag rewards redeemed in these countries.
18
+ class ReviewCountry
19
+ # When type is `whitelist`, it flags any countries that *are not* present in the list. When type is `blacklist`, it flags any countries that *are* present in the list.
20
+ attr_accessor :type
21
+
22
+ # An array of country codes (ISO-3166 alpha-2 character code)
23
+ attr_accessor :countries
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
+ :'type' => :'type',
51
+ :'countries' => :'countries'
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
+ :'type' => :'String',
64
+ :'countries' => :'Array<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::ReviewCountry` 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::ReviewCountry`. 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?(:'type')
90
+ self.type = attributes[:'type']
91
+ else
92
+ self.type = nil
93
+ end
94
+
95
+ if attributes.key?(:'countries')
96
+ if (value = attributes[:'countries']).is_a?(Array)
97
+ self.countries = value
98
+ end
99
+ else
100
+ self.countries = nil
101
+ end
102
+ end
103
+
104
+ # Show invalid properties with the reasons. Usually used together with valid?
105
+ # @return Array for valid properties with the reasons
106
+ def list_invalid_properties
107
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
108
+ invalid_properties = Array.new
109
+ if @type.nil?
110
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
111
+ end
112
+
113
+ if @countries.nil?
114
+ invalid_properties.push('invalid value for "countries", countries cannot be nil.')
115
+ end
116
+
117
+ invalid_properties
118
+ end
119
+
120
+ # Check to see if the all the properties in the model are valid
121
+ # @return true if the model is valid
122
+ def valid?
123
+ warn '[DEPRECATED] the `valid?` method is obsolete'
124
+ return false if @type.nil?
125
+ type_validator = EnumAttributeValidator.new('String', ["whitelist", "blacklist"])
126
+ return false unless type_validator.valid?(@type)
127
+ return false if @countries.nil?
128
+ true
129
+ end
130
+
131
+ # Custom attribute writer method checking allowed values (enum).
132
+ # @param [Object] type Object to be assigned
133
+ def type=(type)
134
+ validator = EnumAttributeValidator.new('String', ["whitelist", "blacklist"])
135
+ unless validator.valid?(type)
136
+ fail ArgumentError, "invalid value for \"type\", must be one of #{validator.allowable_values}."
137
+ end
138
+ @type = type
139
+ end
140
+
141
+ # Checks equality by comparing each attribute.
142
+ # @param [Object] Object to be compared
143
+ def ==(o)
144
+ return true if self.equal?(o)
145
+ self.class == o.class &&
146
+ type == o.type &&
147
+ countries == o.countries
148
+ end
149
+
150
+ # @see the `==` method
151
+ # @param [Object] Object to be compared
152
+ def eql?(o)
153
+ self == o
154
+ end
155
+
156
+ # Calculates hash code according to all attributes.
157
+ # @return [Integer] Hash code
158
+ def hash
159
+ [type, countries].hash
160
+ end
161
+
162
+ # Builds the object from hash
163
+ # @param [Hash] attributes Model attributes in the form of hash
164
+ # @return [Object] Returns the model itself
165
+ def self.build_from_hash(attributes)
166
+ return nil unless attributes.is_a?(Hash)
167
+ attributes = attributes.transform_keys(&:to_sym)
168
+ transformed_hash = {}
169
+ openapi_types.each_pair do |key, type|
170
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
171
+ transformed_hash["#{key}"] = nil
172
+ elsif type =~ /\AArray<(.*)>/i
173
+ # check to ensure the input is an array given that the attribute
174
+ # is documented as an array but the input is not
175
+ if attributes[attribute_map[key]].is_a?(Array)
176
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
177
+ end
178
+ elsif !attributes[attribute_map[key]].nil?
179
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
180
+ end
181
+ end
182
+ new(transformed_hash)
183
+ end
184
+
185
+ # Deserializes the data based on type
186
+ # @param string type Data type
187
+ # @param string value Value to be deserialized
188
+ # @return [Object] Deserialized data
189
+ def self._deserialize(type, value)
190
+ case type.to_sym
191
+ when :Time
192
+ Time.parse(value)
193
+ when :Date
194
+ Date.parse(value)
195
+ when :String
196
+ value.to_s
197
+ when :Integer
198
+ value.to_i
199
+ when :Float
200
+ value.to_f
201
+ when :Boolean
202
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
203
+ true
204
+ else
205
+ false
206
+ end
207
+ when :Object
208
+ # generic object (usually a Hash), return directly
209
+ value
210
+ when /\AArray<(?<inner_type>.+)>\z/
211
+ inner_type = Regexp.last_match[:inner_type]
212
+ value.map { |v| _deserialize(inner_type, v) }
213
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
214
+ k_type = Regexp.last_match[:k_type]
215
+ v_type = Regexp.last_match[:v_type]
216
+ {}.tap do |hash|
217
+ value.each do |k, v|
218
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
219
+ end
220
+ end
221
+ else # model
222
+ # models (e.g. Pet) or oneOf
223
+ klass = Tremendous.const_get(type)
224
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
225
+ end
226
+ end
227
+
228
+ # Returns the string representation of the object
229
+ # @return [String] String presentation of the object
230
+ def to_s
231
+ to_hash.to_s
232
+ end
233
+
234
+ # to_body is an alias to to_hash (backward compatibility)
235
+ # @return [Hash] Returns the object in the form of hash
236
+ def to_body
237
+ to_hash
238
+ end
239
+
240
+ # Returns the object in the form of hash
241
+ # @return [Hash] Returns the object in the form of hash
242
+ def to_hash
243
+ hash = {}
244
+ self.class.attribute_map.each_pair do |attr, param|
245
+ value = self.send(attr)
246
+ if value.nil?
247
+ is_nullable = self.class.openapi_nullable.include?(attr)
248
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
249
+ end
250
+
251
+ hash[param] = _to_hash(value)
252
+ end
253
+ hash
254
+ end
255
+
256
+ # Outputs non-array value in the form of hash
257
+ # For object, use to_hash. Otherwise, just return the value
258
+ # @param [Object] value Any valid value
259
+ # @return [Hash] Returns the value in the form of hash
260
+ def _to_hash(value)
261
+ if value.is_a?(Array)
262
+ value.compact.map { |v| _to_hash(v) }
263
+ elsif value.is_a?(Hash)
264
+ {}.tap do |hash|
265
+ value.each { |k, v| hash[k] = _to_hash(v) }
266
+ end
267
+ elsif value.respond_to? :to_hash
268
+ value.to_hash
269
+ else
270
+ value
271
+ end
272
+ end
273
+
274
+ end
275
+
276
+ end