Documentation
¶
Overview ¶
This file contains internal utilities for sanitizing and validating user-provided input for data integrity before sending requests to the API.
Index ¶
- Constants
- Variables
- func OptionalString(value string) string
- func RequiredString(value string, fieldName string) (string, error)
- func ToPtr[T any](v T) *T
- type Address
- type Announcement
- type AnnouncementAvailability
- type AnnouncementService
- func (c *AnnouncementService) DeleteAllAnnouncements(ctx context.Context, courseID string) error
- func (c *AnnouncementService) DeleteAnnouncement(ctx context.Context, courseID string, announcementID string) error
- func (c *AnnouncementService) GetAllAnnouncements(ctx context.Context, courseID string) ([]Announcement, error)
- func (c *AnnouncementService) GetAnnouncement(ctx context.Context, courseID string, announcementID string) (Announcement, error)
- func (c *AnnouncementService) UpdateAnnouncement(ctx context.Context, courseID string, announcementID string) error
- type Avatar
- type BlackboardClient
- func (c *BlackboardClient) Delete(ctx context.Context, path string) (*http.Response, error)
- func (c *BlackboardClient) Get(ctx context.Context, path string) (*http.Response, error)
- func (c *BlackboardClient) GetRemainingCalls(ctx context.Context) (int, error)
- func (c *BlackboardClient) Patch(ctx context.Context, path string, jsonBody interface{}) (*http.Response, error)
- func (c *BlackboardClient) Post(ctx context.Context, path string, jsonBody interface{}) (*http.Response, error)
- func (c *BlackboardClient) Put(ctx context.Context, path string, jsonBody interface{}) (*http.Response, error)
- type ColumnAvailability
- type ColumnScore
- type Contact
- type ContactUpdate
- type CopyHistory
- type Course
- type CourseAvailability
- type CourseCreateRequest
- type CourseDuration
- type CourseEnrollment
- type CourseLocale
- type CourseMembership
- type CourseService
- func (cs *CourseService) AddChildCourse(ctx context.Context, courseID string, childID string) error
- func (cs *CourseService) CopyCourseByCourseID(ctx context.Context, sourceID, destinationID string) (string, error)
- func (cs *CourseService) Create(ctx context.Context, courseID string, title string, termID string) (*Course, error)
- func (cs *CourseService) CreateMembership(ctx context.Context, username, courseID string, update EnrollmentRequest) error
- func (cs *CourseService) CreatePro(ctx context.Context, req *CourseCreateRequest) (*Course, error)
- func (cs *CourseService) DeleteCourse(ctx context.Context, courseID string) error
- func (cs *CourseService) DoesCourseExist(ctx context.Context, courseID string) (bool, error)
- func (cs *CourseService) EnrollUserIntoCourse(ctx context.Context, courseID string, username string, role string, ...) error
- func (cs *CourseService) GetCourseByCourseId(ctx context.Context, courseID string) (*Course, error)
- func (cs *CourseService) GetCourseById(ctx context.Context, id string) (*Course, error)
- func (cs *CourseService) GetMembershipByID(ctx context.Context, userID string, courseID string) (*CourseMembership, error)
- func (cs *CourseService) GetMembershipByUsername(ctx context.Context, username string, courseID string) (*CourseMembership, error)
- func (cs *CourseService) GetUsers(ctx context.Context, courseID string) ([]CourseUser, error)
- func (cs *CourseService) RemoveUser(ctx context.Context, courseID string, username string) error
- func (cs *CourseService) Update(ctx context.Context, courseID string, req *CourseUpdateRequest) (*Course, error)
- func (cs *CourseService) UpdateMembership(ctx context.Context, username, courseID string, update EnrollmentRequest) error
- func (cs *CourseService) UpdateMembershipAvailability(ctx context.Context, username string, courseID string, availability string) error
- type CourseUpdateRequest
- type CourseUser
- type CreateResult
- type DeleteResult
- type DiscussionService
- type Duration
- type Enrollment
- type EnrollmentRequest
- type FailedOperation
- type GradebookColumn
- type GradebookGrading
- type GradebookService
- func (gs *GradebookService) CreateColumn(ctx context.Context, courseID, name, description string, score float64) error
- func (gs *GradebookService) CreateColumnPro(ctx context.Context, courseID string, column GradebookColumn) error
- func (gs *GradebookService) DeleteColumn(ctx context.Context, courseID string, columnID string) error
- func (gs *GradebookService) DeleteColumns(ctx context.Context, courseID string) error
- func (gs *GradebookService) GetColumn(ctx context.Context, courseID string, columnID string) (*GradebookColumn, error)
- func (gs *GradebookService) GetColumns(ctx context.Context, courseID string) ([]GradebookColumn, error)
- func (gs *GradebookService) UpdateColumnPro(ctx context.Context, courseID string, columnID string) error
- func (gs *GradebookService) UpdateColumnValue(ctx context.Context, courseID string, columnID string) error
- type Job
- type Locale
- type MembershipAvailability
- type Name
- type NameUpdate
- type PronunciationAudio
- type Token
- type UpdateResult
- type User
- type UserAvailability
- type UserService
- func (us *UserService) AddInstitutionRoles(ctx context.Context, username string, roles []string) error
- func (us *UserService) CreateUser(ctx context.Context, username string, fName string, lName string, email string, ...) error
- func (us *UserService) Delete(ctx context.Context, username string) error
- func (s *UserService) DoesUserExist(ctx context.Context, username string) (bool, error)
- func (us *UserService) GetCourses(ctx context.Context, username string) ([]CourseEnrollment, error)
- func (us *UserService) GetUserByUsername(ctx context.Context, username string) (*User, error)
- func (us *UserService) Update(ctx context.Context, username string, update UserUpdate) error
- func (us *UserService) UpdateEmail(ctx context.Context, username, newEmail string) error
- func (us *UserService) UpdateInstitutionEmail(ctx context.Context, username, newEmail string) error
- func (us *UserService) UpdateName(ctx context.Context, username, fName, lName string) error
- func (us *UserService) UpdatePassword(ctx context.Context, username, newPassword string) error
- func (us *UserService) UpdateUserAvailability(ctx context.Context, username string, availability string) error
- type UserUpdate
Constants ¶
const ( AvailabilityYes string = "Yes" AvailabilityNo string = "No" AvailabilityDisabled string = "Disabled" RoleStudent string = "Student" RoleInstructor string = "Instructor" RoleTA string = "TeachingAssistant" // These may not be universal.. // Will need to check at some point RoleCourseBuilder string = "CourseBuilder" RoleFacilitator string = "BbFacilitator" RoleSpectator string = "BbSpectator" RoleGrader string = "Grader" RoleGuest string = "Guest" )
const (
HTTP_TIMEOUT_SECS = 10
)
Variables ¶
var ( ErrInsufficientPrivileges = errors.New("insufficient privileges") ErrClientInitError = errors.New("clientID, clientSecret, and baseURL are required") ErrTokenExpired = errors.New("token expired") ErrTokenMissing = errors.New("token file missing") )
var ErrCourseExist = errors.New("course already exists")
var ErrCourseNotFound = errors.New("course doesn't exist")
Course
var ErrEmptyStringParameter = errors.New("there is a parameter that is empty string")
Client
var ErrInvalidRole = errors.New("invalid course role")
var ErrInvalidUsername = errors.New("invalid username")
var ErrMissingName = errors.New("missing first and last name")
var ErrUserAlreadyEnrolled = errors.New("user already enrolled in course, use UpdateMembership() if needed")
var ErrUserExist = errors.New("user already exists")
var ErrUserNotFound = errors.New("user account doesn't exist")
User
Functions ¶
func OptionalString ¶
OptionalString trims whitespace from a string. Unlike RequiredString, it returns the trimmed value even if it is empty, without an error.
Use this for non-mandatory fields where a blank value is acceptable like user's email
func RequiredString ¶
RequiredString trims leading and trailing whitespace from a string and returns an error if the resulting string is empty.
Use this for mandatory fields like usernames and courseIDs.
Types ¶
type Announcement ¶
type Announcement struct {
ID string `json:"id"`
Title string `json:"title"`
Body string `json:"body"`
Draft bool `json:"draft"`
Availability AnnouncementAvailability `json:"availability"`
CreatorUserID string `json:"creatorUserId"`
Created string `json:"created"`
Modified string `json:"modified"`
Position int `json:"position"`
Creator string `json:"creator"`
}
type AnnouncementAvailability ¶
type AnnouncementAvailability struct {
Duration Duration `json:"duration"`
}
type AnnouncementService ¶
type AnnouncementService struct {
// contains filtered or unexported fields
}
func (*AnnouncementService) DeleteAllAnnouncements ¶
func (c *AnnouncementService) DeleteAllAnnouncements(ctx context.Context, courseID string) error
func (*AnnouncementService) DeleteAnnouncement ¶
func (*AnnouncementService) GetAllAnnouncements ¶
func (c *AnnouncementService) GetAllAnnouncements(ctx context.Context, courseID string) ([]Announcement, error)
GetAllAnnouncements returns all the announcements from a course
func (*AnnouncementService) GetAnnouncement ¶
func (c *AnnouncementService) GetAnnouncement(ctx context.Context, courseID string, announcementID string) (Announcement, error)
GetAnnouncement get a single announcement by its ID
func (*AnnouncementService) UpdateAnnouncement ¶
type BlackboardClient ¶
type BlackboardClient struct {
BaseURL string
UserAgent string
// Sub Services
// TODO: Rename Service to Client
Users *UserService
Courses *CourseService
Announcement *AnnouncementService
Gradebook *GradebookService
Discussion *DiscussionService
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(clientID, clientSecret, baseURL string) (*BlackboardClient, error)
NewClient initializes and returns a new Blackboard API Client. It requires a Client ID and Client Secret obtained from the Blackboard Developer Portal.
func (*BlackboardClient) GetRemainingCalls ¶
func (c *BlackboardClient) GetRemainingCalls(ctx context.Context) (int, error)
GetRemainingCalls returns the number of apis calls left of the key. This does consume a call.
type ColumnAvailability ¶
type ColumnAvailability struct {
Available string `json:"available"`
}
type ColumnScore ¶
type ColumnScore struct {
Possible float64 `json:"possible"`
}
type Contact ¶
type Contact struct {
HomePhone string `json:"homePhone,omitempty"`
MobilePhone string `json:"mobilePhone,omitempty"`
BusinessPhone string `json:"businessPhone,omitempty"`
BusinessFax string `json:"businessFax,omitempty"`
Email string `json:"email,omitempty"`
InstitutionEmail string `json:"institutionEmail,omitempty"`
WebPage string `json:"webPage,omitempty"`
}
type ContactUpdate ¶
type CopyHistory ¶
type CopyHistory struct {
UUID string `json:"uuid,omitempty"`
}
type Course ¶
type Course struct {
// Required for creation
CourseID string `json:"courseId"`
Name string `json:"name"`
TermID string `json:"termId"`
// Optional for creation
Description string `json:"description,omitempty"`
Availability CourseAvailability `json:"availability"`
Organization bool `json:"organization,omitempty"`
UltraStatus string `json:"ultraStatus,omitempty"`
AllowGuests bool `json:"allowGuests,omitempty"`
AllowObservers bool `json:"allowObservers"`
ClosedComplete bool `json:"closedComplete"`
Enrollment Enrollment `json:"enrollment,omitzero"`
Locale CourseLocale `json:"locale,omitzero"`
// Read-only (set by server, ignored on create)
ID string `json:"id,omitempty"`
UUID string `json:"uuid,omitempty"`
Created *time.Time `json:"created,omitempty"`
Modified *time.Time `json:"modified,omitempty"`
ExternalID string `json:"externalId,omitempty"`
DataSourceID string `json:"dataSourceId,omitempty"`
// Stuff Populated on GET'ing
HasChildren bool `json:"hasChildren,omitempty"`
ParentID string `json:"parentId,omitempty"`
ExternalAccessURL string `json:"externalAccessUrl,omitempty"`
GuestAccessURL string `json:"guestAccessUrl,omitempty"`
CopyHistory []CopyHistory `json:"copyHistory"`
IsChild bool `json:"-"`
}
type CourseAvailability ¶
type CourseAvailability struct {
Available string `json:"available"`
Duration CourseDuration `json:"duration,omitzero"`
}
type CourseCreateRequest ¶
type CourseCreateRequest struct {
Name *string `json:"name,omitempty"`
ExternalID *string `json:"termId,omitempty"`
TermID *string `json:"externalId,omitempty"`
Availability *CourseAvailability `json:"availability,omitempty"`
DataSourceID *string `json:"dataSourceId,omitempty"`
Description *string `json:"description,omitempty"`
}
type CourseDuration ¶
type CourseEnrollment ¶
type CourseLocale ¶
type CourseMembership ¶
type CourseMembership struct {
ID string `json:"id,omitempty"`
ChildCourseID *string `json:"childCourseId,omitempty"`
UserID string `json:"userId,omitempty"`
CourseID string `json:"courseId,omitempty"`
DataSourceID string `json:"dataSourceId,omitempty"`
Created time.Time `json:"created,omitempty"`
Modified time.Time `json:"modified,omitempty"`
CourseRoleID *string `json:"courseRoleId"`
Availability *MembershipAvailability `json:"availability,omitempty"`
User *User `json:"user,omitempty"`
}
type CourseService ¶
type CourseService struct {
// contains filtered or unexported fields
}
func (*CourseService) AddChildCourse ¶
func (*CourseService) CopyCourseByCourseID ¶
func (cs *CourseService) CopyCourseByCourseID(ctx context.Context, sourceID, destinationID string) (string, error)
TODO: Rename parameters
func (*CourseService) Create ¶
func (cs *CourseService) Create(ctx context.Context, courseID string, title string, termID string) (*Course, error)
Create function that only needs the bare minimum. For simple creates.
func (*CourseService) CreateMembership ¶
func (cs *CourseService) CreateMembership(ctx context.Context, username, courseID string, update EnrollmentRequest) error
func (*CourseService) CreatePro ¶
func (cs *CourseService) CreatePro(ctx context.Context, req *CourseCreateRequest) (*Course, error)
A more advanced version of Create()
func (*CourseService) DeleteCourse ¶
func (cs *CourseService) DeleteCourse(ctx context.Context, courseID string) error
Tested 11/4/25
func (*CourseService) DoesCourseExist ¶
func (*CourseService) EnrollUserIntoCourse ¶
func (cs *CourseService) EnrollUserIntoCourse(ctx context.Context, courseID string, username string, role string, availability string) error
EnrollUserIntoCourse is a wrapper function that calls CreateMembership.
func (*CourseService) GetCourseByCourseId ¶
func (*CourseService) GetCourseById ¶
func (*CourseService) GetMembershipByID ¶
func (cs *CourseService) GetMembershipByID(ctx context.Context, userID string, courseID string) (*CourseMembership, error)
func (*CourseService) GetMembershipByUsername ¶
func (cs *CourseService) GetMembershipByUsername(ctx context.Context, username string, courseID string) (*CourseMembership, error)
func (*CourseService) GetUsers ¶
func (cs *CourseService) GetUsers(ctx context.Context, courseID string) ([]CourseUser, error)
func (*CourseService) RemoveUser ¶
RemoveUser will remove a user from a course.
func (*CourseService) Update ¶
func (cs *CourseService) Update(ctx context.Context, courseID string, req *CourseUpdateRequest) (*Course, error)
func (*CourseService) UpdateMembership ¶
func (cs *CourseService) UpdateMembership(ctx context.Context, username, courseID string, update EnrollmentRequest) error
func (*CourseService) UpdateMembershipAvailability ¶
type CourseUpdateRequest ¶
type CourseUpdateRequest struct {
Name *string `json:"name,omitempty"`
TermID *string `json:"termId,omitempty"`
Availability *CourseAvailability `json:"availability,omitempty"`
DataSourceID *string `json:"dataSourceId,omitempty"`
Description *string `json:"description,omitempty"`
}
type CourseUser ¶
type CreateResult ¶
type CreateResult struct {
Created []string
Failed []FailedOperation
}
func (CreateResult) Error ¶
func (r CreateResult) Error() string
func (CreateResult) HasErrors ¶
func (r CreateResult) HasErrors() bool
func (CreateResult) Summary ¶
func (r CreateResult) Summary() string
type DeleteResult ¶
type DeleteResult struct {
Deleted []string
Failed []FailedOperation
}
func (DeleteResult) Error ¶
func (r DeleteResult) Error() string
func (DeleteResult) HasErrors ¶
func (r DeleteResult) HasErrors() bool
func (DeleteResult) Summary ¶
func (r DeleteResult) Summary() string
type DiscussionService ¶
type DiscussionService struct {
// contains filtered or unexported fields
}
func (*DiscussionService) DeleteStudentReplies ¶
func (d *DiscussionService) DeleteStudentReplies(ctx context.Context, courseID string) (DeleteResult, error)
ClearDiscussionStudentReplies deletes all posts where author is a student.
type Enrollment ¶
type EnrollmentRequest ¶
type EnrollmentRequest struct {
ChildCourseID *string `json:"childCourseId,omitempty"`
DataSourceID *string `json:"dataSourceId,omitempty"`
Availability *MembershipAvailability `json:"availability,omitempty"`
CourseRoleID *string `json:"courseRoleId,omitempty"`
DisplayOrder *int `json:"displayOrder,omitempty"`
}
type FailedOperation ¶
type GradebookColumn ¶
type GradebookColumn struct {
ID string `json:"id,omitempty"`
ExternalID string `json:"externalId,omitempty"`
Name string `json:"name,omitempty"`
DisplayName string `json:"displayName,omitempty"`
Description string `json:"description,omitempty"`
Created string `json:"created,omitempty"`
Modified string `json:"modified,omitempty"`
Score ColumnScore `json:"score,omitzero"`
Availability ColumnAvailability `json:"availability,omitzero"`
Grading GradebookGrading `json:"grading,omitzero"`
IncludeInCalculations bool `json:"includeInCalculations,omitempty"`
ShowStatisticsToStudents bool `json:"showStatisticsToStudents,omitempty"`
}
type GradebookGrading ¶
type GradebookService ¶
type GradebookService struct {
// contains filtered or unexported fields
}
func (*GradebookService) CreateColumn ¶
func (*GradebookService) CreateColumnPro ¶
func (gs *GradebookService) CreateColumnPro(ctx context.Context, courseID string, column GradebookColumn) error
func (*GradebookService) DeleteColumn ¶
func (*GradebookService) DeleteColumns ¶
func (gs *GradebookService) DeleteColumns(ctx context.Context, courseID string) error
func (*GradebookService) GetColumn ¶
func (gs *GradebookService) GetColumn(ctx context.Context, courseID string, columnID string) (*GradebookColumn, error)
func (*GradebookService) GetColumns ¶
func (gs *GradebookService) GetColumns(ctx context.Context, courseID string) ([]GradebookColumn, error)
func (*GradebookService) UpdateColumnPro ¶
func (*GradebookService) UpdateColumnValue ¶
type MembershipAvailability ¶
type MembershipAvailability struct {
Available *string `json:"available,omitempty"`
}
type Name ¶
type Name struct {
Given string `json:"given,omitempty"`
Family string `json:"family,omitempty"`
Middle string `json:"middle,omitempty"`
Other string `json:"other,omitempty"`
Suffix string `json:"suffix,omitempty"`
Title string `json:"title,omitempty"`
PreferredDisplayName string `json:"preferredDisplayName,omitempty"`
}
type NameUpdate ¶
type PronunciationAudio ¶
type PronunciationAudio struct {
UploadID string `json:"uploadId,omitempty"`
}
type Token ¶
type UpdateResult ¶
type UpdateResult struct {
Updated []string
Failed []FailedOperation
}
func (UpdateResult) Error ¶
func (r UpdateResult) Error() string
func (UpdateResult) HasErrors ¶
func (r UpdateResult) HasErrors() bool
func (UpdateResult) Summary ¶
func (r UpdateResult) Summary() string
type User ¶
type User struct {
ID string `json:"id,omitempty"`
UUID string `json:"uuid,omitempty"`
ExternalID string `json:"externalId,omitempty"`
DataSourceID string `json:"dataSourceId,omitempty"`
UserName string `json:"userName"`
StudentID string `json:"studentId,omitempty"`
Password string `json:"password,omitempty"`
EducationLevel string `json:"educationLevel,omitempty"`
Gender string `json:"gender,omitempty"`
Pronouns string `json:"pronouns,omitempty"`
BirthDate *time.Time `json:"birthDate,omitempty"`
InstitutionRoleIDs []string `json:"institutionRoleIds"`
SystemRoleIDs []string `json:"systemRoleIds,omitempty"`
Availability UserAvailability `json:"availability,omitzero"`
Name Name `json:"name,omitzero"`
Job Job `json:"job,omitzero"`
Contact Contact `json:"contact,omitzero"`
Address Address `json:"address,omitzero"`
Locale Locale `json:"locale,omitzero"`
Avatar Avatar `json:"avatar,omitzero"`
Pronunciation string `json:"pronunciation,omitempty"`
PronunciationAudio PronunciationAudio `json:"pronunciationAudio,omitzero"`
}
type UserAvailability ¶
type UserAvailability struct {
Available string `json:"available"`
}
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
func (*UserService) AddInstitutionRoles ¶
func (*UserService) CreateUser ¶
func (*UserService) Delete ¶
func (us *UserService) Delete(ctx context.Context, username string) error
func (*UserService) DoesUserExist ¶
func (*UserService) GetCourses ¶
func (us *UserService) GetCourses(ctx context.Context, username string) ([]CourseEnrollment, error)
func (*UserService) GetUserByUsername ¶
GetUserObject fetches user data and maps to User struct
func (*UserService) Update ¶
func (us *UserService) Update(ctx context.Context, username string, update UserUpdate) error
func (*UserService) UpdateEmail ¶
func (us *UserService) UpdateEmail(ctx context.Context, username, newEmail string) error
func (*UserService) UpdateInstitutionEmail ¶
func (us *UserService) UpdateInstitutionEmail(ctx context.Context, username, newEmail string) error
func (*UserService) UpdateName ¶
func (us *UserService) UpdateName(ctx context.Context, username, fName, lName string) error
func (*UserService) UpdatePassword ¶
func (us *UserService) UpdatePassword(ctx context.Context, username, newPassword string) error
func (*UserService) UpdateUserAvailability ¶
type UserUpdate ¶
type UserUpdate struct {
Contact *ContactUpdate `json:"contact,omitempty"`
Name *NameUpdate `json:"name,omitempty"`
Password *string `json:"password,omitempty"`
InstitutionRoleIDs []string `json:"institutionRoleIds,omitempty"`
Availability *UserAvailability `json:"availability,omitempty"`
}