token()) ->acceptJson() ->timeout(12) ->withQueryParameters(['owner' => $owner]); } public function configured(): bool { return $this->token() !== '' && $this->base() !== ''; } /** * @return array */ public function status(string $owner): array { $response = $this->http($owner)->get($this->base().'/integrations/status'); $response->throw(); return (array) ($response->json('data') ?? []); } /** * @return array */ public function enable(string $owner, string $organizationName, ?string $branchName = null): array { $response = $this->http($owner)->post($this->base().'/integrations/provision', array_filter([ 'organization_name' => $organizationName, 'branch_name' => $branchName, 'industry' => 'healthcare', ])); $response->throw(); return (array) ($response->json('data') ?? []); } public function disable(string $owner): void { // Local Care setting only; Queue must be disabled separately in Queue settings. } public function isLinked(string $owner): bool { if (! $this->configured()) { return false; } try { $status = $this->status($owner); return (bool) ($status['provisioned'] ?? false) && (bool) data_get($status, 'integrations.care', false); } catch (RequestException) { return false; } } /** * @return list> */ public function counters(string $owner): array { $response = $this->http($owner)->get($this->base().'/counters'); $response->throw(); return (array) ($response->json('data') ?? []); } /** * @return array */ public function console(string $owner, string $counterUuid): array { $response = $this->http($owner)->get($this->base().'/counters/'.$counterUuid.'/console'); $response->throw(); return (array) ($response->json('data') ?? []); } /** * @param array $payload * @return array */ public function consoleAction(string $owner, string $counterUuid, array $payload): array { $response = $this->http($owner)->post($this->base().'/counters/'.$counterUuid.'/console', $payload); $response->throw(); return (array) ($response->json('data') ?? []); } }