koprogo_api/application/ports/
payment_method_repository.rs1use crate::domain::entities::payment_method::{PaymentMethod, PaymentMethodType};
2use async_trait::async_trait;
3use uuid::Uuid;
4
5#[async_trait]
6pub trait PaymentMethodRepository: Send + Sync {
7 async fn create(&self, payment_method: &PaymentMethod) -> Result<PaymentMethod, String>;
9
10 async fn find_by_id(&self, id: Uuid) -> Result<Option<PaymentMethod>, String>;
12
13 async fn find_by_stripe_payment_method_id(
15 &self,
16 stripe_payment_method_id: &str,
17 ) -> Result<Option<PaymentMethod>, String>;
18
19 async fn find_by_owner(&self, owner_id: Uuid) -> Result<Vec<PaymentMethod>, String>;
21
22 async fn find_active_by_owner(&self, owner_id: Uuid) -> Result<Vec<PaymentMethod>, String>;
24
25 async fn find_default_by_owner(&self, owner_id: Uuid) -> Result<Option<PaymentMethod>, String>;
27
28 async fn find_by_organization(
30 &self,
31 organization_id: Uuid,
32 ) -> Result<Vec<PaymentMethod>, String>;
33
34 async fn find_by_owner_and_type(
36 &self,
37 owner_id: Uuid,
38 method_type: PaymentMethodType,
39 ) -> Result<Vec<PaymentMethod>, String>;
40
41 async fn update(&self, payment_method: &PaymentMethod) -> Result<PaymentMethod, String>;
43
44 async fn delete(&self, id: Uuid) -> Result<bool, String>;
46
47 async fn set_as_default(&self, id: Uuid, owner_id: Uuid) -> Result<PaymentMethod, String>;
49
50 async fn count_active_by_owner(&self, owner_id: Uuid) -> Result<i64, String>;
52
53 async fn has_active_payment_methods(&self, owner_id: Uuid) -> Result<bool, String>;
55}