Class: WorkOS::UserAndToken

Inherits:
Object
  • Object
show all
Includes:
HashProvider
Defined in:
lib/workos/user_and_token.rb

Overview

The UserAndToken class represents a User and a corresponding Token. This class is not meant to be instantiated in user space, and is instantiated internally but exposed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HashProvider

#to_h

Constructor Details

#initialize(user_and_token_json) ⇒ UserAndToken

Returns a new instance of UserAndToken.



12
13
14
15
16
17
# File 'lib/workos/user_and_token.rb', line 12

def initialize(user_and_token_json)
  json = JSON.parse(user_and_token_json, symbolize_names: true)

  @token = json[:token]
  @user = WorkOS::User.new(json[:user].to_json)
end

Instance Attribute Details

#tokenObject

Returns the value of attribute token.



10
11
12
# File 'lib/workos/user_and_token.rb', line 10

def token
  @token
end

#userObject

Returns the value of attribute user.



10
11
12
# File 'lib/workos/user_and_token.rb', line 10

def user
  @user
end

Instance Method Details

#to_jsonObject



19
20
21
22
23
24
# File 'lib/workos/user_and_token.rb', line 19

def to_json(*)
  {
    token: token,
    user: user.to_json,
  }
end