From 1c1408276c2b13c01099cfa8e1516a390d162b40 Mon Sep 17 00:00:00 2001 From: Konstantin Protzen Date: Sat, 4 Nov 2023 18:38:12 +0100 Subject: [PATCH] [EN] [V2] Update classes -> subjects and add years --- docs/endpoints/subjects.md | 88 ++++++++++++++++++++++++++++++-------- 1 file changed, 70 insertions(+), 18 deletions(-) diff --git a/docs/endpoints/subjects.md b/docs/endpoints/subjects.md index dacadab..af58bbf 100644 --- a/docs/endpoints/subjects.md +++ b/docs/endpoints/subjects.md @@ -1,6 +1,6 @@ --- -sidebar_position: 3 -title: Classes +sidebar_position: 4 +title: Subjects tags: - Auth - Authentication @@ -14,14 +14,20 @@ tags: ## Endpoints and Methods -| Endpoints | Methods | Use | -| --------------- | ------- | ------------------------- | -| /classes/ | GET | Get a List of all Classes | -| /classes/ | POST | Create a new Class | -| /classes/{:id}/ | DELETE | Delete a Class | -| /classes/{:id}/ | PATCH | Change Class details | +| Endpoints | Methods | Use | +| ------------------ | ------- | ------------------------------------------- | +| /subjects/ | GET | Get a List of all Subjects | +| /subjects/{:year}/ | GET | Get a List of all Subjects for year {:year} | +| /subjects/ | POST | Create a new Subject | +| /subjects/{:id}/ | DELETE | Delete a Subject | +| /subjects/{:id}/ | PATCH | Change Subject details | -## GET /classes/ +:::note +If possible, use the `year` parameter to get a list of subjects for a specific year. +This will improve performance and reduce the amount of data that needs to be transferred. +::: + +## GET /subjects/ ### Request @@ -30,7 +36,7 @@ var axios = require("axios").default; var options = { method: "GET", - url: "https://api.noten-app.de/v1/classes", + url: "https://api.noten-app.de/v2/subjects", headers: { Authorization: "Bearer DFw6zar4QF33Rb6jfp7cQj2UvcrAKgun" }, }; @@ -58,7 +64,8 @@ axios "grade_m": 30, "grade_t": "10", "grade_s": 0, - "average": 2.16667 + "average": 2.16667, + "year": "sjdu6a9j" }, { "name": "English", @@ -70,12 +77,56 @@ axios "grade_m": 40, "grade_t": "1exam", "grade_s": 0, - "average": 2.69118 + "average": 2.69118, + "year": "a76ak8g8" + } +] +``` + +## GET /subjects/{:id} + +### Request + +```js +var axios = require("axios").default; + +var options = { + method: "GET", + url: "https://api.noten-app.de/v2/subjects/a76ak8g8", + headers: { Authorization: "Bearer DFw6zar4QF33Rb6jfp7cQj2UvcrAKgun" }, +}; + +axios + .request(options) + .then(function (response) { + console.log(response.data); + }) + .catch(function (error) { + console.error(error); + }); +``` + +### Response + +```json +[ + { + "name": "English", + "color": "dddd00", + "user_id": "5negptbo-lt6v-9qos-ws1a-1s5qxe36k3op", + "id": 1, + "last_used": "2023-07-10T00:00:00.000Z", + "grade_k": 60, + "grade_m": 40, + "grade_t": "1exam", + "grade_s": 0, + "average": 2.69118, + "year": "a76ak8g8" } ] ``` -## POST /classes/ +## POST /subjects/ ### Request @@ -84,7 +135,7 @@ var axios = require("axios").default; var options = { method: "POST", - url: "https://api.noten-app.de/v1/classes", + url: "https://api.noten-app.de/v2/subjects", headers: { Authorization: "Bearer DFw6zar4QF33Rb6jfp7cQj2UvcrAKgun", "Content-Type": "application/json", @@ -96,6 +147,7 @@ var options = { grade_m: 45, grade_t: "1exam", grade_s: 10, + year: "a76ak8g8", }, }; @@ -118,7 +170,7 @@ axios } ``` -## DELETE /classes/{:id} +## DELETE /subjects/{:id} ### Request @@ -127,7 +179,7 @@ var axios = require("axios").default; var options = { method: "DELETE", - url: "https://api.noten-app.de/v1/classes/42", + url: "https://api.noten-app.de/v2/subjects/42", headers: { Authorization: "Bearer DFw6zar4QF33Rb6jfp7cQj2UvcrAKgun", }, @@ -151,7 +203,7 @@ axios } ``` -## PATCH /classes/{:id} +## PATCH /subjects/{:id} ### Request @@ -160,7 +212,7 @@ var axios = require("axios").default; var options = { method: "PATCH", - url: "https://api.noten-app.de/v1/classes/42", + url: "https://api.noten-app.de/v2/subjects/42", headers: { Authorization: "Bearer DFw6zar4QF33Rb6jfp7cQj2UvcrAKgun", "Content-Type": "application/json",