pub struct DingTalk {
pub dingtalk_type: DingTalkType,
pub default_webhook_url: String,
pub access_token: String,
pub sec_token: String,
pub direct_url: String,
pub proxy: Option<String>,
}
Expand description
Fields§
§dingtalk_type: DingTalkType
§default_webhook_url: String
§access_token: String
§sec_token: String
§direct_url: String
§proxy: Option<String>
Implementations§
Source§impl DingTalk
impl DingTalk
Sourcepub fn from_token(token: &str) -> XResult<Self>
pub fn from_token(token: &str) -> XResult<Self>
Create DingTalk
from token:
wechatwork:access_token
dingtalk:access_token?sec_token
Sourcepub fn from_file(f: &str) -> XResult<Self>
pub fn from_file(f: &str) -> XResult<Self>
Create DingTalk
from file
Format see DingTalk::from_json(json: &str)
Sourcepub fn from_json(json: &str) -> XResult<Self>
pub fn from_json(json: &str) -> XResult<Self>
Create DingTalk
from JSON string
Format:
{
"default_webhook_url": "", // option
"access_token": "<access token>",
"sec_token": "<sec token>" // option
}
Sourcepub fn new(access_token: &str, sec_token: &str) -> Self
pub fn new(access_token: &str, sec_token: &str) -> Self
Create DingTalk
access_token
is access token, sec_token
can be empty ""
Sourcepub fn new_wechat(key: &str) -> Self
pub fn new_wechat(key: &str) -> Self
Create DingTalk
for WeChat Work
Sourcepub fn set_default_webhook_url(&mut self, default_webhook_url: &str)
pub fn set_default_webhook_url(&mut self, default_webhook_url: &str)
Set default webhook url
Sourcepub async fn send_message(
&self,
dingtalk_message: DingTalkMessage,
) -> XResult<()>
pub async fn send_message( &self, dingtalk_message: DingTalkMessage, ) -> XResult<()>
Send DingTalk message
- Create DingTalk JSON message
- POST JSON message to DingTalk server
Sourcepub async fn send_markdown(&self, title: &str, text: &str) -> XResult<()>
pub async fn send_markdown(&self, title: &str, text: &str) -> XResult<()>
Send markdown message
Sourcepub async fn send_link(
&self,
link_title: &str,
link_text: &str,
link_pic_url: &str,
link_message_url: &str,
) -> XResult<()>
pub async fn send_link( &self, link_title: &str, link_text: &str, link_pic_url: &str, link_message_url: &str, ) -> XResult<()>
Send link message
Sourcepub fn generate_signed_url(&self) -> XResult<String>
pub fn generate_signed_url(&self) -> XResult<String>
Generate signed dingtalk webhook URL
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DingTalk
impl RefUnwindSafe for DingTalk
impl Send for DingTalk
impl Sync for DingTalk
impl Unpin for DingTalk
impl UnwindSafe for DingTalk
Blanket Implementations§
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
Mutably borrows from an owned value. Read more