#![allow(unused_imports)]
use crate::objects::*;
use crate::{
CursorPaginated, NextCursor, ResponseMetadata, SlackApiMethod, SlackClient, SlackError,
};
use serde::{Deserialize, Serialize};
#[doc(alias = "chat.appendStream")]
#[derive(Debug, Clone, PartialEq, Serialize)]
#[non_exhaustive]
pub struct ChatAppendStreamRequest {
pub channel: String,
pub ts: String,
#[serde(
skip_serializing_if = "Option::is_none",
serialize_with = "crate::form::as_json"
)]
pub chunks: Option<Vec<serde_json::Value>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub markdown_text: Option<String>,
}
impl ChatAppendStreamRequest {
pub fn new(channel: impl Into<String>, ts: impl Into<String>) -> Self {
Self {
channel: channel.into(),
ts: ts.into(),
chunks: None,
markdown_text: None,
}
}
pub fn chunks(mut self, chunks: Vec<serde_json::Value>) -> Self {
self.chunks = Some(chunks);
self
}
pub fn markdown_text(mut self, markdown_text: impl Into<String>) -> Self {
self.markdown_text = Some(markdown_text.into());
self
}
}
impl SlackApiMethod for ChatAppendStreamRequest {
const METHOD: &'static str = "chat.appendStream";
type Response = ChatAppendStreamResponse;
}
#[doc(alias = "chat.appendStream")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ChatAppendStreamResponse {
#[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_string",
skip_serializing_if = "Option::is_none"
)]
pub ts: Option<String>,
#[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>,
}
#[doc(alias = "chat.delete")]
#[derive(Debug, Clone, PartialEq, Serialize)]
#[non_exhaustive]
pub struct ChatDeleteRequest {
pub channel: String,
pub ts: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub as_user: Option<bool>,
}
impl ChatDeleteRequest {
pub fn new(channel: impl Into<String>, ts: impl Into<String>) -> Self {
Self {
channel: channel.into(),
ts: ts.into(),
as_user: None,
}
}
pub fn as_user(mut self, as_user: bool) -> Self {
self.as_user = Some(as_user);
self
}
}
impl SlackApiMethod for ChatDeleteRequest {
const METHOD: &'static str = "chat.delete";
type Response = ChatDeleteResponse;
}
#[doc(alias = "chat.delete")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ChatDeleteResponse {
#[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_string",
skip_serializing_if = "Option::is_none"
)]
pub ts: Option<String>,
#[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>,
}
#[doc(alias = "chat.deleteScheduledMessage")]
#[derive(Debug, Clone, PartialEq, Serialize)]
#[non_exhaustive]
pub struct ChatDeleteScheduledMessageRequest {
pub channel: String,
pub scheduled_message_id: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub as_user: Option<bool>,
}
impl ChatDeleteScheduledMessageRequest {
pub fn new(channel: impl Into<String>, scheduled_message_id: impl Into<String>) -> Self {
Self {
channel: channel.into(),
scheduled_message_id: scheduled_message_id.into(),
as_user: None,
}
}
pub fn as_user(mut self, as_user: bool) -> Self {
self.as_user = Some(as_user);
self
}
}
impl SlackApiMethod for ChatDeleteScheduledMessageRequest {
const METHOD: &'static str = "chat.deleteScheduledMessage";
type Response = ChatDeleteScheduledMessageResponse;
}
#[doc(alias = "chat.deleteScheduledMessage")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ChatDeleteScheduledMessageResponse {
#[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>,
}
#[doc(alias = "chat.getPermalink")]
#[derive(Debug, Clone, PartialEq, Serialize)]
#[non_exhaustive]
pub struct ChatGetPermalinkRequest {
pub channel: String,
pub message_ts: String,
}
impl ChatGetPermalinkRequest {
pub fn new(channel: impl Into<String>, message_ts: impl Into<String>) -> Self {
Self {
channel: channel.into(),
message_ts: message_ts.into(),
}
}
}
impl SlackApiMethod for ChatGetPermalinkRequest {
const METHOD: &'static str = "chat.getPermalink";
type Response = ChatGetPermalinkResponse;
}
#[doc(alias = "chat.getPermalink")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ChatGetPermalinkResponse {
#[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_string",
skip_serializing_if = "Option::is_none"
)]
pub permalink: Option<String>,
#[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>,
}
#[doc(alias = "chat.meMessage")]
#[derive(Debug, Clone, PartialEq, Serialize)]
#[non_exhaustive]
pub struct ChatMeMessageRequest {
pub channel: String,
pub text: String,
}
impl ChatMeMessageRequest {
pub fn new(channel: impl Into<String>, text: impl Into<String>) -> Self {
Self {
channel: channel.into(),
text: text.into(),
}
}
}
impl SlackApiMethod for ChatMeMessageRequest {
const METHOD: &'static str = "chat.meMessage";
type Response = ChatMeMessageResponse;
}
#[doc(alias = "chat.meMessage")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ChatMeMessageResponse {
#[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_string",
skip_serializing_if = "Option::is_none"
)]
pub ts: Option<String>,
#[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>,
}
#[doc(alias = "chat.postEphemeral")]
#[derive(Debug, Clone, PartialEq, Serialize)]
#[non_exhaustive]
pub struct ChatPostEphemeralRequest {
pub channel: String,
pub user: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub as_user: Option<bool>,
#[serde(
skip_serializing_if = "Option::is_none",
serialize_with = "crate::form::as_json"
)]
pub attachments: Option<Vec<crate::blocks::Attachment>>,
#[serde(
skip_serializing_if = "Option::is_none",
serialize_with = "crate::form::as_json"
)]
pub blocks: Option<Vec<crate::blocks::Block>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub icon_emoji: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub icon_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub link_names: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub markdown_text: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata: Option<crate::blocks::MessageMetadata>,
#[serde(skip_serializing_if = "Option::is_none")]
pub parse: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub text: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub thread_ts: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub username: Option<String>,
}
impl ChatPostEphemeralRequest {
pub fn new(channel: impl Into<String>, user: impl Into<String>) -> Self {
Self {
channel: channel.into(),
user: user.into(),
as_user: None,
attachments: None,
blocks: None,
icon_emoji: None,
icon_url: None,
link_names: None,
markdown_text: None,
metadata: None,
parse: None,
text: None,
thread_ts: None,
username: None,
}
}
pub fn as_user(mut self, as_user: bool) -> Self {
self.as_user = Some(as_user);
self
}
pub fn attachments(mut self, attachments: Vec<crate::blocks::Attachment>) -> Self {
self.attachments = Some(attachments);
self
}
pub fn blocks(mut self, blocks: Vec<crate::blocks::Block>) -> Self {
self.blocks = Some(blocks);
self
}
pub fn icon_emoji(mut self, icon_emoji: impl Into<String>) -> Self {
self.icon_emoji = Some(icon_emoji.into());
self
}
pub fn icon_url(mut self, icon_url: impl Into<String>) -> Self {
self.icon_url = Some(icon_url.into());
self
}
pub fn link_names(mut self, link_names: bool) -> Self {
self.link_names = Some(link_names);
self
}
pub fn markdown_text(mut self, markdown_text: impl Into<String>) -> Self {
self.markdown_text = Some(markdown_text.into());
self
}
pub fn metadata(mut self, metadata: crate::blocks::MessageMetadata) -> Self {
self.metadata = Some(metadata);
self
}
pub fn parse(mut self, parse: impl Into<String>) -> Self {
self.parse = Some(parse.into());
self
}
pub fn text(mut self, text: impl Into<String>) -> Self {
self.text = Some(text.into());
self
}
pub fn thread_ts(mut self, thread_ts: impl Into<String>) -> Self {
self.thread_ts = Some(thread_ts.into());
self
}
pub fn username(mut self, username: impl Into<String>) -> Self {
self.username = Some(username.into());
self
}
}
impl SlackApiMethod for ChatPostEphemeralRequest {
const METHOD: &'static str = "chat.postEphemeral";
type Response = ChatPostEphemeralResponse;
}
#[doc(alias = "chat.postEphemeral")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ChatPostEphemeralResponse {
#[serde(
default,
deserialize_with = "crate::de::opt_string",
skip_serializing_if = "Option::is_none"
)]
pub message_ts: Option<String>,
#[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>,
}
#[doc(alias = "chat.postMessage")]
#[derive(Debug, Clone, PartialEq, Serialize)]
#[non_exhaustive]
pub struct ChatPostMessageRequest {
pub channel: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub as_user: Option<bool>,
#[serde(
skip_serializing_if = "Option::is_none",
serialize_with = "crate::form::as_json"
)]
pub attachments: Option<Vec<crate::blocks::Attachment>>,
#[serde(
skip_serializing_if = "Option::is_none",
serialize_with = "crate::form::as_json"
)]
pub blocks: Option<Vec<crate::blocks::Block>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub current_draft_last_updated_ts: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub icon_emoji: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub icon_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub link_names: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub markdown_text: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata: Option<crate::blocks::MessageMetadata>,
#[serde(skip_serializing_if = "Option::is_none")]
pub mrkdwn: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub parse: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub reply_broadcast: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub text: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub thread_ts: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub unfurl_links: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub unfurl_media: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub username: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub unfurl_app_links: Option<bool>,
}
impl ChatPostMessageRequest {
pub fn new(channel: impl Into<String>) -> Self {
Self {
channel: channel.into(),
as_user: None,
attachments: None,
blocks: None,
current_draft_last_updated_ts: None,
icon_emoji: None,
icon_url: None,
link_names: None,
markdown_text: None,
metadata: None,
mrkdwn: None,
parse: None,
reply_broadcast: None,
text: None,
thread_ts: None,
unfurl_links: None,
unfurl_media: None,
username: None,
unfurl_app_links: None,
}
}
pub fn as_user(mut self, as_user: bool) -> Self {
self.as_user = Some(as_user);
self
}
pub fn attachments(mut self, attachments: Vec<crate::blocks::Attachment>) -> Self {
self.attachments = Some(attachments);
self
}
pub fn blocks(mut self, blocks: Vec<crate::blocks::Block>) -> Self {
self.blocks = Some(blocks);
self
}
pub fn current_draft_last_updated_ts(
mut self,
current_draft_last_updated_ts: impl Into<String>,
) -> Self {
self.current_draft_last_updated_ts = Some(current_draft_last_updated_ts.into());
self
}
pub fn icon_emoji(mut self, icon_emoji: impl Into<String>) -> Self {
self.icon_emoji = Some(icon_emoji.into());
self
}
pub fn icon_url(mut self, icon_url: impl Into<String>) -> Self {
self.icon_url = Some(icon_url.into());
self
}
pub fn link_names(mut self, link_names: bool) -> Self {
self.link_names = Some(link_names);
self
}
pub fn markdown_text(mut self, markdown_text: impl Into<String>) -> Self {
self.markdown_text = Some(markdown_text.into());
self
}
pub fn metadata(mut self, metadata: crate::blocks::MessageMetadata) -> Self {
self.metadata = Some(metadata);
self
}
pub fn mrkdwn(mut self, mrkdwn: bool) -> Self {
self.mrkdwn = Some(mrkdwn);
self
}
pub fn parse(mut self, parse: impl Into<String>) -> Self {
self.parse = Some(parse.into());
self
}
pub fn reply_broadcast(mut self, reply_broadcast: bool) -> Self {
self.reply_broadcast = Some(reply_broadcast);
self
}
pub fn text(mut self, text: impl Into<String>) -> Self {
self.text = Some(text.into());
self
}
pub fn thread_ts(mut self, thread_ts: impl Into<String>) -> Self {
self.thread_ts = Some(thread_ts.into());
self
}
pub fn unfurl_links(mut self, unfurl_links: bool) -> Self {
self.unfurl_links = Some(unfurl_links);
self
}
pub fn unfurl_media(mut self, unfurl_media: bool) -> Self {
self.unfurl_media = Some(unfurl_media);
self
}
pub fn username(mut self, username: impl Into<String>) -> Self {
self.username = Some(username.into());
self
}
pub fn unfurl_app_links(mut self, unfurl_app_links: bool) -> Self {
self.unfurl_app_links = Some(unfurl_app_links);
self
}
}
impl SlackApiMethod for ChatPostMessageRequest {
const METHOD: &'static str = "chat.postMessage";
type Response = ChatPostMessageResponse;
}
#[doc(alias = "chat.postMessage")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ChatPostMessageResponse {
#[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_string",
skip_serializing_if = "Option::is_none"
)]
pub ts: 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_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>,
}
#[doc(alias = "chat.scheduleMessage")]
#[derive(Debug, Clone, PartialEq, Serialize)]
#[non_exhaustive]
pub struct ChatScheduleMessageRequest {
pub channel: String,
pub post_at: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub as_user: Option<bool>,
#[serde(
skip_serializing_if = "Option::is_none",
serialize_with = "crate::form::as_json"
)]
pub attachments: Option<Vec<crate::blocks::Attachment>>,
#[serde(
skip_serializing_if = "Option::is_none",
serialize_with = "crate::form::as_json"
)]
pub blocks: Option<Vec<crate::blocks::Block>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub link_names: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub markdown_text: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub parse: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub reply_broadcast: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub text: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub thread_ts: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub unfurl_links: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub unfurl_media: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata: Option<crate::blocks::MessageMetadata>,
}
impl ChatScheduleMessageRequest {
pub fn new(channel: impl Into<String>, post_at: i64) -> Self {
Self {
channel: channel.into(),
post_at,
as_user: None,
attachments: None,
blocks: None,
link_names: None,
markdown_text: None,
parse: None,
reply_broadcast: None,
text: None,
thread_ts: None,
unfurl_links: None,
unfurl_media: None,
metadata: None,
}
}
pub fn as_user(mut self, as_user: bool) -> Self {
self.as_user = Some(as_user);
self
}
pub fn attachments(mut self, attachments: Vec<crate::blocks::Attachment>) -> Self {
self.attachments = Some(attachments);
self
}
pub fn blocks(mut self, blocks: Vec<crate::blocks::Block>) -> Self {
self.blocks = Some(blocks);
self
}
pub fn link_names(mut self, link_names: bool) -> Self {
self.link_names = Some(link_names);
self
}
pub fn markdown_text(mut self, markdown_text: impl Into<String>) -> Self {
self.markdown_text = Some(markdown_text.into());
self
}
pub fn parse(mut self, parse: impl Into<String>) -> Self {
self.parse = Some(parse.into());
self
}
pub fn reply_broadcast(mut self, reply_broadcast: bool) -> Self {
self.reply_broadcast = Some(reply_broadcast);
self
}
pub fn text(mut self, text: impl Into<String>) -> Self {
self.text = Some(text.into());
self
}
pub fn thread_ts(mut self, thread_ts: impl Into<String>) -> Self {
self.thread_ts = Some(thread_ts.into());
self
}
pub fn unfurl_links(mut self, unfurl_links: bool) -> Self {
self.unfurl_links = Some(unfurl_links);
self
}
pub fn unfurl_media(mut self, unfurl_media: bool) -> Self {
self.unfurl_media = Some(unfurl_media);
self
}
pub fn metadata(mut self, metadata: crate::blocks::MessageMetadata) -> Self {
self.metadata = Some(metadata);
self
}
}
impl SlackApiMethod for ChatScheduleMessageRequest {
const METHOD: &'static str = "chat.scheduleMessage";
type Response = ChatScheduleMessageResponse;
}
#[doc(alias = "chat.scheduleMessage")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ChatScheduleMessageResponse {
#[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_string",
skip_serializing_if = "Option::is_none"
)]
pub scheduled_message_id: Option<String>,
#[serde(
default,
deserialize_with = "crate::de::opt_string",
skip_serializing_if = "Option::is_none"
)]
pub post_at: Option<String>,
#[serde(
default,
deserialize_with = "crate::de::opt_object",
skip_serializing_if = "Option::is_none"
)]
pub message: Option<ChatScheduleMessageResponseMessage>,
#[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 ChatScheduleMessageResponseMessage {
#[serde(
default,
deserialize_with = "crate::de::opt_string",
skip_serializing_if = "Option::is_none"
)]
pub text: Option<String>,
#[serde(
default,
deserialize_with = "crate::de::opt_string",
skip_serializing_if = "Option::is_none"
)]
pub username: Option<String>,
#[serde(
default,
deserialize_with = "crate::de::opt_string",
skip_serializing_if = "Option::is_none"
)]
pub bot_id: Option<String>,
#[serde(
default,
deserialize_with = "crate::de::vec",
skip_serializing_if = "Vec::is_empty"
)]
pub attachments: Vec<MessageAttachment>,
#[serde(
default,
deserialize_with = "crate::de::opt_string",
skip_serializing_if = "Option::is_none"
)]
pub r#type: Option<String>,
#[serde(
default,
deserialize_with = "crate::de::opt_string",
skip_serializing_if = "Option::is_none"
)]
pub subtype: Option<String>,
}
#[doc(alias = "chat.scheduledMessages.list")]
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
#[non_exhaustive]
pub struct ChatScheduledMessagesListRequest {
#[serde(skip_serializing_if = "Option::is_none")]
pub channel: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub cursor: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub latest: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub oldest: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub team_id: Option<String>,
}
impl ChatScheduledMessagesListRequest {
pub fn new() -> Self {
Self {
channel: None,
cursor: None,
latest: None,
limit: None,
oldest: None,
team_id: None,
}
}
pub fn channel(mut self, channel: impl Into<String>) -> Self {
self.channel = Some(channel.into());
self
}
pub fn cursor(mut self, cursor: impl Into<String>) -> Self {
self.cursor = Some(cursor.into());
self
}
pub fn latest(mut self, latest: impl Into<String>) -> Self {
self.latest = Some(latest.into());
self
}
pub fn limit(mut self, limit: i64) -> Self {
self.limit = Some(limit);
self
}
pub fn oldest(mut self, oldest: impl Into<String>) -> Self {
self.oldest = Some(oldest.into());
self
}
pub fn team_id(mut self, team_id: impl Into<String>) -> Self {
self.team_id = Some(team_id.into());
self
}
}
impl SlackApiMethod for ChatScheduledMessagesListRequest {
const METHOD: &'static str = "chat.scheduledMessages.list";
type Response = ChatScheduledMessagesListResponse;
}
impl CursorPaginated for ChatScheduledMessagesListRequest {
fn set_cursor(&mut self, cursor: String) {
self.cursor = Some(cursor);
}
}
impl NextCursor for ChatScheduledMessagesListResponse {
fn next_cursor(&self) -> Option<&str> {
self.response_metadata.as_ref()?.next_cursor.as_deref()
}
}
#[doc(alias = "chat.scheduledMessages.list")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ChatScheduledMessagesListResponse {
#[serde(
default,
deserialize_with = "crate::de::vec",
skip_serializing_if = "Vec::is_empty"
)]
pub scheduled_messages: Vec<ChatScheduledMessagesListResponseScheduledMessages>,
#[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 ChatScheduledMessagesListResponseScheduledMessages {
#[serde(
default,
deserialize_with = "crate::de::opt_i64",
skip_serializing_if = "Option::is_none"
)]
pub id: Option<i64>,
#[serde(
default,
deserialize_with = "crate::de::opt_string",
skip_serializing_if = "Option::is_none"
)]
pub channel_id: Option<String>,
#[serde(
default,
deserialize_with = "crate::de::opt_i64",
skip_serializing_if = "Option::is_none"
)]
pub post_at: Option<i64>,
#[serde(
default,
deserialize_with = "crate::de::opt_i64",
skip_serializing_if = "Option::is_none"
)]
pub date_created: Option<i64>,
#[serde(
default,
deserialize_with = "crate::de::opt_string",
skip_serializing_if = "Option::is_none"
)]
pub text: Option<String>,
}
#[doc(alias = "chat.startStream")]
#[derive(Debug, Clone, PartialEq, Serialize)]
#[non_exhaustive]
pub struct ChatStartStreamRequest {
pub channel: String,
#[serde(
skip_serializing_if = "Option::is_none",
serialize_with = "crate::form::as_json"
)]
pub chunks: Option<Vec<serde_json::Value>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub markdown_text: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub thread_ts: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub recipient_user_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub recipient_team_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub task_display_mode: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub icon_emoji: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub icon_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub username: Option<String>,
}
impl ChatStartStreamRequest {
pub fn new(channel: impl Into<String>) -> Self {
Self {
channel: channel.into(),
chunks: None,
markdown_text: None,
thread_ts: None,
recipient_user_id: None,
recipient_team_id: None,
task_display_mode: None,
icon_emoji: None,
icon_url: None,
username: None,
}
}
pub fn chunks(mut self, chunks: Vec<serde_json::Value>) -> Self {
self.chunks = Some(chunks);
self
}
pub fn markdown_text(mut self, markdown_text: impl Into<String>) -> Self {
self.markdown_text = Some(markdown_text.into());
self
}
pub fn thread_ts(mut self, thread_ts: impl Into<String>) -> Self {
self.thread_ts = Some(thread_ts.into());
self
}
pub fn recipient_user_id(mut self, recipient_user_id: impl Into<String>) -> Self {
self.recipient_user_id = Some(recipient_user_id.into());
self
}
pub fn recipient_team_id(mut self, recipient_team_id: impl Into<String>) -> Self {
self.recipient_team_id = Some(recipient_team_id.into());
self
}
pub fn task_display_mode(mut self, task_display_mode: impl Into<String>) -> Self {
self.task_display_mode = Some(task_display_mode.into());
self
}
pub fn icon_emoji(mut self, icon_emoji: impl Into<String>) -> Self {
self.icon_emoji = Some(icon_emoji.into());
self
}
pub fn icon_url(mut self, icon_url: impl Into<String>) -> Self {
self.icon_url = Some(icon_url.into());
self
}
pub fn username(mut self, username: impl Into<String>) -> Self {
self.username = Some(username.into());
self
}
}
impl SlackApiMethod for ChatStartStreamRequest {
const METHOD: &'static str = "chat.startStream";
type Response = ChatStartStreamResponse;
}
#[doc(alias = "chat.startStream")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ChatStartStreamResponse {
#[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_string",
skip_serializing_if = "Option::is_none"
)]
pub ts: Option<String>,
#[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>,
}
#[doc(alias = "chat.stopStream")]
#[derive(Debug, Clone, PartialEq, Serialize)]
#[non_exhaustive]
pub struct ChatStopStreamRequest {
pub channel: String,
pub ts: String,
#[serde(
skip_serializing_if = "Option::is_none",
serialize_with = "crate::form::as_json"
)]
pub chunks: Option<Vec<serde_json::Value>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub markdown_text: Option<String>,
#[serde(
skip_serializing_if = "Option::is_none",
serialize_with = "crate::form::as_json"
)]
pub blocks: Option<Vec<crate::blocks::Block>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata: Option<crate::blocks::MessageMetadata>,
#[serde(skip_serializing_if = "Option::is_none")]
pub session_status: Option<String>,
}
impl ChatStopStreamRequest {
pub fn new(channel: impl Into<String>, ts: impl Into<String>) -> Self {
Self {
channel: channel.into(),
ts: ts.into(),
chunks: None,
markdown_text: None,
blocks: None,
metadata: None,
session_status: None,
}
}
pub fn chunks(mut self, chunks: Vec<serde_json::Value>) -> Self {
self.chunks = Some(chunks);
self
}
pub fn markdown_text(mut self, markdown_text: impl Into<String>) -> Self {
self.markdown_text = Some(markdown_text.into());
self
}
pub fn blocks(mut self, blocks: Vec<crate::blocks::Block>) -> Self {
self.blocks = Some(blocks);
self
}
pub fn metadata(mut self, metadata: crate::blocks::MessageMetadata) -> Self {
self.metadata = Some(metadata);
self
}
pub fn session_status(mut self, session_status: impl Into<String>) -> Self {
self.session_status = Some(session_status.into());
self
}
}
impl SlackApiMethod for ChatStopStreamRequest {
const METHOD: &'static str = "chat.stopStream";
type Response = ChatStopStreamResponse;
}
#[doc(alias = "chat.stopStream")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ChatStopStreamResponse {
#[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_string",
skip_serializing_if = "Option::is_none"
)]
pub ts: 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_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>,
}
#[doc(alias = "chat.unfurl")]
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
#[non_exhaustive]
pub struct ChatUnfurlRequest {
#[serde(skip_serializing_if = "Option::is_none")]
pub channel: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub ts: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub unfurls: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub user_auth_message: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub user_auth_required: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub user_auth_url: Option<String>,
#[serde(
skip_serializing_if = "Option::is_none",
serialize_with = "crate::form::as_json"
)]
pub user_auth_blocks: Option<Vec<crate::blocks::Block>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub unfurl_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub source: Option<String>,
}
impl ChatUnfurlRequest {
pub fn new() -> Self {
Self {
channel: None,
ts: None,
unfurls: None,
user_auth_message: None,
user_auth_required: None,
user_auth_url: None,
user_auth_blocks: None,
unfurl_id: None,
source: None,
}
}
pub fn channel(mut self, channel: impl Into<String>) -> Self {
self.channel = Some(channel.into());
self
}
pub fn ts(mut self, ts: impl Into<String>) -> Self {
self.ts = Some(ts.into());
self
}
pub fn unfurls(mut self, unfurls: impl Into<String>) -> Self {
self.unfurls = Some(unfurls.into());
self
}
pub fn user_auth_message(mut self, user_auth_message: impl Into<String>) -> Self {
self.user_auth_message = Some(user_auth_message.into());
self
}
pub fn user_auth_required(mut self, user_auth_required: bool) -> Self {
self.user_auth_required = Some(user_auth_required);
self
}
pub fn user_auth_url(mut self, user_auth_url: impl Into<String>) -> Self {
self.user_auth_url = Some(user_auth_url.into());
self
}
pub fn user_auth_blocks(mut self, user_auth_blocks: Vec<crate::blocks::Block>) -> Self {
self.user_auth_blocks = Some(user_auth_blocks);
self
}
pub fn unfurl_id(mut self, unfurl_id: impl Into<String>) -> Self {
self.unfurl_id = Some(unfurl_id.into());
self
}
pub fn source(mut self, source: impl Into<String>) -> Self {
self.source = Some(source.into());
self
}
}
impl SlackApiMethod for ChatUnfurlRequest {
const METHOD: &'static str = "chat.unfurl";
type Response = ChatUnfurlResponse;
}
#[doc(alias = "chat.unfurl")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ChatUnfurlResponse {
#[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>,
}
#[doc(alias = "chat.update")]
#[derive(Debug, Clone, PartialEq, Serialize)]
#[non_exhaustive]
pub struct ChatUpdateRequest {
pub channel: String,
pub ts: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub as_user: Option<bool>,
#[serde(
skip_serializing_if = "Option::is_none",
serialize_with = "crate::form::as_json"
)]
pub attachments: Option<Vec<crate::blocks::Attachment>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub unfurled_attachments: Option<String>,
#[serde(
skip_serializing_if = "Option::is_none",
serialize_with = "crate::form::as_json"
)]
pub blocks: Option<Vec<crate::blocks::Block>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub markdown_text: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata: Option<crate::blocks::MessageMetadata>,
#[serde(skip_serializing_if = "Option::is_none")]
pub link_names: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub parse: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub text: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub reply_broadcast: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub file_ids: Option<Vec<String>>,
}
impl ChatUpdateRequest {
pub fn new(channel: impl Into<String>, ts: impl Into<String>) -> Self {
Self {
channel: channel.into(),
ts: ts.into(),
as_user: None,
attachments: None,
unfurled_attachments: None,
blocks: None,
markdown_text: None,
metadata: None,
link_names: None,
parse: None,
text: None,
reply_broadcast: None,
file_ids: None,
}
}
pub fn as_user(mut self, as_user: bool) -> Self {
self.as_user = Some(as_user);
self
}
pub fn attachments(mut self, attachments: Vec<crate::blocks::Attachment>) -> Self {
self.attachments = Some(attachments);
self
}
pub fn unfurled_attachments(mut self, unfurled_attachments: impl Into<String>) -> Self {
self.unfurled_attachments = Some(unfurled_attachments.into());
self
}
pub fn blocks(mut self, blocks: Vec<crate::blocks::Block>) -> Self {
self.blocks = Some(blocks);
self
}
pub fn markdown_text(mut self, markdown_text: impl Into<String>) -> Self {
self.markdown_text = Some(markdown_text.into());
self
}
pub fn metadata(mut self, metadata: crate::blocks::MessageMetadata) -> Self {
self.metadata = Some(metadata);
self
}
pub fn link_names(mut self, link_names: bool) -> Self {
self.link_names = Some(link_names);
self
}
pub fn parse(mut self, parse: impl Into<String>) -> Self {
self.parse = Some(parse.into());
self
}
pub fn text(mut self, text: impl Into<String>) -> Self {
self.text = Some(text.into());
self
}
pub fn reply_broadcast(mut self, reply_broadcast: bool) -> Self {
self.reply_broadcast = Some(reply_broadcast);
self
}
pub fn file_ids(mut self, file_ids: Vec<String>) -> Self {
self.file_ids = Some(file_ids);
self
}
}
impl SlackApiMethod for ChatUpdateRequest {
const METHOD: &'static str = "chat.update";
type Response = ChatUpdateResponse;
}
#[doc(alias = "chat.update")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ChatUpdateResponse {
#[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_string",
skip_serializing_if = "Option::is_none"
)]
pub ts: Option<String>,
#[serde(
default,
deserialize_with = "crate::de::opt_string",
skip_serializing_if = "Option::is_none"
)]
pub text: Option<String>,
#[serde(
default,
deserialize_with = "crate::de::opt_object",
skip_serializing_if = "Option::is_none"
)]
pub message: Option<ChatUpdateResponseMessage>,
#[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 ChatUpdateResponseMessage {
#[serde(
default,
deserialize_with = "crate::de::opt_string",
skip_serializing_if = "Option::is_none"
)]
pub text: Option<String>,
#[serde(
default,
deserialize_with = "crate::de::opt_string",
skip_serializing_if = "Option::is_none"
)]
pub user: Option<String>,
}
impl SlackClient {
#[doc(alias = "chat.appendStream")]
pub async fn chat_append_stream(
&self,
request: &ChatAppendStreamRequest,
) -> Result<ChatAppendStreamResponse, SlackError> {
self.call(request).await
}
#[doc(alias = "chat.delete")]
pub async fn chat_delete(
&self,
request: &ChatDeleteRequest,
) -> Result<ChatDeleteResponse, SlackError> {
self.call(request).await
}
#[doc(alias = "chat.deleteScheduledMessage")]
pub async fn chat_delete_scheduled_message(
&self,
request: &ChatDeleteScheduledMessageRequest,
) -> Result<ChatDeleteScheduledMessageResponse, SlackError> {
self.call(request).await
}
#[doc(alias = "chat.getPermalink")]
pub async fn chat_get_permalink(
&self,
request: &ChatGetPermalinkRequest,
) -> Result<ChatGetPermalinkResponse, SlackError> {
self.call(request).await
}
#[doc(alias = "chat.meMessage")]
pub async fn chat_me_message(
&self,
request: &ChatMeMessageRequest,
) -> Result<ChatMeMessageResponse, SlackError> {
self.call(request).await
}
#[doc(alias = "chat.postEphemeral")]
pub async fn chat_post_ephemeral(
&self,
request: &ChatPostEphemeralRequest,
) -> Result<ChatPostEphemeralResponse, SlackError> {
self.call(request).await
}
#[doc(alias = "chat.postMessage")]
pub async fn chat_post_message(
&self,
request: &ChatPostMessageRequest,
) -> Result<ChatPostMessageResponse, SlackError> {
self.call(request).await
}
#[doc(alias = "chat.scheduleMessage")]
pub async fn chat_schedule_message(
&self,
request: &ChatScheduleMessageRequest,
) -> Result<ChatScheduleMessageResponse, SlackError> {
self.call(request).await
}
#[doc(alias = "chat.scheduledMessages.list")]
pub async fn chat_scheduled_messages_list(
&self,
request: &ChatScheduledMessagesListRequest,
) -> Result<ChatScheduledMessagesListResponse, SlackError> {
self.call(request).await
}
#[doc(alias = "chat.startStream")]
pub async fn chat_start_stream(
&self,
request: &ChatStartStreamRequest,
) -> Result<ChatStartStreamResponse, SlackError> {
self.call(request).await
}
#[doc(alias = "chat.stopStream")]
pub async fn chat_stop_stream(
&self,
request: &ChatStopStreamRequest,
) -> Result<ChatStopStreamResponse, SlackError> {
self.call(request).await
}
#[doc(alias = "chat.unfurl")]
pub async fn chat_unfurl(
&self,
request: &ChatUnfurlRequest,
) -> Result<ChatUnfurlResponse, SlackError> {
self.call(request).await
}
#[doc(alias = "chat.update")]
pub async fn chat_update(
&self,
request: &ChatUpdateRequest,
) -> Result<ChatUpdateResponse, SlackError> {
self.call(request).await
}
}