slack_chat_api/usergroups_users.rs
1use crate::Client;
2use crate::ClientResult;
3
4pub struct UsergroupsUsers {
5 pub client: Client,
6}
7
8impl UsergroupsUsers {
9 #[doc(hidden)]
10 pub fn new(client: Client) -> Self {
11 UsergroupsUsers { client }
12 }
13
14 /**
15 * This function performs a `GET` to the `/usergroups.users.list` endpoint.
16 *
17 * List all users in a User Group
18 *
19 * FROM: <https://api.slack.com/methods/usergroups.users.list>
20 *
21 * **Parameters:**
22 *
23 * * `token: &str` -- Authentication token. Requires scope: `usergroups:read`.
24 * * `include_disabled: bool` -- Allow results that involve disabled User Groups.
25 * * `usergroup: &str` -- The encoded ID of the User Group to update.
26 */
27 pub async fn list(
28 &self,
29 include_disabled: bool,
30 usergroup: &str,
31 ) -> ClientResult<crate::Response<crate::types::UsergroupsUsersListSchema>> {
32 let mut query_args: Vec<(String, String)> = Default::default();
33 if include_disabled {
34 query_args.push(("include_disabled".to_string(), include_disabled.to_string()));
35 }
36 if !usergroup.is_empty() {
37 query_args.push(("usergroup".to_string(), usergroup.to_string()));
38 }
39 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
40 let url = self
41 .client
42 .url(&format!("/usergroups.users.list?{}", query_), None);
43 self.client
44 .get(
45 &url,
46 crate::Message {
47 body: None,
48 content_type: None,
49 },
50 )
51 .await
52 }
53 /**
54 * This function performs a `POST` to the `/usergroups.users.update` endpoint.
55 *
56 * Update the list of users for a User Group
57 *
58 * FROM: <https://api.slack.com/methods/usergroups.users.update>
59 *
60 * **Parameters:**
61 *
62 * * `token: &str` -- Authentication token. Requires scope: `usergroups:write`.
63 */
64 pub async fn update(
65 &self,
66 ) -> ClientResult<crate::Response<crate::types::UsergroupsCreateSchema>> {
67 let url = self.client.url("/usergroups.users.update", None);
68 self.client
69 .post(
70 &url,
71 crate::Message {
72 body: None,
73 content_type: Some("application/x-www-form-urlencoded".to_string()),
74 },
75 )
76 .await
77 }
78}