📚 Vehicle Inspection API Documentation
🎯 Новая структура данных
Ключевое изменение: Каждая машина имеет индивидуальные параметры (service, appointment, location), но один инспектор на весь ордер.
Структура данных:
Order ├── inspector_id (один на весь ордер) └── vehicles[] ├── vehicle 1 │ ├── service │ ├── appointment (date, time) │ └── location ├── vehicle 2 │ ├── service │ ├── appointment (date, time) │ └── location └── ...
- 🚗 Создание Vehicle Inspection Order
Endpoint
POST /bx_block_order_management/orders/create_vehicle_inspection
Headers
Content-Type: application/json token: YOUR_AUTH_TOKEN
Вариант 1: Одна машина (Single Vehicle)
curl -X POST "http://localhost:3000/bx_block_order_management/orders/create_vehicle_inspection"
-H "Content-Type: application/json"
-H "token: YOUR_AUTH_TOKEN"
-d '{
"inspector_id": 123,
"vehicle_type": "single_vehicle",
"vehicle_detail": {
"make_id": 1,
"model_id": 5,
"year": "2020",
"vin": "1HGBH41JXMN109186",
"mileage": "50000",
"link_to_car": "https://example.com/car",
"notes": "Car in good condition",
"user_service_id": 10,
"delivery_address_id": 25,
"appointment_date": "2025-10-15",
"appointment_time": "14:00"
}
}'
Вариант 2: Несколько машин (Multiple Vehicles)
curl -X POST "http://localhost:3000/bx_block_order_management/orders/create_vehicle_inspection"
-H "Content-Type: application/json"
-H "token: YOUR_AUTH_TOKEN"
-d '{
"inspector_id": 123,
"vehicle_type": "multiple_vehicle",
"vehicles": [
{
"make_id": 1,
"model_id": 5,
"year": "2020",
"vin": "VIN123456",
"mileage": "50000",
"notes": "Toyota Camry - first car",
"user_service_id": 10,
"delivery_address_id": 25,
"appointment_date": "2025-10-15",
"appointment_time": "14:00"
},
{
"make_id": 2,
"model_id": 8,
"year": "2021",
"vin": "VIN789012",
"mileage": "30000",
"notes": "Honda Civic - second car",
"user_service_id": 11,
"delivery_address_id": 26,
"appointment_date": "2025-10-16",
"appointment_time": "10:00"
},
{
"make_id": 3,
"model_id": 12,
"year": "2022",
"vin": "VIN345678",
"mileage": "15000",
"notes": "Tesla Model 3 - third car",
"user_service_id": 12,
"delivery_address_id": 25,
"appointment_date": "2025-10-17",
"appointment_time": "09:00"
}
]
}'
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| inspector_id | integer | ✅ Yes | ID инспектора для всех машин |
| vehicle_type | string | ✅ Yes | "single_vehicle" или "multiple_vehicle" |
| vehicle_detail | object | ✅ (single) | Данные для одной машины |
| vehicles | array | ✅ (multiple) | Массив машин |
Vehicle Object Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| make_id | integer | ✅ Yes | ID производителя |
| model_id | integer | ✅ Yes | ID модели |
| year | string/integer | ✅ Yes | Год выпуска |
| vin | string | ❌ No | VIN номер |
| mileage | string/integer | ❌ No | Пробег |
| link_to_car | string | ❌ No | Ссылка на объявление |
| notes | string | ❌ No | Заметки |
| user_service_id | integer | ❌ No | ID сервиса для этой машины |
| delivery_address_id | integer | ❌ No | ID адреса для этой машины |
| appointment_date | string | ❌ No | Дата инспекции (YYYY-MM-DD) |
| appointment_time | string | ❌ No | Время инспекции (HH:MM) |
Response
{ "id": 456, "message": "Vehicle inspection created successfully", "vehicle_type": "multiple_vehicle", "vehicles_count": 3, "vehicle_details": [ { "id": 789, "make": "Toyota", "model": "Camry", "year": "2020", "vin": "VIN123456", "mileage": "50000", "notes": "Toyota Camry - first car", "link_to_car": null, "photos": [] }, { "id": 790, "make": "Honda", "model": "Civic", "year": "2021", "vin": "VIN789012", "mileage": "30000", "notes": "Honda Civic - second car", "link_to_car": null, "photos": [] }, { "id": 791, "make": "Tesla", "model": "Model 3", "year": "2022", "vin": "VIN345678", "mileage": "15000", "notes": "Tesla Model 3 - third car", "link_to_car": null, "photos": [] } ] }
- 👤 Назначение инспектора с индивидуальными параметрами
Endpoint
PATCH /bx_block_order_management/orders/:order_id/assign_inspector
Request
curl -X PATCH "http://localhost:3000/bx_block_order_management/orders/456/assign_inspector"
-H "Content-Type: application/json"
-H "token: YOUR_AUTH_TOKEN"
-d '{
"inspector_id": 123,
"vehicles": [
{
"vehicle_detail_id": 789,
"user_service_id": 10,
"delivery_address_id": 25,
"appointment_date": "2025-10-15",
"appointment_time": "14:00"
},
{
"vehicle_detail_id": 790,
"user_service_id": 11,
"delivery_address_id": 26,
"appointment_date": "2025-10-16",
"appointment_time": "10:00"
},
{
"vehicle_detail_id": 791,
"user_service_id": 12,
"delivery_address_id": 25,
"appointment_date": "2025-10-17",
"appointment_time": "09:00"
}
]
}'
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| inspector_id | integer | ✅ Yes | ID инспектора |
| vehicles | array | ✅ Yes | Массив с данными для каждого vehicle |
| vehicles[].vehicle_detail_id | integer | ✅ Yes | ID vehicle_detail из созданного ордера |
| vehicles[].user_service_id | integer | ✅ Yes | ID сервиса для этой машины |
| vehicles[].delivery_address_id | integer | ❌ No | ID адреса для этой машины |
| vehicles[].appointment_date | string | ❌ No | Дата инспекции (YYYY-MM-DD) |
| vehicles[].appointment_time | string | ❌ No | Время инспекции (HH:MM) |
Response
{ "message": "Inspector assigned successfully", "order": { "id": 456, "order_number": "OD00000456", "status": "appointment_scheduled", "vehicle_type": "multiple_vehicle", "inspector": { "id": 123, "name": "John Inspector", "email": "[email protected]", "phone": "+1234567890", "city": "New York" }, "vehicles": [ { "id": 789, "make": "Toyota", "model": "Camry", "year": "2020", "vin": "VIN123456", "mileage": "50000", "service": { "id": 10, "name": "basic", "description": "Basic inspection", "price": 100.0, "currency": "dollar" }, "appointment": { "date": "2025-10-15", "time": "14:00", "scheduled_at": "2025-10-15T14:00:00Z" }, "location": "123 Main St, New York, NY 10001" }, { "id": 790, "make": "Honda", "model": "Civic", "year": "2021", "vin": "VIN789012", "mileage": "30000", "service": { "id": 11, "name": "premium", "description": "Premium inspection", "price": 200.0, "currency": "dollar" }, "appointment": { "date": "2025-10-16", "time": "10:00", "scheduled_at": "2025-10-16T10:00:00Z" }, "location": "456 Oak Ave, Brooklyn, NY 11201" } ], "created_at": "2025-10-04T10:00:00Z", "updated_at": "2025-10-04T10:05:00Z" } }
- 📋 Получение деталей ордера
Endpoint
GET /bx_block_order_management/orders/:id
Request
curl -X GET "http://localhost:3000/bx_block_order_management/orders/456"
-H "token: YOUR_AUTH_TOKEN"
Response
{ "order_id": 456, "order_number": "OD00000456", "date": "2025-10-04", "price": 0.0, "status": "appointment_scheduled", "vehicle_type": "multiple_vehicle", "inspector": { "id": 123, "name": "John Inspector", "email": "[email protected]", "phone": "+1234567890", "city": "New York", "experience": "5 years", "profile_picture": "https://cdn.example.com/profile.jpg" }, "vehicles": [ { "id": 789, "make": "Toyota", "model": "Camry", "year": "2020", "vin": "VIN123456", "mileage": "50000", "notes": "Toyota Camry - first car", "link_to_car": null, "photos": [ "https://cdn.example.com/photo1.jpg", "https://cdn.example.com/photo2.jpg" ], "service": { "id": 10, "name": "basic", "description": "Basic inspection service", "price": 100.0, "currency": "dollar" }, "appointment": { "date": "2025-10-15", "time": "14:00", "scheduled_at": "2025-10-15T14:00:00Z" }, "location": "123 Main St, New York, NY 10001" }, { "id": 790, "make": "Honda", "model": "Civic", "year": "2021", "vin": "VIN789012", "mileage": "30000", "notes": "Honda Civic - second car", "link_to_car": null, "photos": [], "service": { "id": 11, "name": "premium", "description": "Premium inspection with detailed report", "price": 200.0, "currency": "dollar" }, "appointment": { "date": "2025-10-16", "time": "10:00", "scheduled_at": "2025-10-16T10:00:00Z" }, "location": "456 Oak Ave, Brooklyn, NY 11201" } ] }
- 📝 Список ордеров клиента
Endpoint
GET /bx_block_order_management/orders
Request
curl -X GET "http://localhost:3000/bx_block_order_management/orders?page=1&per_page=20&status=Confirmed"
-H "token: YOUR_AUTH_TOKEN"
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| page | integer | 1 | Номер страницы |
| per_page | integer | 20 | Количество на странице (max: 100) |
| status | string | - | Фильтр: Pending, Confirmed, In progress, Completed, All |
| sort_by | string | created_at | Поле сортировки: created_at, status |
| sort_order | string | desc | Порядок: asc, desc |
Response
{ "data": [ { "id": "456", "type": "order", "attributes": { "order_number": "OD00000456", "status": "appointment_scheduled", "vehicle_type": "multiple_vehicle", "total": 0.0, "created_at": "2025-10-04T10:00:00Z", "inspector": { "id": 123, "first_name": "John", "last_name": "Inspector", "email": "[email protected]", "phone": "+1234567890", "city": "New York", "experience": "5 years", "profile_picture": "https://..." }, "vehicles": [ { "id": 789, "make": "Toyota", "model": "Camry", "year": "2020", "vin": "VIN123456", "mileage": "50000", "notes": "Toyota Camry - first car", "link_to_car": null, "photos": [], "service": { "id": 10, "name": "basic", "description": "Basic inspection", "price": 100.0, "currency": "dollar" }, "appointment": { "date": "2025-10-15", "time": "14:00", "scheduled_at": "2025-10-15T14:00:00Z" }, "location": "123 Main St, New York" }, { "id": 790, "make": "Honda", "model": "Civic", "year": "2021", "vin": "VIN789012", "mileage": "30000", "service": { "id": 11, "name": "premium", "price": 200.0 }, "appointment": { "date": "2025-10-16", "time": "10:00" }, "location": "456 Oak Ave, Brooklyn" } ] } } ], "meta": { "total": 50, "page": 1, "per_page": 20, "total_pages": 3 } }
- 🔍 Ордера инспектора
Endpoint
GET /bx_block_order_management/orders/inspector_orders
Request
curl -X GET "http://localhost:3000/bx_block_order_management/orders/inspector_orders?page=1&per_page=20"
-H "token: INSPECTOR_AUTH_TOKEN"
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
| page | integer | 1 | Номер страницы |
| per_page | integer | 20 | Количество на странице (max: 100) |
| status | string | - | Фильтр по статусу |
| sort_by | string | created_at | Сортировка: created_at, status |
| sort_order | string | desc | Порядок: asc, desc |
Response
Аналогичен списку ордеров клиента, но возвращает только ордера назначенные этому инспектору.
💡 Примеры использования
Сценарий 1: Создать ордер с несколькими машинами за один раз
curl -X POST "http://localhost:3000/bx_block_order_management/orders/create_vehicle_inspection"
-H "Content-Type: application/json"
-H "token: $CLIENT_TOKEN"
-d '{
"inspector_id": 123,
"vehicle_type": "multiple_vehicle",
"vehicles": [
{
"make_id": 1, "model_id": 5, "year": "2020", "vin": "VIN1",
"user_service_id": 10,
"appointment_date": "2025-10-15",
"appointment_time": "14:00",
"delivery_address_id": 25
},
{
"make_id": 2, "model_id": 8, "year": "2021", "vin": "VIN2",
"user_service_id": 11,
"appointment_date": "2025-10-16",
"appointment_time": "10:00",
"delivery_address_id": 26
},
{
"make_id": 3, "model_id": 12, "year": "2022", "vin": "VIN3",
"user_service_id": 12,
"appointment_date": "2025-10-17",
"appointment_time": "09:00",
"delivery_address_id": 25
}
]
}'
Сценарий 2: Создать ордер и назначить параметры позже
ORDER_RESPONSE=$(curl -s -X POST "http://localhost:3000/bx_block_order_management/orders/create_vehicle_inspection"
-H "Content-Type: application/json"
-H "token: $CLIENT_TOKEN"
-d '{
"inspector_id": 123,
"vehicle_type": "multiple_vehicle",
"vehicles": [
{"make_id": 1, "model_id": 5, "year": "2020", "vin": "VIN1"},
{"make_id": 2, "model_id": 8, "year": "2021", "vin": "VIN2"}
]
}')
ORDER_ID=$(echo
curl -X PATCH "http://localhost:3000/bx_block_order_management/orders/$ORDER_ID/assign_inspector"
-H "Content-Type: application/json"
-H "token: $CLIENT_TOKEN"
-d "{
"inspector_id": 123,
"vehicles": [
{
"vehicle_detail_id": $VEHICLE_1_ID,
"user_service_id": 10,
"appointment_date": "2025-10-15",
"appointment_time": "14:00",
"delivery_address_id": 25
},
{
"vehicle_detail_id": $VEHICLE_2_ID,
"user_service_id": 11,
"appointment_date": "2025-10-16",
"appointment_time": "10:00",
"delivery_address_id": 26
}
]
}"
- Один инспектор на ордер: Все машины в одном ордере используют одного инспектора
- Индивидуальные параметры: Каждая машина имеет свой service, appointment, location
- Формат времени: appointment_time должен быть в формате HH:MM (например, 14:30)
- Booking slots: При назначении appointment автоматически бронируется слот у инспектора
- Массив vehicles: Всегда используйте массив vehicles[] для доступа к данным каждой машины
📊 Статусы ордеров
| Status | Description |
|---|---|
| created | Ордер создан |
| appointment_scheduled | Назначен appointment |
| confirmed | Подтвержден |
| inspection_in_progress | Инспекция в процессе |
| inspection_completed | Инспекция завершена |
| cancelled | Отменен |