tremendous_ruby 5.0.0 → 5.1.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 (139) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tremendous/api/tremendous_api.rb +2508 -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 +303 -0
  8. data/lib/tremendous/models/create_api_key200_response.rb +215 -0
  9. data/lib/tremendous/models/create_campaign201_response.rb +221 -0
  10. data/lib/tremendous/models/create_campaign_request.rb +273 -0
  11. data/lib/tremendous/models/create_invoice.rb +244 -0
  12. data/lib/tremendous/models/create_invoice200_response.rb +221 -0
  13. data/lib/tremendous/models/create_invoice_request.rb +244 -0
  14. data/lib/tremendous/models/create_member.rb +273 -0
  15. data/lib/tremendous/models/create_member200_response.rb +221 -0
  16. data/lib/tremendous/models/create_member_request.rb +273 -0
  17. data/lib/tremendous/models/create_order200_response.rb +221 -0
  18. data/lib/tremendous/models/create_order200_response_order.rb +400 -0
  19. data/lib/tremendous/models/create_order200_response_order_rewards_inner.rb +347 -0
  20. data/lib/tremendous/models/create_order200_response_order_rewards_inner_delivery.rb +296 -0
  21. data/lib/tremendous/models/create_order201_response.rb +221 -0
  22. data/lib/tremendous/models/create_order_request.rb +248 -0
  23. data/lib/tremendous/models/create_order_request_payment.rb +222 -0
  24. data/lib/tremendous/models/create_order_request_reward.rb +344 -0
  25. data/lib/tremendous/models/create_order_request_reward_custom_fields_inner.rb +248 -0
  26. data/lib/tremendous/models/create_order_request_reward_delivery.rb +250 -0
  27. data/lib/tremendous/models/create_organization.rb +268 -0
  28. data/lib/tremendous/models/create_organization200_response.rb +214 -0
  29. data/lib/tremendous/models/create_organization200_response_organization.rb +334 -0
  30. data/lib/tremendous/models/create_organization_request.rb +268 -0
  31. data/lib/tremendous/models/create_organization_request_copy_settings.rb +290 -0
  32. data/lib/tremendous/models/create_webhook200_response.rb +214 -0
  33. data/lib/tremendous/models/create_webhook_request.rb +222 -0
  34. data/lib/tremendous/models/currency_codes.rb +154 -0
  35. data/lib/tremendous/models/custom_field.rb +258 -0
  36. data/lib/tremendous/models/delivery_details.rb +286 -0
  37. data/lib/tremendous/models/delivery_details_with_link.rb +296 -0
  38. data/lib/tremendous/models/delivery_method.rb +41 -0
  39. data/lib/tremendous/models/delivery_status.rb +42 -0
  40. data/lib/tremendous/models/error_model.rb +221 -0
  41. data/lib/tremendous/models/field.rb +286 -0
  42. data/lib/tremendous/models/funding_source.rb +332 -0
  43. data/lib/tremendous/models/generate_reward_link200_response.rb +221 -0
  44. data/lib/tremendous/models/generate_reward_link200_response_reward.rb +247 -0
  45. data/lib/tremendous/models/generate_reward_link403_response.rb +221 -0
  46. data/lib/tremendous/models/generate_reward_token200_response.rb +221 -0
  47. data/lib/tremendous/models/generate_reward_token200_response_reward.rb +257 -0
  48. data/lib/tremendous/models/get_funding_source200_response.rb +221 -0
  49. data/lib/tremendous/models/get_member200_response.rb +221 -0
  50. data/lib/tremendous/models/get_member200_response_member.rb +375 -0
  51. data/lib/tremendous/models/get_member200_response_member_events_inner.rb +260 -0
  52. data/lib/tremendous/models/get_organization200_response.rb +214 -0
  53. data/lib/tremendous/models/get_product_response.rb +221 -0
  54. data/lib/tremendous/models/get_reward200_response.rb +221 -0
  55. data/lib/tremendous/models/invoice.rb +356 -0
  56. data/lib/tremendous/models/list_balance_transactions200_response.rb +216 -0
  57. data/lib/tremendous/models/list_balance_transactions200_response_invoices_inner.rb +256 -0
  58. data/lib/tremendous/models/list_campaigns200_response.rb +223 -0
  59. data/lib/tremendous/models/list_campaigns200_response_campaigns_inner.rb +303 -0
  60. data/lib/tremendous/models/list_campaigns200_response_campaigns_inner_email_style.rb +270 -0
  61. data/lib/tremendous/models/list_campaigns200_response_campaigns_inner_webpage_style.rb +270 -0
  62. data/lib/tremendous/models/list_fields200_response.rb +216 -0
  63. data/lib/tremendous/models/list_fields200_response_fields_inner.rb +286 -0
  64. data/lib/tremendous/models/list_funding_sources200_response.rb +223 -0
  65. data/lib/tremendous/models/list_funding_sources200_response_funding_sources_inner.rb +332 -0
  66. data/lib/tremendous/models/list_funding_sources200_response_funding_sources_inner_meta.rb +436 -0
  67. data/lib/tremendous/models/list_invoices200_response.rb +240 -0
  68. data/lib/tremendous/models/list_invoices200_response_invoices_inner.rb +356 -0
  69. data/lib/tremendous/models/list_members200_response.rb +223 -0
  70. data/lib/tremendous/models/list_members200_response_members_inner.rb +384 -0
  71. data/lib/tremendous/models/list_orders200_response.rb +240 -0
  72. data/lib/tremendous/models/list_orders200_response_orders_inner.rb +379 -0
  73. data/lib/tremendous/models/list_orders200_response_orders_inner_payment.rb +346 -0
  74. data/lib/tremendous/models/list_orders200_response_orders_inner_payment_refund.rb +242 -0
  75. data/lib/tremendous/models/list_organizations200_response.rb +216 -0
  76. data/lib/tremendous/models/list_organizations200_response_organizations_inner.rb +324 -0
  77. data/lib/tremendous/models/list_products_response.rb +223 -0
  78. data/lib/tremendous/models/list_products_response_products_inner.rb +457 -0
  79. data/lib/tremendous/models/list_products_response_products_inner_countries_inner.rb +222 -0
  80. data/lib/tremendous/models/list_products_response_products_inner_images_inner.rb +273 -0
  81. data/lib/tremendous/models/list_products_response_products_inner_skus_inner.rb +277 -0
  82. data/lib/tremendous/models/list_rewards200_response.rb +226 -0
  83. data/lib/tremendous/models/list_rewards200_response_rewards_inner.rb +347 -0
  84. data/lib/tremendous/models/list_rewards200_response_rewards_inner_custom_fields_inner.rb +258 -0
  85. data/lib/tremendous/models/list_rewards200_response_rewards_inner_delivery.rb +286 -0
  86. data/lib/tremendous/models/list_rewards200_response_rewards_inner_recipient.rb +236 -0
  87. data/lib/tremendous/models/list_rewards200_response_rewards_inner_value.rb +273 -0
  88. data/lib/tremendous/models/list_rewards401_response.rb +221 -0
  89. data/lib/tremendous/models/list_rewards401_response_errors.rb +225 -0
  90. data/lib/tremendous/models/list_rewards429_response.rb +221 -0
  91. data/lib/tremendous/models/list_webhook_events200_response.rb +216 -0
  92. data/lib/tremendous/models/list_webhooks200_response.rb +216 -0
  93. data/lib/tremendous/models/list_webhooks200_response_webhooks_inner.rb +258 -0
  94. data/lib/tremendous/models/member.rb +384 -0
  95. data/lib/tremendous/models/member_base.rb +363 -0
  96. data/lib/tremendous/models/member_with_events.rb +375 -0
  97. data/lib/tremendous/models/member_without_events.rb +384 -0
  98. data/lib/tremendous/models/order.rb +379 -0
  99. data/lib/tremendous/models/order_base.rb +370 -0
  100. data/lib/tremendous/models/order_base_payment.rb +346 -0
  101. data/lib/tremendous/models/order_for_create.rb +248 -0
  102. data/lib/tremendous/models/order_for_create_reward.rb +416 -0
  103. data/lib/tremendous/models/order_status.rb +44 -0
  104. data/lib/tremendous/models/order_with_link.rb +400 -0
  105. data/lib/tremendous/models/order_with_link_rewards_inner.rb +406 -0
  106. data/lib/tremendous/models/order_without_link.rb +379 -0
  107. data/lib/tremendous/models/order_without_link_reward.rb +406 -0
  108. data/lib/tremendous/models/organization.rb +324 -0
  109. data/lib/tremendous/models/payment_details.rb +345 -0
  110. data/lib/tremendous/models/payment_details_refund.rb +242 -0
  111. data/lib/tremendous/models/product.rb +457 -0
  112. data/lib/tremendous/models/recipient.rb +236 -0
  113. data/lib/tremendous/models/refund_details.rb +241 -0
  114. data/lib/tremendous/models/resend_reward422_response.rb +221 -0
  115. data/lib/tremendous/models/reward.rb +406 -0
  116. data/lib/tremendous/models/reward_base.rb +397 -0
  117. data/lib/tremendous/models/reward_base_custom_fields_inner.rb +258 -0
  118. data/lib/tremendous/models/reward_for_order_create.rb +416 -0
  119. data/lib/tremendous/models/reward_link.rb +247 -0
  120. data/lib/tremendous/models/reward_token.rb +257 -0
  121. data/lib/tremendous/models/reward_value.rb +273 -0
  122. data/lib/tremendous/models/reward_with_link.rb +406 -0
  123. data/lib/tremendous/models/reward_with_link_delivery.rb +296 -0
  124. data/lib/tremendous/models/reward_without_link.rb +406 -0
  125. data/lib/tremendous/models/reward_without_link_delivery.rb +286 -0
  126. data/lib/tremendous/models/simulate_webhook_request.rb +222 -0
  127. data/lib/tremendous/models/webhook.rb +258 -0
  128. data/lib/tremendous/models/webhook_post.rb +222 -0
  129. data/lib/tremendous/version.rb +3 -0
  130. data/lib/tremendous.rb +163 -0
  131. metadata +132 -11
  132. data/spec/integration/campaigns_spec.rb +0 -27
  133. data/spec/integration/funding_sources_spec.rb +0 -18
  134. data/spec/integration/invoices_spec.rb +0 -19
  135. data/spec/integration/members_spec.rb +0 -19
  136. data/spec/integration/orders_spec.rb +0 -53
  137. data/spec/integration/products_spec.rb +0 -26
  138. data/spec/spec_helper.rb +0 -111
  139. data/spec/support/setup.rb +0 -10
@@ -0,0 +1,347 @@
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 single reward, sent to a recipient. A reward is always part of an order. Either `products` or `campaign_id` must be specified.
18
+ class ListRewards200ResponseRewardsInner
19
+ # Tremendous ID of the reward
20
+ attr_accessor :id
21
+
22
+ # Tremendous ID of the order this reward is part of.
23
+ attr_accessor :order_id
24
+
25
+ # Date the reward was created
26
+ attr_accessor :created_at
27
+
28
+ attr_accessor :value
29
+
30
+ attr_accessor :recipient
31
+
32
+ # Timestamp of reward delivery within the next year. Note that if date-time is provided, the time values will be ignored.
33
+ attr_accessor :deliver_at
34
+
35
+ attr_accessor :custom_fields
36
+
37
+ attr_accessor :delivery
38
+
39
+ # Attribute mapping from ruby-style variable name to JSON key.
40
+ def self.attribute_map
41
+ {
42
+ :'id' => :'id',
43
+ :'order_id' => :'order_id',
44
+ :'created_at' => :'created_at',
45
+ :'value' => :'value',
46
+ :'recipient' => :'recipient',
47
+ :'deliver_at' => :'deliver_at',
48
+ :'custom_fields' => :'custom_fields',
49
+ :'delivery' => :'delivery'
50
+ }
51
+ end
52
+
53
+ # Returns all the JSON keys this model knows about
54
+ def self.acceptable_attributes
55
+ attribute_map.values
56
+ end
57
+
58
+ # Attribute type mapping.
59
+ def self.openapi_types
60
+ {
61
+ :'id' => :'String',
62
+ :'order_id' => :'String',
63
+ :'created_at' => :'Time',
64
+ :'value' => :'ListRewards200ResponseRewardsInnerValue',
65
+ :'recipient' => :'ListRewards200ResponseRewardsInnerRecipient',
66
+ :'deliver_at' => :'Date',
67
+ :'custom_fields' => :'Array<ListRewards200ResponseRewardsInnerCustomFieldsInner>',
68
+ :'delivery' => :'ListRewards200ResponseRewardsInnerDelivery'
69
+ }
70
+ end
71
+
72
+ # List of attributes with nullable: true
73
+ def self.openapi_nullable
74
+ Set.new([
75
+ ])
76
+ end
77
+
78
+ # Initializes the object
79
+ # @param [Hash] attributes Model attributes in the form of hash
80
+ def initialize(attributes = {})
81
+ if (!attributes.is_a?(Hash))
82
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::ListRewards200ResponseRewardsInner` initialize method"
83
+ end
84
+
85
+ # check to see if the attribute exists and convert string to symbol for hash key
86
+ attributes = attributes.each_with_object({}) { |(k, v), h|
87
+ if (!self.class.attribute_map.key?(k.to_sym))
88
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::ListRewards200ResponseRewardsInner`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
89
+ end
90
+ h[k.to_sym] = v
91
+ }
92
+
93
+ if attributes.key?(:'id')
94
+ self.id = attributes[:'id']
95
+ end
96
+
97
+ if attributes.key?(:'order_id')
98
+ self.order_id = attributes[:'order_id']
99
+ end
100
+
101
+ if attributes.key?(:'created_at')
102
+ self.created_at = attributes[:'created_at']
103
+ end
104
+
105
+ if attributes.key?(:'value')
106
+ self.value = attributes[:'value']
107
+ end
108
+
109
+ if attributes.key?(:'recipient')
110
+ self.recipient = attributes[:'recipient']
111
+ end
112
+
113
+ if attributes.key?(:'deliver_at')
114
+ self.deliver_at = attributes[:'deliver_at']
115
+ end
116
+
117
+ if attributes.key?(:'custom_fields')
118
+ if (value = attributes[:'custom_fields']).is_a?(Array)
119
+ self.custom_fields = value
120
+ end
121
+ end
122
+
123
+ if attributes.key?(:'delivery')
124
+ self.delivery = attributes[:'delivery']
125
+ end
126
+ end
127
+
128
+ # Show invalid properties with the reasons. Usually used together with valid?
129
+ # @return Array for valid properties with the reasons
130
+ def list_invalid_properties
131
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
132
+ invalid_properties = Array.new
133
+ pattern = Regexp.new(/[A-Z0-9]{4,20}/)
134
+ if !@id.nil? && @id !~ pattern
135
+ invalid_properties.push("invalid value for \"id\", must conform to the pattern #{pattern}.")
136
+ end
137
+
138
+ pattern = Regexp.new(/[A-Z0-9]{4,20}/)
139
+ if !@order_id.nil? && @order_id !~ pattern
140
+ invalid_properties.push("invalid value for \"order_id\", must conform to the pattern #{pattern}.")
141
+ end
142
+
143
+ pattern = Regexp.new(/YYYY-MM-DD/)
144
+ if !@deliver_at.nil? && @deliver_at !~ pattern
145
+ invalid_properties.push("invalid value for \"deliver_at\", must conform to the pattern #{pattern}.")
146
+ end
147
+
148
+ invalid_properties
149
+ end
150
+
151
+ # Check to see if the all the properties in the model are valid
152
+ # @return true if the model is valid
153
+ def valid?
154
+ warn '[DEPRECATED] the `valid?` method is obsolete'
155
+ return false if !@id.nil? && @id !~ Regexp.new(/[A-Z0-9]{4,20}/)
156
+ return false if !@order_id.nil? && @order_id !~ Regexp.new(/[A-Z0-9]{4,20}/)
157
+ return false if !@deliver_at.nil? && @deliver_at !~ Regexp.new(/YYYY-MM-DD/)
158
+ true
159
+ end
160
+
161
+ # Custom attribute writer method with validation
162
+ # @param [Object] id Value to be assigned
163
+ def id=(id)
164
+ if id.nil?
165
+ fail ArgumentError, 'id cannot be nil'
166
+ end
167
+
168
+ pattern = Regexp.new(/[A-Z0-9]{4,20}/)
169
+ if id !~ pattern
170
+ fail ArgumentError, "invalid value for \"id\", must conform to the pattern #{pattern}."
171
+ end
172
+
173
+ @id = id
174
+ end
175
+
176
+ # Custom attribute writer method with validation
177
+ # @param [Object] order_id Value to be assigned
178
+ def order_id=(order_id)
179
+ if order_id.nil?
180
+ fail ArgumentError, 'order_id cannot be nil'
181
+ end
182
+
183
+ pattern = Regexp.new(/[A-Z0-9]{4,20}/)
184
+ if order_id !~ pattern
185
+ fail ArgumentError, "invalid value for \"order_id\", must conform to the pattern #{pattern}."
186
+ end
187
+
188
+ @order_id = order_id
189
+ end
190
+
191
+ # Custom attribute writer method with validation
192
+ # @param [Object] deliver_at Value to be assigned
193
+ def deliver_at=(deliver_at)
194
+ if deliver_at.nil?
195
+ fail ArgumentError, 'deliver_at cannot be nil'
196
+ end
197
+
198
+ pattern = Regexp.new(/YYYY-MM-DD/)
199
+ if deliver_at !~ pattern
200
+ fail ArgumentError, "invalid value for \"deliver_at\", must conform to the pattern #{pattern}."
201
+ end
202
+
203
+ @deliver_at = deliver_at
204
+ end
205
+
206
+ # Checks equality by comparing each attribute.
207
+ # @param [Object] Object to be compared
208
+ def ==(o)
209
+ return true if self.equal?(o)
210
+ self.class == o.class &&
211
+ id == o.id &&
212
+ order_id == o.order_id &&
213
+ created_at == o.created_at &&
214
+ value == o.value &&
215
+ recipient == o.recipient &&
216
+ deliver_at == o.deliver_at &&
217
+ custom_fields == o.custom_fields &&
218
+ delivery == o.delivery
219
+ end
220
+
221
+ # @see the `==` method
222
+ # @param [Object] Object to be compared
223
+ def eql?(o)
224
+ self == o
225
+ end
226
+
227
+ # Calculates hash code according to all attributes.
228
+ # @return [Integer] Hash code
229
+ def hash
230
+ [id, order_id, created_at, value, recipient, deliver_at, custom_fields, delivery].hash
231
+ end
232
+
233
+ # Builds the object from hash
234
+ # @param [Hash] attributes Model attributes in the form of hash
235
+ # @return [Object] Returns the model itself
236
+ def self.build_from_hash(attributes)
237
+ return nil unless attributes.is_a?(Hash)
238
+ attributes = attributes.transform_keys(&:to_sym)
239
+ transformed_hash = {}
240
+ openapi_types.each_pair do |key, type|
241
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
242
+ transformed_hash["#{key}"] = nil
243
+ elsif type =~ /\AArray<(.*)>/i
244
+ # check to ensure the input is an array given that the attribute
245
+ # is documented as an array but the input is not
246
+ if attributes[attribute_map[key]].is_a?(Array)
247
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
248
+ end
249
+ elsif !attributes[attribute_map[key]].nil?
250
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
251
+ end
252
+ end
253
+ new(transformed_hash)
254
+ end
255
+
256
+ # Deserializes the data based on type
257
+ # @param string type Data type
258
+ # @param string value Value to be deserialized
259
+ # @return [Object] Deserialized data
260
+ def self._deserialize(type, value)
261
+ case type.to_sym
262
+ when :Time
263
+ Time.parse(value)
264
+ when :Date
265
+ Date.parse(value)
266
+ when :String
267
+ value.to_s
268
+ when :Integer
269
+ value.to_i
270
+ when :Float
271
+ value.to_f
272
+ when :Boolean
273
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
274
+ true
275
+ else
276
+ false
277
+ end
278
+ when :Object
279
+ # generic object (usually a Hash), return directly
280
+ value
281
+ when /\AArray<(?<inner_type>.+)>\z/
282
+ inner_type = Regexp.last_match[:inner_type]
283
+ value.map { |v| _deserialize(inner_type, v) }
284
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
285
+ k_type = Regexp.last_match[:k_type]
286
+ v_type = Regexp.last_match[:v_type]
287
+ {}.tap do |hash|
288
+ value.each do |k, v|
289
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
290
+ end
291
+ end
292
+ else # model
293
+ # models (e.g. Pet) or oneOf
294
+ klass = Tremendous.const_get(type)
295
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
296
+ end
297
+ end
298
+
299
+ # Returns the string representation of the object
300
+ # @return [String] String presentation of the object
301
+ def to_s
302
+ to_hash.to_s
303
+ end
304
+
305
+ # to_body is an alias to to_hash (backward compatibility)
306
+ # @return [Hash] Returns the object in the form of hash
307
+ def to_body
308
+ to_hash
309
+ end
310
+
311
+ # Returns the object in the form of hash
312
+ # @return [Hash] Returns the object in the form of hash
313
+ def to_hash
314
+ hash = {}
315
+ self.class.attribute_map.each_pair do |attr, param|
316
+ value = self.send(attr)
317
+ if value.nil?
318
+ is_nullable = self.class.openapi_nullable.include?(attr)
319
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
320
+ end
321
+
322
+ hash[param] = _to_hash(value)
323
+ end
324
+ hash
325
+ end
326
+
327
+ # Outputs non-array value in the form of hash
328
+ # For object, use to_hash. Otherwise, just return the value
329
+ # @param [Object] value Any valid value
330
+ # @return [Hash] Returns the value in the form of hash
331
+ def _to_hash(value)
332
+ if value.is_a?(Array)
333
+ value.compact.map { |v| _to_hash(v) }
334
+ elsif value.is_a?(Hash)
335
+ {}.tap do |hash|
336
+ value.each { |k, v| hash[k] = _to_hash(v) }
337
+ end
338
+ elsif value.respond_to? :to_hash
339
+ value.to_hash
340
+ else
341
+ value
342
+ end
343
+ end
344
+
345
+ end
346
+
347
+ end
@@ -0,0 +1,258 @@
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
+ # Reward custom data for searching, tracking or copy (see [Adding custom fields to orders](https://developers.tremendous.com/reference/using-custom-fields-to-add-custom-data-to-rewards).)
18
+ class ListRewards200ResponseRewardsInnerCustomFieldsInner
19
+ # Tremendous ID of the custom field
20
+ attr_accessor :id
21
+
22
+ # Value of the custom field
23
+ attr_accessor :value
24
+
25
+ # Label of the custom field
26
+ attr_accessor :label
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'id' => :'id',
32
+ :'value' => :'value',
33
+ :'label' => :'label'
34
+ }
35
+ end
36
+
37
+ # Returns all the JSON keys this model knows about
38
+ def self.acceptable_attributes
39
+ attribute_map.values
40
+ end
41
+
42
+ # Attribute type mapping.
43
+ def self.openapi_types
44
+ {
45
+ :'id' => :'String',
46
+ :'value' => :'String',
47
+ :'label' => :'String'
48
+ }
49
+ end
50
+
51
+ # List of attributes with nullable: true
52
+ def self.openapi_nullable
53
+ Set.new([
54
+ :'value',
55
+ ])
56
+ end
57
+
58
+ # Initializes the object
59
+ # @param [Hash] attributes Model attributes in the form of hash
60
+ def initialize(attributes = {})
61
+ if (!attributes.is_a?(Hash))
62
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::ListRewards200ResponseRewardsInnerCustomFieldsInner` initialize method"
63
+ end
64
+
65
+ # check to see if the attribute exists and convert string to symbol for hash key
66
+ attributes = attributes.each_with_object({}) { |(k, v), h|
67
+ if (!self.class.attribute_map.key?(k.to_sym))
68
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::ListRewards200ResponseRewardsInnerCustomFieldsInner`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
69
+ end
70
+ h[k.to_sym] = v
71
+ }
72
+
73
+ if attributes.key?(:'id')
74
+ self.id = attributes[:'id']
75
+ end
76
+
77
+ if attributes.key?(:'value')
78
+ self.value = attributes[:'value']
79
+ end
80
+
81
+ if attributes.key?(:'label')
82
+ self.label = attributes[:'label']
83
+ end
84
+ end
85
+
86
+ # Show invalid properties with the reasons. Usually used together with valid?
87
+ # @return Array for valid properties with the reasons
88
+ def list_invalid_properties
89
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
90
+ invalid_properties = Array.new
91
+ pattern = Regexp.new(/[A-Z0-9]{4,20}/)
92
+ if !@id.nil? && @id !~ pattern
93
+ invalid_properties.push("invalid value for \"id\", must conform to the pattern #{pattern}.")
94
+ end
95
+
96
+ invalid_properties
97
+ end
98
+
99
+ # Check to see if the all the properties in the model are valid
100
+ # @return true if the model is valid
101
+ def valid?
102
+ warn '[DEPRECATED] the `valid?` method is obsolete'
103
+ return false if !@id.nil? && @id !~ Regexp.new(/[A-Z0-9]{4,20}/)
104
+ true
105
+ end
106
+
107
+ # Custom attribute writer method with validation
108
+ # @param [Object] id Value to be assigned
109
+ def id=(id)
110
+ if id.nil?
111
+ fail ArgumentError, 'id cannot be nil'
112
+ end
113
+
114
+ pattern = Regexp.new(/[A-Z0-9]{4,20}/)
115
+ if id !~ pattern
116
+ fail ArgumentError, "invalid value for \"id\", must conform to the pattern #{pattern}."
117
+ end
118
+
119
+ @id = id
120
+ end
121
+
122
+ # Checks equality by comparing each attribute.
123
+ # @param [Object] Object to be compared
124
+ def ==(o)
125
+ return true if self.equal?(o)
126
+ self.class == o.class &&
127
+ id == o.id &&
128
+ value == o.value &&
129
+ label == o.label
130
+ end
131
+
132
+ # @see the `==` method
133
+ # @param [Object] Object to be compared
134
+ def eql?(o)
135
+ self == o
136
+ end
137
+
138
+ # Calculates hash code according to all attributes.
139
+ # @return [Integer] Hash code
140
+ def hash
141
+ [id, value, label].hash
142
+ end
143
+
144
+ # Builds the object from hash
145
+ # @param [Hash] attributes Model attributes in the form of hash
146
+ # @return [Object] Returns the model itself
147
+ def self.build_from_hash(attributes)
148
+ return nil unless attributes.is_a?(Hash)
149
+ attributes = attributes.transform_keys(&:to_sym)
150
+ transformed_hash = {}
151
+ openapi_types.each_pair do |key, type|
152
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
153
+ transformed_hash["#{key}"] = nil
154
+ elsif type =~ /\AArray<(.*)>/i
155
+ # check to ensure the input is an array given that the attribute
156
+ # is documented as an array but the input is not
157
+ if attributes[attribute_map[key]].is_a?(Array)
158
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
159
+ end
160
+ elsif !attributes[attribute_map[key]].nil?
161
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
162
+ end
163
+ end
164
+ new(transformed_hash)
165
+ end
166
+
167
+ # Deserializes the data based on type
168
+ # @param string type Data type
169
+ # @param string value Value to be deserialized
170
+ # @return [Object] Deserialized data
171
+ def self._deserialize(type, value)
172
+ case type.to_sym
173
+ when :Time
174
+ Time.parse(value)
175
+ when :Date
176
+ Date.parse(value)
177
+ when :String
178
+ value.to_s
179
+ when :Integer
180
+ value.to_i
181
+ when :Float
182
+ value.to_f
183
+ when :Boolean
184
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
185
+ true
186
+ else
187
+ false
188
+ end
189
+ when :Object
190
+ # generic object (usually a Hash), return directly
191
+ value
192
+ when /\AArray<(?<inner_type>.+)>\z/
193
+ inner_type = Regexp.last_match[:inner_type]
194
+ value.map { |v| _deserialize(inner_type, v) }
195
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
196
+ k_type = Regexp.last_match[:k_type]
197
+ v_type = Regexp.last_match[:v_type]
198
+ {}.tap do |hash|
199
+ value.each do |k, v|
200
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
201
+ end
202
+ end
203
+ else # model
204
+ # models (e.g. Pet) or oneOf
205
+ klass = Tremendous.const_get(type)
206
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
207
+ end
208
+ end
209
+
210
+ # Returns the string representation of the object
211
+ # @return [String] String presentation of the object
212
+ def to_s
213
+ to_hash.to_s
214
+ end
215
+
216
+ # to_body is an alias to to_hash (backward compatibility)
217
+ # @return [Hash] Returns the object in the form of hash
218
+ def to_body
219
+ to_hash
220
+ end
221
+
222
+ # Returns the object in the form of hash
223
+ # @return [Hash] Returns the object in the form of hash
224
+ def to_hash
225
+ hash = {}
226
+ self.class.attribute_map.each_pair do |attr, param|
227
+ value = self.send(attr)
228
+ if value.nil?
229
+ is_nullable = self.class.openapi_nullable.include?(attr)
230
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
231
+ end
232
+
233
+ hash[param] = _to_hash(value)
234
+ end
235
+ hash
236
+ end
237
+
238
+ # Outputs non-array value in the form of hash
239
+ # For object, use to_hash. Otherwise, just return the value
240
+ # @param [Object] value Any valid value
241
+ # @return [Hash] Returns the value in the form of hash
242
+ def _to_hash(value)
243
+ if value.is_a?(Array)
244
+ value.compact.map { |v| _to_hash(v) }
245
+ elsif value.is_a?(Hash)
246
+ {}.tap do |hash|
247
+ value.each { |k, v| hash[k] = _to_hash(v) }
248
+ end
249
+ elsif value.respond_to? :to_hash
250
+ value.to_hash
251
+ else
252
+ value
253
+ end
254
+ end
255
+
256
+ end
257
+
258
+ end