diff --git a/pages/subjects/create-a-subject.json b/pages/subjects/create-a-subject.json new file mode 100644 index 0000000..6b83e04 --- /dev/null +++ b/pages/subjects/create-a-subject.json @@ -0,0 +1,7 @@ +{ + "id": 168, + "name": "Statistics", + "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..e3da32b --- /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 your Branch. + diff --git a/pages/subjects/create-a-subject.py b/pages/subjects/create-a-subject.py new file mode 100644 index 0000000..d06417a --- /dev/null +++ b/pages/subjects/create-a-subject.py @@ -0,0 +1,5 @@ +import pprint, requests +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/delete-a-subject.md b/pages/subjects/delete-a-subject.md new file mode 100644 index 0000000..34c0adc --- /dev/null +++ b/pages/subjects/delete-a-subject.md @@ -0,0 +1,2 @@ +### Delete a Subject +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/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..6b83e04 --- /dev/null +++ b/pages/subjects/get-a-subject.json @@ -0,0 +1,7 @@ +{ + "id": 168, + "name": "Statistics", + "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..b0149dd 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 associated with your Branch, as well as default Subjects (`custom_to_branch` = null). 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..b2ceead 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` and `category_name` 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 your Branch on your TutorCruncher account. diff --git a/pages/subjects/subject-object.yml b/pages/subjects/subject-object.yml index b619ba4..4cbbff2 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 your Branch (True), or is a default subject (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/