fetch

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventDateStart   = "DTSTART"
	EventDescription = "DESCRIPTION"
	EventSummary     = "SUMMARY"
)
View Source
const (
	LoginURL    = "https://ocjene.skole.hr/login"
	GradeAllURL = "https://ocjene.skole.hr/grade/all"
	CalendarURL = "https://ocjene.skole.hr/exam/ical"
	Timeout     = 60 * time.Second // site can get really slow sometimes
)
View Source
const (
	ErrUnexpectedStatus = "unexpected status code %v"
	ErrCSRFToken        = "could not find CSRF token"
)

Variables

This section is empty.

Functions

This section is empty.

Types

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) GetResponse

func (c *Client) GetResponse() (string, Events, error)

GetResponse attempts to fetch CSRF Token, do SSO/SAML request to have proper security and authentication cookies populated and then proceeds 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.

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, err 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