Class: Ralyxa::RequestEntities::User

Inherits:
Object
  • Object
show all
Defined in:
lib/ralyxa/request_entities/user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, access_token: nil) ⇒ User

Returns a new instance of User.



6
7
8
9
# File 'lib/ralyxa/request_entities/user.rb', line 6

def initialize(id:, access_token: nil)
  @id = id
  @access_token = access_token
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



4
5
6
# File 'lib/ralyxa/request_entities/user.rb', line 4

def access_token
  @access_token
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/ralyxa/request_entities/user.rb', line 4

def id
  @id
end

Class Method Details

.build(request) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/ralyxa/request_entities/user.rb', line 11

def self.build(request)
  user_hash = request.dig('session', 'user') || request.dig('context', 'System', 'user') || {}

  new(
    id: user_hash['userId'],
    access_token: user_hash['accessToken']
  )
end

Instance Method Details

#access_token_exists?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/ralyxa/request_entities/user.rb', line 20

def access_token_exists?
  !@access_token.nil?
end