mirror of
https://github.com/System-End/slack-morphism-rust.git
synced 2026-04-19 22:05:15 +00:00
Slack Client Team API implementation
This commit is contained in:
parent
22a12e80a1
commit
94aaddd993
3 changed files with 88 additions and 0 deletions
|
|
@ -2,6 +2,7 @@ mod bots;
|
|||
mod chat;
|
||||
mod conversations;
|
||||
mod oauth;
|
||||
mod team;
|
||||
mod test;
|
||||
mod users;
|
||||
mod webhook;
|
||||
|
|
@ -10,6 +11,7 @@ pub use bots::*;
|
|||
pub use chat::*;
|
||||
pub use conversations::*;
|
||||
pub use oauth::*;
|
||||
pub use team::*;
|
||||
pub use test::*;
|
||||
pub use users::*;
|
||||
pub use webhook::*;
|
||||
|
|
|
|||
64
src/client/src/api/team.rs
Normal file
64
src/client/src/api/team.rs
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
//!
|
||||
//! Support for Slack Team API methods
|
||||
//!
|
||||
|
||||
use rsb_derive::Builder;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_with::skip_serializing_none;
|
||||
|
||||
use crate::ClientResult;
|
||||
use crate::SlackClientSession;
|
||||
use slack_morphism_models::*;
|
||||
|
||||
impl<'a> SlackClientSession<'a> {
|
||||
///
|
||||
/// https://api.slack.com/methods/team.info
|
||||
///
|
||||
pub async fn team_info(
|
||||
&self,
|
||||
req: &SlackApiTeamInfoRequest,
|
||||
) -> ClientResult<SlackApiTeamInfoResponse> {
|
||||
self.http_api
|
||||
.http_get("team.info", &vec![("team", req.team.as_ref())])
|
||||
.await
|
||||
}
|
||||
|
||||
///
|
||||
/// https://api.slack.com/methods/team.profile.get
|
||||
///
|
||||
pub async fn team_profile_get(
|
||||
&self,
|
||||
req: &SlackApiTeamProfileGetRequest,
|
||||
) -> ClientResult<SlackApiTeamProfileGetResponse> {
|
||||
self.http_api
|
||||
.http_get(
|
||||
"team.profile.get",
|
||||
&vec![("visibility", req.visibility.as_ref())],
|
||||
)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
|
||||
pub struct SlackApiTeamInfoRequest {
|
||||
pub team: Option<SlackTeamId>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
|
||||
pub struct SlackApiTeamInfoResponse {
|
||||
pub team: SlackTeamInfo,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
|
||||
pub struct SlackApiTeamProfileGetRequest {
|
||||
pub visibility: Option<SlackTeamId>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
|
||||
pub struct SlackApiTeamProfileGetResponse {
|
||||
pub profile: SlackTeamProfile,
|
||||
}
|
||||
|
|
@ -20,3 +20,25 @@ pub struct SlackBasicTeamInfo {
|
|||
pub id: SlackTeamId,
|
||||
pub name: Option<String>,
|
||||
}
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
|
||||
pub struct SlackTeamProfile {
|
||||
pub fields: Vec<SlackTeamProfileField>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Eq, PartialEq, Hash, Clone, Serialize, Deserialize, ValueStruct)]
|
||||
pub struct SlackTeamProfileFieldId(pub String);
|
||||
|
||||
#[skip_serializing_none]
|
||||
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize, Builder)]
|
||||
pub struct SlackTeamProfileField {
|
||||
id: SlackTeamProfileFieldId,
|
||||
ordering: i64,
|
||||
label: String,
|
||||
hint: Option<String>,
|
||||
#[serde(rename = "type")]
|
||||
field_type: Option<String>,
|
||||
possible_values: Option<Vec<String>>,
|
||||
options: Option<serde_json::Value>,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue