slack_chat_api/team.rs
1use crate::Client;
2use crate::ClientResult;
3
4pub struct Team {
5 pub client: Client,
6}
7
8impl Team {
9 #[doc(hidden)]
10 pub fn new(client: Client) -> Self {
11 Team { client }
12 }
13
14 /**
15 * This function performs a `GET` to the `/team.accessLogs` endpoint.
16 *
17 * Gets the access logs for the current team.
18 *
19 * FROM: <https://api.slack.com/methods/team.accessLogs>
20 *
21 * **Parameters:**
22 *
23 * * `token: &str` -- Authentication token. Requires scope: `admin`.
24 * * `before: &str` -- End of time range of logs to include in results (inclusive).
25 * * `count: &str`
26 * * `page: &str`
27 */
28 pub async fn access_log(
29 &self,
30 before: &str,
31 count: &str,
32 page: &str,
33 ) -> ClientResult<crate::Response<crate::types::TeamAccessLogsSchema>> {
34 let mut query_args: Vec<(String, String)> = Default::default();
35 if !before.is_empty() {
36 query_args.push(("before".to_string(), before.to_string()));
37 }
38 if !count.is_empty() {
39 query_args.push(("count".to_string(), count.to_string()));
40 }
41 if !page.is_empty() {
42 query_args.push(("page".to_string(), page.to_string()));
43 }
44 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
45 let url = self
46 .client
47 .url(&format!("/team.accessLogs?{}", query_), None);
48 self.client
49 .get(
50 &url,
51 crate::Message {
52 body: None,
53 content_type: None,
54 },
55 )
56 .await
57 }
58 /**
59 * This function performs a `GET` to the `/team.billableInfo` endpoint.
60 *
61 * Gets billable users information for the current team.
62 *
63 * FROM: <https://api.slack.com/methods/team.billableInfo>
64 *
65 * **Parameters:**
66 *
67 * * `token: &str` -- Authentication token. Requires scope: `admin`.
68 * * `user: &str` -- A user to retrieve the billable information for. Defaults to all users.
69 */
70 pub async fn billable_info(
71 &self,
72 user: &str,
73 ) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
74 let mut query_args: Vec<(String, String)> = Default::default();
75 if !user.is_empty() {
76 query_args.push(("user".to_string(), user.to_string()));
77 }
78 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
79 let url = self
80 .client
81 .url(&format!("/team.billableInfo?{}", query_), None);
82 self.client
83 .get(
84 &url,
85 crate::Message {
86 body: None,
87 content_type: None,
88 },
89 )
90 .await
91 }
92 /**
93 * This function performs a `GET` to the `/team.info` endpoint.
94 *
95 * Gets information about the current team.
96 *
97 * FROM: <https://api.slack.com/methods/team.info>
98 *
99 * **Parameters:**
100 *
101 * * `token: &str` -- Authentication token. Requires scope: `team:read`.
102 * * `team: &str` -- Team to get info on, if omitted, will return information about the current team. Will only return team that the authenticated token is allowed to see through external shared channels.
103 */
104 pub async fn info(
105 &self,
106 team: &str,
107 ) -> ClientResult<crate::Response<crate::types::TeamInfoSchema>> {
108 let mut query_args: Vec<(String, String)> = Default::default();
109 if !team.is_empty() {
110 query_args.push(("team".to_string(), team.to_string()));
111 }
112 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
113 let url = self.client.url(&format!("/team.info?{}", query_), None);
114 self.client
115 .get(
116 &url,
117 crate::Message {
118 body: None,
119 content_type: None,
120 },
121 )
122 .await
123 }
124 /**
125 * This function performs a `GET` to the `/team.integrationLogs` endpoint.
126 *
127 * Gets the integration logs for the current team.
128 *
129 * FROM: <https://api.slack.com/methods/team.integrationLogs>
130 *
131 * **Parameters:**
132 *
133 * * `token: &str` -- Authentication token. Requires scope: `admin`.
134 * * `app_id: &str` -- Filter logs to this Slack app. Defaults to all logs.
135 * * `change_type: &str` -- Filter logs with this change type. Defaults to all logs.
136 * * `count: &str`
137 * * `page: &str`
138 * * `service_id: &str` -- Filter logs to this service. Defaults to all logs.
139 * * `user: &str` -- Filter logs generated by this user’s actions. Defaults to all logs.
140 */
141 pub async fn integration_log(
142 &self,
143 app_id: &str,
144 change_type: &str,
145 count: &str,
146 page: &str,
147 service_id: &str,
148 user: &str,
149 ) -> ClientResult<crate::Response<crate::types::TeamIntegrationLogsSchema>> {
150 let mut query_args: Vec<(String, String)> = Default::default();
151 if !app_id.is_empty() {
152 query_args.push(("app_id".to_string(), app_id.to_string()));
153 }
154 if !change_type.is_empty() {
155 query_args.push(("change_type".to_string(), change_type.to_string()));
156 }
157 if !count.is_empty() {
158 query_args.push(("count".to_string(), count.to_string()));
159 }
160 if !page.is_empty() {
161 query_args.push(("page".to_string(), page.to_string()));
162 }
163 if !service_id.is_empty() {
164 query_args.push(("service_id".to_string(), service_id.to_string()));
165 }
166 if !user.is_empty() {
167 query_args.push(("user".to_string(), user.to_string()));
168 }
169 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
170 let url = self
171 .client
172 .url(&format!("/team.integrationLogs?{}", query_), None);
173 self.client
174 .get(
175 &url,
176 crate::Message {
177 body: None,
178 content_type: None,
179 },
180 )
181 .await
182 }
183}