Skip to content

Commit 9ccd619

Browse files
committed
Add 1 v1 report api endpoints
1 parent 2ed22d2 commit 9ccd619

File tree

3 files changed

+227
-0
lines changed

3 files changed

+227
-0
lines changed

.vitepress/config.mts

+1
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ export default withMermaid(defineConfig({
434434
collapse(sidebarSpec1.generateSidebarGroup({ tag: ["readings-gateway"], text: "Gateway readings", linkPrefix: '/apis/v1/', addedOperations: new Set(),})),
435435
collapse(sidebarSpec1.generateSidebarGroup({ tag: ["notifications"], text: "Notifications", linkPrefix: '/apis/v1/', addedOperations: new Set(),})),
436436
collapse(sidebarSpec1.generateSidebarGroup({ tag: ["geofences"], text: "Geofences", linkPrefix: '/apis/v1/', addedOperations: new Set(),})),
437+
collapse(sidebarSpec1.generateSidebarGroup({ tag: ["reports"], text: "Reports", linkPrefix: '/apis/v1/', addedOperations: new Set(),})),
437438
collapse(sidebarSpec1.generateSidebarGroup({ tag: ["rtk"], text: "RTK", linkPrefix: '/apis/v1/', addedOperations: new Set(),})),
438439
collapse(sidebarSpec1.generateSidebarGroup({ tag: ["mqtt"], text: "MQTT", linkPrefix: '/apis/v1/', addedOperations: new Set(),})),
439440
collapse(sidebarSpec1.generateSidebarGroup({ tag: ["device-misc"], text: "Device Misc", linkPrefix: '/apis/v1/', addedOperations: new Set(),})),

public/swagger/v1.json

+117
Original file line numberDiff line numberDiff line change
@@ -3828,6 +3828,92 @@
38283828
},
38293829
"deprecated": false
38303830
}
3831+
},
3832+
"/reports/vehicle-summary": {
3833+
"post": {
3834+
"tags": [
3835+
"report"
3836+
],
3837+
"requestBody": {
3838+
"$ref": "#/components/requestBodies/postReportsVehicleSummary"
3839+
},
3840+
"responses": {
3841+
"200": {
3842+
"description": "Request was successful",
3843+
"content": {
3844+
"application/json": {
3845+
"schema": {
3846+
"type": "object"
3847+
}
3848+
},
3849+
"application/xml": {
3850+
"schema": {
3851+
"type": "object"
3852+
}
3853+
},
3854+
"text/xml": {
3855+
"schema": {
3856+
"type": "object"
3857+
}
3858+
},
3859+
"application/javascript": {
3860+
"schema": {
3861+
"type": "object"
3862+
}
3863+
},
3864+
"text/javascript": {
3865+
"schema": {
3866+
"type": "object"
3867+
}
3868+
}
3869+
}
3870+
}
3871+
},
3872+
"deprecated": false
3873+
}
3874+
},
3875+
"/reports/activity": {
3876+
"post": {
3877+
"tags": [
3878+
"report"
3879+
],
3880+
"requestBody": {
3881+
"$ref": "#/components/requestBodies/postReportsVehicleSummary"
3882+
},
3883+
"responses": {
3884+
"200": {
3885+
"description": "Request was successful",
3886+
"content": {
3887+
"application/json": {
3888+
"schema": {
3889+
"type": "object"
3890+
}
3891+
},
3892+
"application/xml": {
3893+
"schema": {
3894+
"type": "object"
3895+
}
3896+
},
3897+
"text/xml": {
3898+
"schema": {
3899+
"type": "object"
3900+
}
3901+
},
3902+
"application/javascript": {
3903+
"schema": {
3904+
"type": "object"
3905+
}
3906+
},
3907+
"text/javascript": {
3908+
"schema": {
3909+
"type": "object"
3910+
}
3911+
}
3912+
}
3913+
}
3914+
},
3915+
"deprecated": false
3916+
}
38313917
}
38323918
},
38333919
"tags": [
@@ -3891,6 +3977,37 @@
38913977
}
38923978
},
38933979
"description": "Body (JSON)"
3980+
},
3981+
"postReportsVehicleSummary": {
3982+
"content": {
3983+
"application/x-www-form-urlencoded": {
3984+
"schema": {
3985+
"type": "object",
3986+
"properties": {
3987+
"deviceId": {
3988+
"description": "The device id to get the data for",
3989+
"type": "number",
3990+
"format": ""
3991+
},
3992+
"dateRange": {
3993+
"description": "The date range to get the data for, in epoch milliseconds, [start, end]",
3994+
"type": "string",
3995+
"format": "JSON"
3996+
},
3997+
"parameters": {
3998+
"description": "Optional parameters, as JSON object, use the APP and developer console to see the options",
3999+
"type": "string",
4000+
"format": "JSON"
4001+
}
4002+
},
4003+
"required": [
4004+
"deviceId",
4005+
"dateRange"
4006+
]
4007+
}
4008+
}
4009+
},
4010+
"required": true
38944011
}
38954012
},
38964013
"schemas": {

swagger/load.ts

+109
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ const v1SummaryOverrides = {
5050
'get-devices-id-activateOnResellerPlan': 'Activate device on reseller plan',
5151

5252
'get-devices-id-setNtripSettings': 'Set the NTRIP settings for a device.',
53+
54+
'post-reports-activity': 'Device Activity',
55+
'post-reports-vehicle-summary': 'Vehicle Summary',
5356
}
5457

5558
const v1DescriptionOverrides = {
@@ -137,6 +140,8 @@ const v1ReTag = {
137140
'get-users-id-geofences': 'geofences',
138141
'get-users-id-geofences-fk': 'geofences',
139142

143+
'post-reports-activity': 'reports',
144+
'post-reports-vehicle-summary': 'reports',
140145
}
141146

142147
const v1Removed = [
@@ -161,6 +166,103 @@ const V1ParamExamples = {
161166
},
162167
}
163168

169+
const V1ResponseExamples = {
170+
'post-reports-activity': {
171+
'200': {
172+
'application/json': {
173+
'schema': {
174+
'type': 'object',
175+
'properties': {
176+
'off': {
177+
'type': 'object',
178+
'properties': {
179+
'time': { 'type': 'number' },
180+
'distance': { 'type': 'number' }
181+
}
182+
},
183+
'idle': {
184+
'type': 'object',
185+
'properties': {
186+
'time': { 'type': 'number' },
187+
'distance': { 'type': 'number' }
188+
}
189+
},
190+
'movingWithIgnitionOn': {
191+
'type': 'object',
192+
'properties': {
193+
'time': { 'type': 'number' },
194+
'distance': { 'type': 'number' }
195+
}
196+
},
197+
'movingWithIgnitionOff': {
198+
'type': 'object',
199+
'properties': {
200+
'time': { 'type': 'number' },
201+
'distance': { 'type': 'number' }
202+
}
203+
},
204+
'log': {
205+
'type': 'array',
206+
'items': { 'type': 'object' }
207+
}
208+
}
209+
}
210+
}
211+
}
212+
},
213+
'post-reports-vehicle-summary': {
214+
'200': {
215+
'application/json': {
216+
'schema': {
217+
'type': 'object',
218+
'properties': {
219+
'numTrips': { 'type': 'number' },
220+
'totalDist': { 'type': 'number' },
221+
'totalTime': { 'type': 'number' },
222+
'avgDist': { 'type': ['number', 'null'] },
223+
'avgTime': { 'type': ['number', 'null'] },
224+
'idleTime': {
225+
'type': 'object',
226+
'properties': {
227+
'total': { 'type': 'number' },
228+
'inWork': { 'type': 'number' },
229+
'inMaintenance': { 'type': 'number' }
230+
}
231+
},
232+
'distances': {
233+
'type': 'object',
234+
'properties': {
235+
'total': { 'type': 'number' },
236+
'inWork': { 'type': 'number' },
237+
'inMaintenance': { 'type': 'number' }
238+
}
239+
},
240+
'ignitionTime': { 'type': ['number', 'null'] },
241+
'movingTime': {
242+
'type': 'object',
243+
'properties': {
244+
'total': { 'type': 'number' },
245+
'inWork': { 'type': 'number' },
246+
'inMaintenance': { 'type': 'number' }
247+
}
248+
},
249+
'workTime': { 'type': 'number' },
250+
'maintenanceTime': { 'type': 'number' },
251+
'offTimes': {
252+
'type': 'object',
253+
'properties': {
254+
'total': { 'type': 'number' },
255+
'inWork': { 'type': 'number' },
256+
'inMaintenance': { 'type': 'number' }
257+
}
258+
}
259+
}
260+
}
261+
}
262+
}
263+
}
264+
}
265+
164266
const V1BodyExamples = {
165267
'post-devices-changeTags': {
166268
'ids': '[1, 2, 3]',
@@ -240,6 +342,13 @@ export function loadSpec(version: number): any {
240342
}
241343
}
242344
}
345+
if (operationId in V1ResponseExamples) {
346+
for (const response of Object.keys(spec1.paths[path][method].responses)) {
347+
if (response in V1ResponseExamples[operationId]) {
348+
spec1.paths[path][method].responses[response].content = V1ResponseExamples[operationId][response]
349+
}
350+
}
351+
}
243352
if (operationId in V1ParamDescriptions) {
244353
for (const param of spec1.paths[path][method].parameters) {
245354
if (param.name in V1ParamDescriptions[operationId]) {

0 commit comments

Comments
 (0)