diff --git a/postman/collections/Fleetbase API/Inspections/.resources/List Inspection Forms.resources/examples/OK.example.yaml b/postman/collections/Fleetbase API/Inspections/.resources/List Inspection Forms.resources/examples/OK.example.yaml new file mode 100644 index 0000000..aaef9b3 --- /dev/null +++ b/postman/collections/Fleetbase API/Inspections/.resources/List Inspection Forms.resources/examples/OK.example.yaml @@ -0,0 +1,77 @@ +$kind: http-example +request: + url: "{{base_url}}/{{namespace}}/inspection-forms" + method: GET + headers: + Accept: application/json +response: + statusCode: 200 + statusText: OK + headers: + Content-Type: application/json + body: + type: json + content: |- + [ + { + "id": "inspection_form_9Kd2Lm7Aq1", + "name": "Pre-trip DVIR", + "description": "Daily vehicle inspection report, filed before the first run.", + "type": "dvir", + "status": "published", + "items": [], + "grouped_fields": [ + { + "id": "category_4Tn6Ry8Wz3", + "name": "Safety", + "description": null, + "order": 1, + "meta": { "grid_size": 2 }, + "fields": [ + { + "id": "custom_field_9f61c8b7a6", + "name": "brakes", + "label": "Brakes", + "description": null, + "help_text": "Check the pedal travel.", + "type": "pass-fail", + "component": "pass-fail", + "required": true, + "editable": true, + "options": [], + "order": 1, + "meta": { + "severity": "critical", + "require_comment_on_fail": true, + "require_photo_on_fail": true, + "unsafe_on_fail": true + } + }, + { + "id": "custom_field_8a521d9f3b", + "name": "odometer", + "label": "Odometer", + "description": null, + "help_text": null, + "type": "number", + "component": "number", + "required": false, + "editable": true, + "options": [], + "order": 2, + "meta": { "unit": "km", "role": "odometer" } + } + ] + } + ], + "settings": { "create_issue_on_failure": true, "create_work_order_on_failure": false }, + "meta": {}, + "subject_name": null, + "item_count": 2, + "is_published": true, + "published_at": "2026-09-01T00:00:00.000000Z", + "updated_at": "2026-09-01T00:00:00.000000Z", + "created_at": "2026-08-28T00:00:00.000000Z" + } + ] +order: 1000 diff --git a/postman/collections/Fleetbase API/Inspections/.resources/List Inspections.resources/examples/OK.example.yaml b/postman/collections/Fleetbase API/Inspections/.resources/List Inspections.resources/examples/OK.example.yaml new file mode 100644 index 0000000..1863187 --- /dev/null +++ b/postman/collections/Fleetbase API/Inspections/.resources/List Inspections.resources/examples/OK.example.yaml @@ -0,0 +1,112 @@ +$kind: http-example +request: + url: "{{base_url}}/{{namespace}}/inspections" + method: GET + headers: + Accept: application/json +response: + statusCode: 200 + statusText: OK + headers: + Content-Type: application/json + body: + type: json + content: |- + [ + { + "id": "inspection_submission_4Mnp8Qx2Vz", + "form": { "id": "inspection_form_9Kd2Lm7Aq1", "name": "Pre-trip DVIR", "type": "dvir" }, + "vehicle": { "id": "vehicle_7Hx3Pq9Rt2", "plate_number": "TRK-7" }, + "driver": { "id": "driver_2Fb8Nc4Wm6", "name": "Dana Driver" }, + "issue": { "id": "issue_3Vb7Kd1Pq8", "status": "pending", "priority": "critical" }, + "work_order": null, + "answers": [ + { + "field": "custom_field_9f61c8b7a6", + "name": "brakes", + "label": "Brakes", + "type": "pass-fail", + "value": { + "passed": false, + "not_applicable": false, + "severity": "critical", + "comments": "Pedal is soft.", + "photos": [ + { + "id": "file_5Qw8Zt2Nb7", + "url": "https://files.fleetbase.io/inspections/4Mnp8Qx2Vz/lq8w1c0v9xk3.png", + "filename": "lq8w1c0v9xk3.png", + "content_type": "image/png" + } + ], + "unsafe": true + } + }, + { + "field": "custom_field_8a521d9f3b", + "name": "odometer", + "label": "Odometer", + "type": "number", + "value": 120400 + } + ], + "files": [ + { + "id": "file_5Qw8Zt2Nb7", + "uuid": "3a6c9e21-7b4d-4f18-9c05-2d8e1f7a6b34", + "url": "https://files.fleetbase.io/inspections/4Mnp8Qx2Vz/lq8w1c0v9xk3.png", + "original_filename": "lq8w1c0v9xk3.png", + "content_type": "image/png", + "type": "inspection_photo", + "caption": null, + "created_at": "2026-09-09T07:30:00.000000Z" + } + ], + "item_results": [ + { + "id": "b3f0c4a2-1d6e-4c1a-9c2b-8e7f6a5d4c3b", + "item_key": "brakes", + "label": "Brakes", + "category": "Safety", + "status": "failed", + "severity": "critical", + "passed": false, + "comments": "Pedal is soft.", + "photos": [ + { + "id": "file_5Qw8Zt2Nb7", + "url": "https://files.fleetbase.io/inspections/4Mnp8Qx2Vz/lq8w1c0v9xk3.png", + "filename": "lq8w1c0v9xk3.png", + "content_type": "image/png" + } + ], + "meta": { "not_applicable": false, "unsafe": true }, + "submission_id": "inspection_submission_4Mnp8Qx2Vz", + "updated_at": "2026-09-09T07:30:00.000000Z", + "created_at": "2026-09-09T07:30:00.000000Z" + } + ], + "type": "dvir", + "status": "submitted", + "result": "failed", + "source": "navigator", + "odometer": 120400, + "engine_hours": 3100, + "total_items": 1, + "failed_items": 1, + "location": { "latitude": 1.3521, "longitude": 103.8198 }, + "signature": {}, + "attachments": [], + "meta": { "unsafe": true }, + "form_name": "Pre-trip DVIR", + "vehicle_name": "Truck 7", + "driver_name": "Dana Driver", + "has_failures": true, + "started_at": "2026-09-09T07:10:00.000000Z", + "submitted_at": "2026-09-09T07:30:00.000000Z", + "resolved_at": null, + "updated_at": "2026-09-09T07:30:00.000000Z", + "created_at": "2026-09-09T07:30:00.000000Z" + } + ] +order: 1000 diff --git a/postman/collections/Fleetbase API/Inspections/.resources/List Vehicle Inspections.resources/examples/OK.example.yaml b/postman/collections/Fleetbase API/Inspections/.resources/List Vehicle Inspections.resources/examples/OK.example.yaml new file mode 100644 index 0000000..3101d9c --- /dev/null +++ b/postman/collections/Fleetbase API/Inspections/.resources/List Vehicle Inspections.resources/examples/OK.example.yaml @@ -0,0 +1,114 @@ +$kind: http-example +request: + url: "{{base_url}}/{{namespace}}/vehicles/:id/inspections" + method: GET + headers: + Accept: application/json + pathVariables: + id: "vehicle_7Hx3Pq9Rt2" +response: + statusCode: 200 + statusText: OK + headers: + Content-Type: application/json + body: + type: json + content: |- + [ + { + "id": "inspection_submission_4Mnp8Qx2Vz", + "form": { "id": "inspection_form_9Kd2Lm7Aq1", "name": "Pre-trip DVIR", "type": "dvir" }, + "vehicle": { "id": "vehicle_7Hx3Pq9Rt2", "plate_number": "TRK-7" }, + "driver": { "id": "driver_2Fb8Nc4Wm6", "name": "Dana Driver" }, + "issue": { "id": "issue_3Vb7Kd1Pq8", "status": "pending", "priority": "critical" }, + "work_order": null, + "answers": [ + { + "field": "custom_field_9f61c8b7a6", + "name": "brakes", + "label": "Brakes", + "type": "pass-fail", + "value": { + "passed": false, + "not_applicable": false, + "severity": "critical", + "comments": "Pedal is soft.", + "photos": [ + { + "id": "file_5Qw8Zt2Nb7", + "url": "https://files.fleetbase.io/inspections/4Mnp8Qx2Vz/lq8w1c0v9xk3.png", + "filename": "lq8w1c0v9xk3.png", + "content_type": "image/png" + } + ], + "unsafe": true + } + }, + { + "field": "custom_field_8a521d9f3b", + "name": "odometer", + "label": "Odometer", + "type": "number", + "value": 120400 + } + ], + "files": [ + { + "id": "file_5Qw8Zt2Nb7", + "uuid": "3a6c9e21-7b4d-4f18-9c05-2d8e1f7a6b34", + "url": "https://files.fleetbase.io/inspections/4Mnp8Qx2Vz/lq8w1c0v9xk3.png", + "original_filename": "lq8w1c0v9xk3.png", + "content_type": "image/png", + "type": "inspection_photo", + "caption": null, + "created_at": "2026-09-09T07:30:00.000000Z" + } + ], + "item_results": [ + { + "id": "b3f0c4a2-1d6e-4c1a-9c2b-8e7f6a5d4c3b", + "item_key": "brakes", + "label": "Brakes", + "category": "Safety", + "status": "failed", + "severity": "critical", + "passed": false, + "comments": "Pedal is soft.", + "photos": [ + { + "id": "file_5Qw8Zt2Nb7", + "url": "https://files.fleetbase.io/inspections/4Mnp8Qx2Vz/lq8w1c0v9xk3.png", + "filename": "lq8w1c0v9xk3.png", + "content_type": "image/png" + } + ], + "meta": { "not_applicable": false, "unsafe": true }, + "submission_id": "inspection_submission_4Mnp8Qx2Vz", + "updated_at": "2026-09-09T07:30:00.000000Z", + "created_at": "2026-09-09T07:30:00.000000Z" + } + ], + "type": "dvir", + "status": "submitted", + "result": "failed", + "source": "navigator", + "odometer": 120400, + "engine_hours": 3100, + "total_items": 1, + "failed_items": 1, + "location": { "latitude": 1.3521, "longitude": 103.8198 }, + "signature": {}, + "attachments": [], + "meta": { "unsafe": true }, + "form_name": "Pre-trip DVIR", + "vehicle_name": "Truck 7", + "driver_name": "Dana Driver", + "has_failures": true, + "started_at": "2026-09-09T07:10:00.000000Z", + "submitted_at": "2026-09-09T07:30:00.000000Z", + "resolved_at": null, + "updated_at": "2026-09-09T07:30:00.000000Z", + "created_at": "2026-09-09T07:30:00.000000Z" + } + ] +order: 1000 diff --git a/postman/collections/Fleetbase API/Inspections/.resources/Retrieve an Inspection Form.resources/examples/OK.example.yaml b/postman/collections/Fleetbase API/Inspections/.resources/Retrieve an Inspection Form.resources/examples/OK.example.yaml new file mode 100644 index 0000000..742cdf4 --- /dev/null +++ b/postman/collections/Fleetbase API/Inspections/.resources/Retrieve an Inspection Form.resources/examples/OK.example.yaml @@ -0,0 +1,77 @@ +$kind: http-example +request: + url: "{{base_url}}/{{namespace}}/inspection-forms/:id" + method: GET + headers: + Accept: application/json + pathVariables: + id: "inspection_form_9Kd2Lm7Aq1" +response: + statusCode: 200 + statusText: OK + headers: + Content-Type: application/json + body: + type: json + content: |- + { + "id": "inspection_form_9Kd2Lm7Aq1", + "name": "Pre-trip DVIR", + "description": "Daily vehicle inspection report, filed before the first run.", + "type": "dvir", + "status": "published", + "items": [], + "grouped_fields": [ + { + "id": "category_4Tn6Ry8Wz3", + "name": "Safety", + "description": null, + "order": 1, + "meta": { "grid_size": 2 }, + "fields": [ + { + "id": "custom_field_9f61c8b7a6", + "name": "brakes", + "label": "Brakes", + "description": null, + "help_text": "Check the pedal travel.", + "type": "pass-fail", + "component": "pass-fail", + "required": true, + "editable": true, + "options": [], + "order": 1, + "meta": { + "severity": "critical", + "require_comment_on_fail": true, + "require_photo_on_fail": true, + "unsafe_on_fail": true + } + }, + { + "id": "custom_field_8a521d9f3b", + "name": "odometer", + "label": "Odometer", + "description": null, + "help_text": null, + "type": "number", + "component": "number", + "required": false, + "editable": true, + "options": [], + "order": 2, + "meta": { "unit": "km", "role": "odometer" } + } + ] + } + ], + "settings": { "create_issue_on_failure": true, "create_work_order_on_failure": false }, + "meta": {}, + "subject_name": null, + "item_count": 2, + "is_published": true, + "published_at": "2026-09-01T00:00:00.000000Z", + "updated_at": "2026-09-01T00:00:00.000000Z", + "created_at": "2026-08-28T00:00:00.000000Z" + } +order: 1000 diff --git a/postman/collections/Fleetbase API/Inspections/.resources/Retrieve an Inspection.resources/examples/OK.example.yaml b/postman/collections/Fleetbase API/Inspections/.resources/Retrieve an Inspection.resources/examples/OK.example.yaml new file mode 100644 index 0000000..d58fceb --- /dev/null +++ b/postman/collections/Fleetbase API/Inspections/.resources/Retrieve an Inspection.resources/examples/OK.example.yaml @@ -0,0 +1,112 @@ +$kind: http-example +request: + url: "{{base_url}}/{{namespace}}/inspections/:id" + method: GET + headers: + Accept: application/json + pathVariables: + id: "inspection_submission_4Mnp8Qx2Vz" +response: + statusCode: 200 + statusText: OK + headers: + Content-Type: application/json + body: + type: json + content: |- + { + "id": "inspection_submission_4Mnp8Qx2Vz", + "form": { "id": "inspection_form_9Kd2Lm7Aq1", "name": "Pre-trip DVIR", "type": "dvir" }, + "vehicle": { "id": "vehicle_7Hx3Pq9Rt2", "plate_number": "TRK-7" }, + "driver": { "id": "driver_2Fb8Nc4Wm6", "name": "Dana Driver" }, + "issue": { "id": "issue_3Vb7Kd1Pq8", "status": "pending", "priority": "critical" }, + "work_order": null, + "answers": [ + { + "field": "custom_field_9f61c8b7a6", + "name": "brakes", + "label": "Brakes", + "type": "pass-fail", + "value": { + "passed": false, + "not_applicable": false, + "severity": "critical", + "comments": "Pedal is soft.", + "photos": [ + { + "id": "file_5Qw8Zt2Nb7", + "url": "https://files.fleetbase.io/inspections/4Mnp8Qx2Vz/lq8w1c0v9xk3.png", + "filename": "lq8w1c0v9xk3.png", + "content_type": "image/png" + } + ], + "unsafe": true + } + }, + { + "field": "custom_field_8a521d9f3b", + "name": "odometer", + "label": "Odometer", + "type": "number", + "value": 120400 + } + ], + "files": [ + { + "id": "file_5Qw8Zt2Nb7", + "uuid": "3a6c9e21-7b4d-4f18-9c05-2d8e1f7a6b34", + "url": "https://files.fleetbase.io/inspections/4Mnp8Qx2Vz/lq8w1c0v9xk3.png", + "original_filename": "lq8w1c0v9xk3.png", + "content_type": "image/png", + "type": "inspection_photo", + "caption": null, + "created_at": "2026-09-09T07:30:00.000000Z" + } + ], + "item_results": [ + { + "id": "b3f0c4a2-1d6e-4c1a-9c2b-8e7f6a5d4c3b", + "item_key": "brakes", + "label": "Brakes", + "category": "Safety", + "status": "failed", + "severity": "critical", + "passed": false, + "comments": "Pedal is soft.", + "photos": [ + { + "id": "file_5Qw8Zt2Nb7", + "url": "https://files.fleetbase.io/inspections/4Mnp8Qx2Vz/lq8w1c0v9xk3.png", + "filename": "lq8w1c0v9xk3.png", + "content_type": "image/png" + } + ], + "meta": { "not_applicable": false, "unsafe": true }, + "submission_id": "inspection_submission_4Mnp8Qx2Vz", + "updated_at": "2026-09-09T07:30:00.000000Z", + "created_at": "2026-09-09T07:30:00.000000Z" + } + ], + "type": "dvir", + "status": "submitted", + "result": "failed", + "source": "navigator", + "odometer": 120400, + "engine_hours": 3100, + "total_items": 1, + "failed_items": 1, + "location": { "latitude": 1.3521, "longitude": 103.8198 }, + "signature": {}, + "attachments": [], + "meta": { "unsafe": true }, + "form_name": "Pre-trip DVIR", + "vehicle_name": "Truck 7", + "driver_name": "Dana Driver", + "has_failures": true, + "started_at": "2026-09-09T07:10:00.000000Z", + "submitted_at": "2026-09-09T07:30:00.000000Z", + "resolved_at": null, + "updated_at": "2026-09-09T07:30:00.000000Z", + "created_at": "2026-09-09T07:30:00.000000Z" + } +order: 1000 diff --git a/postman/collections/Fleetbase API/Inspections/.resources/Submit an Inspection.resources/examples/Created.example.yaml b/postman/collections/Fleetbase API/Inspections/.resources/Submit an Inspection.resources/examples/Created.example.yaml new file mode 100644 index 0000000..95bfc65 --- /dev/null +++ b/postman/collections/Fleetbase API/Inspections/.resources/Submit an Inspection.resources/examples/Created.example.yaml @@ -0,0 +1,137 @@ +$kind: http-example +request: + url: "{{base_url}}/{{namespace}}/inspections" + method: POST + headers: + Accept: application/json + body: + type: json + content: |- + { + "inspection_form": "inspection_form_9Kd2Lm7Aq1", + "driver": "driver_2Fb8Nc4Wm6", + "vehicle": "vehicle_7Hx3Pq9Rt2", + "started_at": "2026-09-09T07:10:00Z", + "odometer": 120400, + "engine_hours": 3100, + "location": { "latitude": 1.3521, "longitude": 103.8198 }, + "answers": [ + { + "field": "custom_field_9f61c8b7a6", + "value_type": "object", + "value": { + "passed": false, + "not_applicable": false, + "severity": "critical", + "comments": "Pedal is soft.", + "photos": ["iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="], + "unsafe": true + } + }, + { "field": "custom_field_8a521d9f3b", "value_type": "number", "value": 120400 } + ] + } +response: + statusCode: 201 + statusText: Created + headers: + Content-Type: application/json + body: + type: json + content: |- + { + "id": "inspection_submission_4Mnp8Qx2Vz", + "form": { "id": "inspection_form_9Kd2Lm7Aq1", "name": "Pre-trip DVIR", "type": "dvir" }, + "vehicle": { "id": "vehicle_7Hx3Pq9Rt2", "plate_number": "TRK-7" }, + "driver": { "id": "driver_2Fb8Nc4Wm6", "name": "Dana Driver" }, + "issue": { "id": "issue_3Vb7Kd1Pq8", "status": "pending", "priority": "critical" }, + "work_order": null, + "answers": [ + { + "field": "custom_field_9f61c8b7a6", + "name": "brakes", + "label": "Brakes", + "type": "pass-fail", + "value": { + "passed": false, + "not_applicable": false, + "severity": "critical", + "comments": "Pedal is soft.", + "photos": [ + { + "id": "file_5Qw8Zt2Nb7", + "url": "https://files.fleetbase.io/inspections/4Mnp8Qx2Vz/lq8w1c0v9xk3.png", + "filename": "lq8w1c0v9xk3.png", + "content_type": "image/png" + } + ], + "unsafe": true + } + }, + { + "field": "custom_field_8a521d9f3b", + "name": "odometer", + "label": "Odometer", + "type": "number", + "value": 120400 + } + ], + "files": [ + { + "id": "file_5Qw8Zt2Nb7", + "uuid": "3a6c9e21-7b4d-4f18-9c05-2d8e1f7a6b34", + "url": "https://files.fleetbase.io/inspections/4Mnp8Qx2Vz/lq8w1c0v9xk3.png", + "original_filename": "lq8w1c0v9xk3.png", + "content_type": "image/png", + "type": "inspection_photo", + "caption": null, + "created_at": "2026-09-09T07:30:00.000000Z" + } + ], + "item_results": [ + { + "id": "b3f0c4a2-1d6e-4c1a-9c2b-8e7f6a5d4c3b", + "item_key": "brakes", + "label": "Brakes", + "category": "Safety", + "status": "failed", + "severity": "critical", + "passed": false, + "comments": "Pedal is soft.", + "photos": [ + { + "id": "file_5Qw8Zt2Nb7", + "url": "https://files.fleetbase.io/inspections/4Mnp8Qx2Vz/lq8w1c0v9xk3.png", + "filename": "lq8w1c0v9xk3.png", + "content_type": "image/png" + } + ], + "meta": { "not_applicable": false, "unsafe": true }, + "submission_id": "inspection_submission_4Mnp8Qx2Vz", + "updated_at": "2026-09-09T07:30:00.000000Z", + "created_at": "2026-09-09T07:30:00.000000Z" + } + ], + "type": "dvir", + "status": "submitted", + "result": "failed", + "source": "navigator", + "odometer": 120400, + "engine_hours": 3100, + "total_items": 1, + "failed_items": 1, + "location": { "latitude": 1.3521, "longitude": 103.8198 }, + "signature": {}, + "attachments": [], + "meta": { "unsafe": true }, + "form_name": "Pre-trip DVIR", + "vehicle_name": "Truck 7", + "driver_name": "Dana Driver", + "has_failures": true, + "started_at": "2026-09-09T07:10:00.000000Z", + "submitted_at": "2026-09-09T07:30:00.000000Z", + "resolved_at": null, + "updated_at": "2026-09-09T07:30:00.000000Z", + "created_at": "2026-09-09T07:30:00.000000Z" + } +order: 1000 diff --git a/postman/collections/Fleetbase API/Inspections/.resources/Submit an Inspection.resources/examples/Unprocessable Content.example.yaml b/postman/collections/Fleetbase API/Inspections/.resources/Submit an Inspection.resources/examples/Unprocessable Content.example.yaml new file mode 100644 index 0000000..06a6176 --- /dev/null +++ b/postman/collections/Fleetbase API/Inspections/.resources/Submit an Inspection.resources/examples/Unprocessable Content.example.yaml @@ -0,0 +1,31 @@ +$kind: http-example +request: + url: "{{base_url}}/{{namespace}}/inspections" + method: POST + headers: + Accept: application/json + body: + type: json + content: |- + { + "inspection_form": "inspection_form_9Kd2Lm7Aq1", + "driver": "driver_2Fb8Nc4Wm6", + "answers": [ + { "field": "custom_field_9f61c8b7a6", "value": { "passed": false, "severity": "critical" } } + ] + } +response: + statusCode: 422 + statusText: Unprocessable Content + headers: + Content-Type: application/json + body: + type: json + content: |- + { + "errors": [ + "A comment is required when \"Brakes\" fails.", + "A photo is required when \"Brakes\" fails." + ] + } +order: 2000 diff --git a/postman/collections/Fleetbase API/Inspections/.resources/object.yaml b/postman/collections/Fleetbase API/Inspections/.resources/object.yaml index fa26eea..a7d0b99 100644 --- a/postman/collections/Fleetbase API/Inspections/.resources/object.yaml +++ b/postman/collections/Fleetbase API/Inspections/.resources/object.yaml @@ -10,13 +10,12 @@ example: | "driver": { "id": "driver_2Fb8Nc4Wm6", "name": "Dana Driver" }, "issue": null, "work_order": null, - "custom_field_values": [ + "answers": [ { - "custom_field": "0d2b7f1e-4a3c-4d5e-9f61-2c8b7a6d5e4f", + "field": "custom_field_9f61c8b7a6", "name": "brakes", "label": "Brakes", "type": "pass-fail", - "value_type": "object", "value": { "passed": true, "not_applicable": false, @@ -27,19 +26,17 @@ example: | } }, { - "custom_field": "7c1a9e42-6b8d-4f30-8a52-1d9f3b6c4e70", + "field": "custom_field_8a521d9f3b", "name": "odometer", "label": "Odometer", "type": "number", - "value_type": "number", "value": 120400 }, { - "custom_field": "b8e5d3c1-2f74-4a96-bc08-5e1a7d2f9c63", + "field": "custom_field_bc085e1a7d", "name": "signature", "label": "Sign here", "type": "signature", - "value_type": "file", "value": { "id": "file_5Qw8Zt2Nb7", "url": "https://files.fleetbase.io/inspections/4Mnp8Qx2Vz/lq8w1c0v9xk3.png", @@ -118,15 +115,15 @@ fields: - name: work_order type: object description: The work order opened for the failed items, when the form asks for one and any item failed. - - name: custom_field_values + - name: answers type: array of objects - description: The driver's answer to each field of the form — the field's `custom_field` id, `name`, `label`, `type` and `value_type` beside the `value`. A `pass-fail` value is an object of `passed`, `not_applicable`, `severity`, `comments`, `photos` and `unsafe`; a photo or signature value is resolved to `{ id, url, filename, content_type }` rather than the base64 that was sent. + description: The driver's answer to each field of the form — the `field` it answers, named by the same id the form gave it, beside the field's `name`, `label` and `type` and the `value`. A `pass-fail` value is an object of `passed`, `not_applicable`, `severity`, `comments`, `photos` and `unsafe`; a photo or signature value is resolved to `{ id, url, filename, content_type }` rather than the base64 that was sent. - name: files type: array of objects description: The photos and signatures filed with the inspection, however they arrived — inside the submit body, or dropped on the console's Photos panel. - name: item_results type: array of objects - description: One result per `pass-fail` answer, derived from `custom_field_values` — `item_key`, `label`, `category`, `status` (`passed`, `failed` or `not_applicable`), `severity`, `passed`, `comments` and `photos`. This is what issues, work orders and the vehicle's history are built from. + description: One result per `pass-fail` answer, derived from the `answers` — `item_key`, `label`, `category`, `status` (`passed`, `failed` or `not_applicable`), `severity`, `passed`, `comments` and `photos`. This is what issues, work orders and the vehicle's history are built from. - name: type type: string description: Inspection type, taken from the form — `dvir`, `pre_trip`, `post_trip`, or a custom type. diff --git a/postman/collections/Fleetbase API/Inspections/List Inspections.request.yaml b/postman/collections/Fleetbase API/Inspections/List Inspections.request.yaml index b2c609b..8dd0026 100644 --- a/postman/collections/Fleetbase API/Inspections/List Inspections.request.yaml +++ b/postman/collections/Fleetbase API/Inspections/List Inspections.request.yaml @@ -5,7 +5,7 @@ description: |- Narrow by `driver` or `vehicle`, and by `type`, `result` and `status`, each as one value or a comma separated list. Defaults to a recent window rather than the organisation's whole history; use `limit` to widen it. - Each row carries the same shape Retrieve an Inspection answers with: the answers as `custom_field_values`, the `item_results` derived from them, and the `files` filed with the inspection. + Each row carries the same shape Retrieve an Inspection answers with: the `answers`, the `item_results` derived from them, and the `files` filed with the inspection. url: "{{base_url}}/{{namespace}}/inspections" method: GET queryParams: diff --git a/postman/collections/Fleetbase API/Inspections/List Vehicle Inspections.request.yaml b/postman/collections/Fleetbase API/Inspections/List Vehicle Inspections.request.yaml index ed78ec6..3fc1a48 100644 --- a/postman/collections/Fleetbase API/Inspections/List Vehicle Inspections.request.yaml +++ b/postman/collections/Fleetbase API/Inspections/List Vehicle Inspections.request.yaml @@ -5,7 +5,7 @@ description: |- Narrow by `type`, `result` and `status`, each as one value or a comma separated list. - Each row carries the answers as `custom_field_values`, the `item_results` derived from them, and the `files` filed with the inspection. + Each row carries the `answers`, the `item_results` derived from them, and the `files` filed with the inspection. url: "{{base_url}}/{{namespace}}/vehicles/:id/inspections" method: GET pathVariables: diff --git a/postman/collections/Fleetbase API/Inspections/Retrieve an Inspection.request.yaml b/postman/collections/Fleetbase API/Inspections/Retrieve an Inspection.request.yaml index 971e9d1..f3dbc04 100644 --- a/postman/collections/Fleetbase API/Inspections/Retrieve an Inspection.request.yaml +++ b/postman/collections/Fleetbase API/Inspections/Retrieve an Inspection.request.yaml @@ -1,7 +1,7 @@ $kind: http-request name: "Retrieve an Inspection" description: |- - Retrieves one inspection with everything it produced: `custom_field_values` — the driver's answers, each beside the field's `name`, `label` and `type`, with every photo and signature resolved to `{ id, url, filename, content_type }` — the `item_results` derived from the `pass-fail` answers, the `files` filed with it, and the `issue` and `work_order` raised from any failed items. + Retrieves one inspection with everything it produced: the `answers` — one per field the driver answered, each naming the `field` it answers beside that field's `name`, `label` and `type`, with every photo and signature resolved to `{ id, url, filename, content_type }` — the `item_results` derived from the `pass-fail` answers, the `files` filed with it, and the `issue` and `work_order` raised from any failed items. url: "{{base_url}}/{{namespace}}/inspections/:id" method: GET pathVariables: diff --git a/postman/collections/Fleetbase API/Inspections/Submit an Inspection.params.yaml b/postman/collections/Fleetbase API/Inspections/Submit an Inspection.params.yaml index b64b7e5..7800afb 100644 --- a/postman/collections/Fleetbase API/Inspections/Submit an Inspection.params.yaml +++ b/postman/collections/Fleetbase API/Inspections/Submit an Inspection.params.yaml @@ -24,10 +24,27 @@ fields: type: integer required: false description: Engine hours at the time of the inspection. + - name: answers + type: array of objects + required: false + description: "One entry per field the driver answered. Required unless a flat `item_results` body is sent instead; when both arrive the answers win. `custom_field_values` is accepted as the previous name for this field." + fields: + - name: field + type: string + required: true + description: The field being answered, named by the `id` the form read gave it. Its `name` is accepted too. + - name: value + type: any + required: true + description: "The answer. A `pass-fail` field takes an object of `passed`, `not_applicable`, `severity`, `comments`, `photos` and `unsafe`; a meter takes a number; a signature or photo takes a base64 encoded image or a URL; everything else takes its plain value." + - name: value_type + type: string + required: false + description: How to store the value — `object`, `number`, `boolean`, `text` or `file`. Derived from the field's own type when omitted. - name: item_results type: array of objects - required: true - description: One entry per checklist item answered. At least one is required. + required: false + description: The first cut's flat checklist body, still accepted for older app builds and the tokenised public link. Required only when no `answers` are sent. fields: - name: item_key type: string diff --git a/postman/collections/Fleetbase API/Inspections/Submit an Inspection.request.yaml b/postman/collections/Fleetbase API/Inspections/Submit an Inspection.request.yaml index c83add9..53938da 100644 --- a/postman/collections/Fleetbase API/Inspections/Submit an Inspection.request.yaml +++ b/postman/collections/Fleetbase API/Inspections/Submit an Inspection.request.yaml @@ -3,7 +3,7 @@ name: "Submit an Inspection" description: |- Files an inspection against a published form, as the driver app does at the end of a DVIR. - A form built from typed fields is answered with `custom_field_values`: one entry per field the driver answered, naming the field by the `id` the form read gave it, with a `value_type` and a `value`. A `pass-fail` answer is an object — `passed`, `not_applicable`, `severity`, `comments`, `photos` and `unsafe`; a meter is a number, a signature or a photo is base64. The server stores every photo and signature as a file and answers with `file:` references resolved, and mirrors each `pass-fail` answer into an `item_results` row, which is what issues, work orders and the vehicle's history are built from. + A form built from typed fields is answered with `answers`: one entry per field the driver answered, naming the `field` by the `id` the form read gave it, with a `value` and, optionally, a `value_type`. `custom_field_values` is the previous name for this and is still accepted. A `pass-fail` answer is an object — `passed`, `not_applicable`, `severity`, `comments`, `photos` and `unsafe`; a meter is a number, a signature or a photo is base64. The server stores every photo and signature as a file and answers with `file:` references resolved, and mirrors each `pass-fail` answer into an `item_results` row, which is what issues, work orders and the vehicle's history are built from. The first cut's flat `item_results` body is still accepted, for the tokenised public link and for older app builds. When both arrive the field values win and the duplicated results are ignored — which is exactly what the app sends, so one body works against either cut. @@ -13,7 +13,7 @@ description: |- The app queues a submit while offline and replays it later. Send an `Idempotency-Key` header with each attempt: a replay with a key already used by the same driver answers with the inspection the first attempt filed rather than filing a second one. - The response is the inspection with its `custom_field_values`, `item_results` and `files`, and the `issue` and `work_order` the form's settings raised from any failed items. + The response is the inspection with its `answers`, `item_results` and `files`, and the `issue` and `work_order` the form's settings raised from any failed items. url: "{{base_url}}/{{namespace}}/inspections" method: POST headers: @@ -33,7 +33,7 @@ body: "latitude": 1.3521, "longitude": 103.8198 }, - "custom_field_values": [], + "answers": [], "item_results": [ { "item_key": "brakes", @@ -57,7 +57,7 @@ scripts: - type: beforeRequest code: |- // The app sends both bodies and lets the server choose; so does this. - // `custom_field_values` is filled in from the fields Retrieve an + // `answers` is filled in from the fields Retrieve an // Inspection Form chained, because a field is named by an id that only // exists once the form has been read. A form that has not been rebuilt // from the first cut has no fields to name, so the entry is left empty @@ -76,7 +76,7 @@ scripts: if (passFail) { values.push({ - custom_field: passFail, + field: passFail, value_type: "object", value: { passed: false, @@ -90,15 +90,15 @@ scripts: } if (meter) { - values.push({ custom_field: meter, value_type: "number", value: 120400 }); + values.push({ field: meter, value_type: "number", value: 120400 }); } if (signature && photo) { - values.push({ custom_field: signature, value_type: "file", value: photo }); + values.push({ field: signature, value_type: "file", value: photo }); } const body = JSON.parse(pm.request.body.raw); - body.custom_field_values = values; + body.answers = values; // update() replaces the body wholesale, including the raw language that // made it JSON: without restating it the rewritten body went out as // text/plain, the API parsed nothing, and refused every field as missing. @@ -130,18 +130,20 @@ scripts: return; } - pm.expect(json_response.custom_field_values, "no field values were answered").to.be.an("array"); - pm.expect(json_response.custom_field_values.length, "fewer values than were sent").to.eql(sent); + pm.expect(json_response.answers, "no answers were recorded").to.be.an("array"); + pm.expect(json_response.answers.length, "fewer answers than were sent").to.eql(sent); - json_response.custom_field_values.forEach((value) => { - pm.expect(value.custom_field, "a value that names no field").to.be.a("string").and.not.empty; + json_response.answers.forEach((value) => { + pm.expect(value.field, "an answer that names no field").to.be.a("string").and.not.empty; // A photo or signature is stored as a file and answered as one, // never handed back as the base64 that was sent. const photos = (value.value && Array.isArray(value.value.photos)) ? value.value.photos : []; photos.forEach((file) => pm.expect(file, "a photo left unresolved").to.be.an("object").and.to.have.property("url")); - if (value.value_type === "file" && value.value) { + // `value_type` describes storage and is not public; the + // field's own type is what says a value is a stored file. + if ((value.type === "signature" || value.type === "file-upload") && value.value) { pm.expect(value.value, "a signature left unresolved").to.be.an("object").and.to.have.property("url"); } });