From f0fe1d127fd55d153555765d55a40c6f138c1c39 Mon Sep 17 00:00:00 2001 From: zervo Date: Tue, 26 Nov 2024 17:29:30 +0100 Subject: [PATCH] Update README.md --- README.md | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 90 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e351b86..e82947c 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,97 @@ Please remember that you can only retrieve data within the currently active host # Getting started -SomeExampleHere +Install the package in your project: +`go get git.zervo.org/zervo/goskola24api` + +Here is an example of getting all the schools on a host: + +```golang +package main + +import ( + "fmt" + + GoSkola24API "git.zervo.org/zervo/goskola24api" +) + +func main() { + api := GoSkola24API.Skola24API{ + Host: "avesta.skola24.se", + } + + schools, err := api.GetSchools() + if err != nil { + fmt.Println("Could not get schools: " + err.Error()) + } + + for _, school := range schools { + fmt.Println(school.Name) + } +} + +``` + +All the other information below is documentation on examples, the available methods and types. + +Please that some methods are not strongly typed due to a lack of data to develop against. This is clearly marked by the warnings under the affected methods. + +* [Examples](#examples) + +* [Methods](#methods) + +* [Types](#types) + +Good luck! :D + + +# Examples + +Here are a few examples of using the module. + +## Get available terms + +Get all the available terms (aka semesters) of the host. + +```golang +api := GoSkola24API.Skola24API{ + Host: "avesta.skola24.se", +} + +terms, err := api.GetTerms() +if err != nil { + fmt.Println("Could not get terms: " + err.Error()) +} + +for _, term := range terms.ActiveTerms { + fmt.Println(term.Name) +} +``` + +## Get teachers in a school + +Get all teachers in a school. + +```golang +api := GoSkola24API.Skola24API{ + Host: "avesta.skola24.se", +} + +schools, err := api.GetSchools() +if err != nil { + fmt.Println("Could not get schools: " + err.Error()) +} + +teachers, err := api.GetTeachers(schools[0], true) +if err != nil { + fmt.Println("Could not get teachers: " + err.Error()) +} + +for _, teacher := range teachers { + fmt.Println(teacher.FullName) +} +``` # Methods