Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Endpoints #12

Merged
merged 3 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions lib/edusign/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,14 @@ def delete_course(course_uid:)
api :delete, "/course/#{course_uid}"
end

def courses(group_uid: nil)
def courses(group_uid: nil, starts_at: nil, ends_at: nil)
query = {
groupId: group_uid,
start: starts_at,
end: ends_at
}.compact
path = "/course"
path += "?groupId=#{group_uid}" if group_uid.present?
path += "?#{query.to_query}" if query.present?
response = api :get, path
response.result
end
Expand All @@ -139,6 +144,10 @@ def add_student_to_course(course_uid:, student_uid:)
raise e unless e.message == STUDENT_ALREADY_ADDED_TO_COURSE_ERROR_MESSAGE
end

def remove_student_from_course(course_uid:, student_uid:)
api :delete, "/course/attendance/#{course_uid}", {studentId: student_uid}.to_json
end

def send_signature_email(course_uid:)
students = course(course_uid: course_uid)[:STUDENTS].reject { |student| student[:state] }.map { |student| student[:studentId] }
api :post, "/course/send-sign-emails", {"course" => course_uid, "students" => students}.to_json
Expand Down
2 changes: 1 addition & 1 deletion lib/edusign/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Edusign
VERSION = "0.1.1"
VERSION = "0.2.0"
end