pub mod unstable {
use ruma_common::{
OwnedUserId,
api::{request, response},
metadata,
};
use serde::Serialize;
use serde_json::value::{RawValue as RawJsonValue, to_raw_value as to_raw_json_value};
use crate::HomeserverToken;
metadata! {
method: GET,
rate_limited: false,
authentication: HomeserverToken,
path: "/_matrix/app/unstable/uk.half-shot.msc4417/preview_url"
}
#[request]
pub struct Request {
#[ruma_api(query)]
pub url: String,
#[ruma_api(query)]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_id: Option<OwnedUserId>,
}
#[response]
#[derive(Default)]
pub struct Response {
#[ruma_api(body)]
pub data: Option<Box<RawJsonValue>>,
}
impl Request {
pub fn new(url: String) -> Self {
Self { url, user_id: None }
}
}
impl Response {
pub fn new() -> Self {
Self { data: None }
}
pub fn from_raw_value(data: Box<RawJsonValue>) -> Self {
Self { data: Some(data) }
}
pub fn from_serialize<T: Serialize>(data: &T) -> serde_json::Result<Self> {
Ok(Self { data: Some(to_raw_json_value(data)?) })
}
}
}