diff --git a/src/Objects/ConnectedAccount.php b/src/Objects/ConnectedAccount.php index 478c2dd..509a0ca 100644 --- a/src/Objects/ConnectedAccount.php +++ b/src/Objects/ConnectedAccount.php @@ -25,6 +25,7 @@ public static function from_json(mixed $json): ConnectedAccount|null fn ($e) => SeamWarning::from_json($e), $json->warnings ?? [] ), + automatically_manage_new_devices: $json->automatically_manage_new_devices ); } @@ -35,7 +36,8 @@ public function __construct( public array $errors, public array $warnings, public string $created_at, - public mixed $custom_metadata + public mixed $custom_metadata, + public bool $automatically_manage_new_devices ) { } } diff --git a/src/SeamClient.php b/src/SeamClient.php index c95d585..fd48b73 100644 --- a/src/SeamClient.php +++ b/src/SeamClient.php @@ -586,14 +586,14 @@ public function create( /** * Create Access Codes across multiple Devices that share a common code - * + * * @param string[] $device_ids * @param string|null $name * @param string|null $starts_at * @param string|null $ends_at * @param string|null $behavior_when_code_cannot_be_shared Accepts either "throw" or "create_random_code" * @param bool|null $attempt_for_offline_device - * + * * @return AccessCode[] */ public function create_multiple( @@ -883,6 +883,21 @@ public function get(string $connected_account_id): ConnectedAccount ) ); } + + public function update(string $connected_account_id, bool $automatically_manage_new_devices): ConnectedAccount + { + return ConnectedAccount::from_json( + $this->seam->request( + "POST", + "connected_accounts/update", + json: [ + "connected_account_id" => $connected_account_id, + "automatically_manage_new_devices" => $automatically_manage_new_devices, + ], + inner_object: "connected_account" + ) + ); + } } class EventsClient @@ -1245,7 +1260,7 @@ class ThermostatsClient { private SeamClient $seam; - + public ClimateSettingSchedulesClient $climate_setting_schedules; public function __construct(SeamClient $seam) diff --git a/tests/ConnectedAccountsTest.php b/tests/ConnectedAccountsTest.php index d7b3667..7ef2142 100644 --- a/tests/ConnectedAccountsTest.php +++ b/tests/ConnectedAccountsTest.php @@ -50,4 +50,31 @@ public function testDeleteConnectedAccount(): void $this->assertTrue(str_contains($exception->getMessage(), "connected_account_not_found")); } } + + public function testUpdateConnectedAccount(): void + { + $seam = Fixture::getTestServer(true); + $connected_accounts = $seam->connected_accounts->list(); + + $connected_account_id = $connected_accounts[0]->connected_account_id; + + $connected_account = $seam->connected_accounts->get( + connected_account_id: $connected_account_id + ); + $this->assertTrue( + $connected_account->automatically_manage_new_devices === true + ); + + $seam->connected_accounts->update( + connected_account_id: $connected_account_id, + automatically_manage_new_devices: false + ); + + $connected_account = $seam->connected_accounts->get( + connected_account_id: $connected_account_id + ); + $this->assertTrue( + $connected_account->automatically_manage_new_devices === false + ); + } }