From daea28f729739d0075918b4e54907eaa6bd27ebd Mon Sep 17 00:00:00 2001 From: Michael Grace Date: Tue, 31 Oct 2023 22:11:50 +0000 Subject: [PATCH 1/4] training and officership --- user.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/user.go b/user.go index 0ada041..83c6444 100644 --- a/user.go +++ b/user.go @@ -27,6 +27,7 @@ type Officership struct { FromDate time.Time TillDateRaw string `json:"till_date,omitempty"` TillDate time.Time + Officer OfficerPosition `json:"officer"` } // Photo represents a photo of a user. @@ -51,6 +52,11 @@ type College struct { CollegeName string `json:"text"` } +type Training struct { + StatusID int `json:"status_id"` + Title string `json:"title"` +} + // GetUser retrieves the User with the given ID. // This consumes one API request. func (s *Session) GetUser(id int) (user *User, err error) { @@ -156,3 +162,8 @@ func (s *Session) GetColleges() (colleges []College, err error) { err = s.get("/user/colleges").Into(&colleges) return } + +func (s *Session) GetUserTraining(userID int) (trainings []Training, err error) { + err = s.getf("/user/%d/alltraining", userID).Into(&trainings) + return +} From cf6bb78851a4440fd27cfd0a9edd26cf367c2879 Mon Sep 17 00:00:00 2001 From: Michael Grace Date: Wed, 1 Nov 2023 16:28:57 +0000 Subject: [PATCH 2/4] training sessions --- training.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 training.go diff --git a/training.go b/training.go new file mode 100644 index 0000000..1b00777 --- /dev/null +++ b/training.go @@ -0,0 +1,26 @@ +package myradio + +import ( + "time" + + "github.com/UniversityRadioYork/myradio-go/api" +) + +type TrainingSession struct { + StartTimeRaw string `json:"demo_time"` + Host string `json:"member"` + HostMemberID int `json:"memberid"` +} + +func (ts *TrainingSession) StartTime() time.Time { + t, _ := time.Parse("Mon 02 Jan 15:04", ts.StartTimeRaw) + + return time.Date(time.Now().Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), 0, 0, time.Local) +} + +func (s *Session) GetFutureTrainingSessions() (sessions []TrainingSession, err error) { + rq := api.NewRequestf("/demo/listdemos") + err = s.do(rq).Into(&sessions) + + return +} From 325814be9b9f07c1a044c4a8cc0986bc01eae73b Mon Sep 17 00:00:00 2001 From: michael-grace Date: Wed, 29 May 2024 15:16:51 +0100 Subject: [PATCH 3/4] add term methods --- term.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 term.go diff --git a/term.go b/term.go new file mode 100644 index 0000000..757f6ee --- /dev/null +++ b/term.go @@ -0,0 +1,30 @@ +package myradio + +import ( + "errors" + "fmt" + "time" + + "github.com/UniversityRadioYork/myradio-go/api" +) + +// Term represents information about a MyRadio scheduling term +type Term struct { + TermID int `json:"term_id"` + Start int `json:"start"` + Description string `json:"descr"` + NumWeeks int `json:"num_weeks"` + WeekNames []string `json:"week_names"` +} + +// StartTime returns the start of the term as a time.Time object +func (t *Term) StartTime() (time.Time) { + return time.Unix(t.Start, 0) +} + +// GetAllTerms retrieves all the terms MyRadio is aware of (past and future) +func (s *Session) GetAllTerms() (terms []Term, err error) { + err = s.get("/term/allterms/").Into(&terms) + return +} + From 5d3831f963628e854cf9e8b35f7f2cfb6267a48c Mon Sep 17 00:00:00 2001 From: Michael Grace <56653532+michael-grace@users.noreply.github.com> Date: Wed, 12 Jun 2024 17:49:04 +0100 Subject: [PATCH 4/4] fix errors --- term.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/term.go b/term.go index 757f6ee..7431596 100644 --- a/term.go +++ b/term.go @@ -1,17 +1,13 @@ package myradio import ( - "errors" - "fmt" "time" - - "github.com/UniversityRadioYork/myradio-go/api" ) // Term represents information about a MyRadio scheduling term type Term struct { TermID int `json:"term_id"` - Start int `json:"start"` + Start int64 `json:"start"` Description string `json:"descr"` NumWeeks int `json:"num_weeks"` WeekNames []string `json:"week_names"`