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,277 @@
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
+ class ListProductsResponseProductsInnerSkusInner
18
+ # Minimal denomination that this product supports (in the product's currency)
19
+ attr_accessor :min
20
+
21
+ # Maximum denomination that this product supports (in the product's currency)
22
+ attr_accessor :max
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'min' => :'min',
28
+ :'max' => :'max'
29
+ }
30
+ end
31
+
32
+ # Returns all the JSON keys this model knows about
33
+ def self.acceptable_attributes
34
+ attribute_map.values
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.openapi_types
39
+ {
40
+ :'min' => :'Float',
41
+ :'max' => :'Float'
42
+ }
43
+ end
44
+
45
+ # List of attributes with nullable: true
46
+ def self.openapi_nullable
47
+ Set.new([
48
+ ])
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::ListProductsResponseProductsInnerSkusInner` initialize method"
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!self.class.attribute_map.key?(k.to_sym))
61
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::ListProductsResponseProductsInnerSkusInner`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
62
+ end
63
+ h[k.to_sym] = v
64
+ }
65
+
66
+ if attributes.key?(:'min')
67
+ self.min = attributes[:'min']
68
+ else
69
+ self.min = nil
70
+ end
71
+
72
+ if attributes.key?(:'max')
73
+ self.max = attributes[:'max']
74
+ else
75
+ self.max = nil
76
+ end
77
+ end
78
+
79
+ # Show invalid properties with the reasons. Usually used together with valid?
80
+ # @return Array for valid properties with the reasons
81
+ def list_invalid_properties
82
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
83
+ invalid_properties = Array.new
84
+ if @min.nil?
85
+ invalid_properties.push('invalid value for "min", min cannot be nil.')
86
+ end
87
+
88
+ if @min < 0
89
+ invalid_properties.push('invalid value for "min", must be greater than or equal to 0.')
90
+ end
91
+
92
+ if @max.nil?
93
+ invalid_properties.push('invalid value for "max", max cannot be nil.')
94
+ end
95
+
96
+ if @max < 0
97
+ invalid_properties.push('invalid value for "max", must be greater than or equal to 0.')
98
+ end
99
+
100
+ invalid_properties
101
+ end
102
+
103
+ # Check to see if the all the properties in the model are valid
104
+ # @return true if the model is valid
105
+ def valid?
106
+ warn '[DEPRECATED] the `valid?` method is obsolete'
107
+ return false if @min.nil?
108
+ return false if @min < 0
109
+ return false if @max.nil?
110
+ return false if @max < 0
111
+ true
112
+ end
113
+
114
+ # Custom attribute writer method with validation
115
+ # @param [Object] min Value to be assigned
116
+ def min=(min)
117
+ if min.nil?
118
+ fail ArgumentError, 'min cannot be nil'
119
+ end
120
+
121
+ if min < 0
122
+ fail ArgumentError, 'invalid value for "min", must be greater than or equal to 0.'
123
+ end
124
+
125
+ @min = min
126
+ end
127
+
128
+ # Custom attribute writer method with validation
129
+ # @param [Object] max Value to be assigned
130
+ def max=(max)
131
+ if max.nil?
132
+ fail ArgumentError, 'max cannot be nil'
133
+ end
134
+
135
+ if max < 0
136
+ fail ArgumentError, 'invalid value for "max", must be greater than or equal to 0.'
137
+ end
138
+
139
+ @max = max
140
+ end
141
+
142
+ # Checks equality by comparing each attribute.
143
+ # @param [Object] Object to be compared
144
+ def ==(o)
145
+ return true if self.equal?(o)
146
+ self.class == o.class &&
147
+ min == o.min &&
148
+ max == o.max
149
+ end
150
+
151
+ # @see the `==` method
152
+ # @param [Object] Object to be compared
153
+ def eql?(o)
154
+ self == o
155
+ end
156
+
157
+ # Calculates hash code according to all attributes.
158
+ # @return [Integer] Hash code
159
+ def hash
160
+ [min, max].hash
161
+ end
162
+
163
+ # Builds the object from hash
164
+ # @param [Hash] attributes Model attributes in the form of hash
165
+ # @return [Object] Returns the model itself
166
+ def self.build_from_hash(attributes)
167
+ return nil unless attributes.is_a?(Hash)
168
+ attributes = attributes.transform_keys(&:to_sym)
169
+ transformed_hash = {}
170
+ openapi_types.each_pair do |key, type|
171
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
172
+ transformed_hash["#{key}"] = nil
173
+ elsif type =~ /\AArray<(.*)>/i
174
+ # check to ensure the input is an array given that the attribute
175
+ # is documented as an array but the input is not
176
+ if attributes[attribute_map[key]].is_a?(Array)
177
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
178
+ end
179
+ elsif !attributes[attribute_map[key]].nil?
180
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
181
+ end
182
+ end
183
+ new(transformed_hash)
184
+ end
185
+
186
+ # Deserializes the data based on type
187
+ # @param string type Data type
188
+ # @param string value Value to be deserialized
189
+ # @return [Object] Deserialized data
190
+ def self._deserialize(type, value)
191
+ case type.to_sym
192
+ when :Time
193
+ Time.parse(value)
194
+ when :Date
195
+ Date.parse(value)
196
+ when :String
197
+ value.to_s
198
+ when :Integer
199
+ value.to_i
200
+ when :Float
201
+ value.to_f
202
+ when :Boolean
203
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
204
+ true
205
+ else
206
+ false
207
+ end
208
+ when :Object
209
+ # generic object (usually a Hash), return directly
210
+ value
211
+ when /\AArray<(?<inner_type>.+)>\z/
212
+ inner_type = Regexp.last_match[:inner_type]
213
+ value.map { |v| _deserialize(inner_type, v) }
214
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
215
+ k_type = Regexp.last_match[:k_type]
216
+ v_type = Regexp.last_match[:v_type]
217
+ {}.tap do |hash|
218
+ value.each do |k, v|
219
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
220
+ end
221
+ end
222
+ else # model
223
+ # models (e.g. Pet) or oneOf
224
+ klass = Tremendous.const_get(type)
225
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
226
+ end
227
+ end
228
+
229
+ # Returns the string representation of the object
230
+ # @return [String] String presentation of the object
231
+ def to_s
232
+ to_hash.to_s
233
+ end
234
+
235
+ # to_body is an alias to to_hash (backward compatibility)
236
+ # @return [Hash] Returns the object in the form of hash
237
+ def to_body
238
+ to_hash
239
+ end
240
+
241
+ # Returns the object in the form of hash
242
+ # @return [Hash] Returns the object in the form of hash
243
+ def to_hash
244
+ hash = {}
245
+ self.class.attribute_map.each_pair do |attr, param|
246
+ value = self.send(attr)
247
+ if value.nil?
248
+ is_nullable = self.class.openapi_nullable.include?(attr)
249
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
250
+ end
251
+
252
+ hash[param] = _to_hash(value)
253
+ end
254
+ hash
255
+ end
256
+
257
+ # Outputs non-array value in the form of hash
258
+ # For object, use to_hash. Otherwise, just return the value
259
+ # @param [Object] value Any valid value
260
+ # @return [Hash] Returns the value in the form of hash
261
+ def _to_hash(value)
262
+ if value.is_a?(Array)
263
+ value.compact.map { |v| _to_hash(v) }
264
+ elsif value.is_a?(Hash)
265
+ {}.tap do |hash|
266
+ value.each { |k, v| hash[k] = _to_hash(v) }
267
+ end
268
+ elsif value.respond_to? :to_hash
269
+ value.to_hash
270
+ else
271
+ value
272
+ end
273
+ end
274
+
275
+ end
276
+
277
+ end
@@ -0,0 +1,226 @@
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
+ class ListRewards200Response
18
+ attr_accessor :rewards
19
+
20
+ # The total number of rewards across all pages
21
+ attr_accessor :total_count
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'rewards' => :'rewards',
27
+ :'total_count' => :'total_count'
28
+ }
29
+ end
30
+
31
+ # Returns all the JSON keys this model knows about
32
+ def self.acceptable_attributes
33
+ attribute_map.values
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.openapi_types
38
+ {
39
+ :'rewards' => :'Array<ListRewards200ResponseRewardsInner>',
40
+ :'total_count' => :'Integer'
41
+ }
42
+ end
43
+
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new([
47
+ ])
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::ListRewards200Response` initialize method"
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ attributes = attributes.each_with_object({}) { |(k, v), h|
59
+ if (!self.class.attribute_map.key?(k.to_sym))
60
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::ListRewards200Response`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
61
+ end
62
+ h[k.to_sym] = v
63
+ }
64
+
65
+ if attributes.key?(:'rewards')
66
+ if (value = attributes[:'rewards']).is_a?(Array)
67
+ self.rewards = value
68
+ end
69
+ end
70
+
71
+ if attributes.key?(:'total_count')
72
+ self.total_count = attributes[:'total_count']
73
+ end
74
+ end
75
+
76
+ # Show invalid properties with the reasons. Usually used together with valid?
77
+ # @return Array for valid properties with the reasons
78
+ def list_invalid_properties
79
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
80
+ invalid_properties = Array.new
81
+ invalid_properties
82
+ end
83
+
84
+ # Check to see if the all the properties in the model are valid
85
+ # @return true if the model is valid
86
+ def valid?
87
+ warn '[DEPRECATED] the `valid?` method is obsolete'
88
+ true
89
+ end
90
+
91
+ # Checks equality by comparing each attribute.
92
+ # @param [Object] Object to be compared
93
+ def ==(o)
94
+ return true if self.equal?(o)
95
+ self.class == o.class &&
96
+ rewards == o.rewards &&
97
+ total_count == o.total_count
98
+ end
99
+
100
+ # @see the `==` method
101
+ # @param [Object] Object to be compared
102
+ def eql?(o)
103
+ self == o
104
+ end
105
+
106
+ # Calculates hash code according to all attributes.
107
+ # @return [Integer] Hash code
108
+ def hash
109
+ [rewards, total_count].hash
110
+ end
111
+
112
+ # Builds the object from hash
113
+ # @param [Hash] attributes Model attributes in the form of hash
114
+ # @return [Object] Returns the model itself
115
+ def self.build_from_hash(attributes)
116
+ return nil unless attributes.is_a?(Hash)
117
+ attributes = attributes.transform_keys(&:to_sym)
118
+ transformed_hash = {}
119
+ openapi_types.each_pair do |key, type|
120
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
121
+ transformed_hash["#{key}"] = nil
122
+ elsif type =~ /\AArray<(.*)>/i
123
+ # check to ensure the input is an array given that the attribute
124
+ # is documented as an array but the input is not
125
+ if attributes[attribute_map[key]].is_a?(Array)
126
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
127
+ end
128
+ elsif !attributes[attribute_map[key]].nil?
129
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
130
+ end
131
+ end
132
+ new(transformed_hash)
133
+ end
134
+
135
+ # Deserializes the data based on type
136
+ # @param string type Data type
137
+ # @param string value Value to be deserialized
138
+ # @return [Object] Deserialized data
139
+ def self._deserialize(type, value)
140
+ case type.to_sym
141
+ when :Time
142
+ Time.parse(value)
143
+ when :Date
144
+ Date.parse(value)
145
+ when :String
146
+ value.to_s
147
+ when :Integer
148
+ value.to_i
149
+ when :Float
150
+ value.to_f
151
+ when :Boolean
152
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
153
+ true
154
+ else
155
+ false
156
+ end
157
+ when :Object
158
+ # generic object (usually a Hash), return directly
159
+ value
160
+ when /\AArray<(?<inner_type>.+)>\z/
161
+ inner_type = Regexp.last_match[:inner_type]
162
+ value.map { |v| _deserialize(inner_type, v) }
163
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
164
+ k_type = Regexp.last_match[:k_type]
165
+ v_type = Regexp.last_match[:v_type]
166
+ {}.tap do |hash|
167
+ value.each do |k, v|
168
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
169
+ end
170
+ end
171
+ else # model
172
+ # models (e.g. Pet) or oneOf
173
+ klass = Tremendous.const_get(type)
174
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
175
+ end
176
+ end
177
+
178
+ # Returns the string representation of the object
179
+ # @return [String] String presentation of the object
180
+ def to_s
181
+ to_hash.to_s
182
+ end
183
+
184
+ # to_body is an alias to to_hash (backward compatibility)
185
+ # @return [Hash] Returns the object in the form of hash
186
+ def to_body
187
+ to_hash
188
+ end
189
+
190
+ # Returns the object in the form of hash
191
+ # @return [Hash] Returns the object in the form of hash
192
+ def to_hash
193
+ hash = {}
194
+ self.class.attribute_map.each_pair do |attr, param|
195
+ value = self.send(attr)
196
+ if value.nil?
197
+ is_nullable = self.class.openapi_nullable.include?(attr)
198
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
199
+ end
200
+
201
+ hash[param] = _to_hash(value)
202
+ end
203
+ hash
204
+ end
205
+
206
+ # Outputs non-array value in the form of hash
207
+ # For object, use to_hash. Otherwise, just return the value
208
+ # @param [Object] value Any valid value
209
+ # @return [Hash] Returns the value in the form of hash
210
+ def _to_hash(value)
211
+ if value.is_a?(Array)
212
+ value.compact.map { |v| _to_hash(v) }
213
+ elsif value.is_a?(Hash)
214
+ {}.tap do |hash|
215
+ value.each { |k, v| hash[k] = _to_hash(v) }
216
+ end
217
+ elsif value.respond_to? :to_hash
218
+ value.to_hash
219
+ else
220
+ value
221
+ end
222
+ end
223
+
224
+ end
225
+
226
+ end