ory-kratos-client 0.4.6.alpha1 → 0.5.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +82 -60
  3. data/docs/AdminApi.md +208 -98
  4. data/docs/CompleteSelfServiceLoginFlowWithPasswordMethod.md +21 -0
  5. data/docs/CompleteSelfServiceRecoveryFlowWithLinkMethod.md +19 -0
  6. data/docs/CompleteSelfServiceSettingsFlowWithPasswordMethod.md +19 -0
  7. data/docs/CompleteSelfServiceVerificationFlowWithLinkMethod.md +19 -0
  8. data/docs/CreateIdentity.md +19 -0
  9. data/docs/CreateRecoveryLink.md +19 -0
  10. data/docs/ErrorContainer.md +2 -2
  11. data/docs/Identity.md +1 -1
  12. data/docs/LoginFlow.md +33 -0
  13. data/docs/LoginFlowMethod.md +19 -0
  14. data/docs/LoginFlowMethodConfig.md +25 -0
  15. data/docs/LoginViaApiResponse.md +19 -0
  16. data/docs/Message.md +1 -1
  17. data/docs/PublicApi.md +589 -197
  18. data/docs/RecoveryFlow.md +33 -0
  19. data/docs/RecoveryFlowMethod.md +19 -0
  20. data/docs/RecoveryFlowMethodConfig.md +23 -0
  21. data/docs/RecoveryLink.md +19 -0
  22. data/docs/RegistrationFlow.md +31 -0
  23. data/docs/RegistrationFlowMethod.md +19 -0
  24. data/docs/RegistrationFlowMethodConfig.md +25 -0
  25. data/docs/RegistrationViaApiResponse.md +21 -0
  26. data/docs/RevokeSession.md +17 -0
  27. data/docs/Session.md +6 -4
  28. data/docs/SettingsFlow.md +35 -0
  29. data/docs/SettingsFlowMethod.md +19 -0
  30. data/docs/SettingsFlowMethodConfig.md +23 -0
  31. data/docs/SettingsViaApiResponse.md +19 -0
  32. data/docs/UpdateIdentity.md +19 -0
  33. data/docs/VerifiableAddress.md +3 -3
  34. data/docs/VerificationFlow.md +33 -0
  35. data/docs/VerificationFlowMethod.md +19 -0
  36. data/docs/VerificationFlowMethodConfig.md +23 -0
  37. data/lib/ory-kratos-client.rb +28 -17
  38. data/lib/ory-kratos-client/api/admin_api.rb +277 -149
  39. data/lib/ory-kratos-client/api/health_api.rb +1 -1
  40. data/lib/ory-kratos-client/api/public_api.rb +713 -297
  41. data/lib/ory-kratos-client/api/version_api.rb +1 -1
  42. data/lib/ory-kratos-client/api_client.rb +2 -1
  43. data/lib/ory-kratos-client/api_error.rb +1 -1
  44. data/lib/ory-kratos-client/configuration.rb +8 -1
  45. data/lib/ory-kratos-client/models/complete_self_service_login_flow_with_password_method.rb +227 -0
  46. data/lib/ory-kratos-client/models/complete_self_service_recovery_flow_with_link_method.rb +217 -0
  47. data/lib/ory-kratos-client/models/complete_self_service_settings_flow_with_password_method.rb +222 -0
  48. data/lib/ory-kratos-client/models/complete_self_service_verification_flow_with_link_method.rb +217 -0
  49. data/lib/ory-kratos-client/models/create_identity.rb +227 -0
  50. data/lib/ory-kratos-client/models/create_recovery_link.rb +238 -0
  51. data/lib/ory-kratos-client/models/error_container.rb +12 -1
  52. data/lib/ory-kratos-client/models/form_field.rb +1 -1
  53. data/lib/ory-kratos-client/models/generic_error.rb +1 -1
  54. data/lib/ory-kratos-client/models/generic_error_payload.rb +1 -1
  55. data/lib/ory-kratos-client/models/health_not_ready_status.rb +1 -1
  56. data/lib/ory-kratos-client/models/health_status.rb +1 -1
  57. data/lib/ory-kratos-client/models/identity.rb +6 -1
  58. data/lib/ory-kratos-client/models/login_flow.rb +315 -0
  59. data/lib/ory-kratos-client/models/login_flow_method.rb +226 -0
  60. data/lib/ory-kratos-client/models/login_flow_method_config.rb +267 -0
  61. data/lib/ory-kratos-client/models/login_via_api_response.rb +227 -0
  62. data/lib/ory-kratos-client/models/message.rb +2 -1
  63. data/lib/ory-kratos-client/models/recovery_address.rb +1 -1
  64. data/lib/ory-kratos-client/models/recovery_flow.rb +319 -0
  65. data/lib/ory-kratos-client/models/recovery_flow_method.rb +226 -0
  66. data/lib/ory-kratos-client/models/recovery_flow_method_config.rb +255 -0
  67. data/lib/ory-kratos-client/models/recovery_link.rb +222 -0
  68. data/lib/ory-kratos-client/models/registration_flow.rb +304 -0
  69. data/lib/ory-kratos-client/models/registration_flow_method.rb +226 -0
  70. data/lib/ory-kratos-client/models/registration_flow_method_config.rb +267 -0
  71. data/lib/ory-kratos-client/models/registration_via_api_response.rb +236 -0
  72. data/lib/ory-kratos-client/models/revoke_session.rb +212 -0
  73. data/lib/ory-kratos-client/models/session.rb +28 -19
  74. data/lib/ory-kratos-client/models/settings_flow.rb +333 -0
  75. data/lib/ory-kratos-client/models/settings_flow_method.rb +226 -0
  76. data/lib/ory-kratos-client/models/settings_flow_method_config.rb +255 -0
  77. data/lib/ory-kratos-client/models/settings_via_api_response.rb +226 -0
  78. data/lib/ory-kratos-client/models/update_identity.rb +222 -0
  79. data/lib/ory-kratos-client/models/verifiable_address.rb +16 -16
  80. data/lib/ory-kratos-client/models/verification_flow.rb +299 -0
  81. data/lib/ory-kratos-client/models/verification_flow_method.rb +226 -0
  82. data/lib/ory-kratos-client/models/verification_flow_method_config.rb +255 -0
  83. data/lib/ory-kratos-client/models/version.rb +1 -1
  84. data/lib/ory-kratos-client/version.rb +2 -2
  85. data/ory-kratos-client.gemspec +1 -1
  86. data/spec/models/complete_self_service_login_flow_with_password_method_spec.rb +53 -0
  87. data/spec/models/complete_self_service_recovery_flow_with_link_method_spec.rb +47 -0
  88. data/spec/models/complete_self_service_settings_flow_with_password_method_spec.rb +47 -0
  89. data/spec/models/complete_self_service_verification_flow_with_link_method_spec.rb +47 -0
  90. data/spec/models/create_identity_spec.rb +47 -0
  91. data/spec/models/create_recovery_link_spec.rb +47 -0
  92. data/spec/models/login_flow_method_config_spec.rb +65 -0
  93. data/spec/models/login_flow_method_spec.rb +47 -0
  94. data/spec/models/login_flow_spec.rb +89 -0
  95. data/spec/models/login_via_api_response_spec.rb +47 -0
  96. data/spec/models/recovery_flow_method_config_spec.rb +59 -0
  97. data/spec/models/recovery_flow_method_spec.rb +47 -0
  98. data/spec/models/recovery_flow_spec.rb +89 -0
  99. data/spec/models/recovery_link_spec.rb +47 -0
  100. data/spec/models/registration_flow_method_config_spec.rb +65 -0
  101. data/spec/models/registration_flow_method_spec.rb +47 -0
  102. data/spec/models/registration_flow_spec.rb +83 -0
  103. data/spec/models/registration_via_api_response_spec.rb +53 -0
  104. data/spec/models/revoke_session_spec.rb +41 -0
  105. data/spec/models/settings_flow_method_config_spec.rb +59 -0
  106. data/spec/models/settings_flow_method_spec.rb +47 -0
  107. data/spec/models/settings_flow_spec.rb +95 -0
  108. data/spec/models/settings_via_api_response_spec.rb +47 -0
  109. data/spec/models/update_identity_spec.rb +47 -0
  110. data/spec/models/verification_flow_method_config_spec.rb +59 -0
  111. data/spec/models/verification_flow_method_spec.rb +47 -0
  112. data/spec/models/verification_flow_spec.rb +89 -0
  113. metadata +133 -25
@@ -0,0 +1,333 @@
1
+ =begin
2
+ #Ory Kratos
3
+
4
+ #Welcome to the ORY Kratos HTTP API documentation!
5
+
6
+ The version of the OpenAPI document: v0.5.0-alpha.1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module OryHydraClient
16
+ # This flow is used when an identity wants to update settings (e.g. profile data, passwords, ...) in a selfservice manner. We recommend reading the [User Settings Documentation](../self-service/flows/user-settings)
17
+ class SettingsFlow
18
+ # Active, if set, contains the registration method that is being used. It is initially not set.
19
+ attr_accessor :active
20
+
21
+ # ExpiresAt is the time (UTC) when the flow expires. If the user still wishes to update the setting, a new flow has to be initiated.
22
+ attr_accessor :expires_at
23
+
24
+ attr_accessor :id
25
+
26
+ attr_accessor :identity
27
+
28
+ # IssuedAt is the time (UTC) when the flow occurred.
29
+ attr_accessor :issued_at
30
+
31
+ attr_accessor :messages
32
+
33
+ # Methods contains context for all enabled registration methods. If a settings flow has been processed, but for example the first name is empty, this will contain error messages.
34
+ attr_accessor :methods
35
+
36
+ # RequestURL is the initial URL that was requested from ORY Kratos. It can be used to forward information contained in the URL's path or query for example.
37
+ attr_accessor :request_url
38
+
39
+ attr_accessor :state
40
+
41
+ # The flow type can either be `api` or `browser`.
42
+ attr_accessor :type
43
+
44
+ # Attribute mapping from ruby-style variable name to JSON key.
45
+ def self.attribute_map
46
+ {
47
+ :'active' => :'active',
48
+ :'expires_at' => :'expires_at',
49
+ :'id' => :'id',
50
+ :'identity' => :'identity',
51
+ :'issued_at' => :'issued_at',
52
+ :'messages' => :'messages',
53
+ :'methods' => :'methods',
54
+ :'request_url' => :'request_url',
55
+ :'state' => :'state',
56
+ :'type' => :'type'
57
+ }
58
+ end
59
+
60
+ # Attribute type mapping.
61
+ def self.openapi_types
62
+ {
63
+ :'active' => :'String',
64
+ :'expires_at' => :'DateTime',
65
+ :'id' => :'String',
66
+ :'identity' => :'Identity',
67
+ :'issued_at' => :'DateTime',
68
+ :'messages' => :'Array<Message>',
69
+ :'methods' => :'Hash<String, SettingsFlowMethod>',
70
+ :'request_url' => :'String',
71
+ :'state' => :'String',
72
+ :'type' => :'String'
73
+ }
74
+ end
75
+
76
+ # List of attributes with nullable: true
77
+ def self.openapi_nullable
78
+ Set.new([
79
+ ])
80
+ end
81
+
82
+ # Initializes the object
83
+ # @param [Hash] attributes Model attributes in the form of hash
84
+ def initialize(attributes = {})
85
+ if (!attributes.is_a?(Hash))
86
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OryHydraClient::SettingsFlow` initialize method"
87
+ end
88
+
89
+ # check to see if the attribute exists and convert string to symbol for hash key
90
+ attributes = attributes.each_with_object({}) { |(k, v), h|
91
+ if (!self.class.attribute_map.key?(k.to_sym))
92
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OryHydraClient::SettingsFlow`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
93
+ end
94
+ h[k.to_sym] = v
95
+ }
96
+
97
+ if attributes.key?(:'active')
98
+ self.active = attributes[:'active']
99
+ end
100
+
101
+ if attributes.key?(:'expires_at')
102
+ self.expires_at = attributes[:'expires_at']
103
+ end
104
+
105
+ if attributes.key?(:'id')
106
+ self.id = attributes[:'id']
107
+ end
108
+
109
+ if attributes.key?(:'identity')
110
+ self.identity = attributes[:'identity']
111
+ end
112
+
113
+ if attributes.key?(:'issued_at')
114
+ self.issued_at = attributes[:'issued_at']
115
+ end
116
+
117
+ if attributes.key?(:'messages')
118
+ if (value = attributes[:'messages']).is_a?(Array)
119
+ self.messages = value
120
+ end
121
+ end
122
+
123
+ if attributes.key?(:'methods')
124
+ if (value = attributes[:'methods']).is_a?(Hash)
125
+ self.methods = value
126
+ end
127
+ end
128
+
129
+ if attributes.key?(:'request_url')
130
+ self.request_url = attributes[:'request_url']
131
+ end
132
+
133
+ if attributes.key?(:'state')
134
+ self.state = attributes[:'state']
135
+ end
136
+
137
+ if attributes.key?(:'type')
138
+ self.type = attributes[:'type']
139
+ end
140
+ end
141
+
142
+ # Show invalid properties with the reasons. Usually used together with valid?
143
+ # @return Array for valid properties with the reasons
144
+ def list_invalid_properties
145
+ invalid_properties = Array.new
146
+ if @expires_at.nil?
147
+ invalid_properties.push('invalid value for "expires_at", expires_at cannot be nil.')
148
+ end
149
+
150
+ if @id.nil?
151
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
152
+ end
153
+
154
+ if @identity.nil?
155
+ invalid_properties.push('invalid value for "identity", identity cannot be nil.')
156
+ end
157
+
158
+ if @issued_at.nil?
159
+ invalid_properties.push('invalid value for "issued_at", issued_at cannot be nil.')
160
+ end
161
+
162
+ if @methods.nil?
163
+ invalid_properties.push('invalid value for "methods", methods cannot be nil.')
164
+ end
165
+
166
+ if @request_url.nil?
167
+ invalid_properties.push('invalid value for "request_url", request_url cannot be nil.')
168
+ end
169
+
170
+ if @state.nil?
171
+ invalid_properties.push('invalid value for "state", state cannot be nil.')
172
+ end
173
+
174
+ invalid_properties
175
+ end
176
+
177
+ # Check to see if the all the properties in the model are valid
178
+ # @return true if the model is valid
179
+ def valid?
180
+ return false if @expires_at.nil?
181
+ return false if @id.nil?
182
+ return false if @identity.nil?
183
+ return false if @issued_at.nil?
184
+ return false if @methods.nil?
185
+ return false if @request_url.nil?
186
+ return false if @state.nil?
187
+ true
188
+ end
189
+
190
+ # Checks equality by comparing each attribute.
191
+ # @param [Object] Object to be compared
192
+ def ==(o)
193
+ return true if self.equal?(o)
194
+ self.class == o.class &&
195
+ active == o.active &&
196
+ expires_at == o.expires_at &&
197
+ id == o.id &&
198
+ identity == o.identity &&
199
+ issued_at == o.issued_at &&
200
+ messages == o.messages &&
201
+ methods == o.methods &&
202
+ request_url == o.request_url &&
203
+ state == o.state &&
204
+ type == o.type
205
+ end
206
+
207
+ # @see the `==` method
208
+ # @param [Object] Object to be compared
209
+ def eql?(o)
210
+ self == o
211
+ end
212
+
213
+ # Calculates hash code according to all attributes.
214
+ # @return [Integer] Hash code
215
+ def hash
216
+ [active, expires_at, id, identity, issued_at, messages, methods, request_url, state, type].hash
217
+ end
218
+
219
+ # Builds the object from hash
220
+ # @param [Hash] attributes Model attributes in the form of hash
221
+ # @return [Object] Returns the model itself
222
+ def self.build_from_hash(attributes)
223
+ new.build_from_hash(attributes)
224
+ end
225
+
226
+ # Builds the object from hash
227
+ # @param [Hash] attributes Model attributes in the form of hash
228
+ # @return [Object] Returns the model itself
229
+ def build_from_hash(attributes)
230
+ return nil unless attributes.is_a?(Hash)
231
+ self.class.openapi_types.each_pair do |key, type|
232
+ if type =~ /\AArray<(.*)>/i
233
+ # check to ensure the input is an array given that the attribute
234
+ # is documented as an array but the input is not
235
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
236
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
237
+ end
238
+ elsif !attributes[self.class.attribute_map[key]].nil?
239
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
240
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
241
+ end
242
+
243
+ self
244
+ end
245
+
246
+ # Deserializes the data based on type
247
+ # @param string type Data type
248
+ # @param string value Value to be deserialized
249
+ # @return [Object] Deserialized data
250
+ def _deserialize(type, value)
251
+ case type.to_sym
252
+ when :DateTime
253
+ DateTime.parse(value)
254
+ when :Date
255
+ Date.parse(value)
256
+ when :String
257
+ value.to_s
258
+ when :Integer
259
+ value.to_i
260
+ when :Float
261
+ value.to_f
262
+ when :Boolean
263
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
264
+ true
265
+ else
266
+ false
267
+ end
268
+ when :Object
269
+ # generic object (usually a Hash), return directly
270
+ value
271
+ when /\AArray<(?<inner_type>.+)>\z/
272
+ inner_type = Regexp.last_match[:inner_type]
273
+ value.map { |v| _deserialize(inner_type, v) }
274
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
275
+ k_type = Regexp.last_match[:k_type]
276
+ v_type = Regexp.last_match[:v_type]
277
+ {}.tap do |hash|
278
+ value.each do |k, v|
279
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
280
+ end
281
+ end
282
+ else # model
283
+ OryHydraClient.const_get(type).build_from_hash(value)
284
+ end
285
+ end
286
+
287
+ # Returns the string representation of the object
288
+ # @return [String] String presentation of the object
289
+ def to_s
290
+ to_hash.to_s
291
+ end
292
+
293
+ # to_body is an alias to to_hash (backward compatibility)
294
+ # @return [Hash] Returns the object in the form of hash
295
+ def to_body
296
+ to_hash
297
+ end
298
+
299
+ # Returns the object in the form of hash
300
+ # @return [Hash] Returns the object in the form of hash
301
+ def to_hash
302
+ hash = {}
303
+ self.class.attribute_map.each_pair do |attr, param|
304
+ value = self.send(attr)
305
+ if value.nil?
306
+ is_nullable = self.class.openapi_nullable.include?(attr)
307
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
308
+ end
309
+
310
+ hash[param] = _to_hash(value)
311
+ end
312
+ hash
313
+ end
314
+
315
+ # Outputs non-array value in the form of hash
316
+ # For object, use to_hash. Otherwise, just return the value
317
+ # @param [Object] value Any valid value
318
+ # @return [Hash] Returns the value in the form of hash
319
+ def _to_hash(value)
320
+ if value.is_a?(Array)
321
+ value.compact.map { |v| _to_hash(v) }
322
+ elsif value.is_a?(Hash)
323
+ {}.tap do |hash|
324
+ value.each { |k, v| hash[k] = _to_hash(v) }
325
+ end
326
+ elsif value.respond_to? :to_hash
327
+ value.to_hash
328
+ else
329
+ value
330
+ end
331
+ end
332
+ end
333
+ end
@@ -0,0 +1,226 @@
1
+ =begin
2
+ #Ory Kratos
3
+
4
+ #Welcome to the ORY Kratos HTTP API documentation!
5
+
6
+ The version of the OpenAPI document: v0.5.0-alpha.1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 4.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module OryHydraClient
16
+ class SettingsFlowMethod
17
+ attr_accessor :config
18
+
19
+ # Method is the name of this flow method.
20
+ attr_accessor :method
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'config' => :'config',
26
+ :'method' => :'method'
27
+ }
28
+ end
29
+
30
+ # Attribute type mapping.
31
+ def self.openapi_types
32
+ {
33
+ :'config' => :'SettingsFlowMethodConfig',
34
+ :'method' => :'String'
35
+ }
36
+ end
37
+
38
+ # List of attributes with nullable: true
39
+ def self.openapi_nullable
40
+ Set.new([
41
+ ])
42
+ end
43
+
44
+ # Initializes the object
45
+ # @param [Hash] attributes Model attributes in the form of hash
46
+ def initialize(attributes = {})
47
+ if (!attributes.is_a?(Hash))
48
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OryHydraClient::SettingsFlowMethod` initialize method"
49
+ end
50
+
51
+ # check to see if the attribute exists and convert string to symbol for hash key
52
+ attributes = attributes.each_with_object({}) { |(k, v), h|
53
+ if (!self.class.attribute_map.key?(k.to_sym))
54
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OryHydraClient::SettingsFlowMethod`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
55
+ end
56
+ h[k.to_sym] = v
57
+ }
58
+
59
+ if attributes.key?(:'config')
60
+ self.config = attributes[:'config']
61
+ end
62
+
63
+ if attributes.key?(:'method')
64
+ self.method = attributes[:'method']
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
+ invalid_properties = Array.new
72
+ if @config.nil?
73
+ invalid_properties.push('invalid value for "config", config cannot be nil.')
74
+ end
75
+
76
+ if @method.nil?
77
+ invalid_properties.push('invalid value for "method", method cannot be nil.')
78
+ end
79
+
80
+ invalid_properties
81
+ end
82
+
83
+ # Check to see if the all the properties in the model are valid
84
+ # @return true if the model is valid
85
+ def valid?
86
+ return false if @config.nil?
87
+ return false if @method.nil?
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
+ config == o.config &&
97
+ method == o.method
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
+ [config, method].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
+ new.build_from_hash(attributes)
117
+ end
118
+
119
+ # Builds the object from hash
120
+ # @param [Hash] attributes Model attributes in the form of hash
121
+ # @return [Object] Returns the model itself
122
+ def build_from_hash(attributes)
123
+ return nil unless attributes.is_a?(Hash)
124
+ self.class.openapi_types.each_pair do |key, type|
125
+ if type =~ /\AArray<(.*)>/i
126
+ # check to ensure the input is an array given that the attribute
127
+ # is documented as an array but the input is not
128
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
129
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
130
+ end
131
+ elsif !attributes[self.class.attribute_map[key]].nil?
132
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
133
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
134
+ end
135
+
136
+ self
137
+ end
138
+
139
+ # Deserializes the data based on type
140
+ # @param string type Data type
141
+ # @param string value Value to be deserialized
142
+ # @return [Object] Deserialized data
143
+ def _deserialize(type, value)
144
+ case type.to_sym
145
+ when :DateTime
146
+ DateTime.parse(value)
147
+ when :Date
148
+ Date.parse(value)
149
+ when :String
150
+ value.to_s
151
+ when :Integer
152
+ value.to_i
153
+ when :Float
154
+ value.to_f
155
+ when :Boolean
156
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
157
+ true
158
+ else
159
+ false
160
+ end
161
+ when :Object
162
+ # generic object (usually a Hash), return directly
163
+ value
164
+ when /\AArray<(?<inner_type>.+)>\z/
165
+ inner_type = Regexp.last_match[:inner_type]
166
+ value.map { |v| _deserialize(inner_type, v) }
167
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
168
+ k_type = Regexp.last_match[:k_type]
169
+ v_type = Regexp.last_match[:v_type]
170
+ {}.tap do |hash|
171
+ value.each do |k, v|
172
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
173
+ end
174
+ end
175
+ else # model
176
+ OryHydraClient.const_get(type).build_from_hash(value)
177
+ end
178
+ end
179
+
180
+ # Returns the string representation of the object
181
+ # @return [String] String presentation of the object
182
+ def to_s
183
+ to_hash.to_s
184
+ end
185
+
186
+ # to_body is an alias to to_hash (backward compatibility)
187
+ # @return [Hash] Returns the object in the form of hash
188
+ def to_body
189
+ to_hash
190
+ end
191
+
192
+ # Returns the object in the form of hash
193
+ # @return [Hash] Returns the object in the form of hash
194
+ def to_hash
195
+ hash = {}
196
+ self.class.attribute_map.each_pair do |attr, param|
197
+ value = self.send(attr)
198
+ if value.nil?
199
+ is_nullable = self.class.openapi_nullable.include?(attr)
200
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
201
+ end
202
+
203
+ hash[param] = _to_hash(value)
204
+ end
205
+ hash
206
+ end
207
+
208
+ # Outputs non-array value in the form of hash
209
+ # For object, use to_hash. Otherwise, just return the value
210
+ # @param [Object] value Any valid value
211
+ # @return [Hash] Returns the value in the form of hash
212
+ def _to_hash(value)
213
+ if value.is_a?(Array)
214
+ value.compact.map { |v| _to_hash(v) }
215
+ elsif value.is_a?(Hash)
216
+ {}.tap do |hash|
217
+ value.each { |k, v| hash[k] = _to_hash(v) }
218
+ end
219
+ elsif value.respond_to? :to_hash
220
+ value.to_hash
221
+ else
222
+ value
223
+ end
224
+ end
225
+ end
226
+ end