1#![allow(unused_imports)]
4
5use crate::objects::*;
6use crate::{
7 CursorPaginated, NextCursor, ResponseMetadata, SlackApiMethod, SlackClient, SlackError,
8};
9use serde::{Deserialize, Serialize};
10
11#[doc(alias = "pins.add")]
15#[derive(Debug, Clone, PartialEq, Serialize)]
16#[non_exhaustive]
17pub struct PinsAddRequest {
18 pub channel: String,
20 #[serde(skip_serializing_if = "Option::is_none")]
22 pub timestamp: Option<String>,
23}
24
25impl PinsAddRequest {
26 pub fn new(channel: impl Into<String>) -> Self {
27 Self {
28 channel: channel.into(),
29 timestamp: None,
30 }
31 }
32
33 pub fn timestamp(mut self, timestamp: impl Into<String>) -> Self {
34 self.timestamp = Some(timestamp.into());
35 self
36 }
37}
38
39impl SlackApiMethod for PinsAddRequest {
40 const METHOD: &'static str = "pins.add";
41 type Response = PinsAddResponse;
42}
43
44#[doc(alias = "pins.add")]
46#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
47pub struct PinsAddResponse {
48 #[serde(flatten)]
50 pub extra: serde_json::Map<String, serde_json::Value>,
51 #[serde(
52 default,
53 deserialize_with = "crate::de::opt_object",
54 skip_serializing_if = "Option::is_none"
55 )]
56 pub response_metadata: Option<ResponseMetadata>,
57 #[serde(
58 default,
59 deserialize_with = "crate::de::opt_string",
60 skip_serializing_if = "Option::is_none"
61 )]
62 pub warning: Option<String>,
63}
64
65#[doc(alias = "pins.list")]
69#[derive(Debug, Clone, PartialEq, Serialize)]
70#[non_exhaustive]
71pub struct PinsListRequest {
72 pub channel: String,
74}
75
76impl PinsListRequest {
77 pub fn new(channel: impl Into<String>) -> Self {
78 Self {
79 channel: channel.into(),
80 }
81 }
82}
83
84impl SlackApiMethod for PinsListRequest {
85 const METHOD: &'static str = "pins.list";
86 type Response = PinsListResponse;
87}
88
89#[doc(alias = "pins.list")]
91#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
92pub struct PinsListResponse {
93 #[serde(
94 default,
95 deserialize_with = "crate::de::vec",
96 skip_serializing_if = "Vec::is_empty"
97 )]
98 pub items: Vec<PinsListResponseItems>,
99 #[serde(
100 default,
101 deserialize_with = "crate::de::opt_object",
102 skip_serializing_if = "Option::is_none"
103 )]
104 pub response_metadata: Option<ResponseMetadata>,
105 #[serde(
106 default,
107 deserialize_with = "crate::de::opt_string",
108 skip_serializing_if = "Option::is_none"
109 )]
110 pub warning: Option<String>,
111}
112
113#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
114pub struct PinsListResponseItems {
115 #[serde(
116 default,
117 deserialize_with = "crate::de::opt_string",
118 skip_serializing_if = "Option::is_none"
119 )]
120 pub channel: Option<String>,
121 #[serde(
122 default,
123 deserialize_with = "crate::de::opt_i64",
124 skip_serializing_if = "Option::is_none"
125 )]
126 pub created: Option<i64>,
127 #[serde(
128 default,
129 deserialize_with = "crate::de::opt_string",
130 skip_serializing_if = "Option::is_none"
131 )]
132 pub created_by: Option<String>,
133 #[serde(
134 default,
135 deserialize_with = "crate::de::opt_object",
136 skip_serializing_if = "Option::is_none"
137 )]
138 pub message: Option<Message>,
139 #[serde(
140 default,
141 deserialize_with = "crate::de::opt_string",
142 skip_serializing_if = "Option::is_none"
143 )]
144 pub r#type: Option<String>,
145}
146
147#[doc(alias = "pins.remove")]
151#[derive(Debug, Clone, PartialEq, Serialize)]
152#[non_exhaustive]
153pub struct PinsRemoveRequest {
154 pub channel: String,
156 #[serde(skip_serializing_if = "Option::is_none")]
158 pub timestamp: Option<String>,
159}
160
161impl PinsRemoveRequest {
162 pub fn new(channel: impl Into<String>) -> Self {
163 Self {
164 channel: channel.into(),
165 timestamp: None,
166 }
167 }
168
169 pub fn timestamp(mut self, timestamp: impl Into<String>) -> Self {
170 self.timestamp = Some(timestamp.into());
171 self
172 }
173}
174
175impl SlackApiMethod for PinsRemoveRequest {
176 const METHOD: &'static str = "pins.remove";
177 type Response = PinsRemoveResponse;
178}
179
180#[doc(alias = "pins.remove")]
182#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
183pub struct PinsRemoveResponse {
184 #[serde(flatten)]
186 pub extra: serde_json::Map<String, serde_json::Value>,
187 #[serde(
188 default,
189 deserialize_with = "crate::de::opt_object",
190 skip_serializing_if = "Option::is_none"
191 )]
192 pub response_metadata: Option<ResponseMetadata>,
193 #[serde(
194 default,
195 deserialize_with = "crate::de::opt_string",
196 skip_serializing_if = "Option::is_none"
197 )]
198 pub warning: Option<String>,
199}
200
201impl SlackClient {
202 #[doc(alias = "pins.add")]
215 pub async fn pins_add(&self, request: &PinsAddRequest) -> Result<PinsAddResponse, SlackError> {
216 self.call(request).await
217 }
218
219 #[doc(alias = "pins.list")]
232 pub async fn pins_list(
233 &self,
234 request: &PinsListRequest,
235 ) -> Result<PinsListResponse, SlackError> {
236 self.call(request).await
237 }
238
239 #[doc(alias = "pins.remove")]
252 pub async fn pins_remove(
253 &self,
254 request: &PinsRemoveRequest,
255 ) -> Result<PinsRemoveResponse, SlackError> {
256 self.call(request).await
257 }
258}