Skip to content

Commit 52322f4

Browse files
authored
Merge pull request #11 from SimplyPrint/revisions
Add missing endpoints, edit responses
2 parents d87ada3 + 3570dbb commit 52322f4

21 files changed

+3670
-446
lines changed

scripts/check_outdated.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import os
22
import re
33

4-
from settings import ENDPOINTS_DIR
5-
4+
ENDPOINTS_DIR = "<SITE-API/API/Endpoints PATH>"
65
DOCUMENTATION_DIR = os.path.join(os.path.dirname(__file__), "../source/includes")
76

8-
def get_all_endpoints():
7+
def get_all_endpoints(with_disabled=False):
98
endpoints = []
109
for root, dirs, files in os.walk(ENDPOINTS_DIR):
1110
for file in files:
12-
with open(os.path.join(root, file), 'r') as f:
13-
if re.search(r"public bool \$api_disabled = true;", f.read()):
14-
continue
11+
if not with_disabled:
12+
with open(os.path.join(root, file), 'r') as f:
13+
if re.search(r"public *bool *\$api_disabled *= true;", f.read()):
14+
continue
1515

1616
endpoints.append(root.split(ENDPOINTS_DIR)[1] + "/" + file[:-4])
1717

@@ -25,12 +25,12 @@ def get_all_documented_endpoints():
2525
file_cat = file[1:-3]
2626
with open(os.path.join(DOCUMENTATION_DIR, file), 'r') as f:
2727
for line in f.readlines():
28-
match = re.match(r"curl https:\/\/api\.simplyprint\.io\/\{id\}(.*?)(\?| \\).*$", line)
28+
match = re.match(r"(?:curl)?.*https:\/\/api\.simplyprint\.io\/\{id\}(.*?)(\?| \\).*$", line)
2929

3030
if not match:
3131
continue
3232

33-
endpoints.append(match.group(1))
33+
endpoints.append(match.group(1).replace("\"", ""))
3434

3535
endpoints.sort()
3636
return endpoints

source/includes/_account.md

Lines changed: 69 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ curl https://api.simplyprint.io/{id}/account/settings/groups/Create \
5353
</aside>
5454

5555
| Required permissions |
56-
| --------------------- |
57-
| `ORG_RANK_MANAGEMENT` |
56+
|-----------------------|
57+
| `org_rank_management` |
5858

5959
This endpoint creates a new group in the company.
6060

@@ -63,7 +63,7 @@ This endpoint creates a new group in the company.
6363
`POST /{id}/account/settings/groups/Create`
6464

6565
| Parameter | Type | Required | Description |
66-
| --------------------- | ------- | -------- | --------------------------------------------------------------------------------------------------- |
66+
|-----------------------|---------|----------|-----------------------------------------------------------------------------------------------------|
6767
| `ranks` | array | yes | Array of groups to create. |
6868
| `ranks[].title` | string | yes | The name of the group. |
6969
| `ranks[].description` | string | no | The description of the group. |
@@ -73,7 +73,7 @@ This endpoint creates a new group in the company.
7373
### Response
7474

7575
| Parameter | Type | Description |
76-
| --------- | ------- | ----------------------------------- |
76+
|-----------|---------|-------------------------------------|
7777
| `status` | boolean | True if the request was successful. |
7878
| `message` | string | Error message if `status` is false. |
7979
| `data` | array | Array of the created groups. |
@@ -97,7 +97,7 @@ curl https://api.simplyprint.io/{id}/account/settings/groups/Update \
9797
"title": "TITLE",
9898
"description": "DESCRIPTION",
9999
"permissions": "{\"view_news\":true,\"org_admin\":true,\"panel_printing\":true,\"printer_restart\":true,\"printer_edit\":true,\"bed_leveling\":true,\"gcode_profiles\":true,\"printer_settings\":true,\"filament_settings\":true,\"change_filament\":true,\"create_filament\":true,\"see_filament_tab\":true,\"view_users\":true,\"change_user_rank\":true,\"manual_user_email_confirm\":true,\"invite_users\":true,\"delete_user\":true,\"org_user_registration_settings\":true,\"org_hub_settings\":true,\"org_rank_management\":true,\"org_view_statistics\":true,\"refill_quota\":true,\"custom_slicer_profiles\":true,\"org_profiles\":true,\"all_slicer_modes\":true,\"queue_remove_all\":true,\"org_api\":true,\"create_org_folder\":true,\"cancel_others\":true,\"see_who_printed\":true,\"max_print_size\":[],\"default_slicer_mode\":2}",
100-
"sort_order": 3,
100+
"sort_order": 3
101101
}
102102
]
103103
}
@@ -129,8 +129,8 @@ curl https://api.simplyprint.io/{id}/account/settings/groups/Update \
129129
</aside>
130130

131131
| Required permissions |
132-
| --------------------- |
133-
| `ORG_RANK_MANAGEMENT` |
132+
|-----------------------|
133+
| `org_rank_management` |
134134

135135
This endpoint updates the groups in the company.
136136

@@ -139,7 +139,7 @@ This endpoint updates the groups in the company.
139139
`POST /{id}/account/settings/groups/Update`
140140

141141
| Parameter | Type | Required | Description |
142-
| --------------------- | ------- | -------- | --------------------------------------------------------------------------------------------------- |
142+
|-----------------------|---------|----------|-----------------------------------------------------------------------------------------------------|
143143
| `ranks` | array | yes | Array of groups to update. |
144144
| `ranks[].id` | integer | yes | The id of the group to update. |
145145
| `ranks[].title` | string | no | The name of the group. |
@@ -150,7 +150,7 @@ This endpoint updates the groups in the company.
150150
### Response
151151

152152
| Parameter | Type | Description |
153-
| --------------------- | ------- | --------------------------------------------------------------------------------------------------- |
153+
|-----------------------|---------|-----------------------------------------------------------------------------------------------------|
154154
| `status` | boolean | True if the request was successful. |
155155
| `message` | string | Error message if `status` is false. |
156156
| `data` | array | Array of the updated groups. |
@@ -167,7 +167,6 @@ This endpoint updates the groups in the company.
167167

168168
```shell
169169
curl https://api.simplyprint.io/{id}/account/GetGroups \
170-
-X GET \
171170
-H 'accept: application/json' \
172171
-H 'X-API-KEY: {API_KEY}'
173172
```
@@ -200,8 +199,8 @@ curl https://api.simplyprint.io/{id}/account/GetGroups \
200199
</aside>
201200

202201
| Required permissions |
203-
| --------------------- |
204-
| `ORG_RANK_MANAGEMENT` |
202+
|-----------------------|
203+
| `org_rank_management` |
205204

206205
This endpoint returns a list of groups that exist in the company.
207206

@@ -212,7 +211,7 @@ This endpoint returns a list of groups that exist in the company.
212211
### Response
213212

214213
| Parameter | Type | Description |
215-
| --------------- | ------- | ----------------------------------- |
214+
|-----------------|---------|-------------------------------------|
216215
| `status` | boolean | True if the request was successful. |
217216
| `message` | string | Error message if `status` is false. |
218217
| `groups` | array | Array of group objects. |
@@ -242,7 +241,7 @@ curl https://api.simplyprint.io/{id}/account/settings/groups/Delete \
242241
```json
243242
{
244243
"status": true,
245-
"message": null,
244+
"message": null
246245
}
247246
```
248247

@@ -251,22 +250,22 @@ curl https://api.simplyprint.io/{id}/account/settings/groups/Delete \
251250
</aside>
252251

253252
| Required permissions |
254-
| --------------------- |
255-
| `ORG_RANK_MANAGEMENT` |
253+
|-----------------------|
254+
| `org_rank_management` |
256255

257256
### Request
258257

259258
`POST /{id}/account/settings/groups/Delete`
260259

261260
| Parameter | Type | Required | Description |
262-
| ------------------- | ------- | -------- | ------------------------------------------------------------------------------------------------------- |
261+
|---------------------|---------|----------|---------------------------------------------------------------------------------------------------------|
263262
| `id` | integer | yes | The id of the group to delete. |
264263
| `replacementRankId` | integer | maybe | The id of the group to replace the deleted group with.<br>This is only required if the group has users. |
265264

266265
### Response
267266

268267
| Parameter | Type | Description |
269-
| --------- | ------- | ----------------------------------- |
268+
|-----------|---------|-------------------------------------|
270269
| `status` | boolean | True if the request was successful. |
271270
| `message` | string | Error message if `status` is false. |
272271

@@ -283,8 +282,16 @@ curl https://api.simplyprint.io/{id}/account/GetStatistics \
283282
284283
```json
285284
{
286-
"users": [1234, 1235, 1945],
287-
"printers": [1234, 1235, 1945],
285+
"users": [
286+
1234,
287+
1235,
288+
1945
289+
],
290+
"printers": [
291+
1234,
292+
1235,
293+
1945
294+
],
288295
"start_date": "1677629786",
289296
"end_date": "1677629786"
290297
}
@@ -294,46 +301,46 @@ curl https://api.simplyprint.io/{id}/account/GetStatistics \
294301
295302
```json
296303
{
297-
"status": true,
298-
"message": null,
299-
"data": {
300-
"total_print_seconds": 1234,
301-
"total_filament_usage_gram": 1241.1231231,
302-
"print_job_count": 123,
303-
"regretted_print_jobs": 123,
304-
"failed_print_jobs": 123,
305-
"printer_error_print_jobs": 123,
306-
"done_print_jobs": 123,
307-
"date_range": {
308-
"from": "2023-02-22",
309-
"to": "2023-03-02",
310-
"general": false
311-
},
312-
"printers": {
313-
"3104": {
314-
"name": "Printer 1",
315-
"done": 0,
316-
"failed": 0,
317-
"printer_error": 0,
318-
"regretted": 0,
319-
"filament_usage_gram": 0
320-
},
321-
...
322-
},
323-
"print_jobs": [
324-
{
325-
"date": "2023-02-27",
326-
"started": "2023-02-27 11:39:34",
327-
"ended": "2023-02-27 11:56:18",
328-
"cancelled": 1,
329-
"failed": 0,
330-
"cancel_reason_type": 5,
331-
"print_seconds": 1004,
332-
"filament_usage_gram": 0.03758012402132279
333-
},
334-
...
335-
]
336-
}
304+
"status": true,
305+
"message": null,
306+
"data": {
307+
"total_print_seconds": 1234,
308+
"total_filament_usage_gram": 1241.1231231,
309+
"print_job_count": 123,
310+
"regretted_print_jobs": 123,
311+
"failed_print_jobs": 123,
312+
"printer_error_print_jobs": 123,
313+
"done_print_jobs": 123,
314+
"date_range": {
315+
"from": "2023-02-22",
316+
"to": "2023-03-02",
317+
"general": false
318+
},
319+
"printers": {
320+
"3104": {
321+
"name": "Printer 1",
322+
"done": 0,
323+
"failed": 0,
324+
"printer_error": 0,
325+
"regretted": 0,
326+
"filament_usage_gram": 0
327+
},
328+
...
329+
},
330+
"print_jobs": [
331+
{
332+
"date": "2023-02-27",
333+
"started": "2023-02-27 11:39:34",
334+
"ended": "2023-02-27 11:56:18",
335+
"cancelled": 1,
336+
"failed": 0,
337+
"cancel_reason_type": 5,
338+
"print_seconds": 1004,
339+
"filament_usage_gram": 0.03758012402132279
340+
},
341+
...
342+
]
343+
}
337344
}
338345
```
339346

@@ -348,7 +355,7 @@ This endpoint returns statistics for the user / company.
348355
`POST /{id}/account/GetStatistics`
349356

350357
| Parameter | Type | Required | Description |
351-
| ------------ | ------ | -------- | ------------------------------------------------------------------------------------------------------------ |
358+
|--------------|--------|----------|--------------------------------------------------------------------------------------------------------------|
352359
| `users` | array | no | Array of user ids to get statistics for. Don't include this parameter to get statistics for all users. |
353360
| `printers` | array | no | Array of printer ids to get statistics for. Don't include this parameter to get statistics for all printers. |
354361
| `start_date` | string | no | The start date of the statistics. Provide a unix timestamp in seconds. |
@@ -357,7 +364,7 @@ This endpoint returns statistics for the user / company.
357364
### Response
358365

359366
| Parameter | Type | Description |
360-
| ---------------------------------------- | ------- | ---------------------------------------- |
367+
|------------------------------------------|---------|------------------------------------------|
361368
| `status` | boolean | True if the request was successful. |
362369
| `message` | string | Error message if `status` is false. |
363370
| `data` | object | Statistics object. |

0 commit comments

Comments
 (0)