Struct WeChatClient

Source
pub struct WeChatClient { /* private fields */ }
Expand description

Main WeChat Official Account client.

Implementations§

Source§

impl WeChatClient

Source

pub async fn new( app_id: impl Into<String>, app_secret: impl Into<String>, ) -> Result<Self>

Creates a new WeChat client with app credentials.

Source

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:

  1. Parse markdown file
  2. Extract and upload images
  3. Replace image URLs in content
  4. Render content with theme (from frontmatter, options, or default)
  5. Create draft article
§Arguments
  • markdown_path - Path to the markdown file
§Returns

Returns the media ID of the created draft

Source

pub async fn upload_with_options( &self, markdown_path: &str, options: UploadOptions, ) -> Result<String>

Uploads a markdown file with custom options.

§Arguments
  • markdown_path - Path to the markdown file
  • options - Upload options for customization
§Returns

Returns the media ID of the created draft

Source

pub async fn get_draft(&self, media_id: &str) -> Result<DraftInfo>

Gets a draft by media ID.

Source

pub async fn update_draft( &self, media_id: &str, markdown_path: &str, ) -> Result<()>

Updates an existing draft with new content.

Source

pub async fn update_draft_with_options( &self, media_id: &str, markdown_path: &str, options: UploadOptions, ) -> Result<()>

Updates an existing draft with custom options.

Source

pub async fn delete_draft(&self, media_id: &str) -> Result<()>

Deletes a draft by media ID.

Source

pub async fn list_drafts( &self, offset: u32, count: u32, ) -> Result<Vec<DraftInfo>>

Lists drafts with pagination.

Source

pub async fn upload_image(&self, image_path: &str) -> Result<String>

Uploads a single image file and returns the WeChat URL.

Source

pub async fn create_draft(&self, articles: Vec<Article>) -> Result<String>

Creates a draft with custom articles.

Source

pub fn available_themes(&self) -> Vec<&String>

Gets the list of available themes.

Source

pub fn has_theme(&self, theme: &str) -> bool

Checks if a theme exists.

Source

pub async fn get_token_info(&self) -> Option<TokenInfo>

Gets access token information for debugging.

Source

pub async fn refresh_token(&self) -> Result<String>

Forces a token refresh.

Source

pub fn http_client(&self) -> &WeChatHttpClient

Gets the underlying HTTP client for advanced usage.

Trait Implementations§

Source§

impl Debug for WeChatClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,