Associate appointments with a service order
Links every appointment in appointment_ids to service_order in one transaction: either all are linked or none is. The service order is validated as in the appointment update (it must exist, not be cancelled, belong to the plate of each appointment and have a status that allows scheduling), otherwise 422 with errors.service_order. Unknown ids answer 422 with errors.appointment_ids. Appointments already linked to another service order answer 409 with errors.conflicts listing each of them with that order number and document number; one already linked to the requested order is left as it is. The service order takes the earliest reception and the latest delivery datetime of the appointments, reported in meta.service_order_dates_synced when any of them has one.
curl -X POST "https://og-tenant1.test:8003/api/v2/workshop/appointments/associate-service-order" \
-H "Content-Type: application/json" \
-d '{
"service_order": "string",
"appointment_ids": []
}'{
"data": {
"service_order": {
"number": 0,
"document_number": "string"
},
"appointment_ids": [
0
]
}
}{
"data": {
"code": "VALIDATION_FAILED",
"message": "The given data was invalid.",
"errors": {
"email": [
"The email field is required."
]
}
},
"meta": {
"trace_id": "9f86d081884c7d659a2feaa0c55ad01568f3a1c2b4d5e"
}
}{
"data": {
"code": "VALIDATION_FAILED",
"message": "The given data was invalid.",
"errors": {
"email": [
"The email field is required."
]
}
},
"meta": {
"trace_id": "9f86d081884c7d659a2feaa0c55ad01568f3a1c2b4d5e"
}
}{
"data": {
"code": "VALIDATION_FAILED",
"message": "The given data was invalid.",
"errors": {
"email": [
"The email field is required."
]
}
},
"meta": {
"trace_id": "9f86d081884c7d659a2feaa0c55ad01568f3a1c2b4d5e"
}
}{
"data": {
"code": "VALIDATION_FAILED",
"message": "The given data was invalid.",
"errors": {
"email": [
"The email field is required."
]
}
},
"meta": {
"trace_id": "9f86d081884c7d659a2feaa0c55ad01568f3a1c2b4d5e"
}
}