pub struct SubscribeApi { /* private fields */ }Expand description
Subscribe Message API
Provides methods for sending subscribe messages and managing templates.
Implementations§
Source§impl SubscribeApi
impl SubscribeApi
Sourcepub fn new(context: Arc<WechatContext>) -> Self
pub fn new(context: Arc<WechatContext>) -> Self
Create a new SubscribeApi instance
Sourcepub async fn send(
&self,
options: SubscribeMessageOptions,
) -> Result<(), WechatError>
pub async fn send( &self, options: SubscribeMessageOptions, ) -> Result<(), WechatError>
Send subscribe message
POST /cgi-bin/message/subscribe/send?access_token=ACCESS_TOKEN
§Arguments
options- Subscribe message options
§Example
ⓘ
use wechat_mp_sdk::api::subscribe::{
SubscribeApi, SubscribeMessageOptions, SubscribeMessageData, SubscribeMessageValue
};
let mut data = SubscribeMessageData::new();
data.insert("thing1".to_string(), SubscribeMessageValue::new("Order #123"));
let options = SubscribeMessageOptions {
touser: "user_openid".to_string(),
template_id: "template_id".to_string(),
data,
page: Some("pages/index/index".to_string()),
miniprogram_state: None,
lang: None,
};
subscribe_api.send(options).await?;Sourcepub async fn add_template(
&self,
tid: &str,
kid_list: Option<Vec<i32>>,
scene_desc: Option<&str>,
) -> Result<String, WechatError>
pub async fn add_template( &self, tid: &str, kid_list: Option<Vec<i32>>, scene_desc: Option<&str>, ) -> Result<String, WechatError>
Add template from template library
POST /wxaapi/newtmpl/addtemplate?access_token=ACCESS_TOKEN
§Arguments
tid- Template library IDkid_list- Keyword ID list (optional)scene_desc- Scene description (optional)
§Returns
The private template ID
§Example
ⓘ
let pri_tmpl_id = subscribe_api.add_template("tid123", Some(vec![1, 2, 3]), Some("payment notification")).await?;
println!("Template ID: {}", pri_tmpl_id);Sourcepub async fn get_template_list(&self) -> Result<Vec<TemplateInfo>, WechatError>
pub async fn get_template_list(&self) -> Result<Vec<TemplateInfo>, WechatError>
Sourcepub async fn delete_template(
&self,
pri_tmpl_id: &str,
) -> Result<(), WechatError>
pub async fn delete_template( &self, pri_tmpl_id: &str, ) -> Result<(), WechatError>
Sourcepub async fn get_category(&self) -> Result<Vec<CategoryInfo>, WechatError>
pub async fn get_category(&self) -> Result<Vec<CategoryInfo>, WechatError>
pub async fn get_pub_template_keywords_by_id( &self, tid: &str, ) -> Result<PubTemplateKeywordResponse, WechatError>
pub async fn get_pub_template_title_list( &self, ids: &[i32], start: i32, limit: i32, ) -> Result<PubTemplateTitleListResponse, WechatError>
pub async fn set_user_notify( &self, request: &UserNotifyRequest, ) -> Result<UserNotifyResponse, WechatError>
pub async fn set_user_notify_ext( &self, request: &UserNotifyExtRequest, ) -> Result<UserNotifyResponse, WechatError>
pub async fn get_user_notify( &self, request: &GetUserNotifyRequest, ) -> Result<UserNotifyResponse, WechatError>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SubscribeApi
impl !RefUnwindSafe for SubscribeApi
impl Send for SubscribeApi
impl Sync for SubscribeApi
impl Unpin for SubscribeApi
impl UnsafeUnpin for SubscribeApi
impl !UnwindSafe for SubscribeApi
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