fetch

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 9, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventDateStart   = "DTSTART"
	EventDescription = "DESCRIPTION"
	EventSummary     = "SUMMARY"
)
View Source
const (
	LoginURL       = "https://ocjene.skole.hr/login"
	ClassURL       = "https://ocjene.skole.hr/class"
	ClassActionURL = "https://ocjene.skole.hr/class_action/%v/course"
	GradeAllURL    = "https://ocjene.skole.hr/grade/all"
	CalendarURL    = "https://ocjene.skole.hr/exam/ical"
	Timeout        = 60 * time.Second // site can get really slow sometimes
)

Variables

View Source
var (
	ErrUnexpectedStatus = errors.New("unexpected status code")
	ErrCSRFToken        = errors.New("could not find CSRF token")
	ErrNilBody          = errors.New("client body is nil")
)

Functions

This section is empty.

Types

type Class added in v0.9.0

type Class struct {
	ID     string
	Name   string
	Year   string
	School string
}

Class structure holds all active classes.

type Classes added in v0.9.0

type Classes []Class

Classes is a slice of Class structure.

type Client

type Client struct {
	URL *url.URL
	// contains filtered or unexported fields
}

Client structure holds all HTTP Client related fields.

func NewClientWithContext

func NewClientWithContext(ctx context.Context, username, password string) (*Client, error)

NewClientWithContext creates new *Client, initializing HTTP Cookie Jar, context and username with password.

func (*Client) CloseConnections added in v0.9.0

func (c *Client) CloseConnections()

CloseConnections closes all connections on its transport.

func (*Client) GetClassEvents added in v0.9.0

func (c *Client) GetClassEvents(classID string) (string, Events, error)

GetClassEvents attempts to fetch all subjects and their grades, as well as all calendar events for exams in ICS format, returning raw grades listing body, parsed exam events and optional error.

func (*Client) GetClasses added in v0.9.0

func (c *Client) GetClasses() (string, error)

GetClasses attempts to fetch all courses where a student has been previously enlisted or still is (multiple active classes possible).

func (*Client) Login added in v0.9.0

func (c *Client) Login() error

Login attempts get CSRF Token and do SSO/SAML authentication with random User-Agent per session.

type Event

type Event struct {
	Start                time.Time
	Description, Summary string
}

Event structure holds ICS event-related fields.

type Events

type Events []Event

Events is a slice of Event structure.

func (*Events) ConsumeICal

func (e *Events) ConsumeICal(c *goics.Calendar, _ error) error

ConsumeICal is a ICS data decoder that extracts DTSTART, DESCRIPTION and SUMMARY values, parsing timestamp with maximum flexibility and in local timezone, returning optional error.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL