From b68bc4ab9b82ef198babea6e4fcf047da5d33bb8 Mon Sep 17 00:00:00 2001 From: Sandeep Date: Tue, 8 Apr 2025 11:56:30 +0100 Subject: [PATCH 1/6] subjects api docs --- pages/subjects/create-a-subject.json | 7 +++++++ pages/subjects/create-a-subject.md | 3 +++ pages/subjects/create-a-subject.py | 5 +++++ pages/subjects/delete-a-subject.md | 2 ++ pages/subjects/delete-a-subject.py | 6 ++++++ pages/subjects/get-a-subject.json | 7 +++++++ pages/subjects/get-a-subject.md | 4 ++++ pages/subjects/get-a-subject.py | 5 +++++ pages/subjects/list-all-subjects.json | 3 ++- pages/subjects/list-all-subjects.md | 3 +-- pages/subjects/subject-object.json | 3 ++- pages/subjects/subject-object.md | 2 +- pages/subjects/subject-object.yml | 4 ++++ pages/subjects/subjects.yml | 23 +++++++++++++++++++++++ 14 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 pages/subjects/create-a-subject.json create mode 100644 pages/subjects/create-a-subject.md create mode 100644 pages/subjects/create-a-subject.py create mode 100644 pages/subjects/delete-a-subject.md create mode 100644 pages/subjects/delete-a-subject.py create mode 100644 pages/subjects/get-a-subject.json create mode 100644 pages/subjects/get-a-subject.md create mode 100644 pages/subjects/get-a-subject.py diff --git a/pages/subjects/create-a-subject.json b/pages/subjects/create-a-subject.json new file mode 100644 index 0000000..71f9c8b --- /dev/null +++ b/pages/subjects/create-a-subject.json @@ -0,0 +1,7 @@ +{ + "id": 168, + "name": "Statistic", + "category_id": 14, + "category_name": "Science", + "custom_to_branch": true +} diff --git a/pages/subjects/create-a-subject.md b/pages/subjects/create-a-subject.md new file mode 100644 index 0000000..f9ec0aa --- /dev/null +++ b/pages/subjects/create-a-subject.md @@ -0,0 +1,3 @@ +### Create a Subject +Creates a new Subject with the given `name` and `category`, linked to the request user's Branch (`custom_to_branch`=True). + diff --git a/pages/subjects/create-a-subject.py b/pages/subjects/create-a-subject.py new file mode 100644 index 0000000..87298af --- /dev/null +++ b/pages/subjects/create-a-subject.py @@ -0,0 +1,5 @@ +import pprint, requests +data = {"name": "Statistic", "category":14} +headers = {'Authorization': 'token '} +r = requests.post('https://secure.tutorcruncher.com/api/subjects/',json=data, headers=headers) +pprint.pprint(r.json()) diff --git a/pages/subjects/delete-a-subject.md b/pages/subjects/delete-a-subject.md new file mode 100644 index 0000000..e9ec887 --- /dev/null +++ b/pages/subjects/delete-a-subject.md @@ -0,0 +1,2 @@ +### Delete a Subject +Deletes a Subject created by the user's Branch (`custom_to_branch`=True). Only the Subject's unique id is required in the URL. Subjects not created by the user's Branch cannot be deleted. diff --git a/pages/subjects/delete-a-subject.py b/pages/subjects/delete-a-subject.py new file mode 100644 index 0000000..a9f1627 --- /dev/null +++ b/pages/subjects/delete-a-subject.py @@ -0,0 +1,6 @@ +import pprint, requests +headers = {'Authorization': 'token '} +r = requests.delete('https://secure.tutorcruncher.com/api/subjects//', headers=headers) +pprint.pprint(r.json()) + + diff --git a/pages/subjects/get-a-subject.json b/pages/subjects/get-a-subject.json new file mode 100644 index 0000000..71f9c8b --- /dev/null +++ b/pages/subjects/get-a-subject.json @@ -0,0 +1,7 @@ +{ + "id": 168, + "name": "Statistic", + "category_id": 14, + "category_name": "Science", + "custom_to_branch": true +} diff --git a/pages/subjects/get-a-subject.md b/pages/subjects/get-a-subject.md new file mode 100644 index 0000000..94a8235 --- /dev/null +++ b/pages/subjects/get-a-subject.md @@ -0,0 +1,4 @@ +### Get a Subject + +Returns the details of an existing Subject. You only need to specify the unique +`id` of the Subject to get the correct details. diff --git a/pages/subjects/get-a-subject.py b/pages/subjects/get-a-subject.py new file mode 100644 index 0000000..8c5e131 --- /dev/null +++ b/pages/subjects/get-a-subject.py @@ -0,0 +1,5 @@ +import pprint, requests + +headers = {'Authorization': 'token '} +r = requests.get('https://secure.tutorcruncher.com/api/subjects//', headers=headers) +pprint.pprint(r.json()) diff --git a/pages/subjects/list-all-subjects.json b/pages/subjects/list-all-subjects.json index 97da57e..8804f1e 100644 --- a/pages/subjects/list-all-subjects.json +++ b/pages/subjects/list-all-subjects.json @@ -7,7 +7,8 @@ "id": 22, "name": "Computer Science", "category_id": 4, - "category_name": "Engineering" + "category_name": "Engineering", + "custom_to_branch": null }, ... ] diff --git a/pages/subjects/list-all-subjects.md b/pages/subjects/list-all-subjects.md index 7865469..6d9126e 100644 --- a/pages/subjects/list-all-subjects.md +++ b/pages/subjects/list-all-subjects.md @@ -1,4 +1,3 @@ ### List all Subjects -Returns of all the Subjects found on your TutorCruncher account, which are sorted by `id`, -with the largest id first. +Returns all Subjects, sorted by id in descending order (highest first). Includes Subjects linked to the user's Branch, as well as unassigned Subjects (custom_to_branch = null). Subjects assigned to other Branches or marked as hidden for the user's Branch are excluded. diff --git a/pages/subjects/subject-object.json b/pages/subjects/subject-object.json index cd9fab4..d0b5059 100644 --- a/pages/subjects/subject-object.json +++ b/pages/subjects/subject-object.json @@ -2,5 +2,6 @@ "id": 22, "name": "Computer Science", "category_id": 4, - "category_name": "Engineering" + "category_name": "Engineering", + "custom_to_branch": null } diff --git a/pages/subjects/subject-object.md b/pages/subjects/subject-object.md index 6f07b12..6c10150 100644 --- a/pages/subjects/subject-object.md +++ b/pages/subjects/subject-object.md @@ -1,4 +1,4 @@ ### Subject Object -Subject object contains the `id`, `name`, `category_id` and `category_name` for Subjects found +Subject object contains the `id`, `name`, `category_id`, `category_name` and `custom_to_branch` for Subjects found on your TutorCruncher account. diff --git a/pages/subjects/subject-object.yml b/pages/subjects/subject-object.yml index b619ba4..b6cbd97 100644 --- a/pages/subjects/subject-object.yml +++ b/pages/subjects/subject-object.yml @@ -15,4 +15,8 @@ attributes: name: category_name type: string description: Name of the Subject's Category. + - + name: custom_to_branch + type: bool + description: Indicates whether the Subject is specific to the requesting user's Branch (True) or shared across all Branches (null). diff --git a/pages/subjects/subjects.yml b/pages/subjects/subjects.yml index 818b2e5..66e30c0 100644 --- a/pages/subjects/subjects.yml +++ b/pages/subjects/subjects.yml @@ -14,3 +14,26 @@ sections: code_type: GET code_url: /api/subjects/ response: /subjects/list-all-subjects.json + - + title: Get a Subject + id: get-a-subject + description: /subjects/get-a-subject.md + code: /subjects/get-a-subject.py + code_type: GET + code_url: /api/subjects/ + response: /subjects/get-a-subject.json + - + title: Create a Subject + id: create-a-subject + description: /subjects/create-a-subject.md + code: /subjects/create-a-subject.py + code_type: POST + code_url: /api/subjects/ + response: /subjects/create-a-subject.json + - + title: Delete a Subject + id: delete-a-subject + description: /subjects/delete-a-subject.md + code: /subjects/delete-a-subject.py + code_type: POST + code_url: /api/subjects/ From fbbd4e901ce986791f15632b9fb9c326ea8b72e2 Mon Sep 17 00:00:00 2001 From: Sandeep Date: Thu, 10 Apr 2025 00:08:34 +0100 Subject: [PATCH 2/6] updated .md --- pages/subjects/create-a-subject.md | 2 +- pages/subjects/delete-a-subject.md | 2 +- pages/subjects/list-all-subjects.md | 2 +- pages/subjects/subject-object.md | 3 +-- pages/subjects/subject-object.yml | 2 +- 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/pages/subjects/create-a-subject.md b/pages/subjects/create-a-subject.md index f9ec0aa..8f556b2 100644 --- a/pages/subjects/create-a-subject.md +++ b/pages/subjects/create-a-subject.md @@ -1,3 +1,3 @@ ### Create a Subject -Creates a new Subject with the given `name` and `category`, linked to the request user's Branch (`custom_to_branch`=True). +Creates a new Subject with the given `name` and `category`, linked to the API key's Branch (`custom_to_branch`=True). diff --git a/pages/subjects/delete-a-subject.md b/pages/subjects/delete-a-subject.md index e9ec887..34c0adc 100644 --- a/pages/subjects/delete-a-subject.md +++ b/pages/subjects/delete-a-subject.md @@ -1,2 +1,2 @@ ### Delete a Subject -Deletes a Subject created by the user's Branch (`custom_to_branch`=True). Only the Subject's unique id is required in the URL. Subjects not created by the user's Branch cannot be deleted. +Deletes a Subject that was created by your Branch (i.e., where `custom_to_branch`=True). Only Subjects created by your Branch can be deleted; attempting to delete a Subject not owned by your Branch will result in an error. Provide the Subject’s unique ID in the URL path. diff --git a/pages/subjects/list-all-subjects.md b/pages/subjects/list-all-subjects.md index 6d9126e..003a8a9 100644 --- a/pages/subjects/list-all-subjects.md +++ b/pages/subjects/list-all-subjects.md @@ -1,3 +1,3 @@ ### List all Subjects -Returns all Subjects, sorted by id in descending order (highest first). Includes Subjects linked to the user's Branch, as well as unassigned Subjects (custom_to_branch = null). Subjects assigned to other Branches or marked as hidden for the user's Branch are excluded. +Returns all Subjects, sorted by `id` in descending order (highest first). Includes Subjects associated with the API key's Branch, as well as unassigned Subjects (`custom_to_branch` = null). Subjects linked to other Branches or marked as hidden for the API key's Branch are excluded. diff --git a/pages/subjects/subject-object.md b/pages/subjects/subject-object.md index 6c10150..9d2fa37 100644 --- a/pages/subjects/subject-object.md +++ b/pages/subjects/subject-object.md @@ -1,4 +1,3 @@ ### Subject Object -Subject object contains the `id`, `name`, `category_id`, `category_name` and `custom_to_branch` for Subjects found -on your TutorCruncher account. +The Subject object contains the `id`, `name`, `category_id`, `category_name`, and `custom_to_branch` for Subjects associated with the API key's Branch on your TutorCruncher account. diff --git a/pages/subjects/subject-object.yml b/pages/subjects/subject-object.yml index b6cbd97..78e4ba8 100644 --- a/pages/subjects/subject-object.yml +++ b/pages/subjects/subject-object.yml @@ -18,5 +18,5 @@ attributes: - name: custom_to_branch type: bool - description: Indicates whether the Subject is specific to the requesting user's Branch (True) or shared across all Branches (null). + description: Indicates whether the Subject is specific to the API key's Branch (True), or shared across all Branches (null). From 4432b493c6658aa390fb21cbddf2891ce2ad19e0 Mon Sep 17 00:00:00 2001 From: Sandeep Date: Thu, 10 Apr 2025 09:29:58 +0100 Subject: [PATCH 3/6] empty commit --- pages/creating-updating-users/creating-updating-users.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/creating-updating-users/creating-updating-users.py b/pages/creating-updating-users/creating-updating-users.py index 3852b27..45a44fe 100644 --- a/pages/creating-updating-users/creating-updating-users.py +++ b/pages/creating-updating-users/creating-updating-users.py @@ -7,6 +7,6 @@ 'last_name': 'Bob' # ... }, - # ... + # .... } requests.post('...', json=data, headers=headers) From e6761a689bd5655c7b2688e3150a00a67f087dc4 Mon Sep 17 00:00:00 2001 From: Sandeep Date: Thu, 10 Apr 2025 14:22:15 +0100 Subject: [PATCH 4/6] dan comments --- pages/subjects/create-a-subject.md | 2 +- pages/subjects/list-all-subjects.md | 2 +- pages/subjects/subject-object.md | 2 +- pages/subjects/subject-object.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pages/subjects/create-a-subject.md b/pages/subjects/create-a-subject.md index 8f556b2..e3da32b 100644 --- a/pages/subjects/create-a-subject.md +++ b/pages/subjects/create-a-subject.md @@ -1,3 +1,3 @@ ### Create a Subject -Creates a new Subject with the given `name` and `category`, linked to the API key's Branch (`custom_to_branch`=True). +Creates a new Subject with the given `name` and `category`, linked to your Branch. diff --git a/pages/subjects/list-all-subjects.md b/pages/subjects/list-all-subjects.md index 003a8a9..6e7c520 100644 --- a/pages/subjects/list-all-subjects.md +++ b/pages/subjects/list-all-subjects.md @@ -1,3 +1,3 @@ ### List all Subjects -Returns all Subjects, sorted by `id` in descending order (highest first). Includes Subjects associated with the API key's Branch, as well as unassigned Subjects (`custom_to_branch` = null). Subjects linked to other Branches or marked as hidden for the API key's Branch are excluded. +Returns all Subjects, sorted by `id` in descending order (highest first). Includes Subjects associated with your Branch, as well as unassigned Subjects (`custom_to_branch` = null). diff --git a/pages/subjects/subject-object.md b/pages/subjects/subject-object.md index 9d2fa37..b2ceead 100644 --- a/pages/subjects/subject-object.md +++ b/pages/subjects/subject-object.md @@ -1,3 +1,3 @@ ### Subject Object -The Subject object contains the `id`, `name`, `category_id`, `category_name`, and `custom_to_branch` for Subjects associated with the API key's Branch on your TutorCruncher account. +The Subject object contains the `id`, `name`, `category_id`, `category_name`, and `custom_to_branch` for Subjects associated with your Branch on your TutorCruncher account. diff --git a/pages/subjects/subject-object.yml b/pages/subjects/subject-object.yml index 78e4ba8..3f7ec5e 100644 --- a/pages/subjects/subject-object.yml +++ b/pages/subjects/subject-object.yml @@ -18,5 +18,5 @@ attributes: - name: custom_to_branch type: bool - description: Indicates whether the Subject is specific to the API key's Branch (True), or shared across all Branches (null). + description: Indicates whether the Subject is specific to your Branch (True), or shared across all Branches (null). From 518810433bedba600b87ec06fd0de71a1f10e738 Mon Sep 17 00:00:00 2001 From: Sandeep Date: Thu, 10 Apr 2025 14:44:46 +0100 Subject: [PATCH 5/6] dan comments --- pages/creating-updating-users/creating-updating-users.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/creating-updating-users/creating-updating-users.py b/pages/creating-updating-users/creating-updating-users.py index 45a44fe..3852b27 100644 --- a/pages/creating-updating-users/creating-updating-users.py +++ b/pages/creating-updating-users/creating-updating-users.py @@ -7,6 +7,6 @@ 'last_name': 'Bob' # ... }, - # .... + # ... } requests.post('...', json=data, headers=headers) From c85da74222f093499c0d9a02ecfb5b2aeb96cb40 Mon Sep 17 00:00:00 2001 From: Sandeep Date: Thu, 10 Apr 2025 16:47:09 +0100 Subject: [PATCH 6/6] henrys comment --- pages/subjects/create-a-subject.json | 2 +- pages/subjects/create-a-subject.py | 2 +- pages/subjects/get-a-subject.json | 2 +- pages/subjects/list-all-subjects.md | 2 +- pages/subjects/subject-object.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pages/subjects/create-a-subject.json b/pages/subjects/create-a-subject.json index 71f9c8b..6b83e04 100644 --- a/pages/subjects/create-a-subject.json +++ b/pages/subjects/create-a-subject.json @@ -1,6 +1,6 @@ { "id": 168, - "name": "Statistic", + "name": "Statistics", "category_id": 14, "category_name": "Science", "custom_to_branch": true diff --git a/pages/subjects/create-a-subject.py b/pages/subjects/create-a-subject.py index 87298af..d06417a 100644 --- a/pages/subjects/create-a-subject.py +++ b/pages/subjects/create-a-subject.py @@ -1,5 +1,5 @@ import pprint, requests -data = {"name": "Statistic", "category":14} +data = {"name": "Statistics", "category":14} headers = {'Authorization': 'token '} r = requests.post('https://secure.tutorcruncher.com/api/subjects/',json=data, headers=headers) pprint.pprint(r.json()) diff --git a/pages/subjects/get-a-subject.json b/pages/subjects/get-a-subject.json index 71f9c8b..6b83e04 100644 --- a/pages/subjects/get-a-subject.json +++ b/pages/subjects/get-a-subject.json @@ -1,6 +1,6 @@ { "id": 168, - "name": "Statistic", + "name": "Statistics", "category_id": 14, "category_name": "Science", "custom_to_branch": true diff --git a/pages/subjects/list-all-subjects.md b/pages/subjects/list-all-subjects.md index 6e7c520..b0149dd 100644 --- a/pages/subjects/list-all-subjects.md +++ b/pages/subjects/list-all-subjects.md @@ -1,3 +1,3 @@ ### List all Subjects -Returns all Subjects, sorted by `id` in descending order (highest first). Includes Subjects associated with your Branch, as well as unassigned Subjects (`custom_to_branch` = null). +Returns all Subjects, sorted by `id` in descending order (highest first). Includes Subjects associated with your Branch, as well as default Subjects (`custom_to_branch` = null). diff --git a/pages/subjects/subject-object.yml b/pages/subjects/subject-object.yml index 3f7ec5e..4cbbff2 100644 --- a/pages/subjects/subject-object.yml +++ b/pages/subjects/subject-object.yml @@ -18,5 +18,5 @@ attributes: - name: custom_to_branch type: bool - description: Indicates whether the Subject is specific to your Branch (True), or shared across all Branches (null). + description: Indicates whether the Subject is specific to your Branch (True), or is a default subject (null).