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 = "rtm.connect")]
15#[derive(Debug, Clone, PartialEq, Serialize, Default)]
16#[non_exhaustive]
17pub struct RtmConnectRequest {
18 #[serde(skip_serializing_if = "Option::is_none")]
20 pub batch_presence_aware: Option<bool>,
21 #[serde(skip_serializing_if = "Option::is_none")]
23 pub presence_sub: Option<bool>,
24}
25
26impl RtmConnectRequest {
27 pub fn new() -> Self {
28 Self {
29 batch_presence_aware: None,
30 presence_sub: None,
31 }
32 }
33
34 pub fn batch_presence_aware(mut self, batch_presence_aware: bool) -> Self {
35 self.batch_presence_aware = Some(batch_presence_aware);
36 self
37 }
38
39 pub fn presence_sub(mut self, presence_sub: bool) -> Self {
40 self.presence_sub = Some(presence_sub);
41 self
42 }
43}
44
45impl SlackApiMethod for RtmConnectRequest {
46 const METHOD: &'static str = "rtm.connect";
47 type Response = RtmConnectResponse;
48}
49
50#[doc(alias = "rtm.connect")]
52#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
53pub struct RtmConnectResponse {
54 #[serde(
55 rename = "self",
56 default,
57 deserialize_with = "crate::de::opt_object",
58 skip_serializing_if = "Option::is_none"
59 )]
60 pub self_: Option<RtmConnectResponseSelf>,
61 #[serde(
62 default,
63 deserialize_with = "crate::de::opt_object",
64 skip_serializing_if = "Option::is_none"
65 )]
66 pub team: Option<Team>,
67 #[serde(
68 default,
69 deserialize_with = "crate::de::opt_string",
70 skip_serializing_if = "Option::is_none"
71 )]
72 pub url: Option<String>,
73 #[serde(
74 default,
75 deserialize_with = "crate::de::opt_object",
76 skip_serializing_if = "Option::is_none"
77 )]
78 pub response_metadata: Option<ResponseMetadata>,
79 #[serde(
80 default,
81 deserialize_with = "crate::de::opt_string",
82 skip_serializing_if = "Option::is_none"
83 )]
84 pub warning: Option<String>,
85}
86
87#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
88pub struct RtmConnectResponseSelf {
89 #[serde(
90 default,
91 deserialize_with = "crate::de::opt_string",
92 skip_serializing_if = "Option::is_none"
93 )]
94 pub id: Option<String>,
95 #[serde(
96 default,
97 deserialize_with = "crate::de::opt_string",
98 skip_serializing_if = "Option::is_none"
99 )]
100 pub name: Option<String>,
101}
102
103#[doc(alias = "rtm.start")]
107#[derive(Debug, Clone, PartialEq, Serialize, Default)]
108#[non_exhaustive]
109pub struct RtmStartRequest {
110 #[serde(skip_serializing_if = "Option::is_none")]
112 pub simple_latest: Option<bool>,
113 #[serde(skip_serializing_if = "Option::is_none")]
115 pub no_unreads: Option<bool>,
116 #[serde(skip_serializing_if = "Option::is_none")]
118 pub mpim_aware: Option<bool>,
119 #[serde(skip_serializing_if = "Option::is_none")]
121 pub presence_sub: Option<bool>,
122 #[serde(skip_serializing_if = "Option::is_none")]
124 pub batch_presence_aware: Option<bool>,
125 #[serde(skip_serializing_if = "Option::is_none")]
127 pub no_latest: Option<bool>,
128 #[serde(skip_serializing_if = "Option::is_none")]
130 pub include_locale: Option<bool>,
131}
132
133impl RtmStartRequest {
134 pub fn new() -> Self {
135 Self {
136 simple_latest: None,
137 no_unreads: None,
138 mpim_aware: None,
139 presence_sub: None,
140 batch_presence_aware: None,
141 no_latest: None,
142 include_locale: None,
143 }
144 }
145
146 pub fn simple_latest(mut self, simple_latest: bool) -> Self {
147 self.simple_latest = Some(simple_latest);
148 self
149 }
150
151 pub fn no_unreads(mut self, no_unreads: bool) -> Self {
152 self.no_unreads = Some(no_unreads);
153 self
154 }
155
156 pub fn mpim_aware(mut self, mpim_aware: bool) -> Self {
157 self.mpim_aware = Some(mpim_aware);
158 self
159 }
160
161 pub fn presence_sub(mut self, presence_sub: bool) -> Self {
162 self.presence_sub = Some(presence_sub);
163 self
164 }
165
166 pub fn batch_presence_aware(mut self, batch_presence_aware: bool) -> Self {
167 self.batch_presence_aware = Some(batch_presence_aware);
168 self
169 }
170
171 pub fn no_latest(mut self, no_latest: bool) -> Self {
172 self.no_latest = Some(no_latest);
173 self
174 }
175
176 pub fn include_locale(mut self, include_locale: bool) -> Self {
177 self.include_locale = Some(include_locale);
178 self
179 }
180}
181
182impl SlackApiMethod for RtmStartRequest {
183 const METHOD: &'static str = "rtm.start";
184 type Response = RtmStartResponse;
185}
186
187#[doc(alias = "rtm.start")]
189#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
190pub struct RtmStartResponse {
191 #[serde(flatten)]
193 pub extra: serde_json::Map<String, serde_json::Value>,
194 #[serde(
195 default,
196 deserialize_with = "crate::de::opt_object",
197 skip_serializing_if = "Option::is_none"
198 )]
199 pub response_metadata: Option<ResponseMetadata>,
200 #[serde(
201 default,
202 deserialize_with = "crate::de::opt_string",
203 skip_serializing_if = "Option::is_none"
204 )]
205 pub warning: Option<String>,
206}
207
208impl SlackClient {
209 #[doc(alias = "rtm.connect")]
217 pub async fn rtm_connect(
218 &self,
219 request: &RtmConnectRequest,
220 ) -> Result<RtmConnectResponse, SlackError> {
221 self.call(request).await
222 }
223
224 #[doc(alias = "rtm.start")]
232 pub async fn rtm_start(
233 &self,
234 request: &RtmStartRequest,
235 ) -> Result<RtmStartResponse, SlackError> {
236 self.call(request).await
237 }
238}