Class: WorkOS::AuthenticationResponse
- Inherits:
-
Object
- Object
- WorkOS::AuthenticationResponse
- Includes:
- HashProvider
- Defined in:
- lib/workos/authentication_response.rb
Overview
The AuthenticationResponse class represents an Authentication Response as well as an corresponding response data that can later be appended on.
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#impersonator ⇒ Object
Returns the value of attribute impersonator.
-
#organization_id ⇒ Object
Returns the value of attribute organization_id.
-
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(authentication_response_json) ⇒ AuthenticationResponse
constructor
A new instance of AuthenticationResponse.
- #to_json ⇒ Object
Methods included from HashProvider
Constructor Details
#initialize(authentication_response_json) ⇒ AuthenticationResponse
Returns a new instance of AuthenticationResponse.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/workos/authentication_response.rb', line 11 def initialize(authentication_response_json) json = JSON.parse(authentication_response_json, symbolize_names: true) @user = WorkOS::User.new(json[:user].to_json) @organization_id = json[:organization_id] @impersonator = if (impersonator_json = json[:impersonator]) Impersonator.new(email: impersonator_json[:email], reason: impersonator_json[:reason],) end @access_token = json[:access_token] @refresh_token = json[:refresh_token] end |
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
9 10 11 |
# File 'lib/workos/authentication_response.rb', line 9 def access_token @access_token end |
#impersonator ⇒ Object
Returns the value of attribute impersonator.
9 10 11 |
# File 'lib/workos/authentication_response.rb', line 9 def impersonator @impersonator end |
#organization_id ⇒ Object
Returns the value of attribute organization_id.
9 10 11 |
# File 'lib/workos/authentication_response.rb', line 9 def organization_id @organization_id end |
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
9 10 11 |
# File 'lib/workos/authentication_response.rb', line 9 def refresh_token @refresh_token end |
#user ⇒ Object
Returns the value of attribute user.
9 10 11 |
# File 'lib/workos/authentication_response.rb', line 9 def user @user end |
Instance Method Details
#to_json ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/workos/authentication_response.rb', line 24 def to_json(*) { user: user.to_json, organization_id: organization_id, impersonator: impersonator.to_json, access_token: access_token, refresh_token: refresh_token, } end |