#![allow(unused_imports)]
use crate::objects::*;
use crate::{
CursorPaginated, NextCursor, ResponseMetadata, SlackApiMethod, SlackClient, SlackError,
};
use serde::{Deserialize, Serialize};
#[doc(alias = "bookmarks.add")]
#[derive(Debug, Clone, PartialEq, Serialize)]
#[non_exhaustive]
pub struct BookmarksAddRequest {
pub title: String,
pub r#type: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub channel_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub link: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub emoji: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub entity_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub access_level: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub parent_id: Option<String>,
}
impl BookmarksAddRequest {
pub fn new(title: impl Into<String>, r#type: impl Into<String>) -> Self {
Self {
title: title.into(),
r#type: r#type.into(),
channel_id: None,
link: None,
emoji: None,
entity_id: None,
access_level: None,
parent_id: None,
}
}
pub fn channel_id(mut self, channel_id: impl Into<String>) -> Self {
self.channel_id = Some(channel_id.into());
self
}
pub fn link(mut self, link: impl Into<String>) -> Self {
self.link = Some(link.into());
self
}
pub fn emoji(mut self, emoji: impl Into<String>) -> Self {
self.emoji = Some(emoji.into());
self
}
pub fn entity_id(mut self, entity_id: impl Into<String>) -> Self {
self.entity_id = Some(entity_id.into());
self
}
pub fn access_level(mut self, access_level: impl Into<String>) -> Self {
self.access_level = Some(access_level.into());
self
}
pub fn parent_id(mut self, parent_id: impl Into<String>) -> Self {
self.parent_id = Some(parent_id.into());
self
}
}
impl SlackApiMethod for BookmarksAddRequest {
const METHOD: &'static str = "bookmarks.add";
type Response = BookmarksAddResponse;
}
#[doc(alias = "bookmarks.add")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct BookmarksAddResponse {
#[serde(
default,
deserialize_with = "crate::de::opt_object",
skip_serializing_if = "Option::is_none"
)]
pub bookmark: Option<Bookmark>,
#[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 = "bookmarks.edit")]
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
#[non_exhaustive]
pub struct BookmarksEditRequest {
#[serde(skip_serializing_if = "Option::is_none")]
pub channel_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub bookmark_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub link: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub emoji: Option<String>,
}
impl BookmarksEditRequest {
pub fn new() -> Self {
Self {
channel_id: None,
bookmark_id: None,
title: None,
link: None,
emoji: None,
}
}
pub fn channel_id(mut self, channel_id: impl Into<String>) -> Self {
self.channel_id = Some(channel_id.into());
self
}
pub fn bookmark_id(mut self, bookmark_id: impl Into<String>) -> Self {
self.bookmark_id = Some(bookmark_id.into());
self
}
pub fn title(mut self, title: impl Into<String>) -> Self {
self.title = Some(title.into());
self
}
pub fn link(mut self, link: impl Into<String>) -> Self {
self.link = Some(link.into());
self
}
pub fn emoji(mut self, emoji: impl Into<String>) -> Self {
self.emoji = Some(emoji.into());
self
}
}
impl SlackApiMethod for BookmarksEditRequest {
const METHOD: &'static str = "bookmarks.edit";
type Response = BookmarksEditResponse;
}
#[doc(alias = "bookmarks.edit")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct BookmarksEditResponse {
#[serde(
default,
deserialize_with = "crate::de::opt_object",
skip_serializing_if = "Option::is_none"
)]
pub bookmark: Option<Bookmark>,
#[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 = "bookmarks.list")]
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
#[non_exhaustive]
pub struct BookmarksListRequest {
#[serde(skip_serializing_if = "Option::is_none")]
pub channel_id: Option<String>,
}
impl BookmarksListRequest {
pub fn new() -> Self {
Self { channel_id: None }
}
pub fn channel_id(mut self, channel_id: impl Into<String>) -> Self {
self.channel_id = Some(channel_id.into());
self
}
}
impl SlackApiMethod for BookmarksListRequest {
const METHOD: &'static str = "bookmarks.list";
type Response = BookmarksListResponse;
}
#[doc(alias = "bookmarks.list")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct BookmarksListResponse {
#[serde(
default,
deserialize_with = "crate::de::vec",
skip_serializing_if = "Vec::is_empty"
)]
pub bookmarks: Vec<Bookmark>,
#[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 = "bookmarks.remove")]
#[derive(Debug, Clone, PartialEq, Serialize, Default)]
#[non_exhaustive]
pub struct BookmarksRemoveRequest {
#[serde(skip_serializing_if = "Option::is_none")]
pub channel_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub bookmark_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub quip_section_id: Option<String>,
}
impl BookmarksRemoveRequest {
pub fn new() -> Self {
Self {
channel_id: None,
bookmark_id: None,
quip_section_id: None,
}
}
pub fn channel_id(mut self, channel_id: impl Into<String>) -> Self {
self.channel_id = Some(channel_id.into());
self
}
pub fn bookmark_id(mut self, bookmark_id: impl Into<String>) -> Self {
self.bookmark_id = Some(bookmark_id.into());
self
}
pub fn quip_section_id(mut self, quip_section_id: impl Into<String>) -> Self {
self.quip_section_id = Some(quip_section_id.into());
self
}
}
impl SlackApiMethod for BookmarksRemoveRequest {
const METHOD: &'static str = "bookmarks.remove";
type Response = BookmarksRemoveResponse;
}
#[doc(alias = "bookmarks.remove")]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct BookmarksRemoveResponse {
#[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 {
#[doc(alias = "bookmarks.add")]
pub async fn bookmarks_add(
&self,
request: &BookmarksAddRequest,
) -> Result<BookmarksAddResponse, SlackError> {
self.call(request).await
}
#[doc(alias = "bookmarks.edit")]
pub async fn bookmarks_edit(
&self,
request: &BookmarksEditRequest,
) -> Result<BookmarksEditResponse, SlackError> {
self.call(request).await
}
#[doc(alias = "bookmarks.list")]
pub async fn bookmarks_list(
&self,
request: &BookmarksListRequest,
) -> Result<BookmarksListResponse, SlackError> {
self.call(request).await
}
#[doc(alias = "bookmarks.remove")]
pub async fn bookmarks_remove(
&self,
request: &BookmarksRemoveRequest,
) -> Result<BookmarksRemoveResponse, SlackError> {
self.call(request).await
}
}