Class: WorkOS::MagicAuth

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

Overview

The MagicAuth class provides a lightweight wrapper around a WorkOS MagicAuth 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) ⇒ MagicAuth

Returns a new instance of MagicAuth.



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

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

  @id = hash[:id]
  @user_id = hash[:user_id]
  @email = hash[:email]
  @code = hash[:code]
  @expires_at = hash[:expires_at]
  @created_at = hash[:created_at]
  @updated_at = hash[:updated_at]
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



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

def code
  @code
end

#created_atObject

Returns the value of attribute created_at.



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

def created_at
  @created_at
end

#emailObject

Returns the value of attribute email.



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

def email
  @email
end

#expires_atObject

Returns the value of attribute expires_at.



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

def expires_at
  @expires_at
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#updated_atObject

Returns the value of attribute updated_at.



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

def updated_at
  @updated_at
end

#user_idObject

Returns the value of attribute user_id.



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

def user_id
  @user_id
end

Instance Method Details

#to_jsonObject



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/workos/magic_auth.rb', line 25

def to_json(*)
  {
    id: id,
    user_id: user_id,
    email: email,
    code: code,
    expires_at: expires_at,
    created_at: created_at,
    updated_at: updated_at,
  }
end