diff --git a/api.go b/api.go index e71d67c..ded1e78 100644 --- a/api.go +++ b/api.go @@ -192,32 +192,39 @@ func GetClassDetails(term int, crn int) *ClassDetails { return &ClassDetails{} } -type MeetingTimeInnerResponse struct { - Category string `json:"category"` - Class string `json:"class"` - StartDate string `json:"startDate"` - EndDate string `json:"endDate"` - BeginTime string `json:"beginTime"` - EndTime string `json:"endTime"` - Room string `json:"room"` - Term string `json:"term"` - Building string `json:"building"` - BuildingDescription string `json:"buildingDescription"` - Campus string `json:"campus"` - CampusDescription string `json:"campusDescription"` - CourseReferenceNumber string `json:"courseReferenceNumber"` - CreditHourSession float64 `json:"creditHourSession"` - HoursWeek float64 `json:"hoursWeek"` - MeetingScheduleType string `json:"meetingScheduleType"` - MeetingType string `json:"meetingType"` - MeetingTypeDescription string `json:"meetingTypeDescription"` - Monday bool `json:"monday"` - Tuesday bool `json:"tuesday"` - Wednesday bool `json:"wednesday"` - Thursday bool `json:"thursday"` - Friday bool `json:"friday"` - Saturday bool `json:"saturday"` - Sunday bool `json:"sunday"` +type MeetingTimeResponse struct { + Category *string `json:"category"` + Class string `json:"class"` + CourseReferenceNumber string `json:"courseReferenceNumber"` + Faculty []struct{} + MeetingTime struct { + Category string `json:"category"` + Class string `json:"class"` + StartDate string `json:"startDate"` + EndDate string `json:"endDate"` + BeginTime string `json:"beginTime"` + EndTime string `json:"endTime"` + Room string `json:"room"` + Term string `json:"term"` + Building string `json:"building"` + BuildingDescription string `json:"buildingDescription"` + Campus string `json:"campus"` + CampusDescription string `json:"campusDescription"` + CourseReferenceNumber string `json:"courseReferenceNumber"` + CreditHourSession float64 `json:"creditHourSession"` + HoursWeek float64 `json:"hoursWeek"` + MeetingScheduleType string `json:"meetingScheduleType"` + MeetingType string `json:"meetingType"` + MeetingTypeDescription string `json:"meetingTypeDescription"` + Monday bool `json:"monday"` + Tuesday bool `json:"tuesday"` + Wednesday bool `json:"wednesday"` + Thursday bool `json:"thursday"` + Friday bool `json:"friday"` + Saturday bool `json:"saturday"` + Sunday bool `json:"sunday"` + } `json:"meetingTime"` + Term string `json:"term"` } type SearchResult struct { @@ -272,14 +279,7 @@ type SearchResult struct { Primary bool `json:"primaryIndicator"` Term string `json:"term"` } `json:"faculty"` - MeetingsFaculty []struct { - Category *string `json:"category"` - Class string `json:"class"` - CourseReferenceNumber string `json:"courseReferenceNumber"` - Faculty []struct{} - MeetingTime MeetingTimeInnerResponse `json:"meetingTime"` - Term string `json:"term"` - } + MeetingsFaculty []MeetingTimeResponse `json:"meetingsFaculty"` } `json:"data"` } @@ -404,7 +404,7 @@ func GetInstructionalMethods(search string, term int, offset int, max int) ([]In // GetCourseMeetingTime retrieves the meeting time information for a course based on the given term and course reference number (CRN). // It makes an HTTP GET request to the appropriate API endpoint and parses the response to extract the meeting time data. // The function returns a MeetingTimeResponse struct containing the extracted information. -func GetCourseMeetingTime(term int, crn int) (*MeetingTimeResponse, error) { +func GetCourseMeetingTime(term int, crn int) (*PrettyMeetingTimeResponse, error) { req := BuildRequest("GET", "/searchResults/getFacultyMeetingTimes", map[string]string{ "term": strconv.Itoa(term), "courseReferenceNumber": strconv.Itoa(crn), @@ -483,7 +483,7 @@ func GetCourseMeetingTime(term int, crn int) (*MeetingTimeResponse, error) { }) } - return &MeetingTimeResponse{ + return &PrettyMeetingTimeResponse{ faculty: faculty, weekdays: weekdays, campus: campus, diff --git a/main.go b/main.go index 2b4caf7..84a0fbe 100644 --- a/main.go +++ b/main.go @@ -189,7 +189,6 @@ func main() { if err != nil { log.Fatal().Err(err).Msg("Cannot get existing commands") } - newCommands, err := session.ApplicationCommandBulkOverwrite(session.State.User.ID, guildTarget, commandDefinitions) if err != nil { log.Fatal().Err(err).Msg("Cannot register commands") @@ -217,11 +216,10 @@ func main() { log.Info().Msg("Command registration complete") // Fetch terms on startup - terms, err := GetTerms("", 1, 10) + _, err = GetTerms("", 1, 10) if err != nil { log.Fatal().Err(err).Msg("Cannot get terms") } - log.Debug().Interface("terms", terms).Msg("Terms") // Term Select Pre-Search POST var termSelect string diff --git a/types.go b/types.go index c80c0a1..4202819 100644 --- a/types.go +++ b/types.go @@ -12,7 +12,7 @@ type MeetingTimeFaculty struct { primary bool } -type MeetingTimeResponse struct { +type PrettyMeetingTimeResponse struct { faculty []MeetingTimeFaculty weekdays map[time.Weekday]bool campus string