pub struct WeChatClient { /* private fields */ }
Expand description
Main WeChat Official Account client.
Implementations§
Source§impl WeChatClient
impl WeChatClient
Sourcepub async fn new(
app_id: impl Into<String>,
app_secret: impl Into<String>,
) -> Result<Self>
pub async fn new( app_id: impl Into<String>, app_secret: impl Into<String>, ) -> Result<Self>
Creates a new WeChat client with app credentials.
Sourcepub async fn upload(&self, markdown_path: &str) -> Result<String>
pub async fn upload(&self, markdown_path: &str) -> Result<String>
Uploads a markdown file as a WeChat draft article.
This is the main convenience method that handles the entire workflow:
- Parse markdown file
- Extract and upload images
- Replace image URLs in content
- Render content with theme (from frontmatter, options, or default)
- Create draft article
§Arguments
markdown_path
- Path to the markdown file
§Returns
Returns the media ID of the created draft
Sourcepub async fn upload_with_options(
&self,
markdown_path: &str,
options: UploadOptions,
) -> Result<String>
pub async fn upload_with_options( &self, markdown_path: &str, options: UploadOptions, ) -> Result<String>
Sourcepub async fn update_draft(
&self,
media_id: &str,
markdown_path: &str,
) -> Result<()>
pub async fn update_draft( &self, media_id: &str, markdown_path: &str, ) -> Result<()>
Updates an existing draft with new content.
Sourcepub async fn update_draft_with_options(
&self,
media_id: &str,
markdown_path: &str,
options: UploadOptions,
) -> Result<()>
pub async fn update_draft_with_options( &self, media_id: &str, markdown_path: &str, options: UploadOptions, ) -> Result<()>
Updates an existing draft with custom options.
Sourcepub async fn delete_draft(&self, media_id: &str) -> Result<()>
pub async fn delete_draft(&self, media_id: &str) -> Result<()>
Deletes a draft by media ID.
Sourcepub async fn list_drafts(
&self,
offset: u32,
count: u32,
) -> Result<Vec<DraftInfo>>
pub async fn list_drafts( &self, offset: u32, count: u32, ) -> Result<Vec<DraftInfo>>
Lists drafts with pagination.
Sourcepub async fn upload_image(&self, image_path: &str) -> Result<String>
pub async fn upload_image(&self, image_path: &str) -> Result<String>
Uploads a single image file and returns the WeChat URL.
Sourcepub async fn create_draft(&self, articles: Vec<Article>) -> Result<String>
pub async fn create_draft(&self, articles: Vec<Article>) -> Result<String>
Creates a draft with custom articles.
Sourcepub fn available_themes(&self) -> Vec<&String>
pub fn available_themes(&self) -> Vec<&String>
Gets the list of available themes.
Sourcepub async fn get_token_info(&self) -> Option<TokenInfo>
pub async fn get_token_info(&self) -> Option<TokenInfo>
Gets access token information for debugging.
Sourcepub async fn refresh_token(&self) -> Result<String>
pub async fn refresh_token(&self) -> Result<String>
Forces a token refresh.
Sourcepub fn http_client(&self) -> &WeChatHttpClient
pub fn http_client(&self) -> &WeChatHttpClient
Gets the underlying HTTP client for advanced usage.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WeChatClient
impl !RefUnwindSafe for WeChatClient
impl Send for WeChatClient
impl Sync for WeChatClient
impl Unpin for WeChatClient
impl !UnwindSafe for WeChatClient
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