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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
// このファイルは codegen/generate.py が生成する。手で編集しない
#![allow(unused_imports)]
use crate::objects::*;
use crate::{
CursorPaginated, NextCursor, ResponseMetadata, SlackApiMethod, SlackClient, SlackError,
};
use serde::{Deserialize, Serialize};
/// Arguments for the Slack Web API method [`pins.add`](https://docs.slack.dev/reference/methods/pins.add): Pins an item to a channel.
///
/// Send it with [`SlackClient::pins_add`].
#[doc(alias = "pins.add")]
#[derive(Debug, Clone, PartialEq, Serialize)]
#[non_exhaustive]
pub struct PinsAddRequest {
/// Channel to pin the messsage to. You must also include a `timestamp` when pinning messages.
pub channel: String,
/// Timestamp of the message to pin. You must also include the `channel`.
#[serde(skip_serializing_if = "Option::is_none")]
pub timestamp: Option<String>,
}
impl PinsAddRequest {
pub fn new(channel: impl Into<String>) -> Self {
Self {
channel: channel.into(),
timestamp: None,
}
}
pub fn timestamp(mut self, timestamp: impl Into<String>) -> Self {
self.timestamp = Some(timestamp.into());
self
}
}
impl SlackApiMethod for PinsAddRequest {
const METHOD: &'static str = "pins.add";
type Response = PinsAddResponse;
}
/// Successful response of the Slack Web API method [`pins.add`](https://docs.slack.dev/reference/methods/pins.add).
#[doc(alias = "pins.add")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct PinsAddResponse {
/// Fields returned by Slack. This method has no documented response example.
#[serde(flatten)]
pub extra: serde_json::Map<String, serde_json::Value>,
#[serde(
default,
deserialize_with = "crate::de::opt_object",
skip_serializing_if = "Option::is_none"
)]
pub response_metadata: Option<ResponseMetadata>,
#[serde(
default,
deserialize_with = "crate::de::opt_string",
skip_serializing_if = "Option::is_none"
)]
pub warning: Option<String>,
}
/// Arguments for the Slack Web API method [`pins.list`](https://docs.slack.dev/reference/methods/pins.list): Lists items pinned to a channel.
///
/// Send it with [`SlackClient::pins_list`].
#[doc(alias = "pins.list")]
#[derive(Debug, Clone, PartialEq, Serialize)]
#[non_exhaustive]
pub struct PinsListRequest {
/// Channel to get pinned items for.
pub channel: String,
}
impl PinsListRequest {
pub fn new(channel: impl Into<String>) -> Self {
Self {
channel: channel.into(),
}
}
}
impl SlackApiMethod for PinsListRequest {
const METHOD: &'static str = "pins.list";
type Response = PinsListResponse;
}
/// Successful response of the Slack Web API method [`pins.list`](https://docs.slack.dev/reference/methods/pins.list).
#[doc(alias = "pins.list")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct PinsListResponse {
#[serde(
default,
deserialize_with = "crate::de::vec",
skip_serializing_if = "Vec::is_empty"
)]
pub items: Vec<PinsListResponseItems>,
#[serde(
default,
deserialize_with = "crate::de::opt_object",
skip_serializing_if = "Option::is_none"
)]
pub response_metadata: Option<ResponseMetadata>,
#[serde(
default,
deserialize_with = "crate::de::opt_string",
skip_serializing_if = "Option::is_none"
)]
pub warning: Option<String>,
}
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct PinsListResponseItems {
#[serde(
default,
deserialize_with = "crate::de::opt_string",
skip_serializing_if = "Option::is_none"
)]
pub channel: Option<String>,
#[serde(
default,
deserialize_with = "crate::de::opt_i64",
skip_serializing_if = "Option::is_none"
)]
pub created: Option<i64>,
#[serde(
default,
deserialize_with = "crate::de::opt_string",
skip_serializing_if = "Option::is_none"
)]
pub created_by: Option<String>,
#[serde(
default,
deserialize_with = "crate::de::opt_object",
skip_serializing_if = "Option::is_none"
)]
pub message: Option<Message>,
#[serde(
default,
deserialize_with = "crate::de::opt_string",
skip_serializing_if = "Option::is_none"
)]
pub r#type: Option<String>,
}
/// Arguments for the Slack Web API method [`pins.remove`](https://docs.slack.dev/reference/methods/pins.remove): Un-pins an item from a channel.
///
/// Send it with [`SlackClient::pins_remove`].
#[doc(alias = "pins.remove")]
#[derive(Debug, Clone, PartialEq, Serialize)]
#[non_exhaustive]
pub struct PinsRemoveRequest {
/// Channel where the item is pinned to.
pub channel: String,
/// Timestamp of the message to un-pin.
#[serde(skip_serializing_if = "Option::is_none")]
pub timestamp: Option<String>,
}
impl PinsRemoveRequest {
pub fn new(channel: impl Into<String>) -> Self {
Self {
channel: channel.into(),
timestamp: None,
}
}
pub fn timestamp(mut self, timestamp: impl Into<String>) -> Self {
self.timestamp = Some(timestamp.into());
self
}
}
impl SlackApiMethod for PinsRemoveRequest {
const METHOD: &'static str = "pins.remove";
type Response = PinsRemoveResponse;
}
/// Successful response of the Slack Web API method [`pins.remove`](https://docs.slack.dev/reference/methods/pins.remove).
#[doc(alias = "pins.remove")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct PinsRemoveResponse {
/// Fields returned by Slack. This method has no documented response example.
#[serde(flatten)]
pub extra: serde_json::Map<String, serde_json::Value>,
#[serde(
default,
deserialize_with = "crate::de::opt_object",
skip_serializing_if = "Option::is_none"
)]
pub response_metadata: Option<ResponseMetadata>,
#[serde(
default,
deserialize_with = "crate::de::opt_string",
skip_serializing_if = "Option::is_none"
)]
pub warning: Option<String>,
}
impl SlackClient {
/// Calls the Slack Web API method [`pins.add`](https://docs.slack.dev/reference/methods/pins.add): Pins an item to a channel.
///
/// Required scopes:
///
/// - bot token: `pins:write`
/// - user token: `pins:write`
///
/// Rate limit: Tier 2 (<https://docs.slack.dev/apis/web-api/rate-limits>).
///
/// # Errors
///
/// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
#[doc(alias = "pins.add")]
pub async fn pins_add(&self, request: &PinsAddRequest) -> Result<PinsAddResponse, SlackError> {
self.call(request).await
}
/// Calls the Slack Web API method [`pins.list`](https://docs.slack.dev/reference/methods/pins.list): Lists items pinned to a channel.
///
/// Required scopes:
///
/// - bot token: `pins:read`
/// - user token: `pins:read`
///
/// Rate limit: Tier 2 (<https://docs.slack.dev/apis/web-api/rate-limits>).
///
/// # Errors
///
/// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
#[doc(alias = "pins.list")]
pub async fn pins_list(
&self,
request: &PinsListRequest,
) -> Result<PinsListResponse, SlackError> {
self.call(request).await
}
/// Calls the Slack Web API method [`pins.remove`](https://docs.slack.dev/reference/methods/pins.remove): Un-pins an item from a channel.
///
/// Required scopes:
///
/// - bot token: `pins:write`
/// - user token: `pins:write`
///
/// Rate limit: Tier 2 (<https://docs.slack.dev/apis/web-api/rate-limits>).
///
/// # Errors
///
/// Returns [`SlackError::Api`] when Slack answers `"ok": false`; see [`SlackClient::call`] for the other cases.
#[doc(alias = "pins.remove")]
pub async fn pins_remove(
&self,
request: &PinsRemoveRequest,
) -> Result<PinsRemoveResponse, SlackError> {
self.call(request).await
}
}