slack_chat_api/stars.rs
1use crate::Client;
2use crate::ClientResult;
3
4pub struct Stars {
5 pub client: Client,
6}
7
8impl Stars {
9 #[doc(hidden)]
10 pub fn new(client: Client) -> Self {
11 Stars { client }
12 }
13
14 /**
15 * This function performs a `POST` to the `/stars.add` endpoint.
16 *
17 * Adds a star to an item.
18 *
19 * FROM: <https://api.slack.com/methods/stars.add>
20 *
21 * **Parameters:**
22 *
23 * * `token: &str` -- Authentication token. Requires scope: `stars:write`.
24 */
25 pub async fn add(&self) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
26 let url = self.client.url("/stars.add", None);
27 self.client
28 .post(
29 &url,
30 crate::Message {
31 body: None,
32 content_type: Some("application/x-www-form-urlencoded".to_string()),
33 },
34 )
35 .await
36 }
37 /**
38 * This function performs a `GET` to the `/stars.list` endpoint.
39 *
40 * Lists stars for a user.
41 *
42 * FROM: <https://api.slack.com/methods/stars.list>
43 *
44 * **Parameters:**
45 *
46 * * `token: &str` -- Authentication token. Requires scope: `stars:read`.
47 * * `count: &str`
48 * * `page: &str`
49 * * `cursor: &str` -- Parameter for pagination. Set `cursor` equal to the `next_cursor` attribute returned by the previous request's `response_metadata`. This parameter is optional, but pagination is mandatory: the default value simply fetches the first "page" of the collection. See [pagination](/docs/pagination) for more details.
50 * * `limit: i64` -- The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the list hasn't been reached.
51 */
52 pub async fn list(
53 &self,
54 count: &str,
55 page: &str,
56 cursor: &str,
57 limit: i64,
58 ) -> ClientResult<crate::Response<crate::types::StarsListSchema>> {
59 let mut query_args: Vec<(String, String)> = Default::default();
60 if !count.is_empty() {
61 query_args.push(("count".to_string(), count.to_string()));
62 }
63 if !cursor.is_empty() {
64 query_args.push(("cursor".to_string(), cursor.to_string()));
65 }
66 if limit > 0 {
67 query_args.push(("limit".to_string(), limit.to_string()));
68 }
69 if !page.is_empty() {
70 query_args.push(("page".to_string(), page.to_string()));
71 }
72 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
73 let url = self.client.url(&format!("/stars.list?{}", query_), None);
74 self.client
75 .get(
76 &url,
77 crate::Message {
78 body: None,
79 content_type: None,
80 },
81 )
82 .await
83 }
84 /**
85 * This function performs a `POST` to the `/stars.remove` endpoint.
86 *
87 * Removes a star from an item.
88 *
89 * FROM: <https://api.slack.com/methods/stars.remove>
90 *
91 * **Parameters:**
92 *
93 * * `token: &str` -- Authentication token. Requires scope: `stars:write`.
94 */
95 pub async fn remove(&self) -> ClientResult<crate::Response<crate::types::DndEndSchema>> {
96 let url = self.client.url("/stars.remove", None);
97 self.client
98 .post(
99 &url,
100 crate::Message {
101 body: None,
102 content_type: Some("application/x-www-form-urlencoded".to_string()),
103 },
104 )
105 .await
106 }
107}