api

package
v0.0.0-...-6de9b76 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2021 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Subjects = map[string]Subject{
	"MATHÉMATIQUES": {Name: "Mathématiques", Emoji: "🔢"},
	"PHYSIQUE":      {Name: "Sciences physiques", Emoji: "🔭"},
	"INFO COURS":    {Name: "Informatique", Emoji: "💻"},
	"INFO TP":       {Name: "Informatique (TP)", Emoji: "🖥"},

	"FRANÇAIS PHILO": {Name: "Français/Philo", Emoji: "✒"},
	"ANGLAIS":        {Name: "Anglais", Emoji: "🍵"},
	"ESPAGNOL":       {Name: "Espagnol", Emoji: "🌮"},

	"SCIENCES INGÉNIEUR": {Name: "Sciences de l'ingénieur", Emoji: "⚙"},
	"SC ING TD":          {Name: "Sciences de l'ingénieur (TD)", Emoji: "⚙"},

	"DEVOIRS": {Name: "Devoir surveillé", Emoji: "✏"},
}

Subjects holds the list of all available subjects in Pronote

Functions

func Login

func Login(cache *redis.Client) error

Login uses user's credentials to get an API token

func ParseGraphQL

func ParseGraphQL(query string) string

ParseGraphQL transforms a full-text GraphQL query into a json query containing it

Types

type Content

type Content struct {
	Subject  string
	Teachers string
	Time     int `json:"from"`
	Contents []ContentPart
}

Content stores the content of a passed lesson

func (*Content) String

func (content *Content) String() (output string)

type ContentPart

type ContentPart struct {
	Name        string
	Category    string
	Description string
	Files       []File
}

ContentPart stores the different parts of a lesson

type Contents

type Contents []Content

Contents is a shortcut for []Content

func (Contents) Reverse

func (c Contents) Reverse() []Content

Reverse sorts Content objects to reverse their order in a list

type Data

type Data struct {
	// Homework to do for the next days
	Homeworks []Homework
	// Lessons during the next days
	Timetable []Lesson
	// Lesson contents written for the passed days
	Contents Contents
}

Data stores possible data from the Pronote API

func GetContents

func GetContents(cache *redis.Client, days int) (Data, error)

GetContents fetches lesson contents for the past 5 days

func GetHomework

func GetHomework(cache *redis.Client, days int) (Data, error)

GetHomework fetches the homework to do for the next 15 days

func GetTimetable

func GetTimetable(cache *redis.Client, from time.Time, to time.Time) (Data, error)

GetTimetable fetches the timetable for the next 7 days

type File

type File struct {
	Name string
	URL  string
}

File stores a document attached to homework or contents

func (*File) String

func (file *File) String() string

type Homework

type Homework struct {
	Description string
	Subject     string
	Due         int `json:"for"`
	Done        bool
	Files       []File
}

Homework defines the homework given for the next days by a teacher

func (*Homework) String

func (homework *Homework) String() (output string)

type Lesson

type Lesson struct {
	From      int
	To        int
	Subject   string
	Teacher   string
	Room      string
	Status    string
	Cancelled bool `json:"isCancelled"`
	Remote    bool `json:"remoteLesson"`
}

Lesson represents a class during a day on a specific subject

func (*Lesson) String

func (lesson *Lesson) String() (output string)

type Response

type Response struct {
	// A list of errors that could occur during the request
	Errors []interface{}
	// The message associated to an error
	Message string
	// User token (if requested)
	Token string
	// Request data (if requested)
	Data Data
}

Response holds the data from Pronote

func MakeRequest

func MakeRequest(cache *redis.Client, query string) (Response, error)

MakeRequest executes a GraphQL query to the Pronote API

type Subject

type Subject struct {
	Name  string
	Emoji string
}

Subject defines the pretty-print style of a school subject

Jump to

Keyboard shortcuts

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