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' => 'visitor', ])); $response->throw(); return (array) ($response->json('data') ?? []); } 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.frontdesk', 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 */ public function consoleAction(string $owner, string $counterUuid, array $payload): void { $this->http($owner)->post($this->base().'/counters/'.$counterUuid.'/console', $payload)->throw(); } }