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

Off air booking calendar features #68

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
26 changes: 26 additions & 0 deletions term.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package myradio

import (
"time"
)

// Term represents information about a MyRadio scheduling term
type Term struct {
TermID int `json:"term_id"`
Start int64 `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
}

26 changes: 26 additions & 0 deletions training.go
Original file line number Diff line number Diff line change
@@ -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
}
11 changes: 11 additions & 0 deletions user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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) {
Expand Down Expand Up @@ -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
}