This repository has been archived by the owner on Feb 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
student.go
73 lines (68 loc) · 2.48 KB
/
student.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package gokreta
import (
"encoding/json"
)
// SubjectAverage struct will contain every information about a subject average,
type SubjectAverage struct {
Subject string `json:"Subject"`
SubjectCategory string `json:"SubjectCategory"`
SubjectCategoryName string `json:"SubjectCategoryName"`
Value float64 `json:"Value"`
ClassValue float64 `json:"ClassValue"`
Difference float64 `json:"Difference"`
}
// Student struct will contain every information about a student,
type Student struct {
Id int `json:"StudentId"`
SchoolYearId int `json:"StudentYearId"`
Name string `json:"Name"`
NameOfBirth string `json:"NameOfBirth"`
PlaceOfBirth string `json:"PlaceOfBirth"`
MothersName string `json:"MothersName"`
AddressDataList []string `json:"AddressDataList"`
DateOfBirthUtc string `json:"DateOfBirthUtc"`
InstituteName string `json:"InstituteName"`
InstituteCode string `json:"InstituteCode"`
Evaluations []Evaluation `json:"Evaluations"`
SubjectAverages []SubjectAverage `json:"SubjectAverages"`
Absences []Absence `json:"Absences"`
Notes []Note `json:"Notes"`
Lessons string `json:"Lessons"`
Events string `json:"Events"`
FormTeacher Teacher `json:"FormTeacher"`
Tutelaries []Tutelary `json:"Tutelaries"`
}
// GetStudentDetails will return a Student.
func GetStudentDetails(authDetails AuthDetails) (Student, error) {
var student Student
headers := map[string]string{
"Authorization": "Bearer " + authDetails.AccessToken,
}
body, err := MakeRequest("GET",
"https://"+authDetails.InstituteCode+".e-kreta.hu/mapi/api/v1/Student",
headers,
"",
)
if err != nil {
return student, err
}
err = json.Unmarshal(body, &student)
return student, err
}
// GetStudentDetails will return a Student restricted by the given durationn.
func GetStudentDetailsByDate(authDetails AuthDetails, fromDate, toDate string) (Student, error) {
var student Student
headers := map[string]string{
"Authorization": "Bearer " + authDetails.AccessToken,
}
body, err := MakeRequest("GET",
"https://"+authDetails.InstituteCode+".e-kreta.hu/mapi/api/v1/Student?fromDate="+fromDate+"&toDate="+toDate,
headers,
"",
)
if err != nil {
return student, err
}
err = json.Unmarshal(body, &student)
return student, err
}