tremendous_ruby 5.0.0 → 5.0.1

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 (141) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tremendous/api/tremendous_api.rb +2365 -0
  3. data/lib/tremendous/api_client.rb +431 -0
  4. data/lib/tremendous/api_error.rb +58 -0
  5. data/lib/tremendous/configuration.rb +389 -0
  6. data/lib/tremendous/models/balance_transaction.rb +256 -0
  7. data/lib/tremendous/models/campaign.rb +292 -0
  8. data/lib/tremendous/models/create_api_key200_response.rb +215 -0
  9. data/lib/tremendous/models/create_invoice.rb +244 -0
  10. data/lib/tremendous/models/create_invoice200_response.rb +221 -0
  11. data/lib/tremendous/models/create_invoice_request.rb +244 -0
  12. data/lib/tremendous/models/create_member.rb +290 -0
  13. data/lib/tremendous/models/create_member200_response.rb +221 -0
  14. data/lib/tremendous/models/create_member_request.rb +290 -0
  15. data/lib/tremendous/models/create_order200_response.rb +221 -0
  16. data/lib/tremendous/models/create_order200_response_order.rb +400 -0
  17. data/lib/tremendous/models/create_order200_response_order_rewards_inner.rb +347 -0
  18. data/lib/tremendous/models/create_order200_response_order_rewards_inner_delivery.rb +296 -0
  19. data/lib/tremendous/models/create_order201_response.rb +221 -0
  20. data/lib/tremendous/models/create_order_request.rb +248 -0
  21. data/lib/tremendous/models/create_order_request_payment.rb +222 -0
  22. data/lib/tremendous/models/create_order_request_reward.rb +344 -0
  23. data/lib/tremendous/models/create_order_request_reward_delivery.rb +250 -0
  24. data/lib/tremendous/models/create_organization.rb +268 -0
  25. data/lib/tremendous/models/create_organization200_response.rb +214 -0
  26. data/lib/tremendous/models/create_organization200_response_organization.rb +334 -0
  27. data/lib/tremendous/models/create_organization_request.rb +268 -0
  28. data/lib/tremendous/models/create_organization_request_copy_settings.rb +278 -0
  29. data/lib/tremendous/models/create_webhook200_response.rb +214 -0
  30. data/lib/tremendous/models/create_webhook_request.rb +222 -0
  31. data/lib/tremendous/models/currency_codes.rb +154 -0
  32. data/lib/tremendous/models/custom_field.rb +248 -0
  33. data/lib/tremendous/models/delivery_details.rb +286 -0
  34. data/lib/tremendous/models/delivery_details_with_link.rb +296 -0
  35. data/lib/tremendous/models/delivery_method.rb +41 -0
  36. data/lib/tremendous/models/delivery_status.rb +42 -0
  37. data/lib/tremendous/models/error_model.rb +221 -0
  38. data/lib/tremendous/models/field.rb +286 -0
  39. data/lib/tremendous/models/funding_source.rb +332 -0
  40. data/lib/tremendous/models/generate_reward_link200_response.rb +221 -0
  41. data/lib/tremendous/models/generate_reward_link200_response_reward.rb +247 -0
  42. data/lib/tremendous/models/generate_reward_link403_response.rb +221 -0
  43. data/lib/tremendous/models/generate_reward_token200_response.rb +221 -0
  44. data/lib/tremendous/models/generate_reward_token200_response_reward.rb +257 -0
  45. data/lib/tremendous/models/get_campaign200_response.rb +221 -0
  46. data/lib/tremendous/models/get_funding_source200_response.rb +221 -0
  47. data/lib/tremendous/models/get_member200_response.rb +221 -0
  48. data/lib/tremendous/models/get_member200_response_member.rb +365 -0
  49. data/lib/tremendous/models/get_member200_response_member_events_inner.rb +260 -0
  50. data/lib/tremendous/models/get_organization200_response.rb +214 -0
  51. data/lib/tremendous/models/get_product200_response.rb +221 -0
  52. data/lib/tremendous/models/get_product_response.rb +221 -0
  53. data/lib/tremendous/models/get_reward200_response.rb +221 -0
  54. data/lib/tremendous/models/invoice.rb +356 -0
  55. data/lib/tremendous/models/list_balance_transactions200_response.rb +216 -0
  56. data/lib/tremendous/models/list_balance_transactions200_response_invoices_inner.rb +256 -0
  57. data/lib/tremendous/models/list_campaigns200_response.rb +223 -0
  58. data/lib/tremendous/models/list_campaigns200_response_campaigns_inner.rb +292 -0
  59. data/lib/tremendous/models/list_fields200_response.rb +216 -0
  60. data/lib/tremendous/models/list_fields200_response_fields_inner.rb +286 -0
  61. data/lib/tremendous/models/list_funding_sources200_response.rb +223 -0
  62. data/lib/tremendous/models/list_funding_sources200_response_funding_sources_inner.rb +332 -0
  63. data/lib/tremendous/models/list_funding_sources200_response_funding_sources_inner_meta.rb +436 -0
  64. data/lib/tremendous/models/list_invoices200_response.rb +240 -0
  65. data/lib/tremendous/models/list_invoices200_response_invoices_inner.rb +356 -0
  66. data/lib/tremendous/models/list_members200_response.rb +223 -0
  67. data/lib/tremendous/models/list_members200_response_members_inner.rb +374 -0
  68. data/lib/tremendous/models/list_orders200_response.rb +240 -0
  69. data/lib/tremendous/models/list_orders200_response_orders_inner.rb +379 -0
  70. data/lib/tremendous/models/list_orders200_response_orders_inner_payment.rb +346 -0
  71. data/lib/tremendous/models/list_orders200_response_orders_inner_payment_refund.rb +242 -0
  72. data/lib/tremendous/models/list_organizations200_response.rb +216 -0
  73. data/lib/tremendous/models/list_organizations200_response_organizations_inner.rb +324 -0
  74. data/lib/tremendous/models/list_products200_response.rb +223 -0
  75. data/lib/tremendous/models/list_products200_response_products_inner.rb +457 -0
  76. data/lib/tremendous/models/list_products200_response_products_inner_countries_inner.rb +222 -0
  77. data/lib/tremendous/models/list_products200_response_products_inner_images_inner.rb +273 -0
  78. data/lib/tremendous/models/list_products200_response_products_inner_skus_inner.rb +277 -0
  79. data/lib/tremendous/models/list_products_response.rb +223 -0
  80. data/lib/tremendous/models/list_products_response_products_inner.rb +457 -0
  81. data/lib/tremendous/models/list_products_response_products_inner_countries_inner.rb +222 -0
  82. data/lib/tremendous/models/list_products_response_products_inner_images_inner.rb +273 -0
  83. data/lib/tremendous/models/list_products_response_products_inner_skus_inner.rb +277 -0
  84. data/lib/tremendous/models/list_rewards200_response.rb +226 -0
  85. data/lib/tremendous/models/list_rewards200_response_rewards_inner.rb +347 -0
  86. data/lib/tremendous/models/list_rewards200_response_rewards_inner_custom_fields_inner.rb +248 -0
  87. data/lib/tremendous/models/list_rewards200_response_rewards_inner_delivery.rb +286 -0
  88. data/lib/tremendous/models/list_rewards200_response_rewards_inner_recipient.rb +236 -0
  89. data/lib/tremendous/models/list_rewards200_response_rewards_inner_value.rb +273 -0
  90. data/lib/tremendous/models/list_rewards401_response.rb +221 -0
  91. data/lib/tremendous/models/list_rewards401_response_errors.rb +225 -0
  92. data/lib/tremendous/models/list_rewards429_response.rb +221 -0
  93. data/lib/tremendous/models/list_webhook_events200_response.rb +216 -0
  94. data/lib/tremendous/models/list_webhooks200_response.rb +216 -0
  95. data/lib/tremendous/models/list_webhooks200_response_webhooks_inner.rb +258 -0
  96. data/lib/tremendous/models/member.rb +374 -0
  97. data/lib/tremendous/models/member_base.rb +353 -0
  98. data/lib/tremendous/models/member_with_events.rb +365 -0
  99. data/lib/tremendous/models/member_without_events.rb +374 -0
  100. data/lib/tremendous/models/order.rb +379 -0
  101. data/lib/tremendous/models/order_base.rb +370 -0
  102. data/lib/tremendous/models/order_base_payment.rb +346 -0
  103. data/lib/tremendous/models/order_for_create.rb +248 -0
  104. data/lib/tremendous/models/order_for_create_reward.rb +416 -0
  105. data/lib/tremendous/models/order_status.rb +44 -0
  106. data/lib/tremendous/models/order_with_link.rb +400 -0
  107. data/lib/tremendous/models/order_with_link_rewards_inner.rb +406 -0
  108. data/lib/tremendous/models/order_without_link.rb +379 -0
  109. data/lib/tremendous/models/order_without_link_reward.rb +406 -0
  110. data/lib/tremendous/models/organization.rb +324 -0
  111. data/lib/tremendous/models/payment_details.rb +345 -0
  112. data/lib/tremendous/models/payment_details_refund.rb +242 -0
  113. data/lib/tremendous/models/product.rb +457 -0
  114. data/lib/tremendous/models/recipient.rb +236 -0
  115. data/lib/tremendous/models/refund_details.rb +241 -0
  116. data/lib/tremendous/models/resend_reward422_response.rb +221 -0
  117. data/lib/tremendous/models/reward.rb +406 -0
  118. data/lib/tremendous/models/reward_base.rb +397 -0
  119. data/lib/tremendous/models/reward_base_custom_fields_inner.rb +248 -0
  120. data/lib/tremendous/models/reward_for_order_create.rb +416 -0
  121. data/lib/tremendous/models/reward_link.rb +247 -0
  122. data/lib/tremendous/models/reward_token.rb +257 -0
  123. data/lib/tremendous/models/reward_value.rb +273 -0
  124. data/lib/tremendous/models/reward_with_link.rb +406 -0
  125. data/lib/tremendous/models/reward_with_link_delivery.rb +296 -0
  126. data/lib/tremendous/models/reward_without_link.rb +406 -0
  127. data/lib/tremendous/models/reward_without_link_delivery.rb +286 -0
  128. data/lib/tremendous/models/simulate_webhook_request.rb +222 -0
  129. data/lib/tremendous/models/webhook.rb +258 -0
  130. data/lib/tremendous/models/webhook_post.rb +222 -0
  131. data/lib/tremendous/version.rb +3 -0
  132. data/lib/tremendous.rb +159 -0
  133. metadata +133 -10
  134. data/spec/integration/campaigns_spec.rb +0 -27
  135. data/spec/integration/funding_sources_spec.rb +0 -18
  136. data/spec/integration/invoices_spec.rb +0 -19
  137. data/spec/integration/members_spec.rb +0 -19
  138. data/spec/integration/orders_spec.rb +0 -53
  139. data/spec/integration/products_spec.rb +0 -26
  140. data/spec/spec_helper.rb +0 -111
  141. data/spec/support/setup.rb +0 -10
@@ -0,0 +1,389 @@
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
+ module Tremendous
14
+ class Configuration
15
+ # Tremendous Environment mapping
16
+ Environment = { "testflight" => 0, "production" => 1 }
17
+
18
+ # Defines url scheme
19
+ attr_accessor :scheme
20
+
21
+ # Defines url host
22
+ attr_accessor :host
23
+
24
+ # Defines url base path
25
+ attr_accessor :base_path
26
+
27
+ # Define server configuration index
28
+ attr_accessor :server_index
29
+
30
+ # Define server operation configuration index
31
+ attr_accessor :server_operation_index
32
+
33
+ # Default server variables
34
+ attr_accessor :server_variables
35
+
36
+ # Default server operation variables
37
+ attr_accessor :server_operation_variables
38
+
39
+ # Defines API keys used with API Key authentications.
40
+ #
41
+ # @return [Hash] key: parameter name, value: parameter value (API key)
42
+ #
43
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
44
+ # config.api_key['api_key'] = 'xxx'
45
+ attr_accessor :api_key
46
+
47
+ # Defines API key prefixes used with API Key authentications.
48
+ #
49
+ # @return [Hash] key: parameter name, value: API key prefix
50
+ #
51
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
52
+ # config.api_key_prefix['api_key'] = 'Token'
53
+ attr_accessor :api_key_prefix
54
+
55
+ # Defines the username used with HTTP basic authentication.
56
+ #
57
+ # @return [String]
58
+ attr_accessor :username
59
+
60
+ # Defines the password used with HTTP basic authentication.
61
+ #
62
+ # @return [String]
63
+ attr_accessor :password
64
+
65
+ # Defines the access token (Bearer) used with OAuth2.
66
+ attr_accessor :access_token
67
+
68
+ # Defines a Proc used to fetch or refresh access tokens (Bearer) used with OAuth2.
69
+ # Overrides the access_token if set
70
+ # @return [Proc]
71
+ attr_accessor :access_token_getter
72
+
73
+ # Set this to return data as binary instead of downloading a temp file. When enabled (set to true)
74
+ # HTTP responses with return type `File` will be returned as a stream of binary data.
75
+ # Default to false.
76
+ attr_accessor :return_binary_data
77
+
78
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
79
+ # details will be logged with `logger.debug` (see the `logger` attribute).
80
+ # Default to false.
81
+ #
82
+ # @return [true, false]
83
+ attr_accessor :debugging
84
+
85
+ # Defines the logger used for debugging.
86
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
87
+ #
88
+ # @return [#debug]
89
+ attr_accessor :logger
90
+
91
+ # Defines the temporary folder to store downloaded files
92
+ # (for API endpoints that have file response).
93
+ # Default to use `Tempfile`.
94
+ #
95
+ # @return [String]
96
+ attr_accessor :temp_folder_path
97
+
98
+ # The time limit for HTTP request in seconds.
99
+ # Default to 0 (never times out).
100
+ attr_accessor :timeout
101
+
102
+ # Set this to false to skip client side validation in the operation.
103
+ # Default to true.
104
+ # @return [true, false]
105
+ attr_accessor :client_side_validation
106
+
107
+ ### TLS/SSL setting
108
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
109
+ # Default to true.
110
+ #
111
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
112
+ #
113
+ # @return [true, false]
114
+ attr_accessor :ssl_verify
115
+
116
+ ### TLS/SSL setting
117
+ # Any `OpenSSL::SSL::` constant (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL.html)
118
+ #
119
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
120
+ #
121
+ attr_accessor :ssl_verify_mode
122
+
123
+ ### TLS/SSL setting
124
+ # Set this to customize the certificate file to verify the peer.
125
+ #
126
+ # @return [String] the path to the certificate file
127
+ attr_accessor :ssl_ca_file
128
+
129
+ ### TLS/SSL setting
130
+ # Client certificate file (for client certificate)
131
+ attr_accessor :ssl_client_cert
132
+
133
+ ### TLS/SSL setting
134
+ # Client private key file (for client certificate)
135
+ attr_accessor :ssl_client_key
136
+
137
+ ### Proxy setting
138
+ # HTTP Proxy settings
139
+ attr_accessor :proxy
140
+
141
+ # Set this to customize parameters encoder of array parameter.
142
+ # Default to nil. Faraday uses NestedParamsEncoder when nil.
143
+ #
144
+ # @see The params_encoder option of Faraday. Related source code:
145
+ # https://github.com/lostisland/faraday/tree/main/lib/faraday/encoders
146
+ attr_accessor :params_encoder
147
+
148
+
149
+ attr_accessor :inject_format
150
+
151
+ attr_accessor :force_ending_format
152
+
153
+ def initialize
154
+ @scheme = 'https'
155
+ @host = 'testflight.tremendous.com'
156
+ @base_path = '/api/v2'
157
+ @server_index = nil
158
+ @server_operation_index = {}
159
+ @server_variables = {}
160
+ @server_operation_variables = {}
161
+ @api_key = {}
162
+ @api_key_prefix = {}
163
+ @client_side_validation = true
164
+ @ssl_verify = true
165
+ @ssl_verify_mode = nil
166
+ @ssl_ca_file = nil
167
+ @ssl_client_cert = nil
168
+ @ssl_client_key = nil
169
+ @middlewares = Hash.new { |h, k| h[k] = [] }
170
+ @configure_connection_blocks = []
171
+ @timeout = 60
172
+ # return data as binary instead of file
173
+ @return_binary_data = false
174
+ @params_encoder = nil
175
+ @debugging = false
176
+ @inject_format = false
177
+ @force_ending_format = false
178
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
179
+
180
+ yield(self) if block_given?
181
+ end
182
+
183
+ # The default Configuration object.
184
+ def self.default
185
+ @@default ||= Configuration.new
186
+ end
187
+
188
+ def configure
189
+ yield(self) if block_given?
190
+ end
191
+
192
+ def scheme=(scheme)
193
+ # remove :// from scheme
194
+ @scheme = scheme.sub(/:\/\//, '')
195
+ end
196
+
197
+ def host=(host)
198
+ # remove http(s):// and anything after a slash
199
+ @host = host.sub(/https?:\/\//, '').split('/').first
200
+ end
201
+
202
+ def base_path=(base_path)
203
+ # Add leading and trailing slashes to base_path
204
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
205
+ @base_path = '' if @base_path == '/'
206
+ end
207
+
208
+ # Returns base URL for specified operation based on server settings
209
+ def base_url(operation = nil)
210
+ if operation_server_settings.key?(operation) then
211
+ index = server_operation_index.fetch(operation, server_index)
212
+ server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
213
+ else
214
+ server_index.nil? ? "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') : server_url(server_index, server_variables, nil)
215
+ end
216
+ end
217
+
218
+ # Gets API key (with prefix if set).
219
+ # @param [String] param_name the parameter name of API key auth
220
+ def api_key_with_prefix(param_name, param_alias = nil)
221
+ key = @api_key[param_name]
222
+ key = @api_key.fetch(param_alias, key) unless param_alias.nil?
223
+ if @api_key_prefix[param_name]
224
+ "#{@api_key_prefix[param_name]} #{key}"
225
+ else
226
+ key
227
+ end
228
+ end
229
+
230
+ # Gets access_token using access_token_getter or uses the static access_token
231
+ def access_token_with_refresh
232
+ return access_token if access_token_getter.nil?
233
+ access_token_getter.call
234
+ end
235
+
236
+ # Gets Basic Auth token string
237
+ def basic_auth_token
238
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
239
+ end
240
+
241
+ # Returns Auth Settings hash for api client.
242
+ def auth_settings
243
+ {
244
+ 'BearerApiKey' =>
245
+ {
246
+ type: 'bearer',
247
+ in: 'header',
248
+ key: 'Authorization',
249
+ value: "Bearer #{access_token_with_refresh}"
250
+ },
251
+ }
252
+ end
253
+
254
+ # Returns an array of Server setting
255
+ def server_settings
256
+ [
257
+ {
258
+ url: "https://testflight.tremendous.com/api/v2",
259
+ description: "Sandbox environment",
260
+ },
261
+ {
262
+ url: "https://www.tremendous.com/api/v2",
263
+ description: "Production environment",
264
+ }
265
+ ]
266
+ end
267
+
268
+ def operation_server_settings
269
+ {
270
+ }
271
+ end
272
+
273
+ # Returns URL based on server settings
274
+ #
275
+ # @param index array index of the server settings
276
+ # @param variables hash of variable and the corresponding value
277
+ def server_url(index, variables = {}, servers = nil)
278
+ servers = server_settings if servers == nil
279
+
280
+ # check array index out of bound
281
+ if (index.nil? || index < 0 || index >= servers.size)
282
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must not be nil and must be less than #{servers.size}"
283
+ end
284
+
285
+ server = servers[index]
286
+ url = server[:url]
287
+
288
+ return url unless server.key? :variables
289
+
290
+ # go through variable and assign a value
291
+ server[:variables].each do |name, variable|
292
+ if variables.key?(name)
293
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
294
+ url.gsub! "{" + name.to_s + "}", variables[name]
295
+ else
296
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
297
+ end
298
+ else
299
+ # use default value
300
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
301
+ end
302
+ end
303
+
304
+ url
305
+ end
306
+
307
+ # Configure Faraday connection directly.
308
+ #
309
+ # ```
310
+ # c.configure_faraday_connection do |conn|
311
+ # conn.use Faraday::HttpCache, shared_cache: false, logger: logger
312
+ # conn.response :logger, nil, headers: true, bodies: true, log_level: :debug do |logger|
313
+ # logger.filter(/(Authorization: )(.*)/, '\1[REDACTED]')
314
+ # end
315
+ # end
316
+ #
317
+ # c.configure_faraday_connection do |conn|
318
+ # conn.adapter :typhoeus
319
+ # end
320
+ # ```
321
+ #
322
+ # @param block [Proc] `#call`able object that takes one arg, the connection
323
+ def configure_faraday_connection(&block)
324
+ @configure_connection_blocks << block
325
+ end
326
+
327
+ def configure_connection(conn)
328
+ @configure_connection_blocks.each do |block|
329
+ block.call(conn)
330
+ end
331
+ end
332
+
333
+ # Adds middleware to the stack
334
+ def use(*middleware)
335
+ set_faraday_middleware(:use, *middleware)
336
+ end
337
+
338
+ # Adds request middleware to the stack
339
+ def request(*middleware)
340
+ set_faraday_middleware(:request, *middleware)
341
+ end
342
+
343
+ # Adds response middleware to the stack
344
+ def response(*middleware)
345
+ set_faraday_middleware(:response, *middleware)
346
+ end
347
+
348
+ # Adds Faraday middleware setting information to the stack
349
+ #
350
+ # @example Use the `set_faraday_middleware` method to set middleware information
351
+ # config.set_faraday_middleware(:request, :retry, max: 3, methods: [:get, :post], retry_statuses: [503])
352
+ # config.set_faraday_middleware(:response, :logger, nil, { bodies: true, log_level: :debug })
353
+ # config.set_faraday_middleware(:use, Faraday::HttpCache, store: Rails.cache, shared_cache: false)
354
+ # config.set_faraday_middleware(:insert, 0, FaradayMiddleware::FollowRedirects, { standards_compliant: true, limit: 1 })
355
+ # config.set_faraday_middleware(:swap, 0, Faraday::Response::Logger)
356
+ # config.set_faraday_middleware(:delete, Faraday::Multipart::Middleware)
357
+ #
358
+ # @see https://github.com/lostisland/faraday/blob/v2.3.0/lib/faraday/rack_builder.rb#L92-L143
359
+ def set_faraday_middleware(operation, key, *args, &block)
360
+ unless [:request, :response, :use, :insert, :insert_before, :insert_after, :swap, :delete].include?(operation)
361
+ fail ArgumentError, "Invalid faraday middleware operation #{operation}. Must be" \
362
+ " :request, :response, :use, :insert, :insert_before, :insert_after, :swap or :delete."
363
+ end
364
+
365
+ @middlewares[operation] << [key, args, block]
366
+ end
367
+ ruby2_keywords(:set_faraday_middleware) if respond_to?(:ruby2_keywords, true)
368
+
369
+ # Set up middleware on the connection
370
+ def configure_middleware(connection)
371
+ return if @middlewares.empty?
372
+
373
+ [:request, :response, :use, :insert, :insert_before, :insert_after, :swap].each do |operation|
374
+ next unless @middlewares.key?(operation)
375
+
376
+ @middlewares[operation].each do |key, args, block|
377
+ connection.builder.send(operation, key, *args, &block)
378
+ end
379
+ end
380
+
381
+ if @middlewares.key?(:delete)
382
+ @middlewares[:delete].each do |key, _args, _block|
383
+ connection.builder.delete(key)
384
+ end
385
+ end
386
+ end
387
+
388
+ end
389
+ end
@@ -0,0 +1,256 @@
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
+ # A balance transaction represents a specific movement or change in an account's balance.
18
+ class BalanceTransaction
19
+ # Date that the transaction was created
20
+ attr_accessor :created_at
21
+
22
+ # Amount of the transaction in USD
23
+ attr_accessor :amount
24
+
25
+ # The updated total after the transaction. Note that this running balance may be delayed and contain `null`.
26
+ attr_accessor :balance
27
+
28
+ # The action that was performed
29
+ attr_accessor :action
30
+
31
+ # A brief description of the transaction
32
+ attr_accessor :description
33
+
34
+ # Attribute mapping from ruby-style variable name to JSON key.
35
+ def self.attribute_map
36
+ {
37
+ :'created_at' => :'created_at',
38
+ :'amount' => :'amount',
39
+ :'balance' => :'balance',
40
+ :'action' => :'action',
41
+ :'description' => :'description'
42
+ }
43
+ end
44
+
45
+ # Returns all the JSON keys this model knows about
46
+ def self.acceptable_attributes
47
+ attribute_map.values
48
+ end
49
+
50
+ # Attribute type mapping.
51
+ def self.openapi_types
52
+ {
53
+ :'created_at' => :'Date',
54
+ :'amount' => :'Float',
55
+ :'balance' => :'Float',
56
+ :'action' => :'String',
57
+ :'description' => :'String'
58
+ }
59
+ end
60
+
61
+ # List of attributes with nullable: true
62
+ def self.openapi_nullable
63
+ Set.new([
64
+ ])
65
+ end
66
+
67
+ # Initializes the object
68
+ # @param [Hash] attributes Model attributes in the form of hash
69
+ def initialize(attributes = {})
70
+ if (!attributes.is_a?(Hash))
71
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::BalanceTransaction` initialize method"
72
+ end
73
+
74
+ # check to see if the attribute exists and convert string to symbol for hash key
75
+ attributes = attributes.each_with_object({}) { |(k, v), h|
76
+ if (!self.class.attribute_map.key?(k.to_sym))
77
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::BalanceTransaction`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
78
+ end
79
+ h[k.to_sym] = v
80
+ }
81
+
82
+ if attributes.key?(:'created_at')
83
+ self.created_at = attributes[:'created_at']
84
+ end
85
+
86
+ if attributes.key?(:'amount')
87
+ self.amount = attributes[:'amount']
88
+ end
89
+
90
+ if attributes.key?(:'balance')
91
+ self.balance = attributes[:'balance']
92
+ end
93
+
94
+ if attributes.key?(:'action')
95
+ self.action = attributes[:'action']
96
+ end
97
+
98
+ if attributes.key?(:'description')
99
+ self.description = attributes[:'description']
100
+ end
101
+ end
102
+
103
+ # Show invalid properties with the reasons. Usually used together with valid?
104
+ # @return Array for valid properties with the reasons
105
+ def list_invalid_properties
106
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
107
+ invalid_properties = Array.new
108
+ invalid_properties
109
+ end
110
+
111
+ # Check to see if the all the properties in the model are valid
112
+ # @return true if the model is valid
113
+ def valid?
114
+ warn '[DEPRECATED] the `valid?` method is obsolete'
115
+ true
116
+ end
117
+
118
+ # Checks equality by comparing each attribute.
119
+ # @param [Object] Object to be compared
120
+ def ==(o)
121
+ return true if self.equal?(o)
122
+ self.class == o.class &&
123
+ created_at == o.created_at &&
124
+ amount == o.amount &&
125
+ balance == o.balance &&
126
+ action == o.action &&
127
+ description == o.description
128
+ end
129
+
130
+ # @see the `==` method
131
+ # @param [Object] Object to be compared
132
+ def eql?(o)
133
+ self == o
134
+ end
135
+
136
+ # Calculates hash code according to all attributes.
137
+ # @return [Integer] Hash code
138
+ def hash
139
+ [created_at, amount, balance, action, description].hash
140
+ end
141
+
142
+ # Builds the object from hash
143
+ # @param [Hash] attributes Model attributes in the form of hash
144
+ # @return [Object] Returns the model itself
145
+ def self.build_from_hash(attributes)
146
+ return nil unless attributes.is_a?(Hash)
147
+ attributes = attributes.transform_keys(&:to_sym)
148
+ transformed_hash = {}
149
+ openapi_types.each_pair do |key, type|
150
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
151
+ transformed_hash["#{key}"] = nil
152
+ elsif type =~ /\AArray<(.*)>/i
153
+ # check to ensure the input is an array given that the attribute
154
+ # is documented as an array but the input is not
155
+ if attributes[attribute_map[key]].is_a?(Array)
156
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
157
+ end
158
+ elsif !attributes[attribute_map[key]].nil?
159
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
160
+ end
161
+ end
162
+ new(transformed_hash)
163
+ end
164
+
165
+ # Deserializes the data based on type
166
+ # @param string type Data type
167
+ # @param string value Value to be deserialized
168
+ # @return [Object] Deserialized data
169
+ def self._deserialize(type, value)
170
+ case type.to_sym
171
+ when :Time
172
+ Time.parse(value)
173
+ when :Date
174
+ Date.parse(value)
175
+ when :String
176
+ value.to_s
177
+ when :Integer
178
+ value.to_i
179
+ when :Float
180
+ value.to_f
181
+ when :Boolean
182
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
183
+ true
184
+ else
185
+ false
186
+ end
187
+ when :Object
188
+ # generic object (usually a Hash), return directly
189
+ value
190
+ when /\AArray<(?<inner_type>.+)>\z/
191
+ inner_type = Regexp.last_match[:inner_type]
192
+ value.map { |v| _deserialize(inner_type, v) }
193
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
194
+ k_type = Regexp.last_match[:k_type]
195
+ v_type = Regexp.last_match[:v_type]
196
+ {}.tap do |hash|
197
+ value.each do |k, v|
198
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
199
+ end
200
+ end
201
+ else # model
202
+ # models (e.g. Pet) or oneOf
203
+ klass = Tremendous.const_get(type)
204
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
205
+ end
206
+ end
207
+
208
+ # Returns the string representation of the object
209
+ # @return [String] String presentation of the object
210
+ def to_s
211
+ to_hash.to_s
212
+ end
213
+
214
+ # to_body is an alias to to_hash (backward compatibility)
215
+ # @return [Hash] Returns the object in the form of hash
216
+ def to_body
217
+ to_hash
218
+ end
219
+
220
+ # Returns the object in the form of hash
221
+ # @return [Hash] Returns the object in the form of hash
222
+ def to_hash
223
+ hash = {}
224
+ self.class.attribute_map.each_pair do |attr, param|
225
+ value = self.send(attr)
226
+ if value.nil?
227
+ is_nullable = self.class.openapi_nullable.include?(attr)
228
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
229
+ end
230
+
231
+ hash[param] = _to_hash(value)
232
+ end
233
+ hash
234
+ end
235
+
236
+ # Outputs non-array value in the form of hash
237
+ # For object, use to_hash. Otherwise, just return the value
238
+ # @param [Object] value Any valid value
239
+ # @return [Hash] Returns the value in the form of hash
240
+ def _to_hash(value)
241
+ if value.is_a?(Array)
242
+ value.compact.map { |v| _to_hash(v) }
243
+ elsif value.is_a?(Hash)
244
+ {}.tap do |hash|
245
+ value.each { |k, v| hash[k] = _to_hash(v) }
246
+ end
247
+ elsif value.respond_to? :to_hash
248
+ value.to_hash
249
+ else
250
+ value
251
+ end
252
+ end
253
+
254
+ end
255
+
256
+ end