diff --git a/lib/edusign/client.rb b/lib/edusign/client.rb index 8a884a1..b611d93 100644 --- a/lib/edusign/client.rb +++ b/lib/edusign/client.rb @@ -183,11 +183,12 @@ def update_student(student_uid:, first_name:, last_name:, email:, group_uids: [] end def create_or_update_student(first_name:, last_name:, email:, student_uid: nil, group_uids: []) - student = student_uid.present? ? student_by_uid(student_uid: student_uid) : student_by_email(email: email) + @student = student_by_uid(student_uid: student_uid) if student_uid.present? + @student = student_by_email(email: email) if @student.nil? raise Response::Error, "Student doesn't exist" if student.nil? - raise Response::Error, "Student was deleted from edusign" if student[:HIDDEN] == 1 + raise Response::Error, "Student was deleted from edusign" if @student[:HIDDEN] == 1 - update_student(student_uid: student[:ID], first_name: first_name, last_name: last_name, email: email, group_uids: group_uids) + update_student(student_uid: @student[:ID], first_name: first_name, last_name: last_name, email: email, group_uids: group_uids) rescue Response::Error => _e create_student(first_name: first_name, last_name: last_name, email: email, group_uids: group_uids) end