tremendous_ruby 5.0.1 → 5.3.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 (43) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tremendous/api/tremendous_api.rb +677 -9
  3. data/lib/tremendous/models/campaign.rb +25 -14
  4. data/lib/tremendous/models/campaign_base.rb +287 -0
  5. data/lib/tremendous/models/{get_campaign200_response.rb → create_campaign201_response.rb} +3 -3
  6. data/lib/tremendous/models/create_campaign_request.rb +273 -0
  7. data/lib/tremendous/models/create_member.rb +2 -53
  8. data/lib/tremendous/models/create_member_request.rb +2 -53
  9. data/lib/tremendous/models/create_order_request_reward.rb +1 -1
  10. data/lib/tremendous/models/create_order_request_reward_custom_fields_inner.rb +248 -0
  11. data/lib/tremendous/models/create_organization_request_copy_settings.rb +29 -5
  12. data/lib/tremendous/models/{list_products200_response_products_inner_countries_inner.rb → create_public_key.rb} +15 -15
  13. data/lib/tremendous/models/create_public_key200_response.rb +221 -0
  14. data/lib/tremendous/models/create_public_key_request.rb +222 -0
  15. data/lib/tremendous/models/custom_field.rb +15 -5
  16. data/lib/tremendous/models/get_member200_response_member.rb +13 -21
  17. data/lib/tremendous/models/invoice.rb +2 -2
  18. data/lib/tremendous/models/list_campaigns200_response_campaigns_inner.rb +25 -14
  19. data/lib/tremendous/models/list_campaigns200_response_campaigns_inner_email_style.rb +270 -0
  20. data/lib/tremendous/models/list_campaigns200_response_campaigns_inner_webpage_style.rb +270 -0
  21. data/lib/tremendous/models/{get_product200_response.rb → list_forex_response.rb} +16 -14
  22. data/lib/tremendous/models/list_invoices200_response_invoices_inner.rb +2 -2
  23. data/lib/tremendous/models/list_members200_response_members_inner.rb +13 -21
  24. data/lib/tremendous/models/list_rewards200_response_rewards_inner_custom_fields_inner.rb +15 -5
  25. data/lib/tremendous/models/{list_products200_response.rb → list_roles200_response.rb} +15 -15
  26. data/lib/tremendous/models/{list_products200_response_products_inner_images_inner.rb → list_roles200_response_roles_inner.rb} +59 -57
  27. data/lib/tremendous/models/member.rb +13 -21
  28. data/lib/tremendous/models/member_base.rb +13 -21
  29. data/lib/tremendous/models/member_with_events.rb +13 -21
  30. data/lib/tremendous/models/member_without_events.rb +13 -21
  31. data/lib/tremendous/models/public_key.rb +257 -0
  32. data/lib/tremendous/models/public_keys_response.rb +223 -0
  33. data/lib/tremendous/models/public_keys_response_public_keys_inner.rb +257 -0
  34. data/lib/tremendous/models/reward_base_custom_fields_inner.rb +15 -5
  35. data/lib/tremendous/models/{list_products200_response_products_inner_skus_inner.rb → role.rb} +51 -53
  36. data/lib/tremendous/models/test_public_key.rb +222 -0
  37. data/lib/tremendous/models/test_public_key_request.rb +222 -0
  38. data/lib/tremendous/models/update_campaign.rb +287 -0
  39. data/lib/tremendous/models/update_campaign_request.rb +257 -0
  40. data/lib/tremendous/version.rb +1 -1
  41. data/lib/tremendous.rb +20 -1
  42. metadata +23 -10
  43. data/lib/tremendous/models/list_products200_response_products_inner.rb +0 -457
@@ -14,7 +14,7 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module Tremendous
17
- # With a campaign you can define the look & feel of how rewards are sent out. It also lets you set the available products (different gift cards, charity, etc.) recipients can choose from. > Note: Campaigns must be created from the Tremendous dashboard. > > • [Production Dashboard](https://app.tremendous.com) > • [Sandbox Dashboard](https://app.testflight.tremendous.com/)
17
+ # With a campaign you can define the look & feel of how rewards are sent out. It also lets you set the available products (different gift cards, charity, etc.) recipients can choose from.
18
18
  class ListCampaigns200ResponseCampaignsInner
19
19
  attr_accessor :id
20
20
 
@@ -27,13 +27,19 @@ module Tremendous
27
27
  # List of IDs of products (different gift cards, charity, etc.) that are available in this campaign.
28
28
  attr_accessor :products
29
29
 
30
+ attr_accessor :webpage_style
31
+
32
+ attr_accessor :email_style
33
+
30
34
  # Attribute mapping from ruby-style variable name to JSON key.
31
35
  def self.attribute_map
32
36
  {
33
37
  :'id' => :'id',
34
38
  :'name' => :'name',
35
39
  :'description' => :'description',
36
- :'products' => :'products'
40
+ :'products' => :'products',
41
+ :'webpage_style' => :'webpage_style',
42
+ :'email_style' => :'email_style'
37
43
  }
38
44
  end
39
45
 
@@ -48,7 +54,9 @@ module Tremendous
48
54
  :'id' => :'String',
49
55
  :'name' => :'String',
50
56
  :'description' => :'String',
51
- :'products' => :'Array<String>'
57
+ :'products' => :'Array<String>',
58
+ :'webpage_style' => :'ListCampaigns200ResponseCampaignsInnerWebpageStyle',
59
+ :'email_style' => :'ListCampaigns200ResponseCampaignsInnerEmailStyle'
52
60
  }
53
61
  end
54
62
 
@@ -76,8 +84,6 @@ module Tremendous
76
84
 
77
85
  if attributes.key?(:'id')
78
86
  self.id = attributes[:'id']
79
- else
80
- self.id = nil
81
87
  end
82
88
 
83
89
  if attributes.key?(:'name')
@@ -99,6 +105,14 @@ module Tremendous
99
105
  else
100
106
  self.products = nil
101
107
  end
108
+
109
+ if attributes.key?(:'webpage_style')
110
+ self.webpage_style = attributes[:'webpage_style']
111
+ end
112
+
113
+ if attributes.key?(:'email_style')
114
+ self.email_style = attributes[:'email_style']
115
+ end
102
116
  end
103
117
 
104
118
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -106,12 +120,8 @@ module Tremendous
106
120
  def list_invalid_properties
107
121
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
108
122
  invalid_properties = Array.new
109
- if @id.nil?
110
- invalid_properties.push('invalid value for "id", id cannot be nil.')
111
- end
112
-
113
123
  pattern = Regexp.new(/[A-Z0-9]{4,20}/)
114
- if @id !~ pattern
124
+ if !@id.nil? && @id !~ pattern
115
125
  invalid_properties.push("invalid value for \"id\", must conform to the pattern #{pattern}.")
116
126
  end
117
127
 
@@ -130,8 +140,7 @@ module Tremendous
130
140
  # @return true if the model is valid
131
141
  def valid?
132
142
  warn '[DEPRECATED] the `valid?` method is obsolete'
133
- return false if @id.nil?
134
- return false if @id !~ Regexp.new(/[A-Z0-9]{4,20}/)
143
+ return false if !@id.nil? && @id !~ Regexp.new(/[A-Z0-9]{4,20}/)
135
144
  return false if @name.nil?
136
145
  return false if @products.nil?
137
146
  true
@@ -160,7 +169,9 @@ module Tremendous
160
169
  id == o.id &&
161
170
  name == o.name &&
162
171
  description == o.description &&
163
- products == o.products
172
+ products == o.products &&
173
+ webpage_style == o.webpage_style &&
174
+ email_style == o.email_style
164
175
  end
165
176
 
166
177
  # @see the `==` method
@@ -172,7 +183,7 @@ module Tremendous
172
183
  # Calculates hash code according to all attributes.
173
184
  # @return [Integer] Hash code
174
185
  def hash
175
- [id, name, description, products].hash
186
+ [id, name, description, products, webpage_style, email_style].hash
176
187
  end
177
188
 
178
189
  # Builds the object from hash
@@ -0,0 +1,270 @@
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
+ # Definition of the email style
18
+ class ListCampaigns200ResponseCampaignsInnerEmailStyle
19
+ # If sending via email, this is how the email will appear to be sent from
20
+ attr_accessor :sender_name
21
+
22
+ # Email subject line
23
+ attr_accessor :subject_line
24
+
25
+ # URL of a publicly-accessible image (png, jpeg, jpg, gif, or svg). This image will be copied to our storage location.
26
+ attr_accessor :logo_image_url
27
+
28
+ # Image height in pixels
29
+ attr_accessor :logo_image_height_px
30
+
31
+ # Logo backgrond color code (hex, rgb, or rgba)
32
+ attr_accessor :logo_background_color
33
+
34
+ # Button color code (hex, rgb, or rgba)
35
+ attr_accessor :button_color
36
+
37
+ # Attribute mapping from ruby-style variable name to JSON key.
38
+ def self.attribute_map
39
+ {
40
+ :'sender_name' => :'sender_name',
41
+ :'subject_line' => :'subject_line',
42
+ :'logo_image_url' => :'logo_image_url',
43
+ :'logo_image_height_px' => :'logo_image_height_px',
44
+ :'logo_background_color' => :'logo_background_color',
45
+ :'button_color' => :'button_color'
46
+ }
47
+ end
48
+
49
+ # Returns all the JSON keys this model knows about
50
+ def self.acceptable_attributes
51
+ attribute_map.values
52
+ end
53
+
54
+ # Attribute type mapping.
55
+ def self.openapi_types
56
+ {
57
+ :'sender_name' => :'String',
58
+ :'subject_line' => :'String',
59
+ :'logo_image_url' => :'String',
60
+ :'logo_image_height_px' => :'Integer',
61
+ :'logo_background_color' => :'String',
62
+ :'button_color' => :'String'
63
+ }
64
+ end
65
+
66
+ # List of attributes with nullable: true
67
+ def self.openapi_nullable
68
+ Set.new([
69
+ :'logo_image_url',
70
+ :'logo_image_height_px',
71
+ :'logo_background_color',
72
+ :'button_color'
73
+ ])
74
+ end
75
+
76
+ # Initializes the object
77
+ # @param [Hash] attributes Model attributes in the form of hash
78
+ def initialize(attributes = {})
79
+ if (!attributes.is_a?(Hash))
80
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::ListCampaigns200ResponseCampaignsInnerEmailStyle` initialize method"
81
+ end
82
+
83
+ # check to see if the attribute exists and convert string to symbol for hash key
84
+ attributes = attributes.each_with_object({}) { |(k, v), h|
85
+ if (!self.class.attribute_map.key?(k.to_sym))
86
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::ListCampaigns200ResponseCampaignsInnerEmailStyle`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
87
+ end
88
+ h[k.to_sym] = v
89
+ }
90
+
91
+ if attributes.key?(:'sender_name')
92
+ self.sender_name = attributes[:'sender_name']
93
+ end
94
+
95
+ if attributes.key?(:'subject_line')
96
+ self.subject_line = attributes[:'subject_line']
97
+ end
98
+
99
+ if attributes.key?(:'logo_image_url')
100
+ self.logo_image_url = attributes[:'logo_image_url']
101
+ end
102
+
103
+ if attributes.key?(:'logo_image_height_px')
104
+ self.logo_image_height_px = attributes[:'logo_image_height_px']
105
+ end
106
+
107
+ if attributes.key?(:'logo_background_color')
108
+ self.logo_background_color = attributes[:'logo_background_color']
109
+ end
110
+
111
+ if attributes.key?(:'button_color')
112
+ self.button_color = attributes[:'button_color']
113
+ end
114
+ end
115
+
116
+ # Show invalid properties with the reasons. Usually used together with valid?
117
+ # @return Array for valid properties with the reasons
118
+ def list_invalid_properties
119
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
120
+ invalid_properties = Array.new
121
+ invalid_properties
122
+ end
123
+
124
+ # Check to see if the all the properties in the model are valid
125
+ # @return true if the model is valid
126
+ def valid?
127
+ warn '[DEPRECATED] the `valid?` method is obsolete'
128
+ true
129
+ end
130
+
131
+ # Checks equality by comparing each attribute.
132
+ # @param [Object] Object to be compared
133
+ def ==(o)
134
+ return true if self.equal?(o)
135
+ self.class == o.class &&
136
+ sender_name == o.sender_name &&
137
+ subject_line == o.subject_line &&
138
+ logo_image_url == o.logo_image_url &&
139
+ logo_image_height_px == o.logo_image_height_px &&
140
+ logo_background_color == o.logo_background_color &&
141
+ button_color == o.button_color
142
+ end
143
+
144
+ # @see the `==` method
145
+ # @param [Object] Object to be compared
146
+ def eql?(o)
147
+ self == o
148
+ end
149
+
150
+ # Calculates hash code according to all attributes.
151
+ # @return [Integer] Hash code
152
+ def hash
153
+ [sender_name, subject_line, logo_image_url, logo_image_height_px, logo_background_color, button_color].hash
154
+ end
155
+
156
+ # Builds the object from hash
157
+ # @param [Hash] attributes Model attributes in the form of hash
158
+ # @return [Object] Returns the model itself
159
+ def self.build_from_hash(attributes)
160
+ return nil unless attributes.is_a?(Hash)
161
+ attributes = attributes.transform_keys(&:to_sym)
162
+ transformed_hash = {}
163
+ openapi_types.each_pair do |key, type|
164
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
165
+ transformed_hash["#{key}"] = nil
166
+ elsif type =~ /\AArray<(.*)>/i
167
+ # check to ensure the input is an array given that the attribute
168
+ # is documented as an array but the input is not
169
+ if attributes[attribute_map[key]].is_a?(Array)
170
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
171
+ end
172
+ elsif !attributes[attribute_map[key]].nil?
173
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
174
+ end
175
+ end
176
+ new(transformed_hash)
177
+ end
178
+
179
+ # Deserializes the data based on type
180
+ # @param string type Data type
181
+ # @param string value Value to be deserialized
182
+ # @return [Object] Deserialized data
183
+ def self._deserialize(type, value)
184
+ case type.to_sym
185
+ when :Time
186
+ Time.parse(value)
187
+ when :Date
188
+ Date.parse(value)
189
+ when :String
190
+ value.to_s
191
+ when :Integer
192
+ value.to_i
193
+ when :Float
194
+ value.to_f
195
+ when :Boolean
196
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
197
+ true
198
+ else
199
+ false
200
+ end
201
+ when :Object
202
+ # generic object (usually a Hash), return directly
203
+ value
204
+ when /\AArray<(?<inner_type>.+)>\z/
205
+ inner_type = Regexp.last_match[:inner_type]
206
+ value.map { |v| _deserialize(inner_type, v) }
207
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
208
+ k_type = Regexp.last_match[:k_type]
209
+ v_type = Regexp.last_match[:v_type]
210
+ {}.tap do |hash|
211
+ value.each do |k, v|
212
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
213
+ end
214
+ end
215
+ else # model
216
+ # models (e.g. Pet) or oneOf
217
+ klass = Tremendous.const_get(type)
218
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
219
+ end
220
+ end
221
+
222
+ # Returns the string representation of the object
223
+ # @return [String] String presentation of the object
224
+ def to_s
225
+ to_hash.to_s
226
+ end
227
+
228
+ # to_body is an alias to to_hash (backward compatibility)
229
+ # @return [Hash] Returns the object in the form of hash
230
+ def to_body
231
+ to_hash
232
+ end
233
+
234
+ # Returns the object in the form of hash
235
+ # @return [Hash] Returns the object in the form of hash
236
+ def to_hash
237
+ hash = {}
238
+ self.class.attribute_map.each_pair do |attr, param|
239
+ value = self.send(attr)
240
+ if value.nil?
241
+ is_nullable = self.class.openapi_nullable.include?(attr)
242
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
243
+ end
244
+
245
+ hash[param] = _to_hash(value)
246
+ end
247
+ hash
248
+ end
249
+
250
+ # Outputs non-array value in the form of hash
251
+ # For object, use to_hash. Otherwise, just return the value
252
+ # @param [Object] value Any valid value
253
+ # @return [Hash] Returns the value in the form of hash
254
+ def _to_hash(value)
255
+ if value.is_a?(Array)
256
+ value.compact.map { |v| _to_hash(v) }
257
+ elsif value.is_a?(Hash)
258
+ {}.tap do |hash|
259
+ value.each { |k, v| hash[k] = _to_hash(v) }
260
+ end
261
+ elsif value.respond_to? :to_hash
262
+ value.to_hash
263
+ else
264
+ value
265
+ end
266
+ end
267
+
268
+ end
269
+
270
+ end
@@ -0,0 +1,270 @@
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
+ # Definition of the webpage style
18
+ class ListCampaigns200ResponseCampaignsInnerWebpageStyle
19
+ # Headline for the reward page
20
+ attr_accessor :headline
21
+
22
+ # Message for the reward page
23
+ attr_accessor :message
24
+
25
+ # URL of a publicly-accessible image (png, jpeg, jpg, gif, or svg). This image will be copied to our storage location.
26
+ attr_accessor :logo_image_url
27
+
28
+ # Image height in pixels
29
+ attr_accessor :logo_image_height_px
30
+
31
+ # Logo backgrond color code (hex, rgb, or rgba)
32
+ attr_accessor :logo_background_color
33
+
34
+ # Backgrond color code (hex, rgb, or rgba)
35
+ attr_accessor :background_color
36
+
37
+ # Attribute mapping from ruby-style variable name to JSON key.
38
+ def self.attribute_map
39
+ {
40
+ :'headline' => :'headline',
41
+ :'message' => :'message',
42
+ :'logo_image_url' => :'logo_image_url',
43
+ :'logo_image_height_px' => :'logo_image_height_px',
44
+ :'logo_background_color' => :'logo_background_color',
45
+ :'background_color' => :'background_color'
46
+ }
47
+ end
48
+
49
+ # Returns all the JSON keys this model knows about
50
+ def self.acceptable_attributes
51
+ attribute_map.values
52
+ end
53
+
54
+ # Attribute type mapping.
55
+ def self.openapi_types
56
+ {
57
+ :'headline' => :'String',
58
+ :'message' => :'String',
59
+ :'logo_image_url' => :'String',
60
+ :'logo_image_height_px' => :'Integer',
61
+ :'logo_background_color' => :'String',
62
+ :'background_color' => :'String'
63
+ }
64
+ end
65
+
66
+ # List of attributes with nullable: true
67
+ def self.openapi_nullable
68
+ Set.new([
69
+ :'logo_image_url',
70
+ :'logo_image_height_px',
71
+ :'logo_background_color',
72
+ :'background_color'
73
+ ])
74
+ end
75
+
76
+ # Initializes the object
77
+ # @param [Hash] attributes Model attributes in the form of hash
78
+ def initialize(attributes = {})
79
+ if (!attributes.is_a?(Hash))
80
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Tremendous::ListCampaigns200ResponseCampaignsInnerWebpageStyle` initialize method"
81
+ end
82
+
83
+ # check to see if the attribute exists and convert string to symbol for hash key
84
+ attributes = attributes.each_with_object({}) { |(k, v), h|
85
+ if (!self.class.attribute_map.key?(k.to_sym))
86
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Tremendous::ListCampaigns200ResponseCampaignsInnerWebpageStyle`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
87
+ end
88
+ h[k.to_sym] = v
89
+ }
90
+
91
+ if attributes.key?(:'headline')
92
+ self.headline = attributes[:'headline']
93
+ end
94
+
95
+ if attributes.key?(:'message')
96
+ self.message = attributes[:'message']
97
+ end
98
+
99
+ if attributes.key?(:'logo_image_url')
100
+ self.logo_image_url = attributes[:'logo_image_url']
101
+ end
102
+
103
+ if attributes.key?(:'logo_image_height_px')
104
+ self.logo_image_height_px = attributes[:'logo_image_height_px']
105
+ end
106
+
107
+ if attributes.key?(:'logo_background_color')
108
+ self.logo_background_color = attributes[:'logo_background_color']
109
+ end
110
+
111
+ if attributes.key?(:'background_color')
112
+ self.background_color = attributes[:'background_color']
113
+ end
114
+ end
115
+
116
+ # Show invalid properties with the reasons. Usually used together with valid?
117
+ # @return Array for valid properties with the reasons
118
+ def list_invalid_properties
119
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
120
+ invalid_properties = Array.new
121
+ invalid_properties
122
+ end
123
+
124
+ # Check to see if the all the properties in the model are valid
125
+ # @return true if the model is valid
126
+ def valid?
127
+ warn '[DEPRECATED] the `valid?` method is obsolete'
128
+ true
129
+ end
130
+
131
+ # Checks equality by comparing each attribute.
132
+ # @param [Object] Object to be compared
133
+ def ==(o)
134
+ return true if self.equal?(o)
135
+ self.class == o.class &&
136
+ headline == o.headline &&
137
+ message == o.message &&
138
+ logo_image_url == o.logo_image_url &&
139
+ logo_image_height_px == o.logo_image_height_px &&
140
+ logo_background_color == o.logo_background_color &&
141
+ background_color == o.background_color
142
+ end
143
+
144
+ # @see the `==` method
145
+ # @param [Object] Object to be compared
146
+ def eql?(o)
147
+ self == o
148
+ end
149
+
150
+ # Calculates hash code according to all attributes.
151
+ # @return [Integer] Hash code
152
+ def hash
153
+ [headline, message, logo_image_url, logo_image_height_px, logo_background_color, background_color].hash
154
+ end
155
+
156
+ # Builds the object from hash
157
+ # @param [Hash] attributes Model attributes in the form of hash
158
+ # @return [Object] Returns the model itself
159
+ def self.build_from_hash(attributes)
160
+ return nil unless attributes.is_a?(Hash)
161
+ attributes = attributes.transform_keys(&:to_sym)
162
+ transformed_hash = {}
163
+ openapi_types.each_pair do |key, type|
164
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
165
+ transformed_hash["#{key}"] = nil
166
+ elsif type =~ /\AArray<(.*)>/i
167
+ # check to ensure the input is an array given that the attribute
168
+ # is documented as an array but the input is not
169
+ if attributes[attribute_map[key]].is_a?(Array)
170
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
171
+ end
172
+ elsif !attributes[attribute_map[key]].nil?
173
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
174
+ end
175
+ end
176
+ new(transformed_hash)
177
+ end
178
+
179
+ # Deserializes the data based on type
180
+ # @param string type Data type
181
+ # @param string value Value to be deserialized
182
+ # @return [Object] Deserialized data
183
+ def self._deserialize(type, value)
184
+ case type.to_sym
185
+ when :Time
186
+ Time.parse(value)
187
+ when :Date
188
+ Date.parse(value)
189
+ when :String
190
+ value.to_s
191
+ when :Integer
192
+ value.to_i
193
+ when :Float
194
+ value.to_f
195
+ when :Boolean
196
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
197
+ true
198
+ else
199
+ false
200
+ end
201
+ when :Object
202
+ # generic object (usually a Hash), return directly
203
+ value
204
+ when /\AArray<(?<inner_type>.+)>\z/
205
+ inner_type = Regexp.last_match[:inner_type]
206
+ value.map { |v| _deserialize(inner_type, v) }
207
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
208
+ k_type = Regexp.last_match[:k_type]
209
+ v_type = Regexp.last_match[:v_type]
210
+ {}.tap do |hash|
211
+ value.each do |k, v|
212
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
213
+ end
214
+ end
215
+ else # model
216
+ # models (e.g. Pet) or oneOf
217
+ klass = Tremendous.const_get(type)
218
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
219
+ end
220
+ end
221
+
222
+ # Returns the string representation of the object
223
+ # @return [String] String presentation of the object
224
+ def to_s
225
+ to_hash.to_s
226
+ end
227
+
228
+ # to_body is an alias to to_hash (backward compatibility)
229
+ # @return [Hash] Returns the object in the form of hash
230
+ def to_body
231
+ to_hash
232
+ end
233
+
234
+ # Returns the object in the form of hash
235
+ # @return [Hash] Returns the object in the form of hash
236
+ def to_hash
237
+ hash = {}
238
+ self.class.attribute_map.each_pair do |attr, param|
239
+ value = self.send(attr)
240
+ if value.nil?
241
+ is_nullable = self.class.openapi_nullable.include?(attr)
242
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
243
+ end
244
+
245
+ hash[param] = _to_hash(value)
246
+ end
247
+ hash
248
+ end
249
+
250
+ # Outputs non-array value in the form of hash
251
+ # For object, use to_hash. Otherwise, just return the value
252
+ # @param [Object] value Any valid value
253
+ # @return [Hash] Returns the value in the form of hash
254
+ def _to_hash(value)
255
+ if value.is_a?(Array)
256
+ value.compact.map { |v| _to_hash(v) }
257
+ elsif value.is_a?(Hash)
258
+ {}.tap do |hash|
259
+ value.each { |k, v| hash[k] = _to_hash(v) }
260
+ end
261
+ elsif value.respond_to? :to_hash
262
+ value.to_hash
263
+ else
264
+ value
265
+ end
266
+ end
267
+
268
+ end
269
+
270
+ end