1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
use anyhow::Result;
use crate::Client;
pub struct UsersProfile {
pub client: Client,
}
impl UsersProfile {
#[doc(hidden)]
pub fn new(client: Client) -> Self {
UsersProfile { client }
}
/**
* This function performs a `GET` to the `/users.profile.get` endpoint.
*
* Retrieves a user's profile information.
*
* FROM: <https://api.slack.com/methods/users.profile.get>
*
* **Parameters:**
*
* * `token: &str` -- Authentication token. Requires scope: `users.profile:read`.
* * `include_labels: bool` -- Include labels for each ID in custom profile fields.
* * `user: &str` -- User to retrieve profile info for.
*/
pub async fn get(
&self,
include_labels: bool,
user: &str,
) -> Result<crate::types::UsersProfileGetSchema> {
let mut query_args: Vec<(String, String)> = Default::default();
if include_labels {
query_args.push(("include_labels".to_string(), include_labels.to_string()));
}
if !user.is_empty() {
query_args.push(("user".to_string(), user.to_string()));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = self
.client
.url(&format!("/users.profile.get?{}", query_), None);
self.client
.get(
&url,
crate::Message {
body: None,
content_type: None,
},
)
.await
}
/**
* This function performs a `POST` to the `/users.profile.set` endpoint.
*
* Set the profile information for a user.
*
* FROM: <https://api.slack.com/methods/users.profile.set>
*
* **Parameters:**
*
* * `token: &str` -- Authentication token. Requires scope: `users.profile:write`.
*/
pub async fn set(&self) -> Result<crate::types::UsersProfileSetSchema> {
let url = self.client.url("/users.profile.set", None);
self.client
.post(
&url,
crate::Message {
body: None,
content_type: Some("application/x-www-form-urlencoded".to_string()),
},
)
.await
}
}