-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathofficer.go
48 lines (42 loc) · 1.2 KB
/
officer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package myradio
import (
"time"
"github.com/UniversityRadioYork/myradio-go/api"
)
// OfficerPosition represents a specific station officer position.
type OfficerPosition struct {
OfficerID int
Name string
Alias string
Team Team
Ordering int
Description string
Status string
Type string
Current []User `json:"current,omitempty"`
History []struct {
User User
From time.Time
FromRaw int64 `json:"from"`
To time.Time
ToRaw int64 `json:"to"`
MemberOfficerID int
} `json:"history,omitempty"`
}
// GetAllOfficerPositions retrieves all officer positions in MyRadio.
// The amount of detail can be controlled by adding MyRadio mixins.
// This consumes one API request.
func (s *Session) GetAllOfficerPositions(mixins []string) (positions []OfficerPosition, err error) {
rq := api.NewRequest("/officer/allofficerpositions")
rq.Mixins = mixins
if err = s.do(rq).Into(&positions); err != nil {
return
}
for k, v := range positions {
for ik, iv := range v.History {
positions[k].History[ik].From = time.Unix(iv.FromRaw, 0)
positions[k].History[ik].To = time.Unix(iv.ToRaw, 0)
}
}
return
}