Skip to main content

neptunium_http/endpoints/channel/
upload_stream_preview_image.rs

1use bon::Builder;
2use neptunium_model::id::{Id, marker::ChannelMarker};
3use reqwest::Method;
4use serde::Serialize;
5
6use crate::{endpoints::Endpoint, request::Request};
7
8#[derive(Builder, Clone, Debug)]
9pub struct UploadStreamPreviewImage {
10    pub stream_key: String,
11    pub channel_id: Id<ChannelMarker>,
12    /// Base64-encoded thumbnail image data.
13    pub thumbnail: String,
14    /// The MIME type of the thumbnail image.
15    pub content_type: Option<String>,
16}
17
18impl Endpoint for UploadStreamPreviewImage {
19    type Response = ();
20
21    fn into_request(self) -> crate::request::Request {
22        #[derive(Serialize)]
23        struct UploadStreamPreviewImageBody {
24            pub channel_id: Id<ChannelMarker>,
25            pub thumbnail: String,
26            #[serde(skip_serializing_if = "Option::is_none")]
27            pub content_type: Option<String>,
28        }
29
30        let body = UploadStreamPreviewImageBody {
31            channel_id: self.channel_id,
32            thumbnail: self.thumbnail,
33            content_type: self.content_type,
34        };
35
36        Request::builder()
37            .method(Method::POST)
38            .body(serde_json::to_string(&body).unwrap())
39            .path(format!("/streams/{}/preview", self.stream_key))
40            .build()
41    }
42}