webhook optional client

This commit is contained in:
Brandon Thomas committed 2026-05-11 10:50:25 -04:00
1 parent 190c0c65c8
commit 0b6b49f3f8
5 files changed
+37

No files matched your search

@@ -5,5 +5,6 @@ pub mod request_mismatch_mitigation_strategy;
pub mod router_artcraft_client;
pub mod router_client;
pub mod router_fal_client;
pub mod router_fal_webhook_optional_client;
pub mod router_muapi_client;
pub mod router_seedance2pro_client;
@@ -1,5 +1,6 @@
use crate::client::router_artcraft_client::RouterArtcraftClient;
use crate::client::router_fal_client::RouterFalClient;
use crate::client::router_fal_webhook_optional_client::RouterFalWebhookOptionalClient;
use crate::client::router_muapi_client::RouterMuapiClient;
use crate::client::router_seedance2pro_client::RouterSeedance2ProClient;
use crate::errors::client_error::{ClientError, ClientType};
@@ -7,6 +8,7 @@ use crate::errors::client_error::{ClientError, ClientType};
pub struct MultiRouterClient {
pub(crate) artcraft_client: Option<RouterArtcraftClient>,
pub(crate) fal_client: Option<RouterFalClient>,
pub(crate) fal_webhook_optional_client: Option<RouterFalWebhookOptionalClient>,
pub(crate) muapi_client: Option<RouterMuapiClient>,
pub(crate) seedance2pro_client: Option<RouterSeedance2ProClient>,
}
@@ -21,6 +23,10 @@ impl MultiRouterClient {
self.fal_client.as_ref()
.ok_or(ClientError::ClientNotConfigured(ClientType::Fal))
}
pub fn get_fal_webhook_optional_client_ref(&self) -> Result<&RouterFalWebhookOptionalClient, ClientError> {
self.fal_webhook_optional_client.as_ref()
.ok_or(ClientError::ClientNotConfigured(ClientType::FalWebhookOptional))
}
pub fn get_muapi_client_ref(&self) -> Result<&RouterMuapiClient, ClientError> {
self.muapi_client.as_ref()
@@ -1,12 +1,14 @@
use crate::client::multi_router_client::MultiRouterClient;
use crate::client::router_artcraft_client::RouterArtcraftClient;
use crate::client::router_fal_client::RouterFalClient;
use crate::client::router_fal_webhook_optional_client::RouterFalWebhookOptionalClient;
use crate::client::router_muapi_client::RouterMuapiClient;
use crate::client::router_seedance2pro_client::RouterSeedance2ProClient;
pub struct MultiRouterClientBuilder {
artcraft_client: Option<RouterArtcraftClient>,
fal_client: Option<RouterFalClient>,
fal_webhook_optional_client: Option<RouterFalWebhookOptionalClient>,
muapi_client: Option<RouterMuapiClient>,
seedance2pro_client: Option<RouterSeedance2ProClient>,
}
@@ -16,6 +18,7 @@ impl MultiRouterClientBuilder {
Self {
artcraft_client: None,
fal_client: None,
fal_webhook_optional_client: None,
muapi_client: None,
seedance2pro_client: None,
}
@@ -30,6 +33,11 @@ impl MultiRouterClientBuilder {
self.fal_client = Some(client);
self
}
pub fn set_fal_webhook_optional_client(mut self, client: RouterFalWebhookOptionalClient) -> Self {
self.fal_webhook_optional_client = Some(client);
self
}
pub fn set_muapi_client(mut self, client: RouterMuapiClient) -> Self {
self.muapi_client = Some(client);
@@ -45,6 +53,7 @@ impl MultiRouterClientBuilder {
MultiRouterClient {
artcraft_client: self.artcraft_client,
fal_client: self.fal_client,
fal_webhook_optional_client: self.fal_webhook_optional_client,
muapi_client: self.muapi_client,
seedance2pro_client: self.seedance2pro_client,
}
@@ -0,0 +1,19 @@
use fal_client::creds::fal_api_key::FalApiKey;
pub struct RouterFalWebhookOptionalClient {
pub(crate) api_key: FalApiKey,
pub(crate) webhook_url: Option<String>,
}
impl RouterFalWebhookOptionalClient {
pub fn new(api_key: FalApiKey) -> Self {
Self { api_key, webhook_url: None }
}
pub fn new_with_webhook(api_key: FalApiKey, webhook_url: String) -> Self {
Self {
api_key,
webhook_url: Some(webhook_url)
}
}
}
@@ -7,6 +7,7 @@ use tokens::tokens::media_files::MediaFileToken;
pub enum ClientType {
Artcraft,
Fal,
FalWebhookOptional,
Muapi,
Seedance2Pro,
}
@@ -16,6 +17,7 @@ impl Display for ClientType {
match self {
Self::Artcraft => write!(f, "Artcraft"),
Self::Fal => write!(f, "Fal"),
Self::FalWebhookOptional => write!(f, "FalWebhookOptional"),
Self::Muapi => write!(f, "Muapi"),
Self::Seedance2Pro => write!(f, "Seedance2Pro"),
}