Class: Clever::Types::Student
Instance Attribute Summary collapse
-
#first_name ⇒ Object
readonly
Returns the value of attribute first_name.
-
#last_name ⇒ Object
readonly
Returns the value of attribute last_name.
-
#legacy_id ⇒ Object
readonly
Returns the value of attribute legacy_id.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
-
#uid ⇒ Object
readonly
Returns the value of attribute uid.
Instance Method Summary collapse
-
#initialize(attributes = {}, client: nil) ⇒ Student
constructor
A new instance of Student.
- #to_h ⇒ Object
- #username(client = nil) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(attributes = {}, client: nil) ⇒ Student
Returns a new instance of Student.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/clever/types/student.rb', line 12 def initialize(attributes = {}, client: nil) @district_username = attributes.dig('credentials', 'district_username') @email = attributes['email'] @first_name = attributes['name']['first'] @last_name = attributes['name']['last'] @legacy_id = attributes.dig('roles', 'student', 'legacy_id') @provider = 'clever' @sis_id = attributes['sis_id'] @uid = attributes['id'] @username = username(client) end |
Instance Attribute Details
#first_name ⇒ Object (readonly)
Returns the value of attribute first_name.
6 7 8 |
# File 'lib/clever/types/student.rb', line 6 def first_name @first_name end |
#last_name ⇒ Object (readonly)
Returns the value of attribute last_name.
6 7 8 |
# File 'lib/clever/types/student.rb', line 6 def last_name @last_name end |
#legacy_id ⇒ Object (readonly)
Returns the value of attribute legacy_id.
6 7 8 |
# File 'lib/clever/types/student.rb', line 6 def legacy_id @legacy_id end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
6 7 8 |
# File 'lib/clever/types/student.rb', line 6 def provider @provider end |
#uid ⇒ Object (readonly)
Returns the value of attribute uid.
6 7 8 |
# File 'lib/clever/types/student.rb', line 6 def uid @uid end |
Instance Method Details
#to_h ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/clever/types/student.rb', line 30 def to_h { uid: @uid, first_name: @first_name, last_name: @last_name, username: @username, provider: @provider } end |
#username(client = nil) ⇒ Object
24 25 26 27 28 |
# File 'lib/clever/types/student.rb', line 24 def username(client = nil) username_source = client&.username_source @username ||= presence(username_from(username_source)) || default_username end |