withToken((string) config('services.ladill_identity.key')) ->connectTimeout(10) ->timeout(20) ->acceptJson() ->asJson(); } protected function identitySend(string $method, string $path, array $payload): HttpResponse { try { return $this->identity()->send($method, $path, ['json' => $payload]); } catch (ConnectionException) { throw ValidationException::withMessages([ 'base' => ['Could not reach Ladill. Please try again in a moment.'], ]); } } /** Re-throw a 422 from the identity API as local validation errors. */ protected function rethrowValidation(HttpResponse $response, string $fallbackField = 'base'): void { if ($response->status() === 422) { throw ValidationException::withMessages( $response->json('errors') ?: [$fallbackField => [$response->json('message') ?: 'Request failed.']], ); } } }