diff --git a/package-lock.json b/package-lock.json index 004b385c..c6aeb406 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "@seamapi/blueprint": "^1.12.0", "@seamapi/fake-seam-connect": "2.0.6", "@seamapi/smith": "^1.1.0", - "@seamapi/types": "1.1082.0", + "@seamapi/types": "1.1092.0", "change-case": "^5.4.4", "execa": "^10.0.1", "prettier": "^3.9.6" @@ -882,9 +882,9 @@ } }, "node_modules/@seamapi/types": { - "version": "1.1082.0", - "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.1082.0.tgz", - "integrity": "sha512-QDuaHzjq+i/6yQ+fGs2jUmuZ8QomanqnLAuP2NULyGmfpTTeI/pEGkUp9YmRjUrbFoM8LHNT3ZmsFi8/2JJYmA==", + "version": "1.1092.0", + "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.1092.0.tgz", + "integrity": "sha512-99Wi8sSk4RZ2g9/iRJiONtIp9Hc/c2Xe5SeIIacbwxKbqkpmiTi8tQO0+M2qGXVzYuoO3xM/lBkEy4kUAhe/Ew==", "dev": true, "license": "MIT", "engines": { diff --git a/package.json b/package.json index ace6d687..634632b4 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "@seamapi/blueprint": "^1.12.0", "@seamapi/fake-seam-connect": "2.0.6", "@seamapi/smith": "^1.1.0", - "@seamapi/types": "1.1082.0", + "@seamapi/types": "1.1092.0", "change-case": "^5.4.4", "execa": "^10.0.1", "prettier": "^3.9.6" diff --git a/src/Resources/AccessCode.php b/src/Resources/AccessCode.php index 3a00565d..3853ef7a 100644 --- a/src/Resources/AccessCode.php +++ b/src/Resources/AccessCode.php @@ -1164,7 +1164,7 @@ public function __construct( } /** - * Indicates that Seam's integration user does not have sufficient permissions on the provider's system to which this device belongs, so Seam cannot manage access codes or unlock the device. See the error message for specifics, then either reauthorize the connected account in Seam or grant the integration user the required permissions in the provider's system. + * Indicates that the provider's system to which this device belongs is not letting Seam act on it, so Seam cannot manage access codes or unlock the device. The error message says which of three causes applies. Seam's integration user may not have sufficient permissions on the provider's system, or may have been suspended there: grant the integration user the required permissions in the provider's system, or reauthorize the connected account in Seam. The provider account or site may not have a valid subscription with the provider: set up or renew that subscription with the provider. Or the provider may have rejected the credential Seam uses to operate the device's hub: contact Seam support to re-activate it. */ final class InsufficientPermissions extends \Seam\Resources\AccessCode\Errors diff --git a/src/Resources/AcsSystem.php b/src/Resources/AcsSystem.php index 33afa84d..8c69e308 100644 --- a/src/Resources/AcsSystem.php +++ b/src/Resources/AcsSystem.php @@ -568,7 +568,7 @@ public function __construct( } /** - * Indicates that Seam's integration user does not have sufficient permissions on the provider's system backing this [access control system](https://www.seam.co/docs/low-level-apis/access-systems). Access cannot be managed until permissions are restored. See the error message for specifics, then either reauthorize the connected account in Seam or grant the integration user the required permissions in the provider's system. + * Indicates that the provider's system backing this [access control system](https://www.seam.co/docs/low-level-apis/access-systems) is not letting Seam act on it, so access cannot be managed until this is resolved. The error message says which of two causes applies. Either Seam's integration user does not have sufficient permissions on the provider's system, or has been suspended there: grant the integration user the required permissions in the provider's system, or reauthorize the connected account in Seam. Or the provider account or site does not have a valid subscription with the provider: set up or renew that subscription with the provider. */ final class InsufficientPermissions extends \Seam\Resources\AcsSystem\Errors { diff --git a/src/Resources/CameraLiveViewAnswer.php b/src/Resources/CameraLiveViewAnswer.php new file mode 100644 index 00000000..b1372a9d --- /dev/null +++ b/src/Resources/CameraLiveViewAnswer.php @@ -0,0 +1,24 @@ +sdp_answer ?? null); + } + + public function __construct( + /** + * WebRTC SDP answer for the offer, limited to 64 KiB of UTF-8 data. + */ + public string|null $sdp_answer, + ) {} + } +} diff --git a/src/Resources/CameraLiveViewSession.php b/src/Resources/CameraLiveViewSession.php new file mode 100644 index 00000000..d8d8524a --- /dev/null +++ b/src/Resources/CameraLiveViewSession.php @@ -0,0 +1,43 @@ +camera_live_view_session_id ?? + null, + device_id: $json->device_id ?? null, + expires_at: $json->expires_at ?? null, + token: $json->token ?? null, + ); + } + + public function __construct( + /** + * ID of the camera live view session. + */ + public string|null $camera_live_view_session_id, + /** + * ID of the camera. + */ + public string|null $device_id, + /** + * Date and time at which the live view session expires. + */ + public string|null $expires_at, + /** + * Token that authorizes the offer and stop requests for this session. + */ + public string|null $token, + ) {} + } +} diff --git a/src/Resources/Device.php b/src/Resources/Device.php index 5ace2754..26e0dd66 100644 --- a/src/Resources/Device.php +++ b/src/Resources/Device.php @@ -65,6 +65,7 @@ public static function from_json(mixed $json): Device|null can_simulate_paid_subscription: $json->can_simulate_paid_subscription ?? null, can_simulate_removal: $json->can_simulate_removal ?? null, + can_stream_live_video: $json->can_stream_live_video ?? null, can_turn_off_hvac: $json->can_turn_off_hvac ?? null, can_unlock_with_code: $json->can_unlock_with_code ?? null, device_manufacturer: isset($json->device_manufacturer) @@ -227,6 +228,10 @@ public function __construct( * Indicates whether the device supports simulating removal in a sandbox. */ public bool|null $can_simulate_removal = null, + /** + * Indicates whether the camera supports streaming live video through a camera live view session. + */ + public bool|null $can_stream_live_video = null, /** * Indicates whether the thermostat can be turned off. */ @@ -760,6 +765,11 @@ public static function from_json(mixed $json): Properties|null $json->online_time_frame_options ?? [], ), relative_humidity: $json->relative_humidity ?? null, + reolink_metadata: isset($json->reolink_metadata) + ? \Seam\Resources\Device\Properties\ReolinkMetadata::from_json( + $json->reolink_metadata, + ) + : null, ring_metadata: isset($json->ring_metadata) ? \Seam\Resources\Device\Properties\RingMetadata::from_json( $json->ring_metadata, @@ -1228,6 +1238,10 @@ public function __construct( * Reported relative humidity, as a value between 0 and 1, inclusive. */ public float|null $relative_humidity = null, + /** + * Metadata for a Reolink camera. + */ + public \Seam\Resources\Device\Properties\ReolinkMetadata|null $reolink_metadata = null, /** * Metadata for a Ring device. */ @@ -1551,6 +1565,7 @@ enum DeviceType: string case RING_CAMERA = "ring_camera"; case TAPO_CAMERA = "tapo_camera"; case ARLO_CAMERA = "arlo_camera"; + case REOLINK_CAMERA = "reolink_camera"; } } @@ -1662,7 +1677,7 @@ public function __construct( } /** - * Indicates that Seam's integration user does not have sufficient permissions on the provider's system to which this device belongs, so Seam cannot manage access codes or unlock the device. See the error message for specifics, then either reauthorize the connected account in Seam or grant the integration user the required permissions in the provider's system. + * Indicates that the provider's system to which this device belongs is not letting Seam act on it, so Seam cannot manage access codes or unlock the device. The error message says which of three causes applies. Seam's integration user may not have sufficient permissions on the provider's system, or may have been suspended there: grant the integration user the required permissions in the provider's system, or reauthorize the connected account in Seam. The provider account or site may not have a valid subscription with the provider: set up or renew that subscription with the provider. Or the provider may have rejected the credential Seam uses to operate the device's hub: contact Seam support to re-activate it. */ final class InsufficientPermissions extends \Seam\Resources\Device\Errors { @@ -3609,6 +3624,39 @@ public function __construct( ) {} } + /** + * Metadata for a Reolink camera. + */ + class ReolinkMetadata + { + public static function from_json(mixed $json): ReolinkMetadata|null + { + if (!$json) { + return null; + } + return new self( + firmware_version: $json->firmware_version ?? null, + hardware_version: $json->hardware_version ?? null, + model: $json->model ?? null, + ); + } + + public function __construct( + /** + * Firmware version reported by the camera. + */ + public string|null $firmware_version = null, + /** + * Hardware version reported by the camera. + */ + public string|null $hardware_version = null, + /** + * Model reported by the Reolink camera. + */ + public string|null $model = null, + ) {} + } + /** * Metadata for a Ring device. */ diff --git a/src/Resources/DeviceProvider.php b/src/Resources/DeviceProvider.php index 7d92e33d..091c4cb0 100644 --- a/src/Resources/DeviceProvider.php +++ b/src/Resources/DeviceProvider.php @@ -43,6 +43,7 @@ public static function from_json(mixed $json): DeviceProvider|null can_simulate_paid_subscription: $json->can_simulate_paid_subscription ?? null, can_simulate_removal: $json->can_simulate_removal ?? null, + can_stream_live_video: $json->can_stream_live_video ?? null, can_turn_off_hvac: $json->can_turn_off_hvac ?? null, can_unlock_with_code: $json->can_unlock_with_code ?? null, ); @@ -145,6 +146,10 @@ public function __construct( * Indicates whether the device supports simulating removal in a sandbox. */ public bool|null $can_simulate_removal = null, + /** + * Indicates whether the camera supports streaming live video through a camera live view session. + */ + public bool|null $can_stream_live_video = null, /** * Indicates whether the thermostat can be turned off. */ @@ -219,6 +224,7 @@ enum DeviceProviderName: string case RING = "ring"; case TAPO = "tapo"; case ARLO = "arlo"; + case REOLINK = "reolink"; case ICAL = "ical"; case LODGIFY = "lodgify"; case HOSTAWAY = "hostaway"; diff --git a/src/Resources/Event.php b/src/Resources/Event.php index 2b4879f6..eaec085c 100644 --- a/src/Resources/Event.php +++ b/src/Resources/Event.php @@ -10062,6 +10062,7 @@ public static function from_json(mixed $json): CameraActivated|null device_custom_metadata: $json->device_custom_metadata ?? null, event_description: $json->event_description ?? null, image_url: $json->image_url ?? null, + media_ids: $json->media_ids ?? null, motion_sub_type: $json->motion_sub_type ?? null, video_url: $json->video_url ?? null, ); @@ -10126,6 +10127,12 @@ public function __construct( * URL to a thumbnail image captured at the time of activation. */ public string|null $image_url = null, + /** + * IDs of the media, such as a video clip and a thumbnail image, captured for this activation. Use `/media/get` to retrieve each one. + * + * @var list|null + */ + public array|null $media_ids = null, /** * Sub-type of motion detected, if available. * @@ -10172,6 +10179,7 @@ public static function from_json(mixed $json): DeviceDoorbellRang|null device_custom_metadata: $json->device_custom_metadata ?? null, event_description: $json->event_description ?? null, image_url: $json->image_url ?? null, + media_ids: $json->media_ids ?? null, video_url: $json->video_url ?? null, ); } @@ -10229,6 +10237,12 @@ public function __construct( * URL to a thumbnail image captured at the time the doorbell was pressed. */ public string|null $image_url = null, + /** + * IDs of the media, such as a video clip and a thumbnail image, captured when the doorbell was pressed. Use `/media/get` to retrieve each one. + * + * @var list|null + */ + public array|null $media_ids = null, /** * URL to a short video clip captured at the time the doorbell was pressed. */ diff --git a/src/Resources/Media.php b/src/Resources/Media.php new file mode 100644 index 00000000..9548a1e8 --- /dev/null +++ b/src/Resources/Media.php @@ -0,0 +1,104 @@ +content_type ?? null, + created_at: $json->created_at ?? null, + device_id: $json->device_id ?? null, + event_id: $json->event_id ?? null, + expires_at: $json->expires_at ?? null, + media_id: $json->media_id ?? null, + media_type: $json->media_type ?? null, + status: $json->status ?? null, + url: $json->url ?? null, + workspace_id: $json->workspace_id ?? null, + video_codec: $json->video_codec ?? null, + ); + } + + public function __construct( + /** + * MIME type of the media, such as `video/mp4` or `image/jpeg`. + */ + public string|null $content_type, + /** + * Date and time at which the media was created. + */ + public string|null $created_at, + /** + * ID of the device that captured the media. + */ + public string|null $device_id, + /** + * ID of the event that the media belongs to. + */ + public string|null $event_id, + /** + * Date and time at which the media stops being available. Null when Seam does not know when the media expires. + */ + public string|null $expires_at, + /** + * ID of the media. + */ + public string|null $media_id, + /** + * Type of the media: a video clip or a still image. + * + * @var value-of<\Seam\Resources\Media\MediaType>|string|null + */ + public string|null $media_type, + /** + * Status of the media. `pending` means that Seam is still retrieving the media. `available` means that `url` can be used to download it. `unavailable` means that no media exists for the event, and `failed` means that Seam could not retrieve it. + * + * @var value-of<\Seam\Resources\Media\Status>|string|null + */ + public string|null $status, + /** + * Short-lived URL from which you can download the media. Null unless `status` is `available`. The URL expires after about five minutes. Call `/media/get` again for a new URL. + */ + public string|null $url, + /** + * ID of the workspace that contains the media. + */ + public string|null $workspace_id, + /** + * Video codec used to encode the media. Only present for video media. `hevc` (H.265) playback support varies by browser and device, so check compatibility before assuming a clip plays inline. + * + * @var value-of<\Seam\Resources\Media\VideoCodec>|string|null + */ + public string|null $video_codec = null, + ) {} + } +} + +namespace Seam\Resources\Media { + enum MediaType: string + { + case VIDEO = "video"; + case IMAGE = "image"; + } + + enum Status: string + { + case PENDING = "pending"; + case AVAILABLE = "available"; + case UNAVAILABLE = "unavailable"; + case FAILED = "failed"; + } + + enum VideoCodec: string + { + case H264 = "h264"; + case HEVC = "hevc"; + } +} diff --git a/src/Resources/UnmanagedAccessCode.php b/src/Resources/UnmanagedAccessCode.php index f169b9e7..a15a0339 100644 --- a/src/Resources/UnmanagedAccessCode.php +++ b/src/Resources/UnmanagedAccessCode.php @@ -1056,7 +1056,7 @@ public function __construct( } /** - * Indicates that Seam's integration user does not have sufficient permissions on the provider's system to which this device belongs, so Seam cannot manage access codes or unlock the device. See the error message for specifics, then either reauthorize the connected account in Seam or grant the integration user the required permissions in the provider's system. + * Indicates that the provider's system to which this device belongs is not letting Seam act on it, so Seam cannot manage access codes or unlock the device. The error message says which of three causes applies. Seam's integration user may not have sufficient permissions on the provider's system, or may have been suspended there: grant the integration user the required permissions in the provider's system, or reauthorize the connected account in Seam. The provider account or site may not have a valid subscription with the provider: set up or renew that subscription with the provider. Or the provider may have rejected the credential Seam uses to operate the device's hub: contact Seam support to re-activate it. */ final class InsufficientPermissions extends \Seam\Resources\UnmanagedAccessCode\Errors diff --git a/src/Resources/UnmanagedDevice.php b/src/Resources/UnmanagedDevice.php index dd2ca044..f58a66cc 100644 --- a/src/Resources/UnmanagedDevice.php +++ b/src/Resources/UnmanagedDevice.php @@ -70,6 +70,7 @@ public static function from_json(mixed $json): UnmanagedDevice|null can_simulate_paid_subscription: $json->can_simulate_paid_subscription ?? null, can_simulate_removal: $json->can_simulate_removal ?? null, + can_stream_live_video: $json->can_stream_live_video ?? null, can_turn_off_hvac: $json->can_turn_off_hvac ?? null, can_unlock_with_code: $json->can_unlock_with_code ?? null, location: isset($json->location) @@ -215,6 +216,10 @@ public function __construct( * Indicates whether the device supports simulating removal in a sandbox. */ public bool|null $can_simulate_removal = null, + /** + * Indicates whether the camera supports streaming live video through a camera live view session. + */ + public bool|null $can_stream_live_video = null, /** * Indicates whether the thermostat can be turned off. */ @@ -666,6 +671,7 @@ enum DeviceType: string case RING_CAMERA = "ring_camera"; case TAPO_CAMERA = "tapo_camera"; case ARLO_CAMERA = "arlo_camera"; + case REOLINK_CAMERA = "reolink_camera"; } } @@ -778,7 +784,7 @@ public function __construct( } /** - * Indicates that Seam's integration user does not have sufficient permissions on the provider's system to which this device belongs, so Seam cannot manage access codes or unlock the device. See the error message for specifics, then either reauthorize the connected account in Seam or grant the integration user the required permissions in the provider's system. + * Indicates that the provider's system to which this device belongs is not letting Seam act on it, so Seam cannot manage access codes or unlock the device. The error message says which of three causes applies. Seam's integration user may not have sufficient permissions on the provider's system, or may have been suspended there: grant the integration user the required permissions in the provider's system, or reauthorize the connected account in Seam. The provider account or site may not have a valid subscription with the provider: set up or renew that subscription with the provider. Or the provider may have rejected the credential Seam uses to operate the device's hub: contact Seam support to re-activate it. */ final class InsufficientPermissions extends \Seam\Resources\UnmanagedDevice\Errors diff --git a/src/Routes/CamerasClient.php b/src/Routes/CamerasClient.php new file mode 100644 index 00000000..0c05b319 --- /dev/null +++ b/src/Routes/CamerasClient.php @@ -0,0 +1,25 @@ +client = $client; + $this->defaults = $defaults; + $this->live_views = new CamerasLiveViewsClient($client, $defaults); + } +} diff --git a/src/Routes/CamerasLiveViewsClient.php b/src/Routes/CamerasLiveViewsClient.php new file mode 100644 index 00000000..46c57ade --- /dev/null +++ b/src/Routes/CamerasLiveViewsClient.php @@ -0,0 +1,130 @@ +client = $client; + $this->defaults = $defaults; + } + + /** + * Creates a short-lived live view session for a single camera. Pass the returned session ID and token to `/cameras/live_views/offer` to start a WebRTC stream, and to `/cameras/live_views/stop` to end the session. + * + * Camera live view is in beta. To enable it for your workspace, contact Seam support. To check whether a camera supports live view, use `device.can_stream_live_video`. + * + * @param string $device_id ID of the camera to view. + * @param int $duration_seconds Number of seconds for which the live view session is valid, up to 600. + * @param bool $include_audio Indicates whether to include the camera's audio. + * @return CameraLiveViewSession OK + */ + public function create( + string $device_id, + ?int $duration_seconds = null, + ?bool $include_audio = null, + ): CameraLiveViewSession { + $request_payload = []; + + $request_payload["device_id"] = $device_id; + if ($duration_seconds !== null) { + $request_payload["duration_seconds"] = $duration_seconds; + } + if ($include_audio !== null) { + $request_payload["include_audio"] = $include_audio; + } + + $res = Body::decode( + $this->client->request("POST", "/cameras/live_views/create", [ + "json" => (object) $request_payload, + ]), + ); + + return CameraLiveViewSession::from_json( + Body::read( + $res, + "camera_live_view_session", + "/cameras/live_views/create", + ), + ); + } + + /** + * Exchanges a WebRTC SDP offer for an SDP answer that starts streaming video from the camera, for a live view session that you created using `/cameras/live_views/create`. + * + * Camera live view is in beta. To enable it for your workspace, contact Seam support. + * + * @param string $camera_live_view_session_id ID of the camera live view session. + * @param string $sdp_offer WebRTC SDP offer from the viewer, limited to 64 KiB of UTF-8 data. + * @param string $token Token returned when the camera live view session was created. + * @return CameraLiveViewAnswer OK + */ + public function offer( + string $camera_live_view_session_id, + string $sdp_offer, + string $token, + ): CameraLiveViewAnswer { + $request_payload = []; + + $request_payload[ + "camera_live_view_session_id" + ] = $camera_live_view_session_id; + $request_payload["sdp_offer"] = $sdp_offer; + $request_payload["token"] = $token; + + $res = Body::decode( + $this->client->request("POST", "/cameras/live_views/offer", [ + "json" => (object) $request_payload, + ]), + ); + + return CameraLiveViewAnswer::from_json( + Body::read( + $res, + "camera_live_view_answer", + "/cameras/live_views/offer", + ), + ); + } + + /** + * Stops a camera live view session that the current client session owns. + * + * Camera live view is in beta. To enable it for your workspace, contact Seam support. + * + * @param string $camera_live_view_session_id ID of the camera live view session. + * @param string $token Token returned when the camera live view session was created. + * @return void OK + */ + public function stop( + string $camera_live_view_session_id, + string $token, + ): void { + $request_payload = []; + + $request_payload[ + "camera_live_view_session_id" + ] = $camera_live_view_session_id; + $request_payload["token"] = $token; + + $this->client->request("POST", "/cameras/live_views/stop", [ + "json" => (object) $request_payload, + ]); + } +} diff --git a/src/Routes/ClientSessionsClient.php b/src/Routes/ClientSessionsClient.php index 76e01761..51e49f41 100644 --- a/src/Routes/ClientSessionsClient.php +++ b/src/Routes/ClientSessionsClient.php @@ -33,7 +33,7 @@ public function __construct(ClientInterface $client, array $defaults) * @param string $customer_id Customer ID that you want to associate with the new client session. * @param string $customer_key Customer key that you want to associate with the new client session. * @param string $expires_at Date and time at which the client session should expire, in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. - * @param string $user_identifier_key Your user ID for the user for whom you want to create a client session. + * @param string $user_identifier_key Your user ID for the user for whom you want to create a client session. When you authenticate with a publishable key, the `user_identifier_key` must be a high-entropy secret that only the user knows, such as a UUIDv4 or a salted hash. Do not use an email address, name, phone number, or other guessable value, because anyone who knows the `user_identifier_key` can retrieve the client session. * @param string $user_identity_id ID of the [user identity](https://www.seam.co/docs/capability-guides/mobile-access/managing-mobile-app-user-accounts-with-user-identities#what-is-a-user-identity) for which you want to create a client session. * @param list $user_identity_ids IDs of the [user identities](https://www.seam.co/docs/capability-guides/mobile-access/managing-mobile-app-user-accounts-with-user-identities#what-is-a-user-identity) that you want to associate with the client session. * @return ClientSession OK @@ -140,7 +140,7 @@ public function get( * @param list $connect_webview_ids IDs of the [Connect Webviews](https://www.seam.co/docs/core-concepts/connect-webviews) that you want to associate with the client session (or that are already associated with the existing client session). * @param list $connected_account_ids IDs of the [connected accounts](https://www.seam.co/docs/api/connected_accounts/object) that you want to associate with the client session (or that are already associated with the existing client session). * @param string $expires_at Date and time at which the client session should expire in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. If the client session already exists, this will update the expiration before returning it. - * @param string $user_identifier_key Your user ID for the user that you want to associate with the client session (or that is already associated with the existing client session). + * @param string $user_identifier_key Your user ID for the user that you want to associate with the client session (or that is already associated with the existing client session). When you authenticate with a publishable key, the `user_identifier_key` must be a high-entropy secret that only the user knows, such as a UUIDv4 or a salted hash. Do not use an email address, name, phone number, or other guessable value, because anyone who knows the `user_identifier_key` can retrieve the client session. * @param string $user_identity_id ID of the [user identity](https://www.seam.co/docs/capability-guides/mobile-access/managing-mobile-app-user-accounts-with-user-identities#what-is-a-user-identity) that you want to associate with the client session (or that are already associated with the existing client session). * @param list $user_identity_ids IDs of the [user identities](https://www.seam.co/docs/capability-guides/mobile-access/managing-mobile-app-user-accounts-with-user-identities#what-is-a-user-identity) that you want to associate with the client session. * @return ClientSession OK diff --git a/src/Routes/MediaClient.php b/src/Routes/MediaClient.php new file mode 100644 index 00000000..c87925db --- /dev/null +++ b/src/Routes/MediaClient.php @@ -0,0 +1,51 @@ +client = $client; + $this->defaults = $defaults; + } + + /** + * Returns a specified piece of media, such as a video clip or thumbnail image captured for a camera event, with a short-lived URL from which you can download it. Camera events list their media in `media_ids`. This endpoint is in beta. + * + * @param string $media_id ID of the media that you want to get. + * @param string $format Response format. `json` returns the media object. `redirect` responds with a `302` redirect to the media's download URL, so you can use this endpoint directly as the source of an image or video. + * @return Media OK + */ + public function get(string $media_id, ?string $format = null): Media + { + $request_payload = []; + + $request_payload["media_id"] = $media_id; + if ($format !== null) { + $request_payload["format"] = $format; + } + + $res = Body::decode( + $this->client->request("GET", "/media/get", [ + "query" => $request_payload, + ]), + ); + + return Media::from_json(Body::read($res, "media", "/media/get")); + } +} diff --git a/src/Seam.php b/src/Seam.php index 3f423eea..44ffb4c1 100644 --- a/src/Seam.php +++ b/src/Seam.php @@ -7,6 +7,7 @@ use Seam\Routes\AccessMethodsClient; use Seam\Routes\AcsClient; use Seam\Routes\ActionAttemptsClient; +use Seam\Routes\CamerasClient; use Seam\Routes\ClientSessionsClient; use Seam\Routes\ConnectedAccountsClient; use Seam\Routes\ConnectWebviewsClient; @@ -15,6 +16,7 @@ use Seam\Routes\EventsClient; use Seam\Routes\InstantKeysClient; use Seam\Routes\LocksClient; +use Seam\Routes\MediaClient; use Seam\Routes\NoiseSensorsClient; use Seam\Routes\PhonesClient; use Seam\Routes\SpacesClient; @@ -45,6 +47,7 @@ class Seam public AccessMethodsClient $access_methods; public AcsClient $acs; public ActionAttemptsClient $action_attempts; + public CamerasClient $cameras; public ClientSessionsClient $client_sessions; public ConnectWebviewsClient $connect_webviews; public ConnectedAccountsClient $connected_accounts; @@ -53,6 +56,7 @@ class Seam public EventsClient $events; public InstantKeysClient $instant_keys; public LocksClient $locks; + public MediaClient $media; public NoiseSensorsClient $noise_sensors; public PhonesClient $phones; public SpacesClient $spaces; @@ -144,6 +148,7 @@ public function __construct( $this->client, $this->defaults, ); + $this->cameras = new CamerasClient($this->client, $this->defaults); $this->client_sessions = new ClientSessionsClient( $this->client, $this->defaults, @@ -164,6 +169,7 @@ public function __construct( $this->defaults, ); $this->locks = new LocksClient($this->client, $this->defaults); + $this->media = new MediaClient($this->client, $this->defaults); $this->noise_sensors = new NoiseSensorsClient( $this->client, $this->defaults,