tremendous_ruby 5.3.0 → 5.5.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 (192) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tremendous/api/tremendous_api.rb +618 -56
  3. data/lib/tremendous/api_client.rb +31 -26
  4. data/lib/tremendous/api_error.rb +1 -1
  5. data/lib/tremendous/configuration.rb +2 -2
  6. data/lib/tremendous/models/allow_email.rb +225 -0
  7. data/lib/tremendous/models/allow_email1.rb +225 -0
  8. data/lib/tremendous/models/allow_ip.rb +225 -0
  9. data/lib/tremendous/models/allow_ip1.rb +225 -0
  10. data/lib/tremendous/models/balance_transaction.rb +37 -2
  11. data/lib/tremendous/models/base_order_for_create.rb +232 -0
  12. data/lib/tremendous/models/campaign.rb +1 -1
  13. data/lib/tremendous/models/campaign_base.rb +1 -1
  14. data/lib/tremendous/models/channel.rb +45 -0
  15. data/lib/tremendous/models/create_api_key200_response.rb +1 -1
  16. data/lib/tremendous/models/create_campaign201_response.rb +1 -1
  17. data/lib/tremendous/models/create_campaign_request.rb +1 -1
  18. data/lib/tremendous/models/create_invoice.rb +1 -1
  19. data/lib/tremendous/models/create_invoice200_response.rb +1 -1
  20. data/lib/tremendous/models/create_invoice_request.rb +1 -1
  21. data/lib/tremendous/models/create_member.rb +1 -1
  22. data/lib/tremendous/models/create_member200_response.rb +1 -1
  23. data/lib/tremendous/models/create_member_request.rb +1 -1
  24. data/lib/tremendous/models/create_order200_response.rb +2 -2
  25. data/lib/tremendous/models/create_order_request.rb +74 -218
  26. data/lib/tremendous/models/create_organization.rb +1 -1
  27. data/lib/tremendous/models/create_organization200_response.rb +1 -1
  28. data/lib/tremendous/models/create_organization200_response_organization.rb +1 -1
  29. data/lib/tremendous/models/create_organization_request.rb +1 -1
  30. data/lib/tremendous/models/create_organization_request_copy_settings.rb +1 -1
  31. data/lib/tremendous/models/create_public_key.rb +1 -1
  32. data/lib/tremendous/models/create_public_key200_response.rb +1 -1
  33. data/lib/tremendous/models/create_public_key_request.rb +1 -1
  34. data/lib/tremendous/models/create_webhook200_response.rb +1 -1
  35. data/lib/tremendous/models/create_webhook_request.rb +1 -1
  36. data/lib/tremendous/models/currency_codes.rb +1 -1
  37. data/lib/tremendous/models/custom_field.rb +1 -1
  38. data/lib/tremendous/models/delete_fraud_rule200_response.rb +222 -0
  39. data/lib/tremendous/models/delivery_details.rb +1 -1
  40. data/lib/tremendous/models/delivery_method.rb +1 -1
  41. data/lib/tremendous/models/delivery_status.rb +1 -1
  42. data/lib/tremendous/models/error_model.rb +1 -1
  43. data/lib/tremendous/models/field.rb +1 -1
  44. data/lib/tremendous/models/fraud_config_allow_email.rb +224 -0
  45. data/lib/tremendous/models/fraud_config_country.rb +275 -0
  46. data/lib/tremendous/models/fraud_config_country_update_list.rb +224 -0
  47. data/lib/tremendous/models/fraud_config_ip.rb +224 -0
  48. data/lib/tremendous/models/fraud_config_redeemed_rewards_amount.rb +292 -0
  49. data/lib/tremendous/models/fraud_config_redeemed_rewards_count.rb +292 -0
  50. data/lib/tremendous/models/fraud_config_review_email.rb +229 -0
  51. data/lib/tremendous/models/fraud_generic_response.rb +222 -0
  52. data/lib/tremendous/models/fraud_review.rb +351 -0
  53. data/lib/tremendous/models/fraud_review_geo.rb +235 -0
  54. data/lib/tremendous/models/{reward_with_link_delivery.rb → fraud_review_list_item.rb} +27 -52
  55. data/lib/tremendous/models/fraud_review_reason.rb +58 -0
  56. data/lib/tremendous/models/fraud_review_redemption_method.rb +44 -0
  57. data/lib/tremendous/models/fraud_review_related_rewards.rb +304 -0
  58. data/lib/tremendous/models/fraud_review_status.rb +41 -0
  59. data/lib/tremendous/models/fraud_rule200_response.rb +222 -0
  60. data/lib/tremendous/models/fraud_rule400_response.rb +221 -0
  61. data/lib/tremendous/models/fraud_rule422_response.rb +221 -0
  62. data/lib/tremendous/models/fraud_rule_request.rb +214 -0
  63. data/lib/tremendous/models/fraud_rule_request_config.rb +110 -0
  64. data/lib/tremendous/models/fraud_rule_type.rb +49 -0
  65. data/lib/tremendous/models/fraud_rules_list_item.rb +261 -0
  66. data/lib/tremendous/models/funding_source.rb +1 -1
  67. data/lib/tremendous/models/generate_reward_link200_response.rb +1 -1
  68. data/lib/tremendous/models/generate_reward_link200_response_reward.rb +1 -1
  69. data/lib/tremendous/models/generate_reward_link403_response.rb +1 -1
  70. data/lib/tremendous/models/generate_reward_token200_response.rb +1 -1
  71. data/lib/tremendous/models/generate_reward_token200_response_reward.rb +1 -1
  72. data/lib/tremendous/models/get_fraud_review200_response.rb +221 -0
  73. data/lib/tremendous/models/get_fraud_review200_response_fraud_review.rb +351 -0
  74. data/lib/tremendous/models/get_fraud_review200_response_fraud_review_geo.rb +236 -0
  75. data/lib/tremendous/models/get_fraud_review200_response_fraud_review_related_rewards.rb +305 -0
  76. data/lib/tremendous/models/get_funding_source200_response.rb +1 -1
  77. data/lib/tremendous/models/get_member200_response.rb +1 -1
  78. data/lib/tremendous/models/get_member200_response_member.rb +1 -1
  79. data/lib/tremendous/models/get_member200_response_member_events_inner.rb +1 -1
  80. data/lib/tremendous/models/get_organization200_response.rb +1 -1
  81. data/lib/tremendous/models/get_product_response.rb +1 -1
  82. data/lib/tremendous/models/get_reward200_response.rb +1 -1
  83. data/lib/tremendous/models/invoice.rb +1 -1
  84. data/lib/tremendous/models/list_balance_transactions200_response.rb +16 -9
  85. data/lib/tremendous/models/{list_balance_transactions200_response_invoices_inner.rb → list_balance_transactions200_response_transactions_inner.rb} +40 -5
  86. data/lib/tremendous/models/list_campaigns200_response.rb +1 -1
  87. data/lib/tremendous/models/list_campaigns200_response_campaigns_inner.rb +1 -1
  88. data/lib/tremendous/models/list_campaigns200_response_campaigns_inner_email_style.rb +3 -1
  89. data/lib/tremendous/models/list_campaigns200_response_campaigns_inner_webpage_style.rb +2 -1
  90. data/lib/tremendous/models/list_fields200_response.rb +1 -1
  91. data/lib/tremendous/models/list_fields200_response_fields_inner.rb +1 -1
  92. data/lib/tremendous/models/list_forex_response.rb +1 -1
  93. data/lib/tremendous/models/list_fraud_reviews200_response.rb +223 -0
  94. data/lib/tremendous/models/{delivery_details_with_link.rb → list_fraud_reviews200_response_fraud_reviews_inner.rb} +27 -52
  95. data/lib/tremendous/models/list_fraud_rules200_response.rb +223 -0
  96. data/lib/tremendous/models/{create_order200_response_order_rewards_inner_delivery.rb → list_fraud_rules200_response_fraud_rules_inner.rb} +29 -64
  97. data/lib/tremendous/models/list_funding_sources200_response.rb +1 -1
  98. data/lib/tremendous/models/list_funding_sources200_response_funding_sources_inner.rb +1 -1
  99. data/lib/tremendous/models/list_funding_sources200_response_funding_sources_inner_meta.rb +1 -1
  100. data/lib/tremendous/models/list_invoices200_response.rb +1 -1
  101. data/lib/tremendous/models/list_invoices200_response_invoices_inner.rb +1 -1
  102. data/lib/tremendous/models/list_members200_response.rb +1 -1
  103. data/lib/tremendous/models/list_members200_response_members_inner.rb +1 -1
  104. data/lib/tremendous/models/list_orders200_response.rb +1 -1
  105. data/lib/tremendous/models/list_orders200_response_orders_inner.rb +32 -8
  106. data/lib/tremendous/models/list_orders200_response_orders_inner_payment.rb +1 -1
  107. data/lib/tremendous/models/list_orders200_response_orders_inner_payment_refund.rb +1 -1
  108. data/lib/tremendous/models/list_organizations200_response.rb +1 -1
  109. data/lib/tremendous/models/list_organizations200_response_organizations_inner.rb +1 -1
  110. data/lib/tremendous/models/list_products_response.rb +1 -1
  111. data/lib/tremendous/models/list_products_response_products_inner.rb +1 -1
  112. data/lib/tremendous/models/list_products_response_products_inner_countries_inner.rb +1 -1
  113. data/lib/tremendous/models/list_products_response_products_inner_images_inner.rb +1 -1
  114. data/lib/tremendous/models/list_products_response_products_inner_skus_inner.rb +1 -1
  115. data/lib/tremendous/models/list_rewards200_response.rb +1 -1
  116. data/lib/tremendous/models/list_rewards200_response_rewards_inner.rb +1 -22
  117. data/lib/tremendous/models/list_rewards200_response_rewards_inner_custom_fields_inner.rb +1 -1
  118. data/lib/tremendous/models/list_rewards200_response_rewards_inner_delivery.rb +1 -1
  119. data/lib/tremendous/models/list_rewards200_response_rewards_inner_recipient.rb +1 -1
  120. data/lib/tremendous/models/list_rewards200_response_rewards_inner_value.rb +2 -7
  121. data/lib/tremendous/models/list_rewards401_response.rb +1 -1
  122. data/lib/tremendous/models/list_rewards401_response_errors.rb +1 -1
  123. data/lib/tremendous/models/list_rewards429_response.rb +1 -1
  124. data/lib/tremendous/models/list_roles200_response.rb +1 -1
  125. data/lib/tremendous/models/list_roles200_response_roles_inner.rb +1 -1
  126. data/lib/tremendous/models/list_webhook_events200_response.rb +1 -1
  127. data/lib/tremendous/models/list_webhooks200_response.rb +1 -1
  128. data/lib/tremendous/models/list_webhooks200_response_webhooks_inner.rb +1 -1
  129. data/lib/tremendous/models/member.rb +1 -1
  130. data/lib/tremendous/models/member_base.rb +1 -1
  131. data/lib/tremendous/models/member_with_events.rb +1 -1
  132. data/lib/tremendous/models/member_without_events.rb +1 -1
  133. data/lib/tremendous/models/order.rb +32 -8
  134. data/lib/tremendous/models/order_base.rb +24 -2
  135. data/lib/tremendous/models/order_base_payment.rb +1 -1
  136. data/lib/tremendous/models/order_status.rb +1 -1
  137. data/lib/tremendous/models/order_without_link.rb +32 -8
  138. data/lib/tremendous/models/{order_without_link_reward.rb → order_without_link_rewards_inner.rb} +4 -25
  139. data/lib/tremendous/models/organization.rb +1 -1
  140. data/lib/tremendous/models/payment_details.rb +1 -1
  141. data/lib/tremendous/models/payment_details_refund.rb +1 -1
  142. data/lib/tremendous/models/product.rb +1 -1
  143. data/lib/tremendous/models/public_key.rb +2 -2
  144. data/lib/tremendous/models/public_keys_response.rb +1 -1
  145. data/lib/tremendous/models/public_keys_response_public_keys_inner.rb +2 -2
  146. data/lib/tremendous/models/recipient.rb +1 -1
  147. data/lib/tremendous/models/refund_details.rb +1 -1
  148. data/lib/tremendous/models/resend_reward422_response.rb +1 -1
  149. data/lib/tremendous/models/review_country.rb +276 -0
  150. data/lib/tremendous/models/review_country1.rb +225 -0
  151. data/lib/tremendous/models/review_email.rb +230 -0
  152. data/lib/tremendous/models/review_email1.rb +230 -0
  153. data/lib/tremendous/models/review_ip.rb +225 -0
  154. data/lib/tremendous/models/review_ip1.rb +225 -0
  155. data/lib/tremendous/models/review_redeemed_rewards_amount.rb +293 -0
  156. data/lib/tremendous/models/review_redeemed_rewards_count.rb +293 -0
  157. data/lib/tremendous/models/reward.rb +1 -22
  158. data/lib/tremendous/models/reward_base.rb +1 -22
  159. data/lib/tremendous/models/reward_base_custom_fields_inner.rb +1 -1
  160. data/lib/tremendous/models/reward_for_order_create.rb +2 -23
  161. data/lib/tremendous/models/reward_link.rb +1 -1
  162. data/lib/tremendous/models/reward_token.rb +1 -1
  163. data/lib/tremendous/models/reward_value.rb +2 -7
  164. data/lib/tremendous/models/reward_without_link.rb +1 -22
  165. data/lib/tremendous/models/reward_without_link_delivery.rb +1 -1
  166. data/lib/tremendous/models/role.rb +1 -1
  167. data/lib/tremendous/models/simulate_webhook_request.rb +1 -1
  168. data/lib/tremendous/models/{order_for_create.rb → single_reward_order.rb} +7 -13
  169. data/lib/tremendous/models/single_reward_order1.rb +242 -0
  170. data/lib/tremendous/models/{create_order_request_payment.rb → single_reward_order1_payment.rb} +4 -4
  171. data/lib/tremendous/models/{create_order_request_reward.rb → single_reward_order1_reward.rb} +6 -27
  172. data/lib/tremendous/models/{create_order_request_reward_custom_fields_inner.rb → single_reward_order1_reward_custom_fields_inner.rb} +4 -4
  173. data/lib/tremendous/models/{create_order_request_reward_delivery.rb → single_reward_order1_reward_delivery.rb} +4 -4
  174. data/lib/tremendous/models/{order_for_create_reward.rb → single_reward_order_reward.rb} +5 -26
  175. data/lib/tremendous/models/{create_order201_response.rb → single_reward_order_without_link.rb} +5 -5
  176. data/lib/tremendous/models/{order_with_link.rb → single_reward_order_without_link_order.rb} +25 -22
  177. data/lib/tremendous/models/test_public_key.rb +1 -1
  178. data/lib/tremendous/models/test_public_key_request.rb +1 -1
  179. data/lib/tremendous/models/update_campaign.rb +1 -1
  180. data/lib/tremendous/models/update_campaign_request.rb +1 -1
  181. data/lib/tremendous/models/update_fraud_rule_list200_response.rb +222 -0
  182. data/lib/tremendous/models/update_fraud_rule_list_request.rb +272 -0
  183. data/lib/tremendous/models/update_fraud_rule_list_request_config.rb +108 -0
  184. data/lib/tremendous/models/webhook.rb +1 -1
  185. data/lib/tremendous/models/webhook_post.rb +1 -1
  186. data/lib/tremendous/version.rb +1 -1
  187. data/lib/tremendous.rb +60 -18
  188. metadata +62 -20
  189. data/lib/tremendous/models/create_order200_response_order.rb +0 -400
  190. data/lib/tremendous/models/create_order200_response_order_rewards_inner.rb +0 -347
  191. data/lib/tremendous/models/order_with_link_rewards_inner.rb +0 -406
  192. data/lib/tremendous/models/reward_with_link.rb +0 -406
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 2
7
7
  Contact: developers@tremendous.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 7.3.0
9
+ Generator version: 7.8.0
10
10
 
11
11
  =end
12
12
 
@@ -140,8 +140,7 @@ module Tremendous
140
140
  form_params.each do |key, value|
141
141
  case value
142
142
  when ::File, ::Tempfile
143
- # TODO hardcode to application/octet-stream, need better way to detect content type
144
- data[key] = Faraday::FilePart.new(value.path, 'application/octet-stream', value.path)
143
+ data[key] = Faraday::FilePart.new(value.path, Marcel::MimeType.for(Pathname.new(value.path)))
145
144
  when ::Array, nil
146
145
  # let Faraday handle Array and nil parameters
147
146
  data[key] = value
@@ -164,35 +163,41 @@ module Tremendous
164
163
  request.options.on_data = Proc.new do |chunk, overall_received_bytes|
165
164
  stream << chunk
166
165
  end
166
+
167
167
  stream
168
168
  end
169
169
 
170
170
  def deserialize_file(response, stream)
171
- body = response.body
172
- if @config.return_binary_data == true
173
- # return byte stream
174
- encoding = body.encoding
175
- stream.join.force_encoding(encoding)
171
+ body = response.body
172
+ encoding = body.encoding
173
+
174
+ # reconstruct content
175
+ content = stream.join
176
+ content = content.unpack('m').join if response.headers['Content-Transfer-Encoding'] == 'binary'
177
+ content = content.force_encoding(encoding)
178
+
179
+ # return byte stream
180
+ return content if @config.return_binary_data == true
181
+
182
+ # return file instead of binary data
183
+ content_disposition = response.headers['Content-Disposition']
184
+ if content_disposition && content_disposition =~ /filename=/i
185
+ filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
186
+ prefix = sanitize_filename(filename)
176
187
  else
177
- # return file instead of binary data
178
- content_disposition = response.headers['Content-Disposition']
179
- if content_disposition && content_disposition =~ /filename=/i
180
- filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
181
- prefix = sanitize_filename(filename)
182
- else
183
- prefix = 'download-'
184
- end
185
- prefix = prefix + '-' unless prefix.end_with?('-')
186
- encoding = body.encoding
187
- tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
188
- tempfile.write(stream.join.force_encoding(encoding))
189
- tempfile.close
190
- config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
191
- "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
192
- "will be deleted automatically with GC. It's also recommended to delete the temp file "\
193
- "explicitly with `tempfile.delete`"
194
- tempfile
188
+ prefix = 'download-'
195
189
  end
190
+ prefix = prefix + '-' unless prefix.end_with?('-')
191
+
192
+ tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
193
+ tempfile.write(content)
194
+ tempfile.close
195
+
196
+ config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
197
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
198
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
199
+ "explicitly with `tempfile.delete`"
200
+ tempfile
196
201
  end
197
202
 
198
203
  def connection(opts)
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 2
7
7
  Contact: developers@tremendous.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 7.3.0
9
+ Generator version: 7.8.0
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 2
7
7
  Contact: developers@tremendous.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 7.3.0
9
+ Generator version: 7.8.0
10
10
 
11
11
  =end
12
12
 
@@ -259,7 +259,7 @@ module Tremendous
259
259
  description: "Sandbox environment",
260
260
  },
261
261
  {
262
- url: "https://www.tremendous.com/api/v2",
262
+ url: "https://api.tremendous.com/api/v2",
263
263
  description: "Production environment",
264
264
  }
265
265
  ]
@@ -0,0 +1,225 @@
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
+ Generator version: 7.8.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Tremendous
17
+ # Ignore flagging rules for rewards redeemed by an email or domain matching this list.
18
+ class AllowEmail
19
+ # The list of emails.
20
+ attr_accessor :emails
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'emails' => :'emails'
26
+ }
27
+ end
28
+
29
+ # Returns all the JSON keys this model knows about
30
+ def self.acceptable_attributes
31
+ attribute_map.values
32
+ end
33
+
34
+ # Attribute type mapping.
35
+ def self.openapi_types
36
+ {
37
+ :'emails' => :'Array<String>'
38
+ }
39
+ end
40
+
41
+ # List of attributes with nullable: true
42
+ def self.openapi_nullable
43
+ Set.new([
44
+ ])
45
+ end
46
+
47
+ # Initializes the object
48
+ # @param [Hash] attributes Model attributes in the form of hash
49
+ def initialize(attributes = {})
50
+ if (!attributes.is_a?(Hash))
51
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::AllowEmail` initialize method"
52
+ end
53
+
54
+ # check to see if the attribute exists and convert string to symbol for hash key
55
+ attributes = attributes.each_with_object({}) { |(k, v), h|
56
+ if (!self.class.attribute_map.key?(k.to_sym))
57
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::AllowEmail`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
58
+ end
59
+ h[k.to_sym] = v
60
+ }
61
+
62
+ if attributes.key?(:'emails')
63
+ if (value = attributes[:'emails']).is_a?(Array)
64
+ self.emails = value
65
+ end
66
+ else
67
+ self.emails = nil
68
+ end
69
+ end
70
+
71
+ # Show invalid properties with the reasons. Usually used together with valid?
72
+ # @return Array for valid properties with the reasons
73
+ def list_invalid_properties
74
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
75
+ invalid_properties = Array.new
76
+ if @emails.nil?
77
+ invalid_properties.push('invalid value for "emails", emails cannot be nil.')
78
+ end
79
+
80
+ invalid_properties
81
+ end
82
+
83
+ # Check to see if the all the properties in the model are valid
84
+ # @return true if the model is valid
85
+ def valid?
86
+ warn '[DEPRECATED] the `valid?` method is obsolete'
87
+ return false if @emails.nil?
88
+ true
89
+ end
90
+
91
+ # Checks equality by comparing each attribute.
92
+ # @param [Object] Object to be compared
93
+ def ==(o)
94
+ return true if self.equal?(o)
95
+ self.class == o.class &&
96
+ emails == o.emails
97
+ end
98
+
99
+ # @see the `==` method
100
+ # @param [Object] Object to be compared
101
+ def eql?(o)
102
+ self == o
103
+ end
104
+
105
+ # Calculates hash code according to all attributes.
106
+ # @return [Integer] Hash code
107
+ def hash
108
+ [emails].hash
109
+ end
110
+
111
+ # Builds the object from hash
112
+ # @param [Hash] attributes Model attributes in the form of hash
113
+ # @return [Object] Returns the model itself
114
+ def self.build_from_hash(attributes)
115
+ return nil unless attributes.is_a?(Hash)
116
+ attributes = attributes.transform_keys(&:to_sym)
117
+ transformed_hash = {}
118
+ openapi_types.each_pair do |key, type|
119
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
120
+ transformed_hash["#{key}"] = nil
121
+ elsif type =~ /\AArray<(.*)>/i
122
+ # check to ensure the input is an array given that the attribute
123
+ # is documented as an array but the input is not
124
+ if attributes[attribute_map[key]].is_a?(Array)
125
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
126
+ end
127
+ elsif !attributes[attribute_map[key]].nil?
128
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
129
+ end
130
+ end
131
+ new(transformed_hash)
132
+ end
133
+
134
+ # Deserializes the data based on type
135
+ # @param string type Data type
136
+ # @param string value Value to be deserialized
137
+ # @return [Object] Deserialized data
138
+ def self._deserialize(type, value)
139
+ case type.to_sym
140
+ when :Time
141
+ Time.parse(value)
142
+ when :Date
143
+ Date.parse(value)
144
+ when :String
145
+ value.to_s
146
+ when :Integer
147
+ value.to_i
148
+ when :Float
149
+ value.to_f
150
+ when :Boolean
151
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
152
+ true
153
+ else
154
+ false
155
+ end
156
+ when :Object
157
+ # generic object (usually a Hash), return directly
158
+ value
159
+ when /\AArray<(?<inner_type>.+)>\z/
160
+ inner_type = Regexp.last_match[:inner_type]
161
+ value.map { |v| _deserialize(inner_type, v) }
162
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
163
+ k_type = Regexp.last_match[:k_type]
164
+ v_type = Regexp.last_match[:v_type]
165
+ {}.tap do |hash|
166
+ value.each do |k, v|
167
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
168
+ end
169
+ end
170
+ else # model
171
+ # models (e.g. Pet) or oneOf
172
+ klass = Tremendous.const_get(type)
173
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
174
+ end
175
+ end
176
+
177
+ # Returns the string representation of the object
178
+ # @return [String] String presentation of the object
179
+ def to_s
180
+ to_hash.to_s
181
+ end
182
+
183
+ # to_body is an alias to to_hash (backward compatibility)
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_body
186
+ to_hash
187
+ end
188
+
189
+ # Returns the object in the form of hash
190
+ # @return [Hash] Returns the object in the form of hash
191
+ def to_hash
192
+ hash = {}
193
+ self.class.attribute_map.each_pair do |attr, param|
194
+ value = self.send(attr)
195
+ if value.nil?
196
+ is_nullable = self.class.openapi_nullable.include?(attr)
197
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
198
+ end
199
+
200
+ hash[param] = _to_hash(value)
201
+ end
202
+ hash
203
+ end
204
+
205
+ # Outputs non-array value in the form of hash
206
+ # For object, use to_hash. Otherwise, just return the value
207
+ # @param [Object] value Any valid value
208
+ # @return [Hash] Returns the value in the form of hash
209
+ def _to_hash(value)
210
+ if value.is_a?(Array)
211
+ value.compact.map { |v| _to_hash(v) }
212
+ elsif value.is_a?(Hash)
213
+ {}.tap do |hash|
214
+ value.each { |k, v| hash[k] = _to_hash(v) }
215
+ end
216
+ elsif value.respond_to? :to_hash
217
+ value.to_hash
218
+ else
219
+ value
220
+ end
221
+ end
222
+
223
+ end
224
+
225
+ end
@@ -0,0 +1,225 @@
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
+ Generator version: 7.8.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Tremendous
17
+ # The list of emails and domains where a matching redemption will ignore other flagging rules and automatically go through.
18
+ class AllowEmail1
19
+ # The list of emails.
20
+ attr_accessor :emails
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'emails' => :'emails'
26
+ }
27
+ end
28
+
29
+ # Returns all the JSON keys this model knows about
30
+ def self.acceptable_attributes
31
+ attribute_map.values
32
+ end
33
+
34
+ # Attribute type mapping.
35
+ def self.openapi_types
36
+ {
37
+ :'emails' => :'Array<String>'
38
+ }
39
+ end
40
+
41
+ # List of attributes with nullable: true
42
+ def self.openapi_nullable
43
+ Set.new([
44
+ ])
45
+ end
46
+
47
+ # Initializes the object
48
+ # @param [Hash] attributes Model attributes in the form of hash
49
+ def initialize(attributes = {})
50
+ if (!attributes.is_a?(Hash))
51
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::AllowEmail1` initialize method"
52
+ end
53
+
54
+ # check to see if the attribute exists and convert string to symbol for hash key
55
+ attributes = attributes.each_with_object({}) { |(k, v), h|
56
+ if (!self.class.attribute_map.key?(k.to_sym))
57
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::AllowEmail1`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
58
+ end
59
+ h[k.to_sym] = v
60
+ }
61
+
62
+ if attributes.key?(:'emails')
63
+ if (value = attributes[:'emails']).is_a?(Array)
64
+ self.emails = value
65
+ end
66
+ else
67
+ self.emails = nil
68
+ end
69
+ end
70
+
71
+ # Show invalid properties with the reasons. Usually used together with valid?
72
+ # @return Array for valid properties with the reasons
73
+ def list_invalid_properties
74
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
75
+ invalid_properties = Array.new
76
+ if @emails.nil?
77
+ invalid_properties.push('invalid value for "emails", emails cannot be nil.')
78
+ end
79
+
80
+ invalid_properties
81
+ end
82
+
83
+ # Check to see if the all the properties in the model are valid
84
+ # @return true if the model is valid
85
+ def valid?
86
+ warn '[DEPRECATED] the `valid?` method is obsolete'
87
+ return false if @emails.nil?
88
+ true
89
+ end
90
+
91
+ # Checks equality by comparing each attribute.
92
+ # @param [Object] Object to be compared
93
+ def ==(o)
94
+ return true if self.equal?(o)
95
+ self.class == o.class &&
96
+ emails == o.emails
97
+ end
98
+
99
+ # @see the `==` method
100
+ # @param [Object] Object to be compared
101
+ def eql?(o)
102
+ self == o
103
+ end
104
+
105
+ # Calculates hash code according to all attributes.
106
+ # @return [Integer] Hash code
107
+ def hash
108
+ [emails].hash
109
+ end
110
+
111
+ # Builds the object from hash
112
+ # @param [Hash] attributes Model attributes in the form of hash
113
+ # @return [Object] Returns the model itself
114
+ def self.build_from_hash(attributes)
115
+ return nil unless attributes.is_a?(Hash)
116
+ attributes = attributes.transform_keys(&:to_sym)
117
+ transformed_hash = {}
118
+ openapi_types.each_pair do |key, type|
119
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
120
+ transformed_hash["#{key}"] = nil
121
+ elsif type =~ /\AArray<(.*)>/i
122
+ # check to ensure the input is an array given that the attribute
123
+ # is documented as an array but the input is not
124
+ if attributes[attribute_map[key]].is_a?(Array)
125
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
126
+ end
127
+ elsif !attributes[attribute_map[key]].nil?
128
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
129
+ end
130
+ end
131
+ new(transformed_hash)
132
+ end
133
+
134
+ # Deserializes the data based on type
135
+ # @param string type Data type
136
+ # @param string value Value to be deserialized
137
+ # @return [Object] Deserialized data
138
+ def self._deserialize(type, value)
139
+ case type.to_sym
140
+ when :Time
141
+ Time.parse(value)
142
+ when :Date
143
+ Date.parse(value)
144
+ when :String
145
+ value.to_s
146
+ when :Integer
147
+ value.to_i
148
+ when :Float
149
+ value.to_f
150
+ when :Boolean
151
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
152
+ true
153
+ else
154
+ false
155
+ end
156
+ when :Object
157
+ # generic object (usually a Hash), return directly
158
+ value
159
+ when /\AArray<(?<inner_type>.+)>\z/
160
+ inner_type = Regexp.last_match[:inner_type]
161
+ value.map { |v| _deserialize(inner_type, v) }
162
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
163
+ k_type = Regexp.last_match[:k_type]
164
+ v_type = Regexp.last_match[:v_type]
165
+ {}.tap do |hash|
166
+ value.each do |k, v|
167
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
168
+ end
169
+ end
170
+ else # model
171
+ # models (e.g. Pet) or oneOf
172
+ klass = Tremendous.const_get(type)
173
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
174
+ end
175
+ end
176
+
177
+ # Returns the string representation of the object
178
+ # @return [String] String presentation of the object
179
+ def to_s
180
+ to_hash.to_s
181
+ end
182
+
183
+ # to_body is an alias to to_hash (backward compatibility)
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_body
186
+ to_hash
187
+ end
188
+
189
+ # Returns the object in the form of hash
190
+ # @return [Hash] Returns the object in the form of hash
191
+ def to_hash
192
+ hash = {}
193
+ self.class.attribute_map.each_pair do |attr, param|
194
+ value = self.send(attr)
195
+ if value.nil?
196
+ is_nullable = self.class.openapi_nullable.include?(attr)
197
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
198
+ end
199
+
200
+ hash[param] = _to_hash(value)
201
+ end
202
+ hash
203
+ end
204
+
205
+ # Outputs non-array value in the form of hash
206
+ # For object, use to_hash. Otherwise, just return the value
207
+ # @param [Object] value Any valid value
208
+ # @return [Hash] Returns the value in the form of hash
209
+ def _to_hash(value)
210
+ if value.is_a?(Array)
211
+ value.compact.map { |v| _to_hash(v) }
212
+ elsif value.is_a?(Hash)
213
+ {}.tap do |hash|
214
+ value.each { |k, v| hash[k] = _to_hash(v) }
215
+ end
216
+ elsif value.respond_to? :to_hash
217
+ value.to_hash
218
+ else
219
+ value
220
+ end
221
+ end
222
+
223
+ end
224
+
225
+ end