slack_rust/users/profile/
get.rs1use crate::error::Error;
2use crate::http_client::{get_slack_url, SlackWebAPIClient};
3use crate::profiles::profile::Profile;
4
5use serde::{Deserialize, Serialize};
6
7#[derive(Deserialize, Serialize, Debug, Default, PartialEq)]
8pub struct GetRequest {
9 pub include_labels: Option<String>,
10 pub user: Option<String>,
11}
12
13#[derive(Deserialize, Serialize, Debug, Default, PartialEq)]
14pub struct GetResponse {
15 pub ok: bool,
16 pub error: Option<String>,
17 pub profile: Option<Profile>,
18}
19
20pub async fn get<T>(client: &T, param: &GetRequest, bot_token: &str) -> Result<GetResponse, Error>
21where
22 T: SlackWebAPIClient,
23{
24 let url = get_slack_url("users.profile.get");
25 let json = serde_json::to_string(¶m)?;
26
27 client
28 .post_json(&url, &json, bot_token)
29 .await
30 .and_then(|result| {
31 serde_json::from_str::<GetResponse>(&result).map_err(Error::SerdeJsonError)
32 })
33}