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
impl PodbeanClient
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 authorizationredirect_uri- The redirect URI used in the authorization request
§Returns
Ok(())if authorization was successfulErr(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),
}Sourcepub async fn refresh_token(&mut self) -> PodbeanResult<()>
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 successfulErr(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),
}Sourcepub async fn upload_media(
&mut self,
file_path: &str,
content_type: &str,
) -> PodbeanResult<String>
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 uploadcontent_type- MIME type of the file (e.g., “audio/mpeg” for MP3)
§Returns
Ok(String)containing the media key if successfulErr(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);Sourcepub async fn publish_episode(
&mut self,
podcast_id: &str,
title: &str,
content: &str,
media_key: &str,
status: &str,
publish_timestamp: Option<i64>,
) -> PodbeanResult<String>
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 totitle- The title of the episodecontent- The description or show notes for the episodemedia_key- The media key returned fromupload_mediastatus- 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 successfulErr(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);Sourcepub async fn get_episode(&mut self, episode_id: &str) -> PodbeanResult<Episode>
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 successfulErr(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);Sourcepub async fn list_episodes(
&mut self,
podcast_id: Option<&str>,
offset: Option<u32>,
limit: Option<u32>,
) -> PodbeanResult<EpisodeListResponse>
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 episodesoffset- Optional pagination offsetlimit- Optional number of episodes to return
§Returns
Ok(EpisodeListResponse)containing the episodes if successfulErr(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);
}Sourcepub async fn update_episode(
&mut self,
episode_id: &str,
title: Option<&str>,
content: Option<&str>,
status: Option<&str>,
publish_timestamp: Option<i64>,
) -> PodbeanResult<()>
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 updatetitle- Optional new titlecontent- Optional new content/descriptionstatus- Optional new statuspublish_timestamp- Optional new publication timestamp
§Returns
Ok(())if update was successfulErr(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");Sourcepub async fn delete_episode(&mut self, episode_id: &str) -> PodbeanResult<()>
pub async fn delete_episode(&mut self, episode_id: &str) -> PodbeanResult<()>
Sourcepub async fn list_podcasts(
&mut self,
offset: Option<u32>,
limit: Option<u32>,
) -> PodbeanResult<PodcastListResponse>
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 offsetlimit- Optional number of podcasts to return
§Returns
Ok(PodcastListResponse)containing the podcasts if successfulErr(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);
}Sourcepub async fn list_media(
&mut self,
offset: Option<u32>,
limit: Option<u32>,
) -> PodbeanResult<MediaListResponse>
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 offsetlimit- Optional number of media files to return
§Returns
Ok(MediaListResponse)containing the media files if successfulErr(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);
}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 authorizationstate- Optional state parameter for CSRF protection
§Returns
Ok(String)containing the authorization URL if successfulErr(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
impl Clone for PodbeanClient
Source§fn clone(&self) -> PodbeanClient
fn clone(&self) -> PodbeanClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more