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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
use anyhow::Result;
use crate::Client;
pub struct AdminInviteRequests {
pub client: Client,
}
impl AdminInviteRequests {
#[doc(hidden)]
pub fn new(client: Client) -> Self {
AdminInviteRequests { client }
}
/**
* This function performs a `POST` to the `/admin.inviteRequests.approve` endpoint.
*
* Approve a workspace invite request.
*
* FROM: <https://api.slack.com/methods/admin.inviteRequests.approve>
*
* **Parameters:**
*
* * `token: &str` -- Authentication token. Requires scope: `admin.invites:write`.
*/
pub async fn approve(
&self,
body: &crate::types::AdminInviteRequestsApproveRequest,
) -> Result<crate::types::DndEndSchema> {
let url = "/admin.inviteRequests.approve".to_string();
self.client
.post(&url, Some(reqwest::Body::from(serde_json::to_vec(body)?)))
.await
}
/**
* This function performs a `POST` to the `/admin.inviteRequests.deny` endpoint.
*
* Deny a workspace invite request.
*
* FROM: <https://api.slack.com/methods/admin.inviteRequests.deny>
*
* **Parameters:**
*
* * `token: &str` -- Authentication token. Requires scope: `admin.invites:write`.
*/
pub async fn deny(
&self,
body: &crate::types::AdminInviteRequestsApproveRequest,
) -> Result<crate::types::DndEndSchema> {
let url = "/admin.inviteRequests.deny".to_string();
self.client
.post(&url, Some(reqwest::Body::from(serde_json::to_vec(body)?)))
.await
}
/**
* This function performs a `GET` to the `/admin.inviteRequests.list` endpoint.
*
* List all pending workspace invite requests.
*
* FROM: <https://api.slack.com/methods/admin.inviteRequests.list>
*
* **Parameters:**
*
* * `token: &str` -- Authentication token. Requires scope: `admin.invites:read`.
* * `team_id: &str` -- ID for the workspace where the invite requests were made.
* * `cursor: &str` -- Value of the `next_cursor` field sent as part of the previous API response.
* * `limit: i64` -- The number of results that will be returned by the API on each invocation. Must be between 1 - 1000, both inclusive.
*/
pub async fn list(
&self,
team_id: &str,
cursor: &str,
limit: i64,
) -> Result<crate::types::DndEndSchema> {
let mut query_args: Vec<(String, String)> = Default::default();
if !cursor.is_empty() {
query_args.push(("cursor".to_string(), cursor.to_string()));
}
if limit > 0 {
query_args.push(("limit".to_string(), limit.to_string()));
}
if !team_id.is_empty() {
query_args.push(("team_id".to_string(), team_id.to_string()));
}
let query_ = serde_urlencoded::to_string(&query_args).unwrap();
let url = format!("/admin.inviteRequests.list?{}", query_);
self.client.get(&url, None).await
}
}