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,227 @@
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
+ # The Response for Login Flows via API
17
+ class LoginViaApiResponse
18
+ attr_accessor :session
19
+
20
+ # The Session Token A session token is equivalent to a session cookie, but it can be sent in the HTTP Authorization Header: Authorization: bearer ${session-token} The session token is only issued for API flows, not for Browser flows!
21
+ attr_accessor :session_token
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'session' => :'session',
27
+ :'session_token' => :'session_token'
28
+ }
29
+ end
30
+
31
+ # Attribute type mapping.
32
+ def self.openapi_types
33
+ {
34
+ :'session' => :'Session',
35
+ :'session_token' => :'String'
36
+ }
37
+ end
38
+
39
+ # List of attributes with nullable: true
40
+ def self.openapi_nullable
41
+ Set.new([
42
+ ])
43
+ end
44
+
45
+ # Initializes the object
46
+ # @param [Hash] attributes Model attributes in the form of hash
47
+ def initialize(attributes = {})
48
+ if (!attributes.is_a?(Hash))
49
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OryHydraClient::LoginViaApiResponse` initialize method"
50
+ end
51
+
52
+ # check to see if the attribute exists and convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}) { |(k, v), h|
54
+ if (!self.class.attribute_map.key?(k.to_sym))
55
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OryHydraClient::LoginViaApiResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
56
+ end
57
+ h[k.to_sym] = v
58
+ }
59
+
60
+ if attributes.key?(:'session')
61
+ self.session = attributes[:'session']
62
+ end
63
+
64
+ if attributes.key?(:'session_token')
65
+ self.session_token = attributes[:'session_token']
66
+ end
67
+ end
68
+
69
+ # Show invalid properties with the reasons. Usually used together with valid?
70
+ # @return Array for valid properties with the reasons
71
+ def list_invalid_properties
72
+ invalid_properties = Array.new
73
+ if @session.nil?
74
+ invalid_properties.push('invalid value for "session", session cannot be nil.')
75
+ end
76
+
77
+ if @session_token.nil?
78
+ invalid_properties.push('invalid value for "session_token", session_token cannot be nil.')
79
+ end
80
+
81
+ invalid_properties
82
+ end
83
+
84
+ # Check to see if the all the properties in the model are valid
85
+ # @return true if the model is valid
86
+ def valid?
87
+ return false if @session.nil?
88
+ return false if @session_token.nil?
89
+ true
90
+ end
91
+
92
+ # Checks equality by comparing each attribute.
93
+ # @param [Object] Object to be compared
94
+ def ==(o)
95
+ return true if self.equal?(o)
96
+ self.class == o.class &&
97
+ session == o.session &&
98
+ session_token == o.session_token
99
+ end
100
+
101
+ # @see the `==` method
102
+ # @param [Object] Object to be compared
103
+ def eql?(o)
104
+ self == o
105
+ end
106
+
107
+ # Calculates hash code according to all attributes.
108
+ # @return [Integer] Hash code
109
+ def hash
110
+ [session, session_token].hash
111
+ end
112
+
113
+ # Builds the object from hash
114
+ # @param [Hash] attributes Model attributes in the form of hash
115
+ # @return [Object] Returns the model itself
116
+ def self.build_from_hash(attributes)
117
+ new.build_from_hash(attributes)
118
+ end
119
+
120
+ # Builds the object from hash
121
+ # @param [Hash] attributes Model attributes in the form of hash
122
+ # @return [Object] Returns the model itself
123
+ def build_from_hash(attributes)
124
+ return nil unless attributes.is_a?(Hash)
125
+ self.class.openapi_types.each_pair do |key, type|
126
+ if type =~ /\AArray<(.*)>/i
127
+ # check to ensure the input is an array given that the attribute
128
+ # is documented as an array but the input is not
129
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
130
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
131
+ end
132
+ elsif !attributes[self.class.attribute_map[key]].nil?
133
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
134
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
135
+ end
136
+
137
+ self
138
+ end
139
+
140
+ # Deserializes the data based on type
141
+ # @param string type Data type
142
+ # @param string value Value to be deserialized
143
+ # @return [Object] Deserialized data
144
+ def _deserialize(type, value)
145
+ case type.to_sym
146
+ when :DateTime
147
+ DateTime.parse(value)
148
+ when :Date
149
+ Date.parse(value)
150
+ when :String
151
+ value.to_s
152
+ when :Integer
153
+ value.to_i
154
+ when :Float
155
+ value.to_f
156
+ when :Boolean
157
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
158
+ true
159
+ else
160
+ false
161
+ end
162
+ when :Object
163
+ # generic object (usually a Hash), return directly
164
+ value
165
+ when /\AArray<(?<inner_type>.+)>\z/
166
+ inner_type = Regexp.last_match[:inner_type]
167
+ value.map { |v| _deserialize(inner_type, v) }
168
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
169
+ k_type = Regexp.last_match[:k_type]
170
+ v_type = Regexp.last_match[:v_type]
171
+ {}.tap do |hash|
172
+ value.each do |k, v|
173
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
174
+ end
175
+ end
176
+ else # model
177
+ OryHydraClient.const_get(type).build_from_hash(value)
178
+ end
179
+ end
180
+
181
+ # Returns the string representation of the object
182
+ # @return [String] String presentation of the object
183
+ def to_s
184
+ to_hash.to_s
185
+ end
186
+
187
+ # to_body is an alias to to_hash (backward compatibility)
188
+ # @return [Hash] Returns the object in the form of hash
189
+ def to_body
190
+ to_hash
191
+ end
192
+
193
+ # Returns the object in the form of hash
194
+ # @return [Hash] Returns the object in the form of hash
195
+ def to_hash
196
+ hash = {}
197
+ self.class.attribute_map.each_pair do |attr, param|
198
+ value = self.send(attr)
199
+ if value.nil?
200
+ is_nullable = self.class.openapi_nullable.include?(attr)
201
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
202
+ end
203
+
204
+ hash[param] = _to_hash(value)
205
+ end
206
+ hash
207
+ end
208
+
209
+ # Outputs non-array value in the form of hash
210
+ # For object, use to_hash. Otherwise, just return the value
211
+ # @param [Object] value Any valid value
212
+ # @return [Hash] Returns the value in the form of hash
213
+ def _to_hash(value)
214
+ if value.is_a?(Array)
215
+ value.compact.map { |v| _to_hash(v) }
216
+ elsif value.is_a?(Hash)
217
+ {}.tap do |hash|
218
+ value.each { |k, v| hash[k] = _to_hash(v) }
219
+ end
220
+ elsif value.respond_to? :to_hash
221
+ value.to_hash
222
+ else
223
+ value
224
+ end
225
+ end
226
+ end
227
+ end
@@ -3,7 +3,7 @@
3
3
 
4
4
  #Welcome to the ORY Kratos HTTP API documentation!
5
5
 
6
- The version of the OpenAPI document: v0.4.6-alpha.1
6
+ The version of the OpenAPI document: v0.5.0-alpha.1
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
9
  OpenAPI Generator version: 4.3.1
@@ -20,6 +20,7 @@ module OryHydraClient
20
20
 
21
21
  attr_accessor :text
22
22
 
23
+ # The flow type can either be `api` or `browser`.
23
24
  attr_accessor :type
24
25
 
25
26
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -3,7 +3,7 @@
3
3
 
4
4
  #Welcome to the ORY Kratos HTTP API documentation!
5
5
 
6
- The version of the OpenAPI document: v0.4.6-alpha.1
6
+ The version of the OpenAPI document: v0.5.0-alpha.1
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
9
  OpenAPI Generator version: 4.3.1
@@ -0,0 +1,319 @@
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 request is used when an identity wants to recover their account. We recommend reading the [Account Recovery Documentation](../self-service/flows/password-reset-account-recovery)
17
+ class RecoveryFlow
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 request expires. If the user still wishes to update the setting, a new request has to be initiated.
22
+ attr_accessor :expires_at
23
+
24
+ attr_accessor :id
25
+
26
+ # IssuedAt is the time (UTC) when the request occurred.
27
+ attr_accessor :issued_at
28
+
29
+ attr_accessor :messages
30
+
31
+ # Methods contains context for all account recovery methods. If a registration request has been processed, but for example the password is incorrect, this will contain error messages.
32
+ attr_accessor :methods
33
+
34
+ # 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.
35
+ attr_accessor :request_url
36
+
37
+ attr_accessor :state
38
+
39
+ # The flow type can either be `api` or `browser`.
40
+ attr_accessor :type
41
+
42
+ # Attribute mapping from ruby-style variable name to JSON key.
43
+ def self.attribute_map
44
+ {
45
+ :'active' => :'active',
46
+ :'expires_at' => :'expires_at',
47
+ :'id' => :'id',
48
+ :'issued_at' => :'issued_at',
49
+ :'messages' => :'messages',
50
+ :'methods' => :'methods',
51
+ :'request_url' => :'request_url',
52
+ :'state' => :'state',
53
+ :'type' => :'type'
54
+ }
55
+ end
56
+
57
+ # Attribute type mapping.
58
+ def self.openapi_types
59
+ {
60
+ :'active' => :'String',
61
+ :'expires_at' => :'DateTime',
62
+ :'id' => :'String',
63
+ :'issued_at' => :'DateTime',
64
+ :'messages' => :'Array<Message>',
65
+ :'methods' => :'Hash<String, RecoveryFlowMethod>',
66
+ :'request_url' => :'String',
67
+ :'state' => :'String',
68
+ :'type' => :'String'
69
+ }
70
+ end
71
+
72
+ # List of attributes with nullable: true
73
+ def self.openapi_nullable
74
+ Set.new([
75
+ ])
76
+ end
77
+
78
+ # Initializes the object
79
+ # @param [Hash] attributes Model attributes in the form of hash
80
+ def initialize(attributes = {})
81
+ if (!attributes.is_a?(Hash))
82
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OryHydraClient::RecoveryFlow` initialize method"
83
+ end
84
+
85
+ # check to see if the attribute exists and convert string to symbol for hash key
86
+ attributes = attributes.each_with_object({}) { |(k, v), h|
87
+ if (!self.class.attribute_map.key?(k.to_sym))
88
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OryHydraClient::RecoveryFlow`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
89
+ end
90
+ h[k.to_sym] = v
91
+ }
92
+
93
+ if attributes.key?(:'active')
94
+ self.active = attributes[:'active']
95
+ end
96
+
97
+ if attributes.key?(:'expires_at')
98
+ self.expires_at = attributes[:'expires_at']
99
+ end
100
+
101
+ if attributes.key?(:'id')
102
+ self.id = attributes[:'id']
103
+ end
104
+
105
+ if attributes.key?(:'issued_at')
106
+ self.issued_at = attributes[:'issued_at']
107
+ end
108
+
109
+ if attributes.key?(:'messages')
110
+ if (value = attributes[:'messages']).is_a?(Array)
111
+ self.messages = value
112
+ end
113
+ end
114
+
115
+ if attributes.key?(:'methods')
116
+ if (value = attributes[:'methods']).is_a?(Hash)
117
+ self.methods = value
118
+ end
119
+ end
120
+
121
+ if attributes.key?(:'request_url')
122
+ self.request_url = attributes[:'request_url']
123
+ end
124
+
125
+ if attributes.key?(:'state')
126
+ self.state = attributes[:'state']
127
+ end
128
+
129
+ if attributes.key?(:'type')
130
+ self.type = attributes[:'type']
131
+ end
132
+ end
133
+
134
+ # Show invalid properties with the reasons. Usually used together with valid?
135
+ # @return Array for valid properties with the reasons
136
+ def list_invalid_properties
137
+ invalid_properties = Array.new
138
+ if @expires_at.nil?
139
+ invalid_properties.push('invalid value for "expires_at", expires_at cannot be nil.')
140
+ end
141
+
142
+ if @id.nil?
143
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
144
+ end
145
+
146
+ if @issued_at.nil?
147
+ invalid_properties.push('invalid value for "issued_at", issued_at cannot be nil.')
148
+ end
149
+
150
+ if @methods.nil?
151
+ invalid_properties.push('invalid value for "methods", methods cannot be nil.')
152
+ end
153
+
154
+ if @request_url.nil?
155
+ invalid_properties.push('invalid value for "request_url", request_url cannot be nil.')
156
+ end
157
+
158
+ if @state.nil?
159
+ invalid_properties.push('invalid value for "state", state cannot be nil.')
160
+ end
161
+
162
+ invalid_properties
163
+ end
164
+
165
+ # Check to see if the all the properties in the model are valid
166
+ # @return true if the model is valid
167
+ def valid?
168
+ return false if @expires_at.nil?
169
+ return false if @id.nil?
170
+ return false if @issued_at.nil?
171
+ return false if @methods.nil?
172
+ return false if @request_url.nil?
173
+ return false if @state.nil?
174
+ true
175
+ end
176
+
177
+ # Checks equality by comparing each attribute.
178
+ # @param [Object] Object to be compared
179
+ def ==(o)
180
+ return true if self.equal?(o)
181
+ self.class == o.class &&
182
+ active == o.active &&
183
+ expires_at == o.expires_at &&
184
+ id == o.id &&
185
+ issued_at == o.issued_at &&
186
+ messages == o.messages &&
187
+ methods == o.methods &&
188
+ request_url == o.request_url &&
189
+ state == o.state &&
190
+ type == o.type
191
+ end
192
+
193
+ # @see the `==` method
194
+ # @param [Object] Object to be compared
195
+ def eql?(o)
196
+ self == o
197
+ end
198
+
199
+ # Calculates hash code according to all attributes.
200
+ # @return [Integer] Hash code
201
+ def hash
202
+ [active, expires_at, id, issued_at, messages, methods, request_url, state, type].hash
203
+ end
204
+
205
+ # Builds the object from hash
206
+ # @param [Hash] attributes Model attributes in the form of hash
207
+ # @return [Object] Returns the model itself
208
+ def self.build_from_hash(attributes)
209
+ new.build_from_hash(attributes)
210
+ end
211
+
212
+ # Builds the object from hash
213
+ # @param [Hash] attributes Model attributes in the form of hash
214
+ # @return [Object] Returns the model itself
215
+ def build_from_hash(attributes)
216
+ return nil unless attributes.is_a?(Hash)
217
+ self.class.openapi_types.each_pair do |key, type|
218
+ if type =~ /\AArray<(.*)>/i
219
+ # check to ensure the input is an array given that the attribute
220
+ # is documented as an array but the input is not
221
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
222
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
223
+ end
224
+ elsif !attributes[self.class.attribute_map[key]].nil?
225
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
226
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
227
+ end
228
+
229
+ self
230
+ end
231
+
232
+ # Deserializes the data based on type
233
+ # @param string type Data type
234
+ # @param string value Value to be deserialized
235
+ # @return [Object] Deserialized data
236
+ def _deserialize(type, value)
237
+ case type.to_sym
238
+ when :DateTime
239
+ DateTime.parse(value)
240
+ when :Date
241
+ Date.parse(value)
242
+ when :String
243
+ value.to_s
244
+ when :Integer
245
+ value.to_i
246
+ when :Float
247
+ value.to_f
248
+ when :Boolean
249
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
250
+ true
251
+ else
252
+ false
253
+ end
254
+ when :Object
255
+ # generic object (usually a Hash), return directly
256
+ value
257
+ when /\AArray<(?<inner_type>.+)>\z/
258
+ inner_type = Regexp.last_match[:inner_type]
259
+ value.map { |v| _deserialize(inner_type, v) }
260
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
261
+ k_type = Regexp.last_match[:k_type]
262
+ v_type = Regexp.last_match[:v_type]
263
+ {}.tap do |hash|
264
+ value.each do |k, v|
265
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
266
+ end
267
+ end
268
+ else # model
269
+ OryHydraClient.const_get(type).build_from_hash(value)
270
+ end
271
+ end
272
+
273
+ # Returns the string representation of the object
274
+ # @return [String] String presentation of the object
275
+ def to_s
276
+ to_hash.to_s
277
+ end
278
+
279
+ # to_body is an alias to to_hash (backward compatibility)
280
+ # @return [Hash] Returns the object in the form of hash
281
+ def to_body
282
+ to_hash
283
+ end
284
+
285
+ # Returns the object in the form of hash
286
+ # @return [Hash] Returns the object in the form of hash
287
+ def to_hash
288
+ hash = {}
289
+ self.class.attribute_map.each_pair do |attr, param|
290
+ value = self.send(attr)
291
+ if value.nil?
292
+ is_nullable = self.class.openapi_nullable.include?(attr)
293
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
294
+ end
295
+
296
+ hash[param] = _to_hash(value)
297
+ end
298
+ hash
299
+ end
300
+
301
+ # Outputs non-array value in the form of hash
302
+ # For object, use to_hash. Otherwise, just return the value
303
+ # @param [Object] value Any valid value
304
+ # @return [Hash] Returns the value in the form of hash
305
+ def _to_hash(value)
306
+ if value.is_a?(Array)
307
+ value.compact.map { |v| _to_hash(v) }
308
+ elsif value.is_a?(Hash)
309
+ {}.tap do |hash|
310
+ value.each { |k, v| hash[k] = _to_hash(v) }
311
+ end
312
+ elsif value.respond_to? :to_hash
313
+ value.to_hash
314
+ else
315
+ value
316
+ end
317
+ end
318
+ end
319
+ end