fetch

package
v0.26.3 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventDateStart   = "DTSTART"
	EventDescription = "DESCRIPTION"
	EventSummary     = "SUMMARY"

	LayoutISO8601CompactZ    = "20060102T150405Z0700"
	LayoutISO8601CompactNoTZ = "20060102T150405"
	LayoutISO8601Short       = "20060102"
)
View Source
const (
	BaseURL        = "https://ocjene.skole.hr"
	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"
	CourseURL      = "https://ocjene.skole.hr/course"
)
View Source
const (
	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")
	ErrInvalidLogin     = errors.New("unable to login")
)
View Source
var ErrParseTimestamp = errors.New("failed to parse timestamp")

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) GetCourse added in v0.21.0

func (c *Client) GetCourse(dest string) (string, error)

GetCourse fetches the course with the given destination URL and returns its raw body, or an error.

func (*Client) GetCourses added in v0.21.0

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

GetCourses attempts to fetch all active courses.

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 Course added in v0.21.0

type Course struct {
	URL  string
	Name string
}

type Courses added in v0.21.0

type Courses []Course

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