Skip to main content

ferrox_integrations/
lib.rs

1//! # Ferrox Integrations (`ferrox-integrations`)
2//!
3//! `ferrox-integrations` defines unified trait abstractions for external third-party service integrations, including `PaymentProvider`,
4//! `NotificationProvider`, `MailerProvider`, and `StorageProvider`.
5//!
6//! ## Key Features
7//! - ๐Ÿ”Œ **Standardized Provider Traits**: Common interfaces across Stripe, Slack, SendGrid, and AWS.
8//! - ๐Ÿงช **Test Mocking**: Swap external API calls with mock implementations during automated testing.
9
10use async_trait::async_trait;
11use ferrox_errors::AppError;
12
13/// An abstraction for any Payment Gateway (Stripe, PayPal, Adyen, etc.)
14#[async_trait]
15pub trait PaymentProvider: Send + Sync {
16    /// Charge a customer. Returns the external transaction ID.
17    async fn charge(&self, amount: i64, currency: &str, source_id: &str) -> Result<String, AppError>;
18    
19    /// Refund a previously executed transaction.
20    async fn refund(&self, transaction_id: &str) -> Result<(), AppError>;
21}
22
23/// An abstraction for any Notification delivery service (SendGrid, Slack, Twilio, etc.)
24#[async_trait]
25pub trait NotificationProvider: Send + Sync {
26    /// Send an email
27    async fn send_email(&self, to: &str, subject: &str, body: &str) -> Result<(), AppError>;
28    
29    /// Send a Chat Message (Slack/Teams/Discord)
30    async fn send_chat(&self, channel_id: &str, message: &str) -> Result<(), AppError>;
31}
32
33pub fn setup() {
34    println!("ferrox-integrations initialized: Third-Party API abstractions ready.");
35}