Skip to content

Commit 5573fa2

Browse files
authored
Add "cost" return to API endpoints
1 parent fa86849 commit 5573fa2

File tree

3 files changed

+116
-18
lines changed

3 files changed

+116
-18
lines changed

source/includes/_files.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ curl https://api.simplyprint.io/{id}/files/GetFiles?f=123&search=benchy \
3838
"id": "e82ab9e1cc3c20850d94d5cf539390c0",
3939
"name": "3DBenchy",
4040
"ext": "gcode",
41-
"type": "model",
41+
"type": "printable",
4242
"size": 1285384,
4343
"created": "December 23, 2022, 18:00",
4444
"createdint": 1671813330,
@@ -69,6 +69,37 @@ curl https://api.simplyprint.io/{id}/files/GetFiles?f=123&search=benchy \
6969
}
7070
],
7171
"custom": [1, 2, 3]
72+
},
73+
"cost": {
74+
"estimate": false,
75+
"total_cost": 150,
76+
"lines":[
77+
{
78+
"id": 1,
79+
"label": "Material usage (account default)",
80+
"cost": 0.02
81+
},
82+
{
83+
"id": 2,
84+
"label":"Material markup",
85+
"cost": null
86+
},
87+
{
88+
"id": 3,
89+
"label":"Machine run time cost",
90+
"cost": null
91+
},
92+
{
93+
"id": 4,
94+
"label": "Energy cost",
95+
"cost": null
96+
},
97+
{
98+
"id": 5,
99+
"label": "Labor cost",
100+
"cost": 1000
101+
}
102+
]
72103
}
73104
}
74105
],
@@ -109,6 +140,7 @@ This endpoint returns a list of files and folders in a given folder. If no folde
109140
| `f` | integer | no | Folder ID to get files for. **Defaults to 0 (root folder)** |
110141
| `search` | string | no | Search string to filter files by. |
111142
| `global_search` | boolean | no | If true, search all files in the account, not just the folder specified by `f`. |
143+
| `pid` | integer | no | For print cost calculation, if you want the files to use the material of a printer, request with the ID of the printer - don't include the `pid` argument otherwise |
112144

113145
### Response
114146

source/includes/_jobs.md

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,52 @@ curl https://api.simplyprint.io/{id}/jobs/GetPaginatedPrintJobs \
2929
"message": null,
3030
"data": [
3131
{
32-
"id": 549145,
33-
"uid": "7df103aa-b12c-4b33-8305-b55f91c11a4d",
34-
"status": "cancelled",
35-
"cancelReasonType": "5",
36-
"rating": -2,
37-
"filename": "Benchy.gcode",
38-
"startDate": "2023-02-28T21:05:50+00:00",
39-
"endDate": "2023-02-28T21:06:07+00:00",
40-
"user": 5933,
41-
"printer": 385,
42-
"filament": "{\"e0\": {\"usage\": 60}}",
43-
"filUsage": 60,
44-
"filUsageGram": 0,
45-
"currentPercentage": 48,
46-
"printTime": 17
32+
"id": 549145,
33+
"uid": "7df103aa-b12c-4b33-8305-b55f91c11a4d",
34+
"status": "cancelled",
35+
"cancelReasonType": "5",
36+
"rating": -2,
37+
"filename": "Benchy.gcode",
38+
"startDate": "2023-02-28T21:05:50+00:00",
39+
"endDate": "2023-02-28T21:06:07+00:00",
40+
"user": 5933,
41+
"printer": 385,
42+
"filament": "{\"e0\": {\"usage\": 60}}",
43+
"filUsage": 60,
44+
"filUsageGram": 0,
45+
"currentPercentage": 48,
46+
"printTime": 17,
47+
"cost": {
48+
"estimate": false,
49+
"total_cost": 150,
50+
"lines": [
51+
{
52+
"id": 1,
53+
"label": "Material usage (account default)",
54+
"cost": 0.02
55+
},
56+
{
57+
"id": 2,
58+
"label":"Material markup",
59+
"cost": null
60+
},
61+
{
62+
"id": 3,
63+
"label":"Machine run time cost",
64+
"cost": null
65+
},
66+
{
67+
"id": 4,
68+
"label": "Energy cost",
69+
"cost": null
70+
},
71+
{
72+
"id": 5,
73+
"label": "Labor cost",
74+
"cost": 1000
75+
}
76+
]
77+
}
4778
},
4879
...
4980
],
@@ -82,11 +113,12 @@ Get paginated data about ongoing or finished print jobs.
82113
| `data[].rating` | integer | The job rating. |
83114
| `data[].filename` | string | The job filename. |
84115
| `data[].startDate` | string | The job start date. |
85-
| `data[].endDate` | string/null | The job end date. Is null if the job is ongoing. |
116+
| `data[].endDate` | string|nullable | The job end date. Is null if the job is ongoing. |
86117
| `data[].user` | integer | The user id of the user who started the job. |
87118
| `data[].printer` | integer | The printer id that was used to print the job. |
88119
| `data[].filament` | string | The filament usage. JSON encoded string with usage per extruder. |
89120
| `data[].filUsage` | integer | The filament usage in mm. |
90121
| `data[].filUsageGram` | integer | The filament usage in grams. |
91122
| `data[].currentPercentage` | integer | The current percentage of the job. |
123+
| `data[].cost` | object|nullable | Potential calculated cost of job. |
92124
| `page_amount` | integer | The total number of pages for the given parameters. |

source/includes/_printers.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,40 @@ curl https://api.simplyprint.io/{id}/printers/actions/CreateJob?pid=1234&filesys
280280
1234,
281281
1235
282282
],
283-
"queued": false
283+
"queued": false,
284+
"cost": [
285+
{
286+
"estimate": false,
287+
"total_cost": 1006.76,
288+
"lines": [
289+
{
290+
"id": 1,
291+
"label": "HIPS Material usage",
292+
"cost": 0.05
293+
},
294+
{
295+
"id": 2,
296+
"label": "Material markup",
297+
"cost": 0.03
298+
},
299+
{
300+
"id": 3,
301+
"label": "Machine run time cost",
302+
"cost": 6.67
303+
},
304+
{
305+
"id": 4,
306+
"label": "Energy cost",
307+
"cost": 0.01
308+
},
309+
{
310+
"id": 5,
311+
"label": "Labor cost",
312+
"cost": 1000
313+
}
314+
]
315+
}
316+
]
284317
}
285318
],
286319
"jobIds": [
@@ -329,6 +362,7 @@ You can specify these parameters if `next_queue_item` is `true`. Note that you c
329362
| `files[].analysis` | object | The analysis of the file. This has been documented in the [Get queue items endpoint](#get-queue-items). |
330363
| `files[].printers` | integer[] | The IDs of the printers that the print job was started on. |
331364
| `files[].queued` | boolean | Whether the print job was from print queue. |
365+
| `files[].cost` | object[]|nullable | Potential calculated cost of job. Potential of multiple costs if job is created for different printers with different material types assigned. |
332366
| `jobIds` | integer[] | The IDs of the print jobs that were started. |
333367

334368
## Pause print job

0 commit comments

Comments
 (0)