1 use crate::r0::AccessToken;
2 use reqwest::blocking::Client;
3 use reqwest::blocking::Request;
4 use reqwest::Error;
5 use ruma_identifiers::{RoomId, UserId};
6 use serde::Serialize;
7 use url::Url;
8 
9 #[derive(Debug, Clone, Serialize)]
10 pub struct Parameters {
11     pub access_token: AccessToken,
12 }
13 
14 #[derive(Clone, Debug, Serialize)]
15 pub struct Body {
16     // TODO: Restrict values to the range [0.0, 1.0]
17     #[serde(skip_serializing_if = "Option::is_none")]
18     pub order: Option<f64>,
19 }
20 
request( base: Url, user_id: &UserId, room_id: &RoomId, tag: &str, params: &Parameters, body: &Body, ) -> Result<Request, Error>21 pub fn request(
22     base: Url,
23     user_id: &UserId,
24     room_id: &RoomId,
25     tag: &str,
26     params: &Parameters,
27     body: &Body,
28 ) -> Result<Request, Error> {
29     let url = base
30         .join(&format!(
31             "_matrix/client/r0/user/{}/rooms/{}/tags/{}",
32             user_id, room_id, tag
33         ))
34         .expect("Malformed URL in create_tag");
35 
36     Client::new().put(url).query(params).json(body).build()
37 }
38