Class: WorkOS::ProfileAndToken

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

Overview

The ProfileAndToken class represents a Profile and a corresponding Access 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(profile_and_token_json) ⇒ ProfileAndToken

Returns a new instance of ProfileAndToken.



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

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

  @access_token = json[:access_token]
  @profile = WorkOS::Profile.new(json[:profile].to_json)
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



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

def access_token
  @access_token
end

#profileObject

Returns the value of attribute profile.



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

def profile
  @profile
end

Instance Method Details

#to_jsonObject



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

def to_json(*)
  {
    access_token: access_token,
    profile: profile.to_json,
  }
end