Skip to content

Commit

Permalink
feat: Add stars.add and stars.remove methods (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
dax authored Mar 11, 2024
1 parent 3080ece commit f0f23ca
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod conversations;
mod files;
mod oauth;
mod reactions;
mod stars;
mod team;
mod test;
mod usergroups;
Expand All @@ -23,6 +24,7 @@ pub use conversations::*;
pub use files::*;
pub use oauth::*;
pub use reactions::*;
pub use stars::*;
pub use team::*;
pub use test::*;
pub use usergroups::*;
Expand Down
69 changes: 69 additions & 0 deletions src/api/stars.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//!
//! Support for Slack Stars API methods
//!
use rsb_derive::Builder;
use rvstruct::ValueStruct;
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;

use crate::models::*;
use crate::ratectl::*;
use crate::*;
use futures::future::{BoxFuture, FutureExt};
use std::collections::HashSet;

impl<'a, SCHC> SlackClientSession<'a, SCHC>
where
SCHC: SlackClientHttpConnector + Send,
{
///
/// https://api.slack.com/methods/stars.add
///
pub async fn stars_add(
&self,
req: &SlackApiStarsAddRequest,
) -> ClientResult<SlackApiStarsAddResponse> {
self.http_session_api
.http_post("stars.add", req, Some(&SLACK_TIER2_METHOD_CONFIG))
.await
}

///
/// https://api.slack.com/methods/stars.remove
///
pub async fn stars_remove(
&self,
req: &SlackApiStarsRemoveRequest,
) -> ClientResult<SlackApiStarsRemoveResponse> {
self.http_session_api
.http_post("stars.remove", req, Some(&SLACK_TIER2_METHOD_CONFIG))
.await
}
}

#[skip_serializing_none]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
pub struct SlackApiStarsAddRequest {
pub channel: Option<SlackChannelId>,
pub file: Option<SlackFileId>,
pub file_comment: Option<SlackFileCommentId>,
pub timestamp: Option<SlackTs>,
}

#[skip_serializing_none]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
pub struct SlackApiStarsAddResponse {}

#[skip_serializing_none]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
pub struct SlackApiStarsRemoveRequest {
pub channel: Option<SlackChannelId>,
pub file: Option<SlackFileId>,
pub file_comment: Option<SlackFileCommentId>,
pub timestamp: Option<SlackTs>,
}

#[skip_serializing_none]
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
pub struct SlackApiStarsRemoveResponse {}
2 changes: 1 addition & 1 deletion src/models/common/star.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub struct SlackStarsItemFile {
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
pub struct SlackStarsItemFileComment {
pub file: SlackFile,
pub comment: String,
pub comment: SlackFileCommentId,
pub channel: SlackChannelId,
pub date_create: SlackDateTime,
}
Expand Down
5 changes: 5 additions & 0 deletions src/models/files/comments.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use rvstruct::*;
use serde::{Deserialize, Serialize};

#[derive(Debug, Eq, PartialEq, Hash, Clone, Serialize, Deserialize, ValueStruct)]
pub struct SlackFileCommentId(pub String);
3 changes: 3 additions & 0 deletions src/models/files/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
use url::Url;

pub mod comments;
pub use comments::*;

#[derive(Debug, Eq, PartialEq, Hash, Clone, Serialize, Deserialize, ValueStruct)]
pub struct SlackFileId(pub String);

Expand Down

0 comments on commit f0f23ca

Please sign in to comment.