feat(core): Rename crate data_models to hyperswitch_domain_models (#4504)

This commit is contained in:
DEEPANSHU BANSAL
2024-05-02 17:56:11 +05:30
committed by GitHub
parent 6c59d2434c
commit 86e93cd3a0
77 changed files with 309 additions and 258 deletions

View File

@ -1,16 +1,5 @@
use api_models::enums::{AuthenticationType, Connector, PaymentMethod, PaymentMethodType};
use common_utils::{errors::CustomResult, fallback_reverse_lookup_not_found};
use data_models::{
errors,
mandates::{MandateAmountData, MandateDataType, MandateDetails},
payments::{
payment_attempt::{
PaymentAttempt, PaymentAttemptInterface, PaymentAttemptNew, PaymentAttemptUpdate,
PaymentListFilters,
},
PaymentIntent,
},
};
use diesel_models::{
enums::{
MandateAmountData as DieselMandateAmountData, MandateDataType as DieselMandateType,
@ -24,6 +13,17 @@ use diesel_models::{
reverse_lookup::{ReverseLookup, ReverseLookupNew},
};
use error_stack::ResultExt;
use hyperswitch_domain_models::{
errors,
mandates::{MandateAmountData, MandateDataType, MandateDetails},
payments::{
payment_attempt::{
PaymentAttempt, PaymentAttemptInterface, PaymentAttemptNew, PaymentAttemptUpdate,
PaymentListFilters,
},
PaymentIntent,
},
};
use redis_interface::HsetnxReply;
use router_env::{instrument, tracing};

View File

@ -6,17 +6,6 @@ use async_bb8_diesel::{AsyncConnection, AsyncRunQueryDsl};
use common_utils::errors::ReportSwitchExt;
use common_utils::{date_time, ext_traits::Encode};
#[cfg(feature = "olap")]
use data_models::payments::payment_intent::PaymentIntentFetchConstraints;
use data_models::{
errors::StorageError,
payments::{
payment_attempt::PaymentAttempt,
payment_intent::{PaymentIntentInterface, PaymentIntentNew, PaymentIntentUpdate},
PaymentIntent,
},
RemoteStorageObject,
};
#[cfg(feature = "olap")]
use diesel::{associations::HasTable, ExpressionMethods, JoinOnDsl, QueryDsl};
use diesel_models::{
enums::MerchantStorageScheme,
@ -33,6 +22,17 @@ use diesel_models::{
schema::{payment_attempt::dsl as pa_dsl, payment_intent::dsl as pi_dsl},
};
use error_stack::ResultExt;
#[cfg(feature = "olap")]
use hyperswitch_domain_models::payments::payment_intent::PaymentIntentFetchConstraints;
use hyperswitch_domain_models::{
errors::StorageError,
payments::{
payment_attempt::PaymentAttempt,
payment_intent::{PaymentIntentInterface, PaymentIntentNew, PaymentIntentUpdate},
PaymentIntent,
},
RemoteStorageObject,
};
use redis_interface::HsetnxReply;
#[cfg(feature = "olap")]
use router_env::logger;
@ -257,7 +257,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
_storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<PaymentAttempt, StorageError> {
match payment.active_attempt.clone() {
data_models::RemoteStorageObject::ForeignID(attempt_id) => {
hyperswitch_domain_models::RemoteStorageObject::ForeignID(attempt_id) => {
let conn = pg_connection_read(self).await?;
let pa = DieselPaymentAttempt::find_by_merchant_id_attempt_id(
@ -271,10 +271,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
er.change_context(new_err)
})
.map(PaymentAttempt::from_storage_model)?;
payment.active_attempt = data_models::RemoteStorageObject::Object(pa.clone());
payment.active_attempt =
hyperswitch_domain_models::RemoteStorageObject::Object(pa.clone());
Ok(pa)
}
data_models::RemoteStorageObject::Object(pa) => Ok(pa.clone()),
hyperswitch_domain_models::RemoteStorageObject::Object(pa) => Ok(pa.clone()),
}
}
@ -396,7 +397,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
_storage_scheme: MerchantStorageScheme,
) -> error_stack::Result<PaymentAttempt, StorageError> {
match &payment.active_attempt {
data_models::RemoteStorageObject::ForeignID(attempt_id) => {
hyperswitch_domain_models::RemoteStorageObject::ForeignID(attempt_id) => {
let conn = pg_connection_read(self).await?;
let pa = DieselPaymentAttempt::find_by_merchant_id_attempt_id(
@ -410,10 +411,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
er.change_context(new_err)
})
.map(PaymentAttempt::from_storage_model)?;
payment.active_attempt = data_models::RemoteStorageObject::Object(pa.clone());
payment.active_attempt =
hyperswitch_domain_models::RemoteStorageObject::Object(pa.clone());
Ok(pa)
}
data_models::RemoteStorageObject::Object(pa) => Ok(pa.clone()),
hyperswitch_domain_models::RemoteStorageObject::Object(pa) => Ok(pa.clone()),
}
}