Class: Lapis::Yggdrasil::Messaging::RefreshRequest

Inherits:
TokenRequest show all
Defined in:
lib/lapis/yggdrasil/messaging/refresh_request.rb

Overview

Request for renewing a previously used authentication session.

See Also:

Instance Method Summary collapse

Constructor Details

#initialize(client_token, access_token, profile = nil) ⇒ RefreshRequest

Creates a new refresh request.

Parameters:

  • client_token (Uuid)

    Unique ID Of the client that performed the authentication.

  • access_token (Uuid)

    Unique ID of the authentication session.

  • profile (Profile, nil) (defaults to: nil)

    New profile to switch to. Specify nil to keep the same profile.



17
18
19
20
# File 'lib/lapis/yggdrasil/messaging/refresh_request.rb', line 17

def initialize(client_token, access_token, profile = nil)
  super(client_token, access_token)
  @profile = profile
end

Instance Method Details

#endpointString

Path on the server that handles the request.

Returns:

  • (String)

    Path to handler.



24
25
26
# File 'lib/lapis/yggdrasil/messaging/refresh_request.rb', line 24

def endpoint
  '/refresh'
end

#to_jsonString

Generates a JSON string that can be sent to an authentication server.

Returns:

  • (String)

    JSON string.



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/lapis/yggdrasil/messaging/refresh_request.rb', line 30

def to_json
  hash = structure
  if @profile
    profile_hash = {
        :name => @profile.name,
        :id   => @profile.id.to_s(false)
    }
    profile_hash[:legacy] = true if @profile.legacy?
    hash[:selectedProfile] = profile_hash
  end
  hash.to_json
end