Struct PodbeanClient

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

A client for interacting with the Podbean API.

This client handles authentication, token management, rate limiting, and provides methods to interact with Podbean’s API endpoints.

Implementations§

Source§

impl PodbeanClient

Source

pub fn new(client_id: &str, client_secret: &str) -> Self

Creates a new Podbean API client.

§Arguments
  • client_id - The client ID from your Podbean API application
  • client_secret - The client secret from your Podbean API application
§Examples
use podbean::PodbeanClient;

let client = PodbeanClient::new("your_client_id", "your_client_secret");
Source

pub async fn authorize( &mut self, code: &str, redirect_uri: &str, ) -> PodbeanResult<()>

Authorize the client using an authorization code.

This method exchanges an authorization code for an access token after the user has authorized your application.

§Arguments
  • code - The authorization code received after user authorization
  • redirect_uri - The redirect URI used in the authorization request
§Returns
  • Ok(()) if authorization was successful
  • Err(PodbeanError) if there was an error during authorization
§Examples
let code = "authorization_code"; // From callback URL
let redirect_uri = "https://your-app.com/callback";

match client.authorize(code, redirect_uri).await {
    Ok(_) => println!("Authorization successful!"),
    Err(e) => eprintln!("Authorization failed: {}", e),
}
Source

pub async fn refresh_token(&mut self) -> PodbeanResult<()>

Refresh the access token.

This method uses the refresh token to obtain a new access token when the current one expires.

§Returns
  • Ok(()) if token refresh was successful
  • Err(PodbeanError) if there was an error during token refresh
§Examples
// Typically called automatically by the client when needed
match client.refresh_token().await {
    Ok(_) => println!("Token refreshed successfully"),
    Err(e) => eprintln!("Token refresh failed: {}", e),
}
Source

pub async fn upload_media( &mut self, file_path: &str, content_type: &str, ) -> PodbeanResult<String>

Uploads a media file to Podbean.

This method uploads a media file (typically an audio file) to Podbean and returns a media key that can be used to publish episodes.

§Arguments
  • file_path - Path to the local file to upload
  • content_type - MIME type of the file (e.g., “audio/mpeg” for MP3)
§Returns
  • Ok(String) containing the media key if successful
  • Err(PodbeanError) if there was an error during upload
§Examples
let file_path = "/path/to/episode.mp3";
let media_key = client.upload_media(file_path, "audio/mpeg").await.unwrap();
println!("Media uploaded with key: {}", media_key);
Source

pub async fn publish_episode( &mut self, podcast_id: &str, title: &str, content: &str, media_key: &str, status: &str, publish_timestamp: Option<i64>, ) -> PodbeanResult<String>

Publishes a new episode to a podcast.

§Arguments
  • podcast_id - The ID of the podcast to publish to
  • title - The title of the episode
  • content - The description or show notes for the episode
  • media_key - The media key returned from upload_media
  • status - Publication status: “publish”, “draft”, or “schedule”
  • publish_timestamp - Unix timestamp for scheduled publication (required if status is “schedule”)
§Returns
  • Ok(String) containing the episode ID if successful
  • Err(PodbeanError) if there was an error
§Examples
let episode_id = client.publish_episode(
    "podcast_id",
    "My New Episode",
    "Episode description and show notes...",
    &media_key,
    "publish", // Publish immediately
    None,
).await.unwrap();

println!("Episode published with ID: {}", episode_id);
Source

pub async fn get_episode(&mut self, episode_id: &str) -> PodbeanResult<Episode>

Gets information about a specific episode.

§Arguments
  • episode_id - The ID of the episode to retrieve
§Returns
  • Ok(Episode) containing the episode details if successful
  • Err(PodbeanError) if there was an error
§Examples
let episode = client.get_episode("episode_id").await.unwrap();
println!("Episode title: {}", episode.title);
println!("Listen URL: {}", episode.player_url);
Source

pub async fn list_episodes( &mut self, podcast_id: Option<&str>, offset: Option<u32>, limit: Option<u32>, ) -> PodbeanResult<EpisodeListResponse>

Lists episodes from a podcast.

§Arguments
  • podcast_id - Optional podcast ID to filter episodes
  • offset - Optional pagination offset
  • limit - Optional number of episodes to return
§Returns
  • Ok(EpisodeListResponse) containing the episodes if successful
  • Err(PodbeanError) if there was an error
§Examples
// Get the first 10 episodes from a specific podcast
let episodes = client.list_episodes(
    Some("podcast_id"),
    None,  // Start from beginning
    Some(10) // Get 10 episodes
).await.unwrap();

println!("Found {} episodes", episodes.count);
for episode in episodes.episodes {
    println!("- {} ({})", episode.title, episode.publish_time);
}
Source

pub async fn update_episode( &mut self, episode_id: &str, title: Option<&str>, content: Option<&str>, status: Option<&str>, publish_timestamp: Option<i64>, ) -> PodbeanResult<()>

Updates an existing episode.

§Arguments
  • episode_id - The ID of the episode to update
  • title - Optional new title
  • content - Optional new content/description
  • status - Optional new status
  • publish_timestamp - Optional new publication timestamp
§Returns
  • Ok(()) if update was successful
  • Err(PodbeanError) if there was an error
§Examples
// Update just the title of an episode
client.update_episode(
    "episode_id",
    Some("Updated Title"),
    None,  // Keep current content
    None,  // Keep current status
    None   // Keep current publish time
).await.unwrap();
println!("Episode updated successfully");
Source

pub async fn delete_episode(&mut self, episode_id: &str) -> PodbeanResult<()>

Deletes an episode.

§Arguments
  • episode_id - The ID of the episode to delete
§Returns
  • Ok(()) if deletion was successful
  • Err(PodbeanError) if there was an error
§Examples
client.delete_episode("episode_id").await.unwrap();
println!("Episode deleted successfully");
Source

pub async fn list_podcasts( &mut self, offset: Option<u32>, limit: Option<u32>, ) -> PodbeanResult<PodcastListResponse>

Lists podcasts for the authenticated user.

§Arguments
  • offset - Optional pagination offset
  • limit - Optional number of podcasts to return
§Returns
  • Ok(PodcastListResponse) containing the podcasts if successful
  • Err(PodbeanError) if there was an error
§Examples
let podcasts = client.list_podcasts(None, Some(10)).await.unwrap();
println!("Found {} podcasts", podcasts.count);
for podcast in podcasts.podcasts {
    println!("- {} ({})", podcast.title, podcast.podcast_id);
}
Source

pub async fn list_media( &mut self, offset: Option<u32>, limit: Option<u32>, ) -> PodbeanResult<MediaListResponse>

Lists media files for the authenticated user.

§Arguments
  • offset - Optional pagination offset
  • limit - Optional number of media files to return
§Returns
  • Ok(MediaListResponse) containing the media files if successful
  • Err(PodbeanError) if there was an error
§Examples
let media = client.list_media(None, Some(10)).await.unwrap();
println!("Found {} media files", media.count);
for item in media.media {
    println!("- {} ({})", item.title, item.media_key);
}
Source

pub fn get_authorization_url( &self, redirect_uri: &str, state: Option<&str>, ) -> PodbeanResult<String>

Generates an authorization URL for OAuth2 flow.

Users need to visit this URL to authorize your application to access their Podbean account.

§Arguments
  • redirect_uri - The URI to redirect to after authorization
  • state - Optional state parameter for CSRF protection
§Returns
  • Ok(String) containing the authorization URL if successful
  • Err(PodbeanError) if there was an error
§Examples
let client = PodbeanClient::new("client_id", "client_secret");

let auth_url = client.get_authorization_url(
    "https://your-app.com/callback",
    Some("random_state_for_csrf_protection")
).unwrap();

println!("Visit this URL to authorize: {}", auth_url);

Trait Implementations§

Source§

impl Clone for PodbeanClient

Source§

fn clone(&self) -> PodbeanClient

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PodbeanClient

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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,

Source§

impl<T> MaybeSendSync for T