mirror of
https://github.com/Xevion/banner.git
synced 2025-12-10 20:06:32 -06:00
Get closer to unified MeetingTimeResponse parsing
This commit is contained in:
22
api.go
22
api.go
@@ -192,7 +192,12 @@ func GetClassDetails(term int, crn int) *ClassDetails {
|
|||||||
return &ClassDetails{}
|
return &ClassDetails{}
|
||||||
}
|
}
|
||||||
|
|
||||||
type MeetingTimeInnerResponse struct {
|
type MeetingTimeResponse struct {
|
||||||
|
Category *string `json:"category"`
|
||||||
|
Class string `json:"class"`
|
||||||
|
CourseReferenceNumber string `json:"courseReferenceNumber"`
|
||||||
|
Faculty []struct{}
|
||||||
|
MeetingTime struct {
|
||||||
Category string `json:"category"`
|
Category string `json:"category"`
|
||||||
Class string `json:"class"`
|
Class string `json:"class"`
|
||||||
StartDate string `json:"startDate"`
|
StartDate string `json:"startDate"`
|
||||||
@@ -218,6 +223,8 @@ type MeetingTimeInnerResponse struct {
|
|||||||
Friday bool `json:"friday"`
|
Friday bool `json:"friday"`
|
||||||
Saturday bool `json:"saturday"`
|
Saturday bool `json:"saturday"`
|
||||||
Sunday bool `json:"sunday"`
|
Sunday bool `json:"sunday"`
|
||||||
|
} `json:"meetingTime"`
|
||||||
|
Term string `json:"term"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SearchResult struct {
|
type SearchResult struct {
|
||||||
@@ -272,14 +279,7 @@ type SearchResult struct {
|
|||||||
Primary bool `json:"primaryIndicator"`
|
Primary bool `json:"primaryIndicator"`
|
||||||
Term string `json:"term"`
|
Term string `json:"term"`
|
||||||
} `json:"faculty"`
|
} `json:"faculty"`
|
||||||
MeetingsFaculty []struct {
|
MeetingsFaculty []MeetingTimeResponse `json:"meetingsFaculty"`
|
||||||
Category *string `json:"category"`
|
|
||||||
Class string `json:"class"`
|
|
||||||
CourseReferenceNumber string `json:"courseReferenceNumber"`
|
|
||||||
Faculty []struct{}
|
|
||||||
MeetingTime MeetingTimeInnerResponse `json:"meetingTime"`
|
|
||||||
Term string `json:"term"`
|
|
||||||
}
|
|
||||||
} `json:"data"`
|
} `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).
|
// 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.
|
// 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.
|
// 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{
|
req := BuildRequest("GET", "/searchResults/getFacultyMeetingTimes", map[string]string{
|
||||||
"term": strconv.Itoa(term),
|
"term": strconv.Itoa(term),
|
||||||
"courseReferenceNumber": strconv.Itoa(crn),
|
"courseReferenceNumber": strconv.Itoa(crn),
|
||||||
@@ -483,7 +483,7 @@ func GetCourseMeetingTime(term int, crn int) (*MeetingTimeResponse, error) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return &MeetingTimeResponse{
|
return &PrettyMeetingTimeResponse{
|
||||||
faculty: faculty,
|
faculty: faculty,
|
||||||
weekdays: weekdays,
|
weekdays: weekdays,
|
||||||
campus: campus,
|
campus: campus,
|
||||||
|
|||||||
4
main.go
4
main.go
@@ -189,7 +189,6 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err).Msg("Cannot get existing commands")
|
log.Fatal().Err(err).Msg("Cannot get existing commands")
|
||||||
}
|
}
|
||||||
|
|
||||||
newCommands, err := session.ApplicationCommandBulkOverwrite(session.State.User.ID, guildTarget, commandDefinitions)
|
newCommands, err := session.ApplicationCommandBulkOverwrite(session.State.User.ID, guildTarget, commandDefinitions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err).Msg("Cannot register commands")
|
log.Fatal().Err(err).Msg("Cannot register commands")
|
||||||
@@ -217,11 +216,10 @@ func main() {
|
|||||||
log.Info().Msg("Command registration complete")
|
log.Info().Msg("Command registration complete")
|
||||||
|
|
||||||
// Fetch terms on startup
|
// Fetch terms on startup
|
||||||
terms, err := GetTerms("", 1, 10)
|
_, err = GetTerms("", 1, 10)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal().Err(err).Msg("Cannot get terms")
|
log.Fatal().Err(err).Msg("Cannot get terms")
|
||||||
}
|
}
|
||||||
log.Debug().Interface("terms", terms).Msg("Terms")
|
|
||||||
|
|
||||||
// Term Select Pre-Search POST
|
// Term Select Pre-Search POST
|
||||||
var termSelect string
|
var termSelect string
|
||||||
|
|||||||
2
types.go
2
types.go
@@ -12,7 +12,7 @@ type MeetingTimeFaculty struct {
|
|||||||
primary bool
|
primary bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type MeetingTimeResponse struct {
|
type PrettyMeetingTimeResponse struct {
|
||||||
faculty []MeetingTimeFaculty
|
faculty []MeetingTimeFaculty
|
||||||
weekdays map[time.Weekday]bool
|
weekdays map[time.Weekday]bool
|
||||||
campus string
|
campus string
|
||||||
|
|||||||
Reference in New Issue
Block a user