Class: Lapis::Yggdrasil::SessionInfo
- Inherits:
-
Object
- Object
- Lapis::Yggdrasil::SessionInfo
- Defined in:
- lib/lapis/yggdrasil/session_info.rb
Overview
Token and profile information associated with an authentication session.
Instance Attribute Summary collapse
-
#access_token ⇒ Uuid
readonly
Unique ID of the authentication session.
-
#client_token ⇒ Uuid
readonly
Unique ID of the client that performed the authentication.
-
#profile ⇒ Profile
readonly
Information about the currently selected player profile.
Class Method Summary collapse
-
.from_properties(properties) ⇒ SessionInfo
Creates information about an authentication session from response properties.
Instance Method Summary collapse
-
#==(other) ⇒ true, false
Compares this session information to another.
-
#initialize(client_token, access_token, profile) ⇒ SessionInfo
constructor
Creates information about an authentication session.
Constructor Details
#initialize(client_token, access_token, profile) ⇒ SessionInfo
Creates information about an authentication session.
26 27 28 29 30 |
# File 'lib/lapis/yggdrasil/session_info.rb', line 26 def initialize(client_token, access_token, profile) @client_token = client_token @access_token = access_token @profile = profile end |
Instance Attribute Details
#access_token ⇒ Uuid (readonly)
Unique ID of the authentication session.
16 17 18 |
# File 'lib/lapis/yggdrasil/session_info.rb', line 16 def access_token @access_token end |
#client_token ⇒ Uuid (readonly)
Unique ID of the client that performed the authentication.
12 13 14 |
# File 'lib/lapis/yggdrasil/session_info.rb', line 12 def client_token @client_token end |
#profile ⇒ Profile (readonly)
Information about the currently selected player profile.
20 21 22 |
# File 'lib/lapis/yggdrasil/session_info.rb', line 20 def profile @profile end |
Class Method Details
.from_properties(properties) ⇒ SessionInfo
Creates information about an authentication session from response properties.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/lapis/yggdrasil/session_info.rb', line 48 def self.from_properties(properties) fail ArgumentError, 'Client token is required' unless properties.key?(:clientToken) fail ArgumentError, 'Access token is required' unless properties.key?(:accessToken) fail ArgumentError, 'Selected profile is required' unless properties.key?(:selectedProfile) client_token = Uuid.parse(properties[:clientToken]) access_token = Uuid.parse(properties[:accessToken]) profile = Profile.from_properties(properties[:selectedProfile]) new(client_token, access_token, profile) end |
Instance Method Details
#==(other) ⇒ true, false
Compares this session information to another.
36 37 38 39 40 |
# File 'lib/lapis/yggdrasil/session_info.rb', line 36 def ==(other) other.client_token == @client_token && other.access_token == @access_token && other.profile == @profile end |