Update README.md

This commit is contained in:
zervo 2024-11-26 17:29:30 +01:00 committed by zervo
parent 0c512b4af2
commit f0fe1d127f

View file

@ -13,8 +13,97 @@ Please remember that you can only retrieve data within the currently active host
# Getting started # 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 # Methods