Class: WorkOS::User

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

Overview

The User class provides a lightweight wrapper around a WorkOS User resource. This class is not meant to be instantiated in a 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(json) ⇒ User

Returns a new instance of User.



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/workos/user.rb', line 13

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

  @id = hash[:id]
  @email = hash[:email]
  @first_name = hash[:first_name]
  @last_name = hash[:last_name]
  @email_verified = hash[:email_verified]
  @profile_picture_url = hash[:profile_picture_url]
  @last_sign_in_at = hash[:last_sign_in_at]
  @created_at = hash[:created_at]
  @updated_at = hash[:updated_at]
end

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



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

def created_at
  @created_at
end

#emailObject

Returns the value of attribute email.



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

def email
  @email
end

#email_verifiedObject

Returns the value of attribute email_verified.



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

def email_verified
  @email_verified
end

#first_nameObject

Returns the value of attribute first_name.



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

def first_name
  @first_name
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#last_nameObject

Returns the value of attribute last_name.



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

def last_name
  @last_name
end

#last_sign_in_atObject

Returns the value of attribute last_sign_in_at.



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

def 
  @last_sign_in_at
end

#profile_picture_urlObject

Returns the value of attribute profile_picture_url.



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

def profile_picture_url
  @profile_picture_url
end

#updated_atObject

Returns the value of attribute updated_at.



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

def updated_at
  @updated_at
end

Instance Method Details

#to_jsonObject



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/workos/user.rb', line 27

def to_json(*)
  {
    id: id,
    email: email,
    first_name: first_name,
    last_name: last_name,
    email_verified: email_verified,
    profile_picture_url: profile_picture_url,
    last_sign_in_at: ,
    created_at: created_at,
    updated_at: updated_at,
  }
end