passageidentity 0.2.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +27 -0
  3. data/README.md +18 -61
  4. data/docs/custom/AuthApi.md +141 -0
  5. data/docs/custom/ClientApi.md +107 -0
  6. data/docs/custom/UserApi.md +419 -0
  7. data/docs/generated/AppInfo.md +94 -0
  8. data/docs/generated/AppResponse.md +18 -0
  9. data/docs/generated/AppsApi.md +77 -0
  10. data/docs/generated/AuthMethods.md +22 -0
  11. data/docs/generated/CreateMagicLinkRequest.md +36 -0
  12. data/docs/generated/CreateUserRequest.md +22 -0
  13. data/docs/generated/ElementCustomization.md +56 -0
  14. data/docs/generated/FontFamily.md +15 -0
  15. data/docs/generated/GithubSocialConnection.md +24 -0
  16. data/docs/generated/GoogleSocialConnection.md +24 -0
  17. data/docs/generated/LayoutConfig.md +26 -0
  18. data/docs/generated/Layouts.md +20 -0
  19. data/docs/generated/ListDevicesResponse.md +18 -0
  20. data/docs/generated/MagicLink.md +36 -0
  21. data/docs/generated/MagicLinkAuthMethod.md +22 -0
  22. data/docs/generated/MagicLinkChannel.md +15 -0
  23. data/docs/generated/MagicLinkResponse.md +18 -0
  24. data/docs/generated/MagicLinkType.md +15 -0
  25. data/docs/generated/MagicLinksApi.md +79 -0
  26. data/docs/generated/Model400Error.md +20 -0
  27. data/docs/generated/Model401Error.md +20 -0
  28. data/docs/generated/Model404Error.md +20 -0
  29. data/docs/generated/Model500Error.md +20 -0
  30. data/docs/generated/OtpAuthMethod.md +22 -0
  31. data/docs/generated/PasskeysAuthMethod.md +18 -0
  32. data/docs/generated/README.md +152 -0
  33. data/docs/generated/Technologies.md +15 -0
  34. data/docs/generated/TokensApi.md +78 -0
  35. data/docs/generated/TtlDisplayUnit.md +15 -0
  36. data/docs/generated/UpdateMagicLinkAuthMethod.md +22 -0
  37. data/docs/generated/UpdateOtpAuthMethod.md +22 -0
  38. data/docs/generated/UpdatePasskeysAuthMethod.md +18 -0
  39. data/docs/generated/UpdateUserRequest.md +22 -0
  40. data/docs/generated/UserDevicesApi.md +152 -0
  41. data/docs/generated/UserEventInfo.md +26 -0
  42. data/docs/generated/UserInfo.md +48 -0
  43. data/docs/generated/UserMetadataField.md +28 -0
  44. data/docs/generated/UserMetadataFieldType.md +15 -0
  45. data/docs/generated/UserResponse.md +18 -0
  46. data/docs/generated/UserSocialConnections.md +20 -0
  47. data/docs/generated/UserStatus.md +15 -0
  48. data/docs/generated/UsersApi.md +440 -0
  49. data/docs/generated/WebAuthnDevices.md +34 -0
  50. data/docs/generated/WebAuthnIcons.md +20 -0
  51. data/docs/generated/WebAuthnType.md +15 -0
  52. data/generate.sh +31 -0
  53. data/lib/openapi_client/api/apps_api.rb +85 -0
  54. data/lib/openapi_client/api/magic_links_api.rb +96 -0
  55. data/lib/openapi_client/api/tokens_api.rb +91 -0
  56. data/lib/openapi_client/api/user_devices_api.rb +166 -0
  57. data/lib/openapi_client/api/users_api.rb +452 -0
  58. data/lib/openapi_client/api_client.rb +431 -0
  59. data/lib/openapi_client/api_error.rb +58 -0
  60. data/lib/openapi_client/configuration.rb +383 -0
  61. data/lib/openapi_client/models/app_info.rb +853 -0
  62. data/lib/openapi_client/models/app_response.rb +221 -0
  63. data/lib/openapi_client/models/auth_methods.rb +254 -0
  64. data/lib/openapi_client/models/create_magic_link_request.rb +374 -0
  65. data/lib/openapi_client/models/create_user_request.rb +234 -0
  66. data/lib/openapi_client/models/element_customization.rb +457 -0
  67. data/lib/openapi_client/models/font_family.rb +58 -0
  68. data/lib/openapi_client/models/github_social_connection.rb +271 -0
  69. data/lib/openapi_client/models/google_social_connection.rb +271 -0
  70. data/lib/openapi_client/models/layout_config.rb +285 -0
  71. data/lib/openapi_client/models/layouts.rb +241 -0
  72. data/lib/openapi_client/models/list_devices_response.rb +223 -0
  73. data/lib/openapi_client/models/magic_link.rb +387 -0
  74. data/lib/openapi_client/models/magic_link_auth_method.rb +302 -0
  75. data/lib/openapi_client/models/magic_link_channel.rb +40 -0
  76. data/lib/openapi_client/models/magic_link_response.rb +221 -0
  77. data/lib/openapi_client/models/magic_link_type.rb +40 -0
  78. data/lib/openapi_client/models/model400_error.rb +271 -0
  79. data/lib/openapi_client/models/model401_error.rb +271 -0
  80. data/lib/openapi_client/models/model404_error.rb +271 -0
  81. data/lib/openapi_client/models/model500_error.rb +271 -0
  82. data/lib/openapi_client/models/otp_auth_method.rb +302 -0
  83. data/lib/openapi_client/models/passkeys_auth_method.rb +228 -0
  84. data/lib/openapi_client/models/technologies.rb +46 -0
  85. data/lib/openapi_client/models/ttl_display_unit.rb +42 -0
  86. data/lib/openapi_client/models/update_magic_link_auth_method.rb +276 -0
  87. data/lib/openapi_client/models/update_otp_auth_method.rb +276 -0
  88. data/lib/openapi_client/models/update_passkeys_auth_method.rb +216 -0
  89. data/lib/openapi_client/models/update_user_request.rb +232 -0
  90. data/lib/openapi_client/models/user_event_info.rb +285 -0
  91. data/lib/openapi_client/models/user_info.rb +486 -0
  92. data/lib/openapi_client/models/user_metadata_field.rb +323 -0
  93. data/lib/openapi_client/models/user_metadata_field_type.rb +44 -0
  94. data/lib/openapi_client/models/user_response.rb +221 -0
  95. data/lib/openapi_client/models/user_social_connections.rb +223 -0
  96. data/lib/openapi_client/models/user_status.rb +41 -0
  97. data/lib/openapi_client/models/web_authn_devices.rb +378 -0
  98. data/lib/openapi_client/models/web_authn_icons.rb +230 -0
  99. data/lib/openapi_client/models/web_authn_type.rb +41 -0
  100. data/lib/openapi_client/version.rb +15 -0
  101. data/lib/openapi_client.rb +83 -0
  102. data/lib/passageidentity/auth.rb +32 -5
  103. data/lib/passageidentity/client.rb +17 -121
  104. data/lib/passageidentity/user_api.rb +29 -131
  105. data/lib/passageidentity/version.rb +5 -0
  106. data/openapitools.json +7 -0
  107. data/passageidentity.gemspec +3 -1
  108. data/tests/auth_test.rb +6 -1
  109. data/tests/magic_link_test.rb +5 -4
  110. data/tests/user_api_test.rb +2 -2
  111. metadata +103 -2
@@ -0,0 +1,271 @@
1
+ =begin
2
+ #Passage Management API
3
+
4
+ #Passage's management API to manage your Passage apps and users.
5
+
6
+ The version of the OpenAPI document: 1
7
+ Contact: support@passage.id
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 7.1.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module OpenapiClient
17
+ class GithubSocialConnection
18
+ # The external ID of the Social Connection.
19
+ attr_accessor :provider_id
20
+
21
+ attr_accessor :created_at
22
+
23
+ attr_accessor :last_login_at
24
+
25
+ # The email of connected social user.
26
+ attr_accessor :provider_identifier
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'provider_id' => :'provider_id',
32
+ :'created_at' => :'created_at',
33
+ :'last_login_at' => :'last_login_at',
34
+ :'provider_identifier' => :'provider_identifier'
35
+ }
36
+ end
37
+
38
+ # Returns all the JSON keys this model knows about
39
+ def self.acceptable_attributes
40
+ attribute_map.values
41
+ end
42
+
43
+ # Attribute type mapping.
44
+ def self.openapi_types
45
+ {
46
+ :'provider_id' => :'String',
47
+ :'created_at' => :'Time',
48
+ :'last_login_at' => :'Time',
49
+ :'provider_identifier' => :'String'
50
+ }
51
+ end
52
+
53
+ # List of attributes with nullable: true
54
+ def self.openapi_nullable
55
+ Set.new([
56
+ ])
57
+ end
58
+
59
+ # Initializes the object
60
+ # @param [Hash] attributes Model attributes in the form of hash
61
+ def initialize(attributes = {})
62
+ if (!attributes.is_a?(Hash))
63
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::GithubSocialConnection` initialize method"
64
+ end
65
+
66
+ # check to see if the attribute exists and convert string to symbol for hash key
67
+ attributes = attributes.each_with_object({}) { |(k, v), h|
68
+ if (!self.class.attribute_map.key?(k.to_sym))
69
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::GithubSocialConnection`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
70
+ end
71
+ h[k.to_sym] = v
72
+ }
73
+
74
+ if attributes.key?(:'provider_id')
75
+ self.provider_id = attributes[:'provider_id']
76
+ else
77
+ self.provider_id = nil
78
+ end
79
+
80
+ if attributes.key?(:'created_at')
81
+ self.created_at = attributes[:'created_at']
82
+ else
83
+ self.created_at = nil
84
+ end
85
+
86
+ if attributes.key?(:'last_login_at')
87
+ self.last_login_at = attributes[:'last_login_at']
88
+ else
89
+ self.last_login_at = nil
90
+ end
91
+
92
+ if attributes.key?(:'provider_identifier')
93
+ self.provider_identifier = attributes[:'provider_identifier']
94
+ else
95
+ self.provider_identifier = nil
96
+ end
97
+ end
98
+
99
+ # Show invalid properties with the reasons. Usually used together with valid?
100
+ # @return Array for valid properties with the reasons
101
+ def list_invalid_properties
102
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
103
+ invalid_properties = Array.new
104
+ if @provider_id.nil?
105
+ invalid_properties.push('invalid value for "provider_id", provider_id cannot be nil.')
106
+ end
107
+
108
+ if @created_at.nil?
109
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
110
+ end
111
+
112
+ if @last_login_at.nil?
113
+ invalid_properties.push('invalid value for "last_login_at", last_login_at cannot be nil.')
114
+ end
115
+
116
+ if @provider_identifier.nil?
117
+ invalid_properties.push('invalid value for "provider_identifier", provider_identifier cannot be nil.')
118
+ end
119
+
120
+ invalid_properties
121
+ end
122
+
123
+ # Check to see if the all the properties in the model are valid
124
+ # @return true if the model is valid
125
+ def valid?
126
+ warn '[DEPRECATED] the `valid?` method is obsolete'
127
+ return false if @provider_id.nil?
128
+ return false if @created_at.nil?
129
+ return false if @last_login_at.nil?
130
+ return false if @provider_identifier.nil?
131
+ true
132
+ end
133
+
134
+ # Checks equality by comparing each attribute.
135
+ # @param [Object] Object to be compared
136
+ def ==(o)
137
+ return true if self.equal?(o)
138
+ self.class == o.class &&
139
+ provider_id == o.provider_id &&
140
+ created_at == o.created_at &&
141
+ last_login_at == o.last_login_at &&
142
+ provider_identifier == o.provider_identifier
143
+ end
144
+
145
+ # @see the `==` method
146
+ # @param [Object] Object to be compared
147
+ def eql?(o)
148
+ self == o
149
+ end
150
+
151
+ # Calculates hash code according to all attributes.
152
+ # @return [Integer] Hash code
153
+ def hash
154
+ [provider_id, created_at, last_login_at, provider_identifier].hash
155
+ end
156
+
157
+ # Builds the object from hash
158
+ # @param [Hash] attributes Model attributes in the form of hash
159
+ # @return [Object] Returns the model itself
160
+ def self.build_from_hash(attributes)
161
+ return nil unless attributes.is_a?(Hash)
162
+ attributes = attributes.transform_keys(&:to_sym)
163
+ transformed_hash = {}
164
+ openapi_types.each_pair do |key, type|
165
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
166
+ transformed_hash["#{key}"] = nil
167
+ elsif type =~ /\AArray<(.*)>/i
168
+ # check to ensure the input is an array given that the attribute
169
+ # is documented as an array but the input is not
170
+ if attributes[attribute_map[key]].is_a?(Array)
171
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
172
+ end
173
+ elsif !attributes[attribute_map[key]].nil?
174
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
175
+ end
176
+ end
177
+ new(transformed_hash)
178
+ end
179
+
180
+ # Deserializes the data based on type
181
+ # @param string type Data type
182
+ # @param string value Value to be deserialized
183
+ # @return [Object] Deserialized data
184
+ def self._deserialize(type, value)
185
+ case type.to_sym
186
+ when :Time
187
+ Time.parse(value)
188
+ when :Date
189
+ Date.parse(value)
190
+ when :String
191
+ value.to_s
192
+ when :Integer
193
+ value.to_i
194
+ when :Float
195
+ value.to_f
196
+ when :Boolean
197
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
198
+ true
199
+ else
200
+ false
201
+ end
202
+ when :Object
203
+ # generic object (usually a Hash), return directly
204
+ value
205
+ when /\AArray<(?<inner_type>.+)>\z/
206
+ inner_type = Regexp.last_match[:inner_type]
207
+ value.map { |v| _deserialize(inner_type, v) }
208
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
209
+ k_type = Regexp.last_match[:k_type]
210
+ v_type = Regexp.last_match[:v_type]
211
+ {}.tap do |hash|
212
+ value.each do |k, v|
213
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
214
+ end
215
+ end
216
+ else # model
217
+ # models (e.g. Pet) or oneOf
218
+ klass = OpenapiClient.const_get(type)
219
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
220
+ end
221
+ end
222
+
223
+ # Returns the string representation of the object
224
+ # @return [String] String presentation of the object
225
+ def to_s
226
+ to_hash.to_s
227
+ end
228
+
229
+ # to_body is an alias to to_hash (backward compatibility)
230
+ # @return [Hash] Returns the object in the form of hash
231
+ def to_body
232
+ to_hash
233
+ end
234
+
235
+ # Returns the object in the form of hash
236
+ # @return [Hash] Returns the object in the form of hash
237
+ def to_hash
238
+ hash = {}
239
+ self.class.attribute_map.each_pair do |attr, param|
240
+ value = self.send(attr)
241
+ if value.nil?
242
+ is_nullable = self.class.openapi_nullable.include?(attr)
243
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
244
+ end
245
+
246
+ hash[param] = _to_hash(value)
247
+ end
248
+ hash
249
+ end
250
+
251
+ # Outputs non-array value in the form of hash
252
+ # For object, use to_hash. Otherwise, just return the value
253
+ # @param [Object] value Any valid value
254
+ # @return [Hash] Returns the value in the form of hash
255
+ def _to_hash(value)
256
+ if value.is_a?(Array)
257
+ value.compact.map { |v| _to_hash(v) }
258
+ elsif value.is_a?(Hash)
259
+ {}.tap do |hash|
260
+ value.each { |k, v| hash[k] = _to_hash(v) }
261
+ end
262
+ elsif value.respond_to? :to_hash
263
+ value.to_hash
264
+ else
265
+ value
266
+ end
267
+ end
268
+
269
+ end
270
+
271
+ end
@@ -0,0 +1,271 @@
1
+ =begin
2
+ #Passage Management API
3
+
4
+ #Passage's management API to manage your Passage apps and users.
5
+
6
+ The version of the OpenAPI document: 1
7
+ Contact: support@passage.id
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 7.1.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module OpenapiClient
17
+ class GoogleSocialConnection
18
+ # The external ID of the Social Connection.
19
+ attr_accessor :provider_id
20
+
21
+ attr_accessor :created_at
22
+
23
+ attr_accessor :last_login_at
24
+
25
+ # The email of connected social user.
26
+ attr_accessor :provider_identifier
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'provider_id' => :'provider_id',
32
+ :'created_at' => :'created_at',
33
+ :'last_login_at' => :'last_login_at',
34
+ :'provider_identifier' => :'provider_identifier'
35
+ }
36
+ end
37
+
38
+ # Returns all the JSON keys this model knows about
39
+ def self.acceptable_attributes
40
+ attribute_map.values
41
+ end
42
+
43
+ # Attribute type mapping.
44
+ def self.openapi_types
45
+ {
46
+ :'provider_id' => :'String',
47
+ :'created_at' => :'Time',
48
+ :'last_login_at' => :'Time',
49
+ :'provider_identifier' => :'String'
50
+ }
51
+ end
52
+
53
+ # List of attributes with nullable: true
54
+ def self.openapi_nullable
55
+ Set.new([
56
+ ])
57
+ end
58
+
59
+ # Initializes the object
60
+ # @param [Hash] attributes Model attributes in the form of hash
61
+ def initialize(attributes = {})
62
+ if (!attributes.is_a?(Hash))
63
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::GoogleSocialConnection` initialize method"
64
+ end
65
+
66
+ # check to see if the attribute exists and convert string to symbol for hash key
67
+ attributes = attributes.each_with_object({}) { |(k, v), h|
68
+ if (!self.class.attribute_map.key?(k.to_sym))
69
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::GoogleSocialConnection`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
70
+ end
71
+ h[k.to_sym] = v
72
+ }
73
+
74
+ if attributes.key?(:'provider_id')
75
+ self.provider_id = attributes[:'provider_id']
76
+ else
77
+ self.provider_id = nil
78
+ end
79
+
80
+ if attributes.key?(:'created_at')
81
+ self.created_at = attributes[:'created_at']
82
+ else
83
+ self.created_at = nil
84
+ end
85
+
86
+ if attributes.key?(:'last_login_at')
87
+ self.last_login_at = attributes[:'last_login_at']
88
+ else
89
+ self.last_login_at = nil
90
+ end
91
+
92
+ if attributes.key?(:'provider_identifier')
93
+ self.provider_identifier = attributes[:'provider_identifier']
94
+ else
95
+ self.provider_identifier = nil
96
+ end
97
+ end
98
+
99
+ # Show invalid properties with the reasons. Usually used together with valid?
100
+ # @return Array for valid properties with the reasons
101
+ def list_invalid_properties
102
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
103
+ invalid_properties = Array.new
104
+ if @provider_id.nil?
105
+ invalid_properties.push('invalid value for "provider_id", provider_id cannot be nil.')
106
+ end
107
+
108
+ if @created_at.nil?
109
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
110
+ end
111
+
112
+ if @last_login_at.nil?
113
+ invalid_properties.push('invalid value for "last_login_at", last_login_at cannot be nil.')
114
+ end
115
+
116
+ if @provider_identifier.nil?
117
+ invalid_properties.push('invalid value for "provider_identifier", provider_identifier cannot be nil.')
118
+ end
119
+
120
+ invalid_properties
121
+ end
122
+
123
+ # Check to see if the all the properties in the model are valid
124
+ # @return true if the model is valid
125
+ def valid?
126
+ warn '[DEPRECATED] the `valid?` method is obsolete'
127
+ return false if @provider_id.nil?
128
+ return false if @created_at.nil?
129
+ return false if @last_login_at.nil?
130
+ return false if @provider_identifier.nil?
131
+ true
132
+ end
133
+
134
+ # Checks equality by comparing each attribute.
135
+ # @param [Object] Object to be compared
136
+ def ==(o)
137
+ return true if self.equal?(o)
138
+ self.class == o.class &&
139
+ provider_id == o.provider_id &&
140
+ created_at == o.created_at &&
141
+ last_login_at == o.last_login_at &&
142
+ provider_identifier == o.provider_identifier
143
+ end
144
+
145
+ # @see the `==` method
146
+ # @param [Object] Object to be compared
147
+ def eql?(o)
148
+ self == o
149
+ end
150
+
151
+ # Calculates hash code according to all attributes.
152
+ # @return [Integer] Hash code
153
+ def hash
154
+ [provider_id, created_at, last_login_at, provider_identifier].hash
155
+ end
156
+
157
+ # Builds the object from hash
158
+ # @param [Hash] attributes Model attributes in the form of hash
159
+ # @return [Object] Returns the model itself
160
+ def self.build_from_hash(attributes)
161
+ return nil unless attributes.is_a?(Hash)
162
+ attributes = attributes.transform_keys(&:to_sym)
163
+ transformed_hash = {}
164
+ openapi_types.each_pair do |key, type|
165
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
166
+ transformed_hash["#{key}"] = nil
167
+ elsif type =~ /\AArray<(.*)>/i
168
+ # check to ensure the input is an array given that the attribute
169
+ # is documented as an array but the input is not
170
+ if attributes[attribute_map[key]].is_a?(Array)
171
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
172
+ end
173
+ elsif !attributes[attribute_map[key]].nil?
174
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
175
+ end
176
+ end
177
+ new(transformed_hash)
178
+ end
179
+
180
+ # Deserializes the data based on type
181
+ # @param string type Data type
182
+ # @param string value Value to be deserialized
183
+ # @return [Object] Deserialized data
184
+ def self._deserialize(type, value)
185
+ case type.to_sym
186
+ when :Time
187
+ Time.parse(value)
188
+ when :Date
189
+ Date.parse(value)
190
+ when :String
191
+ value.to_s
192
+ when :Integer
193
+ value.to_i
194
+ when :Float
195
+ value.to_f
196
+ when :Boolean
197
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
198
+ true
199
+ else
200
+ false
201
+ end
202
+ when :Object
203
+ # generic object (usually a Hash), return directly
204
+ value
205
+ when /\AArray<(?<inner_type>.+)>\z/
206
+ inner_type = Regexp.last_match[:inner_type]
207
+ value.map { |v| _deserialize(inner_type, v) }
208
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
209
+ k_type = Regexp.last_match[:k_type]
210
+ v_type = Regexp.last_match[:v_type]
211
+ {}.tap do |hash|
212
+ value.each do |k, v|
213
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
214
+ end
215
+ end
216
+ else # model
217
+ # models (e.g. Pet) or oneOf
218
+ klass = OpenapiClient.const_get(type)
219
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
220
+ end
221
+ end
222
+
223
+ # Returns the string representation of the object
224
+ # @return [String] String presentation of the object
225
+ def to_s
226
+ to_hash.to_s
227
+ end
228
+
229
+ # to_body is an alias to to_hash (backward compatibility)
230
+ # @return [Hash] Returns the object in the form of hash
231
+ def to_body
232
+ to_hash
233
+ end
234
+
235
+ # Returns the object in the form of hash
236
+ # @return [Hash] Returns the object in the form of hash
237
+ def to_hash
238
+ hash = {}
239
+ self.class.attribute_map.each_pair do |attr, param|
240
+ value = self.send(attr)
241
+ if value.nil?
242
+ is_nullable = self.class.openapi_nullable.include?(attr)
243
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
244
+ end
245
+
246
+ hash[param] = _to_hash(value)
247
+ end
248
+ hash
249
+ end
250
+
251
+ # Outputs non-array value in the form of hash
252
+ # For object, use to_hash. Otherwise, just return the value
253
+ # @param [Object] value Any valid value
254
+ # @return [Hash] Returns the value in the form of hash
255
+ def _to_hash(value)
256
+ if value.is_a?(Array)
257
+ value.compact.map { |v| _to_hash(v) }
258
+ elsif value.is_a?(Hash)
259
+ {}.tap do |hash|
260
+ value.each { |k, v| hash[k] = _to_hash(v) }
261
+ end
262
+ elsif value.respond_to? :to_hash
263
+ value.to_hash
264
+ else
265
+ value
266
+ end
267
+ end
268
+
269
+ end
270
+
271
+ end