Documentation ¶
Index ¶
- Variables
- func CheckPasswordHash(password, hash string) bool
- func CreatePayload(data map[string]string) url.Values
- func HashPassword(password string) (string, error)
- type Attachment
- type Canteen
- type CanteenPayload
- type Credentials
- type Day
- type EdupageClient
- func (e *EdupageClient) ChangeOrderStatus(day Day, order bool) error
- func (client *EdupageClient) FetchHomeworkAttachments(i model.Homework) (map[string]string, error)
- func (client *EdupageClient) GetCanteen(date time.Time) (Canteen, error)
- func (client *EdupageClient) GetClassroomByID(id string) (model.Classroom, error)
- func (client *EdupageClient) GetRecentCanteen() (Canteen, error)
- func (client *EdupageClient) GetRecentResults() (model.Results, error)
- func (client *EdupageClient) GetRecentTimeline() (model.Timeline, error)
- func (client *EdupageClient) GetRecentTimetable() (model.Timetable, error)
- func (client *EdupageClient) GetResults(year, halfyear string) (model.Results, error)
- func (client *EdupageClient) GetStudentID() (string, error)
- func (client *EdupageClient) GetSubjectByID(id string) (model.Subject, error)
- func (client *EdupageClient) GetTeacherByID(id string) (model.Teacher, error)
- func (client *EdupageClient) GetTimeline(from, to time.Time) (model.Timeline, error)
- func (client *EdupageClient) GetTimetable(from, to time.Time) (model.Timetable, error)
- func (client *EdupageClient) GetUser(update bool) (model.User, error)
- func (client *EdupageClient) PingSession() (bool, error)
- func (client *EdupageClient) SendMessage(recipient string, options MessageOptions) error
- func (client *EdupageClient) UpdateCredentials(credentials Credentials)
- type Meal
- type Menu
- type MessageOptions
- type MessagePayload
- type PollOption
- type PollOptions
- type PortalPingResponse
Constants ¶
This section is empty.
Variables ¶
var ( ErrorUnitialized = errors.New("unitialized") ErrorNotFound = errors.New("not found") ErrorUnchangeable = errors.New("can not make changes at this time") )
var ( ErrAuthorization = errors.New("failed to authorize") ErrRedirect = errors.New("redirect") )
var (
Server = ""
)
Functions ¶
func CheckPasswordHash ¶
func HashPassword ¶
Types ¶
type Attachment ¶
type Attachment struct { }
type Canteen ¶
Represents the canteen, contains menu information, and additional information
func CreateCanteen ¶
CreateCanteen creates Canteen object from model.Canteen
type CanteenPayload ¶
type CanteenPayload struct { BoarderID string `json:"stravnikid"` Edupage string `json:"edupage"` BoarderUser string `json:"stravnikUser,omitempty"` Date string `json:"mysqlDate"` // YYYY-mm-dd FIDS map[string]string `json:"jids"` View string `json:"view"` Permission string `json:"pravo"` Action string `json:"akcia"` }
type Credentials ¶
type Credentials struct { Server string PasswordHash string // contains filtered or unexported fields }
func Login ¶
func Login(username, password, server string) (Credentials, error)
Login creates EdupageClient you can use to interact the edupage api with. Returns EdupageClient or error.
type Day ¶
type Day struct { Date time.Time AvailableFrom time.Time AvailableTo time.Time Ordered bool OrderableUntil time.Time CancelableUntil time.Time Menus []Menu }
type EdupageClient ¶
type EdupageClient struct { Credentials Credentials // contains filtered or unexported fields }
EdupageClient is used to access the edupage api.
func CreateClient ¶
func CreateClient(credentials Credentials) (*EdupageClient, error)
CreateClient is used to create a client struct
func (*EdupageClient) ChangeOrderStatus ¶
func (e *EdupageClient) ChangeOrderStatus(day Day, order bool) error
ChangeOrderStatus changed order status of a meal for the specified day Return ErrorUnathorized, ErrorUnitialized, ErrorUnchangeable
func (*EdupageClient) FetchHomeworkAttachments ¶
FetchHomeworkAttachmens obtains the homework attchments for the specified homework. Returns ErrUnobtainableAttachments in case the attachments are not present. Retruns map, key is the resource name and value is the resource link
func (*EdupageClient) GetCanteen ¶
func (client *EdupageClient) GetCanteen(date time.Time) (Canteen, error)
GetCanteen retrieves the whole week's canteen from the specified day. Return ErrorUnauthorized if an authorization error occcurs.
func (*EdupageClient) GetClassroomByID ¶
func (client *EdupageClient) GetClassroomByID(id string) (model.Classroom, error)
GetClassroomByID is used to retrieve the classroom by it's specified ID. Returns ErrorNotFound if the classroom can't be found. Returns ErrorUnitialized if the user object hasn't been initialized.
func (*EdupageClient) GetRecentCanteen ¶
func (client *EdupageClient) GetRecentCanteen() (Canteen, error)
GetCanteen retrieves the current week's canteen menu. Return ErrorUnauthorized if an authorization error occcurs.
func (*EdupageClient) GetRecentResults ¶
func (client *EdupageClient) GetRecentResults() (model.Results, error)
GetRecentResults retrieves the results from the current year from edupage. Return ErrorUnauthorized if an authorization error occcurs.
func (*EdupageClient) GetRecentTimeline ¶
func (client *EdupageClient) GetRecentTimeline() (model.Timeline, error)
GetRecentTimeline retrieves last 30 days of timeline from edupage. Return ErrorUnauthorized if an authorization error occcurs.
func (*EdupageClient) GetRecentTimetable ¶
func (client *EdupageClient) GetRecentTimetable() (model.Timetable, error)
GetResults retrieves this week's timetable from edupage.
func (*EdupageClient) GetResults ¶
func (client *EdupageClient) GetResults(year, halfyear string) (model.Results, error)
GetResults retrieves the results in a specified interval from edupage. Halfyears types are: P1 (first halfyear), P2 (second halfyear), RX (whole year) Return ErrorUnauthorized if an authorization error occcurs.
func (*EdupageClient) GetStudentID ¶
func (client *EdupageClient) GetStudentID() (string, error)
GetStudentID is used to retrieve the client's student ID. Returns ErrorUnitialized if the user object hasn't been initialized.
func (*EdupageClient) GetSubjectByID ¶
func (client *EdupageClient) GetSubjectByID(id string) (model.Subject, error)
GetSubjectByID is used to retrieve the subject by it's specified ID. Returns ErrorNotFound if the subject can't be found. Returns ErrorUnitialized if the user object hasn't been initialized.
func (*EdupageClient) GetTeacherByID ¶
func (client *EdupageClient) GetTeacherByID(id string) (model.Teacher, error)
GetTeacherByID is used to retrieve the teacher by their specified ID. Returns ErrorNotFound if the teacher can't be found. Returns ErrorUnitialized if the user object hasn't been initialized.
func (*EdupageClient) GetTimeline ¶
GetUser retrieves the timeline in a specified time interval from edupage. Return ErrorUnauthorized if an authorization error occcurs.
func (*EdupageClient) GetTimetable ¶
GetResults retrieves the timetable in the specified interval from edupage. Return ErrorUnauthorized if an authorization error occcurs.
func (*EdupageClient) GetUser ¶
func (client *EdupageClient) GetUser(update bool) (model.User, error)
GetUser retrieves the user from edupage or returns the stored data. If update is set to true, user data wil explicitly update Return ErrorUnauthorized if an authorization error occcurs.
func (*EdupageClient) PingSession ¶
func (client *EdupageClient) PingSession() (bool, error)
func (*EdupageClient) SendMessage ¶
func (client *EdupageClient) SendMessage(recipient string, options MessageOptions) error
func (*EdupageClient) UpdateCredentials ¶
func (client *EdupageClient) UpdateCredentials(credentials Credentials)
UpdateCredentials updates the credentials and allows this struct to continue working after token expiry.
type MessageOptions ¶
type MessageOptions struct { Text string `json:"text"` Important bool `json:"important,omitempty"` Parents bool `json:"parents,omitempty"` AllowReplies *bool `json:"allowReplies,omitempty"` RepliesToAuthorOnly bool `json:"repliesToAuthorOnly,omitempty"` Attachments []string `json:"attachments,omitempty"` Poll *PollOptions `json:"poll,omitempty"` }
func (*MessageOptions) UnmarshalJSON ¶
func (m *MessageOptions) UnmarshalJSON(data []byte) error
type MessagePayload ¶
func CreateMessage ¶
func CreateMessage(receiver, text, attachments string) MessagePayload
type PollOption ¶
type PollOptions ¶
type PollOptions struct { Options []PollOption `json:"options"` Multiple bool `json:"multiple,omitempty"` }
type PortalPingResponse ¶
type PortalPingResponse struct {
Status string `json:"status"`
}