Allow Care service API to issue tickets.
Deploy Ladill Queue / deploy (push) Has started running

Care needs POST /tickets on the service-auth stack so check-in and
department handoffs can create queue tickets without Sanctum.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-17 16:27:51 +00:00
co-authored by Cursor
parent 9edf573d39
commit 0275ec603d
3 changed files with 34 additions and 0 deletions
@@ -57,6 +57,7 @@ class TicketController extends Controller
'customer_email' => ['nullable', 'email', 'max:255'], 'customer_email' => ['nullable', 'email', 'max:255'],
'priority' => ['nullable', 'string', 'in:'.implode(',', array_keys(config('qms.ticket_priorities')))], 'priority' => ['nullable', 'string', 'in:'.implode(',', array_keys(config('qms.ticket_priorities')))],
'source' => ['nullable', 'string', 'in:'.implode(',', array_keys(config('qms.ticket_sources')))], 'source' => ['nullable', 'string', 'in:'.implode(',', array_keys(config('qms.ticket_sources')))],
'metadata' => ['nullable', 'array'],
]); ]);
$queue = ServiceQueue::where('uuid', $validated['service_queue_id'])->firstOrFail(); $queue = ServiceQueue::where('uuid', $validated['service_queue_id'])->firstOrFail();
@@ -66,6 +67,7 @@ class TicketController extends Controller
...$validated, ...$validated,
'source' => $validated['source'] ?? 'api', 'source' => $validated['source'] ?? 'api',
'actor_ref' => $owner, 'actor_ref' => $owner,
'metadata' => $validated['metadata'] ?? null,
]); ]);
return response()->json(['data' => TicketPresenter::toArray($ticket)], 201); return response()->json(['data' => TicketPresenter::toArray($ticket)], 201);
+1
View File
@@ -81,6 +81,7 @@ Route::middleware(['auth.service:qms', 'qms.integration'])->prefix('v1')->group(
Route::post('/queues/{serviceQueue}/call-next', [TicketController::class, 'callNext'])->name('api.service.queues.call-next'); Route::post('/queues/{serviceQueue}/call-next', [TicketController::class, 'callNext'])->name('api.service.queues.call-next');
Route::get('/tickets', [TicketController::class, 'index'])->name('api.service.tickets.index'); Route::get('/tickets', [TicketController::class, 'index'])->name('api.service.tickets.index');
Route::post('/tickets', [TicketController::class, 'store'])->name('api.service.tickets.store');
Route::post('/tickets/{ticket}/action', [TicketController::class, 'action'])->name('api.service.tickets.action'); Route::post('/tickets/{ticket}/action', [TicketController::class, 'action'])->name('api.service.tickets.action');
Route::get('/counters', [CounterController::class, 'index'])->name('api.service.counters.index'); Route::get('/counters', [CounterController::class, 'index'])->name('api.service.counters.index');
+31
View File
@@ -208,4 +208,35 @@ class CareIntegrationTest extends TestCase
$this->assertSame(1, Branch::owned($owner)->count()); $this->assertSame(1, Branch::owned($owner)->count());
} }
public function test_care_can_issue_ticket_via_service_api(): void
{
$owner = 'care-owner-uuid';
$headers = $this->careHeaders($owner);
$this->provisionCareOrg($owner);
$queueUuid = $this->postJson('/api/v1/queues', [
'owner' => $owner,
'name' => 'Consultation',
'prefix' => 'C',
'branch_name' => 'Main',
'external_key' => 'care:dept:consultation:queue:1',
'strategy' => 'fifo',
], $headers)->assertCreated()->json('data.uuid');
$this->postJson('/api/v1/tickets', [
'owner' => $owner,
'service_queue_id' => $queueUuid,
'customer_name' => 'Ada Patient',
'source' => 'appointment',
'metadata' => [
'care_entity' => 'appointment',
'care_entity_id' => 42,
],
], $headers)
->assertCreated()
->assertJsonPath('data.ticket_number', 'C001')
->assertJsonPath('data.status', 'waiting')
->assertJsonPath('data.customer_name', 'Ada Patient');
}
} }