Documentation ¶
Overview ¶
Package api provides abstractions for the REST API.
Index ¶
- Constants
- Variables
- func GetImageFromMd(src string) (alt, url string, found bool)
- type Ann
- type AnnFeedReq
- type AnnFeedResp
- type AnnID
- type AnnReq
- type AnnResp
- type Auth
- type AuthReReq
- type AuthReResp
- type AuthReq
- type AuthResp
- type Client
- func (c *Client) BaseURL() *url.URL
- func (c *Client) CheckAPIVersion() (string, bool, error)
- func (c *Client) CourseEvents() (evs []Event, err error)
- func (c *Client) Do(req Req, v interface{}) (err error)
- func (c *Client) Events(req EventsReq) (resp EventsResp, err error)deprecated
- func (c *Client) HTTPClient() HTTPClient
- func (c *Client) Rel(u *url.URL) *url.URL
- type Course
- type CourseCode
- type CourseID
- type Data
- type Event
- type EventID
- type Events
- type EventsReq
- type EventsResp
- type HTTPClient
- type MeReq
- type MeResp
- type MeScheduleReq
- type MeScheduleResp
- type MeScheduleWeekReq
- type MeScheduleWeekResp
- type MeTimetableReq
- type MeTimetableResp
- type OauthReq
- type Org
- type OrgName
- type OrgReq
- type OrgResp
- type OrgSlug
- type OrgsReq
- type OrgsResp
- type Req
- type Schedule
- type StatusError
- type Tag
- type TagID
- type Term
- type TermID
- type TermsReq
- type TermsResp
- type Timeframe
- type User
- type UserReq
- type UserResp
- type Username
- type VersionReq
- type VersionResp
Constants ¶
const APIVersion = "v3.2.0"
APIVersion is the API version this library is compatible with.
Variables ¶
var ( ErrMultipleLateStarts = errors.New("multiple late starts found") ErrSchoolNotOpen = errors.New("school not open") )
var DefaultBaseURL, _ = url.Parse("https://maclyonsden.com/api/")
var Reqs = [...]Req{ AuthReq{}, AuthReReq{}, AnnFeedReq{}, AnnReq{}, OrgReq{}, OrgsReq{}, UserReq{}, MeReq{}, MeScheduleReq{}, MeScheduleWeekReq{}, MeTimetableReq{}, EventsReq{}, TermsReq{}, VersionReq{}, }
Functions ¶
func GetImageFromMd ¶
Types ¶
type Ann ¶
type Ann struct { Id AnnID `json:"id"` Author Username `json:"author"` Org OrgName `json:"organization"` Tags []Tag `json:"tags"` Created time.Time `json:"created_date"` LastModified time.Time `json:"last_modified_date"` Title string `json:"title"` Body string `json:"body"` Public bool `json:"is_public"` // fields below are not in the API XAuthor UserResp XOrg Org XImageURL string XImagePath string XImageAlt string XURL string }
Ann represents an announcement. Model: core.models.post.Announcement Serializer: core.api.serializers.announcement.AnnouncementSerializer
type AnnFeedReq ¶
type AnnFeedReq struct {
Auth
}
type AnnFeedResp ¶
type AnnFeedResp []Ann
type AuthReResp ¶
type AuthReResp struct {
Access string `json:"access"`
}
func (AuthReResp) UpdateAuth ¶
func (resp AuthReResp) UpdateAuth(a *Auth)
type AuthResp ¶
func (AuthResp) UpdateAuth ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func DefaultClient ¶
func DefaultClient() *Client
func (*Client) CheckAPIVersion ¶
CheckAPIVersion checks whether the API server supports the API version the Client is compatible with.
func (*Client) CourseEvents ¶
CourseEvents generates Event s from the course schedule.
TODO: use MeScheduleResp or MeTimetableResp to generate events for 2+ weeks.
func (*Client) Events
deprecated
func (c *Client) Events(req EventsReq) (resp EventsResp, err error)
Deprecated: use Client.Do instead.
func (*Client) HTTPClient ¶
func (c *Client) HTTPClient() HTTPClient
type Course ¶
type Course struct { Id CourseID `json:"id"` Code CourseCode `json:"code"` Term TermID `json:"term"` Desc string `json:"description"` Position int `json:"position"` Submitter interface{} `json:"submitter"` }
Course represents a course. TODO: fill model Model: core.models.course.Course Serializer: core.api.serializers.course.CourseSerializer
type CourseCode ¶
type CourseCode string
type Event ¶
type Event struct { Id EventID `json:"id"` Name string `json:"name"` Desc string `json:"description"` Tags []Tag `json:"tags"` Term TermID `json:"term"` Org Org `json:"organization"` Start time.Time `json:"start_date"` End time.Time `json:"end_date"` Public bool `json:"is_public"` }
Event represents an event, Model: core.models.course.Event Serializer: core.api.serializers.course.EventSerializer
type Events ¶
type Events struct {
// contains filtered or unexported fields
}
func NewEvents ¶
func NewEvents(resp EventsResp) *Events
type EventsReq ¶
EventsReq has the options for a Client.Events API call.
type EventsResp ¶
type EventsResp = []Event
EventsResp is the expected response from a Client.Events API call.
type HTTPClient ¶
HTTPClient is a subset of the *http.Client interface.
type MeResp ¶
type MeResp struct { Username string `json:"username"` FirstName string `json:"first_name"` LastName string `json:"last_name"` Bio string `json:"bio"` Timezone string `json:"timezone"` GraduatingYear *int `json:"graduating_year"` Organizations []string `json:"organizations"` TagsFollowing []string `json:"tags_following"` }
type MeScheduleReq ¶
type MeScheduleReq struct {
Auth
}
type MeScheduleResp ¶
type MeScheduleResp = []Schedule
type MeScheduleWeekReq ¶
type MeScheduleWeekReq struct {
Auth
}
type MeScheduleWeekResp ¶
type MeTimetableReq ¶
type MeTimetableReq struct {
Auth
}
type MeTimetableResp ¶
type Org ¶
type Org struct { Id int `json:"id"` Owner User `json:"owner"` Supervisors []User `json:"supervisors"` Execs []User `json:"execs"` Tags []Tag `json:"tags"` Name OrgName `json:"name"` Bio string `json:"bio"` Extra string `json:"extra_content"` Slug OrgSlug `json:"slug"` Registered time.Time `json:"registered_date"` Open bool `json:"is_open"` AppsOpen bool `json:"applications_open"` Banner string `json:"banner"` Icon string `json:"icon"` }
Org represents an organization. Model:core.models.organization.Org Serializer: core.api.serializers.organization.OrganizationSerializer
type Schedule ¶
type StatusError ¶
type StatusError struct {
// contains filtered or unexported fields
}
func (StatusError) Error ¶
func (err StatusError) Error() string
type Term ¶
type Term struct { Id TermID `json:"id"` Name string `json:"name"` Desc string `json:"description"` Fmt string `json:"timetable_format"` Start time.Time `json:"start"` End time.Time `json:"end"` Frozen bool `json:"is_frozen"` }
Term represents a term. TODO: fill model Model: core.models.course.Term Serializer: core.api.serializers.course.TermSerializer
type User ¶
type User struct { Username Username `json:"username"` FirstName string `json:"first_name"` LastName string `json:"last_name"` Bio string `json:"bio"` Timezone string `json:"timezone"` GraduatingYear int `json:"graduating_year"` Organizations []string `json:"organizations"` TagsFollowing []interface{} `json:"tags_following"` }
type VersionReq ¶
type VersionReq struct{}
type VersionResp ¶
type VersionResp struct {
Version string `json:"version"`
}
Source Files ¶
- api_ann.go
- api_annFeed.go
- api_auth.go
- api_authRe.go
- api_events.go
- api_me.go
- api_me_schedule.go
- api_me_schedule_week.go
- api_me_timetable.go
- api_org.go
- api_orgs.go
- api_terms.go
- api_user.go
- api_version.go
- auth.go
- client.go
- errors.go
- events.go
- image.go
- main.go
- oauth.go
- ptr.go
- types.go
- util.go
- version.go