refactor(storage): update crate name to diesel models (#1685)

This commit is contained in:
Sampras Lopes
2023-07-12 18:20:55 +05:30
committed by GitHub
parent 57c9dc414c
commit 5a0e8be8c4
159 changed files with 338 additions and 346 deletions

View File

@ -135,7 +135,7 @@ impl<Flow, Request, Response> RouterData for types::RouterData<Flow, Request, Re
fn is_three_ds(&self) -> bool {
matches!(
self.auth_type,
storage_models::enums::AuthenticationType::ThreeDs
diesel_models::enums::AuthenticationType::ThreeDs
)
}
@ -170,8 +170,8 @@ impl<Flow, Request, Response> RouterData for types::RouterData<Flow, Request, Re
pub trait PaymentsPreProcessingData {
fn get_email(&self) -> Result<Email, Error>;
fn get_payment_method_type(&self) -> Result<storage_models::enums::PaymentMethodType, Error>;
fn get_currency(&self) -> Result<storage_models::enums::Currency, Error>;
fn get_payment_method_type(&self) -> Result<diesel_models::enums::PaymentMethodType, Error>;
fn get_currency(&self) -> Result<diesel_models::enums::Currency, Error>;
fn get_amount(&self) -> Result<i64, Error>;
}
@ -179,12 +179,12 @@ impl PaymentsPreProcessingData for types::PaymentsPreProcessingData {
fn get_email(&self) -> Result<Email, Error> {
self.email.clone().ok_or_else(missing_field_err("email"))
}
fn get_payment_method_type(&self) -> Result<storage_models::enums::PaymentMethodType, Error> {
fn get_payment_method_type(&self) -> Result<diesel_models::enums::PaymentMethodType, Error> {
self.payment_method_type
.to_owned()
.ok_or_else(missing_field_err("payment_method_type"))
}
fn get_currency(&self) -> Result<storage_models::enums::Currency, Error> {
fn get_currency(&self) -> Result<diesel_models::enums::Currency, Error> {
self.currency.ok_or_else(missing_field_err("currency"))
}
fn get_amount(&self) -> Result<i64, Error> {
@ -204,15 +204,15 @@ pub trait PaymentsAuthorizeRequestData {
fn get_webhook_url(&self) -> Result<String, Error>;
fn get_router_return_url(&self) -> Result<String, Error>;
fn is_wallet(&self) -> bool;
fn get_payment_method_type(&self) -> Result<storage_models::enums::PaymentMethodType, Error>;
fn get_payment_method_type(&self) -> Result<diesel_models::enums::PaymentMethodType, Error>;
fn get_connector_mandate_id(&self) -> Result<String, Error>;
}
impl PaymentsAuthorizeRequestData for types::PaymentsAuthorizeData {
fn is_auto_capture(&self) -> Result<bool, Error> {
match self.capture_method {
Some(storage_models::enums::CaptureMethod::Automatic) | None => Ok(true),
Some(storage_models::enums::CaptureMethod::Manual) => Ok(false),
Some(diesel_models::enums::CaptureMethod::Automatic) | None => Ok(true),
Some(diesel_models::enums::CaptureMethod::Manual) => Ok(false),
Some(_) => Err(errors::ConnectorError::CaptureMethodNotSupported.into()),
}
}
@ -273,7 +273,7 @@ impl PaymentsAuthorizeRequestData for types::PaymentsAuthorizeData {
matches!(self.payment_method_data, api::PaymentMethodData::Wallet(_))
}
fn get_payment_method_type(&self) -> Result<storage_models::enums::PaymentMethodType, Error> {
fn get_payment_method_type(&self) -> Result<diesel_models::enums::PaymentMethodType, Error> {
self.payment_method_type
.to_owned()
.ok_or_else(missing_field_err("payment_method_type"))
@ -354,8 +354,8 @@ pub trait PaymentsCompleteAuthorizeRequestData {
impl PaymentsCompleteAuthorizeRequestData for types::CompleteAuthorizeData {
fn is_auto_capture(&self) -> Result<bool, Error> {
match self.capture_method {
Some(storage_models::enums::CaptureMethod::Automatic) | None => Ok(true),
Some(storage_models::enums::CaptureMethod::Manual) => Ok(false),
Some(diesel_models::enums::CaptureMethod::Automatic) | None => Ok(true),
Some(diesel_models::enums::CaptureMethod::Manual) => Ok(false),
Some(_) => Err(errors::ConnectorError::CaptureMethodNotSupported.into()),
}
}
@ -372,8 +372,8 @@ pub trait PaymentsSyncRequestData {
impl PaymentsSyncRequestData for types::PaymentsSyncData {
fn is_auto_capture(&self) -> Result<bool, Error> {
match self.capture_method {
Some(storage_models::enums::CaptureMethod::Automatic) | None => Ok(true),
Some(storage_models::enums::CaptureMethod::Manual) => Ok(false),
Some(diesel_models::enums::CaptureMethod::Automatic) | None => Ok(true),
Some(diesel_models::enums::CaptureMethod::Manual) => Ok(false),
Some(_) => Err(errors::ConnectorError::CaptureMethodNotSupported.into()),
}
}
@ -392,7 +392,7 @@ impl PaymentsSyncRequestData for types::PaymentsSyncData {
pub trait PaymentsCancelRequestData {
fn get_amount(&self) -> Result<i64, Error>;
fn get_currency(&self) -> Result<storage_models::enums::Currency, Error>;
fn get_currency(&self) -> Result<diesel_models::enums::Currency, Error>;
fn get_cancellation_reason(&self) -> Result<String, Error>;
}
@ -400,7 +400,7 @@ impl PaymentsCancelRequestData for PaymentsCancelData {
fn get_amount(&self) -> Result<i64, Error> {
self.amount.ok_or_else(missing_field_err("amount"))
}
fn get_currency(&self) -> Result<storage_models::enums::Currency, Error> {
fn get_currency(&self) -> Result<diesel_models::enums::Currency, Error> {
self.currency.ok_or_else(missing_field_err("currency"))
}
fn get_cancellation_reason(&self) -> Result<String, Error> {
@ -852,7 +852,7 @@ pub fn base64_decode(data: String) -> Result<Vec<u8>, Error> {
pub fn to_currency_base_unit_from_optional_amount(
amount: Option<i64>,
currency: storage_models::enums::Currency,
currency: diesel_models::enums::Currency,
) -> Result<String, error_stack::Report<errors::ConnectorError>> {
match amount {
Some(a) => to_currency_base_unit(a, currency),
@ -865,7 +865,7 @@ pub fn to_currency_base_unit_from_optional_amount(
pub fn to_currency_base_unit(
amount: i64,
currency: storage_models::enums::Currency,
currency: diesel_models::enums::Currency,
) -> Result<String, error_stack::Report<errors::ConnectorError>> {
utils::to_currency_base_unit(amount, currency)
.change_context(errors::ConnectorError::RequestEncodingFailed)
@ -873,7 +873,7 @@ pub fn to_currency_base_unit(
pub fn to_currency_base_unit_asf64(
amount: i64,
currency: storage_models::enums::Currency,
currency: diesel_models::enums::Currency,
) -> Result<f64, error_stack::Report<errors::ConnectorError>> {
utils::to_currency_base_unit_asf64(amount, currency)
.change_context(errors::ConnectorError::RequestEncodingFailed)