Class: Lita::GoogleUser

Inherits:
Object
  • Object
show all
Defined in:
lib/lita/google_user.rb

Overview

A google apps user

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, full_name:, email:, suspended:, created_at:, last_login_at:, ou_path:, admin:, delegated_admin:, two_factor_enabled:, two_factor_enforced:) ⇒ GoogleUser

Returns a new instance of GoogleUser.



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/lita/google_user.rb', line 22

def initialize(id:, full_name:, email:, suspended:, created_at:, last_login_at:, ou_path:, admin:, delegated_admin:, two_factor_enabled:, two_factor_enforced:)
  @id = id
  @email = email
  @full_name = full_name
  @suspended = suspended
  @created_at = created_at
  @last_login_at = 
  @ou_path = ou_path
  @admin = admin
  @delegated_admin = delegated_admin
  @two_factor_enabled = two_factor_enabled
  @two_factor_enforced = two_factor_enforced
end

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at.



4
5
6
# File 'lib/lita/google_user.rb', line 4

def created_at
  @created_at
end

#emailObject (readonly)

Returns the value of attribute email.



4
5
6
# File 'lib/lita/google_user.rb', line 4

def email
  @email
end

#full_nameObject (readonly)

Returns the value of attribute full_name.



4
5
6
# File 'lib/lita/google_user.rb', line 4

def full_name
  @full_name
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/lita/google_user.rb', line 4

def id
  @id
end

#last_login_atObject (readonly)

Returns the value of attribute last_login_at.



4
5
6
# File 'lib/lita/google_user.rb', line 4

def 
  @last_login_at
end

#ou_pathObject (readonly)

Returns the value of attribute ou_path.



4
5
6
# File 'lib/lita/google_user.rb', line 4

def ou_path
  @ou_path
end

Class Method Details

.from_api_user(user) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/lita/google_user.rb', line 6

def self.from_api_user(user)
  GoogleUser.new(
    id: user.id,
    full_name: user.name.full_name,
    email: user.primary_email,
    suspended: user.suspended,
    created_at: user.creation_time,
    last_login_at: user.,
    ou_path: user.org_unit_path,
    admin: user.is_admin,
    delegated_admin: user.is_delegated_admin,
    two_factor_enabled: user.is_enrolled_in2_sv,
    two_factor_enforced: user.is_enforced_in2_sv,
  )
end

Instance Method Details

#admin?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/lita/google_user.rb', line 40

def admin?
  @admin
end

#delegated_admin?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/lita/google_user.rb', line 44

def delegated_admin?
  @delegated_admin
end

#pathObject



48
49
50
51
52
53
54
# File 'lib/lita/google_user.rb', line 48

def path
  if @ou_path.end_with?("/")
    "#{@ou_path}#{@email}"
  else
    "#{@ou_path}/#{@email}"
  end
end

#suspended?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/lita/google_user.rb', line 56

def suspended?
  @suspended
end

#to_sObject



36
37
38
# File 'lib/lita/google_user.rb', line 36

def to_s
  @email
end

#two_factor_enabled?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/lita/google_user.rb', line 60

def two_factor_enabled?
  @two_factor_enabled
end

#two_factor_enforced?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/lita/google_user.rb', line 64

def two_factor_enforced?
  @two_factor_enforced
end