ory-kratos-client 0.2.1.alpha1 → 0.5.2.alpha1

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