pub struct SlackClient {
http: Client,
token: String,
}Expand description
Debug is hand-written because the token must never be printed.
Fields§
§http: Client§token: StringImplementations§
Source§impl SlackClient
impl SlackClient
pub fn new(http: Client, token: String) -> Self
Sourcepub async fn call<T: DeserializeOwned>(
&self,
method: &str,
params: &[(&str, String)],
) -> Result<T, SlackError>
pub async fn call<T: DeserializeOwned>( &self, method: &str, params: &[(&str, String)], ) -> Result<T, SlackError>
POST one Web API method. Slack is uniform here, so one helper covers every call the connector makes.
Sourceasync fn call_text(
&self,
method: &str,
params: &[(&str, String)],
) -> Result<String, SlackError>
async fn call_text( &self, method: &str, params: &[(&str, String)], ) -> Result<String, SlackError>
POST one Web API method and hand back the body undecoded, for the callers whose decode needs the raw text rather than one envelope.
Sourcepub async fn auth_test(&self) -> Result<AuthTest, SlackError>
pub async fn auth_test(&self) -> Result<AuthTest, SlackError>
Who this token belongs to. The first thing to prove on a new workspace.
Sourcepub async fn history(
&self,
channel: &str,
oldest: Option<&str>,
newest: Option<&str>,
limit: u32,
cursor: Option<&str>,
) -> Result<MessagePage, SlackError>
pub async fn history( &self, channel: &str, oldest: Option<&str>, newest: Option<&str>, limit: u32, cursor: Option<&str>, ) -> Result<MessagePage, SlackError>
One page of a conversation’s history. Each bound is omitted entirely
when absent: Slack treats an empty oldest differently from an
absent one.
Sourcepub async fn replies(
&self,
channel: &str,
ts: &str,
oldest: Option<&str>,
limit: u32,
cursor: Option<&str>,
) -> Result<MessagePage, SlackError>
pub async fn replies( &self, channel: &str, ts: &str, oldest: Option<&str>, limit: u32, cursor: Option<&str>, ) -> Result<MessagePage, SlackError>
One page of a thread’s replies. Slack repeats the parent on every
page, so the caller dedupes by ts.
Sourcepub async fn post_message(
&self,
channel: &str,
text: &str,
thread_ts: Option<&str>,
) -> Result<PostedMessage, SlackError>
pub async fn post_message( &self, channel: &str, text: &str, thread_ts: Option<&str>, ) -> Result<PostedMessage, SlackError>
Post one message, as a root or into an existing thread. Returns the
posted message’s ts.
Sourcepub async fn update_message(
&self,
channel: &str,
ts: &str,
text: &str,
) -> Result<(), SlackError>
pub async fn update_message( &self, channel: &str, ts: &str, text: &str, ) -> Result<(), SlackError>
Replace the text of one of the user’s own messages. Slack drops
existing blocks when text is sent without them, which is what
this connector wants: one text body, no stale block.
Sourcepub async fn delete_message(
&self,
channel: &str,
ts: &str,
) -> Result<(), SlackError>
pub async fn delete_message( &self, channel: &str, ts: &str, ) -> Result<(), SlackError>
Delete one of the user’s own messages.
Sourcepub async fn set_reaction(
&self,
channel: &str,
ts: &str,
name: &str,
add: bool,
) -> Result<(), SlackError>
pub async fn set_reaction( &self, channel: &str, ts: &str, name: &str, add: bool, ) -> Result<(), SlackError>
Add or remove one reaction. reactions.remove requires being the
original reaction’s author.
Sourcepub async fn get_bytes(&self, url: &str) -> Result<Vec<u8>, SlackError>
pub async fn get_bytes(&self, url: &str) -> Result<Vec<u8>, SlackError>
GET an absolute URL with the bearer attached. Slack’s private file URLs answer 403 without it, and byte-identically with it.
Sourcepub async fn post_bytes(
&self,
url: &str,
body: Vec<u8>,
) -> Result<(), SlackError>
pub async fn post_bytes( &self, url: &str, body: Vec<u8>, ) -> Result<(), SlackError>
POST raw bytes to an absolute URL. Deliberately no bearer: the upload URL is pre-signed, and it is not the Web API host.
Sourcepub async fn file_info(&self, id: &str) -> Result<SlackFile, SlackError>
pub async fn file_info(&self, id: &str) -> Result<SlackFile, SlackError>
files.info for one file id.
Sourcepub async fn get_upload_url(
&self,
name: &str,
length: usize,
) -> Result<(String, String), SlackError>
pub async fn get_upload_url( &self, name: &str, length: usize, ) -> Result<(String, String), SlackError>
files.getUploadURLExternal: the pre-signed URL to POST the bytes
to, plus the file id the completion call needs.
Sourcepub async fn complete_upload(
&self,
file_id: &str,
channel: &str,
thread_ts: Option<&str>,
) -> Result<Vec<SlackFile>, SlackError>
pub async fn complete_upload( &self, file_id: &str, channel: &str, thread_ts: Option<&str>, ) -> Result<Vec<SlackFile>, SlackError>
files.completeUploadExternal. It can be called once only, and the
file is discarded if it never is.
Sourcepub async fn search_messages(
&self,
query: &str,
count: u32,
cursor: Option<&str>,
) -> Result<SearchPage, SlackError>
pub async fn search_messages( &self, query: &str, count: u32, cursor: Option<&str>, ) -> Result<SearchPage, SlackError>
search.messages. Matches text; it cannot find every message that
mentions a user, which is what the mention subscription is for.
Sourcepub async fn user_info(&self, user: &str) -> Result<SlackUser, SlackError>
pub async fn user_info(&self, user: &str) -> Result<SlackUser, SlackError>
users.info for one user id.
Sourcepub async fn list_users(&self) -> Result<Vec<SlackUser>, SlackError>
pub async fn list_users(&self) -> Result<Vec<SlackUser>, SlackError>
Every member in the workspace, following the cursor. Slack has no server-side name search, so a resolver reads the directory and matches locally.
Sourcepub async fn pins(&self, channel: &str) -> Result<Vec<SlackPin>, SlackError>
pub async fn pins(&self, channel: &str) -> Result<Vec<SlackPin>, SlackError>
pins.list for one conversation.
Sourcepub async fn bookmarks(
&self,
channel: &str,
) -> Result<Vec<SlackBookmark>, SlackError>
pub async fn bookmarks( &self, channel: &str, ) -> Result<Vec<SlackBookmark>, SlackError>
bookmarks.list for one conversation. The param is channel_id
here against channel on pins.list.
Sourcepub async fn list_conversations(
&self,
) -> Result<Vec<SlackConversation>, SlackError>
pub async fn list_conversations( &self, ) -> Result<Vec<SlackConversation>, SlackError>
Every conversation the token’s user is a member of, paging to the end.
Trait Implementations§
Source§impl Debug for SlackClient
impl Debug for SlackClient
Source§impl SlackApi for SlackClient
impl SlackApi for SlackClient
Source§fn auth_test<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<AuthTest, SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn auth_test<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<AuthTest, SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_conversations<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<SlackConversation>, SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn history<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
channel: &'life1 str,
oldest: Option<&'life2 str>,
newest: Option<&'life3 str>,
limit: u32,
cursor: Option<&'life4 str>,
) -> Pin<Box<dyn Future<Output = Result<MessagePage, SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
fn replies<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
channel: &'life1 str,
ts: &'life2 str,
oldest: Option<&'life3 str>,
limit: u32,
cursor: Option<&'life4 str>,
) -> Pin<Box<dyn Future<Output = Result<MessagePage, SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Source§fn post_message<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
channel: &'life1 str,
text: &'life2 str,
thread_ts: Option<&'life3 str>,
) -> Pin<Box<dyn Future<Output = Result<PostedMessage, SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn post_message<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
channel: &'life1 str,
text: &'life2 str,
thread_ts: Option<&'life3 str>,
) -> Pin<Box<dyn Future<Output = Result<PostedMessage, SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
ts, the handle a reply, an edit, a delete and a
reaction all take, and the channel it landed in - a request can
address a user id or a channel name instead of the conversation id.Source§fn update_message<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
channel: &'life1 str,
ts: &'life2 str,
text: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<(), SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn update_message<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
channel: &'life1 str,
ts: &'life2 str,
text: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<(), SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Source§fn delete_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
channel: &'life1 str,
ts: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn delete_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
channel: &'life1 str,
ts: &'life2 str,
) -> Pin<Box<dyn Future<Output = Result<(), SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn set_reaction<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
channel: &'life1 str,
ts: &'life2 str,
name: &'life3 str,
add: bool,
) -> Pin<Box<dyn Future<Output = Result<(), SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn set_reaction<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
channel: &'life1 str,
ts: &'life2 str,
name: &'life3 str,
add: bool,
) -> Pin<Box<dyn Future<Output = Result<(), SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Source§fn get_bytes<'life0, 'life1, 'async_trait>(
&'life0 self,
url: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_bytes<'life0, 'life1, 'async_trait>(
&'life0 self,
url: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn post_bytes<'life0, 'life1, 'async_trait>(
&'life0 self,
url: &'life1 str,
body: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<(), SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn post_bytes<'life0, 'life1, 'async_trait>(
&'life0 self,
url: &'life1 str,
body: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<(), SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn file_info<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<SlackFile, SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn file_info<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<SlackFile, SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
files.info for one file id.Source§fn get_upload_url<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
length: usize,
) -> Pin<Box<dyn Future<Output = Result<(String, String), SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_upload_url<'life0, 'life1, 'async_trait>(
&'life0 self,
name: &'life1 str,
length: usize,
) -> Pin<Box<dyn Future<Output = Result<(String, String), SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
files.getUploadURLExternal: the pre-signed URL to POST the bytes
to, plus the file id the completion call needs.Source§fn complete_upload<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
file_id: &'life1 str,
channel: &'life2 str,
thread_ts: Option<&'life3 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<SlackFile>, SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn complete_upload<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
file_id: &'life1 str,
channel: &'life2 str,
thread_ts: Option<&'life3 str>,
) -> Pin<Box<dyn Future<Output = Result<Vec<SlackFile>, SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
files.completeUploadExternal, which can be called once only.
Returns the files it reports: when Slack fills their shares, that
already names the message the upload was posted as.Source§fn search_messages<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
count: u32,
cursor: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<SearchPage, SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn search_messages<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
query: &'life1 str,
count: u32,
cursor: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<SearchPage, SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
search.messages, always timestamp-ordered. The cursor follows a
previous page when one sweep has more hits than one page holds.Source§fn user_info<'life0, 'life1, 'async_trait>(
&'life0 self,
user: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<SlackUser, SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn user_info<'life0, 'life1, 'async_trait>(
&'life0 self,
user: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<SlackUser, SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
users.info for one user id.Source§fn list_users<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<SlackUser>, SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_users<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<SlackUser>, SlackError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§impl UsersPages for SlackClient
impl UsersPages for SlackClient
Auto Trait Implementations§
impl !RefUnwindSafe for SlackClient
impl !UnwindSafe for SlackClient
impl Freeze for SlackClient
impl Send for SlackClient
impl Sync for SlackClient
impl Unpin for SlackClient
impl UnsafeUnpin for SlackClient
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more