feat: add API endpoints for creating inspections from templates and sharing documents

This commit is contained in:
humam kerdiah 2026-05-18 14:43:11 +04:00
parent 5570527e69
commit 2d6e3c5734
3 changed files with 583 additions and 0 deletions

View File

@ -368,6 +368,9 @@
}, },
{ {
"name": "Document print / download" "name": "Document print / download"
},
{
"name": "Document share"
} }
], ],
"paths": { "paths": {
@ -18229,6 +18232,169 @@
} }
} }
}, },
"/api/inspections/from-template": {
"post": {
"tags": [
"Inspections"
],
"summary": "Create inspection from a template (DVI flow).",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"template_id": {
"type": "integer"
},
"title": {
"type": "string"
},
"customer_id": {
"type": "integer"
},
"vehicle_id": {
"type": "integer"
},
"department_id": {
"type": "integer"
},
"employee_id": {
"type": "integer"
},
"order_number": {
"type": "string"
},
"date": {
"type": "string"
},
"time": {
"type": "string"
},
"odometer": {
"type": "integer"
},
"note": {
"type": "string"
},
"inspection_category_id": {
"type": "integer"
}
}
},
"example": {
"template_id": 1,
"title": "Pre-Service Inspection",
"customer_id": 1,
"vehicle_id": 1,
"department_id": 1,
"employee_id": 1,
"order_number": "INSP-001",
"date": "2026-03-31",
"time": "09:00:00",
"odometer": 12500,
"note": "Initial walk-around notes.",
"inspection_category_id": 1
}
}
}
},
"responses": {
"201": {
"description": "Created",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"data": {
"type": "object",
"properties": {
"id": {
"type": "integer"
},
"title": {
"type": "string"
},
"customer_id": {
"type": "integer"
},
"vehicle_id": {
"type": "integer"
},
"department_id": {
"type": "integer"
},
"employee_id": {
"type": "integer"
},
"order_number": {
"type": "string"
},
"date": {
"type": "string"
},
"time": {
"type": "string"
},
"odometer": {
"type": "integer"
},
"note": {
"type": "string"
},
"inspection_category_id": {
"type": "integer"
},
"template_id": {
"type": "integer"
},
"status": {
"type": "string"
},
"created_at": {
"type": "string",
"format": "date-time"
},
"updated_at": {
"type": "string",
"format": "date-time"
}
}
}
}
},
"example": {
"message": "Inspection created successfully",
"data": {
"id": 1,
"title": "Pre-Service Inspection",
"customer_id": 1,
"vehicle_id": 1,
"department_id": 1,
"employee_id": 1,
"order_number": "INSP-001",
"date": "2026-03-31",
"time": "09:00:00",
"odometer": 12500,
"note": "Initial walk-around notes.",
"inspection_category_id": 1,
"template_id": 1,
"status": "in_progress",
"created_at": "2026-03-31T10:00:00.000000Z",
"updated_at": "2026-03-31T10:00:00.000000Z"
}
}
}
}
}
}
}
},
"/api/inspections/{id}": { "/api/inspections/{id}": {
"put": { "put": {
"tags": [ "tags": [
@ -56330,6 +56496,81 @@
} }
} }
} }
},
"/api/documents/share": {
"post": {
"tags": [
"Document share"
],
"summary": "POST /api/documents/share",
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"document_type": {
"type": "string"
},
"document_id": {
"type": "integer"
},
"channel": {
"type": "string"
},
"email": {
"type": "string"
},
"phone": {
"type": "string"
},
"message": {
"type": "string"
}
}
},
"example": {
"document_type": "invoice",
"document_id": 1,
"channel": "email",
"email": "customer@example.com",
"phone": "+971500000000",
"message": "Please find your document."
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"share_url": {
"type": "string"
},
"whatsapp_url": {
"type": "string"
},
"expires_at": {
"type": "string",
"format": "date-time"
}
}
},
"example": {
"share_url": "https://example.com/share/abc",
"whatsapp_url": "https://wa.me/971500000000?text=...",
"expires_at": "2026-05-19T12:00:00+00:00"
}
}
}
}
}
}
} }
} }
} }

View File

@ -11624,6 +11624,84 @@
} }
] ]
}, },
{
"name": "Create inspection from a template (DVI flow).",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{auth_token}}",
"type": "string"
}
]
},
"method": "POST",
"header": [
{
"key": "Accept",
"value": "application/json"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"template_id\": 1,\n \"title\": \"Pre-Service Inspection\",\n \"customer_id\": 1,\n \"vehicle_id\": 1,\n \"department_id\": 1,\n \"employee_id\": 1,\n \"order_number\": \"INSP-001\",\n \"date\": \"2026-03-31\",\n \"time\": \"09:00:00\",\n \"odometer\": 12500,\n \"note\": \"Initial walk-around notes.\",\n \"inspection_category_id\": 1\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{base_url}}/api/inspections/from-template",
"host": [
"{{base_url}}"
],
"path": [
"api",
"inspections",
"from-template"
]
},
"description": "Required: template_id, title, customer_id, vehicle_id, department_id, employee_id, order_number, date, time (H:i:s). Optional: odometer, note, inspection_category_id. Available only when inspections.use_dvi_flow is enabled."
},
"response": [
{
"name": "201 Created",
"originalRequest": {
"method": "POST",
"header": [],
"url": {
"raw": "{{base_url}}/api/inspections/from-template",
"host": [
"{{base_url}}"
],
"path": [
"api",
"inspections",
"from-template"
]
}
},
"status": "Created",
"code": 201,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"cookie": [],
"body": "{\n \"message\": \"Inspection created successfully\",\n \"data\": {\n \"id\": 1,\n \"title\": \"Pre-Service Inspection\",\n \"customer_id\": 1,\n \"vehicle_id\": 1,\n \"department_id\": 1,\n \"employee_id\": 1,\n \"order_number\": \"INSP-001\",\n \"date\": \"2026-03-31\",\n \"time\": \"09:00:00\",\n \"odometer\": 12500,\n \"note\": \"Initial walk-around notes.\",\n \"inspection_category_id\": 1,\n \"template_id\": 1,\n \"status\": \"in_progress\",\n \"created_at\": \"2026-03-31T10:00:00.000000Z\",\n \"updated_at\": \"2026-03-31T10:00:00.000000Z\"\n }\n}"
}
]
},
{ {
"name": "Update the specified inspection.", "name": "Update the specified inspection.",
"request": { "request": {
@ -43839,6 +43917,87 @@
} }
], ],
"description": "Unified PDF endpoint. Query/body: type = inspection | estimate | job_card | invoice | payment_received | expense | purchase_order | bill | payment_made; id = record id; mode = print (inline) | download (attachment)." "description": "Unified PDF endpoint. Query/body: type = inspection | estimate | job_card | invoice | payment_received | expense | purchase_order | bill | payment_made; id = record id; mode = print (inline) | download (attachment)."
},
{
"name": "Document share",
"item": [
{
"name": "POST /api/documents/share",
"request": {
"auth": {
"type": "bearer",
"bearer": [
{
"key": "token",
"value": "{{auth_token}}",
"type": "string"
}
]
},
"method": "POST",
"header": [
{
"key": "Accept",
"value": "application/json"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"document_type\": \"invoice\",\n \"document_id\": 1,\n \"channel\": \"email\",\n \"email\": \"customer@example.com\",\n \"phone\": \"+971500000000\",\n \"message\": \"Please find your document.\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{base_url}}/api/documents/share",
"host": [
"{{base_url}}"
],
"path": [
"api",
"documents",
"share"
]
}
},
"response": [
{
"name": "200 OK",
"originalRequest": {
"method": "POST",
"header": [],
"url": {
"raw": "{{base_url}}/api/documents/share",
"host": [
"{{base_url}}"
],
"path": [
"api",
"documents",
"share"
]
}
},
"status": "OK",
"code": 200,
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": "{\n \"share_url\": \"https://example.com/share/abc\",\n \"whatsapp_url\": \"https://wa.me/971500000000?text=...\",\n \"expires_at\": \"2026-05-19T12:00:00+00:00\"\n}"
}
]
}
],
"description": "Generates a tokenized share URL (and WhatsApp link) for a document; optionally emails it. Body: document_type, document_id, channel (email|link), email (required if channel=email), phone, message."
} }
], ],
"auth": { "auth": {

View File

@ -11786,6 +11786,120 @@ export interface paths {
patch?: never; patch?: never;
trace?: never; trace?: never;
}; };
"/api/inspections/from-template": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get?: never;
put?: never;
/** Create inspection from a template (DVI flow). */
post: {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody: {
content: {
/**
* @example {
* "template_id": 1,
* "title": "Pre-Service Inspection",
* "customer_id": 1,
* "vehicle_id": 1,
* "department_id": 1,
* "employee_id": 1,
* "order_number": "INSP-001",
* "date": "2026-03-31",
* "time": "09:00:00",
* "odometer": 12500,
* "note": "Initial walk-around notes.",
* "inspection_category_id": 1
* }
*/
"application/json": {
template_id?: number;
title?: string;
customer_id?: number;
vehicle_id?: number;
department_id?: number;
employee_id?: number;
order_number?: string;
date?: string;
time?: string;
odometer?: number;
note?: string;
inspection_category_id?: number;
};
};
};
responses: {
/** @description Created */
201: {
headers: {
[name: string]: unknown;
};
content: {
/**
* @example {
* "message": "Inspection created successfully",
* "data": {
* "id": 1,
* "title": "Pre-Service Inspection",
* "customer_id": 1,
* "vehicle_id": 1,
* "department_id": 1,
* "employee_id": 1,
* "order_number": "INSP-001",
* "date": "2026-03-31",
* "time": "09:00:00",
* "odometer": 12500,
* "note": "Initial walk-around notes.",
* "inspection_category_id": 1,
* "template_id": 1,
* "status": "in_progress",
* "created_at": "2026-03-31T10:00:00.000000Z",
* "updated_at": "2026-03-31T10:00:00.000000Z"
* }
* }
*/
"application/json": {
message?: string;
data?: {
id?: number;
title?: string;
customer_id?: number;
vehicle_id?: number;
department_id?: number;
employee_id?: number;
order_number?: string;
date?: string;
time?: string;
odometer?: number;
note?: string;
inspection_category_id?: number;
template_id?: number;
status?: string;
/** Format: date-time */
created_at?: string;
/** Format: date-time */
updated_at?: string;
};
};
};
};
};
};
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
"/api/inspections/{id}": { "/api/inspections/{id}": {
parameters: { parameters: {
query?: never; query?: never;
@ -38964,6 +39078,75 @@ export interface paths {
patch?: never; patch?: never;
trace?: never; trace?: never;
}; };
"/api/documents/share": {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
get?: never;
put?: never;
/** POST /api/documents/share */
post: {
parameters: {
query?: never;
header?: never;
path?: never;
cookie?: never;
};
requestBody: {
content: {
/**
* @example {
* "document_type": "invoice",
* "document_id": 1,
* "channel": "email",
* "email": "customer@example.com",
* "phone": "+971500000000",
* "message": "Please find your document."
* }
*/
"application/json": {
document_type?: string;
document_id?: number;
channel?: string;
email?: string;
phone?: string;
message?: string;
};
};
};
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
/**
* @example {
* "share_url": "https://example.com/share/abc",
* "whatsapp_url": "https://wa.me/971500000000?text=...",
* "expires_at": "2026-05-19T12:00:00+00:00"
* }
*/
"application/json": {
share_url?: string;
whatsapp_url?: string;
/** Format: date-time */
expires_at?: string;
};
};
};
};
};
delete?: never;
options?: never;
head?: never;
patch?: never;
trace?: never;
};
} }
export type webhooks = Record<string, never>; export type webhooks = Record<string, never>;
export interface components { export interface components {