feat(core): diesel models, domain models and db interface changes for callback_mapper table (#6571)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Prasunna Soppa
2025-01-15 15:26:14 +05:30
committed by GitHub
parent dbe0cd4d2c
commit 043cf8e0c1
18 changed files with 219 additions and 13 deletions

View File

@ -6,6 +6,7 @@ pub mod blocklist;
pub mod blocklist_fingerprint;
pub mod blocklist_lookup;
pub mod business_profile;
pub mod callback_mapper;
pub mod capture;
pub mod cards_info;
pub mod configs;

View File

@ -0,0 +1,53 @@
use error_stack::report;
use hyperswitch_domain_models::callback_mapper as domain;
use router_env::{instrument, tracing};
use storage_impl::DataModelExt;
use super::Store;
use crate::{
connection,
core::errors::{self, CustomResult},
types::storage,
};
#[async_trait::async_trait]
pub trait CallbackMapperInterface {
async fn insert_call_back_mapper(
&self,
call_back_mapper: domain::CallbackMapper,
) -> CustomResult<domain::CallbackMapper, errors::StorageError>;
async fn find_call_back_mapper_by_id(
&self,
id: &str,
) -> CustomResult<domain::CallbackMapper, errors::StorageError>;
}
#[async_trait::async_trait]
impl CallbackMapperInterface for Store {
#[instrument(skip_all)]
async fn insert_call_back_mapper(
&self,
call_back_mapper: domain::CallbackMapper,
) -> CustomResult<domain::CallbackMapper, errors::StorageError> {
let conn = connection::pg_connection_write(self).await?;
call_back_mapper
.to_storage_model()
.insert(&conn)
.await
.map_err(|error| report!(errors::StorageError::from(error)))
.map(domain::CallbackMapper::from_storage_model)
}
#[instrument(skip_all)]
async fn find_call_back_mapper_by_id(
&self,
id: &str,
) -> CustomResult<domain::CallbackMapper, errors::StorageError> {
let conn = connection::pg_connection_read(self).await?;
storage::CallbackMapper::find_by_id(&conn, id)
.await
.map_err(|error| report!(errors::StorageError::from(error)))
.map(domain::CallbackMapper::from_storage_model)
}
}

View File

@ -28,7 +28,7 @@ use hyperswitch_domain_models::{
use hyperswitch_domain_models::{PayoutAttemptInterface, PayoutsInterface};
use masking::Secret;
use redis_interface::{errors::RedisError, RedisConnectionPool, RedisEntryId};
use router_env::logger;
use router_env::{instrument, logger, tracing};
use scheduler::{
db::{process_tracker::ProcessTrackerInterface, queue::QueueInterface},
SchedulerInterface,
@ -55,6 +55,7 @@ use crate::{
authentication::AuthenticationInterface,
authorization::AuthorizationInterface,
business_profile::ProfileInterface,
callback_mapper::CallbackMapperInterface,
capture::CaptureInterface,
cards_info::CardsInfoInterface,
configs::ConfigInterface,
@ -3889,3 +3890,24 @@ impl ThemeInterface for KafkaStore {
.await
}
}
#[async_trait::async_trait]
impl CallbackMapperInterface for KafkaStore {
#[instrument(skip_all)]
async fn insert_call_back_mapper(
&self,
call_back_mapper: domain::CallbackMapper,
) -> CustomResult<domain::CallbackMapper, errors::StorageError> {
self.diesel_store
.insert_call_back_mapper(call_back_mapper)
.await
}
#[instrument(skip_all)]
async fn find_call_back_mapper_by_id(
&self,
id: &str,
) -> CustomResult<domain::CallbackMapper, errors::StorageError> {
self.diesel_store.find_call_back_mapper_by_id(id).await
}
}

View File

@ -16,6 +16,10 @@ mod customers {
pub use hyperswitch_domain_models::customer::*;
}
mod callback_mapper {
pub use hyperswitch_domain_models::callback_mapper::CallbackMapper;
}
pub use customers::*;
pub use merchant_account::*;
@ -39,6 +43,7 @@ pub mod user_key_store;
pub use address::*;
pub use business_profile::*;
pub use callback_mapper::*;
pub use consts::*;
pub use event::*;
pub use merchant_connector_account::*;

View File

@ -6,6 +6,7 @@ pub mod blocklist;
pub mod blocklist_fingerprint;
pub mod blocklist_lookup;
pub mod business_profile;
pub mod callback_mapper;
pub mod capture;
pub mod cards_info;
pub mod configs;
@ -63,13 +64,13 @@ pub use scheduler::db::process_tracker;
pub use self::{
address::*, api_keys::*, authentication::*, authorization::*, blocklist::*,
blocklist_fingerprint::*, blocklist_lookup::*, business_profile::*, capture::*, cards_info::*,
configs::*, customers::*, dashboard_metadata::*, dispute::*, dynamic_routing_stats::*,
ephemeral_key::*, events::*, file::*, fraud_check::*, generic_link::*, gsm::*,
locker_mock_up::*, mandate::*, merchant_account::*, merchant_connector_account::*,
merchant_key_store::*, payment_link::*, payment_method::*, process_tracker::*, refund::*,
reverse_lookup::*, role::*, routing_algorithm::*, unified_translations::*, user::*,
user_authentication_method::*, user_role::*,
blocklist_fingerprint::*, blocklist_lookup::*, business_profile::*, callback_mapper::*,
capture::*, cards_info::*, configs::*, customers::*, dashboard_metadata::*, dispute::*,
dynamic_routing_stats::*, ephemeral_key::*, events::*, file::*, fraud_check::*,
generic_link::*, gsm::*, locker_mock_up::*, mandate::*, merchant_account::*,
merchant_connector_account::*, merchant_key_store::*, payment_link::*, payment_method::*,
process_tracker::*, refund::*, reverse_lookup::*, role::*, routing_algorithm::*,
unified_translations::*, user::*, user_authentication_method::*, user_role::*,
};
use crate::types::api::routing;

View File

@ -0,0 +1 @@
pub use diesel_models::callback_mapper::CallbackMapper;