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,242 @@
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
+ # Breakdown of the order refunds (total amount in USD, independent from the currency of the ordered rewards). Note that this property will only appear for canceled orders or orders with canceled rewards.
18
+ class PaymentDetailsRefund
19
+ # Total amount of the order refunds (in USD)
20
+ attr_accessor :total
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'total' => :'total'
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
+ :'total' => :'Float'
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::PaymentDetailsRefund` 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::PaymentDetailsRefund`. 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?(:'total')
63
+ self.total = attributes[:'total']
64
+ else
65
+ self.total = nil
66
+ end
67
+ end
68
+
69
+ # Show invalid properties with the reasons. Usually used together with valid?
70
+ # @return Array for valid properties with the reasons
71
+ def list_invalid_properties
72
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
73
+ invalid_properties = Array.new
74
+ if @total.nil?
75
+ invalid_properties.push('invalid value for "total", total cannot be nil.')
76
+ end
77
+
78
+ if @total < 0
79
+ invalid_properties.push('invalid value for "total", must be greater than or equal to 0.')
80
+ end
81
+
82
+ invalid_properties
83
+ end
84
+
85
+ # Check to see if the all the properties in the model are valid
86
+ # @return true if the model is valid
87
+ def valid?
88
+ warn '[DEPRECATED] the `valid?` method is obsolete'
89
+ return false if @total.nil?
90
+ return false if @total < 0
91
+ true
92
+ end
93
+
94
+ # Custom attribute writer method with validation
95
+ # @param [Object] total Value to be assigned
96
+ def total=(total)
97
+ if total.nil?
98
+ fail ArgumentError, 'total cannot be nil'
99
+ end
100
+
101
+ if total < 0
102
+ fail ArgumentError, 'invalid value for "total", must be greater than or equal to 0.'
103
+ end
104
+
105
+ @total = total
106
+ end
107
+
108
+ # Checks equality by comparing each attribute.
109
+ # @param [Object] Object to be compared
110
+ def ==(o)
111
+ return true if self.equal?(o)
112
+ self.class == o.class &&
113
+ total == o.total
114
+ end
115
+
116
+ # @see the `==` method
117
+ # @param [Object] Object to be compared
118
+ def eql?(o)
119
+ self == o
120
+ end
121
+
122
+ # Calculates hash code according to all attributes.
123
+ # @return [Integer] Hash code
124
+ def hash
125
+ [total].hash
126
+ end
127
+
128
+ # Builds the object from hash
129
+ # @param [Hash] attributes Model attributes in the form of hash
130
+ # @return [Object] Returns the model itself
131
+ def self.build_from_hash(attributes)
132
+ return nil unless attributes.is_a?(Hash)
133
+ attributes = attributes.transform_keys(&:to_sym)
134
+ transformed_hash = {}
135
+ openapi_types.each_pair do |key, type|
136
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
137
+ transformed_hash["#{key}"] = nil
138
+ elsif type =~ /\AArray<(.*)>/i
139
+ # check to ensure the input is an array given that the attribute
140
+ # is documented as an array but the input is not
141
+ if attributes[attribute_map[key]].is_a?(Array)
142
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
143
+ end
144
+ elsif !attributes[attribute_map[key]].nil?
145
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
146
+ end
147
+ end
148
+ new(transformed_hash)
149
+ end
150
+
151
+ # Deserializes the data based on type
152
+ # @param string type Data type
153
+ # @param string value Value to be deserialized
154
+ # @return [Object] Deserialized data
155
+ def self._deserialize(type, value)
156
+ case type.to_sym
157
+ when :Time
158
+ Time.parse(value)
159
+ when :Date
160
+ Date.parse(value)
161
+ when :String
162
+ value.to_s
163
+ when :Integer
164
+ value.to_i
165
+ when :Float
166
+ value.to_f
167
+ when :Boolean
168
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
169
+ true
170
+ else
171
+ false
172
+ end
173
+ when :Object
174
+ # generic object (usually a Hash), return directly
175
+ value
176
+ when /\AArray<(?<inner_type>.+)>\z/
177
+ inner_type = Regexp.last_match[:inner_type]
178
+ value.map { |v| _deserialize(inner_type, v) }
179
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
180
+ k_type = Regexp.last_match[:k_type]
181
+ v_type = Regexp.last_match[:v_type]
182
+ {}.tap do |hash|
183
+ value.each do |k, v|
184
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
185
+ end
186
+ end
187
+ else # model
188
+ # models (e.g. Pet) or oneOf
189
+ klass = Tremendous.const_get(type)
190
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
191
+ end
192
+ end
193
+
194
+ # Returns the string representation of the object
195
+ # @return [String] String presentation of the object
196
+ def to_s
197
+ to_hash.to_s
198
+ end
199
+
200
+ # to_body is an alias to to_hash (backward compatibility)
201
+ # @return [Hash] Returns the object in the form of hash
202
+ def to_body
203
+ to_hash
204
+ end
205
+
206
+ # Returns the object in the form of hash
207
+ # @return [Hash] Returns the object in the form of hash
208
+ def to_hash
209
+ hash = {}
210
+ self.class.attribute_map.each_pair do |attr, param|
211
+ value = self.send(attr)
212
+ if value.nil?
213
+ is_nullable = self.class.openapi_nullable.include?(attr)
214
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
215
+ end
216
+
217
+ hash[param] = _to_hash(value)
218
+ end
219
+ hash
220
+ end
221
+
222
+ # Outputs non-array value in the form of hash
223
+ # For object, use to_hash. Otherwise, just return the value
224
+ # @param [Object] value Any valid value
225
+ # @return [Hash] Returns the value in the form of hash
226
+ def _to_hash(value)
227
+ if value.is_a?(Array)
228
+ value.compact.map { |v| _to_hash(v) }
229
+ elsif value.is_a?(Hash)
230
+ {}.tap do |hash|
231
+ value.each { |k, v| hash[k] = _to_hash(v) }
232
+ end
233
+ elsif value.respond_to? :to_hash
234
+ value.to_hash
235
+ else
236
+ value
237
+ end
238
+ end
239
+
240
+ end
241
+
242
+ end
@@ -0,0 +1,457 @@
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 product represents one way to payout a reward to it's recipient. Think: * Amazon.com gift card (ID: `OKMHM2X2OHYV`) * Donations to Save the Children (ID: `ESRNAD533W5A`) * Virtual Visa debit card (ID: `Q24BD9EZ332JT`) each of which is one specific product on Tremendous. > 📘 All available products > > See this [list](https://www.tremendous.com/catalog) Products can be limited in their availability to recipients by * geography (field `countries`) * currency (field `currencies`) * amount of the reward (field `skus`) * e.g. adidas gift cards accept any amount between 5 and 200 USD. See the description of each respective parameter for further details.
18
+ class Product
19
+ attr_accessor :id
20
+
21
+ # Name of the product
22
+ attr_accessor :name
23
+
24
+ # Detailed description of the product. Mostly used for products with a `category` of `charities`.
25
+ attr_accessor :description
26
+
27
+ # The category of this product <table> <thead> <tr> <th>Category</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code>ach</code></td> <td>Bank transfer to the recipient</td> </tr> <tr> <td><code>charity</code></td> <td>Donations to a charity</td> </tr> <tr> <td><code>merchant_card</code></td> <td>A gift card for a certain merchant (e.g. Amazon)</td> </tr> <tr> <td><code>paypal</code></td> <td>Payout via PayPal</td> </tr> <tr> <td><code>venmo</code></td> <td>Payout via Venmo</td> </tr> <tr> <td><code>visa_card</code></td> <td>Payout in form of a Visa debit card</td> </tr> </tbody> </table>
28
+ attr_accessor :category
29
+
30
+ # Legal disclosures for this product. Can be in HTML format.
31
+ attr_accessor :disclosure
32
+
33
+ # Products may are restricted in their usage based on the amount of the reward. The `skus` array defines bands of denominations in which this product may be used for payouts.
34
+ attr_accessor :skus
35
+
36
+ # Available currencies for this product
37
+ attr_accessor :currency_codes
38
+
39
+ # List of countries in which this product is available to recipients.
40
+ attr_accessor :countries
41
+
42
+ # List of product images associated with this product (e.g. logos or images of the gift cards)
43
+ attr_accessor :images
44
+
45
+ class EnumAttributeValidator
46
+ attr_reader :datatype
47
+ attr_reader :allowable_values
48
+
49
+ def initialize(datatype, allowable_values)
50
+ @allowable_values = allowable_values.map do |value|
51
+ case datatype.to_s
52
+ when /Integer/i
53
+ value.to_i
54
+ when /Float/i
55
+ value.to_f
56
+ else
57
+ value
58
+ end
59
+ end
60
+ end
61
+
62
+ def valid?(value)
63
+ !value || allowable_values.include?(value)
64
+ end
65
+ end
66
+
67
+ # Attribute mapping from ruby-style variable name to JSON key.
68
+ def self.attribute_map
69
+ {
70
+ :'id' => :'id',
71
+ :'name' => :'name',
72
+ :'description' => :'description',
73
+ :'category' => :'category',
74
+ :'disclosure' => :'disclosure',
75
+ :'skus' => :'skus',
76
+ :'currency_codes' => :'currency_codes',
77
+ :'countries' => :'countries',
78
+ :'images' => :'images'
79
+ }
80
+ end
81
+
82
+ # Returns all the JSON keys this model knows about
83
+ def self.acceptable_attributes
84
+ attribute_map.values
85
+ end
86
+
87
+ # Attribute type mapping.
88
+ def self.openapi_types
89
+ {
90
+ :'id' => :'String',
91
+ :'name' => :'String',
92
+ :'description' => :'String',
93
+ :'category' => :'String',
94
+ :'disclosure' => :'String',
95
+ :'skus' => :'Array<ListProductsResponseProductsInnerSkusInner>',
96
+ :'currency_codes' => :'Array<String>',
97
+ :'countries' => :'Array<ListProductsResponseProductsInnerCountriesInner>',
98
+ :'images' => :'Array<ListProductsResponseProductsInnerImagesInner>'
99
+ }
100
+ end
101
+
102
+ # List of attributes with nullable: true
103
+ def self.openapi_nullable
104
+ Set.new([
105
+ ])
106
+ end
107
+
108
+ # Initializes the object
109
+ # @param [Hash] attributes Model attributes in the form of hash
110
+ def initialize(attributes = {})
111
+ if (!attributes.is_a?(Hash))
112
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::Product` initialize method"
113
+ end
114
+
115
+ # check to see if the attribute exists and convert string to symbol for hash key
116
+ attributes = attributes.each_with_object({}) { |(k, v), h|
117
+ if (!self.class.attribute_map.key?(k.to_sym))
118
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::Product`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
119
+ end
120
+ h[k.to_sym] = v
121
+ }
122
+
123
+ if attributes.key?(:'id')
124
+ self.id = attributes[:'id']
125
+ else
126
+ self.id = nil
127
+ end
128
+
129
+ if attributes.key?(:'name')
130
+ self.name = attributes[:'name']
131
+ else
132
+ self.name = nil
133
+ end
134
+
135
+ if attributes.key?(:'description')
136
+ self.description = attributes[:'description']
137
+ else
138
+ self.description = nil
139
+ end
140
+
141
+ if attributes.key?(:'category')
142
+ self.category = attributes[:'category']
143
+ else
144
+ self.category = nil
145
+ end
146
+
147
+ if attributes.key?(:'disclosure')
148
+ self.disclosure = attributes[:'disclosure']
149
+ else
150
+ self.disclosure = nil
151
+ end
152
+
153
+ if attributes.key?(:'skus')
154
+ if (value = attributes[:'skus']).is_a?(Array)
155
+ self.skus = value
156
+ end
157
+ end
158
+
159
+ if attributes.key?(:'currency_codes')
160
+ if (value = attributes[:'currency_codes']).is_a?(Array)
161
+ self.currency_codes = value
162
+ end
163
+ else
164
+ self.currency_codes = nil
165
+ end
166
+
167
+ if attributes.key?(:'countries')
168
+ if (value = attributes[:'countries']).is_a?(Array)
169
+ self.countries = value
170
+ end
171
+ else
172
+ self.countries = nil
173
+ end
174
+
175
+ if attributes.key?(:'images')
176
+ if (value = attributes[:'images']).is_a?(Array)
177
+ self.images = value
178
+ end
179
+ else
180
+ self.images = nil
181
+ end
182
+ end
183
+
184
+ # Show invalid properties with the reasons. Usually used together with valid?
185
+ # @return Array for valid properties with the reasons
186
+ def list_invalid_properties
187
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
188
+ invalid_properties = Array.new
189
+ if @id.nil?
190
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
191
+ end
192
+
193
+ pattern = Regexp.new(/[A-Z0-9]{4,20}/)
194
+ if @id !~ pattern
195
+ invalid_properties.push("invalid value for \"id\", must conform to the pattern #{pattern}.")
196
+ end
197
+
198
+ if @name.nil?
199
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
200
+ end
201
+
202
+ if @description.nil?
203
+ invalid_properties.push('invalid value for "description", description cannot be nil.')
204
+ end
205
+
206
+ if @category.nil?
207
+ invalid_properties.push('invalid value for "category", category cannot be nil.')
208
+ end
209
+
210
+ if @disclosure.nil?
211
+ invalid_properties.push('invalid value for "disclosure", disclosure cannot be nil.')
212
+ end
213
+
214
+ if @currency_codes.nil?
215
+ invalid_properties.push('invalid value for "currency_codes", currency_codes cannot be nil.')
216
+ end
217
+
218
+ if @currency_codes.length < 1
219
+ invalid_properties.push('invalid value for "currency_codes", number of items must be greater than or equal to 1.')
220
+ end
221
+
222
+ if @countries.nil?
223
+ invalid_properties.push('invalid value for "countries", countries cannot be nil.')
224
+ end
225
+
226
+ if @countries.length < 1
227
+ invalid_properties.push('invalid value for "countries", number of items must be greater than or equal to 1.')
228
+ end
229
+
230
+ if @images.nil?
231
+ invalid_properties.push('invalid value for "images", images cannot be nil.')
232
+ end
233
+
234
+ if @images.length < 0
235
+ invalid_properties.push('invalid value for "images", number of items must be greater than or equal to 0.')
236
+ end
237
+
238
+ invalid_properties
239
+ end
240
+
241
+ # Check to see if the all the properties in the model are valid
242
+ # @return true if the model is valid
243
+ def valid?
244
+ warn '[DEPRECATED] the `valid?` method is obsolete'
245
+ return false if @id.nil?
246
+ return false if @id !~ Regexp.new(/[A-Z0-9]{4,20}/)
247
+ return false if @name.nil?
248
+ return false if @description.nil?
249
+ return false if @category.nil?
250
+ category_validator = EnumAttributeValidator.new('String', ["ach", "charity", "merchant_card", "paypal", "venmo", "visa_card"])
251
+ return false unless category_validator.valid?(@category)
252
+ return false if @disclosure.nil?
253
+ return false if @currency_codes.nil?
254
+ return false if @currency_codes.length < 1
255
+ return false if @countries.nil?
256
+ return false if @countries.length < 1
257
+ return false if @images.nil?
258
+ return false if @images.length < 0
259
+ true
260
+ end
261
+
262
+ # Custom attribute writer method with validation
263
+ # @param [Object] id Value to be assigned
264
+ def id=(id)
265
+ if id.nil?
266
+ fail ArgumentError, 'id cannot be nil'
267
+ end
268
+
269
+ pattern = Regexp.new(/[A-Z0-9]{4,20}/)
270
+ if id !~ pattern
271
+ fail ArgumentError, "invalid value for \"id\", must conform to the pattern #{pattern}."
272
+ end
273
+
274
+ @id = id
275
+ end
276
+
277
+ # Custom attribute writer method checking allowed values (enum).
278
+ # @param [Object] category Object to be assigned
279
+ def category=(category)
280
+ validator = EnumAttributeValidator.new('String', ["ach", "charity", "merchant_card", "paypal", "venmo", "visa_card"])
281
+ unless validator.valid?(category)
282
+ fail ArgumentError, "invalid value for \"category\", must be one of #{validator.allowable_values}."
283
+ end
284
+ @category = category
285
+ end
286
+
287
+ # Custom attribute writer method with validation
288
+ # @param [Object] countries Value to be assigned
289
+ def countries=(countries)
290
+ if countries.nil?
291
+ fail ArgumentError, 'countries cannot be nil'
292
+ end
293
+
294
+ if countries.length < 1
295
+ fail ArgumentError, 'invalid value for "countries", number of items must be greater than or equal to 1.'
296
+ end
297
+
298
+ @countries = countries
299
+ end
300
+
301
+ # Custom attribute writer method with validation
302
+ # @param [Object] images Value to be assigned
303
+ def images=(images)
304
+ if images.nil?
305
+ fail ArgumentError, 'images cannot be nil'
306
+ end
307
+
308
+ if images.length < 0
309
+ fail ArgumentError, 'invalid value for "images", number of items must be greater than or equal to 0.'
310
+ end
311
+
312
+ @images = images
313
+ end
314
+
315
+ # Checks equality by comparing each attribute.
316
+ # @param [Object] Object to be compared
317
+ def ==(o)
318
+ return true if self.equal?(o)
319
+ self.class == o.class &&
320
+ id == o.id &&
321
+ name == o.name &&
322
+ description == o.description &&
323
+ category == o.category &&
324
+ disclosure == o.disclosure &&
325
+ skus == o.skus &&
326
+ currency_codes == o.currency_codes &&
327
+ countries == o.countries &&
328
+ images == o.images
329
+ end
330
+
331
+ # @see the `==` method
332
+ # @param [Object] Object to be compared
333
+ def eql?(o)
334
+ self == o
335
+ end
336
+
337
+ # Calculates hash code according to all attributes.
338
+ # @return [Integer] Hash code
339
+ def hash
340
+ [id, name, description, category, disclosure, skus, currency_codes, countries, images].hash
341
+ end
342
+
343
+ # Builds the object from hash
344
+ # @param [Hash] attributes Model attributes in the form of hash
345
+ # @return [Object] Returns the model itself
346
+ def self.build_from_hash(attributes)
347
+ return nil unless attributes.is_a?(Hash)
348
+ attributes = attributes.transform_keys(&:to_sym)
349
+ transformed_hash = {}
350
+ openapi_types.each_pair do |key, type|
351
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
352
+ transformed_hash["#{key}"] = nil
353
+ elsif type =~ /\AArray<(.*)>/i
354
+ # check to ensure the input is an array given that the attribute
355
+ # is documented as an array but the input is not
356
+ if attributes[attribute_map[key]].is_a?(Array)
357
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
358
+ end
359
+ elsif !attributes[attribute_map[key]].nil?
360
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
361
+ end
362
+ end
363
+ new(transformed_hash)
364
+ end
365
+
366
+ # Deserializes the data based on type
367
+ # @param string type Data type
368
+ # @param string value Value to be deserialized
369
+ # @return [Object] Deserialized data
370
+ def self._deserialize(type, value)
371
+ case type.to_sym
372
+ when :Time
373
+ Time.parse(value)
374
+ when :Date
375
+ Date.parse(value)
376
+ when :String
377
+ value.to_s
378
+ when :Integer
379
+ value.to_i
380
+ when :Float
381
+ value.to_f
382
+ when :Boolean
383
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
384
+ true
385
+ else
386
+ false
387
+ end
388
+ when :Object
389
+ # generic object (usually a Hash), return directly
390
+ value
391
+ when /\AArray<(?<inner_type>.+)>\z/
392
+ inner_type = Regexp.last_match[:inner_type]
393
+ value.map { |v| _deserialize(inner_type, v) }
394
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
395
+ k_type = Regexp.last_match[:k_type]
396
+ v_type = Regexp.last_match[:v_type]
397
+ {}.tap do |hash|
398
+ value.each do |k, v|
399
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
400
+ end
401
+ end
402
+ else # model
403
+ # models (e.g. Pet) or oneOf
404
+ klass = Tremendous.const_get(type)
405
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
406
+ end
407
+ end
408
+
409
+ # Returns the string representation of the object
410
+ # @return [String] String presentation of the object
411
+ def to_s
412
+ to_hash.to_s
413
+ end
414
+
415
+ # to_body is an alias to to_hash (backward compatibility)
416
+ # @return [Hash] Returns the object in the form of hash
417
+ def to_body
418
+ to_hash
419
+ end
420
+
421
+ # Returns the object in the form of hash
422
+ # @return [Hash] Returns the object in the form of hash
423
+ def to_hash
424
+ hash = {}
425
+ self.class.attribute_map.each_pair do |attr, param|
426
+ value = self.send(attr)
427
+ if value.nil?
428
+ is_nullable = self.class.openapi_nullable.include?(attr)
429
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
430
+ end
431
+
432
+ hash[param] = _to_hash(value)
433
+ end
434
+ hash
435
+ end
436
+
437
+ # Outputs non-array value in the form of hash
438
+ # For object, use to_hash. Otherwise, just return the value
439
+ # @param [Object] value Any valid value
440
+ # @return [Hash] Returns the value in the form of hash
441
+ def _to_hash(value)
442
+ if value.is_a?(Array)
443
+ value.compact.map { |v| _to_hash(v) }
444
+ elsif value.is_a?(Hash)
445
+ {}.tap do |hash|
446
+ value.each { |k, v| hash[k] = _to_hash(v) }
447
+ end
448
+ elsif value.respond_to? :to_hash
449
+ value.to_hash
450
+ else
451
+ value
452
+ end
453
+ end
454
+
455
+ end
456
+
457
+ end