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::{Deserialize, Serialize};
7 use std::collections::HashMap;
8 use url::Url;
9 
10 #[derive(Clone, Debug, Serialize)]
11 pub struct Parameters {
12     pub access_token: AccessToken,
13 }
14 
15 #[derive(Clone, Debug, Deserialize)]
16 pub struct Response {
17     #[serde(default)]
18     pub joined: HashMap<UserId, RoomMember>,
19 }
20 
21 #[derive(Clone, Debug, Deserialize)]
22 pub struct RoomMember {
23     pub display_name: Option<String>,
24     pub avatar_url: Option<String>,
25 }
26 
request(base: Url, room_id: &RoomId, params: &Parameters) -> Result<Request, Error>27 pub fn request(base: Url, room_id: &RoomId, params: &Parameters) -> Result<Request, Error> {
28     let url = base
29         .join(&format!(
30             "_matrix/client/r0/rooms/{}/joined_members",
31             room_id
32         ))
33         .expect("Malformed URL in get_joined_members");
34 
35     Client::new().get(url).query(params).build()
36 }
37