Skip to content

Commit e5cf97d

Browse files
authored
Merge pull request #186 from tutorcruncher/label-api-objects
Label API objects
2 parents 04f1b6b + 6bd11a7 commit e5cf97d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+821
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ harrier dev
1919

2020
The visual content is setup in the api-content.jinja template stype page
2121

22-
The content set by this template is reffered to as sections, each section is set out in api.yml
22+
The content set by this template is referred to as sections, each section is set out in api.yml
2323

2424
## Deploying
2525

data/actions.json

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -896,20 +896,27 @@
896896
"help_text": "When an Administrator exports data about Reports.",
897897
"subject_types": []
898898
},
899-
{
900-
"key": "EXPORTED_USERS",
901-
"value": "EXPORTED_USERS",
902-
"msg": "Exported Users",
903-
"help_text": "When an Administrator exports data about Users.",
904-
"subject_types": []
905-
},
906899
{
907900
"key": "CLIENTS_EXPORT",
908901
"value": "CLIENTS_EXPORT",
909902
"msg": "Exported Clients",
910903
"help_text": "When an Administrator exports data about Clients.",
911904
"subject_types": []
912905
},
906+
{
907+
"key": "CONTRACTOR_EXPORT",
908+
"value": "CONTRACTOR_EXPORT",
909+
"msg": "Exported Tutors",
910+
"help_text": "When an Administrator exports data about Tutors.",
911+
"subject_types": []
912+
},
913+
{
914+
"key": "SERVICE_RECIPIENTS_EXPORT",
915+
"value": "SERVICE_RECIPIENTS_EXPORT",
916+
"msg": "Exported Students",
917+
"help_text": "When an Administrator exports data about Students.",
918+
"subject_types": []
919+
},
913920
{
914921
"key": "EDITED_SYSTEM_SETTINGS",
915922
"value": "EDITED_SYSTEM_SETTINGS",

pages/agents/agents.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,20 @@ sections:
3939
code_type: POST
4040
code_url: /api/agents/
4141
response: /agents/update-an-agent.json
42+
-
43+
title: Add a Label to an Agent
44+
id: label-add-to-an-agent
45+
description: /agents/label-add-to-an-agent.md
46+
code: /agents/label-add-to-an-agent.py
47+
code_type: POST
48+
code_url: /api/agents/<id>/add_label/
49+
response: /agents/label-add-to-an-agent.json
50+
-
51+
title: Removing a Label from an Agent
52+
id: label-remove-from-an-agent
53+
description: /agents/label-remove-from-an-agent.md
54+
code: /agents/label-remove-from-an-agent.py
55+
code_type: POST
56+
code_url: /api/agents/<id>/add_label/
57+
response: /agents/label-remove-from-an-agent.json
58+

pages/agents/get-an-agent.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@
2121
"clients": [],
2222
"last_updated": "2020-03-16T12:23:39.056867Z",
2323
"calendar_colour": "Brown",
24-
"labels": [],
24+
"labels": [
25+
{
26+
"id": 2,
27+
"name": "Very important",
28+
"machine_name": "very-important",
29+
"url": "https://secure.tutorcruncher.com/api/labels/2/"
30+
}
31+
],
2532
"extra_attrs": []
2633
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"id": 65,
3+
"user": {
4+
"title": null,
5+
"first_name": "Billy",
6+
"last_name": "Bob2",
7+
"email": "[email protected]",
8+
"mobile": "07123 456 789",
9+
"phone": "0208 123 4567",
10+
"street": "8 Albert Road",
11+
"state": null,
12+
"town": "London",
13+
"country": "United Kingdom (GB)",
14+
"postcode": "E80 1FA",
15+
"latitude": "51.5373258999999990",
16+
"longitude": "-0.1496343000000000",
17+
"date_created": "2020-02-18T16:13:04.193340Z",
18+
"timezone": "Europe/London"
19+
},
20+
"commission_rate": null,
21+
"clients": [],
22+
"last_updated": "2020-03-16T12:23:39.056867Z",
23+
"calendar_colour": "Brown",
24+
"labels": [
25+
{
26+
"id": 2,
27+
"name": "Very important",
28+
"machine_name": "very-important",
29+
"url": "https://secure.tutorcruncher.com/api/labels/2/"
30+
}
31+
],
32+
"extra_attrs": [
33+
{
34+
"id": 1,
35+
"value": "1993-06-23",
36+
"type": "Date",
37+
"machine_name": "user-dob",
38+
"name": "Date of birth"
39+
}
40+
]
41+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
### Adding a Label to an Agent
2+
3+
For more information on Labels, see the [Labels](#label-object) section. Bear in mind that if the Label has been set up to email admins when added to an object, adding a Label through the API will trigger the email.
4+
5+
If you add a Label that has already been added to an object, the Label will not be added again and you will get a normal `200` response.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import pprint, requests
2+
3+
headers = {'Authorization': 'token <API KEY>'}
4+
data = {
5+
'label': 2,
6+
}
7+
r = requests.post('https://secure.tutorcruncher.com/api/agents/65/add_label/', json=data, headers=headers)
8+
pprint.pprint(r.json())
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"id": 65,
3+
"user": {
4+
"title": null,
5+
"first_name": "Billy",
6+
"last_name": "Bob2",
7+
"email": "[email protected]",
8+
"mobile": "07123 456 789",
9+
"phone": "0208 123 4567",
10+
"street": "8 Albert Road",
11+
"state": null,
12+
"town": "London",
13+
"country": "United Kingdom (GB)",
14+
"postcode": "E80 1FA",
15+
"latitude": "51.5373258999999990",
16+
"longitude": "-0.1496343000000000",
17+
"date_created": "2020-02-18T16:13:04.193340Z",
18+
"timezone": "Europe/London"
19+
},
20+
"commission_rate": null,
21+
"clients": [],
22+
"last_updated": "2020-03-16T12:23:39.056867Z",
23+
"calendar_colour": "Brown",
24+
"labels": [],
25+
"extra_attrs": [
26+
{
27+
"id": 1,
28+
"value": "1993-06-23",
29+
"type": "Date",
30+
"machine_name": "user-dob",
31+
"name": "Date of birth"
32+
}
33+
]
34+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
### Removing a Label from an Agent
2+
3+
For more information on Labels, see the [Labels](#label-object) section.
4+
5+
If you remove a Label that has already been removed to an object, you will get a normal `200` response.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import pprint, requests
2+
3+
headers = {'Authorization': 'token <API KEY>'}
4+
data = {
5+
'label': 2,
6+
}
7+
r = requests.post('https://secure.tutorcruncher.com/api/agents/65/remove_label/', json=data, headers=headers)
8+
pprint.pprint(r.json())

0 commit comments

Comments
 (0)