Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
use diesel::{associations::HasTable, ExpressionMethods};
use error_stack::ResultExt;
use super::generics;
use crate::{
kv,
reverse_lookup::{ReverseLookup, ReverseLookupNew},
schema::reverse_lookup::dsl,
DatabaseConnectionWithContext, StorageResult,
};
impl ReverseLookupNew {
pub async fn insert(
self,
conn: &DatabaseConnectionWithContext<'_>,
) -> StorageResult<ReverseLookup> {
generics::generic_insert(conn, self).await
}
pub async fn batch_insert(
reverse_lookups: Vec<Self>,
conn: &DatabaseConnectionWithContext<'_>,
) -> StorageResult<()> {
generics::generic_insert::<_, _, ReverseLookup>(conn, reverse_lookups).await?;
Ok(())
}
pub async fn generate_drainer_insert_query(
self,
conn: &mut DatabaseConnectionWithContext<'_>,
) -> StorageResult<kv::SerializableQuery> {
kv::generate_insert_query(conn, self)
.await
.attach_printable("Failed to generate insert query for reverse lookup")
}
}
impl ReverseLookup {
pub async fn find_by_lookup_id(
lookup_id: &str,
conn: &DatabaseConnectionWithContext<'_>,
) -> StorageResult<Self> {
generics::generic_find_one::<<Self as HasTable>::Table, _, _>(
conn,
dsl::lookup_id.eq(lookup_id.to_owned()),
)
.await
}
}