From 5bb02f641423df3a0aa5a479dc6bf41e12a1c1c2 Mon Sep 17 00:00:00 2001 From: Andrii Balitskyi <10balian10@gmail.com> Date: Fri, 4 Apr 2025 14:32:52 +0200 Subject: [PATCH 1/6] Add ->createPaginator --- .github/workflows/generate.yml | 4 +- src/Paginator.php | 89 + src/SeamClient.php | 5808 +++++++++++++++----------------- tests/DevicesTest.php | 11 - tests/PaginatorTest.php | 78 + 5 files changed, 2965 insertions(+), 3025 deletions(-) create mode 100644 src/Paginator.php create mode 100644 tests/PaginatorTest.php diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 98269747..e8653dcd 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -3,8 +3,8 @@ name: Generate on: push: - branches-ignore: - - main + branches: + - 'no-branch-will-match-this-pattern' workflow_dispatch: {} jobs: diff --git a/src/Paginator.php b/src/Paginator.php new file mode 100644 index 00000000..696a704a --- /dev/null +++ b/src/Paginator.php @@ -0,0 +1,89 @@ +callable = $callable; + $this->params = $params; + } + + public function firstPage(): array + { + $callable = $this->callable; + $params = $this->params; + + $params["on_response"] = fn($response) => $this->cachePagination( + $response, + self::FIRST_PAGE + ); + + $data = $callable($params); + + return [$data, $this->pagination_cache[self::FIRST_PAGE]]; + } + + public function nextPage(string $nextPageCursor): array + { + $callable = $this->callable; + $params = $this->params; + + $params["page_cursor"] = $nextPageCursor; + $params["on_response"] = fn($response) => $this->cachePagination( + $response, + $nextPageCursor + ); + + $data = $callable($params); + + return [$data, $this->pagination_cache[$nextPageCursor]]; + } + + private function cachePagination($response, $nextPageCursor) + { + $this->pagination_cache[$nextPageCursor] = $response->pagination; + } + + public function flattenToArray(): array + { + $items = []; + + [$response, $pagination] = $this->firstPage(); + $items = array_merge($items, $response); + + while ($pagination->has_next_page) { + [$response, $pagination] = $this->nextPage( + $pagination->next_page_cursor + ); + $items = array_merge($items, $response); + } + + return $items; + } + + public function flatten() + { + [$current, $pagination] = $this->firstPage(); + + foreach ($current as $item) { + yield $item; + } + + while ($pagination->has_next_page) { + [$current, $pagination] = $this->nextPage( + $pagination->next_page_cursor + ); + + foreach ($current as $item) { + yield $item; + } + } + } +} diff --git a/src/SeamClient.php b/src/SeamClient.php index 3af13b56..eadf7bfc 100644 --- a/src/SeamClient.php +++ b/src/SeamClient.php @@ -105,13 +105,13 @@ public function __construct( $this->workspaces = new WorkspacesClient($this); } - public function request( - $method, - $path, - $json = null, - $query = null, - $inner_object = null - ) { + public function createPaginator($callable, $params = []) + { + return new Paginator($callable, $params); + } + + public function request($method, $path, $json = null, $query = null) + { $options = [ "json" => $json, "query" => $query, @@ -156,7 +156,7 @@ public function request( ); } - return $inner_object ? $res_json->$inner_object : $res_json; + return $res_json; } } @@ -174,52 +174,79 @@ public function __construct(SeamClient $seam) public function create( string $device_id, - bool $allow_external_modification = null, - bool $attempt_for_offline_device = null, - string $code = null, - string $common_code_key = null, - string $ends_at = null, - bool $is_external_modification_allowed = null, - bool $is_offline_access_code = null, - bool $is_one_time_use = null, - string $max_time_rounding = null, - string $name = null, - bool $prefer_native_scheduling = null, - float $preferred_code_length = null, - string $starts_at = null, - bool $sync = null, - bool $use_backup_access_code_pool = null, - bool $use_offline_access_code = null + ?string $name = null, + ?string $starts_at = null, + ?string $ends_at = null, + ?string $code = null, + ?bool $sync = null, + ?bool $attempt_for_offline_device = null, + ?string $common_code_key = null, + ?bool $prefer_native_scheduling = null, + ?bool $use_backup_access_code_pool = null, + ?bool $allow_external_modification = null, + ?bool $is_external_modification_allowed = null, + ?float $preferred_code_length = null, + ?bool $use_offline_access_code = null, + ?bool $is_offline_access_code = null, + ?bool $is_one_time_use = null, + ?string $max_time_rounding = null ): AccessCode { $request_payload = []; if ($device_id !== null) { $request_payload["device_id"] = $device_id; } - if ($allow_external_modification !== null) { - $request_payload[ - "allow_external_modification" - ] = $allow_external_modification; + if ($name !== null) { + $request_payload["name"] = $name; + } + if ($starts_at !== null) { + $request_payload["starts_at"] = $starts_at; + } + if ($ends_at !== null) { + $request_payload["ends_at"] = $ends_at; + } + if ($code !== null) { + $request_payload["code"] = $code; + } + if ($sync !== null) { + $request_payload["sync"] = $sync; } if ($attempt_for_offline_device !== null) { $request_payload[ "attempt_for_offline_device" ] = $attempt_for_offline_device; } - if ($code !== null) { - $request_payload["code"] = $code; - } if ($common_code_key !== null) { $request_payload["common_code_key"] = $common_code_key; } - if ($ends_at !== null) { - $request_payload["ends_at"] = $ends_at; + if ($prefer_native_scheduling !== null) { + $request_payload[ + "prefer_native_scheduling" + ] = $prefer_native_scheduling; + } + if ($use_backup_access_code_pool !== null) { + $request_payload[ + "use_backup_access_code_pool" + ] = $use_backup_access_code_pool; + } + if ($allow_external_modification !== null) { + $request_payload[ + "allow_external_modification" + ] = $allow_external_modification; } if ($is_external_modification_allowed !== null) { $request_payload[ "is_external_modification_allowed" ] = $is_external_modification_allowed; } + if ($preferred_code_length !== null) { + $request_payload["preferred_code_length"] = $preferred_code_length; + } + if ($use_offline_access_code !== null) { + $request_payload[ + "use_offline_access_code" + ] = $use_offline_access_code; + } if ($is_offline_access_code !== null) { $request_payload[ "is_offline_access_code" @@ -231,143 +258,117 @@ public function create( if ($max_time_rounding !== null) { $request_payload["max_time_rounding"] = $max_time_rounding; } - if ($name !== null) { - $request_payload["name"] = $name; - } - if ($prefer_native_scheduling !== null) { - $request_payload[ - "prefer_native_scheduling" - ] = $prefer_native_scheduling; - } - if ($preferred_code_length !== null) { - $request_payload["preferred_code_length"] = $preferred_code_length; - } - if ($starts_at !== null) { - $request_payload["starts_at"] = $starts_at; - } - if ($sync !== null) { - $request_payload["sync"] = $sync; - } - if ($use_backup_access_code_pool !== null) { - $request_payload[ - "use_backup_access_code_pool" - ] = $use_backup_access_code_pool; - } - if ($use_offline_access_code !== null) { - $request_payload[ - "use_offline_access_code" - ] = $use_offline_access_code; - } $res = $this->seam->request( "POST", "/access_codes/create", - json: (object) $request_payload, - inner_object: "access_code" + json: (object) $request_payload ); - return AccessCode::from_json($res); + return AccessCode::from_json($res->access_code); } public function create_multiple( array $device_ids, - bool $allow_external_modification = null, - bool $attempt_for_offline_device = null, - string $behavior_when_code_cannot_be_shared = null, - string $code = null, - string $ends_at = null, - bool $is_external_modification_allowed = null, - bool $is_offline_access_code = null, - bool $is_one_time_use = null, - string $max_time_rounding = null, - string $name = null, - bool $prefer_native_scheduling = null, - float $preferred_code_length = null, - string $starts_at = null, - bool $use_backup_access_code_pool = null, - bool $use_offline_access_code = null + ?string $behavior_when_code_cannot_be_shared = null, + ?float $preferred_code_length = null, + ?string $name = null, + ?string $starts_at = null, + ?string $ends_at = null, + ?string $code = null, + ?bool $attempt_for_offline_device = null, + ?bool $prefer_native_scheduling = null, + ?bool $use_backup_access_code_pool = null, + ?bool $allow_external_modification = null, + ?bool $is_external_modification_allowed = null, + ?bool $use_offline_access_code = null, + ?bool $is_offline_access_code = null, + ?bool $is_one_time_use = null, + ?string $max_time_rounding = null ): array { $request_payload = []; if ($device_ids !== null) { $request_payload["device_ids"] = $device_ids; } - if ($allow_external_modification !== null) { - $request_payload[ - "allow_external_modification" - ] = $allow_external_modification; - } - if ($attempt_for_offline_device !== null) { - $request_payload[ - "attempt_for_offline_device" - ] = $attempt_for_offline_device; - } if ($behavior_when_code_cannot_be_shared !== null) { $request_payload[ "behavior_when_code_cannot_be_shared" ] = $behavior_when_code_cannot_be_shared; } - if ($code !== null) { - $request_payload["code"] = $code; + if ($preferred_code_length !== null) { + $request_payload["preferred_code_length"] = $preferred_code_length; + } + if ($name !== null) { + $request_payload["name"] = $name; + } + if ($starts_at !== null) { + $request_payload["starts_at"] = $starts_at; } if ($ends_at !== null) { $request_payload["ends_at"] = $ends_at; } - if ($is_external_modification_allowed !== null) { - $request_payload[ - "is_external_modification_allowed" - ] = $is_external_modification_allowed; + if ($code !== null) { + $request_payload["code"] = $code; } - if ($is_offline_access_code !== null) { + if ($attempt_for_offline_device !== null) { $request_payload[ - "is_offline_access_code" - ] = $is_offline_access_code; - } - if ($is_one_time_use !== null) { - $request_payload["is_one_time_use"] = $is_one_time_use; - } - if ($max_time_rounding !== null) { - $request_payload["max_time_rounding"] = $max_time_rounding; - } - if ($name !== null) { - $request_payload["name"] = $name; + "attempt_for_offline_device" + ] = $attempt_for_offline_device; } if ($prefer_native_scheduling !== null) { $request_payload[ "prefer_native_scheduling" ] = $prefer_native_scheduling; } - if ($preferred_code_length !== null) { - $request_payload["preferred_code_length"] = $preferred_code_length; - } - if ($starts_at !== null) { - $request_payload["starts_at"] = $starts_at; - } if ($use_backup_access_code_pool !== null) { $request_payload[ "use_backup_access_code_pool" ] = $use_backup_access_code_pool; } + if ($allow_external_modification !== null) { + $request_payload[ + "allow_external_modification" + ] = $allow_external_modification; + } + if ($is_external_modification_allowed !== null) { + $request_payload[ + "is_external_modification_allowed" + ] = $is_external_modification_allowed; + } if ($use_offline_access_code !== null) { $request_payload[ "use_offline_access_code" ] = $use_offline_access_code; } + if ($is_offline_access_code !== null) { + $request_payload[ + "is_offline_access_code" + ] = $is_offline_access_code; + } + if ($is_one_time_use !== null) { + $request_payload["is_one_time_use"] = $is_one_time_use; + } + if ($max_time_rounding !== null) { + $request_payload["max_time_rounding"] = $max_time_rounding; + } $res = $this->seam->request( "POST", "/access_codes/create_multiple", - json: (object) $request_payload, - inner_object: "access_codes" + json: (object) $request_payload ); - return array_map(fn($r) => AccessCode::from_json($r), $res); + return array_map( + fn($r) => AccessCode::from_json($r), + $res->access_codes + ); } public function delete( string $access_code_id, - string $device_id = null, - bool $sync = null + ?string $device_id = null, + ?bool $sync = null ): void { $request_payload = []; @@ -399,53 +400,52 @@ public function generate_code(string $device_id): AccessCode $res = $this->seam->request( "POST", "/access_codes/generate_code", - json: (object) $request_payload, - inner_object: "generated_code" + json: (object) $request_payload ); - return AccessCode::from_json($res); + return AccessCode::from_json($res->generated_code); } public function get( - string $access_code_id = null, - string $code = null, - string $device_id = null + ?string $device_id = null, + ?string $access_code_id = null, + ?string $code = null ): AccessCode { $request_payload = []; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } if ($access_code_id !== null) { $request_payload["access_code_id"] = $access_code_id; } if ($code !== null) { $request_payload["code"] = $code; } - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } $res = $this->seam->request( "POST", "/access_codes/get", - json: (object) $request_payload, - inner_object: "access_code" + json: (object) $request_payload ); - return AccessCode::from_json($res); + return AccessCode::from_json($res->access_code); } public function list( - array $access_code_ids = null, - string $device_id = null, - string $user_identifier_key = null + ?string $device_id = null, + ?array $access_code_ids = null, + ?string $user_identifier_key = null, + ?callable $on_response = null ): array { $request_payload = []; - if ($access_code_ids !== null) { - $request_payload["access_code_ids"] = $access_code_ids; - } if ($device_id !== null) { $request_payload["device_id"] = $device_id; } + if ($access_code_ids !== null) { + $request_payload["access_code_ids"] = $access_code_ids; + } if ($user_identifier_key !== null) { $request_payload["user_identifier_key"] = $user_identifier_key; } @@ -453,11 +453,17 @@ public function list( $res = $this->seam->request( "POST", "/access_codes/list", - json: (object) $request_payload, - inner_object: "access_codes" + json: (object) $request_payload ); - return array_map(fn($r) => AccessCode::from_json($r), $res); + if ($on_response !== null) { + $on_response($res); + } + + return array_map( + fn($r) => AccessCode::from_json($r), + $res->access_codes + ); } public function pull_backup_access_code(string $access_code_id): AccessCode @@ -471,65 +477,85 @@ public function pull_backup_access_code(string $access_code_id): AccessCode $res = $this->seam->request( "POST", "/access_codes/pull_backup_access_code", - json: (object) $request_payload, - inner_object: "access_code" + json: (object) $request_payload ); - return AccessCode::from_json($res); + return AccessCode::from_json($res->access_code); } public function update( string $access_code_id, - bool $allow_external_modification = null, - bool $attempt_for_offline_device = null, - string $code = null, - string $device_id = null, - string $ends_at = null, - bool $is_external_modification_allowed = null, - bool $is_managed = null, - bool $is_offline_access_code = null, - bool $is_one_time_use = null, - string $max_time_rounding = null, - string $name = null, - bool $prefer_native_scheduling = null, - float $preferred_code_length = null, - string $starts_at = null, - bool $sync = null, - string $type = null, - bool $use_backup_access_code_pool = null, - bool $use_offline_access_code = null + ?string $name = null, + ?string $starts_at = null, + ?string $ends_at = null, + ?string $code = null, + ?bool $sync = null, + ?bool $attempt_for_offline_device = null, + ?bool $prefer_native_scheduling = null, + ?bool $use_backup_access_code_pool = null, + ?bool $allow_external_modification = null, + ?bool $is_external_modification_allowed = null, + ?float $preferred_code_length = null, + ?bool $use_offline_access_code = null, + ?bool $is_offline_access_code = null, + ?bool $is_one_time_use = null, + ?string $max_time_rounding = null, + ?string $device_id = null, + ?string $type = null, + ?bool $is_managed = null ): void { $request_payload = []; if ($access_code_id !== null) { $request_payload["access_code_id"] = $access_code_id; } - if ($allow_external_modification !== null) { - $request_payload[ - "allow_external_modification" - ] = $allow_external_modification; + if ($name !== null) { + $request_payload["name"] = $name; + } + if ($starts_at !== null) { + $request_payload["starts_at"] = $starts_at; + } + if ($ends_at !== null) { + $request_payload["ends_at"] = $ends_at; + } + if ($code !== null) { + $request_payload["code"] = $code; + } + if ($sync !== null) { + $request_payload["sync"] = $sync; } if ($attempt_for_offline_device !== null) { $request_payload[ "attempt_for_offline_device" ] = $attempt_for_offline_device; } - if ($code !== null) { - $request_payload["code"] = $code; + if ($prefer_native_scheduling !== null) { + $request_payload[ + "prefer_native_scheduling" + ] = $prefer_native_scheduling; } - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($use_backup_access_code_pool !== null) { + $request_payload[ + "use_backup_access_code_pool" + ] = $use_backup_access_code_pool; } - if ($ends_at !== null) { - $request_payload["ends_at"] = $ends_at; + if ($allow_external_modification !== null) { + $request_payload[ + "allow_external_modification" + ] = $allow_external_modification; } if ($is_external_modification_allowed !== null) { $request_payload[ "is_external_modification_allowed" ] = $is_external_modification_allowed; } - if ($is_managed !== null) { - $request_payload["is_managed"] = $is_managed; + if ($preferred_code_length !== null) { + $request_payload["preferred_code_length"] = $preferred_code_length; + } + if ($use_offline_access_code !== null) { + $request_payload[ + "use_offline_access_code" + ] = $use_offline_access_code; } if ($is_offline_access_code !== null) { $request_payload[ @@ -542,35 +568,14 @@ public function update( if ($max_time_rounding !== null) { $request_payload["max_time_rounding"] = $max_time_rounding; } - if ($name !== null) { - $request_payload["name"] = $name; - } - if ($prefer_native_scheduling !== null) { - $request_payload[ - "prefer_native_scheduling" - ] = $prefer_native_scheduling; - } - if ($preferred_code_length !== null) { - $request_payload["preferred_code_length"] = $preferred_code_length; - } - if ($starts_at !== null) { - $request_payload["starts_at"] = $starts_at; - } - if ($sync !== null) { - $request_payload["sync"] = $sync; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } if ($type !== null) { $request_payload["type"] = $type; } - if ($use_backup_access_code_pool !== null) { - $request_payload[ - "use_backup_access_code_pool" - ] = $use_backup_access_code_pool; - } - if ($use_offline_access_code !== null) { - $request_payload[ - "use_offline_access_code" - ] = $use_offline_access_code; + if ($is_managed !== null) { + $request_payload["is_managed"] = $is_managed; } $this->seam->request( @@ -582,9 +587,9 @@ public function update( public function update_multiple( string $common_code_key, - string $ends_at = null, - string $name = null, - string $starts_at = null + ?string $ends_at = null, + ?string $starts_at = null, + ?string $name = null ): void { $request_payload = []; @@ -594,12 +599,12 @@ public function update_multiple( if ($ends_at !== null) { $request_payload["ends_at"] = $ends_at; } - if ($name !== null) { - $request_payload["name"] = $name; - } if ($starts_at !== null) { $request_payload["starts_at"] = $starts_at; } + if ($name !== null) { + $request_payload["name"] = $name; + } $this->seam->request( "POST", @@ -609,7 +614,7 @@ public function update_multiple( } } -class AccessCodesSimulateClient +class ActionAttemptsClient { private SeamClient $seam; @@ -618,35 +623,77 @@ public function __construct(SeamClient $seam) $this->seam = $seam; } - public function create_unmanaged_access_code( - string $code, - string $device_id, - string $name - ): UnmanagedAccessCode { + public function get(string $action_attempt_id): ActionAttempt + { $request_payload = []; - if ($code !== null) { - $request_payload["code"] = $code; - } - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($action_attempt_id !== null) { + $request_payload["action_attempt_id"] = $action_attempt_id; } - if ($name !== null) { - $request_payload["name"] = $name; + + $res = $this->seam->request( + "POST", + "/action_attempts/get", + json: (object) $request_payload + ); + + return ActionAttempt::from_json($res->action_attempt); + } + + public function list( + array $action_attempt_ids, + ?callable $on_response = null + ): array { + $request_payload = []; + + if ($action_attempt_ids !== null) { + $request_payload["action_attempt_ids"] = $action_attempt_ids; } $res = $this->seam->request( "POST", - "/access_codes/simulate/create_unmanaged_access_code", - json: (object) $request_payload, - inner_object: "access_code" + "/action_attempts/list", + json: (object) $request_payload + ); + + if ($on_response !== null) { + $on_response($res); + } + + return array_map( + fn($r) => ActionAttempt::from_json($r), + $res->action_attempts ); + } + public function poll_until_ready( + string $action_attempt_id, + float $timeout = 20.0 + ): ActionAttempt { + $seam = $this->seam; + $time_waiting = 0.0; + $polling_interval = 0.4; + $action_attempt = $seam->action_attempts->get($action_attempt_id); + + while ($action_attempt->status == "pending") { + $action_attempt = $seam->action_attempts->get( + $action_attempt->action_attempt_id + ); + if ($time_waiting > $timeout) { + throw new ActionAttemptTimeoutError($action_attempt, $timeout); + } + $time_waiting += $polling_interval; + usleep($polling_interval * 1000000); + } + + if ($action_attempt->status == "error") { + throw new ActionAttemptFailedError($action_attempt); + } - return UnmanagedAccessCode::from_json($res); + return $action_attempt; } } -class AccessCodesUnmanagedClient +class BridgesClient { private SeamClient $seam; @@ -655,95 +702,93 @@ public function __construct(SeamClient $seam) $this->seam = $seam; } - public function convert_to_managed( - string $access_code_id, - bool $allow_external_modification = null, - bool $force = null, - bool $is_external_modification_allowed = null, - bool $sync = null - ): void { + public function get(string $bridge_id): void + { $request_payload = []; - if ($access_code_id !== null) { - $request_payload["access_code_id"] = $access_code_id; - } - if ($allow_external_modification !== null) { - $request_payload[ - "allow_external_modification" - ] = $allow_external_modification; - } - if ($force !== null) { - $request_payload["force"] = $force; - } - if ($is_external_modification_allowed !== null) { - $request_payload[ - "is_external_modification_allowed" - ] = $is_external_modification_allowed; - } - if ($sync !== null) { - $request_payload["sync"] = $sync; + if ($bridge_id !== null) { + $request_payload["bridge_id"] = $bridge_id; } $this->seam->request( "POST", - "/access_codes/unmanaged/convert_to_managed", + "/bridges/get", json: (object) $request_payload ); } - public function delete(string $access_code_id, bool $sync = null): void + public function list(): void + { + $this->seam->request("POST", "/bridges/list"); + } +} + +class ClientSessionsClient +{ + private SeamClient $seam; + + public function __construct(SeamClient $seam) { + $this->seam = $seam; + } + + public function create( + ?string $user_identifier_key = null, + ?array $connect_webview_ids = null, + ?array $connected_account_ids = null, + ?array $user_identity_ids = null, + ?string $expires_at = null + ): ClientSession { $request_payload = []; - if ($access_code_id !== null) { - $request_payload["access_code_id"] = $access_code_id; + if ($user_identifier_key !== null) { + $request_payload["user_identifier_key"] = $user_identifier_key; } - if ($sync !== null) { - $request_payload["sync"] = $sync; + if ($connect_webview_ids !== null) { + $request_payload["connect_webview_ids"] = $connect_webview_ids; + } + if ($connected_account_ids !== null) { + $request_payload["connected_account_ids"] = $connected_account_ids; + } + if ($user_identity_ids !== null) { + $request_payload["user_identity_ids"] = $user_identity_ids; + } + if ($expires_at !== null) { + $request_payload["expires_at"] = $expires_at; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/access_codes/unmanaged/delete", + "/client_sessions/create", json: (object) $request_payload ); + + return ClientSession::from_json($res->client_session); } - public function get( - string $access_code_id = null, - string $code = null, - string $device_id = null - ): UnmanagedAccessCode { + public function delete(string $client_session_id): void + { $request_payload = []; - if ($access_code_id !== null) { - $request_payload["access_code_id"] = $access_code_id; - } - if ($code !== null) { - $request_payload["code"] = $code; - } - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($client_session_id !== null) { + $request_payload["client_session_id"] = $client_session_id; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/access_codes/unmanaged/get", - json: (object) $request_payload, - inner_object: "access_code" + "/client_sessions/delete", + json: (object) $request_payload ); - - return UnmanagedAccessCode::from_json($res); } - public function list( - string $device_id, - string $user_identifier_key = null - ): array { + public function get( + ?string $client_session_id = null, + ?string $user_identifier_key = null + ): ClientSession { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($client_session_id !== null) { + $request_payload["client_session_id"] = $client_session_id; } if ($user_identifier_key !== null) { $request_payload["user_identifier_key"] = $user_identifier_key; @@ -751,207 +796,268 @@ public function list( $res = $this->seam->request( "POST", - "/access_codes/unmanaged/list", - json: (object) $request_payload, - inner_object: "access_codes" + "/client_sessions/get", + json: (object) $request_payload ); - return array_map(fn($r) => UnmanagedAccessCode::from_json($r), $res); + return ClientSession::from_json($res->client_session); } - public function update( - string $access_code_id, - bool $is_managed, - bool $allow_external_modification = null, - bool $force = null, - bool $is_external_modification_allowed = null - ): void { + public function get_or_create( + ?string $user_identifier_key = null, + ?array $connect_webview_ids = null, + ?array $connected_account_ids = null, + ?array $user_identity_ids = null, + ?string $expires_at = null + ): ClientSession { $request_payload = []; - if ($access_code_id !== null) { - $request_payload["access_code_id"] = $access_code_id; + if ($user_identifier_key !== null) { + $request_payload["user_identifier_key"] = $user_identifier_key; } - if ($is_managed !== null) { - $request_payload["is_managed"] = $is_managed; + if ($connect_webview_ids !== null) { + $request_payload["connect_webview_ids"] = $connect_webview_ids; } - if ($allow_external_modification !== null) { - $request_payload[ - "allow_external_modification" - ] = $allow_external_modification; + if ($connected_account_ids !== null) { + $request_payload["connected_account_ids"] = $connected_account_ids; } - if ($force !== null) { - $request_payload["force"] = $force; + if ($user_identity_ids !== null) { + $request_payload["user_identity_ids"] = $user_identity_ids; } - if ($is_external_modification_allowed !== null) { - $request_payload[ - "is_external_modification_allowed" - ] = $is_external_modification_allowed; + if ($expires_at !== null) { + $request_payload["expires_at"] = $expires_at; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/access_codes/unmanaged/update", + "/client_sessions/get_or_create", json: (object) $request_payload ); - } -} - -class AcsAccessGroupsClient -{ - private SeamClient $seam; - public function __construct(SeamClient $seam) - { - $this->seam = $seam; + return ClientSession::from_json($res->client_session); } - public function add_user( - string $acs_access_group_id, - string $acs_user_id + public function grant_access( + ?string $client_session_id = null, + ?string $user_identifier_key = null, + ?array $connected_account_ids = null, + ?array $connect_webview_ids = null, + ?array $user_identity_ids = null ): void { $request_payload = []; - if ($acs_access_group_id !== null) { - $request_payload["acs_access_group_id"] = $acs_access_group_id; + if ($client_session_id !== null) { + $request_payload["client_session_id"] = $client_session_id; } - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($user_identifier_key !== null) { + $request_payload["user_identifier_key"] = $user_identifier_key; + } + if ($connected_account_ids !== null) { + $request_payload["connected_account_ids"] = $connected_account_ids; + } + if ($connect_webview_ids !== null) { + $request_payload["connect_webview_ids"] = $connect_webview_ids; + } + if ($user_identity_ids !== null) { + $request_payload["user_identity_ids"] = $user_identity_ids; } $this->seam->request( "POST", - "/acs/access_groups/add_user", + "/client_sessions/grant_access", json: (object) $request_payload ); } - public function get(string $acs_access_group_id): AcsAccessGroup - { + public function list( + ?string $client_session_id = null, + ?string $user_identifier_key = null, + ?string $connect_webview_id = null, + ?bool $without_user_identifier_key = null, + ?string $user_identity_id = null, + ?callable $on_response = null + ): array { $request_payload = []; - if ($acs_access_group_id !== null) { - $request_payload["acs_access_group_id"] = $acs_access_group_id; + if ($client_session_id !== null) { + $request_payload["client_session_id"] = $client_session_id; + } + if ($user_identifier_key !== null) { + $request_payload["user_identifier_key"] = $user_identifier_key; + } + if ($connect_webview_id !== null) { + $request_payload["connect_webview_id"] = $connect_webview_id; + } + if ($without_user_identifier_key !== null) { + $request_payload[ + "without_user_identifier_key" + ] = $without_user_identifier_key; + } + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; } $res = $this->seam->request( "POST", - "/acs/access_groups/get", - json: (object) $request_payload, - inner_object: "acs_access_group" + "/client_sessions/list", + json: (object) $request_payload ); - return AcsAccessGroup::from_json($res); + if ($on_response !== null) { + $on_response($res); + } + + return array_map( + fn($r) => ClientSession::from_json($r), + $res->client_sessions + ); } - public function list( - string $acs_system_id = null, - string $acs_user_id = null - ): array { + public function revoke(string $client_session_id): void + { $request_payload = []; - if ($acs_system_id !== null) { - $request_payload["acs_system_id"] = $acs_system_id; - } - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($client_session_id !== null) { + $request_payload["client_session_id"] = $client_session_id; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/acs/access_groups/list", - json: (object) $request_payload, - inner_object: "acs_access_groups" + "/client_sessions/revoke", + json: (object) $request_payload ); + } +} + +class ConnectWebviewsClient +{ + private SeamClient $seam; - return array_map(fn($r) => AcsAccessGroup::from_json($r), $res); + public function __construct(SeamClient $seam) + { + $this->seam = $seam; } - public function list_accessible_entrances( - string $acs_access_group_id - ): array { + public function create( + ?string $device_selection_mode = null, + ?string $custom_redirect_url = null, + ?string $custom_redirect_failure_url = null, + ?array $accepted_providers = null, + ?string $provider_category = null, + mixed $custom_metadata = null, + ?bool $automatically_manage_new_devices = null, + ?bool $wait_for_device_creation = null + ): ConnectWebview { $request_payload = []; - if ($acs_access_group_id !== null) { - $request_payload["acs_access_group_id"] = $acs_access_group_id; + if ($device_selection_mode !== null) { + $request_payload["device_selection_mode"] = $device_selection_mode; + } + if ($custom_redirect_url !== null) { + $request_payload["custom_redirect_url"] = $custom_redirect_url; + } + if ($custom_redirect_failure_url !== null) { + $request_payload[ + "custom_redirect_failure_url" + ] = $custom_redirect_failure_url; + } + if ($accepted_providers !== null) { + $request_payload["accepted_providers"] = $accepted_providers; + } + if ($provider_category !== null) { + $request_payload["provider_category"] = $provider_category; + } + if ($custom_metadata !== null) { + $request_payload["custom_metadata"] = $custom_metadata; + } + if ($automatically_manage_new_devices !== null) { + $request_payload[ + "automatically_manage_new_devices" + ] = $automatically_manage_new_devices; + } + if ($wait_for_device_creation !== null) { + $request_payload[ + "wait_for_device_creation" + ] = $wait_for_device_creation; } $res = $this->seam->request( "POST", - "/acs/access_groups/list_accessible_entrances", - json: (object) $request_payload, - inner_object: "acs_entrances" + "/connect_webviews/create", + json: (object) $request_payload ); - return array_map(fn($r) => AcsEntrance::from_json($r), $res); + return ConnectWebview::from_json($res->connect_webview); } - public function list_users(string $acs_access_group_id): array + public function delete(string $connect_webview_id): void { $request_payload = []; - if ($acs_access_group_id !== null) { - $request_payload["acs_access_group_id"] = $acs_access_group_id; + if ($connect_webview_id !== null) { + $request_payload["connect_webview_id"] = $connect_webview_id; + } + + $this->seam->request( + "POST", + "/connect_webviews/delete", + json: (object) $request_payload + ); + } + + public function get(string $connect_webview_id): ConnectWebview + { + $request_payload = []; + + if ($connect_webview_id !== null) { + $request_payload["connect_webview_id"] = $connect_webview_id; } $res = $this->seam->request( "POST", - "/acs/access_groups/list_users", - json: (object) $request_payload, - inner_object: "acs_users" + "/connect_webviews/get", + json: (object) $request_payload ); - return array_map(fn($r) => AcsUser::from_json($r), $res); + return ConnectWebview::from_json($res->connect_webview); } - public function remove_user( - string $acs_access_group_id, - string $acs_user_id - ): void { + public function list( + ?string $user_identifier_key = null, + mixed $custom_metadata_has = null, + ?float $limit = null, + ?callable $on_response = null + ): array { $request_payload = []; - if ($acs_access_group_id !== null) { - $request_payload["acs_access_group_id"] = $acs_access_group_id; + if ($user_identifier_key !== null) { + $request_payload["user_identifier_key"] = $user_identifier_key; } - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($custom_metadata_has !== null) { + $request_payload["custom_metadata_has"] = $custom_metadata_has; + } + if ($limit !== null) { + $request_payload["limit"] = $limit; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/acs/access_groups/remove_user", + "/connect_webviews/list", json: (object) $request_payload ); - } -} -class AcsClient -{ - private SeamClient $seam; - public AcsAccessGroupsClient $access_groups; - public AcsCredentialPoolsClient $credential_pools; - public AcsCredentialProvisioningAutomationsClient $credential_provisioning_automations; - public AcsCredentialsClient $credentials; - public AcsEncodersClient $encoders; - public AcsEntrancesClient $entrances; - public AcsSystemsClient $systems; - public AcsUsersClient $users; - public function __construct(SeamClient $seam) - { - $this->seam = $seam; - $this->access_groups = new AcsAccessGroupsClient($seam); - $this->credential_pools = new AcsCredentialPoolsClient($seam); - $this->credential_provisioning_automations = new AcsCredentialProvisioningAutomationsClient( - $seam + if ($on_response !== null) { + $on_response($res); + } + + return array_map( + fn($r) => ConnectWebview::from_json($r), + $res->connect_webviews ); - $this->credentials = new AcsCredentialsClient($seam); - $this->encoders = new AcsEncodersClient($seam); - $this->entrances = new AcsEntrancesClient($seam); - $this->systems = new AcsSystemsClient($seam); - $this->users = new AcsUsersClient($seam); } } -class AcsAccessGroupsUnmanagedClient +class ConnectedAccountsClient { private SeamClient $seam; @@ -960,401 +1066,394 @@ public function __construct(SeamClient $seam) $this->seam = $seam; } - public function get(string $acs_access_group_id): UnmanagedAcsAccessGroup - { + public function delete( + string $connected_account_id, + ?bool $sync = null + ): void { $request_payload = []; - if ($acs_access_group_id !== null) { - $request_payload["acs_access_group_id"] = $acs_access_group_id; + if ($connected_account_id !== null) { + $request_payload["connected_account_id"] = $connected_account_id; + } + if ($sync !== null) { + $request_payload["sync"] = $sync; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/acs/access_groups/unmanaged/get", - json: (object) $request_payload, - inner_object: "acs_access_group" + "/connected_accounts/delete", + json: (object) $request_payload ); - - return UnmanagedAcsAccessGroup::from_json($res); } - public function list( - string $acs_system_id = null, - string $acs_user_id = null - ): array { + public function get( + ?string $connected_account_id = null, + ?string $email = null + ): ConnectedAccount { $request_payload = []; - if ($acs_system_id !== null) { - $request_payload["acs_system_id"] = $acs_system_id; + if ($connected_account_id !== null) { + $request_payload["connected_account_id"] = $connected_account_id; } - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($email !== null) { + $request_payload["email"] = $email; } $res = $this->seam->request( "POST", - "/acs/access_groups/unmanaged/list", - json: (object) $request_payload, - inner_object: "acs_access_groups" - ); - - return array_map( - fn($r) => UnmanagedAcsAccessGroup::from_json($r), - $res + "/connected_accounts/get", + json: (object) $request_payload ); - } -} - -class AcsCredentialPoolsClient -{ - private SeamClient $seam; - public function __construct(SeamClient $seam) - { - $this->seam = $seam; + return ConnectedAccount::from_json($res->connected_account); } - public function list(string $acs_system_id): array - { + public function list( + ?string $user_identifier_key = null, + mixed $custom_metadata_has = null, + mixed $limit = null, + ?string $page_cursor = null, + ?callable $on_response = null + ): array { $request_payload = []; - if ($acs_system_id !== null) { - $request_payload["acs_system_id"] = $acs_system_id; + if ($user_identifier_key !== null) { + $request_payload["user_identifier_key"] = $user_identifier_key; + } + if ($custom_metadata_has !== null) { + $request_payload["custom_metadata_has"] = $custom_metadata_has; + } + if ($limit !== null) { + $request_payload["limit"] = $limit; + } + if ($page_cursor !== null) { + $request_payload["page_cursor"] = $page_cursor; } $res = $this->seam->request( "POST", - "/acs/credential_pools/list", - json: (object) $request_payload, - inner_object: "acs_credential_pools" + "/connected_accounts/list", + json: (object) $request_payload ); - return array_map(fn($r) => AcsCredentialPool::from_json($r), $res); - } -} - -class AcsCredentialProvisioningAutomationsClient -{ - private SeamClient $seam; + if ($on_response !== null) { + $on_response($res); + } - public function __construct(SeamClient $seam) - { - $this->seam = $seam; + return array_map( + fn($r) => ConnectedAccount::from_json($r), + $res->connected_accounts + ); } - public function launch( - string $credential_manager_acs_system_id, - string $user_identity_id, - string $acs_credential_pool_id = null, - bool $create_credential_manager_user = null, - string $credential_manager_acs_user_id = null - ): AcsCredentialProvisioningAutomation { + public function update( + string $connected_account_id, + ?bool $automatically_manage_new_devices = null, + mixed $custom_metadata = null + ): void { $request_payload = []; - if ($credential_manager_acs_system_id !== null) { - $request_payload[ - "credential_manager_acs_system_id" - ] = $credential_manager_acs_system_id; - } - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; - } - if ($acs_credential_pool_id !== null) { - $request_payload[ - "acs_credential_pool_id" - ] = $acs_credential_pool_id; + if ($connected_account_id !== null) { + $request_payload["connected_account_id"] = $connected_account_id; } - if ($create_credential_manager_user !== null) { + if ($automatically_manage_new_devices !== null) { $request_payload[ - "create_credential_manager_user" - ] = $create_credential_manager_user; + "automatically_manage_new_devices" + ] = $automatically_manage_new_devices; } - if ($credential_manager_acs_user_id !== null) { - $request_payload[ - "credential_manager_acs_user_id" - ] = $credential_manager_acs_user_id; + if ($custom_metadata !== null) { + $request_payload["custom_metadata"] = $custom_metadata; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/acs/credential_provisioning_automations/launch", - json: (object) $request_payload, - inner_object: "acs_credential_provisioning_automation" + "/connected_accounts/update", + json: (object) $request_payload ); - - return AcsCredentialProvisioningAutomation::from_json($res); } } -class AcsCredentialsClient +class DevicesClient { private SeamClient $seam; - + public DevicesSimulateClient $simulate; + public DevicesUnmanagedClient $unmanaged; public function __construct(SeamClient $seam) { $this->seam = $seam; + $this->simulate = new DevicesSimulateClient($seam); + $this->unmanaged = new DevicesUnmanagedClient($seam); } - public function assign(string $acs_credential_id, string $acs_user_id): void + public function get(?string $device_id = null, ?string $name = null): Device { $request_payload = []; - if ($acs_credential_id !== null) { - $request_payload["acs_credential_id"] = $acs_credential_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($name !== null) { + $request_payload["name"] = $name; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/acs/credentials/assign", + "/devices/get", json: (object) $request_payload ); + + return Device::from_json($res->device); } - public function create( - string $access_method, - string $acs_user_id, - array $allowed_acs_entrance_ids = null, - mixed $assa_abloy_vostio_metadata = null, - string $code = null, - string $credential_manager_acs_system_id = null, - string $ends_at = null, - bool $is_multi_phone_sync_credential = null, - mixed $salto_space_metadata = null, - string $starts_at = null, - mixed $visionline_metadata = null - ): AcsCredential { + public function list( + ?string $connected_account_id = null, + ?array $connected_account_ids = null, + ?string $connect_webview_id = null, + ?string $device_type = null, + ?array $device_types = null, + ?string $manufacturer = null, + ?array $device_ids = null, + ?float $limit = null, + ?string $created_before = null, + ?string $user_identifier_key = null, + mixed $custom_metadata_has = null, + ?array $include_if = null, + ?array $exclude_if = null, + ?string $unstable_location_id = null, + ?callable $on_response = null, + ?string $page_cursor = null + ): array { $request_payload = []; - if ($access_method !== null) { - $request_payload["access_method"] = $access_method; + if ($connected_account_id !== null) { + $request_payload["connected_account_id"] = $connected_account_id; } - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($connected_account_ids !== null) { + $request_payload["connected_account_ids"] = $connected_account_ids; } - if ($allowed_acs_entrance_ids !== null) { - $request_payload[ - "allowed_acs_entrance_ids" - ] = $allowed_acs_entrance_ids; + if ($connect_webview_id !== null) { + $request_payload["connect_webview_id"] = $connect_webview_id; } - if ($assa_abloy_vostio_metadata !== null) { - $request_payload[ - "assa_abloy_vostio_metadata" - ] = $assa_abloy_vostio_metadata; + if ($device_type !== null) { + $request_payload["device_type"] = $device_type; } - if ($code !== null) { - $request_payload["code"] = $code; + if ($device_types !== null) { + $request_payload["device_types"] = $device_types; } - if ($credential_manager_acs_system_id !== null) { - $request_payload[ - "credential_manager_acs_system_id" - ] = $credential_manager_acs_system_id; + if ($manufacturer !== null) { + $request_payload["manufacturer"] = $manufacturer; } - if ($ends_at !== null) { - $request_payload["ends_at"] = $ends_at; + if ($device_ids !== null) { + $request_payload["device_ids"] = $device_ids; } - if ($is_multi_phone_sync_credential !== null) { - $request_payload[ - "is_multi_phone_sync_credential" - ] = $is_multi_phone_sync_credential; + if ($limit !== null) { + $request_payload["limit"] = $limit; } - if ($salto_space_metadata !== null) { - $request_payload["salto_space_metadata"] = $salto_space_metadata; + if ($created_before !== null) { + $request_payload["created_before"] = $created_before; } - if ($starts_at !== null) { - $request_payload["starts_at"] = $starts_at; + if ($user_identifier_key !== null) { + $request_payload["user_identifier_key"] = $user_identifier_key; } - if ($visionline_metadata !== null) { - $request_payload["visionline_metadata"] = $visionline_metadata; + if ($custom_metadata_has !== null) { + $request_payload["custom_metadata_has"] = $custom_metadata_has; + } + if ($include_if !== null) { + $request_payload["include_if"] = $include_if; + } + if ($exclude_if !== null) { + $request_payload["exclude_if"] = $exclude_if; + } + if ($unstable_location_id !== null) { + $request_payload["unstable_location_id"] = $unstable_location_id; + } + if ($page_cursor !== null) { + $request_payload["page_cursor"] = $page_cursor; } $res = $this->seam->request( "POST", - "/acs/credentials/create", - json: (object) $request_payload, - inner_object: "acs_credential" + "/devices/list", + json: (object) $request_payload ); - return AcsCredential::from_json($res); + if ($on_response !== null) { + $on_response($res); + } + + return array_map(fn($r) => Device::from_json($r), $res->devices); } - public function create_offline_code( - string $acs_user_id, - string $allowed_acs_entrance_id, - string $ends_at = null, - bool $is_one_time_use = null, - string $starts_at = null - ): AcsCredential { + public function list_device_providers( + ?string $provider_category = null + ): array { $request_payload = []; - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; - } - if ($allowed_acs_entrance_id !== null) { - $request_payload[ - "allowed_acs_entrance_id" - ] = $allowed_acs_entrance_id; - } - if ($ends_at !== null) { - $request_payload["ends_at"] = $ends_at; - } - if ($is_one_time_use !== null) { - $request_payload["is_one_time_use"] = $is_one_time_use; - } - if ($starts_at !== null) { - $request_payload["starts_at"] = $starts_at; + if ($provider_category !== null) { + $request_payload["provider_category"] = $provider_category; } $res = $this->seam->request( "POST", - "/acs/credentials/create_offline_code", - json: (object) $request_payload, - inner_object: "acs_credential" + "/devices/list_device_providers", + json: (object) $request_payload ); - return AcsCredential::from_json($res); + return array_map( + fn($r) => DeviceProvider::from_json($r), + $res->device_providers + ); } - public function delete(string $acs_credential_id): void - { + public function update( + string $device_id, + mixed $properties = null, + ?string $name = null, + ?bool $is_managed = null, + mixed $custom_metadata = null + ): void { $request_payload = []; - if ($acs_credential_id !== null) { - $request_payload["acs_credential_id"] = $acs_credential_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } + if ($properties !== null) { + $request_payload["properties"] = $properties; + } + if ($name !== null) { + $request_payload["name"] = $name; + } + if ($is_managed !== null) { + $request_payload["is_managed"] = $is_managed; + } + if ($custom_metadata !== null) { + $request_payload["custom_metadata"] = $custom_metadata; } $this->seam->request( "POST", - "/acs/credentials/delete", + "/devices/update", json: (object) $request_payload ); } +} - public function get(string $acs_credential_id): AcsCredential +class EventsClient +{ + private SeamClient $seam; + + public function __construct(SeamClient $seam) { + $this->seam = $seam; + } + + public function get( + ?string $event_id = null, + ?string $event_type = null, + ?string $device_id = null + ): Event { $request_payload = []; - if ($acs_credential_id !== null) { - $request_payload["acs_credential_id"] = $acs_credential_id; + if ($event_id !== null) { + $request_payload["event_id"] = $event_id; + } + if ($event_type !== null) { + $request_payload["event_type"] = $event_type; + } + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } $res = $this->seam->request( "POST", - "/acs/credentials/get", - json: (object) $request_payload, - inner_object: "acs_credential" + "/events/get", + json: (object) $request_payload ); - return AcsCredential::from_json($res); + return Event::from_json($res->event); } public function list( - string $acs_user_id = null, - string $acs_system_id = null, - string $user_identity_id = null, - string $created_before = null, - bool $is_multi_phone_sync_credential = null, - float $limit = null + ?float $unstable_offset = null, + ?string $since = null, + ?array $between = null, + ?string $device_id = null, + ?array $device_ids = null, + ?string $acs_system_id = null, + ?array $acs_system_ids = null, + ?string $access_code_id = null, + ?array $access_code_ids = null, + ?string $event_type = null, + ?array $event_types = null, + ?string $connected_account_id = null, + ?string $connect_webview_id = null, + ?float $limit = null, + ?array $event_ids = null, + ?callable $on_response = null ): array { $request_payload = []; - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($unstable_offset !== null) { + $request_payload["unstable_offset"] = $unstable_offset; + } + if ($since !== null) { + $request_payload["since"] = $since; + } + if ($between !== null) { + $request_payload["between"] = $between; + } + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } + if ($device_ids !== null) { + $request_payload["device_ids"] = $device_ids; } if ($acs_system_id !== null) { $request_payload["acs_system_id"] = $acs_system_id; } - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; + if ($acs_system_ids !== null) { + $request_payload["acs_system_ids"] = $acs_system_ids; } - if ($created_before !== null) { - $request_payload["created_before"] = $created_before; + if ($access_code_id !== null) { + $request_payload["access_code_id"] = $access_code_id; } - if ($is_multi_phone_sync_credential !== null) { - $request_payload[ - "is_multi_phone_sync_credential" - ] = $is_multi_phone_sync_credential; + if ($access_code_ids !== null) { + $request_payload["access_code_ids"] = $access_code_ids; + } + if ($event_type !== null) { + $request_payload["event_type"] = $event_type; + } + if ($event_types !== null) { + $request_payload["event_types"] = $event_types; + } + if ($connected_account_id !== null) { + $request_payload["connected_account_id"] = $connected_account_id; + } + if ($connect_webview_id !== null) { + $request_payload["connect_webview_id"] = $connect_webview_id; } if ($limit !== null) { $request_payload["limit"] = $limit; } - - $res = $this->seam->request( - "POST", - "/acs/credentials/list", - json: (object) $request_payload, - inner_object: "acs_credentials" - ); - - return array_map(fn($r) => AcsCredential::from_json($r), $res); - } - - public function list_accessible_entrances(string $acs_credential_id): array - { - $request_payload = []; - - if ($acs_credential_id !== null) { - $request_payload["acs_credential_id"] = $acs_credential_id; + if ($event_ids !== null) { + $request_payload["event_ids"] = $event_ids; } $res = $this->seam->request( "POST", - "/acs/credentials/list_accessible_entrances", - json: (object) $request_payload, - inner_object: "acs_entrances" - ); - - return array_map(fn($r) => AcsEntrance::from_json($r), $res); - } - - public function unassign( - string $acs_credential_id, - string $acs_user_id - ): void { - $request_payload = []; - - if ($acs_credential_id !== null) { - $request_payload["acs_credential_id"] = $acs_credential_id; - } - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; - } - - $this->seam->request( - "POST", - "/acs/credentials/unassign", + "/events/list", json: (object) $request_payload ); - } - - public function update( - string $acs_credential_id, - string $code = null, - string $ends_at = null - ): void { - $request_payload = []; - if ($acs_credential_id !== null) { - $request_payload["acs_credential_id"] = $acs_credential_id; - } - if ($code !== null) { - $request_payload["code"] = $code; - } - if ($ends_at !== null) { - $request_payload["ends_at"] = $ends_at; + if ($on_response !== null) { + $on_response($res); } - $this->seam->request( - "POST", - "/acs/credentials/update", - json: (object) $request_payload - ); + return array_map(fn($r) => Event::from_json($r), $res->events); } } -class AcsCredentialsUnmanagedClient +class LocksClient { private SeamClient $seam; @@ -1363,154 +1462,165 @@ public function __construct(SeamClient $seam) $this->seam = $seam; } - public function get(string $acs_credential_id): UnmanagedAcsCredential + public function get(?string $device_id = null, ?string $name = null): Device { $request_payload = []; - if ($acs_credential_id !== null) { - $request_payload["acs_credential_id"] = $acs_credential_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } + if ($name !== null) { + $request_payload["name"] = $name; } $res = $this->seam->request( "POST", - "/acs/credentials/unmanaged/get", - json: (object) $request_payload, - inner_object: "acs_credential" + "/locks/get", + json: (object) $request_payload ); - return UnmanagedAcsCredential::from_json($res); + return Device::from_json($res->device); } public function list( - string $acs_user_id = null, - string $acs_system_id = null, - string $user_identity_id = null + ?string $connected_account_id = null, + ?array $connected_account_ids = null, + ?string $connect_webview_id = null, + ?string $device_type = null, + ?array $device_types = null, + ?string $manufacturer = null, + ?array $device_ids = null, + ?float $limit = null, + ?string $created_before = null, + ?string $user_identifier_key = null, + mixed $custom_metadata_has = null, + ?array $include_if = null, + ?array $exclude_if = null, + ?string $unstable_location_id = null, + ?callable $on_response = null ): array { $request_payload = []; - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($connected_account_id !== null) { + $request_payload["connected_account_id"] = $connected_account_id; } - if ($acs_system_id !== null) { - $request_payload["acs_system_id"] = $acs_system_id; + if ($connected_account_ids !== null) { + $request_payload["connected_account_ids"] = $connected_account_ids; } - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; + if ($connect_webview_id !== null) { + $request_payload["connect_webview_id"] = $connect_webview_id; + } + if ($device_type !== null) { + $request_payload["device_type"] = $device_type; + } + if ($device_types !== null) { + $request_payload["device_types"] = $device_types; + } + if ($manufacturer !== null) { + $request_payload["manufacturer"] = $manufacturer; + } + if ($device_ids !== null) { + $request_payload["device_ids"] = $device_ids; + } + if ($limit !== null) { + $request_payload["limit"] = $limit; + } + if ($created_before !== null) { + $request_payload["created_before"] = $created_before; + } + if ($user_identifier_key !== null) { + $request_payload["user_identifier_key"] = $user_identifier_key; + } + if ($custom_metadata_has !== null) { + $request_payload["custom_metadata_has"] = $custom_metadata_has; + } + if ($include_if !== null) { + $request_payload["include_if"] = $include_if; + } + if ($exclude_if !== null) { + $request_payload["exclude_if"] = $exclude_if; + } + if ($unstable_location_id !== null) { + $request_payload["unstable_location_id"] = $unstable_location_id; } $res = $this->seam->request( "POST", - "/acs/credentials/unmanaged/list", - json: (object) $request_payload, - inner_object: "acs_credentials" + "/locks/list", + json: (object) $request_payload ); - return array_map(fn($r) => UnmanagedAcsCredential::from_json($r), $res); - } -} - -class AcsEncodersClient -{ - private SeamClient $seam; + if ($on_response !== null) { + $on_response($res); + } - public function __construct(SeamClient $seam) - { - $this->seam = $seam; + return array_map(fn($r) => Device::from_json($r), $res->devices); } - public function encode_credential( - string $acs_credential_id, - string $acs_encoder_id, + public function lock_door( + string $device_id, + ?bool $sync = null, bool $wait_for_action_attempt = true ): ActionAttempt { $request_payload = []; - if ($acs_credential_id !== null) { - $request_payload["acs_credential_id"] = $acs_credential_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - if ($acs_encoder_id !== null) { - $request_payload["acs_encoder_id"] = $acs_encoder_id; + if ($sync !== null) { + $request_payload["sync"] = $sync; } $res = $this->seam->request( "POST", - "/acs/encoders/encode_credential", - json: (object) $request_payload, - inner_object: "action_attempt" + "/locks/lock_door", + json: (object) $request_payload ); if (!$wait_for_action_attempt) { - return ActionAttempt::from_json($res); + return ActionAttempt::from_json($res->action_attempt); } $action_attempt = $this->seam->action_attempts->poll_until_ready( - $res->action_attempt_id + $res->action_attempt->action_attempt_id ); return $action_attempt; } - public function list( - string $acs_system_id = null, - float $limit = null, - array $acs_system_ids = null, - array $acs_encoder_ids = null - ): array { - $request_payload = []; - - if ($acs_system_id !== null) { - $request_payload["acs_system_id"] = $acs_system_id; - } - if ($limit !== null) { - $request_payload["limit"] = $limit; - } - if ($acs_system_ids !== null) { - $request_payload["acs_system_ids"] = $acs_system_ids; - } - if ($acs_encoder_ids !== null) { - $request_payload["acs_encoder_ids"] = $acs_encoder_ids; - } - - $res = $this->seam->request( - "POST", - "/acs/encoders/list", - json: (object) $request_payload, - inner_object: "acs_encoders" - ); - - return array_map(fn($r) => AcsEncoder::from_json($r), $res); - } - - public function scan_credential( - string $acs_encoder_id, + public function unlock_door( + string $device_id, + ?bool $sync = null, bool $wait_for_action_attempt = true ): ActionAttempt { $request_payload = []; - if ($acs_encoder_id !== null) { - $request_payload["acs_encoder_id"] = $acs_encoder_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } + if ($sync !== null) { + $request_payload["sync"] = $sync; } $res = $this->seam->request( "POST", - "/acs/encoders/scan_credential", - json: (object) $request_payload, - inner_object: "action_attempt" + "/locks/unlock_door", + json: (object) $request_payload ); if (!$wait_for_action_attempt) { - return ActionAttempt::from_json($res); + return ActionAttempt::from_json($res->action_attempt); } $action_attempt = $this->seam->action_attempts->poll_until_ready( - $res->action_attempt_id + $res->action_attempt->action_attempt_id ); return $action_attempt; } } -class AcsEncodersSimulateClient +class NetworksClient { private SeamClient $seam; @@ -1519,1041 +1629,1052 @@ public function __construct(SeamClient $seam) $this->seam = $seam; } - public function next_credential_encode_will_fail( - string $acs_encoder_id, - string $error_code = null, - string $acs_credential_id = null - ): void { + public function get(string $network_id): Network + { $request_payload = []; - if ($acs_encoder_id !== null) { - $request_payload["acs_encoder_id"] = $acs_encoder_id; - } - if ($error_code !== null) { - $request_payload["error_code"] = $error_code; - } - if ($acs_credential_id !== null) { - $request_payload["acs_credential_id"] = $acs_credential_id; + if ($network_id !== null) { + $request_payload["network_id"] = $network_id; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/acs/encoders/simulate/next_credential_encode_will_fail", + "/networks/get", json: (object) $request_payload ); + + return Network::from_json($res->network); } - public function next_credential_encode_will_succeed( - string $acs_encoder_id, - string $scenario = null - ): void { - $request_payload = []; + public function list(?callable $on_response = null): array + { + $res = $this->seam->request("POST", "/networks/list"); - if ($acs_encoder_id !== null) { - $request_payload["acs_encoder_id"] = $acs_encoder_id; - } - if ($scenario !== null) { - $request_payload["scenario"] = $scenario; + if ($on_response !== null) { + $on_response($res); } - $this->seam->request( - "POST", - "/acs/encoders/simulate/next_credential_encode_will_succeed", - json: (object) $request_payload - ); + return array_map(fn($r) => Network::from_json($r), $res->networks); } +} - public function next_credential_scan_will_fail( - string $acs_encoder_id, - string $error_code = null, - string $acs_credential_id_on_seam = null - ): void { +class NoiseSensorsClient +{ + private SeamClient $seam; + public NoiseSensorsNoiseThresholdsClient $noise_thresholds; + public NoiseSensorsSimulateClient $simulate; + public function __construct(SeamClient $seam) + { + $this->seam = $seam; + $this->noise_thresholds = new NoiseSensorsNoiseThresholdsClient($seam); + $this->simulate = new NoiseSensorsSimulateClient($seam); + } + + public function list( + ?string $connected_account_id = null, + ?array $connected_account_ids = null, + ?string $connect_webview_id = null, + ?string $device_type = null, + ?array $device_types = null, + ?string $manufacturer = null, + ?array $device_ids = null, + ?float $limit = null, + ?string $created_before = null, + ?string $user_identifier_key = null, + mixed $custom_metadata_has = null, + ?array $include_if = null, + ?array $exclude_if = null, + ?string $unstable_location_id = null, + ?callable $on_response = null + ): array { $request_payload = []; - if ($acs_encoder_id !== null) { - $request_payload["acs_encoder_id"] = $acs_encoder_id; + if ($connected_account_id !== null) { + $request_payload["connected_account_id"] = $connected_account_id; } - if ($error_code !== null) { - $request_payload["error_code"] = $error_code; + if ($connected_account_ids !== null) { + $request_payload["connected_account_ids"] = $connected_account_ids; } - if ($acs_credential_id_on_seam !== null) { - $request_payload[ - "acs_credential_id_on_seam" - ] = $acs_credential_id_on_seam; + if ($connect_webview_id !== null) { + $request_payload["connect_webview_id"] = $connect_webview_id; } - - $this->seam->request( - "POST", - "/acs/encoders/simulate/next_credential_scan_will_fail", - json: (object) $request_payload - ); - } - - public function next_credential_scan_will_succeed( - string $acs_encoder_id, - string $acs_credential_id_on_seam = null, - string $scenario = null - ): void { - $request_payload = []; - - if ($acs_encoder_id !== null) { - $request_payload["acs_encoder_id"] = $acs_encoder_id; + if ($device_type !== null) { + $request_payload["device_type"] = $device_type; } - if ($acs_credential_id_on_seam !== null) { - $request_payload[ - "acs_credential_id_on_seam" - ] = $acs_credential_id_on_seam; + if ($device_types !== null) { + $request_payload["device_types"] = $device_types; } - if ($scenario !== null) { - $request_payload["scenario"] = $scenario; + if ($manufacturer !== null) { + $request_payload["manufacturer"] = $manufacturer; + } + if ($device_ids !== null) { + $request_payload["device_ids"] = $device_ids; + } + if ($limit !== null) { + $request_payload["limit"] = $limit; + } + if ($created_before !== null) { + $request_payload["created_before"] = $created_before; + } + if ($user_identifier_key !== null) { + $request_payload["user_identifier_key"] = $user_identifier_key; + } + if ($custom_metadata_has !== null) { + $request_payload["custom_metadata_has"] = $custom_metadata_has; + } + if ($include_if !== null) { + $request_payload["include_if"] = $include_if; + } + if ($exclude_if !== null) { + $request_payload["exclude_if"] = $exclude_if; + } + if ($unstable_location_id !== null) { + $request_payload["unstable_location_id"] = $unstable_location_id; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/acs/encoders/simulate/next_credential_scan_will_succeed", + "/noise_sensors/list", json: (object) $request_payload ); + + if ($on_response !== null) { + $on_response($res); + } + + return array_map(fn($r) => Device::from_json($r), $res->devices); } } -class AcsEntrancesClient +class PhonesClient { private SeamClient $seam; - + public PhonesSimulateClient $simulate; public function __construct(SeamClient $seam) { $this->seam = $seam; + $this->simulate = new PhonesSimulateClient($seam); } - public function get(string $acs_entrance_id): AcsEntrance + public function deactivate(string $device_id): void { $request_payload = []; - if ($acs_entrance_id !== null) { - $request_payload["acs_entrance_id"] = $acs_entrance_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/acs/entrances/get", - json: (object) $request_payload, - inner_object: "acs_entrance" + "/phones/deactivate", + json: (object) $request_payload ); - - return AcsEntrance::from_json($res); } - public function grant_access( - string $acs_entrance_id, - string $acs_user_id - ): void { - $request_payload = []; + public function get(string $device_id): Phone + { + $request_payload = []; - if ($acs_entrance_id !== null) { - $request_payload["acs_entrance_id"] = $acs_entrance_id; - } - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/acs/entrances/grant_access", + "/phones/get", json: (object) $request_payload ); + + return Phone::from_json($res->phone); } public function list( - string $acs_credential_id = null, - string $acs_system_id = null + ?string $owner_user_identity_id = null, + ?string $acs_credential_id = null, + ?callable $on_response = null ): array { $request_payload = []; + if ($owner_user_identity_id !== null) { + $request_payload[ + "owner_user_identity_id" + ] = $owner_user_identity_id; + } if ($acs_credential_id !== null) { $request_payload["acs_credential_id"] = $acs_credential_id; } - if ($acs_system_id !== null) { - $request_payload["acs_system_id"] = $acs_system_id; - } $res = $this->seam->request( "POST", - "/acs/entrances/list", - json: (object) $request_payload, - inner_object: "acs_entrances" + "/phones/list", + json: (object) $request_payload ); - return array_map(fn($r) => AcsEntrance::from_json($r), $res); - } - - public function list_credentials_with_access( - string $acs_entrance_id, - array $include_if = null - ): array { - $request_payload = []; - - if ($acs_entrance_id !== null) { - $request_payload["acs_entrance_id"] = $acs_entrance_id; - } - if ($include_if !== null) { - $request_payload["include_if"] = $include_if; + if ($on_response !== null) { + $on_response($res); } - $res = $this->seam->request( - "POST", - "/acs/entrances/list_credentials_with_access", - json: (object) $request_payload, - inner_object: "acs_credentials" - ); - - return array_map(fn($r) => AcsCredential::from_json($r), $res); + return array_map(fn($r) => Phone::from_json($r), $res->phones); } } -class AcsSystemsClient +class ThermostatsClient { private SeamClient $seam; - + public ThermostatsSchedulesClient $schedules; + public ThermostatsSimulateClient $simulate; public function __construct(SeamClient $seam) { $this->seam = $seam; + $this->schedules = new ThermostatsSchedulesClient($seam); + $this->simulate = new ThermostatsSimulateClient($seam); } - public function get(string $acs_system_id): AcsSystem - { + public function activate_climate_preset( + string $device_id, + string $climate_preset_key, + bool $wait_for_action_attempt = true + ): ActionAttempt { $request_payload = []; - if ($acs_system_id !== null) { - $request_payload["acs_system_id"] = $acs_system_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } + if ($climate_preset_key !== null) { + $request_payload["climate_preset_key"] = $climate_preset_key; } $res = $this->seam->request( "POST", - "/acs/systems/get", - json: (object) $request_payload, - inner_object: "acs_system" + "/thermostats/activate_climate_preset", + json: (object) $request_payload ); - return AcsSystem::from_json($res); - } - - public function list(string $connected_account_id = null): array - { - $request_payload = []; - - if ($connected_account_id !== null) { - $request_payload["connected_account_id"] = $connected_account_id; + if (!$wait_for_action_attempt) { + return ActionAttempt::from_json($res->action_attempt); } - $res = $this->seam->request( - "POST", - "/acs/systems/list", - json: (object) $request_payload, - inner_object: "acs_systems" + $action_attempt = $this->seam->action_attempts->poll_until_ready( + $res->action_attempt->action_attempt_id ); - return array_map(fn($r) => AcsSystem::from_json($r), $res); + return $action_attempt; } - public function list_compatible_credential_manager_acs_systems( - string $acs_system_id - ): array { + public function cool( + string $device_id, + ?float $cooling_set_point_celsius = null, + ?float $cooling_set_point_fahrenheit = null, + ?bool $sync = null, + bool $wait_for_action_attempt = true + ): ActionAttempt { $request_payload = []; - if ($acs_system_id !== null) { - $request_payload["acs_system_id"] = $acs_system_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } + if ($cooling_set_point_celsius !== null) { + $request_payload[ + "cooling_set_point_celsius" + ] = $cooling_set_point_celsius; + } + if ($cooling_set_point_fahrenheit !== null) { + $request_payload[ + "cooling_set_point_fahrenheit" + ] = $cooling_set_point_fahrenheit; + } + if ($sync !== null) { + $request_payload["sync"] = $sync; } $res = $this->seam->request( "POST", - "/acs/systems/list_compatible_credential_manager_acs_systems", - json: (object) $request_payload, - inner_object: "acs_systems" + "/thermostats/cool", + json: (object) $request_payload ); - return array_map(fn($r) => AcsSystem::from_json($r), $res); - } -} + if (!$wait_for_action_attempt) { + return ActionAttempt::from_json($res->action_attempt); + } -class AcsUsersClient -{ - private SeamClient $seam; + $action_attempt = $this->seam->action_attempts->poll_until_ready( + $res->action_attempt->action_attempt_id + ); - public function __construct(SeamClient $seam) - { - $this->seam = $seam; + return $action_attempt; } - public function add_to_access_group( - string $acs_access_group_id, - string $acs_user_id + public function create_climate_preset( + string $device_id, + string $climate_preset_key, + ?bool $manual_override_allowed = null, + ?string $name = null, + ?string $fan_mode_setting = null, + ?string $hvac_mode_setting = null, + ?float $cooling_set_point_celsius = null, + ?float $heating_set_point_celsius = null, + ?float $cooling_set_point_fahrenheit = null, + ?float $heating_set_point_fahrenheit = null ): void { $request_payload = []; - if ($acs_access_group_id !== null) { - $request_payload["acs_access_group_id"] = $acs_access_group_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($climate_preset_key !== null) { + $request_payload["climate_preset_key"] = $climate_preset_key; } - - $this->seam->request( - "POST", - "/acs/users/add_to_access_group", - json: (object) $request_payload - ); - } - - public function create( - string $acs_system_id, - string $full_name, - mixed $access_schedule = null, - array $acs_access_group_ids = null, - string $email = null, - string $email_address = null, - string $phone_number = null, - string $user_identity_id = null - ): AcsUser { - $request_payload = []; - - if ($acs_system_id !== null) { - $request_payload["acs_system_id"] = $acs_system_id; + if ($manual_override_allowed !== null) { + $request_payload[ + "manual_override_allowed" + ] = $manual_override_allowed; } - if ($full_name !== null) { - $request_payload["full_name"] = $full_name; + if ($name !== null) { + $request_payload["name"] = $name; } - if ($access_schedule !== null) { - $request_payload["access_schedule"] = $access_schedule; + if ($fan_mode_setting !== null) { + $request_payload["fan_mode_setting"] = $fan_mode_setting; } - if ($acs_access_group_ids !== null) { - $request_payload["acs_access_group_ids"] = $acs_access_group_ids; + if ($hvac_mode_setting !== null) { + $request_payload["hvac_mode_setting"] = $hvac_mode_setting; } - if ($email !== null) { - $request_payload["email"] = $email; + if ($cooling_set_point_celsius !== null) { + $request_payload[ + "cooling_set_point_celsius" + ] = $cooling_set_point_celsius; } - if ($email_address !== null) { - $request_payload["email_address"] = $email_address; + if ($heating_set_point_celsius !== null) { + $request_payload[ + "heating_set_point_celsius" + ] = $heating_set_point_celsius; } - if ($phone_number !== null) { - $request_payload["phone_number"] = $phone_number; + if ($cooling_set_point_fahrenheit !== null) { + $request_payload[ + "cooling_set_point_fahrenheit" + ] = $cooling_set_point_fahrenheit; } - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; + if ($heating_set_point_fahrenheit !== null) { + $request_payload[ + "heating_set_point_fahrenheit" + ] = $heating_set_point_fahrenheit; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/acs/users/create", - json: (object) $request_payload, - inner_object: "acs_user" + "/thermostats/create_climate_preset", + json: (object) $request_payload ); - - return AcsUser::from_json($res); } - public function delete(string $acs_user_id): void - { + public function delete_climate_preset( + string $device_id, + string $climate_preset_key + ): void { $request_payload = []; - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } + if ($climate_preset_key !== null) { + $request_payload["climate_preset_key"] = $climate_preset_key; } $this->seam->request( "POST", - "/acs/users/delete", + "/thermostats/delete_climate_preset", json: (object) $request_payload ); } - public function get(string $acs_user_id): AcsUser - { + public function heat( + string $device_id, + ?float $heating_set_point_celsius = null, + ?float $heating_set_point_fahrenheit = null, + ?bool $sync = null, + bool $wait_for_action_attempt = true + ): ActionAttempt { $request_payload = []; - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } + if ($heating_set_point_celsius !== null) { + $request_payload[ + "heating_set_point_celsius" + ] = $heating_set_point_celsius; + } + if ($heating_set_point_fahrenheit !== null) { + $request_payload[ + "heating_set_point_fahrenheit" + ] = $heating_set_point_fahrenheit; + } + if ($sync !== null) { + $request_payload["sync"] = $sync; } $res = $this->seam->request( "POST", - "/acs/users/get", - json: (object) $request_payload, - inner_object: "acs_user" + "/thermostats/heat", + json: (object) $request_payload + ); + + if (!$wait_for_action_attempt) { + return ActionAttempt::from_json($res->action_attempt); + } + + $action_attempt = $this->seam->action_attempts->poll_until_ready( + $res->action_attempt->action_attempt_id ); - return AcsUser::from_json($res); + return $action_attempt; } - public function list( - string $acs_system_id = null, - string $created_before = null, - float $limit = null, - string $user_identity_email_address = null, - string $user_identity_id = null, - string $user_identity_phone_number = null - ): array { + public function heat_cool( + string $device_id, + ?float $heating_set_point_celsius = null, + ?float $heating_set_point_fahrenheit = null, + ?float $cooling_set_point_celsius = null, + ?float $cooling_set_point_fahrenheit = null, + ?bool $sync = null, + bool $wait_for_action_attempt = true + ): ActionAttempt { $request_payload = []; - if ($acs_system_id !== null) { - $request_payload["acs_system_id"] = $acs_system_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - if ($created_before !== null) { - $request_payload["created_before"] = $created_before; - } - if ($limit !== null) { - $request_payload["limit"] = $limit; + if ($heating_set_point_celsius !== null) { + $request_payload[ + "heating_set_point_celsius" + ] = $heating_set_point_celsius; } - if ($user_identity_email_address !== null) { + if ($heating_set_point_fahrenheit !== null) { $request_payload[ - "user_identity_email_address" - ] = $user_identity_email_address; + "heating_set_point_fahrenheit" + ] = $heating_set_point_fahrenheit; } - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; + if ($cooling_set_point_celsius !== null) { + $request_payload[ + "cooling_set_point_celsius" + ] = $cooling_set_point_celsius; } - if ($user_identity_phone_number !== null) { + if ($cooling_set_point_fahrenheit !== null) { $request_payload[ - "user_identity_phone_number" - ] = $user_identity_phone_number; + "cooling_set_point_fahrenheit" + ] = $cooling_set_point_fahrenheit; + } + if ($sync !== null) { + $request_payload["sync"] = $sync; } $res = $this->seam->request( "POST", - "/acs/users/list", - json: (object) $request_payload, - inner_object: "acs_users" + "/thermostats/heat_cool", + json: (object) $request_payload ); - return array_map(fn($r) => AcsUser::from_json($r), $res); - } - - public function list_accessible_entrances(string $acs_user_id): array - { - $request_payload = []; - - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if (!$wait_for_action_attempt) { + return ActionAttempt::from_json($res->action_attempt); } - $res = $this->seam->request( - "POST", - "/acs/users/list_accessible_entrances", - json: (object) $request_payload, - inner_object: "acs_entrances" + $action_attempt = $this->seam->action_attempts->poll_until_ready( + $res->action_attempt->action_attempt_id ); - return array_map(fn($r) => AcsEntrance::from_json($r), $res); + return $action_attempt; } - public function remove_from_access_group( - string $acs_access_group_id, - string $acs_user_id - ): void { + public function list( + ?string $connected_account_id = null, + ?array $connected_account_ids = null, + ?string $connect_webview_id = null, + ?string $device_type = null, + ?array $device_types = null, + ?string $manufacturer = null, + ?array $device_ids = null, + ?float $limit = null, + ?string $created_before = null, + ?string $user_identifier_key = null, + mixed $custom_metadata_has = null, + ?array $include_if = null, + ?array $exclude_if = null, + ?string $unstable_location_id = null, + ?callable $on_response = null + ): array { $request_payload = []; - if ($acs_access_group_id !== null) { - $request_payload["acs_access_group_id"] = $acs_access_group_id; + if ($connected_account_id !== null) { + $request_payload["connected_account_id"] = $connected_account_id; } - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($connected_account_ids !== null) { + $request_payload["connected_account_ids"] = $connected_account_ids; + } + if ($connect_webview_id !== null) { + $request_payload["connect_webview_id"] = $connect_webview_id; + } + if ($device_type !== null) { + $request_payload["device_type"] = $device_type; + } + if ($device_types !== null) { + $request_payload["device_types"] = $device_types; + } + if ($manufacturer !== null) { + $request_payload["manufacturer"] = $manufacturer; + } + if ($device_ids !== null) { + $request_payload["device_ids"] = $device_ids; + } + if ($limit !== null) { + $request_payload["limit"] = $limit; + } + if ($created_before !== null) { + $request_payload["created_before"] = $created_before; + } + if ($user_identifier_key !== null) { + $request_payload["user_identifier_key"] = $user_identifier_key; + } + if ($custom_metadata_has !== null) { + $request_payload["custom_metadata_has"] = $custom_metadata_has; + } + if ($include_if !== null) { + $request_payload["include_if"] = $include_if; + } + if ($exclude_if !== null) { + $request_payload["exclude_if"] = $exclude_if; + } + if ($unstable_location_id !== null) { + $request_payload["unstable_location_id"] = $unstable_location_id; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/acs/users/remove_from_access_group", + "/thermostats/list", json: (object) $request_payload ); + + if ($on_response !== null) { + $on_response($res); + } + + return array_map(fn($r) => Device::from_json($r), $res->devices); } - public function revoke_access_to_all_entrances(string $acs_user_id): void - { + public function off( + string $device_id, + ?bool $sync = null, + bool $wait_for_action_attempt = true + ): ActionAttempt { $request_payload = []; - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } + if ($sync !== null) { + $request_payload["sync"] = $sync; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/acs/users/revoke_access_to_all_entrances", + "/thermostats/off", json: (object) $request_payload ); - } - - public function suspend(string $acs_user_id): void - { - $request_payload = []; - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if (!$wait_for_action_attempt) { + return ActionAttempt::from_json($res->action_attempt); } - $this->seam->request( - "POST", - "/acs/users/suspend", - json: (object) $request_payload + $action_attempt = $this->seam->action_attempts->poll_until_ready( + $res->action_attempt->action_attempt_id ); + + return $action_attempt; } - public function unsuspend(string $acs_user_id): void - { + public function set_fallback_climate_preset( + string $device_id, + string $climate_preset_key + ): void { $request_payload = []; - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } + if ($climate_preset_key !== null) { + $request_payload["climate_preset_key"] = $climate_preset_key; } $this->seam->request( "POST", - "/acs/users/unsuspend", + "/thermostats/set_fallback_climate_preset", json: (object) $request_payload ); } - public function update( - string $acs_user_id, - mixed $access_schedule = null, - string $email = null, - string $email_address = null, - string $full_name = null, - string $hid_acs_system_id = null, - string $phone_number = null - ): void { + public function set_fan_mode( + string $device_id, + ?string $fan_mode = null, + ?string $fan_mode_setting = null, + ?bool $sync = null, + bool $wait_for_action_attempt = true + ): ActionAttempt { $request_payload = []; - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; - } - if ($access_schedule !== null) { - $request_payload["access_schedule"] = $access_schedule; - } - if ($email !== null) { - $request_payload["email"] = $email; - } - if ($email_address !== null) { - $request_payload["email_address"] = $email_address; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - if ($full_name !== null) { - $request_payload["full_name"] = $full_name; + if ($fan_mode !== null) { + $request_payload["fan_mode"] = $fan_mode; } - if ($hid_acs_system_id !== null) { - $request_payload["hid_acs_system_id"] = $hid_acs_system_id; + if ($fan_mode_setting !== null) { + $request_payload["fan_mode_setting"] = $fan_mode_setting; } - if ($phone_number !== null) { - $request_payload["phone_number"] = $phone_number; + if ($sync !== null) { + $request_payload["sync"] = $sync; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/acs/users/update", + "/thermostats/set_fan_mode", json: (object) $request_payload ); - } -} - -class AcsUsersUnmanagedClient -{ - private SeamClient $seam; - - public function __construct(SeamClient $seam) - { - $this->seam = $seam; - } - - public function get(string $acs_user_id): UnmanagedAcsUser - { - $request_payload = []; - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if (!$wait_for_action_attempt) { + return ActionAttempt::from_json($res->action_attempt); } - $res = $this->seam->request( - "POST", - "/acs/users/unmanaged/get", - json: (object) $request_payload, - inner_object: "acs_user" + $action_attempt = $this->seam->action_attempts->poll_until_ready( + $res->action_attempt->action_attempt_id ); - return UnmanagedAcsUser::from_json($res); + return $action_attempt; } - public function list( - string $acs_system_id = null, - float $limit = null, - string $user_identity_email_address = null, - string $user_identity_id = null, - string $user_identity_phone_number = null - ): array { + public function set_hvac_mode( + string $hvac_mode_setting, + string $device_id, + ?float $cooling_set_point_celsius = null, + ?float $cooling_set_point_fahrenheit = null, + ?float $heating_set_point_celsius = null, + ?float $heating_set_point_fahrenheit = null, + bool $wait_for_action_attempt = true + ): ActionAttempt { $request_payload = []; - if ($acs_system_id !== null) { - $request_payload["acs_system_id"] = $acs_system_id; + if ($hvac_mode_setting !== null) { + $request_payload["hvac_mode_setting"] = $hvac_mode_setting; } - if ($limit !== null) { - $request_payload["limit"] = $limit; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - if ($user_identity_email_address !== null) { + if ($cooling_set_point_celsius !== null) { $request_payload[ - "user_identity_email_address" - ] = $user_identity_email_address; + "cooling_set_point_celsius" + ] = $cooling_set_point_celsius; } - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; + if ($cooling_set_point_fahrenheit !== null) { + $request_payload[ + "cooling_set_point_fahrenheit" + ] = $cooling_set_point_fahrenheit; } - if ($user_identity_phone_number !== null) { + if ($heating_set_point_celsius !== null) { $request_payload[ - "user_identity_phone_number" - ] = $user_identity_phone_number; + "heating_set_point_celsius" + ] = $heating_set_point_celsius; + } + if ($heating_set_point_fahrenheit !== null) { + $request_payload[ + "heating_set_point_fahrenheit" + ] = $heating_set_point_fahrenheit; } $res = $this->seam->request( "POST", - "/acs/users/unmanaged/list", - json: (object) $request_payload, - inner_object: "acs_users" + "/thermostats/set_hvac_mode", + json: (object) $request_payload ); - return array_map(fn($r) => UnmanagedAcsUser::from_json($r), $res); - } -} + if (!$wait_for_action_attempt) { + return ActionAttempt::from_json($res->action_attempt); + } -class ActionAttemptsClient -{ - private SeamClient $seam; + $action_attempt = $this->seam->action_attempts->poll_until_ready( + $res->action_attempt->action_attempt_id + ); - public function __construct(SeamClient $seam) - { - $this->seam = $seam; + return $action_attempt; } - public function get(string $action_attempt_id): ActionAttempt - { + public function set_temperature_threshold( + string $device_id, + ?float $lower_limit_celsius = null, + ?float $lower_limit_fahrenheit = null, + ?float $upper_limit_celsius = null, + ?float $upper_limit_fahrenheit = null + ): void { $request_payload = []; - if ($action_attempt_id !== null) { - $request_payload["action_attempt_id"] = $action_attempt_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } + if ($lower_limit_celsius !== null) { + $request_payload["lower_limit_celsius"] = $lower_limit_celsius; + } + if ($lower_limit_fahrenheit !== null) { + $request_payload[ + "lower_limit_fahrenheit" + ] = $lower_limit_fahrenheit; + } + if ($upper_limit_celsius !== null) { + $request_payload["upper_limit_celsius"] = $upper_limit_celsius; + } + if ($upper_limit_fahrenheit !== null) { + $request_payload[ + "upper_limit_fahrenheit" + ] = $upper_limit_fahrenheit; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/action_attempts/get", - json: (object) $request_payload, - inner_object: "action_attempt" + "/thermostats/set_temperature_threshold", + json: (object) $request_payload ); - - return ActionAttempt::from_json($res); } - public function list(array $action_attempt_ids): array - { + public function update_climate_preset( + string $device_id, + string $climate_preset_key, + bool $manual_override_allowed, + ?string $name = null, + ?string $fan_mode_setting = null, + ?string $hvac_mode_setting = null, + ?float $cooling_set_point_celsius = null, + ?float $heating_set_point_celsius = null, + ?float $cooling_set_point_fahrenheit = null, + ?float $heating_set_point_fahrenheit = null + ): void { $request_payload = []; - if ($action_attempt_ids !== null) { - $request_payload["action_attempt_ids"] = $action_attempt_ids; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - - $res = $this->seam->request( - "POST", - "/action_attempts/list", - json: (object) $request_payload, - inner_object: "action_attempts" - ); - - return array_map(fn($r) => ActionAttempt::from_json($r), $res); - } - public function poll_until_ready( - string $action_attempt_id, - float $timeout = 20.0 - ): ActionAttempt { - $seam = $this->seam; - $time_waiting = 0.0; - $polling_interval = 0.4; - $action_attempt = $seam->action_attempts->get($action_attempt_id); - - while ($action_attempt->status == "pending") { - $action_attempt = $seam->action_attempts->get( - $action_attempt->action_attempt_id - ); - if ($time_waiting > $timeout) { - throw new ActionAttemptTimeoutError($action_attempt, $timeout); - } - $time_waiting += $polling_interval; - usleep($polling_interval * 1000000); + if ($climate_preset_key !== null) { + $request_payload["climate_preset_key"] = $climate_preset_key; } - - if ($action_attempt->status == "error") { - throw new ActionAttemptFailedError($action_attempt); + if ($manual_override_allowed !== null) { + $request_payload[ + "manual_override_allowed" + ] = $manual_override_allowed; + } + if ($name !== null) { + $request_payload["name"] = $name; + } + if ($fan_mode_setting !== null) { + $request_payload["fan_mode_setting"] = $fan_mode_setting; + } + if ($hvac_mode_setting !== null) { + $request_payload["hvac_mode_setting"] = $hvac_mode_setting; + } + if ($cooling_set_point_celsius !== null) { + $request_payload[ + "cooling_set_point_celsius" + ] = $cooling_set_point_celsius; + } + if ($heating_set_point_celsius !== null) { + $request_payload[ + "heating_set_point_celsius" + ] = $heating_set_point_celsius; + } + if ($cooling_set_point_fahrenheit !== null) { + $request_payload[ + "cooling_set_point_fahrenheit" + ] = $cooling_set_point_fahrenheit; + } + if ($heating_set_point_fahrenheit !== null) { + $request_payload[ + "heating_set_point_fahrenheit" + ] = $heating_set_point_fahrenheit; } - return $action_attempt; + $this->seam->request( + "POST", + "/thermostats/update_climate_preset", + json: (object) $request_payload + ); } } -class BridgesClient +class UserIdentitiesClient { private SeamClient $seam; - + public UserIdentitiesEnrollmentAutomationsClient $enrollment_automations; public function __construct(SeamClient $seam) { $this->seam = $seam; + $this->enrollment_automations = new UserIdentitiesEnrollmentAutomationsClient( + $seam + ); } - public function get(string $bridge_id): void - { + public function add_acs_user( + string $user_identity_id, + string $acs_user_id + ): void { $request_payload = []; - if ($bridge_id !== null) { - $request_payload["bridge_id"] = $bridge_id; + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; + } + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } $this->seam->request( "POST", - "/bridges/get", - json: (object) $request_payload, - inner_object: "bridge" - ); - } - - public function list(): void - { - $request_payload = []; - - $this->seam->request( - "POST", - "/bridges/list", - json: (object) $request_payload, - inner_object: "bridges" + "/user_identities/add_acs_user", + json: (object) $request_payload ); } -} - -class ClientSessionsClient -{ - private SeamClient $seam; - - public function __construct(SeamClient $seam) - { - $this->seam = $seam; - } public function create( - array $connect_webview_ids = null, - array $connected_account_ids = null, - string $expires_at = null, - string $user_identifier_key = null, - array $user_identity_ids = null - ): ClientSession { + ?string $user_identity_key = null, + ?string $email_address = null, + ?string $phone_number = null, + ?string $full_name = null + ): UserIdentity { $request_payload = []; - if ($connect_webview_ids !== null) { - $request_payload["connect_webview_ids"] = $connect_webview_ids; - } - if ($connected_account_ids !== null) { - $request_payload["connected_account_ids"] = $connected_account_ids; + if ($user_identity_key !== null) { + $request_payload["user_identity_key"] = $user_identity_key; } - if ($expires_at !== null) { - $request_payload["expires_at"] = $expires_at; + if ($email_address !== null) { + $request_payload["email_address"] = $email_address; } - if ($user_identifier_key !== null) { - $request_payload["user_identifier_key"] = $user_identifier_key; + if ($phone_number !== null) { + $request_payload["phone_number"] = $phone_number; } - if ($user_identity_ids !== null) { - $request_payload["user_identity_ids"] = $user_identity_ids; + if ($full_name !== null) { + $request_payload["full_name"] = $full_name; } $res = $this->seam->request( "POST", - "/client_sessions/create", - json: (object) $request_payload, - inner_object: "client_session" + "/user_identities/create", + json: (object) $request_payload ); - return ClientSession::from_json($res); + return UserIdentity::from_json($res->user_identity); } - public function delete(string $client_session_id): void + public function delete(string $user_identity_id): void { $request_payload = []; - if ($client_session_id !== null) { - $request_payload["client_session_id"] = $client_session_id; + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; } $this->seam->request( "POST", - "/client_sessions/delete", + "/user_identities/delete", json: (object) $request_payload ); } public function get( - string $client_session_id = null, - string $user_identifier_key = null - ): ClientSession { - $request_payload = []; - - if ($client_session_id !== null) { - $request_payload["client_session_id"] = $client_session_id; - } - if ($user_identifier_key !== null) { - $request_payload["user_identifier_key"] = $user_identifier_key; - } - - $res = $this->seam->request( - "POST", - "/client_sessions/get", - json: (object) $request_payload, - inner_object: "client_session" - ); - - return ClientSession::from_json($res); - } - - public function get_or_create( - array $connect_webview_ids = null, - array $connected_account_ids = null, - string $expires_at = null, - string $user_identifier_key = null, - array $user_identity_ids = null - ): ClientSession { + ?string $user_identity_id = null, + ?string $user_identity_key = null + ): UserIdentity { $request_payload = []; - if ($connect_webview_ids !== null) { - $request_payload["connect_webview_ids"] = $connect_webview_ids; - } - if ($connected_account_ids !== null) { - $request_payload["connected_account_ids"] = $connected_account_ids; - } - if ($expires_at !== null) { - $request_payload["expires_at"] = $expires_at; - } - if ($user_identifier_key !== null) { - $request_payload["user_identifier_key"] = $user_identifier_key; + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; } - if ($user_identity_ids !== null) { - $request_payload["user_identity_ids"] = $user_identity_ids; + if ($user_identity_key !== null) { + $request_payload["user_identity_key"] = $user_identity_key; } $res = $this->seam->request( "POST", - "/client_sessions/get_or_create", - json: (object) $request_payload, - inner_object: "client_session" + "/user_identities/get", + json: (object) $request_payload ); - return ClientSession::from_json($res); + return UserIdentity::from_json($res->user_identity); } - public function grant_access( - string $client_session_id = null, - array $connect_webview_ids = null, - array $connected_account_ids = null, - string $user_identifier_key = null, - array $user_identity_ids = null + public function grant_access_to_device( + string $user_identity_id, + string $device_id ): void { $request_payload = []; - if ($client_session_id !== null) { - $request_payload["client_session_id"] = $client_session_id; - } - if ($connect_webview_ids !== null) { - $request_payload["connect_webview_ids"] = $connect_webview_ids; - } - if ($connected_account_ids !== null) { - $request_payload["connected_account_ids"] = $connected_account_ids; - } - if ($user_identifier_key !== null) { - $request_payload["user_identifier_key"] = $user_identifier_key; + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; } - if ($user_identity_ids !== null) { - $request_payload["user_identity_ids"] = $user_identity_ids; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } $this->seam->request( "POST", - "/client_sessions/grant_access", + "/user_identities/grant_access_to_device", json: (object) $request_payload ); } public function list( - string $client_session_id = null, - string $connect_webview_id = null, - string $user_identifier_key = null, - string $user_identity_id = null, - bool $without_user_identifier_key = null + ?string $credential_manager_acs_system_id = null, + ?callable $on_response = null ): array { $request_payload = []; - if ($client_session_id !== null) { - $request_payload["client_session_id"] = $client_session_id; + if ($credential_manager_acs_system_id !== null) { + $request_payload[ + "credential_manager_acs_system_id" + ] = $credential_manager_acs_system_id; } - if ($connect_webview_id !== null) { - $request_payload["connect_webview_id"] = $connect_webview_id; - } - if ($user_identifier_key !== null) { - $request_payload["user_identifier_key"] = $user_identifier_key; + + $res = $this->seam->request( + "POST", + "/user_identities/list", + json: (object) $request_payload + ); + + if ($on_response !== null) { + $on_response($res); } + + return array_map( + fn($r) => UserIdentity::from_json($r), + $res->user_identities + ); + } + + public function list_accessible_devices(string $user_identity_id): array + { + $request_payload = []; + if ($user_identity_id !== null) { $request_payload["user_identity_id"] = $user_identity_id; } - if ($without_user_identifier_key !== null) { - $request_payload[ - "without_user_identifier_key" - ] = $without_user_identifier_key; - } $res = $this->seam->request( "POST", - "/client_sessions/list", - json: (object) $request_payload, - inner_object: "client_sessions" + "/user_identities/list_accessible_devices", + json: (object) $request_payload ); - return array_map(fn($r) => ClientSession::from_json($r), $res); + return array_map(fn($r) => Device::from_json($r), $res->devices); } - public function revoke(string $client_session_id): void + public function list_acs_systems(string $user_identity_id): array { $request_payload = []; - if ($client_session_id !== null) { - $request_payload["client_session_id"] = $client_session_id; + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/client_sessions/revoke", + "/user_identities/list_acs_systems", json: (object) $request_payload ); - } -} - -class ConnectWebviewsClient -{ - private SeamClient $seam; - public function __construct(SeamClient $seam) - { - $this->seam = $seam; + return array_map(fn($r) => AcsSystem::from_json($r), $res->acs_systems); } - public function create( - array $accepted_providers = null, - bool $automatically_manage_new_devices = null, - mixed $custom_metadata = null, - string $custom_redirect_failure_url = null, - string $custom_redirect_url = null, - string $device_selection_mode = null, - string $provider_category = null, - bool $wait_for_device_creation = null - ): ConnectWebview { + public function list_acs_users(string $user_identity_id): array + { $request_payload = []; - if ($accepted_providers !== null) { - $request_payload["accepted_providers"] = $accepted_providers; - } - if ($automatically_manage_new_devices !== null) { - $request_payload[ - "automatically_manage_new_devices" - ] = $automatically_manage_new_devices; - } - if ($custom_metadata !== null) { - $request_payload["custom_metadata"] = $custom_metadata; - } - if ($custom_redirect_failure_url !== null) { - $request_payload[ - "custom_redirect_failure_url" - ] = $custom_redirect_failure_url; - } - if ($custom_redirect_url !== null) { - $request_payload["custom_redirect_url"] = $custom_redirect_url; - } - if ($device_selection_mode !== null) { - $request_payload["device_selection_mode"] = $device_selection_mode; - } - if ($provider_category !== null) { - $request_payload["provider_category"] = $provider_category; - } - if ($wait_for_device_creation !== null) { - $request_payload[ - "wait_for_device_creation" - ] = $wait_for_device_creation; + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; } $res = $this->seam->request( "POST", - "/connect_webviews/create", - json: (object) $request_payload, - inner_object: "connect_webview" + "/user_identities/list_acs_users", + json: (object) $request_payload ); - return ConnectWebview::from_json($res); + return array_map(fn($r) => AcsUser::from_json($r), $res->acs_users); } - public function delete(string $connect_webview_id): void - { + public function remove_acs_user( + string $user_identity_id, + string $acs_user_id + ): void { $request_payload = []; - if ($connect_webview_id !== null) { - $request_payload["connect_webview_id"] = $connect_webview_id; + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; + } + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } $this->seam->request( "POST", - "/connect_webviews/delete", + "/user_identities/remove_acs_user", json: (object) $request_payload ); } - public function get(string $connect_webview_id): ConnectWebview - { + public function revoke_access_to_device( + string $user_identity_id, + string $device_id + ): void { $request_payload = []; - if ($connect_webview_id !== null) { - $request_payload["connect_webview_id"] = $connect_webview_id; + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; + } + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/connect_webviews/get", - json: (object) $request_payload, - inner_object: "connect_webview" + "/user_identities/revoke_access_to_device", + json: (object) $request_payload ); - - return ConnectWebview::from_json($res); } - public function list( - mixed $custom_metadata_has = null, - float $limit = null, - string $user_identifier_key = null - ): array { + public function update( + string $user_identity_id, + ?string $user_identity_key = null, + ?string $email_address = null, + ?string $phone_number = null, + ?string $full_name = null + ): void { $request_payload = []; - if ($custom_metadata_has !== null) { - $request_payload["custom_metadata_has"] = $custom_metadata_has; + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; } - if ($limit !== null) { - $request_payload["limit"] = $limit; + if ($user_identity_key !== null) { + $request_payload["user_identity_key"] = $user_identity_key; } - if ($user_identifier_key !== null) { - $request_payload["user_identifier_key"] = $user_identifier_key; + if ($email_address !== null) { + $request_payload["email_address"] = $email_address; + } + if ($phone_number !== null) { + $request_payload["phone_number"] = $phone_number; + } + if ($full_name !== null) { + $request_payload["full_name"] = $full_name; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/connect_webviews/list", - json: (object) $request_payload, - inner_object: "connect_webviews" + "/user_identities/update", + json: (object) $request_payload ); - - return array_map(fn($r) => ConnectWebview::from_json($r), $res); } } -class ConnectedAccountsClient +class WebhooksClient { private SeamClient $seam; @@ -2562,267 +2683,221 @@ public function __construct(SeamClient $seam) $this->seam = $seam; } - public function delete( - string $connected_account_id, - bool $sync = null - ): void { + public function create(string $url, ?array $event_types = null): Webhook + { $request_payload = []; - if ($connected_account_id !== null) { - $request_payload["connected_account_id"] = $connected_account_id; + if ($url !== null) { + $request_payload["url"] = $url; } - if ($sync !== null) { - $request_payload["sync"] = $sync; + if ($event_types !== null) { + $request_payload["event_types"] = $event_types; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/connected_accounts/delete", + "/webhooks/create", json: (object) $request_payload ); + + return Webhook::from_json($res->webhook); } - public function get( - string $connected_account_id = null, - string $email = null - ): ConnectedAccount { + public function delete(string $webhook_id): void + { $request_payload = []; - if ($connected_account_id !== null) { - $request_payload["connected_account_id"] = $connected_account_id; - } - if ($email !== null) { - $request_payload["email"] = $email; + if ($webhook_id !== null) { + $request_payload["webhook_id"] = $webhook_id; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/connected_accounts/get", - json: (object) $request_payload, - inner_object: "connected_account" + "/webhooks/delete", + json: (object) $request_payload ); - - return ConnectedAccount::from_json($res); } - public function list( - mixed $custom_metadata_has = null, - string $user_identifier_key = null - ): array { + public function get(string $webhook_id): Webhook + { $request_payload = []; - if ($custom_metadata_has !== null) { - $request_payload["custom_metadata_has"] = $custom_metadata_has; - } - if ($user_identifier_key !== null) { - $request_payload["user_identifier_key"] = $user_identifier_key; + if ($webhook_id !== null) { + $request_payload["webhook_id"] = $webhook_id; } $res = $this->seam->request( "POST", - "/connected_accounts/list", - json: (object) $request_payload, - inner_object: "connected_accounts" + "/webhooks/get", + json: (object) $request_payload ); - return array_map(fn($r) => ConnectedAccount::from_json($r), $res); + return Webhook::from_json($res->webhook); } - public function update( - string $connected_account_id, - bool $automatically_manage_new_devices = null, - mixed $custom_metadata = null - ): void { - $request_payload = []; + public function list(?callable $on_response = null): array + { + $res = $this->seam->request("POST", "/webhooks/list"); - if ($connected_account_id !== null) { - $request_payload["connected_account_id"] = $connected_account_id; + if ($on_response !== null) { + $on_response($res); } - if ($automatically_manage_new_devices !== null) { - $request_payload[ - "automatically_manage_new_devices" - ] = $automatically_manage_new_devices; + + return array_map(fn($r) => Webhook::from_json($r), $res->webhooks); + } + + public function update(string $webhook_id, array $event_types): void + { + $request_payload = []; + + if ($webhook_id !== null) { + $request_payload["webhook_id"] = $webhook_id; } - if ($custom_metadata !== null) { - $request_payload["custom_metadata"] = $custom_metadata; + if ($event_types !== null) { + $request_payload["event_types"] = $event_types; } $this->seam->request( "POST", - "/connected_accounts/update", + "/webhooks/update", json: (object) $request_payload ); } } -class DevicesClient +class WorkspacesClient { private SeamClient $seam; - public DevicesSimulateClient $simulate; - public DevicesUnmanagedClient $unmanaged; + public function __construct(SeamClient $seam) { $this->seam = $seam; - $this->simulate = new DevicesSimulateClient($seam); - $this->unmanaged = new DevicesUnmanagedClient($seam); - } - - public function delete(string $device_id): void - { - $request_payload = []; - - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - - $this->seam->request( - "POST", - "/devices/delete", - json: (object) $request_payload - ); } - public function get(string $device_id = null, string $name = null): Device - { + public function create( + string $name, + ?string $company_name = null, + ?string $connect_partner_name = null, + ?bool $is_sandbox = null, + ?string $webview_primary_button_color = null, + ?string $webview_primary_button_text_color = null, + ?string $webview_logo_shape = null, + ?string $webview_success_message = null + ): Workspace { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } if ($name !== null) { $request_payload["name"] = $name; } - - $res = $this->seam->request( - "POST", - "/devices/get", - json: (object) $request_payload, - inner_object: "device" - ); - - return Device::from_json($res); - } - - public function list( - string $connect_webview_id = null, - string $connected_account_id = null, - array $connected_account_ids = null, - string $created_before = null, - mixed $custom_metadata_has = null, - array $device_ids = null, - string $device_type = null, - array $device_types = null, - array $exclude_if = null, - array $include_if = null, - float $limit = null, - string $manufacturer = null, - string $user_identifier_key = null - ): array { - $request_payload = []; - - if ($connect_webview_id !== null) { - $request_payload["connect_webview_id"] = $connect_webview_id; - } - if ($connected_account_id !== null) { - $request_payload["connected_account_id"] = $connected_account_id; - } - if ($connected_account_ids !== null) { - $request_payload["connected_account_ids"] = $connected_account_ids; - } - if ($created_before !== null) { - $request_payload["created_before"] = $created_before; - } - if ($custom_metadata_has !== null) { - $request_payload["custom_metadata_has"] = $custom_metadata_has; - } - if ($device_ids !== null) { - $request_payload["device_ids"] = $device_ids; - } - if ($device_type !== null) { - $request_payload["device_type"] = $device_type; + if ($company_name !== null) { + $request_payload["company_name"] = $company_name; } - if ($device_types !== null) { - $request_payload["device_types"] = $device_types; + if ($connect_partner_name !== null) { + $request_payload["connect_partner_name"] = $connect_partner_name; } - if ($exclude_if !== null) { - $request_payload["exclude_if"] = $exclude_if; + if ($is_sandbox !== null) { + $request_payload["is_sandbox"] = $is_sandbox; } - if ($include_if !== null) { - $request_payload["include_if"] = $include_if; + if ($webview_primary_button_color !== null) { + $request_payload[ + "webview_primary_button_color" + ] = $webview_primary_button_color; } - if ($limit !== null) { - $request_payload["limit"] = $limit; + if ($webview_primary_button_text_color !== null) { + $request_payload[ + "webview_primary_button_text_color" + ] = $webview_primary_button_text_color; } - if ($manufacturer !== null) { - $request_payload["manufacturer"] = $manufacturer; + if ($webview_logo_shape !== null) { + $request_payload["webview_logo_shape"] = $webview_logo_shape; } - if ($user_identifier_key !== null) { - $request_payload["user_identifier_key"] = $user_identifier_key; + if ($webview_success_message !== null) { + $request_payload[ + "webview_success_message" + ] = $webview_success_message; } $res = $this->seam->request( "POST", - "/devices/list", - json: (object) $request_payload, - inner_object: "devices" + "/workspaces/create", + json: (object) $request_payload ); - return array_map(fn($r) => Device::from_json($r), $res); + return Workspace::from_json($res->workspace); } - public function list_device_providers( - string $provider_category = null - ): array { - $request_payload = []; + public function get(): Workspace + { + $res = $this->seam->request("POST", "/workspaces/get"); - if ($provider_category !== null) { - $request_payload["provider_category"] = $provider_category; + return Workspace::from_json($res->workspace); + } + + public function list(?callable $on_response = null): array + { + $res = $this->seam->request("POST", "/workspaces/list"); + + if ($on_response !== null) { + $on_response($res); } - $res = $this->seam->request( - "POST", - "/devices/list_device_providers", - json: (object) $request_payload, - inner_object: "device_providers" + return array_map(fn($r) => Workspace::from_json($r), $res->workspaces); + } + + public function reset_sandbox( + bool $wait_for_action_attempt = true + ): ActionAttempt { + $res = $this->seam->request("POST", "/workspaces/reset_sandbox"); + + if (!$wait_for_action_attempt) { + return ActionAttempt::from_json($res->action_attempt); + } + + $action_attempt = $this->seam->action_attempts->poll_until_ready( + $res->action_attempt->action_attempt_id ); - return array_map(fn($r) => DeviceProvider::from_json($r), $res); + return $action_attempt; } +} - public function update( +class AccessCodesSimulateClient +{ + private SeamClient $seam; + + public function __construct(SeamClient $seam) + { + $this->seam = $seam; + } + + public function create_unmanaged_access_code( string $device_id, - mixed $custom_metadata = null, - bool $is_managed = null, - string $name = null, - mixed $properties = null - ): void { + string $name, + string $code + ): UnmanagedAccessCode { $request_payload = []; if ($device_id !== null) { $request_payload["device_id"] = $device_id; } - if ($custom_metadata !== null) { - $request_payload["custom_metadata"] = $custom_metadata; - } - if ($is_managed !== null) { - $request_payload["is_managed"] = $is_managed; - } if ($name !== null) { $request_payload["name"] = $name; } - if ($properties !== null) { - $request_payload["properties"] = $properties; + if ($code !== null) { + $request_payload["code"] = $code; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/devices/update", + "/access_codes/simulate/create_unmanaged_access_code", json: (object) $request_payload ); + + return UnmanagedAccessCode::from_json($res->access_code); } } -class DevicesSimulateClient +class AccessCodesUnmanagedClient { private SeamClient $seam; @@ -2831,136 +2906,95 @@ public function __construct(SeamClient $seam) $this->seam = $seam; } - public function connect(string $device_id): void - { + public function convert_to_managed( + string $access_code_id, + ?bool $is_external_modification_allowed = null, + ?bool $allow_external_modification = null, + ?bool $force = null, + ?bool $sync = null + ): void { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($access_code_id !== null) { + $request_payload["access_code_id"] = $access_code_id; } - - $this->seam->request( - "POST", - "/devices/simulate/connect", - json: (object) $request_payload - ); - } - - public function disconnect(string $device_id): void - { - $request_payload = []; - - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($is_external_modification_allowed !== null) { + $request_payload[ + "is_external_modification_allowed" + ] = $is_external_modification_allowed; + } + if ($allow_external_modification !== null) { + $request_payload[ + "allow_external_modification" + ] = $allow_external_modification; + } + if ($force !== null) { + $request_payload["force"] = $force; + } + if ($sync !== null) { + $request_payload["sync"] = $sync; } $this->seam->request( "POST", - "/devices/simulate/disconnect", + "/access_codes/unmanaged/convert_to_managed", json: (object) $request_payload ); } - public function remove(string $device_id): void + public function delete(string $access_code_id, ?bool $sync = null): void { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($access_code_id !== null) { + $request_payload["access_code_id"] = $access_code_id; + } + if ($sync !== null) { + $request_payload["sync"] = $sync; } $this->seam->request( "POST", - "/devices/simulate/remove", + "/access_codes/unmanaged/delete", json: (object) $request_payload ); } -} - -class DevicesUnmanagedClient -{ - private SeamClient $seam; - - public function __construct(SeamClient $seam) - { - $this->seam = $seam; - } public function get( - string $device_id = null, - string $name = null - ): UnmanagedDevice { + ?string $device_id = null, + ?string $access_code_id = null, + ?string $code = null + ): UnmanagedAccessCode { $request_payload = []; if ($device_id !== null) { $request_payload["device_id"] = $device_id; } - if ($name !== null) { - $request_payload["name"] = $name; + if ($access_code_id !== null) { + $request_payload["access_code_id"] = $access_code_id; + } + if ($code !== null) { + $request_payload["code"] = $code; } $res = $this->seam->request( "POST", - "/devices/unmanaged/get", - json: (object) $request_payload, - inner_object: "device" + "/access_codes/unmanaged/get", + json: (object) $request_payload ); - return UnmanagedDevice::from_json($res); + return UnmanagedAccessCode::from_json($res->access_code); } public function list( - string $connect_webview_id = null, - string $connected_account_id = null, - array $connected_account_ids = null, - string $created_before = null, - mixed $custom_metadata_has = null, - array $device_ids = null, - string $device_type = null, - array $device_types = null, - array $exclude_if = null, - array $include_if = null, - float $limit = null, - string $manufacturer = null, - string $user_identifier_key = null + string $device_id, + ?string $user_identifier_key = null, + ?callable $on_response = null ): array { $request_payload = []; - if ($connect_webview_id !== null) { - $request_payload["connect_webview_id"] = $connect_webview_id; - } - if ($connected_account_id !== null) { - $request_payload["connected_account_id"] = $connected_account_id; - } - if ($connected_account_ids !== null) { - $request_payload["connected_account_ids"] = $connected_account_ids; - } - if ($created_before !== null) { - $request_payload["created_before"] = $created_before; - } - if ($custom_metadata_has !== null) { - $request_payload["custom_metadata_has"] = $custom_metadata_has; - } - if ($device_ids !== null) { - $request_payload["device_ids"] = $device_ids; - } - if ($device_type !== null) { - $request_payload["device_type"] = $device_type; - } - if ($device_types !== null) { - $request_payload["device_types"] = $device_types; - } - if ($exclude_if !== null) { - $request_payload["exclude_if"] = $exclude_if; - } - if ($include_if !== null) { - $request_payload["include_if"] = $include_if; - } - if ($limit !== null) { - $request_payload["limit"] = $limit; - } - if ($manufacturer !== null) { - $request_payload["manufacturer"] = $manufacturer; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } if ($user_identifier_key !== null) { $request_payload["user_identifier_key"] = $user_identifier_key; @@ -2968,34 +3002,58 @@ public function list( $res = $this->seam->request( "POST", - "/devices/unmanaged/list", - json: (object) $request_payload, - inner_object: "devices" + "/access_codes/unmanaged/list", + json: (object) $request_payload ); - return array_map(fn($r) => UnmanagedDevice::from_json($r), $res); + if ($on_response !== null) { + $on_response($res); + } + + return array_map( + fn($r) => UnmanagedAccessCode::from_json($r), + $res->access_codes + ); } - public function update(string $device_id, bool $is_managed): void - { + public function update( + string $access_code_id, + bool $is_managed, + ?bool $allow_external_modification = null, + ?bool $is_external_modification_allowed = null, + ?bool $force = null + ): void { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($access_code_id !== null) { + $request_payload["access_code_id"] = $access_code_id; } if ($is_managed !== null) { $request_payload["is_managed"] = $is_managed; } + if ($allow_external_modification !== null) { + $request_payload[ + "allow_external_modification" + ] = $allow_external_modification; + } + if ($is_external_modification_allowed !== null) { + $request_payload[ + "is_external_modification_allowed" + ] = $is_external_modification_allowed; + } + if ($force !== null) { + $request_payload["force"] = $force; + } - $this->seam->request( - "POST", - "/devices/unmanaged/update", - json: (object) $request_payload - ); - } -} - -class EventsClient + $this->seam->request( + "POST", + "/access_codes/unmanaged/update", + json: (object) $request_payload + ); + } +} + +class AcsAccessGroupsClient { private SeamClient $seam; @@ -3004,268 +3062,154 @@ public function __construct(SeamClient $seam) $this->seam = $seam; } - public function get( - string $device_id = null, - string $event_id = null, - string $event_type = null - ): Event { + public function add_user( + string $acs_access_group_id, + string $acs_user_id + ): void { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($event_id !== null) { - $request_payload["event_id"] = $event_id; + if ($acs_access_group_id !== null) { + $request_payload["acs_access_group_id"] = $acs_access_group_id; } - if ($event_type !== null) { - $request_payload["event_type"] = $event_type; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/events/get", - json: (object) $request_payload, - inner_object: "event" + "/acs/access_groups/add_user", + json: (object) $request_payload ); - - return Event::from_json($res); } - public function list( - string $access_code_id = null, - array $access_code_ids = null, - string $acs_system_id = null, - array $acs_system_ids = null, - array $between = null, - string $connect_webview_id = null, - string $connected_account_id = null, - string $device_id = null, - array $device_ids = null, - string $event_type = null, - array $event_types = null, - float $limit = null, - string $since = null, - float $unstable_offset = null - ): array { + public function get(string $acs_access_group_id): AcsAccessGroup + { $request_payload = []; - if ($access_code_id !== null) { - $request_payload["access_code_id"] = $access_code_id; - } - if ($access_code_ids !== null) { - $request_payload["access_code_ids"] = $access_code_ids; - } - if ($acs_system_id !== null) { - $request_payload["acs_system_id"] = $acs_system_id; - } - if ($acs_system_ids !== null) { - $request_payload["acs_system_ids"] = $acs_system_ids; - } - if ($between !== null) { - $request_payload["between"] = $between; - } - if ($connect_webview_id !== null) { - $request_payload["connect_webview_id"] = $connect_webview_id; - } - if ($connected_account_id !== null) { - $request_payload["connected_account_id"] = $connected_account_id; - } - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($device_ids !== null) { - $request_payload["device_ids"] = $device_ids; - } - if ($event_type !== null) { - $request_payload["event_type"] = $event_type; - } - if ($event_types !== null) { - $request_payload["event_types"] = $event_types; - } - if ($limit !== null) { - $request_payload["limit"] = $limit; - } - if ($since !== null) { - $request_payload["since"] = $since; - } - if ($unstable_offset !== null) { - $request_payload["unstable_offset"] = $unstable_offset; + if ($acs_access_group_id !== null) { + $request_payload["acs_access_group_id"] = $acs_access_group_id; } $res = $this->seam->request( "POST", - "/events/list", - json: (object) $request_payload, - inner_object: "events" + "/acs/access_groups/get", + json: (object) $request_payload ); - return array_map(fn($r) => Event::from_json($r), $res); - } -} - -class LocksClient -{ - private SeamClient $seam; - - public function __construct(SeamClient $seam) - { - $this->seam = $seam; + return AcsAccessGroup::from_json($res->acs_access_group); } - public function get(string $device_id = null, string $name = null): Device - { + public function list( + ?string $acs_system_id = null, + ?string $acs_user_id = null, + ?callable $on_response = null + ): array { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($acs_system_id !== null) { + $request_payload["acs_system_id"] = $acs_system_id; } - if ($name !== null) { - $request_payload["name"] = $name; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } $res = $this->seam->request( "POST", - "/locks/get", - json: (object) $request_payload, - inner_object: "device" + "/acs/access_groups/list", + json: (object) $request_payload ); - return Device::from_json($res); + if ($on_response !== null) { + $on_response($res); + } + + return array_map( + fn($r) => AcsAccessGroup::from_json($r), + $res->acs_access_groups + ); } - public function list( - string $connect_webview_id = null, - string $connected_account_id = null, - array $connected_account_ids = null, - string $created_before = null, - mixed $custom_metadata_has = null, - array $device_ids = null, - string $device_type = null, - array $device_types = null, - array $exclude_if = null, - array $include_if = null, - float $limit = null, - string $manufacturer = null, - string $user_identifier_key = null + public function list_accessible_entrances( + string $acs_access_group_id ): array { $request_payload = []; - if ($connect_webview_id !== null) { - $request_payload["connect_webview_id"] = $connect_webview_id; - } - if ($connected_account_id !== null) { - $request_payload["connected_account_id"] = $connected_account_id; - } - if ($connected_account_ids !== null) { - $request_payload["connected_account_ids"] = $connected_account_ids; - } - if ($created_before !== null) { - $request_payload["created_before"] = $created_before; - } - if ($custom_metadata_has !== null) { - $request_payload["custom_metadata_has"] = $custom_metadata_has; - } - if ($device_ids !== null) { - $request_payload["device_ids"] = $device_ids; - } - if ($device_type !== null) { - $request_payload["device_type"] = $device_type; - } - if ($device_types !== null) { - $request_payload["device_types"] = $device_types; - } - if ($exclude_if !== null) { - $request_payload["exclude_if"] = $exclude_if; - } - if ($include_if !== null) { - $request_payload["include_if"] = $include_if; - } - if ($limit !== null) { - $request_payload["limit"] = $limit; - } - if ($manufacturer !== null) { - $request_payload["manufacturer"] = $manufacturer; - } - if ($user_identifier_key !== null) { - $request_payload["user_identifier_key"] = $user_identifier_key; + if ($acs_access_group_id !== null) { + $request_payload["acs_access_group_id"] = $acs_access_group_id; } $res = $this->seam->request( "POST", - "/locks/list", - json: (object) $request_payload, - inner_object: "devices" + "/acs/access_groups/list_accessible_entrances", + json: (object) $request_payload ); - return array_map(fn($r) => Device::from_json($r), $res); + return array_map( + fn($r) => AcsEntrance::from_json($r), + $res->acs_entrances + ); } - public function lock_door( - string $device_id, - bool $sync = null, - bool $wait_for_action_attempt = true - ): ActionAttempt { + public function list_users(string $acs_access_group_id): array + { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($sync !== null) { - $request_payload["sync"] = $sync; + if ($acs_access_group_id !== null) { + $request_payload["acs_access_group_id"] = $acs_access_group_id; } $res = $this->seam->request( "POST", - "/locks/lock_door", - json: (object) $request_payload, - inner_object: "action_attempt" - ); - - if (!$wait_for_action_attempt) { - return ActionAttempt::from_json($res); - } - - $action_attempt = $this->seam->action_attempts->poll_until_ready( - $res->action_attempt_id + "/acs/access_groups/list_users", + json: (object) $request_payload ); - return $action_attempt; + return array_map(fn($r) => AcsUser::from_json($r), $res->acs_users); } - public function unlock_door( - string $device_id, - bool $sync = null, - bool $wait_for_action_attempt = true - ): ActionAttempt { + public function remove_user( + string $acs_access_group_id, + string $acs_user_id + ): void { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($acs_access_group_id !== null) { + $request_payload["acs_access_group_id"] = $acs_access_group_id; } - if ($sync !== null) { - $request_payload["sync"] = $sync; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/locks/unlock_door", - json: (object) $request_payload, - inner_object: "action_attempt" - ); - - if (!$wait_for_action_attempt) { - return ActionAttempt::from_json($res); - } - - $action_attempt = $this->seam->action_attempts->poll_until_ready( - $res->action_attempt_id + "/acs/access_groups/remove_user", + json: (object) $request_payload ); + } +} - return $action_attempt; +class AcsClient +{ + private SeamClient $seam; + public AcsAccessGroupsClient $access_groups; + public AcsCredentialsClient $credentials; + public AcsEncodersClient $encoders; + public AcsEntrancesClient $entrances; + public AcsSystemsClient $systems; + public AcsUsersClient $users; + public function __construct(SeamClient $seam) + { + $this->seam = $seam; + $this->access_groups = new AcsAccessGroupsClient($seam); + $this->credentials = new AcsCredentialsClient($seam); + $this->encoders = new AcsEncodersClient($seam); + $this->entrances = new AcsEntrancesClient($seam); + $this->systems = new AcsSystemsClient($seam); + $this->users = new AcsUsersClient($seam); } } -class NetworksClient +class AcsCredentialsClient { private SeamClient $seam; @@ -3274,284 +3218,236 @@ public function __construct(SeamClient $seam) $this->seam = $seam; } - public function get(string $network_id): Network + public function assign(string $acs_user_id, string $acs_credential_id): void { $request_payload = []; - if ($network_id !== null) { - $request_payload["network_id"] = $network_id; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; + } + if ($acs_credential_id !== null) { + $request_payload["acs_credential_id"] = $acs_credential_id; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/networks/get", - json: (object) $request_payload, - inner_object: "network" - ); - - return Network::from_json($res); - } - - public function list(): array - { - $request_payload = []; - - $res = $this->seam->request( - "POST", - "/networks/list", - json: (object) $request_payload, - inner_object: "networks" + "/acs/credentials/assign", + json: (object) $request_payload ); - - return array_map(fn($r) => Network::from_json($r), $res); - } -} - -class NoiseSensorsClient -{ - private SeamClient $seam; - public NoiseSensorsNoiseThresholdsClient $noise_thresholds; - public NoiseSensorsSimulateClient $simulate; - public function __construct(SeamClient $seam) - { - $this->seam = $seam; - $this->noise_thresholds = new NoiseSensorsNoiseThresholdsClient($seam); - $this->simulate = new NoiseSensorsSimulateClient($seam); } - public function list( - string $connect_webview_id = null, - string $connected_account_id = null, - array $connected_account_ids = null, - string $created_before = null, - mixed $custom_metadata_has = null, - array $device_ids = null, - string $device_type = null, - array $device_types = null, - array $exclude_if = null, - array $include_if = null, - float $limit = null, - string $manufacturer = null, - string $user_identifier_key = null - ): array { + public function create( + string $acs_user_id, + string $access_method, + ?string $credential_manager_acs_system_id = null, + ?string $code = null, + ?bool $is_multi_phone_sync_credential = null, + ?array $allowed_acs_entrance_ids = null, + mixed $visionline_metadata = null, + mixed $assa_abloy_vostio_metadata = null, + mixed $salto_space_metadata = null, + ?string $starts_at = null, + ?string $ends_at = null + ): AcsCredential { $request_payload = []; - if ($connect_webview_id !== null) { - $request_payload["connect_webview_id"] = $connect_webview_id; - } - if ($connected_account_id !== null) { - $request_payload["connected_account_id"] = $connected_account_id; - } - if ($connected_account_ids !== null) { - $request_payload["connected_account_ids"] = $connected_account_ids; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } - if ($created_before !== null) { - $request_payload["created_before"] = $created_before; + if ($access_method !== null) { + $request_payload["access_method"] = $access_method; } - if ($custom_metadata_has !== null) { - $request_payload["custom_metadata_has"] = $custom_metadata_has; + if ($credential_manager_acs_system_id !== null) { + $request_payload[ + "credential_manager_acs_system_id" + ] = $credential_manager_acs_system_id; } - if ($device_ids !== null) { - $request_payload["device_ids"] = $device_ids; + if ($code !== null) { + $request_payload["code"] = $code; } - if ($device_type !== null) { - $request_payload["device_type"] = $device_type; + if ($is_multi_phone_sync_credential !== null) { + $request_payload[ + "is_multi_phone_sync_credential" + ] = $is_multi_phone_sync_credential; } - if ($device_types !== null) { - $request_payload["device_types"] = $device_types; + if ($allowed_acs_entrance_ids !== null) { + $request_payload[ + "allowed_acs_entrance_ids" + ] = $allowed_acs_entrance_ids; } - if ($exclude_if !== null) { - $request_payload["exclude_if"] = $exclude_if; + if ($visionline_metadata !== null) { + $request_payload["visionline_metadata"] = $visionline_metadata; } - if ($include_if !== null) { - $request_payload["include_if"] = $include_if; + if ($assa_abloy_vostio_metadata !== null) { + $request_payload[ + "assa_abloy_vostio_metadata" + ] = $assa_abloy_vostio_metadata; } - if ($limit !== null) { - $request_payload["limit"] = $limit; + if ($salto_space_metadata !== null) { + $request_payload["salto_space_metadata"] = $salto_space_metadata; } - if ($manufacturer !== null) { - $request_payload["manufacturer"] = $manufacturer; + if ($starts_at !== null) { + $request_payload["starts_at"] = $starts_at; } - if ($user_identifier_key !== null) { - $request_payload["user_identifier_key"] = $user_identifier_key; + if ($ends_at !== null) { + $request_payload["ends_at"] = $ends_at; } $res = $this->seam->request( "POST", - "/noise_sensors/list", - json: (object) $request_payload, - inner_object: "devices" + "/acs/credentials/create", + json: (object) $request_payload ); - return array_map(fn($r) => Device::from_json($r), $res); + return AcsCredential::from_json($res->acs_credential); } -} - -class NoiseSensorsNoiseThresholdsClient -{ - private SeamClient $seam; - public function __construct(SeamClient $seam) + public function delete(string $acs_credential_id): void { - $this->seam = $seam; + $request_payload = []; + + if ($acs_credential_id !== null) { + $request_payload["acs_credential_id"] = $acs_credential_id; + } + + $this->seam->request( + "POST", + "/acs/credentials/delete", + json: (object) $request_payload + ); } - public function create( - string $device_id, - string $ends_daily_at, - string $starts_daily_at, - string $name = null, - float $noise_threshold_decibels = null, - float $noise_threshold_nrs = null, - bool $sync = null - ): NoiseThreshold { + public function get(string $acs_credential_id): AcsCredential + { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($ends_daily_at !== null) { - $request_payload["ends_daily_at"] = $ends_daily_at; - } - if ($starts_daily_at !== null) { - $request_payload["starts_daily_at"] = $starts_daily_at; - } - if ($name !== null) { - $request_payload["name"] = $name; - } - if ($noise_threshold_decibels !== null) { - $request_payload[ - "noise_threshold_decibels" - ] = $noise_threshold_decibels; - } - if ($noise_threshold_nrs !== null) { - $request_payload["noise_threshold_nrs"] = $noise_threshold_nrs; - } - if ($sync !== null) { - $request_payload["sync"] = $sync; + if ($acs_credential_id !== null) { + $request_payload["acs_credential_id"] = $acs_credential_id; } $res = $this->seam->request( "POST", - "/noise_sensors/noise_thresholds/create", - json: (object) $request_payload, - inner_object: "noise_threshold" + "/acs/credentials/get", + json: (object) $request_payload ); - return NoiseThreshold::from_json($res); + return AcsCredential::from_json($res->acs_credential); } - public function delete( - string $device_id, - string $noise_threshold_id, - bool $sync = null - ): void { + public function list( + ?string $acs_user_id = null, + ?string $acs_system_id = null, + ?string $user_identity_id = null, + ?float $limit = null, + ?string $created_before = null, + ?bool $is_multi_phone_sync_credential = null, + ?callable $on_response = null + ): array { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } - if ($noise_threshold_id !== null) { - $request_payload["noise_threshold_id"] = $noise_threshold_id; + if ($acs_system_id !== null) { + $request_payload["acs_system_id"] = $acs_system_id; } - if ($sync !== null) { - $request_payload["sync"] = $sync; + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; + } + if ($limit !== null) { + $request_payload["limit"] = $limit; + } + if ($created_before !== null) { + $request_payload["created_before"] = $created_before; + } + if ($is_multi_phone_sync_credential !== null) { + $request_payload[ + "is_multi_phone_sync_credential" + ] = $is_multi_phone_sync_credential; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/noise_sensors/noise_thresholds/delete", + "/acs/credentials/list", json: (object) $request_payload ); + + if ($on_response !== null) { + $on_response($res); + } + + return array_map( + fn($r) => AcsCredential::from_json($r), + $res->acs_credentials + ); } - public function get(string $noise_threshold_id): NoiseThreshold + public function list_accessible_entrances(string $acs_credential_id): array { $request_payload = []; - if ($noise_threshold_id !== null) { - $request_payload["noise_threshold_id"] = $noise_threshold_id; + if ($acs_credential_id !== null) { + $request_payload["acs_credential_id"] = $acs_credential_id; } $res = $this->seam->request( "POST", - "/noise_sensors/noise_thresholds/get", - json: (object) $request_payload, - inner_object: "noise_threshold" + "/acs/credentials/list_accessible_entrances", + json: (object) $request_payload ); - return NoiseThreshold::from_json($res); + return array_map( + fn($r) => AcsEntrance::from_json($r), + $res->acs_entrances + ); } - public function list(string $device_id, bool $is_programmed = null): array - { + public function unassign( + string $acs_user_id, + string $acs_credential_id + ): void { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } - if ($is_programmed !== null) { - $request_payload["is_programmed"] = $is_programmed; + if ($acs_credential_id !== null) { + $request_payload["acs_credential_id"] = $acs_credential_id; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/noise_sensors/noise_thresholds/list", - json: (object) $request_payload, - inner_object: "noise_thresholds" + "/acs/credentials/unassign", + json: (object) $request_payload ); - - return array_map(fn($r) => NoiseThreshold::from_json($r), $res); } public function update( - string $device_id, - string $noise_threshold_id, - string $ends_daily_at = null, - string $name = null, - float $noise_threshold_decibels = null, - float $noise_threshold_nrs = null, - string $starts_daily_at = null, - bool $sync = null + string $acs_credential_id, + ?string $code = null, + ?string $ends_at = null ): void { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($noise_threshold_id !== null) { - $request_payload["noise_threshold_id"] = $noise_threshold_id; - } - if ($ends_daily_at !== null) { - $request_payload["ends_daily_at"] = $ends_daily_at; - } - if ($name !== null) { - $request_payload["name"] = $name; - } - if ($noise_threshold_decibels !== null) { - $request_payload[ - "noise_threshold_decibels" - ] = $noise_threshold_decibels; - } - if ($noise_threshold_nrs !== null) { - $request_payload["noise_threshold_nrs"] = $noise_threshold_nrs; + if ($acs_credential_id !== null) { + $request_payload["acs_credential_id"] = $acs_credential_id; } - if ($starts_daily_at !== null) { - $request_payload["starts_daily_at"] = $starts_daily_at; + if ($code !== null) { + $request_payload["code"] = $code; } - if ($sync !== null) { - $request_payload["sync"] = $sync; + if ($ends_at !== null) { + $request_payload["ends_at"] = $ends_at; } $this->seam->request( "POST", - "/noise_sensors/noise_thresholds/update", + "/acs/credentials/update", json: (object) $request_payload ); } } -class NoiseSensorsSimulateClient +class AcsEncodersClient { private SeamClient $seam; @@ -3560,740 +3456,562 @@ public function __construct(SeamClient $seam) $this->seam = $seam; } - public function trigger_noise_threshold(string $device_id): void - { - $request_payload = []; - - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + public function encode_credential( + string $acs_encoder_id, + string $acs_credential_id, + bool $wait_for_action_attempt = true + ): ActionAttempt { + $request_payload = []; + + if ($acs_encoder_id !== null) { + $request_payload["acs_encoder_id"] = $acs_encoder_id; + } + if ($acs_credential_id !== null) { + $request_payload["acs_credential_id"] = $acs_credential_id; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/noise_sensors/simulate/trigger_noise_threshold", + "/acs/encoders/encode_credential", json: (object) $request_payload ); + + if (!$wait_for_action_attempt) { + return ActionAttempt::from_json($res->action_attempt); + } + + $action_attempt = $this->seam->action_attempts->poll_until_ready( + $res->action_attempt->action_attempt_id + ); + + return $action_attempt; + } + + public function list( + ?string $acs_system_id = null, + ?float $limit = null, + ?array $acs_system_ids = null, + ?array $acs_encoder_ids = null, + ?callable $on_response = null + ): array { + $request_payload = []; + + if ($acs_system_id !== null) { + $request_payload["acs_system_id"] = $acs_system_id; + } + if ($limit !== null) { + $request_payload["limit"] = $limit; + } + if ($acs_system_ids !== null) { + $request_payload["acs_system_ids"] = $acs_system_ids; + } + if ($acs_encoder_ids !== null) { + $request_payload["acs_encoder_ids"] = $acs_encoder_ids; + } + + $res = $this->seam->request( + "POST", + "/acs/encoders/list", + json: (object) $request_payload + ); + + if ($on_response !== null) { + $on_response($res); + } + + return array_map( + fn($r) => AcsEncoder::from_json($r), + $res->acs_encoders + ); + } + + public function scan_credential( + string $acs_encoder_id, + bool $wait_for_action_attempt = true + ): ActionAttempt { + $request_payload = []; + + if ($acs_encoder_id !== null) { + $request_payload["acs_encoder_id"] = $acs_encoder_id; + } + + $res = $this->seam->request( + "POST", + "/acs/encoders/scan_credential", + json: (object) $request_payload + ); + + if (!$wait_for_action_attempt) { + return ActionAttempt::from_json($res->action_attempt); + } + + $action_attempt = $this->seam->action_attempts->poll_until_ready( + $res->action_attempt->action_attempt_id + ); + + return $action_attempt; } } -class PhonesClient +class AcsEntrancesClient { private SeamClient $seam; - public PhonesSimulateClient $simulate; + public function __construct(SeamClient $seam) { $this->seam = $seam; - $this->simulate = new PhonesSimulateClient($seam); } - public function deactivate(string $device_id): void + public function get(string $acs_entrance_id): AcsEntrance { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($acs_entrance_id !== null) { + $request_payload["acs_entrance_id"] = $acs_entrance_id; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/phones/deactivate", + "/acs/entrances/get", json: (object) $request_payload ); + + return AcsEntrance::from_json($res->acs_entrance); } - public function get(string $device_id): Phone - { + public function grant_access( + string $acs_entrance_id, + string $acs_user_id + ): void { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($acs_entrance_id !== null) { + $request_payload["acs_entrance_id"] = $acs_entrance_id; + } + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/phones/get", - json: (object) $request_payload, - inner_object: "phone" + "/acs/entrances/grant_access", + json: (object) $request_payload ); - - return Phone::from_json($res); } public function list( - string $acs_credential_id = null, - string $owner_user_identity_id = null + ?string $acs_system_id = null, + ?string $acs_credential_id = null, + ?callable $on_response = null ): array { $request_payload = []; + if ($acs_system_id !== null) { + $request_payload["acs_system_id"] = $acs_system_id; + } if ($acs_credential_id !== null) { $request_payload["acs_credential_id"] = $acs_credential_id; } - if ($owner_user_identity_id !== null) { - $request_payload[ - "owner_user_identity_id" - ] = $owner_user_identity_id; - } $res = $this->seam->request( "POST", - "/phones/list", - json: (object) $request_payload, - inner_object: "phones" + "/acs/entrances/list", + json: (object) $request_payload ); - return array_map(fn($r) => Phone::from_json($r), $res); - } -} - -class PhonesSimulateClient -{ - private SeamClient $seam; + if ($on_response !== null) { + $on_response($res); + } - public function __construct(SeamClient $seam) - { - $this->seam = $seam; + return array_map( + fn($r) => AcsEntrance::from_json($r), + $res->acs_entrances + ); } - public function create_sandbox_phone( - string $user_identity_id, - mixed $assa_abloy_metadata = null, - string $custom_sdk_installation_id = null, - mixed $phone_metadata = null - ): Phone { + public function list_credentials_with_access( + string $acs_entrance_id, + ?array $include_if = null + ): array { $request_payload = []; - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; - } - if ($assa_abloy_metadata !== null) { - $request_payload["assa_abloy_metadata"] = $assa_abloy_metadata; - } - if ($custom_sdk_installation_id !== null) { - $request_payload[ - "custom_sdk_installation_id" - ] = $custom_sdk_installation_id; + if ($acs_entrance_id !== null) { + $request_payload["acs_entrance_id"] = $acs_entrance_id; } - if ($phone_metadata !== null) { - $request_payload["phone_metadata"] = $phone_metadata; + if ($include_if !== null) { + $request_payload["include_if"] = $include_if; } $res = $this->seam->request( "POST", - "/phones/simulate/create_sandbox_phone", - json: (object) $request_payload, - inner_object: "phone" + "/acs/entrances/list_credentials_with_access", + json: (object) $request_payload ); - return Phone::from_json($res); + return array_map( + fn($r) => AcsCredential::from_json($r), + $res->acs_credentials + ); } } -class ThermostatsClient +class AcsSystemsClient { private SeamClient $seam; - public ThermostatsSchedulesClient $schedules; - public ThermostatsSimulateClient $simulate; + public function __construct(SeamClient $seam) { $this->seam = $seam; - $this->schedules = new ThermostatsSchedulesClient($seam); - $this->simulate = new ThermostatsSimulateClient($seam); } - public function activate_climate_preset( - string $climate_preset_key, - string $device_id, - bool $wait_for_action_attempt = true - ): ActionAttempt { + public function get(string $acs_system_id): AcsSystem + { $request_payload = []; - if ($climate_preset_key !== null) { - $request_payload["climate_preset_key"] = $climate_preset_key; - } - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($acs_system_id !== null) { + $request_payload["acs_system_id"] = $acs_system_id; } $res = $this->seam->request( "POST", - "/thermostats/activate_climate_preset", - json: (object) $request_payload, - inner_object: "action_attempt" - ); - - if (!$wait_for_action_attempt) { - return ActionAttempt::from_json($res); - } - - $action_attempt = $this->seam->action_attempts->poll_until_ready( - $res->action_attempt_id + "/acs/systems/get", + json: (object) $request_payload ); - return $action_attempt; + return AcsSystem::from_json($res->acs_system); } - public function cool( - string $device_id, - float $cooling_set_point_celsius = null, - float $cooling_set_point_fahrenheit = null, - bool $sync = null, - bool $wait_for_action_attempt = true - ): ActionAttempt { + public function list( + ?string $connected_account_id = null, + ?callable $on_response = null + ): array { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($cooling_set_point_celsius !== null) { - $request_payload[ - "cooling_set_point_celsius" - ] = $cooling_set_point_celsius; - } - if ($cooling_set_point_fahrenheit !== null) { - $request_payload[ - "cooling_set_point_fahrenheit" - ] = $cooling_set_point_fahrenheit; - } - if ($sync !== null) { - $request_payload["sync"] = $sync; + if ($connected_account_id !== null) { + $request_payload["connected_account_id"] = $connected_account_id; } $res = $this->seam->request( "POST", - "/thermostats/cool", - json: (object) $request_payload, - inner_object: "action_attempt" + "/acs/systems/list", + json: (object) $request_payload ); - if (!$wait_for_action_attempt) { - return ActionAttempt::from_json($res); + if ($on_response !== null) { + $on_response($res); } - $action_attempt = $this->seam->action_attempts->poll_until_ready( - $res->action_attempt_id - ); - - return $action_attempt; + return array_map(fn($r) => AcsSystem::from_json($r), $res->acs_systems); } - public function create_climate_preset( - string $climate_preset_key, - string $device_id, - float $cooling_set_point_celsius = null, - float $cooling_set_point_fahrenheit = null, - string $fan_mode_setting = null, - float $heating_set_point_celsius = null, - float $heating_set_point_fahrenheit = null, - string $hvac_mode_setting = null, - bool $manual_override_allowed = null, - string $name = null - ): void { + public function list_compatible_credential_manager_acs_systems( + string $acs_system_id + ): array { $request_payload = []; - if ($climate_preset_key !== null) { - $request_payload["climate_preset_key"] = $climate_preset_key; - } - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($cooling_set_point_celsius !== null) { - $request_payload[ - "cooling_set_point_celsius" - ] = $cooling_set_point_celsius; - } - if ($cooling_set_point_fahrenheit !== null) { - $request_payload[ - "cooling_set_point_fahrenheit" - ] = $cooling_set_point_fahrenheit; - } - if ($fan_mode_setting !== null) { - $request_payload["fan_mode_setting"] = $fan_mode_setting; - } - if ($heating_set_point_celsius !== null) { - $request_payload[ - "heating_set_point_celsius" - ] = $heating_set_point_celsius; - } - if ($heating_set_point_fahrenheit !== null) { - $request_payload[ - "heating_set_point_fahrenheit" - ] = $heating_set_point_fahrenheit; - } - if ($hvac_mode_setting !== null) { - $request_payload["hvac_mode_setting"] = $hvac_mode_setting; - } - if ($manual_override_allowed !== null) { - $request_payload[ - "manual_override_allowed" - ] = $manual_override_allowed; - } - if ($name !== null) { - $request_payload["name"] = $name; + if ($acs_system_id !== null) { + $request_payload["acs_system_id"] = $acs_system_id; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/thermostats/create_climate_preset", + "/acs/systems/list_compatible_credential_manager_acs_systems", json: (object) $request_payload ); + + return array_map(fn($r) => AcsSystem::from_json($r), $res->acs_systems); } +} - public function delete_climate_preset( - string $climate_preset_key, - string $device_id +class AcsUsersClient +{ + private SeamClient $seam; + + public function __construct(SeamClient $seam) + { + $this->seam = $seam; + } + + public function add_to_access_group( + string $acs_user_id, + string $acs_access_group_id ): void { $request_payload = []; - if ($climate_preset_key !== null) { - $request_payload["climate_preset_key"] = $climate_preset_key; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($acs_access_group_id !== null) { + $request_payload["acs_access_group_id"] = $acs_access_group_id; } $this->seam->request( "POST", - "/thermostats/delete_climate_preset", + "/acs/users/add_to_access_group", json: (object) $request_payload ); } - public function get(string $device_id = null, string $name = null): Device - { + public function create( + string $full_name, + string $acs_system_id, + ?array $acs_access_group_ids = null, + ?string $user_identity_id = null, + mixed $access_schedule = null, + ?string $email = null, + ?string $phone_number = null, + ?string $email_address = null + ): AcsUser { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($full_name !== null) { + $request_payload["full_name"] = $full_name; } - if ($name !== null) { - $request_payload["name"] = $name; + if ($acs_system_id !== null) { + $request_payload["acs_system_id"] = $acs_system_id; } - - $res = $this->seam->request( - "POST", - "/thermostats/get", - json: (object) $request_payload, - inner_object: "thermostat" - ); - - return Device::from_json($res); - } - - public function heat( - string $device_id, - float $heating_set_point_celsius = null, - float $heating_set_point_fahrenheit = null, - bool $sync = null, - bool $wait_for_action_attempt = true - ): ActionAttempt { - $request_payload = []; - - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($acs_access_group_ids !== null) { + $request_payload["acs_access_group_ids"] = $acs_access_group_ids; } - if ($heating_set_point_celsius !== null) { - $request_payload[ - "heating_set_point_celsius" - ] = $heating_set_point_celsius; + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; } - if ($heating_set_point_fahrenheit !== null) { - $request_payload[ - "heating_set_point_fahrenheit" - ] = $heating_set_point_fahrenheit; + if ($access_schedule !== null) { + $request_payload["access_schedule"] = $access_schedule; } - if ($sync !== null) { - $request_payload["sync"] = $sync; + if ($email !== null) { + $request_payload["email"] = $email; + } + if ($phone_number !== null) { + $request_payload["phone_number"] = $phone_number; + } + if ($email_address !== null) { + $request_payload["email_address"] = $email_address; } $res = $this->seam->request( "POST", - "/thermostats/heat", - json: (object) $request_payload, - inner_object: "action_attempt" - ); - - if (!$wait_for_action_attempt) { - return ActionAttempt::from_json($res); - } - - $action_attempt = $this->seam->action_attempts->poll_until_ready( - $res->action_attempt_id + "/acs/users/create", + json: (object) $request_payload ); - return $action_attempt; + return AcsUser::from_json($res->acs_user); } - public function heat_cool( - string $device_id, - float $cooling_set_point_celsius = null, - float $cooling_set_point_fahrenheit = null, - float $heating_set_point_celsius = null, - float $heating_set_point_fahrenheit = null, - bool $sync = null, - bool $wait_for_action_attempt = true - ): ActionAttempt { + public function delete(string $acs_user_id): void + { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($cooling_set_point_celsius !== null) { - $request_payload[ - "cooling_set_point_celsius" - ] = $cooling_set_point_celsius; - } - if ($cooling_set_point_fahrenheit !== null) { - $request_payload[ - "cooling_set_point_fahrenheit" - ] = $cooling_set_point_fahrenheit; - } - if ($heating_set_point_celsius !== null) { - $request_payload[ - "heating_set_point_celsius" - ] = $heating_set_point_celsius; - } - if ($heating_set_point_fahrenheit !== null) { - $request_payload[ - "heating_set_point_fahrenheit" - ] = $heating_set_point_fahrenheit; - } - if ($sync !== null) { - $request_payload["sync"] = $sync; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/thermostats/heat_cool", - json: (object) $request_payload, - inner_object: "action_attempt" + "/acs/users/delete", + json: (object) $request_payload ); + } + + public function get(string $acs_user_id): AcsUser + { + $request_payload = []; - if (!$wait_for_action_attempt) { - return ActionAttempt::from_json($res); + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } - $action_attempt = $this->seam->action_attempts->poll_until_ready( - $res->action_attempt_id + $res = $this->seam->request( + "POST", + "/acs/users/get", + json: (object) $request_payload ); - return $action_attempt; + return AcsUser::from_json($res->acs_user); } public function list( - string $connect_webview_id = null, - string $connected_account_id = null, - array $connected_account_ids = null, - string $created_before = null, - mixed $custom_metadata_has = null, - array $device_ids = null, - string $device_type = null, - array $device_types = null, - array $exclude_if = null, - array $include_if = null, - float $limit = null, - string $manufacturer = null, - string $user_identifier_key = null + ?string $user_identity_id = null, + ?string $user_identity_phone_number = null, + ?string $user_identity_email_address = null, + ?string $acs_system_id = null, + ?string $search = null, + mixed $limit = null, + ?string $created_before = null, + ?string $page_cursor = null, + ?callable $on_response = null ): array { $request_payload = []; - if ($connect_webview_id !== null) { - $request_payload["connect_webview_id"] = $connect_webview_id; - } - if ($connected_account_id !== null) { - $request_payload["connected_account_id"] = $connected_account_id; - } - if ($connected_account_ids !== null) { - $request_payload["connected_account_ids"] = $connected_account_ids; - } - if ($created_before !== null) { - $request_payload["created_before"] = $created_before; - } - if ($custom_metadata_has !== null) { - $request_payload["custom_metadata_has"] = $custom_metadata_has; - } - if ($device_ids !== null) { - $request_payload["device_ids"] = $device_ids; + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; } - if ($device_type !== null) { - $request_payload["device_type"] = $device_type; + if ($user_identity_phone_number !== null) { + $request_payload[ + "user_identity_phone_number" + ] = $user_identity_phone_number; } - if ($device_types !== null) { - $request_payload["device_types"] = $device_types; + if ($user_identity_email_address !== null) { + $request_payload[ + "user_identity_email_address" + ] = $user_identity_email_address; } - if ($exclude_if !== null) { - $request_payload["exclude_if"] = $exclude_if; + if ($acs_system_id !== null) { + $request_payload["acs_system_id"] = $acs_system_id; } - if ($include_if !== null) { - $request_payload["include_if"] = $include_if; + if ($search !== null) { + $request_payload["search"] = $search; } if ($limit !== null) { $request_payload["limit"] = $limit; } - if ($manufacturer !== null) { - $request_payload["manufacturer"] = $manufacturer; + if ($created_before !== null) { + $request_payload["created_before"] = $created_before; } - if ($user_identifier_key !== null) { - $request_payload["user_identifier_key"] = $user_identifier_key; + if ($page_cursor !== null) { + $request_payload["page_cursor"] = $page_cursor; } $res = $this->seam->request( "POST", - "/thermostats/list", - json: (object) $request_payload, - inner_object: "devices" + "/acs/users/list", + json: (object) $request_payload ); - return array_map(fn($r) => Device::from_json($r), $res); + if ($on_response !== null) { + $on_response($res); + } + + return array_map(fn($r) => AcsUser::from_json($r), $res->acs_users); } - public function off( - string $device_id, - bool $sync = null, - bool $wait_for_action_attempt = true - ): ActionAttempt { + public function list_accessible_entrances(string $acs_user_id): array + { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($sync !== null) { - $request_payload["sync"] = $sync; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } $res = $this->seam->request( "POST", - "/thermostats/off", - json: (object) $request_payload, - inner_object: "action_attempt" + "/acs/users/list_accessible_entrances", + json: (object) $request_payload ); - if (!$wait_for_action_attempt) { - return ActionAttempt::from_json($res); - } - - $action_attempt = $this->seam->action_attempts->poll_until_ready( - $res->action_attempt_id + return array_map( + fn($r) => AcsEntrance::from_json($r), + $res->acs_entrances ); - - return $action_attempt; } - public function set_fallback_climate_preset( - string $climate_preset_key, - string $device_id + public function remove_from_access_group( + string $acs_user_id, + string $acs_access_group_id ): void { $request_payload = []; - if ($climate_preset_key !== null) { - $request_payload["climate_preset_key"] = $climate_preset_key; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($acs_access_group_id !== null) { + $request_payload["acs_access_group_id"] = $acs_access_group_id; } $this->seam->request( "POST", - "/thermostats/set_fallback_climate_preset", + "/acs/users/remove_from_access_group", json: (object) $request_payload ); } - public function set_fan_mode( - string $device_id, - string $fan_mode = null, - string $fan_mode_setting = null, - bool $sync = null, - bool $wait_for_action_attempt = true - ): ActionAttempt { + public function revoke_access_to_all_entrances(string $acs_user_id): void + { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($fan_mode !== null) { - $request_payload["fan_mode"] = $fan_mode; - } - if ($fan_mode_setting !== null) { - $request_payload["fan_mode_setting"] = $fan_mode_setting; - } - if ($sync !== null) { - $request_payload["sync"] = $sync; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/thermostats/set_fan_mode", - json: (object) $request_payload, - inner_object: "action_attempt" - ); - - if (!$wait_for_action_attempt) { - return ActionAttempt::from_json($res); - } - - $action_attempt = $this->seam->action_attempts->poll_until_ready( - $res->action_attempt_id + "/acs/users/revoke_access_to_all_entrances", + json: (object) $request_payload ); - - return $action_attempt; } - public function set_hvac_mode( - string $device_id, - string $hvac_mode_setting, - float $cooling_set_point_celsius = null, - float $cooling_set_point_fahrenheit = null, - float $heating_set_point_celsius = null, - float $heating_set_point_fahrenheit = null, - bool $wait_for_action_attempt = true - ): ActionAttempt { + public function suspend(string $acs_user_id): void + { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($hvac_mode_setting !== null) { - $request_payload["hvac_mode_setting"] = $hvac_mode_setting; - } - if ($cooling_set_point_celsius !== null) { - $request_payload[ - "cooling_set_point_celsius" - ] = $cooling_set_point_celsius; - } - if ($cooling_set_point_fahrenheit !== null) { - $request_payload[ - "cooling_set_point_fahrenheit" - ] = $cooling_set_point_fahrenheit; - } - if ($heating_set_point_celsius !== null) { - $request_payload[ - "heating_set_point_celsius" - ] = $heating_set_point_celsius; - } - if ($heating_set_point_fahrenheit !== null) { - $request_payload[ - "heating_set_point_fahrenheit" - ] = $heating_set_point_fahrenheit; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/thermostats/set_hvac_mode", - json: (object) $request_payload, - inner_object: "action_attempt" - ); - - if (!$wait_for_action_attempt) { - return ActionAttempt::from_json($res); - } - - $action_attempt = $this->seam->action_attempts->poll_until_ready( - $res->action_attempt_id + "/acs/users/suspend", + json: (object) $request_payload ); - - return $action_attempt; } - public function set_temperature_threshold( - string $device_id, - float $lower_limit_celsius = null, - float $lower_limit_fahrenheit = null, - float $upper_limit_celsius = null, - float $upper_limit_fahrenheit = null - ): void { + public function unsuspend(string $acs_user_id): void + { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($lower_limit_celsius !== null) { - $request_payload["lower_limit_celsius"] = $lower_limit_celsius; - } - if ($lower_limit_fahrenheit !== null) { - $request_payload[ - "lower_limit_fahrenheit" - ] = $lower_limit_fahrenheit; - } - if ($upper_limit_celsius !== null) { - $request_payload["upper_limit_celsius"] = $upper_limit_celsius; - } - if ($upper_limit_fahrenheit !== null) { - $request_payload[ - "upper_limit_fahrenheit" - ] = $upper_limit_fahrenheit; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } $this->seam->request( "POST", - "/thermostats/set_temperature_threshold", + "/acs/users/unsuspend", json: (object) $request_payload ); } - public function update_climate_preset( - string $climate_preset_key, - string $device_id, - bool $manual_override_allowed, - float $cooling_set_point_celsius = null, - float $cooling_set_point_fahrenheit = null, - string $fan_mode_setting = null, - float $heating_set_point_celsius = null, - float $heating_set_point_fahrenheit = null, - string $hvac_mode_setting = null, - string $name = null + public function update( + string $acs_user_id, + mixed $access_schedule = null, + ?string $full_name = null, + ?string $email = null, + ?string $phone_number = null, + ?string $email_address = null, + ?string $hid_acs_system_id = null ): void { $request_payload = []; - if ($climate_preset_key !== null) { - $request_payload["climate_preset_key"] = $climate_preset_key; - } - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($manual_override_allowed !== null) { - $request_payload[ - "manual_override_allowed" - ] = $manual_override_allowed; - } - if ($cooling_set_point_celsius !== null) { - $request_payload[ - "cooling_set_point_celsius" - ] = $cooling_set_point_celsius; - } - if ($cooling_set_point_fahrenheit !== null) { - $request_payload[ - "cooling_set_point_fahrenheit" - ] = $cooling_set_point_fahrenheit; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } - if ($fan_mode_setting !== null) { - $request_payload["fan_mode_setting"] = $fan_mode_setting; + if ($access_schedule !== null) { + $request_payload["access_schedule"] = $access_schedule; } - if ($heating_set_point_celsius !== null) { - $request_payload[ - "heating_set_point_celsius" - ] = $heating_set_point_celsius; + if ($full_name !== null) { + $request_payload["full_name"] = $full_name; } - if ($heating_set_point_fahrenheit !== null) { - $request_payload[ - "heating_set_point_fahrenheit" - ] = $heating_set_point_fahrenheit; + if ($email !== null) { + $request_payload["email"] = $email; } - if ($hvac_mode_setting !== null) { - $request_payload["hvac_mode_setting"] = $hvac_mode_setting; + if ($phone_number !== null) { + $request_payload["phone_number"] = $phone_number; } - if ($name !== null) { - $request_payload["name"] = $name; + if ($email_address !== null) { + $request_payload["email_address"] = $email_address; + } + if ($hid_acs_system_id !== null) { + $request_payload["hid_acs_system_id"] = $hid_acs_system_id; } $this->seam->request( "POST", - "/thermostats/update_climate_preset", + "/acs/users/update", json: (object) $request_payload ); } } -class ThermostatsSchedulesClient +class DevicesSimulateClient { private SeamClient $seam; @@ -4302,157 +4020,181 @@ public function __construct(SeamClient $seam) $this->seam = $seam; } - public function create( - string $climate_preset_key, - string $device_id, - string $ends_at, - string $starts_at, - bool $is_override_allowed = null, - mixed $max_override_period_minutes = null, - string $name = null - ): ThermostatSchedule { + public function connect(string $device_id): void + { $request_payload = []; - if ($climate_preset_key !== null) { - $request_payload["climate_preset_key"] = $climate_preset_key; - } if ($device_id !== null) { $request_payload["device_id"] = $device_id; } - if ($ends_at !== null) { - $request_payload["ends_at"] = $ends_at; - } - if ($starts_at !== null) { - $request_payload["starts_at"] = $starts_at; - } - if ($is_override_allowed !== null) { - $request_payload["is_override_allowed"] = $is_override_allowed; - } - if ($max_override_period_minutes !== null) { - $request_payload[ - "max_override_period_minutes" - ] = $max_override_period_minutes; - } - if ($name !== null) { - $request_payload["name"] = $name; - } - $res = $this->seam->request( + $this->seam->request( "POST", - "/thermostats/schedules/create", - json: (object) $request_payload, - inner_object: "thermostat_schedule" + "/devices/simulate/connect", + json: (object) $request_payload ); - - return ThermostatSchedule::from_json($res); } - public function delete(string $thermostat_schedule_id): void + public function disconnect(string $device_id): void { $request_payload = []; - if ($thermostat_schedule_id !== null) { - $request_payload[ - "thermostat_schedule_id" - ] = $thermostat_schedule_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } $this->seam->request( "POST", - "/thermostats/schedules/delete", + "/devices/simulate/disconnect", json: (object) $request_payload ); } - public function get(string $thermostat_schedule_id): ThermostatSchedule + public function remove(string $device_id): void { $request_payload = []; - if ($thermostat_schedule_id !== null) { - $request_payload[ - "thermostat_schedule_id" - ] = $thermostat_schedule_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/thermostats/schedules/get", - json: (object) $request_payload, - inner_object: "thermostat_schedule" + "/devices/simulate/remove", + json: (object) $request_payload ); + } +} + +class DevicesUnmanagedClient +{ + private SeamClient $seam; - return ThermostatSchedule::from_json($res); + public function __construct(SeamClient $seam) + { + $this->seam = $seam; } - public function list( - string $device_id, - string $user_identifier_key = null - ): array { + public function get( + ?string $device_id = null, + ?string $name = null + ): UnmanagedDevice { $request_payload = []; if ($device_id !== null) { $request_payload["device_id"] = $device_id; } - if ($user_identifier_key !== null) { - $request_payload["user_identifier_key"] = $user_identifier_key; + if ($name !== null) { + $request_payload["name"] = $name; } $res = $this->seam->request( "POST", - "/thermostats/schedules/list", - json: (object) $request_payload, - inner_object: "thermostat_schedules" + "/devices/unmanaged/get", + json: (object) $request_payload ); - return array_map(fn($r) => ThermostatSchedule::from_json($r), $res); + return UnmanagedDevice::from_json($res->device); } - public function update( - string $thermostat_schedule_id, - string $climate_preset_key = null, - string $ends_at = null, - bool $is_override_allowed = null, - mixed $max_override_period_minutes = null, - string $name = null, - string $starts_at = null - ): void { + public function list( + ?string $connected_account_id = null, + ?array $connected_account_ids = null, + ?string $connect_webview_id = null, + ?string $device_type = null, + ?array $device_types = null, + ?string $manufacturer = null, + ?array $device_ids = null, + ?float $limit = null, + ?string $created_before = null, + ?string $user_identifier_key = null, + mixed $custom_metadata_has = null, + ?array $include_if = null, + ?array $exclude_if = null, + ?string $unstable_location_id = null, + ?callable $on_response = null + ): array { $request_payload = []; - if ($thermostat_schedule_id !== null) { - $request_payload[ - "thermostat_schedule_id" - ] = $thermostat_schedule_id; + if ($connected_account_id !== null) { + $request_payload["connected_account_id"] = $connected_account_id; } - if ($climate_preset_key !== null) { - $request_payload["climate_preset_key"] = $climate_preset_key; + if ($connected_account_ids !== null) { + $request_payload["connected_account_ids"] = $connected_account_ids; } - if ($ends_at !== null) { - $request_payload["ends_at"] = $ends_at; + if ($connect_webview_id !== null) { + $request_payload["connect_webview_id"] = $connect_webview_id; } - if ($is_override_allowed !== null) { - $request_payload["is_override_allowed"] = $is_override_allowed; + if ($device_type !== null) { + $request_payload["device_type"] = $device_type; } - if ($max_override_period_minutes !== null) { - $request_payload[ - "max_override_period_minutes" - ] = $max_override_period_minutes; + if ($device_types !== null) { + $request_payload["device_types"] = $device_types; } - if ($name !== null) { - $request_payload["name"] = $name; + if ($manufacturer !== null) { + $request_payload["manufacturer"] = $manufacturer; } - if ($starts_at !== null) { - $request_payload["starts_at"] = $starts_at; + if ($device_ids !== null) { + $request_payload["device_ids"] = $device_ids; + } + if ($limit !== null) { + $request_payload["limit"] = $limit; + } + if ($created_before !== null) { + $request_payload["created_before"] = $created_before; + } + if ($user_identifier_key !== null) { + $request_payload["user_identifier_key"] = $user_identifier_key; + } + if ($custom_metadata_has !== null) { + $request_payload["custom_metadata_has"] = $custom_metadata_has; + } + if ($include_if !== null) { + $request_payload["include_if"] = $include_if; + } + if ($exclude_if !== null) { + $request_payload["exclude_if"] = $exclude_if; + } + if ($unstable_location_id !== null) { + $request_payload["unstable_location_id"] = $unstable_location_id; + } + + $res = $this->seam->request( + "POST", + "/devices/unmanaged/list", + json: (object) $request_payload + ); + + if ($on_response !== null) { + $on_response($res); + } + + return array_map( + fn($r) => UnmanagedDevice::from_json($r), + $res->devices + ); + } + + public function update(string $device_id, bool $is_managed): void + { + $request_payload = []; + + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } + if ($is_managed !== null) { + $request_payload["is_managed"] = $is_managed; } $this->seam->request( "POST", - "/thermostats/schedules/update", + "/devices/unmanaged/update", json: (object) $request_payload ); } } -class ThermostatsSimulateClient +class NoiseSensorsNoiseThresholdsClient { private SeamClient $seam; @@ -4461,340 +4203,474 @@ public function __construct(SeamClient $seam) $this->seam = $seam; } - public function hvac_mode_adjusted( + public function create( string $device_id, - string $hvac_mode, - float $cooling_set_point_celsius = null, - float $cooling_set_point_fahrenheit = null, - float $heating_set_point_celsius = null, - float $heating_set_point_fahrenheit = null - ): void { + string $starts_daily_at, + string $ends_daily_at, + ?bool $sync = null, + ?string $name = null, + ?float $noise_threshold_decibels = null, + ?float $noise_threshold_nrs = null + ): NoiseThreshold { $request_payload = []; if ($device_id !== null) { $request_payload["device_id"] = $device_id; } - if ($hvac_mode !== null) { - $request_payload["hvac_mode"] = $hvac_mode; + if ($starts_daily_at !== null) { + $request_payload["starts_daily_at"] = $starts_daily_at; } - if ($cooling_set_point_celsius !== null) { - $request_payload[ - "cooling_set_point_celsius" - ] = $cooling_set_point_celsius; + if ($ends_daily_at !== null) { + $request_payload["ends_daily_at"] = $ends_daily_at; } - if ($cooling_set_point_fahrenheit !== null) { - $request_payload[ - "cooling_set_point_fahrenheit" - ] = $cooling_set_point_fahrenheit; + if ($sync !== null) { + $request_payload["sync"] = $sync; } - if ($heating_set_point_celsius !== null) { + if ($name !== null) { + $request_payload["name"] = $name; + } + if ($noise_threshold_decibels !== null) { $request_payload[ - "heating_set_point_celsius" - ] = $heating_set_point_celsius; + "noise_threshold_decibels" + ] = $noise_threshold_decibels; + } + if ($noise_threshold_nrs !== null) { + $request_payload["noise_threshold_nrs"] = $noise_threshold_nrs; + } + + $res = $this->seam->request( + "POST", + "/noise_sensors/noise_thresholds/create", + json: (object) $request_payload + ); + + return NoiseThreshold::from_json($res->noise_threshold); + } + + public function delete( + string $noise_threshold_id, + string $device_id, + ?bool $sync = null + ): void { + $request_payload = []; + + if ($noise_threshold_id !== null) { + $request_payload["noise_threshold_id"] = $noise_threshold_id; + } + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } + if ($sync !== null) { + $request_payload["sync"] = $sync; + } + + $this->seam->request( + "POST", + "/noise_sensors/noise_thresholds/delete", + json: (object) $request_payload + ); + } + + public function get(string $noise_threshold_id): NoiseThreshold + { + $request_payload = []; + + if ($noise_threshold_id !== null) { + $request_payload["noise_threshold_id"] = $noise_threshold_id; + } + + $res = $this->seam->request( + "POST", + "/noise_sensors/noise_thresholds/get", + json: (object) $request_payload + ); + + return NoiseThreshold::from_json($res->noise_threshold); + } + + public function list( + string $device_id, + ?bool $is_programmed = null, + ?callable $on_response = null + ): array { + $request_payload = []; + + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - if ($heating_set_point_fahrenheit !== null) { - $request_payload[ - "heating_set_point_fahrenheit" - ] = $heating_set_point_fahrenheit; + if ($is_programmed !== null) { + $request_payload["is_programmed"] = $is_programmed; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/thermostats/simulate/hvac_mode_adjusted", + "/noise_sensors/noise_thresholds/list", json: (object) $request_payload ); + + if ($on_response !== null) { + $on_response($res); + } + + return array_map( + fn($r) => NoiseThreshold::from_json($r), + $res->noise_thresholds + ); } - public function temperature_reached( + public function update( + string $noise_threshold_id, string $device_id, - float $temperature_celsius = null, - float $temperature_fahrenheit = null + ?bool $sync = null, + ?string $name = null, + ?string $starts_daily_at = null, + ?string $ends_daily_at = null, + ?float $noise_threshold_decibels = null, + ?float $noise_threshold_nrs = null ): void { $request_payload = []; + if ($noise_threshold_id !== null) { + $request_payload["noise_threshold_id"] = $noise_threshold_id; + } if ($device_id !== null) { $request_payload["device_id"] = $device_id; } - if ($temperature_celsius !== null) { - $request_payload["temperature_celsius"] = $temperature_celsius; + if ($sync !== null) { + $request_payload["sync"] = $sync; } - if ($temperature_fahrenheit !== null) { + if ($name !== null) { + $request_payload["name"] = $name; + } + if ($starts_daily_at !== null) { + $request_payload["starts_daily_at"] = $starts_daily_at; + } + if ($ends_daily_at !== null) { + $request_payload["ends_daily_at"] = $ends_daily_at; + } + if ($noise_threshold_decibels !== null) { $request_payload[ - "temperature_fahrenheit" - ] = $temperature_fahrenheit; + "noise_threshold_decibels" + ] = $noise_threshold_decibels; + } + if ($noise_threshold_nrs !== null) { + $request_payload["noise_threshold_nrs"] = $noise_threshold_nrs; } $this->seam->request( "POST", - "/thermostats/simulate/temperature_reached", + "/noise_sensors/noise_thresholds/update", json: (object) $request_payload ); } } -class UserIdentitiesClient +class NoiseSensorsSimulateClient { private SeamClient $seam; - public UserIdentitiesEnrollmentAutomationsClient $enrollment_automations; + public function __construct(SeamClient $seam) { $this->seam = $seam; - $this->enrollment_automations = new UserIdentitiesEnrollmentAutomationsClient( - $seam - ); } - public function add_acs_user( - string $acs_user_id, - string $user_identity_id - ): void { + public function trigger_noise_threshold(string $device_id): void + { $request_payload = []; - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; - } - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } $this->seam->request( "POST", - "/user_identities/add_acs_user", + "/noise_sensors/simulate/trigger_noise_threshold", json: (object) $request_payload ); } +} - public function create( - string $email_address = null, - string $full_name = null, - string $phone_number = null, - string $user_identity_key = null - ): UserIdentity { - $request_payload = []; - - if ($email_address !== null) { - $request_payload["email_address"] = $email_address; - } - if ($full_name !== null) { - $request_payload["full_name"] = $full_name; - } - if ($phone_number !== null) { - $request_payload["phone_number"] = $phone_number; - } - if ($user_identity_key !== null) { - $request_payload["user_identity_key"] = $user_identity_key; - } - - $res = $this->seam->request( - "POST", - "/user_identities/create", - json: (object) $request_payload, - inner_object: "user_identity" - ); - - return UserIdentity::from_json($res); - } +class PhonesSimulateClient +{ + private SeamClient $seam; - public function delete(string $user_identity_id): void + public function __construct(SeamClient $seam) { - $request_payload = []; - - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; - } - - $this->seam->request( - "POST", - "/user_identities/delete", - json: (object) $request_payload - ); + $this->seam = $seam; } - public function get( - string $user_identity_id = null, - string $user_identity_key = null - ): UserIdentity { + public function create_sandbox_phone( + string $user_identity_id, + ?string $custom_sdk_installation_id = null, + mixed $phone_metadata = null, + mixed $assa_abloy_metadata = null + ): Phone { $request_payload = []; if ($user_identity_id !== null) { $request_payload["user_identity_id"] = $user_identity_id; } - if ($user_identity_key !== null) { - $request_payload["user_identity_key"] = $user_identity_key; + if ($custom_sdk_installation_id !== null) { + $request_payload[ + "custom_sdk_installation_id" + ] = $custom_sdk_installation_id; + } + if ($phone_metadata !== null) { + $request_payload["phone_metadata"] = $phone_metadata; + } + if ($assa_abloy_metadata !== null) { + $request_payload["assa_abloy_metadata"] = $assa_abloy_metadata; } $res = $this->seam->request( "POST", - "/user_identities/get", - json: (object) $request_payload, - inner_object: "user_identity" + "/phones/simulate/create_sandbox_phone", + json: (object) $request_payload ); - return UserIdentity::from_json($res); + return Phone::from_json($res->phone); } +} - public function grant_access_to_device( +class ThermostatsSchedulesClient +{ + private SeamClient $seam; + + public function __construct(SeamClient $seam) + { + $this->seam = $seam; + } + + public function create( string $device_id, - string $user_identity_id - ): void { + string $climate_preset_key, + string $starts_at, + string $ends_at, + ?string $name = null, + mixed $max_override_period_minutes = null, + ?bool $is_override_allowed = null + ): ThermostatSchedule { $request_payload = []; if ($device_id !== null) { $request_payload["device_id"] = $device_id; } - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; + if ($climate_preset_key !== null) { + $request_payload["climate_preset_key"] = $climate_preset_key; + } + if ($starts_at !== null) { + $request_payload["starts_at"] = $starts_at; + } + if ($ends_at !== null) { + $request_payload["ends_at"] = $ends_at; + } + if ($name !== null) { + $request_payload["name"] = $name; + } + if ($max_override_period_minutes !== null) { + $request_payload[ + "max_override_period_minutes" + ] = $max_override_period_minutes; + } + if ($is_override_allowed !== null) { + $request_payload["is_override_allowed"] = $is_override_allowed; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/user_identities/grant_access_to_device", + "/thermostats/schedules/create", json: (object) $request_payload ); + + return ThermostatSchedule::from_json($res->thermostat_schedule); } - public function list(string $credential_manager_acs_system_id = null): array + public function delete(string $thermostat_schedule_id): void { $request_payload = []; - if ($credential_manager_acs_system_id !== null) { + if ($thermostat_schedule_id !== null) { $request_payload[ - "credential_manager_acs_system_id" - ] = $credential_manager_acs_system_id; + "thermostat_schedule_id" + ] = $thermostat_schedule_id; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/user_identities/list", - json: (object) $request_payload, - inner_object: "user_identities" + "/thermostats/schedules/delete", + json: (object) $request_payload ); - - return array_map(fn($r) => UserIdentity::from_json($r), $res); } - public function list_accessible_devices(string $user_identity_id): array + public function get(string $thermostat_schedule_id): ThermostatSchedule { $request_payload = []; - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; + if ($thermostat_schedule_id !== null) { + $request_payload[ + "thermostat_schedule_id" + ] = $thermostat_schedule_id; } $res = $this->seam->request( "POST", - "/user_identities/list_accessible_devices", - json: (object) $request_payload, - inner_object: "devices" + "/thermostats/schedules/get", + json: (object) $request_payload ); - return array_map(fn($r) => Device::from_json($r), $res); + return ThermostatSchedule::from_json($res->thermostat_schedule); } - public function list_acs_systems(string $user_identity_id): array - { + public function list( + string $device_id, + ?string $user_identifier_key = null, + ?callable $on_response = null + ): array { $request_payload = []; - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } + if ($user_identifier_key !== null) { + $request_payload["user_identifier_key"] = $user_identifier_key; } $res = $this->seam->request( "POST", - "/user_identities/list_acs_systems", - json: (object) $request_payload, - inner_object: "acs_systems" + "/thermostats/schedules/list", + json: (object) $request_payload ); - return array_map(fn($r) => AcsSystem::from_json($r), $res); - } - - public function list_acs_users(string $user_identity_id): array - { - $request_payload = []; - - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; + if ($on_response !== null) { + $on_response($res); } - $res = $this->seam->request( - "POST", - "/user_identities/list_acs_users", - json: (object) $request_payload, - inner_object: "acs_users" + return array_map( + fn($r) => ThermostatSchedule::from_json($r), + $res->thermostat_schedules ); - - return array_map(fn($r) => AcsUser::from_json($r), $res); } - public function remove_acs_user( - string $acs_user_id, - string $user_identity_id + public function update( + string $thermostat_schedule_id, + ?string $name = null, + ?string $climate_preset_key = null, + mixed $max_override_period_minutes = null, + ?string $starts_at = null, + ?string $ends_at = null, + ?bool $is_override_allowed = null ): void { $request_payload = []; - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($thermostat_schedule_id !== null) { + $request_payload[ + "thermostat_schedule_id" + ] = $thermostat_schedule_id; + } + if ($name !== null) { + $request_payload["name"] = $name; + } + if ($climate_preset_key !== null) { + $request_payload["climate_preset_key"] = $climate_preset_key; + } + if ($max_override_period_minutes !== null) { + $request_payload[ + "max_override_period_minutes" + ] = $max_override_period_minutes; + } + if ($starts_at !== null) { + $request_payload["starts_at"] = $starts_at; + } + if ($ends_at !== null) { + $request_payload["ends_at"] = $ends_at; } - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; + if ($is_override_allowed !== null) { + $request_payload["is_override_allowed"] = $is_override_allowed; } $this->seam->request( "POST", - "/user_identities/remove_acs_user", + "/thermostats/schedules/update", json: (object) $request_payload ); } +} - public function revoke_access_to_device( +class ThermostatsSimulateClient +{ + private SeamClient $seam; + + public function __construct(SeamClient $seam) + { + $this->seam = $seam; + } + + public function hvac_mode_adjusted( + string $hvac_mode, string $device_id, - string $user_identity_id + ?float $cooling_set_point_celsius = null, + ?float $cooling_set_point_fahrenheit = null, + ?float $heating_set_point_celsius = null, + ?float $heating_set_point_fahrenheit = null ): void { $request_payload = []; + if ($hvac_mode !== null) { + $request_payload["hvac_mode"] = $hvac_mode; + } if ($device_id !== null) { $request_payload["device_id"] = $device_id; } - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; + if ($cooling_set_point_celsius !== null) { + $request_payload[ + "cooling_set_point_celsius" + ] = $cooling_set_point_celsius; + } + if ($cooling_set_point_fahrenheit !== null) { + $request_payload[ + "cooling_set_point_fahrenheit" + ] = $cooling_set_point_fahrenheit; + } + if ($heating_set_point_celsius !== null) { + $request_payload[ + "heating_set_point_celsius" + ] = $heating_set_point_celsius; + } + if ($heating_set_point_fahrenheit !== null) { + $request_payload[ + "heating_set_point_fahrenheit" + ] = $heating_set_point_fahrenheit; } $this->seam->request( "POST", - "/user_identities/revoke_access_to_device", + "/thermostats/simulate/hvac_mode_adjusted", json: (object) $request_payload ); } - public function update( - string $user_identity_id, - string $email_address = null, - string $full_name = null, - string $phone_number = null, - string $user_identity_key = null + public function temperature_reached( + string $device_id, + ?float $temperature_celsius = null, + ?float $temperature_fahrenheit = null ): void { $request_payload = []; - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; - } - if ($email_address !== null) { - $request_payload["email_address"] = $email_address; - } - if ($full_name !== null) { - $request_payload["full_name"] = $full_name; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - if ($phone_number !== null) { - $request_payload["phone_number"] = $phone_number; + if ($temperature_celsius !== null) { + $request_payload["temperature_celsius"] = $temperature_celsius; } - if ($user_identity_key !== null) { - $request_payload["user_identity_key"] = $user_identity_key; + if ($temperature_fahrenheit !== null) { + $request_payload[ + "temperature_fahrenheit" + ] = $temperature_fahrenheit; } $this->seam->request( "POST", - "/user_identities/update", + "/thermostats/simulate/temperature_reached", json: (object) $request_payload ); } @@ -4839,30 +4715,29 @@ public function get(string $enrollment_automation_id): EnrollmentAutomation $res = $this->seam->request( "POST", "/user_identities/enrollment_automations/get", - json: (object) $request_payload, - inner_object: "enrollment_automation" + json: (object) $request_payload ); - return EnrollmentAutomation::from_json($res); + return EnrollmentAutomation::from_json($res->enrollment_automation); } public function launch( - string $credential_manager_acs_system_id, string $user_identity_id, - string $acs_credential_pool_id = null, - bool $create_credential_manager_user = null, - string $credential_manager_acs_user_id = null + string $credential_manager_acs_system_id, + ?string $acs_credential_pool_id = null, + ?bool $create_credential_manager_user = null, + ?string $credential_manager_acs_user_id = null ): void { $request_payload = []; + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; + } if ($credential_manager_acs_system_id !== null) { $request_payload[ "credential_manager_acs_system_id" ] = $credential_manager_acs_system_id; } - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; - } if ($acs_credential_pool_id !== null) { $request_payload[ "acs_credential_pool_id" @@ -4882,13 +4757,14 @@ public function launch( $this->seam->request( "POST", "/user_identities/enrollment_automations/launch", - json: (object) $request_payload, - inner_object: "enrollment_automation" + json: (object) $request_payload ); } - public function list(string $user_identity_id): array - { + public function list( + string $user_identity_id, + ?callable $on_response = null + ): array { $request_payload = []; if ($user_identity_id !== null) { @@ -4898,15 +4774,21 @@ public function list(string $user_identity_id): array $res = $this->seam->request( "POST", "/user_identities/enrollment_automations/list", - json: (object) $request_payload, - inner_object: "enrollment_automations" + json: (object) $request_payload ); - return array_map(fn($r) => EnrollmentAutomation::from_json($r), $res); + if ($on_response !== null) { + $on_response($res); + } + + return array_map( + fn($r) => EnrollmentAutomation::from_json($r), + $res->enrollment_automations + ); } } -class WebhooksClient +class AcsEncodersSimulateClient { private SeamClient $seam; @@ -4915,197 +4797,99 @@ public function __construct(SeamClient $seam) $this->seam = $seam; } - public function create(string $url, array $event_types = null): Webhook - { + public function next_credential_encode_will_fail( + string $acs_encoder_id, + ?string $error_code = null, + ?string $acs_credential_id = null + ): void { $request_payload = []; - if ($url !== null) { - $request_payload["url"] = $url; + if ($acs_encoder_id !== null) { + $request_payload["acs_encoder_id"] = $acs_encoder_id; } - if ($event_types !== null) { - $request_payload["event_types"] = $event_types; + if ($error_code !== null) { + $request_payload["error_code"] = $error_code; } - - $res = $this->seam->request( - "POST", - "/webhooks/create", - json: (object) $request_payload, - inner_object: "webhook" - ); - - return Webhook::from_json($res); - } - - public function delete(string $webhook_id): void - { - $request_payload = []; - - if ($webhook_id !== null) { - $request_payload["webhook_id"] = $webhook_id; + if ($acs_credential_id !== null) { + $request_payload["acs_credential_id"] = $acs_credential_id; } $this->seam->request( "POST", - "/webhooks/delete", + "/acs/encoders/simulate/next_credential_encode_will_fail", json: (object) $request_payload ); } - public function get(string $webhook_id): Webhook - { + public function next_credential_encode_will_succeed( + string $acs_encoder_id, + ?string $scenario = null + ): void { $request_payload = []; - if ($webhook_id !== null) { - $request_payload["webhook_id"] = $webhook_id; + if ($acs_encoder_id !== null) { + $request_payload["acs_encoder_id"] = $acs_encoder_id; + } + if ($scenario !== null) { + $request_payload["scenario"] = $scenario; } - $res = $this->seam->request( - "POST", - "/webhooks/get", - json: (object) $request_payload, - inner_object: "webhook" - ); - - return Webhook::from_json($res); - } - - public function list(): array - { - $request_payload = []; - - $res = $this->seam->request( + $this->seam->request( "POST", - "/webhooks/list", - json: (object) $request_payload, - inner_object: "webhooks" + "/acs/encoders/simulate/next_credential_encode_will_succeed", + json: (object) $request_payload ); - - return array_map(fn($r) => Webhook::from_json($r), $res); } - public function update(array $event_types, string $webhook_id): void - { + public function next_credential_scan_will_fail( + string $acs_encoder_id, + ?string $error_code = null, + ?string $acs_credential_id_on_seam = null + ): void { $request_payload = []; - if ($event_types !== null) { - $request_payload["event_types"] = $event_types; + if ($acs_encoder_id !== null) { + $request_payload["acs_encoder_id"] = $acs_encoder_id; } - if ($webhook_id !== null) { - $request_payload["webhook_id"] = $webhook_id; + if ($error_code !== null) { + $request_payload["error_code"] = $error_code; + } + if ($acs_credential_id_on_seam !== null) { + $request_payload[ + "acs_credential_id_on_seam" + ] = $acs_credential_id_on_seam; } $this->seam->request( "POST", - "/webhooks/update", + "/acs/encoders/simulate/next_credential_scan_will_fail", json: (object) $request_payload ); } -} - -class WorkspacesClient -{ - private SeamClient $seam; - - public function __construct(SeamClient $seam) - { - $this->seam = $seam; - } - public function create( - string $name, - string $company_name = null, - string $connect_partner_name = null, - bool $is_sandbox = null, - string $webview_logo_shape = null, - string $webview_primary_button_color = null, - string $webview_primary_button_text_color = null - ): Workspace { + public function next_credential_scan_will_succeed( + string $acs_encoder_id, + ?string $scenario = null, + ?string $acs_credential_id_on_seam = null + ): void { $request_payload = []; - if ($name !== null) { - $request_payload["name"] = $name; - } - if ($company_name !== null) { - $request_payload["company_name"] = $company_name; - } - if ($connect_partner_name !== null) { - $request_payload["connect_partner_name"] = $connect_partner_name; - } - if ($is_sandbox !== null) { - $request_payload["is_sandbox"] = $is_sandbox; - } - if ($webview_logo_shape !== null) { - $request_payload["webview_logo_shape"] = $webview_logo_shape; + if ($acs_encoder_id !== null) { + $request_payload["acs_encoder_id"] = $acs_encoder_id; } - if ($webview_primary_button_color !== null) { - $request_payload[ - "webview_primary_button_color" - ] = $webview_primary_button_color; + if ($scenario !== null) { + $request_payload["scenario"] = $scenario; } - if ($webview_primary_button_text_color !== null) { + if ($acs_credential_id_on_seam !== null) { $request_payload[ - "webview_primary_button_text_color" - ] = $webview_primary_button_text_color; + "acs_credential_id_on_seam" + ] = $acs_credential_id_on_seam; } - $res = $this->seam->request( - "POST", - "/workspaces/create", - json: (object) $request_payload, - inner_object: "workspace" - ); - - return Workspace::from_json($res); - } - - public function get(): Workspace - { - $request_payload = []; - - $res = $this->seam->request( - "POST", - "/workspaces/get", - json: (object) $request_payload, - inner_object: "workspace" - ); - - return Workspace::from_json($res); - } - - public function list(): array - { - $request_payload = []; - - $res = $this->seam->request( - "POST", - "/workspaces/list", - json: (object) $request_payload, - inner_object: "workspaces" - ); - - return array_map(fn($r) => Workspace::from_json($r), $res); - } - - public function reset_sandbox( - bool $wait_for_action_attempt = true - ): ActionAttempt { - $request_payload = []; - - $res = $this->seam->request( + $this->seam->request( "POST", - "/workspaces/reset_sandbox", - json: (object) $request_payload, - inner_object: "action_attempt" - ); - - if (!$wait_for_action_attempt) { - return ActionAttempt::from_json($res); - } - - $action_attempt = $this->seam->action_attempts->poll_until_ready( - $res->action_attempt_id + "/acs/encoders/simulate/next_credential_scan_will_succeed", + json: (object) $request_payload ); - - return $action_attempt; } } diff --git a/tests/DevicesTest.php b/tests/DevicesTest.php index eff72cd4..6a3156f5 100644 --- a/tests/DevicesTest.php +++ b/tests/DevicesTest.php @@ -41,17 +41,6 @@ public function testGetAndListDevices(): void $device = $seam->devices->get(name: $device_name); $this->assertTrue($device->properties->manufacturer === $manufacturer); - $seam->devices->delete(device_id: $device_id); - try { - $seam->devices->get(device_id: $device_id); - - $this->fail("Expected the device to be deleted"); - } catch (\Seam\HttpApiError $exception) { - $this->assertTrue( - str_contains($exception->getErrorCode(), "device_not_found") - ); - } - $stable_device_providers = $seam->devices->list_device_providers( provider_category: "stable" ); diff --git a/tests/PaginatorTest.php b/tests/PaginatorTest.php new file mode 100644 index 00000000..1ab4c7cb --- /dev/null +++ b/tests/PaginatorTest.php @@ -0,0 +1,78 @@ +createPaginator( + fn($params) => $seam->devices->list(...$params), + ["limit" => 2] + ); + [$devices, $pagination] = $pages->firstPage(); + + $this->assertTrue(count($devices) == 2); + $this->assertTrue($pagination->has_next_page); + $this->assertTrue($pagination->next_page_cursor !== null); + $this->assertTrue($pagination->next_page_url !== null); + } + + public function testPaginatorNextPage(): void + { + $seam = Fixture::getTestServer(); + + $pages = $seam->createPaginator( + fn($params) => $seam->devices->list(...$params), + ["limit" => 2] + ); + [$devices, $pagination] = $pages->firstPage(); + + $this->assertTrue(count($devices) == 2); + $this->assertTrue($pagination->has_next_page); + + [$moreDevices] = $pages->nextPage($pagination->next_page_cursor); + + $this->assertTrue(count($moreDevices) == 2); + } + + public function testPaginatorFlattenToArray(): void + { + $seam = Fixture::getTestServer(); + + $allDevices = $seam->devices->list(); + + $pages = $seam->createPaginator( + fn($params) => $seam->devices->list(...$params), + ["limit" => 1] + ); + $devices = $pages->flattenToArray(); + + $this->assertTrue(count($devices) > 1); + $this->assertTrue(count($devices) == count($allDevices)); + } + + public function testPaginatorFlatten(): void + { + $seam = Fixture::getTestServer(); + + $allDevices = $seam->devices->list(); + $pages = $seam->createPaginator( + fn($params) => $seam->devices->list(...$params), + ["limit" => 1] + ); + + $devices = []; + foreach ($pages->flatten() as $device) { + $devices[] = $device; + } + $this->assertTrue(count($devices) > 1); + $this->assertTrue(count($devices) == count($allDevices)); + } +} From beafe285513c335dd85e94151b081f032ee85ef7 Mon Sep 17 00:00:00 2001 From: Andrii Balitskyi <10balian10@gmail.com> Date: Tue, 8 Apr 2025 14:54:09 +0200 Subject: [PATCH 2/6] Bump types and sdk generator, re-enable generation --- .github/workflows/generate.yml | 4 ++-- package-lock.json | 25 ++++++++++++------------- package.json | 4 ++-- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index e8653dcd..98269747 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -3,8 +3,8 @@ name: Generate on: push: - branches: - - 'no-branch-will-match-this-pattern' + branches-ignore: + - main workflow_dispatch: {} jobs: diff --git a/package-lock.json b/package-lock.json index 9f9b1ab4..7c22fff3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,8 +10,8 @@ "license": "MIT", "devDependencies": { "@prettier/plugin-php": "^0.22.1", - "@seamapi/nextlove-sdk-generator": "1.15.8", - "@seamapi/types": "1.351.1", + "@seamapi/nextlove-sdk-generator": "1.18.0", + "@seamapi/types": "1.377.0", "del": "^7.1.0", "prettier": "^3.0.0" } @@ -434,9 +434,9 @@ } }, "node_modules/@seamapi/nextlove-sdk-generator": { - "version": "1.15.8", - "resolved": "https://registry.npmjs.org/@seamapi/nextlove-sdk-generator/-/nextlove-sdk-generator-1.15.8.tgz", - "integrity": "sha512-Q2v5p5BmK45/Qm6LpwUe3c2s6zzgUum9VOxnQU0K9CO3n23KaJf1X2M/sU6mRedAGh+JJsgmXLePtj21hhPZZg==", + "version": "1.18.0", + "resolved": "https://registry.npmjs.org/@seamapi/nextlove-sdk-generator/-/nextlove-sdk-generator-1.18.0.tgz", + "integrity": "sha512-lINrwlr3pJUWawFvEXezY89VxS4mafgkqeBGTiLRZSXTDLzqEl8QD6UKN0CHKirwHCjPFj8MUsGDyz7pCzbCmQ==", "dev": true, "dependencies": { "@nodelib/fs.walk": "^2.0.0", @@ -455,17 +455,16 @@ } }, "node_modules/@seamapi/types": { - "version": "1.351.1", - "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.351.1.tgz", - "integrity": "sha512-zqgGhSUs1EpNAxSAuDPq0jQNifMJua+lX5jviFtC7RSxjqGIP47oBtW76OxFHOnJK9FyIk4vYE583ioBzIPzOg==", + "version": "1.377.0", + "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.377.0.tgz", + "integrity": "sha512-EOdujTToK8AxrMn7TSL3Ju4X+3GeHB8RsrF4M8w5aIGjyOzJzPcxOMJHlhfCzB+x5A6r3VA50FIOsB8U9KmFiw==", "dev": true, - "license": "MIT", "engines": { "node": ">=18.12.0", "npm": ">= 9.0.0" }, "peerDependencies": { - "zod": "^3.21.4" + "zod": "^3.24.0" } }, "node_modules/aggregate-error": { @@ -1608,9 +1607,9 @@ } }, "node_modules/zod": { - "version": "3.22.4", - "resolved": "https://registry.npmjs.org/zod/-/zod-3.22.4.tgz", - "integrity": "sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==", + "version": "3.24.2", + "resolved": "https://registry.npmjs.org/zod/-/zod-3.24.2.tgz", + "integrity": "sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ==", "dev": true, "peer": true, "funding": { diff --git a/package.json b/package.json index 6220dbda..2f11a833 100644 --- a/package.json +++ b/package.json @@ -12,8 +12,8 @@ }, "devDependencies": { "@prettier/plugin-php": "^0.22.1", - "@seamapi/nextlove-sdk-generator": "1.15.8", - "@seamapi/types": "1.351.1", + "@seamapi/nextlove-sdk-generator": "1.18.0", + "@seamapi/types": "1.377.0", "del": "^7.1.0", "prettier": "^3.0.0" } From 553d5cb3901cc3a854154da4247229153a207215 Mon Sep 17 00:00:00 2001 From: Seam Bot Date: Tue, 8 Apr 2025 12:54:31 +0000 Subject: [PATCH 3/6] ci: Generate code --- src/Objects/AccessCodeErrors.php | 2 + src/Objects/AcsSystem.php | 4 + src/Objects/AcsSystemErrors.php | 6 +- src/Objects/AcsUser.php | 5 + src/Objects/AcsUserFrom.php | 20 + src/Objects/AcsUserPendingMutations.php | 29 + src/Objects/AcsUserTo.php | 20 + src/Objects/ConnectedAccountErrors.php | 17 +- .../ConnectedAccountSaltoKsMetadata.php | 24 + src/Objects/ConnectedAccountSites.php | 27 + src/Objects/ConnectedAccountWarnings.php | 10 +- src/Objects/DeviceErrors.php | 6 +- src/Objects/DeviceFeatures.php | 6 +- src/Objects/DeviceProperties.php | 4 + src/Objects/DeviceSensiMetadata.php | 25 + src/Objects/DeviceWarnings.php | 8 +- src/Objects/Event.php | 4 + src/Objects/Pagination.php | 25 + src/Objects/UnmanagedAccessCodeErrors.php | 2 + src/Objects/UnmanagedAcsUser.php | 5 + src/Objects/UnmanagedAcsUserFrom.php | 20 + .../UnmanagedAcsUserPendingMutations.php | 32 + src/Objects/UnmanagedAcsUserTo.php | 20 + src/Objects/UnmanagedDeviceErrors.php | 6 +- src/Objects/UnmanagedDeviceWarnings.php | 8 +- src/Objects/Workspace.php | 2 + src/Paginator.php | 12 +- src/SeamClient.php | 5387 ++++++++--------- 28 files changed, 3013 insertions(+), 2723 deletions(-) create mode 100644 src/Objects/AcsUserFrom.php create mode 100644 src/Objects/AcsUserPendingMutations.php create mode 100644 src/Objects/AcsUserTo.php create mode 100644 src/Objects/ConnectedAccountSaltoKsMetadata.php create mode 100644 src/Objects/ConnectedAccountSites.php create mode 100644 src/Objects/DeviceSensiMetadata.php create mode 100644 src/Objects/Pagination.php create mode 100644 src/Objects/UnmanagedAcsUserFrom.php create mode 100644 src/Objects/UnmanagedAcsUserPendingMutations.php create mode 100644 src/Objects/UnmanagedAcsUserTo.php diff --git a/src/Objects/AccessCodeErrors.php b/src/Objects/AccessCodeErrors.php index f267c8fb..8f17847f 100644 --- a/src/Objects/AccessCodeErrors.php +++ b/src/Objects/AccessCodeErrors.php @@ -14,6 +14,7 @@ public static function from_json(mixed $json): AccessCodeErrors|null message: $json->message, created_at: $json->created_at ?? null, is_access_code_error: $json->is_access_code_error ?? null, + is_bridge_error: $json->is_bridge_error ?? null, is_connected_account_error: $json->is_connected_account_error ?? null, is_device_error: $json->is_device_error ?? null @@ -25,6 +26,7 @@ public function __construct( public string $message, public string|null $created_at, public bool|null $is_access_code_error, + public bool|null $is_bridge_error, public bool|null $is_connected_account_error, public bool|null $is_device_error ) { diff --git a/src/Objects/AcsSystem.php b/src/Objects/AcsSystem.php index a874ff1f..95c5b818 100644 --- a/src/Objects/AcsSystem.php +++ b/src/Objects/AcsSystem.php @@ -28,6 +28,8 @@ public static function from_json(mixed $json): AcsSystem|null $json->warnings ?? [] ), workspace_id: $json->workspace_id, + acs_access_group_count: $json->acs_access_group_count ?? null, + acs_user_count: $json->acs_user_count ?? null, can_add_acs_users_to_acs_access_groups: $json->can_add_acs_users_to_acs_access_groups ?? null, can_automate_enrollment: $json->can_automate_enrollment ?? null, @@ -63,6 +65,8 @@ public function __construct( public string $name, public array $warnings, public string $workspace_id, + public float|null $acs_access_group_count, + public float|null $acs_user_count, public bool|null $can_add_acs_users_to_acs_access_groups, public bool|null $can_automate_enrollment, public bool|null $can_create_acs_access_groups, diff --git a/src/Objects/AcsSystemErrors.php b/src/Objects/AcsSystemErrors.php index 3f6889b2..70924d88 100644 --- a/src/Objects/AcsSystemErrors.php +++ b/src/Objects/AcsSystemErrors.php @@ -12,14 +12,16 @@ public static function from_json(mixed $json): AcsSystemErrors|null return new self( created_at: $json->created_at, error_code: $json->error_code, - message: $json->message + message: $json->message, + is_bridge_error: $json->is_bridge_error ?? null ); } public function __construct( public string $created_at, public string $error_code, - public string $message + public string $message, + public bool|null $is_bridge_error ) { } } diff --git a/src/Objects/AcsUser.php b/src/Objects/AcsUser.php index 08608dfd..b3746fb7 100644 --- a/src/Objects/AcsUser.php +++ b/src/Objects/AcsUser.php @@ -35,6 +35,10 @@ public static function from_json(mixed $json): AcsUser|null full_name: $json->full_name ?? null, hid_acs_system_id: $json->hid_acs_system_id ?? null, is_suspended: $json->is_suspended ?? null, + pending_mutations: array_map( + fn($p) => AcsUserPendingMutations::from_json($p), + $json->pending_mutations ?? [] + ), phone_number: $json->phone_number ?? null, user_identity_id: $json->user_identity_id ?? null, is_latest_desired_state_synced_with_provider: $json->is_latest_desired_state_synced_with_provider ?? @@ -66,6 +70,7 @@ public function __construct( public string|null $full_name, public string|null $hid_acs_system_id, public bool|null $is_suspended, + public array|null $pending_mutations, public string|null $phone_number, public string|null $user_identity_id, public bool|null $is_latest_desired_state_synced_with_provider, diff --git a/src/Objects/AcsUserFrom.php b/src/Objects/AcsUserFrom.php new file mode 100644 index 00000000..bcc98a3e --- /dev/null +++ b/src/Objects/AcsUserFrom.php @@ -0,0 +1,20 @@ +acs_access_group_id ?? null + ); + } + + public function __construct(public string|null $acs_access_group_id) + { + } +} diff --git a/src/Objects/AcsUserPendingMutations.php b/src/Objects/AcsUserPendingMutations.php new file mode 100644 index 00000000..22a42feb --- /dev/null +++ b/src/Objects/AcsUserPendingMutations.php @@ -0,0 +1,29 @@ +created_at, + mutation_code: $json->mutation_code, + from: isset($json->from) + ? AcsUserFrom::from_json($json->from) + : null, + to: isset($json->to) ? AcsUserTo::from_json($json->to) : null + ); + } + + public function __construct( + public string $created_at, + public string $mutation_code, + public AcsUserFrom|null $from, + public AcsUserTo|null $to + ) { + } +} diff --git a/src/Objects/AcsUserTo.php b/src/Objects/AcsUserTo.php new file mode 100644 index 00000000..f55db154 --- /dev/null +++ b/src/Objects/AcsUserTo.php @@ -0,0 +1,20 @@ +acs_access_group_id ?? null + ); + } + + public function __construct(public string|null $acs_access_group_id) + { + } +} diff --git a/src/Objects/ConnectedAccountErrors.php b/src/Objects/ConnectedAccountErrors.php index c721eb03..4f5f5965 100644 --- a/src/Objects/ConnectedAccountErrors.php +++ b/src/Objects/ConnectedAccountErrors.php @@ -10,18 +10,27 @@ public static function from_json(mixed $json): ConnectedAccountErrors|null return null; } return new self( + created_at: $json->created_at, error_code: $json->error_code, - is_connected_account_error: $json->is_connected_account_error, message: $json->message, - created_at: $json->created_at ?? null + is_bridge_error: $json->is_bridge_error ?? null, + is_connected_account_error: $json->is_connected_account_error ?? + null, + salto_ks_metadata: isset($json->salto_ks_metadata) + ? ConnectedAccountSaltoKsMetadata::from_json( + $json->salto_ks_metadata + ) + : null ); } public function __construct( + public string $created_at, public string $error_code, - public bool $is_connected_account_error, public string $message, - public string|null $created_at + public bool|null $is_bridge_error, + public bool|null $is_connected_account_error, + public ConnectedAccountSaltoKsMetadata|null $salto_ks_metadata ) { } } diff --git a/src/Objects/ConnectedAccountSaltoKsMetadata.php b/src/Objects/ConnectedAccountSaltoKsMetadata.php new file mode 100644 index 00000000..57fb5ef1 --- /dev/null +++ b/src/Objects/ConnectedAccountSaltoKsMetadata.php @@ -0,0 +1,24 @@ + ConnectedAccountSites::from_json($s), + $json->sites ?? [] + ) + ); + } + + public function __construct(public array $sites) + { + } +} diff --git a/src/Objects/ConnectedAccountSites.php b/src/Objects/ConnectedAccountSites.php new file mode 100644 index 00000000..1e2d116f --- /dev/null +++ b/src/Objects/ConnectedAccountSites.php @@ -0,0 +1,27 @@ +site_id, + site_name: $json->site_name, + site_user_subscription_limit: $json->site_user_subscription_limit, + subscribed_site_user_count: $json->subscribed_site_user_count + ); + } + + public function __construct( + public string $site_id, + public string $site_name, + public mixed $site_user_subscription_limit, + public mixed $subscribed_site_user_count + ) { + } +} diff --git a/src/Objects/ConnectedAccountWarnings.php b/src/Objects/ConnectedAccountWarnings.php index 43e69bd8..d97c7661 100644 --- a/src/Objects/ConnectedAccountWarnings.php +++ b/src/Objects/ConnectedAccountWarnings.php @@ -10,16 +10,22 @@ public static function from_json(mixed $json): ConnectedAccountWarnings|null return null; } return new self( + created_at: $json->created_at, message: $json->message, warning_code: $json->warning_code, - created_at: $json->created_at ?? null + salto_ks_metadata: isset($json->salto_ks_metadata) + ? ConnectedAccountSaltoKsMetadata::from_json( + $json->salto_ks_metadata + ) + : null ); } public function __construct( + public string $created_at, public string $message, public string $warning_code, - public string|null $created_at + public ConnectedAccountSaltoKsMetadata|null $salto_ks_metadata ) { } } diff --git a/src/Objects/DeviceErrors.php b/src/Objects/DeviceErrors.php index ecd009fa..166b6f9a 100644 --- a/src/Objects/DeviceErrors.php +++ b/src/Objects/DeviceErrors.php @@ -10,9 +10,10 @@ public static function from_json(mixed $json): DeviceErrors|null return null; } return new self( + created_at: $json->created_at, error_code: $json->error_code, message: $json->message, - created_at: $json->created_at ?? null, + is_bridge_error: $json->is_bridge_error ?? null, is_connected_account_error: $json->is_connected_account_error ?? null, is_device_error: $json->is_device_error ?? null @@ -20,9 +21,10 @@ public static function from_json(mixed $json): DeviceErrors|null } public function __construct( + public string $created_at, public string $error_code, public string $message, - public string|null $created_at, + public bool|null $is_bridge_error, public bool|null $is_connected_account_error, public bool|null $is_device_error ) { diff --git a/src/Objects/DeviceFeatures.php b/src/Objects/DeviceFeatures.php index b4c81580..98708fa7 100644 --- a/src/Objects/DeviceFeatures.php +++ b/src/Objects/DeviceFeatures.php @@ -14,7 +14,8 @@ public static function from_json(mixed $json): DeviceFeatures|null lock_command: $json->lock_command, passcode: $json->passcode, passcode_management: $json->passcode_management, - unlock_via_gateway: $json->unlock_via_gateway + unlock_via_gateway: $json->unlock_via_gateway, + wifi: $json->wifi ); } @@ -23,7 +24,8 @@ public function __construct( public bool $lock_command, public bool $passcode, public bool $passcode_management, - public bool $unlock_via_gateway + public bool $unlock_via_gateway, + public bool $wifi ) { } } diff --git a/src/Objects/DeviceProperties.php b/src/Objects/DeviceProperties.php index 9a32e4e3..3eb6aefe 100644 --- a/src/Objects/DeviceProperties.php +++ b/src/Objects/DeviceProperties.php @@ -198,6 +198,9 @@ public static function from_json(mixed $json): DeviceProperties|null $json->seam_bridge_metadata ) : null, + sensi_metadata: isset($json->sensi_metadata) + ? DeviceSensiMetadata::from_json($json->sensi_metadata) + : null, serial_number: $json->serial_number ?? null, smartthings_metadata: isset($json->smartthings_metadata) ? DeviceSmartthingsMetadata::from_json( @@ -313,6 +316,7 @@ public function __construct( public DeviceSaltoSpaceCredentialServiceMetadata|null $salto_space_credential_service_metadata, public DeviceSchlageMetadata|null $schlage_metadata, public DeviceSeamBridgeMetadata|null $seam_bridge_metadata, + public DeviceSensiMetadata|null $sensi_metadata, public string|null $serial_number, public DeviceSmartthingsMetadata|null $smartthings_metadata, public array|null $supported_code_lengths, diff --git a/src/Objects/DeviceSensiMetadata.php b/src/Objects/DeviceSensiMetadata.php new file mode 100644 index 00000000..aace90a0 --- /dev/null +++ b/src/Objects/DeviceSensiMetadata.php @@ -0,0 +1,25 @@ +device_id, + device_name: $json->device_name, + product_type: $json->product_type + ); + } + + public function __construct( + public string $device_id, + public string $device_name, + public string $product_type + ) { + } +} diff --git a/src/Objects/DeviceWarnings.php b/src/Objects/DeviceWarnings.php index fa29faf0..db5e7aa8 100644 --- a/src/Objects/DeviceWarnings.php +++ b/src/Objects/DeviceWarnings.php @@ -10,16 +10,16 @@ public static function from_json(mixed $json): DeviceWarnings|null return null; } return new self( + created_at: $json->created_at, message: $json->message, - warning_code: $json->warning_code, - created_at: $json->created_at ?? null + warning_code: $json->warning_code ); } public function __construct( + public string $created_at, public string $message, - public string $warning_code, - public string|null $created_at + public string $warning_code ) { } } diff --git a/src/Objects/Event.php b/src/Objects/Event.php index 5a1030e6..be37a1c6 100644 --- a/src/Objects/Event.php +++ b/src/Objects/Event.php @@ -14,6 +14,7 @@ public static function from_json(mixed $json): Event|null acs_access_group_id: $json->acs_access_group_id ?? null, acs_credential_id: $json->acs_credential_id ?? null, acs_encoder_id: $json->acs_encoder_id ?? null, + acs_entrance_id: $json->acs_entrance_id ?? null, acs_system_id: $json->acs_system_id ?? null, acs_user_id: $json->acs_user_id ?? null, action_attempt_id: $json->action_attempt_id ?? null, @@ -34,6 +35,7 @@ public static function from_json(mixed $json): Event|null desired_temperature_fahrenheit: $json->desired_temperature_fahrenheit ?? null, device_id: $json->device_id ?? null, + device_name: $json->device_name ?? null, enrollment_automation_id: $json->enrollment_automation_id ?? null, error_code: $json->error_code ?? null, event_id: $json->event_id ?? null, @@ -71,6 +73,7 @@ public function __construct( public string|null $acs_access_group_id, public string|null $acs_credential_id, public string|null $acs_encoder_id, + public string|null $acs_entrance_id, public string|null $acs_system_id, public string|null $acs_user_id, public string|null $action_attempt_id, @@ -88,6 +91,7 @@ public function __construct( public float|null $desired_temperature_celsius, public float|null $desired_temperature_fahrenheit, public string|null $device_id, + public string|null $device_name, public string|null $enrollment_automation_id, public string|null $error_code, public string|null $event_id, diff --git a/src/Objects/Pagination.php b/src/Objects/Pagination.php new file mode 100644 index 00000000..58e41e44 --- /dev/null +++ b/src/Objects/Pagination.php @@ -0,0 +1,25 @@ +has_next_page, + next_page_cursor: $json->next_page_cursor ?? null, + next_page_url: $json->next_page_url ?? null + ); + } + + public function __construct( + public bool $has_next_page, + public string|null $next_page_cursor, + public string|null $next_page_url + ) { + } +} diff --git a/src/Objects/UnmanagedAccessCodeErrors.php b/src/Objects/UnmanagedAccessCodeErrors.php index 7240b0e2..e7f4d4cb 100644 --- a/src/Objects/UnmanagedAccessCodeErrors.php +++ b/src/Objects/UnmanagedAccessCodeErrors.php @@ -15,6 +15,7 @@ public static function from_json( message: $json->message, created_at: $json->created_at ?? null, is_access_code_error: $json->is_access_code_error ?? null, + is_bridge_error: $json->is_bridge_error ?? null, is_connected_account_error: $json->is_connected_account_error ?? null, is_device_error: $json->is_device_error ?? null @@ -26,6 +27,7 @@ public function __construct( public string $message, public string|null $created_at, public bool|null $is_access_code_error, + public bool|null $is_bridge_error, public bool|null $is_connected_account_error, public bool|null $is_device_error ) { diff --git a/src/Objects/UnmanagedAcsUser.php b/src/Objects/UnmanagedAcsUser.php index 5e938fdc..ae8cde13 100644 --- a/src/Objects/UnmanagedAcsUser.php +++ b/src/Objects/UnmanagedAcsUser.php @@ -37,6 +37,10 @@ public static function from_json(mixed $json): UnmanagedAcsUser|null full_name: $json->full_name ?? null, hid_acs_system_id: $json->hid_acs_system_id ?? null, is_suspended: $json->is_suspended ?? null, + pending_mutations: array_map( + fn($p) => UnmanagedAcsUserPendingMutations::from_json($p), + $json->pending_mutations ?? [] + ), phone_number: $json->phone_number ?? null, user_identity_id: $json->user_identity_id ?? null, is_latest_desired_state_synced_with_provider: $json->is_latest_desired_state_synced_with_provider ?? @@ -68,6 +72,7 @@ public function __construct( public string|null $full_name, public string|null $hid_acs_system_id, public bool|null $is_suspended, + public array|null $pending_mutations, public string|null $phone_number, public string|null $user_identity_id, public bool|null $is_latest_desired_state_synced_with_provider, diff --git a/src/Objects/UnmanagedAcsUserFrom.php b/src/Objects/UnmanagedAcsUserFrom.php new file mode 100644 index 00000000..47a251a0 --- /dev/null +++ b/src/Objects/UnmanagedAcsUserFrom.php @@ -0,0 +1,20 @@ +acs_access_group_id ?? null + ); + } + + public function __construct(public string|null $acs_access_group_id) + { + } +} diff --git a/src/Objects/UnmanagedAcsUserPendingMutations.php b/src/Objects/UnmanagedAcsUserPendingMutations.php new file mode 100644 index 00000000..b1469cbb --- /dev/null +++ b/src/Objects/UnmanagedAcsUserPendingMutations.php @@ -0,0 +1,32 @@ +created_at, + mutation_code: $json->mutation_code, + from: isset($json->from) + ? UnmanagedAcsUserFrom::from_json($json->from) + : null, + to: isset($json->to) + ? UnmanagedAcsUserTo::from_json($json->to) + : null + ); + } + + public function __construct( + public string $created_at, + public string $mutation_code, + public UnmanagedAcsUserFrom|null $from, + public UnmanagedAcsUserTo|null $to + ) { + } +} diff --git a/src/Objects/UnmanagedAcsUserTo.php b/src/Objects/UnmanagedAcsUserTo.php new file mode 100644 index 00000000..d2eb20ee --- /dev/null +++ b/src/Objects/UnmanagedAcsUserTo.php @@ -0,0 +1,20 @@ +acs_access_group_id ?? null + ); + } + + public function __construct(public string|null $acs_access_group_id) + { + } +} diff --git a/src/Objects/UnmanagedDeviceErrors.php b/src/Objects/UnmanagedDeviceErrors.php index 0b0f12a2..37c0b465 100644 --- a/src/Objects/UnmanagedDeviceErrors.php +++ b/src/Objects/UnmanagedDeviceErrors.php @@ -10,9 +10,10 @@ public static function from_json(mixed $json): UnmanagedDeviceErrors|null return null; } return new self( + created_at: $json->created_at, error_code: $json->error_code, message: $json->message, - created_at: $json->created_at ?? null, + is_bridge_error: $json->is_bridge_error ?? null, is_connected_account_error: $json->is_connected_account_error ?? null, is_device_error: $json->is_device_error ?? null @@ -20,9 +21,10 @@ public static function from_json(mixed $json): UnmanagedDeviceErrors|null } public function __construct( + public string $created_at, public string $error_code, public string $message, - public string|null $created_at, + public bool|null $is_bridge_error, public bool|null $is_connected_account_error, public bool|null $is_device_error ) { diff --git a/src/Objects/UnmanagedDeviceWarnings.php b/src/Objects/UnmanagedDeviceWarnings.php index 84cc664f..c7cbe962 100644 --- a/src/Objects/UnmanagedDeviceWarnings.php +++ b/src/Objects/UnmanagedDeviceWarnings.php @@ -10,16 +10,16 @@ public static function from_json(mixed $json): UnmanagedDeviceWarnings|null return null; } return new self( + created_at: $json->created_at, message: $json->message, - warning_code: $json->warning_code, - created_at: $json->created_at ?? null + warning_code: $json->warning_code ); } public function __construct( + public string $created_at, public string $message, - public string $warning_code, - public string|null $created_at + public string $warning_code ) { } } diff --git a/src/Objects/Workspace.php b/src/Objects/Workspace.php index 9ac24e25..a48dc00b 100644 --- a/src/Objects/Workspace.php +++ b/src/Objects/Workspace.php @@ -12,6 +12,7 @@ public static function from_json(mixed $json): Workspace|null return new self( company_name: $json->company_name, is_sandbox: $json->is_sandbox, + is_suspended: $json->is_suspended, name: $json->name, workspace_id: $json->workspace_id, connect_partner_name: $json->connect_partner_name ?? null @@ -21,6 +22,7 @@ public static function from_json(mixed $json): Workspace|null public function __construct( public string $company_name, public bool $is_sandbox, + public bool $is_suspended, public string $name, public string $workspace_id, public string|null $connect_partner_name diff --git a/src/Paginator.php b/src/Paginator.php index 696a704a..42526658 100644 --- a/src/Paginator.php +++ b/src/Paginator.php @@ -30,25 +30,25 @@ public function firstPage(): array return [$data, $this->pagination_cache[self::FIRST_PAGE]]; } - public function nextPage(string $nextPageCursor): array + public function nextPage(string $next_page_cursor): array { $callable = $this->callable; $params = $this->params; - $params["page_cursor"] = $nextPageCursor; + $params["page_cursor"] = $next_page_cursor; $params["on_response"] = fn($response) => $this->cachePagination( $response, - $nextPageCursor + $next_page_cursor ); $data = $callable($params); - return [$data, $this->pagination_cache[$nextPageCursor]]; + return [$data, $this->pagination_cache[$next_page_cursor]]; } - private function cachePagination($response, $nextPageCursor) + private function cachePagination($response, $next_page_cursor) { - $this->pagination_cache[$nextPageCursor] = $response->pagination; + $this->pagination_cache[$next_page_cursor] = $response->pagination; } public function flattenToArray(): array diff --git a/src/SeamClient.php b/src/SeamClient.php index eadf7bfc..df6389ac 100644 --- a/src/SeamClient.php +++ b/src/SeamClient.php @@ -21,6 +21,7 @@ use Seam\Objects\Event; use Seam\Objects\Network; use Seam\Objects\NoiseThreshold; +use Seam\Objects\Pagination; use Seam\Objects\Phone; use Seam\Objects\ThermostatSchedule; use Seam\Objects\UnmanagedAccessCode; @@ -105,11 +106,6 @@ public function __construct( $this->workspaces = new WorkspacesClient($this); } - public function createPaginator($callable, $params = []) - { - return new Paginator($callable, $params); - } - public function request($method, $path, $json = null, $query = null) { $options = [ @@ -158,6 +154,11 @@ public function request($method, $path, $json = null, $query = null) return $res_json; } + + public function createPaginator($request, $params = []) + { + return new Paginator($request, $params); + } } class AccessCodesClient @@ -174,79 +175,52 @@ public function __construct(SeamClient $seam) public function create( string $device_id, - ?string $name = null, - ?string $starts_at = null, - ?string $ends_at = null, - ?string $code = null, - ?bool $sync = null, + ?bool $allow_external_modification = null, ?bool $attempt_for_offline_device = null, + ?string $code = null, ?string $common_code_key = null, - ?bool $prefer_native_scheduling = null, - ?bool $use_backup_access_code_pool = null, - ?bool $allow_external_modification = null, + ?string $ends_at = null, ?bool $is_external_modification_allowed = null, - ?float $preferred_code_length = null, - ?bool $use_offline_access_code = null, ?bool $is_offline_access_code = null, ?bool $is_one_time_use = null, - ?string $max_time_rounding = null + ?string $max_time_rounding = null, + ?string $name = null, + ?bool $prefer_native_scheduling = null, + ?float $preferred_code_length = null, + ?string $starts_at = null, + ?bool $sync = null, + ?bool $use_backup_access_code_pool = null, + ?bool $use_offline_access_code = null ): AccessCode { $request_payload = []; if ($device_id !== null) { $request_payload["device_id"] = $device_id; } - if ($name !== null) { - $request_payload["name"] = $name; - } - if ($starts_at !== null) { - $request_payload["starts_at"] = $starts_at; - } - if ($ends_at !== null) { - $request_payload["ends_at"] = $ends_at; - } - if ($code !== null) { - $request_payload["code"] = $code; - } - if ($sync !== null) { - $request_payload["sync"] = $sync; + if ($allow_external_modification !== null) { + $request_payload[ + "allow_external_modification" + ] = $allow_external_modification; } if ($attempt_for_offline_device !== null) { $request_payload[ "attempt_for_offline_device" ] = $attempt_for_offline_device; } + if ($code !== null) { + $request_payload["code"] = $code; + } if ($common_code_key !== null) { $request_payload["common_code_key"] = $common_code_key; } - if ($prefer_native_scheduling !== null) { - $request_payload[ - "prefer_native_scheduling" - ] = $prefer_native_scheduling; - } - if ($use_backup_access_code_pool !== null) { - $request_payload[ - "use_backup_access_code_pool" - ] = $use_backup_access_code_pool; - } - if ($allow_external_modification !== null) { - $request_payload[ - "allow_external_modification" - ] = $allow_external_modification; + if ($ends_at !== null) { + $request_payload["ends_at"] = $ends_at; } if ($is_external_modification_allowed !== null) { $request_payload[ "is_external_modification_allowed" ] = $is_external_modification_allowed; } - if ($preferred_code_length !== null) { - $request_payload["preferred_code_length"] = $preferred_code_length; - } - if ($use_offline_access_code !== null) { - $request_payload[ - "use_offline_access_code" - ] = $use_offline_access_code; - } if ($is_offline_access_code !== null) { $request_payload[ "is_offline_access_code" @@ -258,6 +232,33 @@ public function create( if ($max_time_rounding !== null) { $request_payload["max_time_rounding"] = $max_time_rounding; } + if ($name !== null) { + $request_payload["name"] = $name; + } + if ($prefer_native_scheduling !== null) { + $request_payload[ + "prefer_native_scheduling" + ] = $prefer_native_scheduling; + } + if ($preferred_code_length !== null) { + $request_payload["preferred_code_length"] = $preferred_code_length; + } + if ($starts_at !== null) { + $request_payload["starts_at"] = $starts_at; + } + if ($sync !== null) { + $request_payload["sync"] = $sync; + } + if ($use_backup_access_code_pool !== null) { + $request_payload[ + "use_backup_access_code_pool" + ] = $use_backup_access_code_pool; + } + if ($use_offline_access_code !== null) { + $request_payload[ + "use_offline_access_code" + ] = $use_offline_access_code; + } $res = $this->seam->request( "POST", @@ -270,77 +271,53 @@ public function create( public function create_multiple( array $device_ids, + ?bool $allow_external_modification = null, + ?bool $attempt_for_offline_device = null, ?string $behavior_when_code_cannot_be_shared = null, - ?float $preferred_code_length = null, - ?string $name = null, - ?string $starts_at = null, - ?string $ends_at = null, ?string $code = null, - ?bool $attempt_for_offline_device = null, - ?bool $prefer_native_scheduling = null, - ?bool $use_backup_access_code_pool = null, - ?bool $allow_external_modification = null, + ?string $ends_at = null, ?bool $is_external_modification_allowed = null, - ?bool $use_offline_access_code = null, ?bool $is_offline_access_code = null, ?bool $is_one_time_use = null, - ?string $max_time_rounding = null + ?string $max_time_rounding = null, + ?string $name = null, + ?bool $prefer_native_scheduling = null, + ?float $preferred_code_length = null, + ?string $starts_at = null, + ?bool $use_backup_access_code_pool = null, + ?bool $use_offline_access_code = null ): array { $request_payload = []; if ($device_ids !== null) { $request_payload["device_ids"] = $device_ids; } - if ($behavior_when_code_cannot_be_shared !== null) { + if ($allow_external_modification !== null) { $request_payload[ - "behavior_when_code_cannot_be_shared" - ] = $behavior_when_code_cannot_be_shared; - } - if ($preferred_code_length !== null) { - $request_payload["preferred_code_length"] = $preferred_code_length; - } - if ($name !== null) { - $request_payload["name"] = $name; - } - if ($starts_at !== null) { - $request_payload["starts_at"] = $starts_at; - } - if ($ends_at !== null) { - $request_payload["ends_at"] = $ends_at; - } - if ($code !== null) { - $request_payload["code"] = $code; + "allow_external_modification" + ] = $allow_external_modification; } if ($attempt_for_offline_device !== null) { $request_payload[ "attempt_for_offline_device" ] = $attempt_for_offline_device; } - if ($prefer_native_scheduling !== null) { + if ($behavior_when_code_cannot_be_shared !== null) { $request_payload[ - "prefer_native_scheduling" - ] = $prefer_native_scheduling; + "behavior_when_code_cannot_be_shared" + ] = $behavior_when_code_cannot_be_shared; } - if ($use_backup_access_code_pool !== null) { - $request_payload[ - "use_backup_access_code_pool" - ] = $use_backup_access_code_pool; + if ($code !== null) { + $request_payload["code"] = $code; } - if ($allow_external_modification !== null) { - $request_payload[ - "allow_external_modification" - ] = $allow_external_modification; + if ($ends_at !== null) { + $request_payload["ends_at"] = $ends_at; } if ($is_external_modification_allowed !== null) { $request_payload[ "is_external_modification_allowed" ] = $is_external_modification_allowed; } - if ($use_offline_access_code !== null) { - $request_payload[ - "use_offline_access_code" - ] = $use_offline_access_code; - } if ($is_offline_access_code !== null) { $request_payload[ "is_offline_access_code" @@ -352,6 +329,30 @@ public function create_multiple( if ($max_time_rounding !== null) { $request_payload["max_time_rounding"] = $max_time_rounding; } + if ($name !== null) { + $request_payload["name"] = $name; + } + if ($prefer_native_scheduling !== null) { + $request_payload[ + "prefer_native_scheduling" + ] = $prefer_native_scheduling; + } + if ($preferred_code_length !== null) { + $request_payload["preferred_code_length"] = $preferred_code_length; + } + if ($starts_at !== null) { + $request_payload["starts_at"] = $starts_at; + } + if ($use_backup_access_code_pool !== null) { + $request_payload[ + "use_backup_access_code_pool" + ] = $use_backup_access_code_pool; + } + if ($use_offline_access_code !== null) { + $request_payload[ + "use_offline_access_code" + ] = $use_offline_access_code; + } $res = $this->seam->request( "POST", @@ -407,21 +408,21 @@ public function generate_code(string $device_id): AccessCode } public function get( - ?string $device_id = null, ?string $access_code_id = null, - ?string $code = null + ?string $code = null, + ?string $device_id = null ): AccessCode { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } if ($access_code_id !== null) { $request_payload["access_code_id"] = $access_code_id; } if ($code !== null) { $request_payload["code"] = $code; } + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } $res = $this->seam->request( "POST", @@ -433,19 +434,19 @@ public function get( } public function list( - ?string $device_id = null, ?array $access_code_ids = null, + ?string $device_id = null, ?string $user_identifier_key = null, ?callable $on_response = null ): array { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } if ($access_code_ids !== null) { $request_payload["access_code_ids"] = $access_code_ids; } + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } if ($user_identifier_key !== null) { $request_payload["user_identifier_key"] = $user_identifier_key; } @@ -485,77 +486,56 @@ public function pull_backup_access_code(string $access_code_id): AccessCode public function update( string $access_code_id, - ?string $name = null, - ?string $starts_at = null, - ?string $ends_at = null, - ?string $code = null, - ?bool $sync = null, - ?bool $attempt_for_offline_device = null, - ?bool $prefer_native_scheduling = null, - ?bool $use_backup_access_code_pool = null, ?bool $allow_external_modification = null, + ?bool $attempt_for_offline_device = null, + ?string $code = null, + ?string $device_id = null, + ?string $ends_at = null, ?bool $is_external_modification_allowed = null, - ?float $preferred_code_length = null, - ?bool $use_offline_access_code = null, + ?bool $is_managed = null, ?bool $is_offline_access_code = null, ?bool $is_one_time_use = null, ?string $max_time_rounding = null, - ?string $device_id = null, + ?string $name = null, + ?bool $prefer_native_scheduling = null, + ?float $preferred_code_length = null, + ?string $starts_at = null, + ?bool $sync = null, ?string $type = null, - ?bool $is_managed = null + ?bool $use_backup_access_code_pool = null, + ?bool $use_offline_access_code = null ): void { $request_payload = []; if ($access_code_id !== null) { $request_payload["access_code_id"] = $access_code_id; } - if ($name !== null) { - $request_payload["name"] = $name; - } - if ($starts_at !== null) { - $request_payload["starts_at"] = $starts_at; - } - if ($ends_at !== null) { - $request_payload["ends_at"] = $ends_at; - } - if ($code !== null) { - $request_payload["code"] = $code; - } - if ($sync !== null) { - $request_payload["sync"] = $sync; + if ($allow_external_modification !== null) { + $request_payload[ + "allow_external_modification" + ] = $allow_external_modification; } if ($attempt_for_offline_device !== null) { $request_payload[ "attempt_for_offline_device" ] = $attempt_for_offline_device; } - if ($prefer_native_scheduling !== null) { - $request_payload[ - "prefer_native_scheduling" - ] = $prefer_native_scheduling; + if ($code !== null) { + $request_payload["code"] = $code; } - if ($use_backup_access_code_pool !== null) { - $request_payload[ - "use_backup_access_code_pool" - ] = $use_backup_access_code_pool; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - if ($allow_external_modification !== null) { - $request_payload[ - "allow_external_modification" - ] = $allow_external_modification; + if ($ends_at !== null) { + $request_payload["ends_at"] = $ends_at; } if ($is_external_modification_allowed !== null) { $request_payload[ "is_external_modification_allowed" ] = $is_external_modification_allowed; } - if ($preferred_code_length !== null) { - $request_payload["preferred_code_length"] = $preferred_code_length; - } - if ($use_offline_access_code !== null) { - $request_payload[ - "use_offline_access_code" - ] = $use_offline_access_code; + if ($is_managed !== null) { + $request_payload["is_managed"] = $is_managed; } if ($is_offline_access_code !== null) { $request_payload[ @@ -568,14 +548,35 @@ public function update( if ($max_time_rounding !== null) { $request_payload["max_time_rounding"] = $max_time_rounding; } - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($name !== null) { + $request_payload["name"] = $name; + } + if ($prefer_native_scheduling !== null) { + $request_payload[ + "prefer_native_scheduling" + ] = $prefer_native_scheduling; + } + if ($preferred_code_length !== null) { + $request_payload["preferred_code_length"] = $preferred_code_length; + } + if ($starts_at !== null) { + $request_payload["starts_at"] = $starts_at; + } + if ($sync !== null) { + $request_payload["sync"] = $sync; } if ($type !== null) { $request_payload["type"] = $type; } - if ($is_managed !== null) { - $request_payload["is_managed"] = $is_managed; + if ($use_backup_access_code_pool !== null) { + $request_payload[ + "use_backup_access_code_pool" + ] = $use_backup_access_code_pool; + } + if ($use_offline_access_code !== null) { + $request_payload[ + "use_offline_access_code" + ] = $use_offline_access_code; } $this->seam->request( @@ -588,8 +589,8 @@ public function update( public function update_multiple( string $common_code_key, ?string $ends_at = null, - ?string $starts_at = null, - ?string $name = null + ?string $name = null, + ?string $starts_at = null ): void { $request_payload = []; @@ -599,12 +600,12 @@ public function update_multiple( if ($ends_at !== null) { $request_payload["ends_at"] = $ends_at; } - if ($starts_at !== null) { - $request_payload["starts_at"] = $starts_at; - } if ($name !== null) { $request_payload["name"] = $name; } + if ($starts_at !== null) { + $request_payload["starts_at"] = $starts_at; + } $this->seam->request( "POST", @@ -614,7 +615,7 @@ public function update_multiple( } } -class ActionAttemptsClient +class AccessCodesSimulateClient { private SeamClient $seam; @@ -623,107 +624,34 @@ public function __construct(SeamClient $seam) $this->seam = $seam; } - public function get(string $action_attempt_id): ActionAttempt - { - $request_payload = []; - - if ($action_attempt_id !== null) { - $request_payload["action_attempt_id"] = $action_attempt_id; - } - - $res = $this->seam->request( - "POST", - "/action_attempts/get", - json: (object) $request_payload - ); - - return ActionAttempt::from_json($res->action_attempt); - } - - public function list( - array $action_attempt_ids, - ?callable $on_response = null - ): array { + public function create_unmanaged_access_code( + string $code, + string $device_id, + string $name + ): UnmanagedAccessCode { $request_payload = []; - if ($action_attempt_ids !== null) { - $request_payload["action_attempt_ids"] = $action_attempt_ids; - } - - $res = $this->seam->request( - "POST", - "/action_attempts/list", - json: (object) $request_payload - ); - - if ($on_response !== null) { - $on_response($res); - } - - return array_map( - fn($r) => ActionAttempt::from_json($r), - $res->action_attempts - ); - } - public function poll_until_ready( - string $action_attempt_id, - float $timeout = 20.0 - ): ActionAttempt { - $seam = $this->seam; - $time_waiting = 0.0; - $polling_interval = 0.4; - $action_attempt = $seam->action_attempts->get($action_attempt_id); - - while ($action_attempt->status == "pending") { - $action_attempt = $seam->action_attempts->get( - $action_attempt->action_attempt_id - ); - if ($time_waiting > $timeout) { - throw new ActionAttemptTimeoutError($action_attempt, $timeout); - } - $time_waiting += $polling_interval; - usleep($polling_interval * 1000000); + if ($code !== null) { + $request_payload["code"] = $code; } - - if ($action_attempt->status == "error") { - throw new ActionAttemptFailedError($action_attempt); + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - - return $action_attempt; - } -} - -class BridgesClient -{ - private SeamClient $seam; - - public function __construct(SeamClient $seam) - { - $this->seam = $seam; - } - - public function get(string $bridge_id): void - { - $request_payload = []; - - if ($bridge_id !== null) { - $request_payload["bridge_id"] = $bridge_id; + if ($name !== null) { + $request_payload["name"] = $name; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/bridges/get", + "/access_codes/simulate/create_unmanaged_access_code", json: (object) $request_payload ); - } - public function list(): void - { - $this->seam->request("POST", "/bridges/list"); + return UnmanagedAccessCode::from_json($res->access_code); } } -class ClientSessionsClient +class AccessCodesUnmanagedClient { private SeamClient $seam; @@ -732,204 +660,154 @@ public function __construct(SeamClient $seam) $this->seam = $seam; } - public function create( - ?string $user_identifier_key = null, - ?array $connect_webview_ids = null, - ?array $connected_account_ids = null, - ?array $user_identity_ids = null, - ?string $expires_at = null - ): ClientSession { + public function convert_to_managed( + string $access_code_id, + ?bool $allow_external_modification = null, + ?bool $force = null, + ?bool $is_external_modification_allowed = null, + ?bool $sync = null + ): void { $request_payload = []; - if ($user_identifier_key !== null) { - $request_payload["user_identifier_key"] = $user_identifier_key; + if ($access_code_id !== null) { + $request_payload["access_code_id"] = $access_code_id; } - if ($connect_webview_ids !== null) { - $request_payload["connect_webview_ids"] = $connect_webview_ids; + if ($allow_external_modification !== null) { + $request_payload[ + "allow_external_modification" + ] = $allow_external_modification; } - if ($connected_account_ids !== null) { - $request_payload["connected_account_ids"] = $connected_account_ids; + if ($force !== null) { + $request_payload["force"] = $force; } - if ($user_identity_ids !== null) { - $request_payload["user_identity_ids"] = $user_identity_ids; + if ($is_external_modification_allowed !== null) { + $request_payload[ + "is_external_modification_allowed" + ] = $is_external_modification_allowed; } - if ($expires_at !== null) { - $request_payload["expires_at"] = $expires_at; + if ($sync !== null) { + $request_payload["sync"] = $sync; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/client_sessions/create", + "/access_codes/unmanaged/convert_to_managed", json: (object) $request_payload ); - - return ClientSession::from_json($res->client_session); } - public function delete(string $client_session_id): void + public function delete(string $access_code_id, ?bool $sync = null): void { $request_payload = []; - if ($client_session_id !== null) { - $request_payload["client_session_id"] = $client_session_id; + if ($access_code_id !== null) { + $request_payload["access_code_id"] = $access_code_id; + } + if ($sync !== null) { + $request_payload["sync"] = $sync; } $this->seam->request( "POST", - "/client_sessions/delete", + "/access_codes/unmanaged/delete", json: (object) $request_payload ); } public function get( - ?string $client_session_id = null, - ?string $user_identifier_key = null - ): ClientSession { + ?string $access_code_id = null, + ?string $code = null, + ?string $device_id = null + ): UnmanagedAccessCode { $request_payload = []; - if ($client_session_id !== null) { - $request_payload["client_session_id"] = $client_session_id; + if ($access_code_id !== null) { + $request_payload["access_code_id"] = $access_code_id; } - if ($user_identifier_key !== null) { - $request_payload["user_identifier_key"] = $user_identifier_key; + if ($code !== null) { + $request_payload["code"] = $code; + } + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } $res = $this->seam->request( "POST", - "/client_sessions/get", + "/access_codes/unmanaged/get", json: (object) $request_payload ); - return ClientSession::from_json($res->client_session); + return UnmanagedAccessCode::from_json($res->access_code); } - public function get_or_create( + public function list( + string $device_id, ?string $user_identifier_key = null, - ?array $connect_webview_ids = null, - ?array $connected_account_ids = null, - ?array $user_identity_ids = null, - ?string $expires_at = null - ): ClientSession { + ?callable $on_response = null + ): array { $request_payload = []; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } if ($user_identifier_key !== null) { $request_payload["user_identifier_key"] = $user_identifier_key; } - if ($connect_webview_ids !== null) { - $request_payload["connect_webview_ids"] = $connect_webview_ids; - } - if ($connected_account_ids !== null) { - $request_payload["connected_account_ids"] = $connected_account_ids; - } - if ($user_identity_ids !== null) { - $request_payload["user_identity_ids"] = $user_identity_ids; - } - if ($expires_at !== null) { - $request_payload["expires_at"] = $expires_at; - } $res = $this->seam->request( "POST", - "/client_sessions/get_or_create", + "/access_codes/unmanaged/list", json: (object) $request_payload ); - return ClientSession::from_json($res->client_session); - } + if ($on_response !== null) { + $on_response($res); + } - public function grant_access( - ?string $client_session_id = null, - ?string $user_identifier_key = null, - ?array $connected_account_ids = null, - ?array $connect_webview_ids = null, - ?array $user_identity_ids = null - ): void { - $request_payload = []; - - if ($client_session_id !== null) { - $request_payload["client_session_id"] = $client_session_id; - } - if ($user_identifier_key !== null) { - $request_payload["user_identifier_key"] = $user_identifier_key; - } - if ($connected_account_ids !== null) { - $request_payload["connected_account_ids"] = $connected_account_ids; - } - if ($connect_webview_ids !== null) { - $request_payload["connect_webview_ids"] = $connect_webview_ids; - } - if ($user_identity_ids !== null) { - $request_payload["user_identity_ids"] = $user_identity_ids; - } - - $this->seam->request( - "POST", - "/client_sessions/grant_access", - json: (object) $request_payload + return array_map( + fn($r) => UnmanagedAccessCode::from_json($r), + $res->access_codes ); } - public function list( - ?string $client_session_id = null, - ?string $user_identifier_key = null, - ?string $connect_webview_id = null, - ?bool $without_user_identifier_key = null, - ?string $user_identity_id = null, - ?callable $on_response = null - ): array { + public function update( + string $access_code_id, + bool $is_managed, + ?bool $allow_external_modification = null, + ?bool $force = null, + ?bool $is_external_modification_allowed = null + ): void { $request_payload = []; - if ($client_session_id !== null) { - $request_payload["client_session_id"] = $client_session_id; - } - if ($user_identifier_key !== null) { - $request_payload["user_identifier_key"] = $user_identifier_key; + if ($access_code_id !== null) { + $request_payload["access_code_id"] = $access_code_id; } - if ($connect_webview_id !== null) { - $request_payload["connect_webview_id"] = $connect_webview_id; + if ($is_managed !== null) { + $request_payload["is_managed"] = $is_managed; } - if ($without_user_identifier_key !== null) { + if ($allow_external_modification !== null) { $request_payload[ - "without_user_identifier_key" - ] = $without_user_identifier_key; - } - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; + "allow_external_modification" + ] = $allow_external_modification; } - - $res = $this->seam->request( - "POST", - "/client_sessions/list", - json: (object) $request_payload - ); - - if ($on_response !== null) { - $on_response($res); + if ($force !== null) { + $request_payload["force"] = $force; } - - return array_map( - fn($r) => ClientSession::from_json($r), - $res->client_sessions - ); - } - - public function revoke(string $client_session_id): void - { - $request_payload = []; - - if ($client_session_id !== null) { - $request_payload["client_session_id"] = $client_session_id; + if ($is_external_modification_allowed !== null) { + $request_payload[ + "is_external_modification_allowed" + ] = $is_external_modification_allowed; } $this->seam->request( "POST", - "/client_sessions/revoke", + "/access_codes/unmanaged/update", json: (object) $request_payload ); } } -class ConnectWebviewsClient +class AcsAccessGroupsClient { private SeamClient $seam; @@ -938,111 +816,60 @@ public function __construct(SeamClient $seam) $this->seam = $seam; } - public function create( - ?string $device_selection_mode = null, - ?string $custom_redirect_url = null, - ?string $custom_redirect_failure_url = null, - ?array $accepted_providers = null, - ?string $provider_category = null, - mixed $custom_metadata = null, - ?bool $automatically_manage_new_devices = null, - ?bool $wait_for_device_creation = null - ): ConnectWebview { + public function add_user( + string $acs_access_group_id, + string $acs_user_id + ): void { $request_payload = []; - if ($device_selection_mode !== null) { - $request_payload["device_selection_mode"] = $device_selection_mode; - } - if ($custom_redirect_url !== null) { - $request_payload["custom_redirect_url"] = $custom_redirect_url; - } - if ($custom_redirect_failure_url !== null) { - $request_payload[ - "custom_redirect_failure_url" - ] = $custom_redirect_failure_url; - } - if ($accepted_providers !== null) { - $request_payload["accepted_providers"] = $accepted_providers; - } - if ($provider_category !== null) { - $request_payload["provider_category"] = $provider_category; - } - if ($custom_metadata !== null) { - $request_payload["custom_metadata"] = $custom_metadata; - } - if ($automatically_manage_new_devices !== null) { - $request_payload[ - "automatically_manage_new_devices" - ] = $automatically_manage_new_devices; - } - if ($wait_for_device_creation !== null) { - $request_payload[ - "wait_for_device_creation" - ] = $wait_for_device_creation; + if ($acs_access_group_id !== null) { + $request_payload["acs_access_group_id"] = $acs_access_group_id; } - - $res = $this->seam->request( - "POST", - "/connect_webviews/create", - json: (object) $request_payload - ); - - return ConnectWebview::from_json($res->connect_webview); - } - - public function delete(string $connect_webview_id): void - { - $request_payload = []; - - if ($connect_webview_id !== null) { - $request_payload["connect_webview_id"] = $connect_webview_id; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } $this->seam->request( "POST", - "/connect_webviews/delete", + "/acs/access_groups/add_user", json: (object) $request_payload ); } - public function get(string $connect_webview_id): ConnectWebview + public function get(string $acs_access_group_id): AcsAccessGroup { $request_payload = []; - if ($connect_webview_id !== null) { - $request_payload["connect_webview_id"] = $connect_webview_id; + if ($acs_access_group_id !== null) { + $request_payload["acs_access_group_id"] = $acs_access_group_id; } $res = $this->seam->request( "POST", - "/connect_webviews/get", + "/acs/access_groups/get", json: (object) $request_payload ); - return ConnectWebview::from_json($res->connect_webview); + return AcsAccessGroup::from_json($res->acs_access_group); } public function list( - ?string $user_identifier_key = null, - mixed $custom_metadata_has = null, - ?float $limit = null, + ?string $acs_system_id = null, + ?string $acs_user_id = null, ?callable $on_response = null ): array { $request_payload = []; - if ($user_identifier_key !== null) { - $request_payload["user_identifier_key"] = $user_identifier_key; - } - if ($custom_metadata_has !== null) { - $request_payload["custom_metadata_has"] = $custom_metadata_has; + if ($acs_system_id !== null) { + $request_payload["acs_system_id"] = $acs_system_id; } - if ($limit !== null) { - $request_payload["limit"] = $limit; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } $res = $this->seam->request( "POST", - "/connect_webviews/list", + "/acs/access_groups/list", json: (object) $request_payload ); @@ -1051,229 +878,251 @@ public function list( } return array_map( - fn($r) => ConnectWebview::from_json($r), - $res->connect_webviews + fn($r) => AcsAccessGroup::from_json($r), + $res->acs_access_groups ); } -} - -class ConnectedAccountsClient -{ - private SeamClient $seam; - - public function __construct(SeamClient $seam) - { - $this->seam = $seam; - } - public function delete( - string $connected_account_id, - ?bool $sync = null - ): void { + public function list_accessible_entrances( + string $acs_access_group_id + ): array { $request_payload = []; - if ($connected_account_id !== null) { - $request_payload["connected_account_id"] = $connected_account_id; - } - if ($sync !== null) { - $request_payload["sync"] = $sync; + if ($acs_access_group_id !== null) { + $request_payload["acs_access_group_id"] = $acs_access_group_id; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/connected_accounts/delete", + "/acs/access_groups/list_accessible_entrances", json: (object) $request_payload ); + + return array_map( + fn($r) => AcsEntrance::from_json($r), + $res->acs_entrances + ); } - public function get( - ?string $connected_account_id = null, - ?string $email = null - ): ConnectedAccount { + public function list_users(string $acs_access_group_id): array + { $request_payload = []; - if ($connected_account_id !== null) { - $request_payload["connected_account_id"] = $connected_account_id; - } - if ($email !== null) { - $request_payload["email"] = $email; + if ($acs_access_group_id !== null) { + $request_payload["acs_access_group_id"] = $acs_access_group_id; } $res = $this->seam->request( "POST", - "/connected_accounts/get", + "/acs/access_groups/list_users", json: (object) $request_payload ); - return ConnectedAccount::from_json($res->connected_account); + return array_map(fn($r) => AcsUser::from_json($r), $res->acs_users); } - public function list( - ?string $user_identifier_key = null, - mixed $custom_metadata_has = null, - mixed $limit = null, - ?string $page_cursor = null, - ?callable $on_response = null - ): array { + public function remove_user( + string $acs_access_group_id, + string $acs_user_id + ): void { $request_payload = []; - if ($user_identifier_key !== null) { - $request_payload["user_identifier_key"] = $user_identifier_key; - } - if ($custom_metadata_has !== null) { - $request_payload["custom_metadata_has"] = $custom_metadata_has; - } - if ($limit !== null) { - $request_payload["limit"] = $limit; + if ($acs_access_group_id !== null) { + $request_payload["acs_access_group_id"] = $acs_access_group_id; } - if ($page_cursor !== null) { - $request_payload["page_cursor"] = $page_cursor; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/connected_accounts/list", + "/acs/access_groups/remove_user", json: (object) $request_payload ); + } +} - if ($on_response !== null) { - $on_response($res); +class AcsClient +{ + private SeamClient $seam; + public AcsAccessGroupsClient $access_groups; + public AcsCredentialsClient $credentials; + public AcsEncodersClient $encoders; + public AcsEntrancesClient $entrances; + public AcsSystemsClient $systems; + public AcsUsersClient $users; + public function __construct(SeamClient $seam) + { + $this->seam = $seam; + $this->access_groups = new AcsAccessGroupsClient($seam); + $this->credentials = new AcsCredentialsClient($seam); + $this->encoders = new AcsEncodersClient($seam); + $this->entrances = new AcsEntrancesClient($seam); + $this->systems = new AcsSystemsClient($seam); + $this->users = new AcsUsersClient($seam); + } +} + +class AcsCredentialsClient +{ + private SeamClient $seam; + + public function __construct(SeamClient $seam) + { + $this->seam = $seam; + } + + public function assign(string $acs_credential_id, string $acs_user_id): void + { + $request_payload = []; + + if ($acs_credential_id !== null) { + $request_payload["acs_credential_id"] = $acs_credential_id; + } + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } - return array_map( - fn($r) => ConnectedAccount::from_json($r), - $res->connected_accounts + $this->seam->request( + "POST", + "/acs/credentials/assign", + json: (object) $request_payload ); } - public function update( - string $connected_account_id, - ?bool $automatically_manage_new_devices = null, - mixed $custom_metadata = null - ): void { + public function create( + string $access_method, + string $acs_user_id, + ?array $allowed_acs_entrance_ids = null, + mixed $assa_abloy_vostio_metadata = null, + ?string $code = null, + ?string $credential_manager_acs_system_id = null, + ?string $ends_at = null, + ?bool $is_multi_phone_sync_credential = null, + mixed $salto_space_metadata = null, + ?string $starts_at = null, + mixed $visionline_metadata = null + ): AcsCredential { $request_payload = []; - if ($connected_account_id !== null) { - $request_payload["connected_account_id"] = $connected_account_id; + if ($access_method !== null) { + $request_payload["access_method"] = $access_method; } - if ($automatically_manage_new_devices !== null) { + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; + } + if ($allowed_acs_entrance_ids !== null) { $request_payload[ - "automatically_manage_new_devices" - ] = $automatically_manage_new_devices; + "allowed_acs_entrance_ids" + ] = $allowed_acs_entrance_ids; } - if ($custom_metadata !== null) { - $request_payload["custom_metadata"] = $custom_metadata; + if ($assa_abloy_vostio_metadata !== null) { + $request_payload[ + "assa_abloy_vostio_metadata" + ] = $assa_abloy_vostio_metadata; + } + if ($code !== null) { + $request_payload["code"] = $code; + } + if ($credential_manager_acs_system_id !== null) { + $request_payload[ + "credential_manager_acs_system_id" + ] = $credential_manager_acs_system_id; + } + if ($ends_at !== null) { + $request_payload["ends_at"] = $ends_at; + } + if ($is_multi_phone_sync_credential !== null) { + $request_payload[ + "is_multi_phone_sync_credential" + ] = $is_multi_phone_sync_credential; + } + if ($salto_space_metadata !== null) { + $request_payload["salto_space_metadata"] = $salto_space_metadata; + } + if ($starts_at !== null) { + $request_payload["starts_at"] = $starts_at; + } + if ($visionline_metadata !== null) { + $request_payload["visionline_metadata"] = $visionline_metadata; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/connected_accounts/update", + "/acs/credentials/create", json: (object) $request_payload ); + + return AcsCredential::from_json($res->acs_credential); } -} -class DevicesClient -{ - private SeamClient $seam; - public DevicesSimulateClient $simulate; - public DevicesUnmanagedClient $unmanaged; - public function __construct(SeamClient $seam) + public function delete(string $acs_credential_id): void { - $this->seam = $seam; - $this->simulate = new DevicesSimulateClient($seam); - $this->unmanaged = new DevicesUnmanagedClient($seam); + $request_payload = []; + + if ($acs_credential_id !== null) { + $request_payload["acs_credential_id"] = $acs_credential_id; + } + + $this->seam->request( + "POST", + "/acs/credentials/delete", + json: (object) $request_payload + ); } - public function get(?string $device_id = null, ?string $name = null): Device + public function get(string $acs_credential_id): AcsCredential { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($name !== null) { - $request_payload["name"] = $name; + if ($acs_credential_id !== null) { + $request_payload["acs_credential_id"] = $acs_credential_id; } $res = $this->seam->request( "POST", - "/devices/get", + "/acs/credentials/get", json: (object) $request_payload ); - return Device::from_json($res->device); + return AcsCredential::from_json($res->acs_credential); } public function list( - ?string $connected_account_id = null, - ?array $connected_account_ids = null, - ?string $connect_webview_id = null, - ?string $device_type = null, - ?array $device_types = null, - ?string $manufacturer = null, - ?array $device_ids = null, - ?float $limit = null, + ?string $acs_user_id = null, + ?string $acs_system_id = null, + ?string $user_identity_id = null, ?string $created_before = null, - ?string $user_identifier_key = null, - mixed $custom_metadata_has = null, - ?array $include_if = null, - ?array $exclude_if = null, - ?string $unstable_location_id = null, - ?callable $on_response = null, - ?string $page_cursor = null + ?bool $is_multi_phone_sync_credential = null, + ?float $limit = null, + ?callable $on_response = null ): array { $request_payload = []; - if ($connected_account_id !== null) { - $request_payload["connected_account_id"] = $connected_account_id; - } - if ($connected_account_ids !== null) { - $request_payload["connected_account_ids"] = $connected_account_ids; - } - if ($connect_webview_id !== null) { - $request_payload["connect_webview_id"] = $connect_webview_id; - } - if ($device_type !== null) { - $request_payload["device_type"] = $device_type; - } - if ($device_types !== null) { - $request_payload["device_types"] = $device_types; - } - if ($manufacturer !== null) { - $request_payload["manufacturer"] = $manufacturer; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } - if ($device_ids !== null) { - $request_payload["device_ids"] = $device_ids; + if ($acs_system_id !== null) { + $request_payload["acs_system_id"] = $acs_system_id; } - if ($limit !== null) { - $request_payload["limit"] = $limit; + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; } if ($created_before !== null) { $request_payload["created_before"] = $created_before; } - if ($user_identifier_key !== null) { - $request_payload["user_identifier_key"] = $user_identifier_key; - } - if ($custom_metadata_has !== null) { - $request_payload["custom_metadata_has"] = $custom_metadata_has; - } - if ($include_if !== null) { - $request_payload["include_if"] = $include_if; - } - if ($exclude_if !== null) { - $request_payload["exclude_if"] = $exclude_if; - } - if ($unstable_location_id !== null) { - $request_payload["unstable_location_id"] = $unstable_location_id; + if ($is_multi_phone_sync_credential !== null) { + $request_payload[ + "is_multi_phone_sync_credential" + ] = $is_multi_phone_sync_credential; } - if ($page_cursor !== null) { - $request_payload["page_cursor"] = $page_cursor; + if ($limit !== null) { + $request_payload["limit"] = $limit; } $res = $this->seam->request( "POST", - "/devices/list", + "/acs/credentials/list", json: (object) $request_payload ); @@ -1281,179 +1130,78 @@ public function list( $on_response($res); } - return array_map(fn($r) => Device::from_json($r), $res->devices); + return array_map( + fn($r) => AcsCredential::from_json($r), + $res->acs_credentials + ); } - public function list_device_providers( - ?string $provider_category = null - ): array { + public function list_accessible_entrances(string $acs_credential_id): array + { $request_payload = []; - if ($provider_category !== null) { - $request_payload["provider_category"] = $provider_category; + if ($acs_credential_id !== null) { + $request_payload["acs_credential_id"] = $acs_credential_id; } $res = $this->seam->request( "POST", - "/devices/list_device_providers", + "/acs/credentials/list_accessible_entrances", json: (object) $request_payload ); return array_map( - fn($r) => DeviceProvider::from_json($r), - $res->device_providers + fn($r) => AcsEntrance::from_json($r), + $res->acs_entrances ); } - public function update( - string $device_id, - mixed $properties = null, - ?string $name = null, - ?bool $is_managed = null, - mixed $custom_metadata = null + public function unassign( + string $acs_credential_id, + string $acs_user_id ): void { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($properties !== null) { - $request_payload["properties"] = $properties; - } - if ($name !== null) { - $request_payload["name"] = $name; - } - if ($is_managed !== null) { - $request_payload["is_managed"] = $is_managed; + if ($acs_credential_id !== null) { + $request_payload["acs_credential_id"] = $acs_credential_id; } - if ($custom_metadata !== null) { - $request_payload["custom_metadata"] = $custom_metadata; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } $this->seam->request( "POST", - "/devices/update", - json: (object) $request_payload - ); - } -} - -class EventsClient -{ - private SeamClient $seam; - - public function __construct(SeamClient $seam) - { - $this->seam = $seam; - } - - public function get( - ?string $event_id = null, - ?string $event_type = null, - ?string $device_id = null - ): Event { - $request_payload = []; - - if ($event_id !== null) { - $request_payload["event_id"] = $event_id; - } - if ($event_type !== null) { - $request_payload["event_type"] = $event_type; - } - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - - $res = $this->seam->request( - "POST", - "/events/get", + "/acs/credentials/unassign", json: (object) $request_payload ); - - return Event::from_json($res->event); } - public function list( - ?float $unstable_offset = null, - ?string $since = null, - ?array $between = null, - ?string $device_id = null, - ?array $device_ids = null, - ?string $acs_system_id = null, - ?array $acs_system_ids = null, - ?string $access_code_id = null, - ?array $access_code_ids = null, - ?string $event_type = null, - ?array $event_types = null, - ?string $connected_account_id = null, - ?string $connect_webview_id = null, - ?float $limit = null, - ?array $event_ids = null, - ?callable $on_response = null - ): array { + public function update( + string $acs_credential_id, + ?string $code = null, + ?string $ends_at = null + ): void { $request_payload = []; - if ($unstable_offset !== null) { - $request_payload["unstable_offset"] = $unstable_offset; - } - if ($since !== null) { - $request_payload["since"] = $since; - } - if ($between !== null) { - $request_payload["between"] = $between; - } - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($device_ids !== null) { - $request_payload["device_ids"] = $device_ids; - } - if ($acs_system_id !== null) { - $request_payload["acs_system_id"] = $acs_system_id; - } - if ($acs_system_ids !== null) { - $request_payload["acs_system_ids"] = $acs_system_ids; - } - if ($access_code_id !== null) { - $request_payload["access_code_id"] = $access_code_id; - } - if ($access_code_ids !== null) { - $request_payload["access_code_ids"] = $access_code_ids; - } - if ($event_type !== null) { - $request_payload["event_type"] = $event_type; - } - if ($event_types !== null) { - $request_payload["event_types"] = $event_types; - } - if ($connected_account_id !== null) { - $request_payload["connected_account_id"] = $connected_account_id; - } - if ($connect_webview_id !== null) { - $request_payload["connect_webview_id"] = $connect_webview_id; + if ($acs_credential_id !== null) { + $request_payload["acs_credential_id"] = $acs_credential_id; } - if ($limit !== null) { - $request_payload["limit"] = $limit; + if ($code !== null) { + $request_payload["code"] = $code; } - if ($event_ids !== null) { - $request_payload["event_ids"] = $event_ids; + if ($ends_at !== null) { + $request_payload["ends_at"] = $ends_at; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/events/list", + "/acs/credentials/update", json: (object) $request_payload ); - - if ($on_response !== null) { - $on_response($res); - } - - return array_map(fn($r) => Event::from_json($r), $res->events); } } -class LocksClient +class AcsEncodersClient { private SeamClient $seam; @@ -1462,91 +1210,62 @@ public function __construct(SeamClient $seam) $this->seam = $seam; } - public function get(?string $device_id = null, ?string $name = null): Device - { + public function encode_credential( + string $acs_credential_id, + string $acs_encoder_id, + bool $wait_for_action_attempt = true + ): ActionAttempt { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($acs_credential_id !== null) { + $request_payload["acs_credential_id"] = $acs_credential_id; } - if ($name !== null) { - $request_payload["name"] = $name; + if ($acs_encoder_id !== null) { + $request_payload["acs_encoder_id"] = $acs_encoder_id; } $res = $this->seam->request( "POST", - "/locks/get", + "/acs/encoders/encode_credential", json: (object) $request_payload ); - return Device::from_json($res->device); + if (!$wait_for_action_attempt) { + return ActionAttempt::from_json($res->action_attempt); + } + + $action_attempt = $this->seam->action_attempts->poll_until_ready( + $res->action_attempt->action_attempt_id + ); + + return $action_attempt; } public function list( - ?string $connected_account_id = null, - ?array $connected_account_ids = null, - ?string $connect_webview_id = null, - ?string $device_type = null, - ?array $device_types = null, - ?string $manufacturer = null, - ?array $device_ids = null, + ?string $acs_system_id = null, ?float $limit = null, - ?string $created_before = null, - ?string $user_identifier_key = null, - mixed $custom_metadata_has = null, - ?array $include_if = null, - ?array $exclude_if = null, - ?string $unstable_location_id = null, + ?array $acs_system_ids = null, + ?array $acs_encoder_ids = null, ?callable $on_response = null ): array { $request_payload = []; - if ($connected_account_id !== null) { - $request_payload["connected_account_id"] = $connected_account_id; - } - if ($connected_account_ids !== null) { - $request_payload["connected_account_ids"] = $connected_account_ids; - } - if ($connect_webview_id !== null) { - $request_payload["connect_webview_id"] = $connect_webview_id; - } - if ($device_type !== null) { - $request_payload["device_type"] = $device_type; - } - if ($device_types !== null) { - $request_payload["device_types"] = $device_types; - } - if ($manufacturer !== null) { - $request_payload["manufacturer"] = $manufacturer; - } - if ($device_ids !== null) { - $request_payload["device_ids"] = $device_ids; + if ($acs_system_id !== null) { + $request_payload["acs_system_id"] = $acs_system_id; } if ($limit !== null) { $request_payload["limit"] = $limit; } - if ($created_before !== null) { - $request_payload["created_before"] = $created_before; - } - if ($user_identifier_key !== null) { - $request_payload["user_identifier_key"] = $user_identifier_key; - } - if ($custom_metadata_has !== null) { - $request_payload["custom_metadata_has"] = $custom_metadata_has; - } - if ($include_if !== null) { - $request_payload["include_if"] = $include_if; - } - if ($exclude_if !== null) { - $request_payload["exclude_if"] = $exclude_if; + if ($acs_system_ids !== null) { + $request_payload["acs_system_ids"] = $acs_system_ids; } - if ($unstable_location_id !== null) { - $request_payload["unstable_location_id"] = $unstable_location_id; + if ($acs_encoder_ids !== null) { + $request_payload["acs_encoder_ids"] = $acs_encoder_ids; } $res = $this->seam->request( "POST", - "/locks/list", + "/acs/encoders/list", json: (object) $request_payload ); @@ -1554,26 +1273,25 @@ public function list( $on_response($res); } - return array_map(fn($r) => Device::from_json($r), $res->devices); + return array_map( + fn($r) => AcsEncoder::from_json($r), + $res->acs_encoders + ); } - public function lock_door( - string $device_id, - ?bool $sync = null, + public function scan_credential( + string $acs_encoder_id, bool $wait_for_action_attempt = true ): ActionAttempt { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($sync !== null) { - $request_payload["sync"] = $sync; + if ($acs_encoder_id !== null) { + $request_payload["acs_encoder_id"] = $acs_encoder_id; } $res = $this->seam->request( "POST", - "/locks/lock_door", + "/acs/encoders/scan_credential", json: (object) $request_payload ); @@ -1587,40 +1305,9 @@ public function lock_door( return $action_attempt; } +} - public function unlock_door( - string $device_id, - ?bool $sync = null, - bool $wait_for_action_attempt = true - ): ActionAttempt { - $request_payload = []; - - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($sync !== null) { - $request_payload["sync"] = $sync; - } - - $res = $this->seam->request( - "POST", - "/locks/unlock_door", - json: (object) $request_payload - ); - - if (!$wait_for_action_attempt) { - return ActionAttempt::from_json($res->action_attempt); - } - - $action_attempt = $this->seam->action_attempts->poll_until_ready( - $res->action_attempt->action_attempt_id - ); - - return $action_attempt; - } -} - -class NetworksClient +class AcsEncodersSimulateClient { private SeamClient $seam; @@ -1629,184 +1316,166 @@ public function __construct(SeamClient $seam) $this->seam = $seam; } - public function get(string $network_id): Network - { + public function next_credential_encode_will_fail( + string $acs_encoder_id, + ?string $error_code = null, + ?string $acs_credential_id = null + ): void { $request_payload = []; - if ($network_id !== null) { - $request_payload["network_id"] = $network_id; + if ($acs_encoder_id !== null) { + $request_payload["acs_encoder_id"] = $acs_encoder_id; + } + if ($error_code !== null) { + $request_payload["error_code"] = $error_code; + } + if ($acs_credential_id !== null) { + $request_payload["acs_credential_id"] = $acs_credential_id; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/networks/get", + "/acs/encoders/simulate/next_credential_encode_will_fail", json: (object) $request_payload ); - - return Network::from_json($res->network); } - public function list(?callable $on_response = null): array - { - $res = $this->seam->request("POST", "/networks/list"); + public function next_credential_encode_will_succeed( + string $acs_encoder_id, + ?string $scenario = null + ): void { + $request_payload = []; - if ($on_response !== null) { - $on_response($res); + if ($acs_encoder_id !== null) { + $request_payload["acs_encoder_id"] = $acs_encoder_id; + } + if ($scenario !== null) { + $request_payload["scenario"] = $scenario; } - return array_map(fn($r) => Network::from_json($r), $res->networks); - } -} - -class NoiseSensorsClient -{ - private SeamClient $seam; - public NoiseSensorsNoiseThresholdsClient $noise_thresholds; - public NoiseSensorsSimulateClient $simulate; - public function __construct(SeamClient $seam) - { - $this->seam = $seam; - $this->noise_thresholds = new NoiseSensorsNoiseThresholdsClient($seam); - $this->simulate = new NoiseSensorsSimulateClient($seam); + $this->seam->request( + "POST", + "/acs/encoders/simulate/next_credential_encode_will_succeed", + json: (object) $request_payload + ); } - public function list( - ?string $connected_account_id = null, - ?array $connected_account_ids = null, - ?string $connect_webview_id = null, - ?string $device_type = null, - ?array $device_types = null, - ?string $manufacturer = null, - ?array $device_ids = null, - ?float $limit = null, - ?string $created_before = null, - ?string $user_identifier_key = null, - mixed $custom_metadata_has = null, - ?array $include_if = null, - ?array $exclude_if = null, - ?string $unstable_location_id = null, - ?callable $on_response = null - ): array { + public function next_credential_scan_will_fail( + string $acs_encoder_id, + ?string $error_code = null, + ?string $acs_credential_id_on_seam = null + ): void { $request_payload = []; - if ($connected_account_id !== null) { - $request_payload["connected_account_id"] = $connected_account_id; - } - if ($connected_account_ids !== null) { - $request_payload["connected_account_ids"] = $connected_account_ids; - } - if ($connect_webview_id !== null) { - $request_payload["connect_webview_id"] = $connect_webview_id; - } - if ($device_type !== null) { - $request_payload["device_type"] = $device_type; - } - if ($device_types !== null) { - $request_payload["device_types"] = $device_types; - } - if ($manufacturer !== null) { - $request_payload["manufacturer"] = $manufacturer; - } - if ($device_ids !== null) { - $request_payload["device_ids"] = $device_ids; - } - if ($limit !== null) { - $request_payload["limit"] = $limit; - } - if ($created_before !== null) { - $request_payload["created_before"] = $created_before; - } - if ($user_identifier_key !== null) { - $request_payload["user_identifier_key"] = $user_identifier_key; - } - if ($custom_metadata_has !== null) { - $request_payload["custom_metadata_has"] = $custom_metadata_has; - } - if ($include_if !== null) { - $request_payload["include_if"] = $include_if; + if ($acs_encoder_id !== null) { + $request_payload["acs_encoder_id"] = $acs_encoder_id; } - if ($exclude_if !== null) { - $request_payload["exclude_if"] = $exclude_if; + if ($error_code !== null) { + $request_payload["error_code"] = $error_code; } - if ($unstable_location_id !== null) { - $request_payload["unstable_location_id"] = $unstable_location_id; + if ($acs_credential_id_on_seam !== null) { + $request_payload[ + "acs_credential_id_on_seam" + ] = $acs_credential_id_on_seam; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/noise_sensors/list", + "/acs/encoders/simulate/next_credential_scan_will_fail", json: (object) $request_payload ); + } - if ($on_response !== null) { - $on_response($res); + public function next_credential_scan_will_succeed( + string $acs_encoder_id, + ?string $acs_credential_id_on_seam = null, + ?string $scenario = null + ): void { + $request_payload = []; + + if ($acs_encoder_id !== null) { + $request_payload["acs_encoder_id"] = $acs_encoder_id; + } + if ($acs_credential_id_on_seam !== null) { + $request_payload[ + "acs_credential_id_on_seam" + ] = $acs_credential_id_on_seam; + } + if ($scenario !== null) { + $request_payload["scenario"] = $scenario; } - return array_map(fn($r) => Device::from_json($r), $res->devices); + $this->seam->request( + "POST", + "/acs/encoders/simulate/next_credential_scan_will_succeed", + json: (object) $request_payload + ); } } -class PhonesClient +class AcsEntrancesClient { private SeamClient $seam; - public PhonesSimulateClient $simulate; + public function __construct(SeamClient $seam) { $this->seam = $seam; - $this->simulate = new PhonesSimulateClient($seam); } - public function deactivate(string $device_id): void + public function get(string $acs_entrance_id): AcsEntrance { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($acs_entrance_id !== null) { + $request_payload["acs_entrance_id"] = $acs_entrance_id; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/phones/deactivate", + "/acs/entrances/get", json: (object) $request_payload ); + + return AcsEntrance::from_json($res->acs_entrance); } - public function get(string $device_id): Phone - { + public function grant_access( + string $acs_entrance_id, + string $acs_user_id + ): void { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($acs_entrance_id !== null) { + $request_payload["acs_entrance_id"] = $acs_entrance_id; + } + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/phones/get", + "/acs/entrances/grant_access", json: (object) $request_payload ); - - return Phone::from_json($res->phone); } public function list( - ?string $owner_user_identity_id = null, ?string $acs_credential_id = null, + ?string $acs_system_id = null, ?callable $on_response = null ): array { $request_payload = []; - if ($owner_user_identity_id !== null) { - $request_payload[ - "owner_user_identity_id" - ] = $owner_user_identity_id; - } if ($acs_credential_id !== null) { $request_payload["acs_credential_id"] = $acs_credential_id; } + if ($acs_system_id !== null) { + $request_payload["acs_system_id"] = $acs_system_id; + } $res = $this->seam->request( "POST", - "/phones/list", + "/acs/entrances/list", json: (object) $request_payload ); @@ -1814,341 +1483,258 @@ public function list( $on_response($res); } - return array_map(fn($r) => Phone::from_json($r), $res->phones); - } -} - -class ThermostatsClient -{ - private SeamClient $seam; - public ThermostatsSchedulesClient $schedules; - public ThermostatsSimulateClient $simulate; - public function __construct(SeamClient $seam) - { - $this->seam = $seam; - $this->schedules = new ThermostatsSchedulesClient($seam); - $this->simulate = new ThermostatsSimulateClient($seam); + return array_map( + fn($r) => AcsEntrance::from_json($r), + $res->acs_entrances + ); } - public function activate_climate_preset( - string $device_id, - string $climate_preset_key, - bool $wait_for_action_attempt = true - ): ActionAttempt { + public function list_credentials_with_access( + string $acs_entrance_id, + ?array $include_if = null + ): array { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($acs_entrance_id !== null) { + $request_payload["acs_entrance_id"] = $acs_entrance_id; } - if ($climate_preset_key !== null) { - $request_payload["climate_preset_key"] = $climate_preset_key; + if ($include_if !== null) { + $request_payload["include_if"] = $include_if; } $res = $this->seam->request( "POST", - "/thermostats/activate_climate_preset", + "/acs/entrances/list_credentials_with_access", json: (object) $request_payload ); - if (!$wait_for_action_attempt) { - return ActionAttempt::from_json($res->action_attempt); + return array_map( + fn($r) => AcsCredential::from_json($r), + $res->acs_credentials + ); + } +} + +class AcsSystemsClient +{ + private SeamClient $seam; + + public function __construct(SeamClient $seam) + { + $this->seam = $seam; + } + + public function get(string $acs_system_id): AcsSystem + { + $request_payload = []; + + if ($acs_system_id !== null) { + $request_payload["acs_system_id"] = $acs_system_id; } - $action_attempt = $this->seam->action_attempts->poll_until_ready( - $res->action_attempt->action_attempt_id + $res = $this->seam->request( + "POST", + "/acs/systems/get", + json: (object) $request_payload ); - return $action_attempt; + return AcsSystem::from_json($res->acs_system); } - public function cool( - string $device_id, - ?float $cooling_set_point_celsius = null, - ?float $cooling_set_point_fahrenheit = null, - ?bool $sync = null, - bool $wait_for_action_attempt = true - ): ActionAttempt { + public function list( + ?string $connected_account_id = null, + ?callable $on_response = null + ): array { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($cooling_set_point_celsius !== null) { - $request_payload[ - "cooling_set_point_celsius" - ] = $cooling_set_point_celsius; - } - if ($cooling_set_point_fahrenheit !== null) { - $request_payload[ - "cooling_set_point_fahrenheit" - ] = $cooling_set_point_fahrenheit; - } - if ($sync !== null) { - $request_payload["sync"] = $sync; + if ($connected_account_id !== null) { + $request_payload["connected_account_id"] = $connected_account_id; } $res = $this->seam->request( "POST", - "/thermostats/cool", + "/acs/systems/list", json: (object) $request_payload ); - if (!$wait_for_action_attempt) { - return ActionAttempt::from_json($res->action_attempt); + if ($on_response !== null) { + $on_response($res); } - $action_attempt = $this->seam->action_attempts->poll_until_ready( - $res->action_attempt->action_attempt_id + return array_map(fn($r) => AcsSystem::from_json($r), $res->acs_systems); + } + + public function list_compatible_credential_manager_acs_systems( + string $acs_system_id + ): array { + $request_payload = []; + + if ($acs_system_id !== null) { + $request_payload["acs_system_id"] = $acs_system_id; + } + + $res = $this->seam->request( + "POST", + "/acs/systems/list_compatible_credential_manager_acs_systems", + json: (object) $request_payload ); - return $action_attempt; + return array_map(fn($r) => AcsSystem::from_json($r), $res->acs_systems); } +} - public function create_climate_preset( - string $device_id, - string $climate_preset_key, - ?bool $manual_override_allowed = null, - ?string $name = null, - ?string $fan_mode_setting = null, - ?string $hvac_mode_setting = null, - ?float $cooling_set_point_celsius = null, - ?float $heating_set_point_celsius = null, - ?float $cooling_set_point_fahrenheit = null, - ?float $heating_set_point_fahrenheit = null +class AcsUsersClient +{ + private SeamClient $seam; + + public function __construct(SeamClient $seam) + { + $this->seam = $seam; + } + + public function add_to_access_group( + string $acs_access_group_id, + string $acs_user_id ): void { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($acs_access_group_id !== null) { + $request_payload["acs_access_group_id"] = $acs_access_group_id; } - if ($climate_preset_key !== null) { - $request_payload["climate_preset_key"] = $climate_preset_key; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } - if ($manual_override_allowed !== null) { - $request_payload[ - "manual_override_allowed" - ] = $manual_override_allowed; + + $this->seam->request( + "POST", + "/acs/users/add_to_access_group", + json: (object) $request_payload + ); + } + + public function create( + string $acs_system_id, + string $full_name, + mixed $access_schedule = null, + ?array $acs_access_group_ids = null, + ?string $email = null, + ?string $email_address = null, + ?string $phone_number = null, + ?string $user_identity_id = null + ): AcsUser { + $request_payload = []; + + if ($acs_system_id !== null) { + $request_payload["acs_system_id"] = $acs_system_id; } - if ($name !== null) { - $request_payload["name"] = $name; + if ($full_name !== null) { + $request_payload["full_name"] = $full_name; } - if ($fan_mode_setting !== null) { - $request_payload["fan_mode_setting"] = $fan_mode_setting; + if ($access_schedule !== null) { + $request_payload["access_schedule"] = $access_schedule; } - if ($hvac_mode_setting !== null) { - $request_payload["hvac_mode_setting"] = $hvac_mode_setting; + if ($acs_access_group_ids !== null) { + $request_payload["acs_access_group_ids"] = $acs_access_group_ids; } - if ($cooling_set_point_celsius !== null) { - $request_payload[ - "cooling_set_point_celsius" - ] = $cooling_set_point_celsius; + if ($email !== null) { + $request_payload["email"] = $email; } - if ($heating_set_point_celsius !== null) { - $request_payload[ - "heating_set_point_celsius" - ] = $heating_set_point_celsius; + if ($email_address !== null) { + $request_payload["email_address"] = $email_address; } - if ($cooling_set_point_fahrenheit !== null) { - $request_payload[ - "cooling_set_point_fahrenheit" - ] = $cooling_set_point_fahrenheit; + if ($phone_number !== null) { + $request_payload["phone_number"] = $phone_number; } - if ($heating_set_point_fahrenheit !== null) { - $request_payload[ - "heating_set_point_fahrenheit" - ] = $heating_set_point_fahrenheit; + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/thermostats/create_climate_preset", + "/acs/users/create", json: (object) $request_payload ); + + return AcsUser::from_json($res->acs_user); } - public function delete_climate_preset( - string $device_id, - string $climate_preset_key - ): void { + public function delete(string $acs_user_id): void + { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($climate_preset_key !== null) { - $request_payload["climate_preset_key"] = $climate_preset_key; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } $this->seam->request( "POST", - "/thermostats/delete_climate_preset", + "/acs/users/delete", json: (object) $request_payload ); } - public function heat( - string $device_id, - ?float $heating_set_point_celsius = null, - ?float $heating_set_point_fahrenheit = null, - ?bool $sync = null, - bool $wait_for_action_attempt = true - ): ActionAttempt { + public function get(string $acs_user_id): AcsUser + { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($heating_set_point_celsius !== null) { - $request_payload[ - "heating_set_point_celsius" - ] = $heating_set_point_celsius; - } - if ($heating_set_point_fahrenheit !== null) { - $request_payload[ - "heating_set_point_fahrenheit" - ] = $heating_set_point_fahrenheit; - } - if ($sync !== null) { - $request_payload["sync"] = $sync; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } $res = $this->seam->request( "POST", - "/thermostats/heat", + "/acs/users/get", json: (object) $request_payload ); - if (!$wait_for_action_attempt) { - return ActionAttempt::from_json($res->action_attempt); - } - - $action_attempt = $this->seam->action_attempts->poll_until_ready( - $res->action_attempt->action_attempt_id - ); - - return $action_attempt; - } - - public function heat_cool( - string $device_id, - ?float $heating_set_point_celsius = null, - ?float $heating_set_point_fahrenheit = null, - ?float $cooling_set_point_celsius = null, - ?float $cooling_set_point_fahrenheit = null, - ?bool $sync = null, - bool $wait_for_action_attempt = true - ): ActionAttempt { - $request_payload = []; - - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($heating_set_point_celsius !== null) { - $request_payload[ - "heating_set_point_celsius" - ] = $heating_set_point_celsius; - } - if ($heating_set_point_fahrenheit !== null) { - $request_payload[ - "heating_set_point_fahrenheit" - ] = $heating_set_point_fahrenheit; - } - if ($cooling_set_point_celsius !== null) { - $request_payload[ - "cooling_set_point_celsius" - ] = $cooling_set_point_celsius; - } - if ($cooling_set_point_fahrenheit !== null) { - $request_payload[ - "cooling_set_point_fahrenheit" - ] = $cooling_set_point_fahrenheit; - } - if ($sync !== null) { - $request_payload["sync"] = $sync; - } - - $res = $this->seam->request( - "POST", - "/thermostats/heat_cool", - json: (object) $request_payload - ); - - if (!$wait_for_action_attempt) { - return ActionAttempt::from_json($res->action_attempt); - } - - $action_attempt = $this->seam->action_attempts->poll_until_ready( - $res->action_attempt->action_attempt_id - ); - - return $action_attempt; + return AcsUser::from_json($res->acs_user); } public function list( - ?string $connected_account_id = null, - ?array $connected_account_ids = null, - ?string $connect_webview_id = null, - ?string $device_type = null, - ?array $device_types = null, - ?string $manufacturer = null, - ?array $device_ids = null, - ?float $limit = null, + ?string $acs_system_id = null, ?string $created_before = null, - ?string $user_identifier_key = null, - mixed $custom_metadata_has = null, - ?array $include_if = null, - ?array $exclude_if = null, - ?string $unstable_location_id = null, + mixed $limit = null, + ?string $page_cursor = null, + ?string $search = null, + ?string $user_identity_email_address = null, + ?string $user_identity_id = null, + ?string $user_identity_phone_number = null, ?callable $on_response = null ): array { $request_payload = []; - if ($connected_account_id !== null) { - $request_payload["connected_account_id"] = $connected_account_id; - } - if ($connected_account_ids !== null) { - $request_payload["connected_account_ids"] = $connected_account_ids; - } - if ($connect_webview_id !== null) { - $request_payload["connect_webview_id"] = $connect_webview_id; - } - if ($device_type !== null) { - $request_payload["device_type"] = $device_type; - } - if ($device_types !== null) { - $request_payload["device_types"] = $device_types; - } - if ($manufacturer !== null) { - $request_payload["manufacturer"] = $manufacturer; + if ($acs_system_id !== null) { + $request_payload["acs_system_id"] = $acs_system_id; } - if ($device_ids !== null) { - $request_payload["device_ids"] = $device_ids; + if ($created_before !== null) { + $request_payload["created_before"] = $created_before; } if ($limit !== null) { $request_payload["limit"] = $limit; } - if ($created_before !== null) { - $request_payload["created_before"] = $created_before; - } - if ($user_identifier_key !== null) { - $request_payload["user_identifier_key"] = $user_identifier_key; + if ($page_cursor !== null) { + $request_payload["page_cursor"] = $page_cursor; } - if ($custom_metadata_has !== null) { - $request_payload["custom_metadata_has"] = $custom_metadata_has; + if ($search !== null) { + $request_payload["search"] = $search; } - if ($include_if !== null) { - $request_payload["include_if"] = $include_if; + if ($user_identity_email_address !== null) { + $request_payload[ + "user_identity_email_address" + ] = $user_identity_email_address; } - if ($exclude_if !== null) { - $request_payload["exclude_if"] = $exclude_if; + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; } - if ($unstable_location_id !== null) { - $request_payload["unstable_location_id"] = $unstable_location_id; + if ($user_identity_phone_number !== null) { + $request_payload[ + "user_identity_phone_number" + ] = $user_identity_phone_number; } $res = $this->seam->request( "POST", - "/thermostats/list", + "/acs/users/list", json: (object) $request_payload ); @@ -2156,387 +1742,564 @@ public function list( $on_response($res); } - return array_map(fn($r) => Device::from_json($r), $res->devices); + return array_map(fn($r) => AcsUser::from_json($r), $res->acs_users); } - public function off( - string $device_id, - ?bool $sync = null, - bool $wait_for_action_attempt = true - ): ActionAttempt { + public function list_accessible_entrances(string $acs_user_id): array + { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($sync !== null) { - $request_payload["sync"] = $sync; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } $res = $this->seam->request( "POST", - "/thermostats/off", + "/acs/users/list_accessible_entrances", json: (object) $request_payload ); - if (!$wait_for_action_attempt) { - return ActionAttempt::from_json($res->action_attempt); - } - - $action_attempt = $this->seam->action_attempts->poll_until_ready( - $res->action_attempt->action_attempt_id + return array_map( + fn($r) => AcsEntrance::from_json($r), + $res->acs_entrances ); - - return $action_attempt; } - public function set_fallback_climate_preset( - string $device_id, - string $climate_preset_key + public function remove_from_access_group( + string $acs_access_group_id, + string $acs_user_id ): void { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($acs_access_group_id !== null) { + $request_payload["acs_access_group_id"] = $acs_access_group_id; } - if ($climate_preset_key !== null) { - $request_payload["climate_preset_key"] = $climate_preset_key; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } $this->seam->request( "POST", - "/thermostats/set_fallback_climate_preset", + "/acs/users/remove_from_access_group", json: (object) $request_payload ); } - public function set_fan_mode( - string $device_id, - ?string $fan_mode = null, - ?string $fan_mode_setting = null, - ?bool $sync = null, - bool $wait_for_action_attempt = true - ): ActionAttempt { + public function revoke_access_to_all_entrances(string $acs_user_id): void + { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($fan_mode !== null) { - $request_payload["fan_mode"] = $fan_mode; - } - if ($fan_mode_setting !== null) { - $request_payload["fan_mode_setting"] = $fan_mode_setting; - } - if ($sync !== null) { - $request_payload["sync"] = $sync; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/thermostats/set_fan_mode", + "/acs/users/revoke_access_to_all_entrances", json: (object) $request_payload ); + } - if (!$wait_for_action_attempt) { - return ActionAttempt::from_json($res->action_attempt); + public function suspend(string $acs_user_id): void + { + $request_payload = []; + + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } - $action_attempt = $this->seam->action_attempts->poll_until_ready( - $res->action_attempt->action_attempt_id + $this->seam->request( + "POST", + "/acs/users/suspend", + json: (object) $request_payload ); - - return $action_attempt; } - public function set_hvac_mode( - string $hvac_mode_setting, - string $device_id, - ?float $cooling_set_point_celsius = null, - ?float $cooling_set_point_fahrenheit = null, - ?float $heating_set_point_celsius = null, - ?float $heating_set_point_fahrenheit = null, - bool $wait_for_action_attempt = true - ): ActionAttempt { + public function unsuspend(string $acs_user_id): void + { $request_payload = []; - if ($hvac_mode_setting !== null) { - $request_payload["hvac_mode_setting"] = $hvac_mode_setting; - } - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($cooling_set_point_celsius !== null) { - $request_payload[ - "cooling_set_point_celsius" - ] = $cooling_set_point_celsius; - } - if ($cooling_set_point_fahrenheit !== null) { - $request_payload[ - "cooling_set_point_fahrenheit" - ] = $cooling_set_point_fahrenheit; - } - if ($heating_set_point_celsius !== null) { - $request_payload[ - "heating_set_point_celsius" - ] = $heating_set_point_celsius; - } - if ($heating_set_point_fahrenheit !== null) { - $request_payload[ - "heating_set_point_fahrenheit" - ] = $heating_set_point_fahrenheit; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/thermostats/set_hvac_mode", + "/acs/users/unsuspend", json: (object) $request_payload ); + } - if (!$wait_for_action_attempt) { - return ActionAttempt::from_json($res->action_attempt); - } - - $action_attempt = $this->seam->action_attempts->poll_until_ready( - $res->action_attempt->action_attempt_id - ); - - return $action_attempt; - } - - public function set_temperature_threshold( - string $device_id, - ?float $lower_limit_celsius = null, - ?float $lower_limit_fahrenheit = null, - ?float $upper_limit_celsius = null, - ?float $upper_limit_fahrenheit = null + public function update( + string $acs_user_id, + mixed $access_schedule = null, + ?string $email = null, + ?string $email_address = null, + ?string $full_name = null, + ?string $hid_acs_system_id = null, + ?string $phone_number = null ): void { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } - if ($lower_limit_celsius !== null) { - $request_payload["lower_limit_celsius"] = $lower_limit_celsius; + if ($access_schedule !== null) { + $request_payload["access_schedule"] = $access_schedule; } - if ($lower_limit_fahrenheit !== null) { - $request_payload[ - "lower_limit_fahrenheit" - ] = $lower_limit_fahrenheit; + if ($email !== null) { + $request_payload["email"] = $email; } - if ($upper_limit_celsius !== null) { - $request_payload["upper_limit_celsius"] = $upper_limit_celsius; + if ($email_address !== null) { + $request_payload["email_address"] = $email_address; } - if ($upper_limit_fahrenheit !== null) { - $request_payload[ - "upper_limit_fahrenheit" - ] = $upper_limit_fahrenheit; + if ($full_name !== null) { + $request_payload["full_name"] = $full_name; + } + if ($hid_acs_system_id !== null) { + $request_payload["hid_acs_system_id"] = $hid_acs_system_id; + } + if ($phone_number !== null) { + $request_payload["phone_number"] = $phone_number; } $this->seam->request( "POST", - "/thermostats/set_temperature_threshold", + "/acs/users/update", json: (object) $request_payload ); } +} - public function update_climate_preset( - string $device_id, - string $climate_preset_key, - bool $manual_override_allowed, - ?string $name = null, - ?string $fan_mode_setting = null, - ?string $hvac_mode_setting = null, - ?float $cooling_set_point_celsius = null, - ?float $heating_set_point_celsius = null, - ?float $cooling_set_point_fahrenheit = null, - ?float $heating_set_point_fahrenheit = null - ): void { +class ActionAttemptsClient +{ + private SeamClient $seam; + + public function __construct(SeamClient $seam) + { + $this->seam = $seam; + } + + public function get(string $action_attempt_id): ActionAttempt + { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($climate_preset_key !== null) { - $request_payload["climate_preset_key"] = $climate_preset_key; - } - if ($manual_override_allowed !== null) { - $request_payload[ - "manual_override_allowed" - ] = $manual_override_allowed; - } - if ($name !== null) { - $request_payload["name"] = $name; - } - if ($fan_mode_setting !== null) { - $request_payload["fan_mode_setting"] = $fan_mode_setting; + if ($action_attempt_id !== null) { + $request_payload["action_attempt_id"] = $action_attempt_id; } - if ($hvac_mode_setting !== null) { - $request_payload["hvac_mode_setting"] = $hvac_mode_setting; + + $res = $this->seam->request( + "POST", + "/action_attempts/get", + json: (object) $request_payload + ); + + return ActionAttempt::from_json($res->action_attempt); + } + + public function list( + array $action_attempt_ids, + ?callable $on_response = null + ): array { + $request_payload = []; + + if ($action_attempt_ids !== null) { + $request_payload["action_attempt_ids"] = $action_attempt_ids; } - if ($cooling_set_point_celsius !== null) { - $request_payload[ - "cooling_set_point_celsius" - ] = $cooling_set_point_celsius; + + $res = $this->seam->request( + "POST", + "/action_attempts/list", + json: (object) $request_payload + ); + + if ($on_response !== null) { + $on_response($res); } - if ($heating_set_point_celsius !== null) { - $request_payload[ - "heating_set_point_celsius" - ] = $heating_set_point_celsius; + + return array_map( + fn($r) => ActionAttempt::from_json($r), + $res->action_attempts + ); + } + public function poll_until_ready( + string $action_attempt_id, + float $timeout = 20.0 + ): ActionAttempt { + $seam = $this->seam; + $time_waiting = 0.0; + $polling_interval = 0.4; + $action_attempt = $seam->action_attempts->get($action_attempt_id); + + while ($action_attempt->status == "pending") { + $action_attempt = $seam->action_attempts->get( + $action_attempt->action_attempt_id + ); + if ($time_waiting > $timeout) { + throw new ActionAttemptTimeoutError($action_attempt, $timeout); + } + $time_waiting += $polling_interval; + usleep($polling_interval * 1000000); } - if ($cooling_set_point_fahrenheit !== null) { - $request_payload[ - "cooling_set_point_fahrenheit" - ] = $cooling_set_point_fahrenheit; + + if ($action_attempt->status == "error") { + throw new ActionAttemptFailedError($action_attempt); } - if ($heating_set_point_fahrenheit !== null) { - $request_payload[ - "heating_set_point_fahrenheit" - ] = $heating_set_point_fahrenheit; + + return $action_attempt; + } +} + +class BridgesClient +{ + private SeamClient $seam; + + public function __construct(SeamClient $seam) + { + $this->seam = $seam; + } + + public function get(string $bridge_id): void + { + $request_payload = []; + + if ($bridge_id !== null) { + $request_payload["bridge_id"] = $bridge_id; } $this->seam->request( "POST", - "/thermostats/update_climate_preset", + "/bridges/get", json: (object) $request_payload ); } + + public function list(): void + { + $this->seam->request("POST", "/bridges/list"); + } } -class UserIdentitiesClient +class ClientSessionsClient { private SeamClient $seam; - public UserIdentitiesEnrollmentAutomationsClient $enrollment_automations; + public function __construct(SeamClient $seam) { $this->seam = $seam; - $this->enrollment_automations = new UserIdentitiesEnrollmentAutomationsClient( - $seam - ); } - public function add_acs_user( - string $user_identity_id, - string $acs_user_id - ): void { + public function create( + ?array $connect_webview_ids = null, + ?array $connected_account_ids = null, + ?string $expires_at = null, + ?string $user_identifier_key = null, + ?array $user_identity_ids = null + ): ClientSession { $request_payload = []; - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; + if ($connect_webview_ids !== null) { + $request_payload["connect_webview_ids"] = $connect_webview_ids; } - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($connected_account_ids !== null) { + $request_payload["connected_account_ids"] = $connected_account_ids; + } + if ($expires_at !== null) { + $request_payload["expires_at"] = $expires_at; + } + if ($user_identifier_key !== null) { + $request_payload["user_identifier_key"] = $user_identifier_key; + } + if ($user_identity_ids !== null) { + $request_payload["user_identity_ids"] = $user_identity_ids; + } + + $res = $this->seam->request( + "POST", + "/client_sessions/create", + json: (object) $request_payload + ); + + return ClientSession::from_json($res->client_session); + } + + public function delete(string $client_session_id): void + { + $request_payload = []; + + if ($client_session_id !== null) { + $request_payload["client_session_id"] = $client_session_id; } $this->seam->request( "POST", - "/user_identities/add_acs_user", + "/client_sessions/delete", json: (object) $request_payload ); } - public function create( - ?string $user_identity_key = null, - ?string $email_address = null, - ?string $phone_number = null, - ?string $full_name = null - ): UserIdentity { + public function get( + ?string $client_session_id = null, + ?string $user_identifier_key = null + ): ClientSession { $request_payload = []; - if ($user_identity_key !== null) { - $request_payload["user_identity_key"] = $user_identity_key; + if ($client_session_id !== null) { + $request_payload["client_session_id"] = $client_session_id; } - if ($email_address !== null) { - $request_payload["email_address"] = $email_address; + if ($user_identifier_key !== null) { + $request_payload["user_identifier_key"] = $user_identifier_key; } - if ($phone_number !== null) { - $request_payload["phone_number"] = $phone_number; + + $res = $this->seam->request( + "POST", + "/client_sessions/get", + json: (object) $request_payload + ); + + return ClientSession::from_json($res->client_session); + } + + public function get_or_create( + ?array $connect_webview_ids = null, + ?array $connected_account_ids = null, + ?string $expires_at = null, + ?string $user_identifier_key = null, + ?array $user_identity_ids = null + ): ClientSession { + $request_payload = []; + + if ($connect_webview_ids !== null) { + $request_payload["connect_webview_ids"] = $connect_webview_ids; } - if ($full_name !== null) { - $request_payload["full_name"] = $full_name; + if ($connected_account_ids !== null) { + $request_payload["connected_account_ids"] = $connected_account_ids; + } + if ($expires_at !== null) { + $request_payload["expires_at"] = $expires_at; + } + if ($user_identifier_key !== null) { + $request_payload["user_identifier_key"] = $user_identifier_key; + } + if ($user_identity_ids !== null) { + $request_payload["user_identity_ids"] = $user_identity_ids; } $res = $this->seam->request( "POST", - "/user_identities/create", + "/client_sessions/get_or_create", json: (object) $request_payload ); - return UserIdentity::from_json($res->user_identity); + return ClientSession::from_json($res->client_session); } - public function delete(string $user_identity_id): void - { + public function grant_access( + ?string $client_session_id = null, + ?array $connect_webview_ids = null, + ?array $connected_account_ids = null, + ?string $user_identifier_key = null, + ?array $user_identity_ids = null + ): void { $request_payload = []; - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; + if ($client_session_id !== null) { + $request_payload["client_session_id"] = $client_session_id; + } + if ($connect_webview_ids !== null) { + $request_payload["connect_webview_ids"] = $connect_webview_ids; + } + if ($connected_account_ids !== null) { + $request_payload["connected_account_ids"] = $connected_account_ids; + } + if ($user_identifier_key !== null) { + $request_payload["user_identifier_key"] = $user_identifier_key; + } + if ($user_identity_ids !== null) { + $request_payload["user_identity_ids"] = $user_identity_ids; } $this->seam->request( "POST", - "/user_identities/delete", + "/client_sessions/grant_access", json: (object) $request_payload ); } - public function get( + public function list( + ?string $client_session_id = null, + ?string $connect_webview_id = null, + ?string $user_identifier_key = null, ?string $user_identity_id = null, - ?string $user_identity_key = null - ): UserIdentity { + ?bool $without_user_identifier_key = null, + ?callable $on_response = null + ): array { $request_payload = []; + if ($client_session_id !== null) { + $request_payload["client_session_id"] = $client_session_id; + } + if ($connect_webview_id !== null) { + $request_payload["connect_webview_id"] = $connect_webview_id; + } + if ($user_identifier_key !== null) { + $request_payload["user_identifier_key"] = $user_identifier_key; + } if ($user_identity_id !== null) { $request_payload["user_identity_id"] = $user_identity_id; } - if ($user_identity_key !== null) { - $request_payload["user_identity_key"] = $user_identity_key; + if ($without_user_identifier_key !== null) { + $request_payload[ + "without_user_identifier_key" + ] = $without_user_identifier_key; + } + + $res = $this->seam->request( + "POST", + "/client_sessions/list", + json: (object) $request_payload + ); + + if ($on_response !== null) { + $on_response($res); + } + + return array_map( + fn($r) => ClientSession::from_json($r), + $res->client_sessions + ); + } + + public function revoke(string $client_session_id): void + { + $request_payload = []; + + if ($client_session_id !== null) { + $request_payload["client_session_id"] = $client_session_id; + } + + $this->seam->request( + "POST", + "/client_sessions/revoke", + json: (object) $request_payload + ); + } +} + +class ConnectWebviewsClient +{ + private SeamClient $seam; + + public function __construct(SeamClient $seam) + { + $this->seam = $seam; + } + + public function create( + ?array $accepted_providers = null, + ?bool $automatically_manage_new_devices = null, + mixed $custom_metadata = null, + ?string $custom_redirect_failure_url = null, + ?string $custom_redirect_url = null, + ?string $device_selection_mode = null, + ?string $provider_category = null, + ?bool $wait_for_device_creation = null + ): ConnectWebview { + $request_payload = []; + + if ($accepted_providers !== null) { + $request_payload["accepted_providers"] = $accepted_providers; + } + if ($automatically_manage_new_devices !== null) { + $request_payload[ + "automatically_manage_new_devices" + ] = $automatically_manage_new_devices; + } + if ($custom_metadata !== null) { + $request_payload["custom_metadata"] = $custom_metadata; + } + if ($custom_redirect_failure_url !== null) { + $request_payload[ + "custom_redirect_failure_url" + ] = $custom_redirect_failure_url; + } + if ($custom_redirect_url !== null) { + $request_payload["custom_redirect_url"] = $custom_redirect_url; + } + if ($device_selection_mode !== null) { + $request_payload["device_selection_mode"] = $device_selection_mode; + } + if ($provider_category !== null) { + $request_payload["provider_category"] = $provider_category; + } + if ($wait_for_device_creation !== null) { + $request_payload[ + "wait_for_device_creation" + ] = $wait_for_device_creation; + } + + $res = $this->seam->request( + "POST", + "/connect_webviews/create", + json: (object) $request_payload + ); + + return ConnectWebview::from_json($res->connect_webview); + } + + public function delete(string $connect_webview_id): void + { + $request_payload = []; + + if ($connect_webview_id !== null) { + $request_payload["connect_webview_id"] = $connect_webview_id; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/user_identities/get", + "/connect_webviews/delete", json: (object) $request_payload ); - - return UserIdentity::from_json($res->user_identity); } - public function grant_access_to_device( - string $user_identity_id, - string $device_id - ): void { + public function get(string $connect_webview_id): ConnectWebview + { $request_payload = []; - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; - } - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($connect_webview_id !== null) { + $request_payload["connect_webview_id"] = $connect_webview_id; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/user_identities/grant_access_to_device", + "/connect_webviews/get", json: (object) $request_payload ); + + return ConnectWebview::from_json($res->connect_webview); } public function list( - ?string $credential_manager_acs_system_id = null, + mixed $custom_metadata_has = null, + ?float $limit = null, + ?string $user_identifier_key = null, ?callable $on_response = null ): array { $request_payload = []; - if ($credential_manager_acs_system_id !== null) { - $request_payload[ - "credential_manager_acs_system_id" - ] = $credential_manager_acs_system_id; + if ($custom_metadata_has !== null) { + $request_payload["custom_metadata_has"] = $custom_metadata_has; + } + if ($limit !== null) { + $request_payload["limit"] = $limit; + } + if ($user_identifier_key !== null) { + $request_payload["user_identifier_key"] = $user_identifier_key; } $res = $this->seam->request( "POST", - "/user_identities/list", + "/connect_webviews/list", json: (object) $request_payload ); @@ -2545,227 +2308,290 @@ public function list( } return array_map( - fn($r) => UserIdentity::from_json($r), - $res->user_identities + fn($r) => ConnectWebview::from_json($r), + $res->connect_webviews ); } +} - public function list_accessible_devices(string $user_identity_id): array - { - $request_payload = []; - - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; - } - - $res = $this->seam->request( - "POST", - "/user_identities/list_accessible_devices", - json: (object) $request_payload - ); +class ConnectedAccountsClient +{ + private SeamClient $seam; - return array_map(fn($r) => Device::from_json($r), $res->devices); + public function __construct(SeamClient $seam) + { + $this->seam = $seam; } - public function list_acs_systems(string $user_identity_id): array - { + public function delete( + string $connected_account_id, + ?bool $sync = null + ): void { $request_payload = []; - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; + if ($connected_account_id !== null) { + $request_payload["connected_account_id"] = $connected_account_id; + } + if ($sync !== null) { + $request_payload["sync"] = $sync; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/user_identities/list_acs_systems", + "/connected_accounts/delete", json: (object) $request_payload ); - - return array_map(fn($r) => AcsSystem::from_json($r), $res->acs_systems); } - public function list_acs_users(string $user_identity_id): array - { + public function get( + ?string $connected_account_id = null, + ?string $email = null + ): ConnectedAccount { $request_payload = []; - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; + if ($connected_account_id !== null) { + $request_payload["connected_account_id"] = $connected_account_id; + } + if ($email !== null) { + $request_payload["email"] = $email; } $res = $this->seam->request( "POST", - "/user_identities/list_acs_users", + "/connected_accounts/get", json: (object) $request_payload ); - return array_map(fn($r) => AcsUser::from_json($r), $res->acs_users); + return ConnectedAccount::from_json($res->connected_account); } - public function remove_acs_user( - string $user_identity_id, - string $acs_user_id - ): void { + public function list( + mixed $custom_metadata_has = null, + mixed $limit = null, + ?string $page_cursor = null, + ?string $user_identifier_key = null, + ?callable $on_response = null + ): array { $request_payload = []; - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; + if ($custom_metadata_has !== null) { + $request_payload["custom_metadata_has"] = $custom_metadata_has; } - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($limit !== null) { + $request_payload["limit"] = $limit; + } + if ($page_cursor !== null) { + $request_payload["page_cursor"] = $page_cursor; + } + if ($user_identifier_key !== null) { + $request_payload["user_identifier_key"] = $user_identifier_key; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/user_identities/remove_acs_user", + "/connected_accounts/list", json: (object) $request_payload ); - } - - public function revoke_access_to_device( - string $user_identity_id, - string $device_id - ): void { - $request_payload = []; - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; - } - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($on_response !== null) { + $on_response($res); } - $this->seam->request( - "POST", - "/user_identities/revoke_access_to_device", - json: (object) $request_payload + return array_map( + fn($r) => ConnectedAccount::from_json($r), + $res->connected_accounts ); } public function update( - string $user_identity_id, - ?string $user_identity_key = null, - ?string $email_address = null, - ?string $phone_number = null, - ?string $full_name = null + string $connected_account_id, + ?bool $automatically_manage_new_devices = null, + mixed $custom_metadata = null ): void { $request_payload = []; - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; - } - if ($user_identity_key !== null) { - $request_payload["user_identity_key"] = $user_identity_key; - } - if ($email_address !== null) { - $request_payload["email_address"] = $email_address; + if ($connected_account_id !== null) { + $request_payload["connected_account_id"] = $connected_account_id; } - if ($phone_number !== null) { - $request_payload["phone_number"] = $phone_number; + if ($automatically_manage_new_devices !== null) { + $request_payload[ + "automatically_manage_new_devices" + ] = $automatically_manage_new_devices; } - if ($full_name !== null) { - $request_payload["full_name"] = $full_name; + if ($custom_metadata !== null) { + $request_payload["custom_metadata"] = $custom_metadata; } $this->seam->request( "POST", - "/user_identities/update", + "/connected_accounts/update", json: (object) $request_payload ); } } -class WebhooksClient +class DevicesClient { private SeamClient $seam; - + public DevicesSimulateClient $simulate; + public DevicesUnmanagedClient $unmanaged; public function __construct(SeamClient $seam) { $this->seam = $seam; + $this->simulate = new DevicesSimulateClient($seam); + $this->unmanaged = new DevicesUnmanagedClient($seam); } - public function create(string $url, ?array $event_types = null): Webhook + public function get(?string $device_id = null, ?string $name = null): Device { $request_payload = []; - if ($url !== null) { - $request_payload["url"] = $url; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } + if ($name !== null) { + $request_payload["name"] = $name; + } + + $res = $this->seam->request( + "POST", + "/devices/get", + json: (object) $request_payload + ); + + return Device::from_json($res->device); + } + + public function list( + ?string $connect_webview_id = null, + ?string $connected_account_id = null, + ?array $connected_account_ids = null, + ?string $created_before = null, + mixed $custom_metadata_has = null, + ?array $device_ids = null, + ?string $device_type = null, + ?array $device_types = null, + ?array $exclude_if = null, + ?array $include_if = null, + ?float $limit = null, + ?string $manufacturer = null, + ?string $unstable_location_id = null, + ?string $user_identifier_key = null, + ?callable $on_response = null + ): array { + $request_payload = []; + + if ($connect_webview_id !== null) { + $request_payload["connect_webview_id"] = $connect_webview_id; + } + if ($connected_account_id !== null) { + $request_payload["connected_account_id"] = $connected_account_id; + } + if ($connected_account_ids !== null) { + $request_payload["connected_account_ids"] = $connected_account_ids; + } + if ($created_before !== null) { + $request_payload["created_before"] = $created_before; + } + if ($custom_metadata_has !== null) { + $request_payload["custom_metadata_has"] = $custom_metadata_has; + } + if ($device_ids !== null) { + $request_payload["device_ids"] = $device_ids; + } + if ($device_type !== null) { + $request_payload["device_type"] = $device_type; + } + if ($device_types !== null) { + $request_payload["device_types"] = $device_types; + } + if ($exclude_if !== null) { + $request_payload["exclude_if"] = $exclude_if; } - if ($event_types !== null) { - $request_payload["event_types"] = $event_types; + if ($include_if !== null) { + $request_payload["include_if"] = $include_if; + } + if ($limit !== null) { + $request_payload["limit"] = $limit; + } + if ($manufacturer !== null) { + $request_payload["manufacturer"] = $manufacturer; + } + if ($unstable_location_id !== null) { + $request_payload["unstable_location_id"] = $unstable_location_id; + } + if ($user_identifier_key !== null) { + $request_payload["user_identifier_key"] = $user_identifier_key; } $res = $this->seam->request( "POST", - "/webhooks/create", + "/devices/list", json: (object) $request_payload ); - return Webhook::from_json($res->webhook); - } - - public function delete(string $webhook_id): void - { - $request_payload = []; - - if ($webhook_id !== null) { - $request_payload["webhook_id"] = $webhook_id; + if ($on_response !== null) { + $on_response($res); } - $this->seam->request( - "POST", - "/webhooks/delete", - json: (object) $request_payload - ); + return array_map(fn($r) => Device::from_json($r), $res->devices); } - public function get(string $webhook_id): Webhook - { + public function list_device_providers( + ?string $provider_category = null + ): array { $request_payload = []; - if ($webhook_id !== null) { - $request_payload["webhook_id"] = $webhook_id; + if ($provider_category !== null) { + $request_payload["provider_category"] = $provider_category; } $res = $this->seam->request( "POST", - "/webhooks/get", + "/devices/list_device_providers", json: (object) $request_payload ); - return Webhook::from_json($res->webhook); - } - - public function list(?callable $on_response = null): array - { - $res = $this->seam->request("POST", "/webhooks/list"); - - if ($on_response !== null) { - $on_response($res); - } - - return array_map(fn($r) => Webhook::from_json($r), $res->webhooks); + return array_map( + fn($r) => DeviceProvider::from_json($r), + $res->device_providers + ); } - public function update(string $webhook_id, array $event_types): void - { + public function update( + string $device_id, + mixed $custom_metadata = null, + ?bool $is_managed = null, + ?string $name = null, + mixed $properties = null + ): void { $request_payload = []; - if ($webhook_id !== null) { - $request_payload["webhook_id"] = $webhook_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - if ($event_types !== null) { - $request_payload["event_types"] = $event_types; + if ($custom_metadata !== null) { + $request_payload["custom_metadata"] = $custom_metadata; + } + if ($is_managed !== null) { + $request_payload["is_managed"] = $is_managed; + } + if ($name !== null) { + $request_payload["name"] = $name; + } + if ($properties !== null) { + $request_payload["properties"] = $properties; } $this->seam->request( "POST", - "/webhooks/update", + "/devices/update", json: (object) $request_payload ); } } -class WorkspacesClient +class DevicesSimulateClient { private SeamClient $seam; @@ -2774,94 +2600,53 @@ public function __construct(SeamClient $seam) $this->seam = $seam; } - public function create( - string $name, - ?string $company_name = null, - ?string $connect_partner_name = null, - ?bool $is_sandbox = null, - ?string $webview_primary_button_color = null, - ?string $webview_primary_button_text_color = null, - ?string $webview_logo_shape = null, - ?string $webview_success_message = null - ): Workspace { + public function connect(string $device_id): void + { $request_payload = []; - if ($name !== null) { - $request_payload["name"] = $name; - } - if ($company_name !== null) { - $request_payload["company_name"] = $company_name; - } - if ($connect_partner_name !== null) { - $request_payload["connect_partner_name"] = $connect_partner_name; - } - if ($is_sandbox !== null) { - $request_payload["is_sandbox"] = $is_sandbox; - } - if ($webview_primary_button_color !== null) { - $request_payload[ - "webview_primary_button_color" - ] = $webview_primary_button_color; - } - if ($webview_primary_button_text_color !== null) { - $request_payload[ - "webview_primary_button_text_color" - ] = $webview_primary_button_text_color; - } - if ($webview_logo_shape !== null) { - $request_payload["webview_logo_shape"] = $webview_logo_shape; - } - if ($webview_success_message !== null) { - $request_payload[ - "webview_success_message" - ] = $webview_success_message; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/workspaces/create", + "/devices/simulate/connect", json: (object) $request_payload ); - - return Workspace::from_json($res->workspace); - } - - public function get(): Workspace - { - $res = $this->seam->request("POST", "/workspaces/get"); - - return Workspace::from_json($res->workspace); } - public function list(?callable $on_response = null): array + public function disconnect(string $device_id): void { - $res = $this->seam->request("POST", "/workspaces/list"); + $request_payload = []; - if ($on_response !== null) { - $on_response($res); + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - return array_map(fn($r) => Workspace::from_json($r), $res->workspaces); + $this->seam->request( + "POST", + "/devices/simulate/disconnect", + json: (object) $request_payload + ); } - public function reset_sandbox( - bool $wait_for_action_attempt = true - ): ActionAttempt { - $res = $this->seam->request("POST", "/workspaces/reset_sandbox"); + public function remove(string $device_id): void + { + $request_payload = []; - if (!$wait_for_action_attempt) { - return ActionAttempt::from_json($res->action_attempt); + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - $action_attempt = $this->seam->action_attempts->poll_until_ready( - $res->action_attempt->action_attempt_id + $this->seam->request( + "POST", + "/devices/simulate/remove", + json: (object) $request_payload ); - - return $action_attempt; } } -class AccessCodesSimulateClient +class DevicesUnmanagedClient { private SeamClient $seam; @@ -2870,11 +2655,10 @@ public function __construct(SeamClient $seam) $this->seam = $seam; } - public function create_unmanaged_access_code( - string $device_id, - string $name, - string $code - ): UnmanagedAccessCode { + public function get( + ?string $device_id = null, + ?string $name = null + ): UnmanagedDevice { $request_payload = []; if ($device_id !== null) { @@ -2883,177 +2667,229 @@ public function create_unmanaged_access_code( if ($name !== null) { $request_payload["name"] = $name; } - if ($code !== null) { - $request_payload["code"] = $code; - } $res = $this->seam->request( "POST", - "/access_codes/simulate/create_unmanaged_access_code", + "/devices/unmanaged/get", json: (object) $request_payload ); - return UnmanagedAccessCode::from_json($res->access_code); - } -} - -class AccessCodesUnmanagedClient -{ - private SeamClient $seam; - - public function __construct(SeamClient $seam) - { - $this->seam = $seam; + return UnmanagedDevice::from_json($res->device); } - public function convert_to_managed( - string $access_code_id, - ?bool $is_external_modification_allowed = null, - ?bool $allow_external_modification = null, - ?bool $force = null, - ?bool $sync = null - ): void { + public function list( + ?string $connect_webview_id = null, + ?string $connected_account_id = null, + ?array $connected_account_ids = null, + ?string $created_before = null, + mixed $custom_metadata_has = null, + ?array $device_ids = null, + ?string $device_type = null, + ?array $device_types = null, + ?array $exclude_if = null, + ?array $include_if = null, + ?float $limit = null, + ?string $manufacturer = null, + ?string $unstable_location_id = null, + ?string $user_identifier_key = null, + ?callable $on_response = null + ): array { $request_payload = []; - if ($access_code_id !== null) { - $request_payload["access_code_id"] = $access_code_id; + if ($connect_webview_id !== null) { + $request_payload["connect_webview_id"] = $connect_webview_id; + } + if ($connected_account_id !== null) { + $request_payload["connected_account_id"] = $connected_account_id; + } + if ($connected_account_ids !== null) { + $request_payload["connected_account_ids"] = $connected_account_ids; + } + if ($created_before !== null) { + $request_payload["created_before"] = $created_before; + } + if ($custom_metadata_has !== null) { + $request_payload["custom_metadata_has"] = $custom_metadata_has; + } + if ($device_ids !== null) { + $request_payload["device_ids"] = $device_ids; + } + if ($device_type !== null) { + $request_payload["device_type"] = $device_type; + } + if ($device_types !== null) { + $request_payload["device_types"] = $device_types; } - if ($is_external_modification_allowed !== null) { - $request_payload[ - "is_external_modification_allowed" - ] = $is_external_modification_allowed; + if ($exclude_if !== null) { + $request_payload["exclude_if"] = $exclude_if; } - if ($allow_external_modification !== null) { - $request_payload[ - "allow_external_modification" - ] = $allow_external_modification; + if ($include_if !== null) { + $request_payload["include_if"] = $include_if; } - if ($force !== null) { - $request_payload["force"] = $force; + if ($limit !== null) { + $request_payload["limit"] = $limit; } - if ($sync !== null) { - $request_payload["sync"] = $sync; + if ($manufacturer !== null) { + $request_payload["manufacturer"] = $manufacturer; + } + if ($unstable_location_id !== null) { + $request_payload["unstable_location_id"] = $unstable_location_id; + } + if ($user_identifier_key !== null) { + $request_payload["user_identifier_key"] = $user_identifier_key; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/access_codes/unmanaged/convert_to_managed", + "/devices/unmanaged/list", json: (object) $request_payload ); + + if ($on_response !== null) { + $on_response($res); + } + + return array_map( + fn($r) => UnmanagedDevice::from_json($r), + $res->devices + ); } - public function delete(string $access_code_id, ?bool $sync = null): void + public function update(string $device_id, bool $is_managed): void { $request_payload = []; - if ($access_code_id !== null) { - $request_payload["access_code_id"] = $access_code_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - if ($sync !== null) { - $request_payload["sync"] = $sync; + if ($is_managed !== null) { + $request_payload["is_managed"] = $is_managed; } $this->seam->request( "POST", - "/access_codes/unmanaged/delete", + "/devices/unmanaged/update", json: (object) $request_payload ); } +} + +class EventsClient +{ + private SeamClient $seam; + + public function __construct(SeamClient $seam) + { + $this->seam = $seam; + } public function get( ?string $device_id = null, - ?string $access_code_id = null, - ?string $code = null - ): UnmanagedAccessCode { + ?string $event_id = null, + ?string $event_type = null + ): Event { $request_payload = []; if ($device_id !== null) { $request_payload["device_id"] = $device_id; } - if ($access_code_id !== null) { - $request_payload["access_code_id"] = $access_code_id; + if ($event_id !== null) { + $request_payload["event_id"] = $event_id; } - if ($code !== null) { - $request_payload["code"] = $code; + if ($event_type !== null) { + $request_payload["event_type"] = $event_type; } $res = $this->seam->request( "POST", - "/access_codes/unmanaged/get", + "/events/get", json: (object) $request_payload ); - return UnmanagedAccessCode::from_json($res->access_code); + return Event::from_json($res->event); } public function list( - string $device_id, - ?string $user_identifier_key = null, + ?string $access_code_id = null, + ?array $access_code_ids = null, + ?string $acs_system_id = null, + ?array $acs_system_ids = null, + ?array $between = null, + ?string $connect_webview_id = null, + ?string $connected_account_id = null, + ?string $device_id = null, + ?array $device_ids = null, + ?array $event_ids = null, + ?string $event_type = null, + ?array $event_types = null, + ?float $limit = null, + ?string $since = null, + ?float $unstable_offset = null, ?callable $on_response = null ): array { $request_payload = []; + if ($access_code_id !== null) { + $request_payload["access_code_id"] = $access_code_id; + } + if ($access_code_ids !== null) { + $request_payload["access_code_ids"] = $access_code_ids; + } + if ($acs_system_id !== null) { + $request_payload["acs_system_id"] = $acs_system_id; + } + if ($acs_system_ids !== null) { + $request_payload["acs_system_ids"] = $acs_system_ids; + } + if ($between !== null) { + $request_payload["between"] = $between; + } + if ($connect_webview_id !== null) { + $request_payload["connect_webview_id"] = $connect_webview_id; + } + if ($connected_account_id !== null) { + $request_payload["connected_account_id"] = $connected_account_id; + } if ($device_id !== null) { $request_payload["device_id"] = $device_id; } - if ($user_identifier_key !== null) { - $request_payload["user_identifier_key"] = $user_identifier_key; + if ($device_ids !== null) { + $request_payload["device_ids"] = $device_ids; } - - $res = $this->seam->request( - "POST", - "/access_codes/unmanaged/list", - json: (object) $request_payload - ); - - if ($on_response !== null) { - $on_response($res); + if ($event_ids !== null) { + $request_payload["event_ids"] = $event_ids; } - - return array_map( - fn($r) => UnmanagedAccessCode::from_json($r), - $res->access_codes - ); - } - - public function update( - string $access_code_id, - bool $is_managed, - ?bool $allow_external_modification = null, - ?bool $is_external_modification_allowed = null, - ?bool $force = null - ): void { - $request_payload = []; - - if ($access_code_id !== null) { - $request_payload["access_code_id"] = $access_code_id; + if ($event_type !== null) { + $request_payload["event_type"] = $event_type; } - if ($is_managed !== null) { - $request_payload["is_managed"] = $is_managed; + if ($event_types !== null) { + $request_payload["event_types"] = $event_types; } - if ($allow_external_modification !== null) { - $request_payload[ - "allow_external_modification" - ] = $allow_external_modification; + if ($limit !== null) { + $request_payload["limit"] = $limit; } - if ($is_external_modification_allowed !== null) { - $request_payload[ - "is_external_modification_allowed" - ] = $is_external_modification_allowed; + if ($since !== null) { + $request_payload["since"] = $since; } - if ($force !== null) { - $request_payload["force"] = $force; + if ($unstable_offset !== null) { + $request_payload["unstable_offset"] = $unstable_offset; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/access_codes/unmanaged/update", + "/events/list", json: (object) $request_payload ); + + if ($on_response !== null) { + $on_response($res); + } + + return array_map(fn($r) => Event::from_json($r), $res->events); } } -class AcsAccessGroupsClient +class LocksClient { private SeamClient $seam; @@ -3062,60 +2898,91 @@ public function __construct(SeamClient $seam) $this->seam = $seam; } - public function add_user( - string $acs_access_group_id, - string $acs_user_id - ): void { - $request_payload = []; - - if ($acs_access_group_id !== null) { - $request_payload["acs_access_group_id"] = $acs_access_group_id; - } - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; - } - - $this->seam->request( - "POST", - "/acs/access_groups/add_user", - json: (object) $request_payload - ); - } - - public function get(string $acs_access_group_id): AcsAccessGroup + public function get(?string $device_id = null, ?string $name = null): Device { $request_payload = []; - if ($acs_access_group_id !== null) { - $request_payload["acs_access_group_id"] = $acs_access_group_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } + if ($name !== null) { + $request_payload["name"] = $name; } $res = $this->seam->request( "POST", - "/acs/access_groups/get", + "/locks/get", json: (object) $request_payload ); - return AcsAccessGroup::from_json($res->acs_access_group); + return Device::from_json($res->device); } public function list( - ?string $acs_system_id = null, - ?string $acs_user_id = null, + ?string $connect_webview_id = null, + ?string $connected_account_id = null, + ?array $connected_account_ids = null, + ?string $created_before = null, + mixed $custom_metadata_has = null, + ?array $device_ids = null, + ?string $device_type = null, + ?array $device_types = null, + ?array $exclude_if = null, + ?array $include_if = null, + ?float $limit = null, + ?string $manufacturer = null, + ?string $unstable_location_id = null, + ?string $user_identifier_key = null, ?callable $on_response = null ): array { $request_payload = []; - if ($acs_system_id !== null) { - $request_payload["acs_system_id"] = $acs_system_id; + if ($connect_webview_id !== null) { + $request_payload["connect_webview_id"] = $connect_webview_id; + } + if ($connected_account_id !== null) { + $request_payload["connected_account_id"] = $connected_account_id; + } + if ($connected_account_ids !== null) { + $request_payload["connected_account_ids"] = $connected_account_ids; + } + if ($created_before !== null) { + $request_payload["created_before"] = $created_before; + } + if ($custom_metadata_has !== null) { + $request_payload["custom_metadata_has"] = $custom_metadata_has; + } + if ($device_ids !== null) { + $request_payload["device_ids"] = $device_ids; + } + if ($device_type !== null) { + $request_payload["device_type"] = $device_type; + } + if ($device_types !== null) { + $request_payload["device_types"] = $device_types; + } + if ($exclude_if !== null) { + $request_payload["exclude_if"] = $exclude_if; } - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($include_if !== null) { + $request_payload["include_if"] = $include_if; + } + if ($limit !== null) { + $request_payload["limit"] = $limit; + } + if ($manufacturer !== null) { + $request_payload["manufacturer"] = $manufacturer; + } + if ($unstable_location_id !== null) { + $request_payload["unstable_location_id"] = $unstable_location_id; + } + if ($user_identifier_key !== null) { + $request_payload["user_identifier_key"] = $user_identifier_key; } $res = $this->seam->request( "POST", - "/acs/access_groups/list", + "/locks/list", json: (object) $request_payload ); @@ -3123,93 +2990,73 @@ public function list( $on_response($res); } - return array_map( - fn($r) => AcsAccessGroup::from_json($r), - $res->acs_access_groups - ); + return array_map(fn($r) => Device::from_json($r), $res->devices); } - public function list_accessible_entrances( - string $acs_access_group_id - ): array { + public function lock_door( + string $device_id, + ?bool $sync = null, + bool $wait_for_action_attempt = true + ): ActionAttempt { $request_payload = []; - if ($acs_access_group_id !== null) { - $request_payload["acs_access_group_id"] = $acs_access_group_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } + if ($sync !== null) { + $request_payload["sync"] = $sync; } $res = $this->seam->request( "POST", - "/acs/access_groups/list_accessible_entrances", + "/locks/lock_door", json: (object) $request_payload ); - return array_map( - fn($r) => AcsEntrance::from_json($r), - $res->acs_entrances + if (!$wait_for_action_attempt) { + return ActionAttempt::from_json($res->action_attempt); + } + + $action_attempt = $this->seam->action_attempts->poll_until_ready( + $res->action_attempt->action_attempt_id ); + + return $action_attempt; } - public function list_users(string $acs_access_group_id): array - { + public function unlock_door( + string $device_id, + ?bool $sync = null, + bool $wait_for_action_attempt = true + ): ActionAttempt { $request_payload = []; - if ($acs_access_group_id !== null) { - $request_payload["acs_access_group_id"] = $acs_access_group_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } + if ($sync !== null) { + $request_payload["sync"] = $sync; } $res = $this->seam->request( "POST", - "/acs/access_groups/list_users", + "/locks/unlock_door", json: (object) $request_payload ); - return array_map(fn($r) => AcsUser::from_json($r), $res->acs_users); - } - - public function remove_user( - string $acs_access_group_id, - string $acs_user_id - ): void { - $request_payload = []; - - if ($acs_access_group_id !== null) { - $request_payload["acs_access_group_id"] = $acs_access_group_id; - } - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if (!$wait_for_action_attempt) { + return ActionAttempt::from_json($res->action_attempt); } - $this->seam->request( - "POST", - "/acs/access_groups/remove_user", - json: (object) $request_payload + $action_attempt = $this->seam->action_attempts->poll_until_ready( + $res->action_attempt->action_attempt_id ); - } -} -class AcsClient -{ - private SeamClient $seam; - public AcsAccessGroupsClient $access_groups; - public AcsCredentialsClient $credentials; - public AcsEncodersClient $encoders; - public AcsEntrancesClient $entrances; - public AcsSystemsClient $systems; - public AcsUsersClient $users; - public function __construct(SeamClient $seam) - { - $this->seam = $seam; - $this->access_groups = new AcsAccessGroupsClient($seam); - $this->credentials = new AcsCredentialsClient($seam); - $this->encoders = new AcsEncodersClient($seam); - $this->entrances = new AcsEntrancesClient($seam); - $this->systems = new AcsSystemsClient($seam); - $this->users = new AcsUsersClient($seam); + return $action_attempt; } } -class AcsCredentialsClient +class NetworksClient { private SeamClient $seam; @@ -3218,157 +3065,112 @@ public function __construct(SeamClient $seam) $this->seam = $seam; } - public function assign(string $acs_user_id, string $acs_credential_id): void + public function get(string $network_id): Network { $request_payload = []; - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; - } - if ($acs_credential_id !== null) { - $request_payload["acs_credential_id"] = $acs_credential_id; - } - - $this->seam->request( - "POST", - "/acs/credentials/assign", - json: (object) $request_payload - ); - } - - public function create( - string $acs_user_id, - string $access_method, - ?string $credential_manager_acs_system_id = null, - ?string $code = null, - ?bool $is_multi_phone_sync_credential = null, - ?array $allowed_acs_entrance_ids = null, - mixed $visionline_metadata = null, - mixed $assa_abloy_vostio_metadata = null, - mixed $salto_space_metadata = null, - ?string $starts_at = null, - ?string $ends_at = null - ): AcsCredential { - $request_payload = []; - - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; - } - if ($access_method !== null) { - $request_payload["access_method"] = $access_method; - } - if ($credential_manager_acs_system_id !== null) { - $request_payload[ - "credential_manager_acs_system_id" - ] = $credential_manager_acs_system_id; - } - if ($code !== null) { - $request_payload["code"] = $code; - } - if ($is_multi_phone_sync_credential !== null) { - $request_payload[ - "is_multi_phone_sync_credential" - ] = $is_multi_phone_sync_credential; - } - if ($allowed_acs_entrance_ids !== null) { - $request_payload[ - "allowed_acs_entrance_ids" - ] = $allowed_acs_entrance_ids; - } - if ($visionline_metadata !== null) { - $request_payload["visionline_metadata"] = $visionline_metadata; - } - if ($assa_abloy_vostio_metadata !== null) { - $request_payload[ - "assa_abloy_vostio_metadata" - ] = $assa_abloy_vostio_metadata; - } - if ($salto_space_metadata !== null) { - $request_payload["salto_space_metadata"] = $salto_space_metadata; - } - if ($starts_at !== null) { - $request_payload["starts_at"] = $starts_at; - } - if ($ends_at !== null) { - $request_payload["ends_at"] = $ends_at; + if ($network_id !== null) { + $request_payload["network_id"] = $network_id; } $res = $this->seam->request( "POST", - "/acs/credentials/create", + "/networks/get", json: (object) $request_payload ); - return AcsCredential::from_json($res->acs_credential); + return Network::from_json($res->network); } - public function delete(string $acs_credential_id): void + public function list(?callable $on_response = null): array { - $request_payload = []; + $res = $this->seam->request("POST", "/networks/list"); - if ($acs_credential_id !== null) { - $request_payload["acs_credential_id"] = $acs_credential_id; + if ($on_response !== null) { + $on_response($res); } - $this->seam->request( - "POST", - "/acs/credentials/delete", - json: (object) $request_payload - ); + return array_map(fn($r) => Network::from_json($r), $res->networks); } +} - public function get(string $acs_credential_id): AcsCredential +class NoiseSensorsClient +{ + private SeamClient $seam; + public NoiseSensorsNoiseThresholdsClient $noise_thresholds; + public NoiseSensorsSimulateClient $simulate; + public function __construct(SeamClient $seam) { - $request_payload = []; - - if ($acs_credential_id !== null) { - $request_payload["acs_credential_id"] = $acs_credential_id; - } - - $res = $this->seam->request( - "POST", - "/acs/credentials/get", - json: (object) $request_payload - ); - - return AcsCredential::from_json($res->acs_credential); + $this->seam = $seam; + $this->noise_thresholds = new NoiseSensorsNoiseThresholdsClient($seam); + $this->simulate = new NoiseSensorsSimulateClient($seam); } public function list( - ?string $acs_user_id = null, - ?string $acs_system_id = null, - ?string $user_identity_id = null, - ?float $limit = null, + ?string $connect_webview_id = null, + ?string $connected_account_id = null, + ?array $connected_account_ids = null, ?string $created_before = null, - ?bool $is_multi_phone_sync_credential = null, + mixed $custom_metadata_has = null, + ?array $device_ids = null, + ?string $device_type = null, + ?array $device_types = null, + ?array $exclude_if = null, + ?array $include_if = null, + ?float $limit = null, + ?string $manufacturer = null, + ?string $unstable_location_id = null, + ?string $user_identifier_key = null, ?callable $on_response = null ): array { $request_payload = []; - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($connect_webview_id !== null) { + $request_payload["connect_webview_id"] = $connect_webview_id; + } + if ($connected_account_id !== null) { + $request_payload["connected_account_id"] = $connected_account_id; + } + if ($connected_account_ids !== null) { + $request_payload["connected_account_ids"] = $connected_account_ids; + } + if ($created_before !== null) { + $request_payload["created_before"] = $created_before; } - if ($acs_system_id !== null) { - $request_payload["acs_system_id"] = $acs_system_id; + if ($custom_metadata_has !== null) { + $request_payload["custom_metadata_has"] = $custom_metadata_has; } - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; + if ($device_ids !== null) { + $request_payload["device_ids"] = $device_ids; + } + if ($device_type !== null) { + $request_payload["device_type"] = $device_type; + } + if ($device_types !== null) { + $request_payload["device_types"] = $device_types; + } + if ($exclude_if !== null) { + $request_payload["exclude_if"] = $exclude_if; + } + if ($include_if !== null) { + $request_payload["include_if"] = $include_if; } if ($limit !== null) { $request_payload["limit"] = $limit; } - if ($created_before !== null) { - $request_payload["created_before"] = $created_before; + if ($manufacturer !== null) { + $request_payload["manufacturer"] = $manufacturer; } - if ($is_multi_phone_sync_credential !== null) { - $request_payload[ - "is_multi_phone_sync_credential" - ] = $is_multi_phone_sync_credential; + if ($unstable_location_id !== null) { + $request_payload["unstable_location_id"] = $unstable_location_id; + } + if ($user_identifier_key !== null) { + $request_payload["user_identifier_key"] = $user_identifier_key; } $res = $this->seam->request( "POST", - "/acs/credentials/list", + "/noise_sensors/list", json: (object) $request_payload ); @@ -3376,142 +3178,121 @@ public function list( $on_response($res); } - return array_map( - fn($r) => AcsCredential::from_json($r), - $res->acs_credentials - ); + return array_map(fn($r) => Device::from_json($r), $res->devices); } +} - public function list_accessible_entrances(string $acs_credential_id): array - { - $request_payload = []; - - if ($acs_credential_id !== null) { - $request_payload["acs_credential_id"] = $acs_credential_id; - } - - $res = $this->seam->request( - "POST", - "/acs/credentials/list_accessible_entrances", - json: (object) $request_payload - ); +class NoiseSensorsNoiseThresholdsClient +{ + private SeamClient $seam; - return array_map( - fn($r) => AcsEntrance::from_json($r), - $res->acs_entrances - ); + public function __construct(SeamClient $seam) + { + $this->seam = $seam; } - public function unassign( - string $acs_user_id, - string $acs_credential_id - ): void { + public function create( + string $device_id, + string $ends_daily_at, + string $starts_daily_at, + ?string $name = null, + ?float $noise_threshold_decibels = null, + ?float $noise_threshold_nrs = null, + ?bool $sync = null + ): NoiseThreshold { $request_payload = []; - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - if ($acs_credential_id !== null) { - $request_payload["acs_credential_id"] = $acs_credential_id; + if ($ends_daily_at !== null) { + $request_payload["ends_daily_at"] = $ends_daily_at; + } + if ($starts_daily_at !== null) { + $request_payload["starts_daily_at"] = $starts_daily_at; + } + if ($name !== null) { + $request_payload["name"] = $name; + } + if ($noise_threshold_decibels !== null) { + $request_payload[ + "noise_threshold_decibels" + ] = $noise_threshold_decibels; + } + if ($noise_threshold_nrs !== null) { + $request_payload["noise_threshold_nrs"] = $noise_threshold_nrs; + } + if ($sync !== null) { + $request_payload["sync"] = $sync; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/acs/credentials/unassign", + "/noise_sensors/noise_thresholds/create", json: (object) $request_payload ); + + return NoiseThreshold::from_json($res->noise_threshold); } - public function update( - string $acs_credential_id, - ?string $code = null, - ?string $ends_at = null + public function delete( + string $device_id, + string $noise_threshold_id, + ?bool $sync = null ): void { $request_payload = []; - if ($acs_credential_id !== null) { - $request_payload["acs_credential_id"] = $acs_credential_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - if ($code !== null) { - $request_payload["code"] = $code; + if ($noise_threshold_id !== null) { + $request_payload["noise_threshold_id"] = $noise_threshold_id; } - if ($ends_at !== null) { - $request_payload["ends_at"] = $ends_at; + if ($sync !== null) { + $request_payload["sync"] = $sync; } $this->seam->request( "POST", - "/acs/credentials/update", + "/noise_sensors/noise_thresholds/delete", json: (object) $request_payload ); } -} - -class AcsEncodersClient -{ - private SeamClient $seam; - public function __construct(SeamClient $seam) + public function get(string $noise_threshold_id): NoiseThreshold { - $this->seam = $seam; - } - - public function encode_credential( - string $acs_encoder_id, - string $acs_credential_id, - bool $wait_for_action_attempt = true - ): ActionAttempt { $request_payload = []; - if ($acs_encoder_id !== null) { - $request_payload["acs_encoder_id"] = $acs_encoder_id; - } - if ($acs_credential_id !== null) { - $request_payload["acs_credential_id"] = $acs_credential_id; + if ($noise_threshold_id !== null) { + $request_payload["noise_threshold_id"] = $noise_threshold_id; } $res = $this->seam->request( "POST", - "/acs/encoders/encode_credential", + "/noise_sensors/noise_thresholds/get", json: (object) $request_payload ); - if (!$wait_for_action_attempt) { - return ActionAttempt::from_json($res->action_attempt); - } - - $action_attempt = $this->seam->action_attempts->poll_until_ready( - $res->action_attempt->action_attempt_id - ); - - return $action_attempt; + return NoiseThreshold::from_json($res->noise_threshold); } public function list( - ?string $acs_system_id = null, - ?float $limit = null, - ?array $acs_system_ids = null, - ?array $acs_encoder_ids = null, + string $device_id, + ?bool $is_programmed = null, ?callable $on_response = null ): array { $request_payload = []; - if ($acs_system_id !== null) { - $request_payload["acs_system_id"] = $acs_system_id; - } - if ($limit !== null) { - $request_payload["limit"] = $limit; - } - if ($acs_system_ids !== null) { - $request_payload["acs_system_ids"] = $acs_system_ids; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - if ($acs_encoder_ids !== null) { - $request_payload["acs_encoder_ids"] = $acs_encoder_ids; + if ($is_programmed !== null) { + $request_payload["is_programmed"] = $is_programmed; } $res = $this->seam->request( "POST", - "/acs/encoders/list", + "/noise_sensors/noise_thresholds/list", json: (object) $request_payload ); @@ -3520,102 +3301,144 @@ public function list( } return array_map( - fn($r) => AcsEncoder::from_json($r), - $res->acs_encoders + fn($r) => NoiseThreshold::from_json($r), + $res->noise_thresholds ); } - public function scan_credential( - string $acs_encoder_id, - bool $wait_for_action_attempt = true - ): ActionAttempt { + public function update( + string $device_id, + string $noise_threshold_id, + ?string $ends_daily_at = null, + ?string $name = null, + ?float $noise_threshold_decibels = null, + ?float $noise_threshold_nrs = null, + ?string $starts_daily_at = null, + ?bool $sync = null + ): void { $request_payload = []; - if ($acs_encoder_id !== null) { - $request_payload["acs_encoder_id"] = $acs_encoder_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } + if ($noise_threshold_id !== null) { + $request_payload["noise_threshold_id"] = $noise_threshold_id; + } + if ($ends_daily_at !== null) { + $request_payload["ends_daily_at"] = $ends_daily_at; + } + if ($name !== null) { + $request_payload["name"] = $name; + } + if ($noise_threshold_decibels !== null) { + $request_payload[ + "noise_threshold_decibels" + ] = $noise_threshold_decibels; + } + if ($noise_threshold_nrs !== null) { + $request_payload["noise_threshold_nrs"] = $noise_threshold_nrs; + } + if ($starts_daily_at !== null) { + $request_payload["starts_daily_at"] = $starts_daily_at; + } + if ($sync !== null) { + $request_payload["sync"] = $sync; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/acs/encoders/scan_credential", + "/noise_sensors/noise_thresholds/update", json: (object) $request_payload ); + } +} - if (!$wait_for_action_attempt) { - return ActionAttempt::from_json($res->action_attempt); - } +class NoiseSensorsSimulateClient +{ + private SeamClient $seam; - $action_attempt = $this->seam->action_attempts->poll_until_ready( - $res->action_attempt->action_attempt_id - ); + public function __construct(SeamClient $seam) + { + $this->seam = $seam; + } + + public function trigger_noise_threshold(string $device_id): void + { + $request_payload = []; + + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } - return $action_attempt; + $this->seam->request( + "POST", + "/noise_sensors/simulate/trigger_noise_threshold", + json: (object) $request_payload + ); } } -class AcsEntrancesClient +class PhonesClient { private SeamClient $seam; - + public PhonesSimulateClient $simulate; public function __construct(SeamClient $seam) { $this->seam = $seam; + $this->simulate = new PhonesSimulateClient($seam); } - public function get(string $acs_entrance_id): AcsEntrance + public function deactivate(string $device_id): void { $request_payload = []; - if ($acs_entrance_id !== null) { - $request_payload["acs_entrance_id"] = $acs_entrance_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/acs/entrances/get", + "/phones/deactivate", json: (object) $request_payload ); - - return AcsEntrance::from_json($res->acs_entrance); } - public function grant_access( - string $acs_entrance_id, - string $acs_user_id - ): void { + public function get(string $device_id): Phone + { $request_payload = []; - if ($acs_entrance_id !== null) { - $request_payload["acs_entrance_id"] = $acs_entrance_id; - } - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/acs/entrances/grant_access", + "/phones/get", json: (object) $request_payload ); + + return Phone::from_json($res->phone); } public function list( - ?string $acs_system_id = null, ?string $acs_credential_id = null, + ?string $owner_user_identity_id = null, ?callable $on_response = null ): array { $request_payload = []; - if ($acs_system_id !== null) { - $request_payload["acs_system_id"] = $acs_system_id; - } if ($acs_credential_id !== null) { $request_payload["acs_credential_id"] = $acs_credential_id; } + if ($owner_user_identity_id !== null) { + $request_payload[ + "owner_user_identity_id" + ] = $owner_user_identity_id; + } $res = $this->seam->request( "POST", - "/acs/entrances/list", + "/phones/list", json: (object) $request_payload ); @@ -3623,258 +3446,383 @@ public function list( $on_response($res); } - return array_map( - fn($r) => AcsEntrance::from_json($r), - $res->acs_entrances - ); + return array_map(fn($r) => Phone::from_json($r), $res->phones); } +} - public function list_credentials_with_access( - string $acs_entrance_id, - ?array $include_if = null - ): array { +class PhonesSimulateClient +{ + private SeamClient $seam; + + public function __construct(SeamClient $seam) + { + $this->seam = $seam; + } + + public function create_sandbox_phone( + string $user_identity_id, + mixed $assa_abloy_metadata = null, + ?string $custom_sdk_installation_id = null, + mixed $phone_metadata = null + ): Phone { $request_payload = []; - if ($acs_entrance_id !== null) { - $request_payload["acs_entrance_id"] = $acs_entrance_id; + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; } - if ($include_if !== null) { - $request_payload["include_if"] = $include_if; + if ($assa_abloy_metadata !== null) { + $request_payload["assa_abloy_metadata"] = $assa_abloy_metadata; + } + if ($custom_sdk_installation_id !== null) { + $request_payload[ + "custom_sdk_installation_id" + ] = $custom_sdk_installation_id; + } + if ($phone_metadata !== null) { + $request_payload["phone_metadata"] = $phone_metadata; } $res = $this->seam->request( "POST", - "/acs/entrances/list_credentials_with_access", + "/phones/simulate/create_sandbox_phone", json: (object) $request_payload ); - return array_map( - fn($r) => AcsCredential::from_json($r), - $res->acs_credentials - ); + return Phone::from_json($res->phone); } } -class AcsSystemsClient +class ThermostatsClient { private SeamClient $seam; - + public ThermostatsSchedulesClient $schedules; + public ThermostatsSimulateClient $simulate; public function __construct(SeamClient $seam) { $this->seam = $seam; + $this->schedules = new ThermostatsSchedulesClient($seam); + $this->simulate = new ThermostatsSimulateClient($seam); } - public function get(string $acs_system_id): AcsSystem - { + public function activate_climate_preset( + string $climate_preset_key, + string $device_id, + bool $wait_for_action_attempt = true + ): ActionAttempt { $request_payload = []; - if ($acs_system_id !== null) { - $request_payload["acs_system_id"] = $acs_system_id; + if ($climate_preset_key !== null) { + $request_payload["climate_preset_key"] = $climate_preset_key; + } + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } $res = $this->seam->request( "POST", - "/acs/systems/get", + "/thermostats/activate_climate_preset", json: (object) $request_payload ); - return AcsSystem::from_json($res->acs_system); + if (!$wait_for_action_attempt) { + return ActionAttempt::from_json($res->action_attempt); + } + + $action_attempt = $this->seam->action_attempts->poll_until_ready( + $res->action_attempt->action_attempt_id + ); + + return $action_attempt; } - public function list( - ?string $connected_account_id = null, - ?callable $on_response = null - ): array { + public function cool( + string $device_id, + ?float $cooling_set_point_celsius = null, + ?float $cooling_set_point_fahrenheit = null, + ?bool $sync = null, + bool $wait_for_action_attempt = true + ): ActionAttempt { $request_payload = []; - if ($connected_account_id !== null) { - $request_payload["connected_account_id"] = $connected_account_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } + if ($cooling_set_point_celsius !== null) { + $request_payload[ + "cooling_set_point_celsius" + ] = $cooling_set_point_celsius; + } + if ($cooling_set_point_fahrenheit !== null) { + $request_payload[ + "cooling_set_point_fahrenheit" + ] = $cooling_set_point_fahrenheit; + } + if ($sync !== null) { + $request_payload["sync"] = $sync; } $res = $this->seam->request( "POST", - "/acs/systems/list", + "/thermostats/cool", json: (object) $request_payload ); - if ($on_response !== null) { - $on_response($res); + if (!$wait_for_action_attempt) { + return ActionAttempt::from_json($res->action_attempt); } - return array_map(fn($r) => AcsSystem::from_json($r), $res->acs_systems); + $action_attempt = $this->seam->action_attempts->poll_until_ready( + $res->action_attempt->action_attempt_id + ); + + return $action_attempt; } - public function list_compatible_credential_manager_acs_systems( - string $acs_system_id - ): array { + public function create_climate_preset( + string $climate_preset_key, + string $device_id, + ?float $cooling_set_point_celsius = null, + ?float $cooling_set_point_fahrenheit = null, + ?string $fan_mode_setting = null, + ?float $heating_set_point_celsius = null, + ?float $heating_set_point_fahrenheit = null, + ?string $hvac_mode_setting = null, + ?bool $manual_override_allowed = null, + ?string $name = null + ): void { $request_payload = []; - if ($acs_system_id !== null) { - $request_payload["acs_system_id"] = $acs_system_id; + if ($climate_preset_key !== null) { + $request_payload["climate_preset_key"] = $climate_preset_key; + } + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } + if ($cooling_set_point_celsius !== null) { + $request_payload[ + "cooling_set_point_celsius" + ] = $cooling_set_point_celsius; + } + if ($cooling_set_point_fahrenheit !== null) { + $request_payload[ + "cooling_set_point_fahrenheit" + ] = $cooling_set_point_fahrenheit; + } + if ($fan_mode_setting !== null) { + $request_payload["fan_mode_setting"] = $fan_mode_setting; + } + if ($heating_set_point_celsius !== null) { + $request_payload[ + "heating_set_point_celsius" + ] = $heating_set_point_celsius; + } + if ($heating_set_point_fahrenheit !== null) { + $request_payload[ + "heating_set_point_fahrenheit" + ] = $heating_set_point_fahrenheit; + } + if ($hvac_mode_setting !== null) { + $request_payload["hvac_mode_setting"] = $hvac_mode_setting; + } + if ($manual_override_allowed !== null) { + $request_payload[ + "manual_override_allowed" + ] = $manual_override_allowed; + } + if ($name !== null) { + $request_payload["name"] = $name; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/acs/systems/list_compatible_credential_manager_acs_systems", + "/thermostats/create_climate_preset", json: (object) $request_payload ); - - return array_map(fn($r) => AcsSystem::from_json($r), $res->acs_systems); - } -} - -class AcsUsersClient -{ - private SeamClient $seam; - - public function __construct(SeamClient $seam) - { - $this->seam = $seam; } - public function add_to_access_group( - string $acs_user_id, - string $acs_access_group_id + public function delete_climate_preset( + string $climate_preset_key, + string $device_id ): void { $request_payload = []; - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($climate_preset_key !== null) { + $request_payload["climate_preset_key"] = $climate_preset_key; } - if ($acs_access_group_id !== null) { - $request_payload["acs_access_group_id"] = $acs_access_group_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } $this->seam->request( "POST", - "/acs/users/add_to_access_group", + "/thermostats/delete_climate_preset", json: (object) $request_payload ); } - public function create( - string $full_name, - string $acs_system_id, - ?array $acs_access_group_ids = null, - ?string $user_identity_id = null, - mixed $access_schedule = null, - ?string $email = null, - ?string $phone_number = null, - ?string $email_address = null - ): AcsUser { + public function heat( + string $device_id, + ?float $heating_set_point_celsius = null, + ?float $heating_set_point_fahrenheit = null, + ?bool $sync = null, + bool $wait_for_action_attempt = true + ): ActionAttempt { $request_payload = []; - if ($full_name !== null) { - $request_payload["full_name"] = $full_name; - } - if ($acs_system_id !== null) { - $request_payload["acs_system_id"] = $acs_system_id; - } - if ($acs_access_group_ids !== null) { - $request_payload["acs_access_group_ids"] = $acs_access_group_ids; - } - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; - } - if ($access_schedule !== null) { - $request_payload["access_schedule"] = $access_schedule; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - if ($email !== null) { - $request_payload["email"] = $email; + if ($heating_set_point_celsius !== null) { + $request_payload[ + "heating_set_point_celsius" + ] = $heating_set_point_celsius; } - if ($phone_number !== null) { - $request_payload["phone_number"] = $phone_number; + if ($heating_set_point_fahrenheit !== null) { + $request_payload[ + "heating_set_point_fahrenheit" + ] = $heating_set_point_fahrenheit; } - if ($email_address !== null) { - $request_payload["email_address"] = $email_address; + if ($sync !== null) { + $request_payload["sync"] = $sync; } $res = $this->seam->request( "POST", - "/acs/users/create", + "/thermostats/heat", json: (object) $request_payload ); - return AcsUser::from_json($res->acs_user); - } - - public function delete(string $acs_user_id): void - { - $request_payload = []; - - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if (!$wait_for_action_attempt) { + return ActionAttempt::from_json($res->action_attempt); } - $this->seam->request( - "POST", - "/acs/users/delete", - json: (object) $request_payload + $action_attempt = $this->seam->action_attempts->poll_until_ready( + $res->action_attempt->action_attempt_id ); + + return $action_attempt; } - public function get(string $acs_user_id): AcsUser - { + public function heat_cool( + string $device_id, + ?float $cooling_set_point_celsius = null, + ?float $cooling_set_point_fahrenheit = null, + ?float $heating_set_point_celsius = null, + ?float $heating_set_point_fahrenheit = null, + ?bool $sync = null, + bool $wait_for_action_attempt = true + ): ActionAttempt { $request_payload = []; - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } + if ($cooling_set_point_celsius !== null) { + $request_payload[ + "cooling_set_point_celsius" + ] = $cooling_set_point_celsius; + } + if ($cooling_set_point_fahrenheit !== null) { + $request_payload[ + "cooling_set_point_fahrenheit" + ] = $cooling_set_point_fahrenheit; + } + if ($heating_set_point_celsius !== null) { + $request_payload[ + "heating_set_point_celsius" + ] = $heating_set_point_celsius; + } + if ($heating_set_point_fahrenheit !== null) { + $request_payload[ + "heating_set_point_fahrenheit" + ] = $heating_set_point_fahrenheit; + } + if ($sync !== null) { + $request_payload["sync"] = $sync; } $res = $this->seam->request( "POST", - "/acs/users/get", + "/thermostats/heat_cool", json: (object) $request_payload ); - return AcsUser::from_json($res->acs_user); + if (!$wait_for_action_attempt) { + return ActionAttempt::from_json($res->action_attempt); + } + + $action_attempt = $this->seam->action_attempts->poll_until_ready( + $res->action_attempt->action_attempt_id + ); + + return $action_attempt; } public function list( - ?string $user_identity_id = null, - ?string $user_identity_phone_number = null, - ?string $user_identity_email_address = null, - ?string $acs_system_id = null, - ?string $search = null, - mixed $limit = null, + ?string $connect_webview_id = null, + ?string $connected_account_id = null, + ?array $connected_account_ids = null, ?string $created_before = null, - ?string $page_cursor = null, + mixed $custom_metadata_has = null, + ?array $device_ids = null, + ?string $device_type = null, + ?array $device_types = null, + ?array $exclude_if = null, + ?array $include_if = null, + ?float $limit = null, + ?string $manufacturer = null, + ?string $unstable_location_id = null, + ?string $user_identifier_key = null, ?callable $on_response = null ): array { $request_payload = []; - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; + if ($connect_webview_id !== null) { + $request_payload["connect_webview_id"] = $connect_webview_id; } - if ($user_identity_phone_number !== null) { - $request_payload[ - "user_identity_phone_number" - ] = $user_identity_phone_number; + if ($connected_account_id !== null) { + $request_payload["connected_account_id"] = $connected_account_id; } - if ($user_identity_email_address !== null) { - $request_payload[ - "user_identity_email_address" - ] = $user_identity_email_address; + if ($connected_account_ids !== null) { + $request_payload["connected_account_ids"] = $connected_account_ids; } - if ($acs_system_id !== null) { - $request_payload["acs_system_id"] = $acs_system_id; + if ($created_before !== null) { + $request_payload["created_before"] = $created_before; } - if ($search !== null) { - $request_payload["search"] = $search; + if ($custom_metadata_has !== null) { + $request_payload["custom_metadata_has"] = $custom_metadata_has; + } + if ($device_ids !== null) { + $request_payload["device_ids"] = $device_ids; + } + if ($device_type !== null) { + $request_payload["device_type"] = $device_type; + } + if ($device_types !== null) { + $request_payload["device_types"] = $device_types; + } + if ($exclude_if !== null) { + $request_payload["exclude_if"] = $exclude_if; + } + if ($include_if !== null) { + $request_payload["include_if"] = $include_if; } if ($limit !== null) { $request_payload["limit"] = $limit; } - if ($created_before !== null) { - $request_payload["created_before"] = $created_before; + if ($manufacturer !== null) { + $request_payload["manufacturer"] = $manufacturer; } - if ($page_cursor !== null) { - $request_payload["page_cursor"] = $page_cursor; + if ($unstable_location_id !== null) { + $request_payload["unstable_location_id"] = $unstable_location_id; + } + if ($user_identifier_key !== null) { + $request_payload["user_identifier_key"] = $user_identifier_key; } $res = $this->seam->request( "POST", - "/acs/users/list", + "/thermostats/list", json: (object) $request_payload ); @@ -3882,136 +3830,254 @@ public function list( $on_response($res); } - return array_map(fn($r) => AcsUser::from_json($r), $res->acs_users); + return array_map(fn($r) => Device::from_json($r), $res->devices); } - public function list_accessible_entrances(string $acs_user_id): array - { + public function off( + string $device_id, + ?bool $sync = null, + bool $wait_for_action_attempt = true + ): ActionAttempt { $request_payload = []; - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } + if ($sync !== null) { + $request_payload["sync"] = $sync; } $res = $this->seam->request( "POST", - "/acs/users/list_accessible_entrances", + "/thermostats/off", json: (object) $request_payload ); - return array_map( - fn($r) => AcsEntrance::from_json($r), - $res->acs_entrances + if (!$wait_for_action_attempt) { + return ActionAttempt::from_json($res->action_attempt); + } + + $action_attempt = $this->seam->action_attempts->poll_until_ready( + $res->action_attempt->action_attempt_id ); + + return $action_attempt; } - public function remove_from_access_group( - string $acs_user_id, - string $acs_access_group_id + public function set_fallback_climate_preset( + string $climate_preset_key, + string $device_id ): void { $request_payload = []; - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($climate_preset_key !== null) { + $request_payload["climate_preset_key"] = $climate_preset_key; + } + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } + + $this->seam->request( + "POST", + "/thermostats/set_fallback_climate_preset", + json: (object) $request_payload + ); + } + + public function set_fan_mode( + string $device_id, + ?string $fan_mode = null, + ?string $fan_mode_setting = null, + ?bool $sync = null, + bool $wait_for_action_attempt = true + ): ActionAttempt { + $request_payload = []; + + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - if ($acs_access_group_id !== null) { - $request_payload["acs_access_group_id"] = $acs_access_group_id; + if ($fan_mode !== null) { + $request_payload["fan_mode"] = $fan_mode; + } + if ($fan_mode_setting !== null) { + $request_payload["fan_mode_setting"] = $fan_mode_setting; + } + if ($sync !== null) { + $request_payload["sync"] = $sync; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/acs/users/remove_from_access_group", + "/thermostats/set_fan_mode", json: (object) $request_payload ); - } - - public function revoke_access_to_all_entrances(string $acs_user_id): void - { - $request_payload = []; - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if (!$wait_for_action_attempt) { + return ActionAttempt::from_json($res->action_attempt); } - $this->seam->request( - "POST", - "/acs/users/revoke_access_to_all_entrances", - json: (object) $request_payload + $action_attempt = $this->seam->action_attempts->poll_until_ready( + $res->action_attempt->action_attempt_id ); + + return $action_attempt; } - public function suspend(string $acs_user_id): void - { + public function set_hvac_mode( + string $device_id, + string $hvac_mode_setting, + ?float $cooling_set_point_celsius = null, + ?float $cooling_set_point_fahrenheit = null, + ?float $heating_set_point_celsius = null, + ?float $heating_set_point_fahrenheit = null, + bool $wait_for_action_attempt = true + ): ActionAttempt { $request_payload = []; - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } + if ($hvac_mode_setting !== null) { + $request_payload["hvac_mode_setting"] = $hvac_mode_setting; + } + if ($cooling_set_point_celsius !== null) { + $request_payload[ + "cooling_set_point_celsius" + ] = $cooling_set_point_celsius; + } + if ($cooling_set_point_fahrenheit !== null) { + $request_payload[ + "cooling_set_point_fahrenheit" + ] = $cooling_set_point_fahrenheit; + } + if ($heating_set_point_celsius !== null) { + $request_payload[ + "heating_set_point_celsius" + ] = $heating_set_point_celsius; + } + if ($heating_set_point_fahrenheit !== null) { + $request_payload[ + "heating_set_point_fahrenheit" + ] = $heating_set_point_fahrenheit; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/acs/users/suspend", + "/thermostats/set_hvac_mode", json: (object) $request_payload ); + + if (!$wait_for_action_attempt) { + return ActionAttempt::from_json($res->action_attempt); + } + + $action_attempt = $this->seam->action_attempts->poll_until_ready( + $res->action_attempt->action_attempt_id + ); + + return $action_attempt; } - public function unsuspend(string $acs_user_id): void - { + public function set_temperature_threshold( + string $device_id, + ?float $lower_limit_celsius = null, + ?float $lower_limit_fahrenheit = null, + ?float $upper_limit_celsius = null, + ?float $upper_limit_fahrenheit = null + ): void { $request_payload = []; - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; + } + if ($lower_limit_celsius !== null) { + $request_payload["lower_limit_celsius"] = $lower_limit_celsius; + } + if ($lower_limit_fahrenheit !== null) { + $request_payload[ + "lower_limit_fahrenheit" + ] = $lower_limit_fahrenheit; + } + if ($upper_limit_celsius !== null) { + $request_payload["upper_limit_celsius"] = $upper_limit_celsius; + } + if ($upper_limit_fahrenheit !== null) { + $request_payload[ + "upper_limit_fahrenheit" + ] = $upper_limit_fahrenheit; } $this->seam->request( "POST", - "/acs/users/unsuspend", + "/thermostats/set_temperature_threshold", json: (object) $request_payload ); } - public function update( - string $acs_user_id, - mixed $access_schedule = null, - ?string $full_name = null, - ?string $email = null, - ?string $phone_number = null, - ?string $email_address = null, - ?string $hid_acs_system_id = null + public function update_climate_preset( + string $climate_preset_key, + string $device_id, + bool $manual_override_allowed, + ?float $cooling_set_point_celsius = null, + ?float $cooling_set_point_fahrenheit = null, + ?string $fan_mode_setting = null, + ?float $heating_set_point_celsius = null, + ?float $heating_set_point_fahrenheit = null, + ?string $hvac_mode_setting = null, + ?string $name = null ): void { $request_payload = []; - if ($acs_user_id !== null) { - $request_payload["acs_user_id"] = $acs_user_id; + if ($climate_preset_key !== null) { + $request_payload["climate_preset_key"] = $climate_preset_key; } - if ($access_schedule !== null) { - $request_payload["access_schedule"] = $access_schedule; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } - if ($full_name !== null) { - $request_payload["full_name"] = $full_name; + if ($manual_override_allowed !== null) { + $request_payload[ + "manual_override_allowed" + ] = $manual_override_allowed; } - if ($email !== null) { - $request_payload["email"] = $email; + if ($cooling_set_point_celsius !== null) { + $request_payload[ + "cooling_set_point_celsius" + ] = $cooling_set_point_celsius; } - if ($phone_number !== null) { - $request_payload["phone_number"] = $phone_number; + if ($cooling_set_point_fahrenheit !== null) { + $request_payload[ + "cooling_set_point_fahrenheit" + ] = $cooling_set_point_fahrenheit; } - if ($email_address !== null) { - $request_payload["email_address"] = $email_address; + if ($fan_mode_setting !== null) { + $request_payload["fan_mode_setting"] = $fan_mode_setting; } - if ($hid_acs_system_id !== null) { - $request_payload["hid_acs_system_id"] = $hid_acs_system_id; + if ($heating_set_point_celsius !== null) { + $request_payload[ + "heating_set_point_celsius" + ] = $heating_set_point_celsius; + } + if ($heating_set_point_fahrenheit !== null) { + $request_payload[ + "heating_set_point_fahrenheit" + ] = $heating_set_point_fahrenheit; + } + if ($hvac_mode_setting !== null) { + $request_payload["hvac_mode_setting"] = $hvac_mode_setting; + } + if ($name !== null) { + $request_payload["name"] = $name; } $this->seam->request( "POST", - "/acs/users/update", + "/thermostats/update_climate_preset", json: (object) $request_payload ); } } -class DevicesSimulateClient +class ThermostatsSchedulesClient { private SeamClient $seam; @@ -4020,148 +4086,103 @@ public function __construct(SeamClient $seam) $this->seam = $seam; } - public function connect(string $device_id): void - { + public function create( + string $climate_preset_key, + string $device_id, + string $ends_at, + string $starts_at, + ?bool $is_override_allowed = null, + mixed $max_override_period_minutes = null, + ?string $name = null + ): ThermostatSchedule { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($climate_preset_key !== null) { + $request_payload["climate_preset_key"] = $climate_preset_key; } - - $this->seam->request( - "POST", - "/devices/simulate/connect", - json: (object) $request_payload - ); - } - - public function disconnect(string $device_id): void - { - $request_payload = []; - if ($device_id !== null) { $request_payload["device_id"] = $device_id; } + if ($ends_at !== null) { + $request_payload["ends_at"] = $ends_at; + } + if ($starts_at !== null) { + $request_payload["starts_at"] = $starts_at; + } + if ($is_override_allowed !== null) { + $request_payload["is_override_allowed"] = $is_override_allowed; + } + if ($max_override_period_minutes !== null) { + $request_payload[ + "max_override_period_minutes" + ] = $max_override_period_minutes; + } + if ($name !== null) { + $request_payload["name"] = $name; + } - $this->seam->request( + $res = $this->seam->request( "POST", - "/devices/simulate/disconnect", + "/thermostats/schedules/create", json: (object) $request_payload ); + + return ThermostatSchedule::from_json($res->thermostat_schedule); } - public function remove(string $device_id): void + public function delete(string $thermostat_schedule_id): void { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($thermostat_schedule_id !== null) { + $request_payload[ + "thermostat_schedule_id" + ] = $thermostat_schedule_id; } $this->seam->request( "POST", - "/devices/simulate/remove", - json: (object) $request_payload - ); - } -} - -class DevicesUnmanagedClient -{ - private SeamClient $seam; - - public function __construct(SeamClient $seam) - { - $this->seam = $seam; + "/thermostats/schedules/delete", + json: (object) $request_payload + ); } - public function get( - ?string $device_id = null, - ?string $name = null - ): UnmanagedDevice { + public function get(string $thermostat_schedule_id): ThermostatSchedule + { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($name !== null) { - $request_payload["name"] = $name; + if ($thermostat_schedule_id !== null) { + $request_payload[ + "thermostat_schedule_id" + ] = $thermostat_schedule_id; } $res = $this->seam->request( "POST", - "/devices/unmanaged/get", + "/thermostats/schedules/get", json: (object) $request_payload ); - return UnmanagedDevice::from_json($res->device); + return ThermostatSchedule::from_json($res->thermostat_schedule); } public function list( - ?string $connected_account_id = null, - ?array $connected_account_ids = null, - ?string $connect_webview_id = null, - ?string $device_type = null, - ?array $device_types = null, - ?string $manufacturer = null, - ?array $device_ids = null, - ?float $limit = null, - ?string $created_before = null, + string $device_id, ?string $user_identifier_key = null, - mixed $custom_metadata_has = null, - ?array $include_if = null, - ?array $exclude_if = null, - ?string $unstable_location_id = null, ?callable $on_response = null ): array { $request_payload = []; - if ($connected_account_id !== null) { - $request_payload["connected_account_id"] = $connected_account_id; - } - if ($connected_account_ids !== null) { - $request_payload["connected_account_ids"] = $connected_account_ids; - } - if ($connect_webview_id !== null) { - $request_payload["connect_webview_id"] = $connect_webview_id; - } - if ($device_type !== null) { - $request_payload["device_type"] = $device_type; - } - if ($device_types !== null) { - $request_payload["device_types"] = $device_types; - } - if ($manufacturer !== null) { - $request_payload["manufacturer"] = $manufacturer; - } - if ($device_ids !== null) { - $request_payload["device_ids"] = $device_ids; - } - if ($limit !== null) { - $request_payload["limit"] = $limit; - } - if ($created_before !== null) { - $request_payload["created_before"] = $created_before; + if ($device_id !== null) { + $request_payload["device_id"] = $device_id; } if ($user_identifier_key !== null) { $request_payload["user_identifier_key"] = $user_identifier_key; } - if ($custom_metadata_has !== null) { - $request_payload["custom_metadata_has"] = $custom_metadata_has; - } - if ($include_if !== null) { - $request_payload["include_if"] = $include_if; - } - if ($exclude_if !== null) { - $request_payload["exclude_if"] = $exclude_if; - } - if ($unstable_location_id !== null) { - $request_payload["unstable_location_id"] = $unstable_location_id; - } $res = $this->seam->request( "POST", - "/devices/unmanaged/list", + "/thermostats/schedules/list", json: (object) $request_payload ); @@ -4170,31 +4191,57 @@ public function list( } return array_map( - fn($r) => UnmanagedDevice::from_json($r), - $res->devices + fn($r) => ThermostatSchedule::from_json($r), + $res->thermostat_schedules ); } - public function update(string $device_id, bool $is_managed): void - { + public function update( + string $thermostat_schedule_id, + ?string $climate_preset_key = null, + ?string $ends_at = null, + ?bool $is_override_allowed = null, + mixed $max_override_period_minutes = null, + ?string $name = null, + ?string $starts_at = null + ): void { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($thermostat_schedule_id !== null) { + $request_payload[ + "thermostat_schedule_id" + ] = $thermostat_schedule_id; } - if ($is_managed !== null) { - $request_payload["is_managed"] = $is_managed; + if ($climate_preset_key !== null) { + $request_payload["climate_preset_key"] = $climate_preset_key; + } + if ($ends_at !== null) { + $request_payload["ends_at"] = $ends_at; + } + if ($is_override_allowed !== null) { + $request_payload["is_override_allowed"] = $is_override_allowed; + } + if ($max_override_period_minutes !== null) { + $request_payload[ + "max_override_period_minutes" + ] = $max_override_period_minutes; + } + if ($name !== null) { + $request_payload["name"] = $name; + } + if ($starts_at !== null) { + $request_payload["starts_at"] = $starts_at; } $this->seam->request( "POST", - "/devices/unmanaged/update", + "/thermostats/schedules/update", json: (object) $request_payload ); } } -class NoiseSensorsNoiseThresholdsClient +class ThermostatsSimulateClient { private SeamClient $seam; @@ -4203,474 +4250,343 @@ public function __construct(SeamClient $seam) $this->seam = $seam; } - public function create( + public function hvac_mode_adjusted( string $device_id, - string $starts_daily_at, - string $ends_daily_at, - ?bool $sync = null, - ?string $name = null, - ?float $noise_threshold_decibels = null, - ?float $noise_threshold_nrs = null - ): NoiseThreshold { + string $hvac_mode, + ?float $cooling_set_point_celsius = null, + ?float $cooling_set_point_fahrenheit = null, + ?float $heating_set_point_celsius = null, + ?float $heating_set_point_fahrenheit = null + ): void { $request_payload = []; if ($device_id !== null) { $request_payload["device_id"] = $device_id; } - if ($starts_daily_at !== null) { - $request_payload["starts_daily_at"] = $starts_daily_at; - } - if ($ends_daily_at !== null) { - $request_payload["ends_daily_at"] = $ends_daily_at; + if ($hvac_mode !== null) { + $request_payload["hvac_mode"] = $hvac_mode; } - if ($sync !== null) { - $request_payload["sync"] = $sync; + if ($cooling_set_point_celsius !== null) { + $request_payload[ + "cooling_set_point_celsius" + ] = $cooling_set_point_celsius; } - if ($name !== null) { - $request_payload["name"] = $name; + if ($cooling_set_point_fahrenheit !== null) { + $request_payload[ + "cooling_set_point_fahrenheit" + ] = $cooling_set_point_fahrenheit; } - if ($noise_threshold_decibels !== null) { + if ($heating_set_point_celsius !== null) { $request_payload[ - "noise_threshold_decibels" - ] = $noise_threshold_decibels; + "heating_set_point_celsius" + ] = $heating_set_point_celsius; } - if ($noise_threshold_nrs !== null) { - $request_payload["noise_threshold_nrs"] = $noise_threshold_nrs; + if ($heating_set_point_fahrenheit !== null) { + $request_payload[ + "heating_set_point_fahrenheit" + ] = $heating_set_point_fahrenheit; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/noise_sensors/noise_thresholds/create", + "/thermostats/simulate/hvac_mode_adjusted", json: (object) $request_payload ); - - return NoiseThreshold::from_json($res->noise_threshold); } - public function delete( - string $noise_threshold_id, + public function temperature_reached( string $device_id, - ?bool $sync = null + ?float $temperature_celsius = null, + ?float $temperature_fahrenheit = null ): void { $request_payload = []; - if ($noise_threshold_id !== null) { - $request_payload["noise_threshold_id"] = $noise_threshold_id; - } if ($device_id !== null) { $request_payload["device_id"] = $device_id; } - if ($sync !== null) { - $request_payload["sync"] = $sync; + if ($temperature_celsius !== null) { + $request_payload["temperature_celsius"] = $temperature_celsius; + } + if ($temperature_fahrenheit !== null) { + $request_payload[ + "temperature_fahrenheit" + ] = $temperature_fahrenheit; } $this->seam->request( "POST", - "/noise_sensors/noise_thresholds/delete", + "/thermostats/simulate/temperature_reached", json: (object) $request_payload ); } +} - public function get(string $noise_threshold_id): NoiseThreshold +class UserIdentitiesClient +{ + private SeamClient $seam; + public UserIdentitiesEnrollmentAutomationsClient $enrollment_automations; + public function __construct(SeamClient $seam) { - $request_payload = []; - - if ($noise_threshold_id !== null) { - $request_payload["noise_threshold_id"] = $noise_threshold_id; - } - - $res = $this->seam->request( - "POST", - "/noise_sensors/noise_thresholds/get", - json: (object) $request_payload + $this->seam = $seam; + $this->enrollment_automations = new UserIdentitiesEnrollmentAutomationsClient( + $seam ); - - return NoiseThreshold::from_json($res->noise_threshold); } - public function list( - string $device_id, - ?bool $is_programmed = null, - ?callable $on_response = null - ): array { + public function add_acs_user( + string $acs_user_id, + string $user_identity_id + ): void { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } - if ($is_programmed !== null) { - $request_payload["is_programmed"] = $is_programmed; + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; } - $res = $this->seam->request( + $this->seam->request( "POST", - "/noise_sensors/noise_thresholds/list", + "/user_identities/add_acs_user", json: (object) $request_payload ); - - if ($on_response !== null) { - $on_response($res); - } - - return array_map( - fn($r) => NoiseThreshold::from_json($r), - $res->noise_thresholds - ); } - public function update( - string $noise_threshold_id, - string $device_id, - ?bool $sync = null, - ?string $name = null, - ?string $starts_daily_at = null, - ?string $ends_daily_at = null, - ?float $noise_threshold_decibels = null, - ?float $noise_threshold_nrs = null - ): void { + public function create( + ?string $email_address = null, + ?string $full_name = null, + ?string $phone_number = null, + ?string $user_identity_key = null + ): UserIdentity { $request_payload = []; - if ($noise_threshold_id !== null) { - $request_payload["noise_threshold_id"] = $noise_threshold_id; - } - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($sync !== null) { - $request_payload["sync"] = $sync; - } - if ($name !== null) { - $request_payload["name"] = $name; - } - if ($starts_daily_at !== null) { - $request_payload["starts_daily_at"] = $starts_daily_at; + if ($email_address !== null) { + $request_payload["email_address"] = $email_address; } - if ($ends_daily_at !== null) { - $request_payload["ends_daily_at"] = $ends_daily_at; + if ($full_name !== null) { + $request_payload["full_name"] = $full_name; } - if ($noise_threshold_decibels !== null) { - $request_payload[ - "noise_threshold_decibels" - ] = $noise_threshold_decibels; + if ($phone_number !== null) { + $request_payload["phone_number"] = $phone_number; } - if ($noise_threshold_nrs !== null) { - $request_payload["noise_threshold_nrs"] = $noise_threshold_nrs; + if ($user_identity_key !== null) { + $request_payload["user_identity_key"] = $user_identity_key; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/noise_sensors/noise_thresholds/update", + "/user_identities/create", json: (object) $request_payload ); - } -} - -class NoiseSensorsSimulateClient -{ - private SeamClient $seam; - public function __construct(SeamClient $seam) - { - $this->seam = $seam; + return UserIdentity::from_json($res->user_identity); } - public function trigger_noise_threshold(string $device_id): void + public function delete(string $user_identity_id): void { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; } $this->seam->request( "POST", - "/noise_sensors/simulate/trigger_noise_threshold", + "/user_identities/delete", json: (object) $request_payload ); } -} - -class PhonesSimulateClient -{ - private SeamClient $seam; - - public function __construct(SeamClient $seam) - { - $this->seam = $seam; - } - public function create_sandbox_phone( - string $user_identity_id, - ?string $custom_sdk_installation_id = null, - mixed $phone_metadata = null, - mixed $assa_abloy_metadata = null - ): Phone { + public function get( + ?string $user_identity_id = null, + ?string $user_identity_key = null + ): UserIdentity { $request_payload = []; if ($user_identity_id !== null) { $request_payload["user_identity_id"] = $user_identity_id; } - if ($custom_sdk_installation_id !== null) { - $request_payload[ - "custom_sdk_installation_id" - ] = $custom_sdk_installation_id; - } - if ($phone_metadata !== null) { - $request_payload["phone_metadata"] = $phone_metadata; - } - if ($assa_abloy_metadata !== null) { - $request_payload["assa_abloy_metadata"] = $assa_abloy_metadata; + if ($user_identity_key !== null) { + $request_payload["user_identity_key"] = $user_identity_key; } $res = $this->seam->request( "POST", - "/phones/simulate/create_sandbox_phone", + "/user_identities/get", json: (object) $request_payload ); - return Phone::from_json($res->phone); - } -} - -class ThermostatsSchedulesClient -{ - private SeamClient $seam; - - public function __construct(SeamClient $seam) - { - $this->seam = $seam; + return UserIdentity::from_json($res->user_identity); } - public function create( + public function grant_access_to_device( string $device_id, - string $climate_preset_key, - string $starts_at, - string $ends_at, - ?string $name = null, - mixed $max_override_period_minutes = null, - ?bool $is_override_allowed = null - ): ThermostatSchedule { + string $user_identity_id + ): void { $request_payload = []; if ($device_id !== null) { $request_payload["device_id"] = $device_id; } - if ($climate_preset_key !== null) { - $request_payload["climate_preset_key"] = $climate_preset_key; - } - if ($starts_at !== null) { - $request_payload["starts_at"] = $starts_at; - } - if ($ends_at !== null) { - $request_payload["ends_at"] = $ends_at; - } - if ($name !== null) { - $request_payload["name"] = $name; + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; } - if ($max_override_period_minutes !== null) { + + $this->seam->request( + "POST", + "/user_identities/grant_access_to_device", + json: (object) $request_payload + ); + } + + public function list( + ?string $credential_manager_acs_system_id = null, + ?callable $on_response = null + ): array { + $request_payload = []; + + if ($credential_manager_acs_system_id !== null) { $request_payload[ - "max_override_period_minutes" - ] = $max_override_period_minutes; - } - if ($is_override_allowed !== null) { - $request_payload["is_override_allowed"] = $is_override_allowed; + "credential_manager_acs_system_id" + ] = $credential_manager_acs_system_id; } $res = $this->seam->request( "POST", - "/thermostats/schedules/create", + "/user_identities/list", json: (object) $request_payload ); - return ThermostatSchedule::from_json($res->thermostat_schedule); + if ($on_response !== null) { + $on_response($res); + } + + return array_map( + fn($r) => UserIdentity::from_json($r), + $res->user_identities + ); } - public function delete(string $thermostat_schedule_id): void + public function list_accessible_devices(string $user_identity_id): array { $request_payload = []; - if ($thermostat_schedule_id !== null) { - $request_payload[ - "thermostat_schedule_id" - ] = $thermostat_schedule_id; + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/thermostats/schedules/delete", + "/user_identities/list_accessible_devices", json: (object) $request_payload ); + + return array_map(fn($r) => Device::from_json($r), $res->devices); } - public function get(string $thermostat_schedule_id): ThermostatSchedule + public function list_acs_systems(string $user_identity_id): array { $request_payload = []; - if ($thermostat_schedule_id !== null) { - $request_payload[ - "thermostat_schedule_id" - ] = $thermostat_schedule_id; + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; } $res = $this->seam->request( "POST", - "/thermostats/schedules/get", + "/user_identities/list_acs_systems", json: (object) $request_payload ); - return ThermostatSchedule::from_json($res->thermostat_schedule); + return array_map(fn($r) => AcsSystem::from_json($r), $res->acs_systems); } - public function list( - string $device_id, - ?string $user_identifier_key = null, - ?callable $on_response = null - ): array { + public function list_acs_users(string $user_identity_id): array + { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; - } - if ($user_identifier_key !== null) { - $request_payload["user_identifier_key"] = $user_identifier_key; + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; } $res = $this->seam->request( "POST", - "/thermostats/schedules/list", + "/user_identities/list_acs_users", json: (object) $request_payload ); - if ($on_response !== null) { - $on_response($res); - } - - return array_map( - fn($r) => ThermostatSchedule::from_json($r), - $res->thermostat_schedules - ); + return array_map(fn($r) => AcsUser::from_json($r), $res->acs_users); } - public function update( - string $thermostat_schedule_id, - ?string $name = null, - ?string $climate_preset_key = null, - mixed $max_override_period_minutes = null, - ?string $starts_at = null, - ?string $ends_at = null, - ?bool $is_override_allowed = null + public function remove_acs_user( + string $acs_user_id, + string $user_identity_id ): void { $request_payload = []; - if ($thermostat_schedule_id !== null) { - $request_payload[ - "thermostat_schedule_id" - ] = $thermostat_schedule_id; - } - if ($name !== null) { - $request_payload["name"] = $name; - } - if ($climate_preset_key !== null) { - $request_payload["climate_preset_key"] = $climate_preset_key; - } - if ($max_override_period_minutes !== null) { - $request_payload[ - "max_override_period_minutes" - ] = $max_override_period_minutes; - } - if ($starts_at !== null) { - $request_payload["starts_at"] = $starts_at; - } - if ($ends_at !== null) { - $request_payload["ends_at"] = $ends_at; + if ($acs_user_id !== null) { + $request_payload["acs_user_id"] = $acs_user_id; } - if ($is_override_allowed !== null) { - $request_payload["is_override_allowed"] = $is_override_allowed; + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; } $this->seam->request( "POST", - "/thermostats/schedules/update", + "/user_identities/remove_acs_user", json: (object) $request_payload ); } -} - -class ThermostatsSimulateClient -{ - private SeamClient $seam; - - public function __construct(SeamClient $seam) - { - $this->seam = $seam; - } - public function hvac_mode_adjusted( - string $hvac_mode, + public function revoke_access_to_device( string $device_id, - ?float $cooling_set_point_celsius = null, - ?float $cooling_set_point_fahrenheit = null, - ?float $heating_set_point_celsius = null, - ?float $heating_set_point_fahrenheit = null + string $user_identity_id ): void { $request_payload = []; - if ($hvac_mode !== null) { - $request_payload["hvac_mode"] = $hvac_mode; - } if ($device_id !== null) { $request_payload["device_id"] = $device_id; } - if ($cooling_set_point_celsius !== null) { - $request_payload[ - "cooling_set_point_celsius" - ] = $cooling_set_point_celsius; - } - if ($cooling_set_point_fahrenheit !== null) { - $request_payload[ - "cooling_set_point_fahrenheit" - ] = $cooling_set_point_fahrenheit; - } - if ($heating_set_point_celsius !== null) { - $request_payload[ - "heating_set_point_celsius" - ] = $heating_set_point_celsius; - } - if ($heating_set_point_fahrenheit !== null) { - $request_payload[ - "heating_set_point_fahrenheit" - ] = $heating_set_point_fahrenheit; + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; } $this->seam->request( "POST", - "/thermostats/simulate/hvac_mode_adjusted", + "/user_identities/revoke_access_to_device", json: (object) $request_payload ); } - public function temperature_reached( - string $device_id, - ?float $temperature_celsius = null, - ?float $temperature_fahrenheit = null + public function update( + string $user_identity_id, + ?string $email_address = null, + ?string $full_name = null, + ?string $phone_number = null, + ?string $user_identity_key = null ): void { $request_payload = []; - if ($device_id !== null) { - $request_payload["device_id"] = $device_id; + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; } - if ($temperature_celsius !== null) { - $request_payload["temperature_celsius"] = $temperature_celsius; + if ($email_address !== null) { + $request_payload["email_address"] = $email_address; } - if ($temperature_fahrenheit !== null) { - $request_payload[ - "temperature_fahrenheit" - ] = $temperature_fahrenheit; + if ($full_name !== null) { + $request_payload["full_name"] = $full_name; + } + if ($phone_number !== null) { + $request_payload["phone_number"] = $phone_number; + } + if ($user_identity_key !== null) { + $request_payload["user_identity_key"] = $user_identity_key; } $this->seam->request( "POST", - "/thermostats/simulate/temperature_reached", + "/user_identities/update", json: (object) $request_payload ); } @@ -4722,22 +4638,22 @@ public function get(string $enrollment_automation_id): EnrollmentAutomation } public function launch( - string $user_identity_id, string $credential_manager_acs_system_id, + string $user_identity_id, ?string $acs_credential_pool_id = null, ?bool $create_credential_manager_user = null, ?string $credential_manager_acs_user_id = null ): void { $request_payload = []; - if ($user_identity_id !== null) { - $request_payload["user_identity_id"] = $user_identity_id; - } if ($credential_manager_acs_system_id !== null) { $request_payload[ "credential_manager_acs_system_id" ] = $credential_manager_acs_system_id; } + if ($user_identity_id !== null) { + $request_payload["user_identity_id"] = $user_identity_id; + } if ($acs_credential_pool_id !== null) { $request_payload[ "acs_credential_pool_id" @@ -4788,7 +4704,7 @@ public function list( } } -class AcsEncodersSimulateClient +class WebhooksClient { private SeamClient $seam; @@ -4797,99 +4713,180 @@ public function __construct(SeamClient $seam) $this->seam = $seam; } - public function next_credential_encode_will_fail( - string $acs_encoder_id, - ?string $error_code = null, - ?string $acs_credential_id = null - ): void { + public function create(string $url, ?array $event_types = null): Webhook + { $request_payload = []; - if ($acs_encoder_id !== null) { - $request_payload["acs_encoder_id"] = $acs_encoder_id; - } - if ($error_code !== null) { - $request_payload["error_code"] = $error_code; + if ($url !== null) { + $request_payload["url"] = $url; } - if ($acs_credential_id !== null) { - $request_payload["acs_credential_id"] = $acs_credential_id; + if ($event_types !== null) { + $request_payload["event_types"] = $event_types; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/acs/encoders/simulate/next_credential_encode_will_fail", + "/webhooks/create", json: (object) $request_payload ); + + return Webhook::from_json($res->webhook); } - public function next_credential_encode_will_succeed( - string $acs_encoder_id, - ?string $scenario = null - ): void { + public function delete(string $webhook_id): void + { $request_payload = []; - if ($acs_encoder_id !== null) { - $request_payload["acs_encoder_id"] = $acs_encoder_id; - } - if ($scenario !== null) { - $request_payload["scenario"] = $scenario; + if ($webhook_id !== null) { + $request_payload["webhook_id"] = $webhook_id; } $this->seam->request( "POST", - "/acs/encoders/simulate/next_credential_encode_will_succeed", + "/webhooks/delete", json: (object) $request_payload ); } - public function next_credential_scan_will_fail( - string $acs_encoder_id, - ?string $error_code = null, - ?string $acs_credential_id_on_seam = null - ): void { + public function get(string $webhook_id): Webhook + { $request_payload = []; - if ($acs_encoder_id !== null) { - $request_payload["acs_encoder_id"] = $acs_encoder_id; + if ($webhook_id !== null) { + $request_payload["webhook_id"] = $webhook_id; } - if ($error_code !== null) { - $request_payload["error_code"] = $error_code; + + $res = $this->seam->request( + "POST", + "/webhooks/get", + json: (object) $request_payload + ); + + return Webhook::from_json($res->webhook); + } + + public function list(?callable $on_response = null): array + { + $res = $this->seam->request("POST", "/webhooks/list"); + + if ($on_response !== null) { + $on_response($res); } - if ($acs_credential_id_on_seam !== null) { - $request_payload[ - "acs_credential_id_on_seam" - ] = $acs_credential_id_on_seam; + + return array_map(fn($r) => Webhook::from_json($r), $res->webhooks); + } + + public function update(array $event_types, string $webhook_id): void + { + $request_payload = []; + + if ($event_types !== null) { + $request_payload["event_types"] = $event_types; + } + if ($webhook_id !== null) { + $request_payload["webhook_id"] = $webhook_id; } $this->seam->request( "POST", - "/acs/encoders/simulate/next_credential_scan_will_fail", + "/webhooks/update", json: (object) $request_payload ); } +} + +class WorkspacesClient +{ + private SeamClient $seam; + + public function __construct(SeamClient $seam) + { + $this->seam = $seam; + } - public function next_credential_scan_will_succeed( - string $acs_encoder_id, - ?string $scenario = null, - ?string $acs_credential_id_on_seam = null - ): void { + public function create( + string $name, + ?string $company_name = null, + ?string $connect_partner_name = null, + ?bool $is_sandbox = null, + ?string $webview_logo_shape = null, + ?string $webview_primary_button_color = null, + ?string $webview_primary_button_text_color = null, + ?string $webview_success_message = null + ): Workspace { $request_payload = []; - if ($acs_encoder_id !== null) { - $request_payload["acs_encoder_id"] = $acs_encoder_id; + if ($name !== null) { + $request_payload["name"] = $name; } - if ($scenario !== null) { - $request_payload["scenario"] = $scenario; + if ($company_name !== null) { + $request_payload["company_name"] = $company_name; } - if ($acs_credential_id_on_seam !== null) { + if ($connect_partner_name !== null) { + $request_payload["connect_partner_name"] = $connect_partner_name; + } + if ($is_sandbox !== null) { + $request_payload["is_sandbox"] = $is_sandbox; + } + if ($webview_logo_shape !== null) { + $request_payload["webview_logo_shape"] = $webview_logo_shape; + } + if ($webview_primary_button_color !== null) { $request_payload[ - "acs_credential_id_on_seam" - ] = $acs_credential_id_on_seam; + "webview_primary_button_color" + ] = $webview_primary_button_color; + } + if ($webview_primary_button_text_color !== null) { + $request_payload[ + "webview_primary_button_text_color" + ] = $webview_primary_button_text_color; + } + if ($webview_success_message !== null) { + $request_payload[ + "webview_success_message" + ] = $webview_success_message; } - $this->seam->request( + $res = $this->seam->request( "POST", - "/acs/encoders/simulate/next_credential_scan_will_succeed", + "/workspaces/create", json: (object) $request_payload ); + + return Workspace::from_json($res->workspace); + } + + public function get(): Workspace + { + $res = $this->seam->request("POST", "/workspaces/get"); + + return Workspace::from_json($res->workspace); + } + + public function list(?callable $on_response = null): array + { + $res = $this->seam->request("POST", "/workspaces/list"); + + if ($on_response !== null) { + $on_response($res); + } + + return array_map(fn($r) => Workspace::from_json($r), $res->workspaces); + } + + public function reset_sandbox( + bool $wait_for_action_attempt = true + ): ActionAttempt { + $res = $this->seam->request("POST", "/workspaces/reset_sandbox"); + + if (!$wait_for_action_attempt) { + return ActionAttempt::from_json($res->action_attempt); + } + + $action_attempt = $this->seam->action_attempts->poll_until_ready( + $res->action_attempt->action_attempt_id + ); + + return $action_attempt; } } From c1fe18bb572b4cda1b08d39f17754595d4388581 Mon Sep 17 00:00:00 2001 From: Andrii Balitskyi <10balian10@gmail.com> Date: Wed, 9 Apr 2025 15:47:33 +0200 Subject: [PATCH 4/6] Use connected_accounts->list in paginator test --- tests/PaginatorTest.php | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/tests/PaginatorTest.php b/tests/PaginatorTest.php index 1ab4c7cb..7866deba 100644 --- a/tests/PaginatorTest.php +++ b/tests/PaginatorTest.php @@ -13,12 +13,12 @@ public function testPaginatorFirstPage(): void $seam = Fixture::getTestServer(); $pages = $seam->createPaginator( - fn($params) => $seam->devices->list(...$params), + fn($params) => $seam->connected_accounts->list(...$params), ["limit" => 2] ); - [$devices, $pagination] = $pages->firstPage(); + [$connectedAccounts, $pagination] = $pages->firstPage(); - $this->assertTrue(count($devices) == 2); + $this->assertTrue(count($connectedAccounts) == 2); $this->assertTrue($pagination->has_next_page); $this->assertTrue($pagination->next_page_cursor !== null); $this->assertTrue($pagination->next_page_url !== null); @@ -29,50 +29,54 @@ public function testPaginatorNextPage(): void $seam = Fixture::getTestServer(); $pages = $seam->createPaginator( - fn($params) => $seam->devices->list(...$params), + fn($params) => $seam->connected_accounts->list(...$params), ["limit" => 2] ); - [$devices, $pagination] = $pages->firstPage(); + [$connectedAccounts, $pagination] = $pages->firstPage(); - $this->assertTrue(count($devices) == 2); + $this->assertTrue(count($connectedAccounts) == 2); $this->assertTrue($pagination->has_next_page); - [$moreDevices] = $pages->nextPage($pagination->next_page_cursor); + [$moreConnectedAccounts] = $pages->nextPage( + $pagination->next_page_cursor + ); - $this->assertTrue(count($moreDevices) == 2); + $this->assertTrue(count($moreConnectedAccounts) == 1); } public function testPaginatorFlattenToArray(): void { $seam = Fixture::getTestServer(); - $allDevices = $seam->devices->list(); + $allConnectedAccounts = $seam->connected_accounts->list(); $pages = $seam->createPaginator( - fn($params) => $seam->devices->list(...$params), + fn($params) => $seam->connected_accounts->list(...$params), ["limit" => 1] ); $devices = $pages->flattenToArray(); $this->assertTrue(count($devices) > 1); - $this->assertTrue(count($devices) == count($allDevices)); + $this->assertTrue(count($devices) == count($allConnectedAccounts)); } public function testPaginatorFlatten(): void { $seam = Fixture::getTestServer(); - $allDevices = $seam->devices->list(); + $allConnectedAccounts = $seam->connected_accounts->list(); $pages = $seam->createPaginator( - fn($params) => $seam->devices->list(...$params), + fn($params) => $seam->connected_accounts->list(...$params), ["limit" => 1] ); - $devices = []; - foreach ($pages->flatten() as $device) { - $devices[] = $device; + $connectedAccounts = []; + foreach ($pages->flatten() as $connectedAccount) { + $connectedAccounts[] = $connectedAccount; } - $this->assertTrue(count($devices) > 1); - $this->assertTrue(count($devices) == count($allDevices)); + $this->assertTrue(count($connectedAccounts) > 1); + $this->assertTrue( + count($connectedAccounts) == count($allConnectedAccounts) + ); } } From 9346a0cd7fa57669e6b4f9c8dc4a9a54550f8be7 Mon Sep 17 00:00:00 2001 From: Andrii Balitskyi <10balian10@gmail.com> Date: Wed, 9 Apr 2025 16:48:35 +0200 Subject: [PATCH 5/6] Update readme --- README.md | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 87 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dd85a49f..73120579 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,92 @@ $access_code->status; // 'setting' (it will go to 'set' when active on the devic $seam->access_codes->delete($access_code->access_code_id); ``` +### Pagination + +Some Seam API endpoints that return lists of resources support pagination. +Use the `Paginator` class to fetch and process resources across multiple pages. + +#### Manually fetch pages with the next_page_cursor + +```php +$pages = $seam->createPaginator( + fn($params) => $seam->connected_accounts->list(...$params), + ["limit" => 2] +); + +[$connectedAccounts, $pagination] = $pages->firstPage(); + +if ($pagination->has_next_page) { + [$moreConnectedAccounts] = $pages->nextPage( + $pagination->next_page_cursor + ); +} +``` + +#### Resume pagination + +Get the first page on initial load: + +```php +$params = ["limit" => 20]; + +$pages = $seam->createPaginator( + fn($p) => $seam->connected_accounts->list(...$p), + $params +); + +[$connectedAccounts, $pagination] = $pages->firstPage(); + +// Store pagination state for later use +file_put_contents( + '/tmp/seam_connected_accounts_list.json', + json_encode([$params, $pagination]) +); +``` + +Get the next page at a later time: + +```php +$stored_data = json_decode( + file_get_contents('/tmp/seam_connected_accounts_list.json') ?: '[]', + false +); + +$params = $stored_data[0] ?? []; +$pagination = $stored_data[1] ?? (object)['has_next_page' => false, 'next_page_cursor' => null]; + +if ($pagination->has_next_page) { + $pages = $seam->createPaginator( + fn($p) => $seam->connected_accounts->list(...$p), + $params + ); + [$moreConnectedAccounts] = $pages->nextPage($pagination->next_page_cursor); +} +``` +#### Iterate over all resources + +```php +$pages = $seam->createPaginator( + fn($p) => $seam->connected_accounts->list(...$p), + ["limit" => 20] +); + +foreach ($pages->flatten() as $connectedAccount) { + print $connectedAccount->account_type_display_name . "\n"; +} +``` + +#### Return all resources across all pages as an array + +```php +$pages = $seam->createPaginator( + fn($p) => $seam->connected_accounts->list(...$p), + ["limit" => 20] +); + +$connectedAccounts = $pages->flattenToArray(); +``` + ## Installation To install the latest version of the automatically generated SDK, run: @@ -87,4 +173,4 @@ If you want to install our previous handwritten version, run: ### Running Tests -You'll need to export `SEAM_API_KEY` to a sandbox workspace API key. +You'll need to export `SEAM_API_KEY` to a sandbox workspace API key. \ No newline at end of file From e9ab66c20f623dc5680a216fa5ab214d4b3738e5 Mon Sep 17 00:00:00 2001 From: Andrii Balitskyi <10balian10@gmail.com> Date: Thu, 10 Apr 2025 11:37:22 +0200 Subject: [PATCH 6/6] Format code samples in readme --- README.md | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 73120579..2ca38f9f 100644 --- a/README.md +++ b/README.md @@ -11,32 +11,32 @@ $seam = new Seam\SeamClient("YOUR_API_KEY"); # Create a Connect Webview to login to a provider $connect_webview = $seam->connect_webviews->create( - accepted_providers: ["august"] + accepted_providers: ["august"] ); print "Please Login at this url: " . $connect_webview->url; # Poll until connect webview is completed while (true) { - $connect_webview = $seam->connect_webviews->get( - $connect_webview->connect_webview_id - ); - if ($connect_webview->status == "authorized") { - break; - } else { - sleep(1); - } + $connect_webview = $seam->connect_webviews->get( + $connect_webview->connect_webview_id + ); + if ($connect_webview->status == "authorized") { + break; + } else { + sleep(1); + } } $connected_account = $seam->connected_accounts->get( - $connect_webview->connected_account_id + $connect_webview->connected_account_id ); print "Looks like you connected with " . - json_encode($connected_account->user_identifier); + json_encode($connected_account->user_identifier); $devices = $seam->devices->list( - connected_account_id: $connected_account->connected_account_id + connected_account_id: $connected_account->connected_account_id ); print "You have " . count($devices) . " devices"; @@ -55,9 +55,9 @@ $updated_device->properties->locked; // false # Create an access code on a device $access_code = $seam->access_codes->create( - device_id: $device_id, - code: "1234", - name: "Test Code" + device_id: $device_id, + code: "1234", + name: "Test Code" ); # Check the status of an access code @@ -82,9 +82,7 @@ $pages = $seam->createPaginator( [$connectedAccounts, $pagination] = $pages->firstPage(); if ($pagination->has_next_page) { - [$moreConnectedAccounts] = $pages->nextPage( - $pagination->next_page_cursor - ); + [$moreConnectedAccounts] = $pages->nextPage($pagination->next_page_cursor); } ``` @@ -104,7 +102,7 @@ $pages = $seam->createPaginator( // Store pagination state for later use file_put_contents( - '/tmp/seam_connected_accounts_list.json', + "/tmp/seam_connected_accounts_list.json", json_encode([$params, $pagination]) ); ``` @@ -113,12 +111,14 @@ Get the next page at a later time: ```php $stored_data = json_decode( - file_get_contents('/tmp/seam_connected_accounts_list.json') ?: '[]', + file_get_contents("/tmp/seam_connected_accounts_list.json") ?: "[]", false ); $params = $stored_data[0] ?? []; -$pagination = $stored_data[1] ?? (object)['has_next_page' => false, 'next_page_cursor' => null]; +$pagination = + $stored_data[1] ?? + (object) ["has_next_page" => false, "next_page_cursor" => null]; if ($pagination->has_next_page) { $pages = $seam->createPaginator( @@ -128,6 +128,7 @@ if ($pagination->has_next_page) { [$moreConnectedAccounts] = $pages->nextPage($pagination->next_page_cursor); } ``` + #### Iterate over all resources ```php