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