Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Replace euclid enum with RoutableConnectors enum #2994

Merged
merged 10 commits into from
Nov 28, 2023
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion connector-template/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ impl ConnectorCommon for {{project-name | downcase | pascal_case}} {
message: response.message,
reason: response.reason,
attempt_status: None,
connector_transaction_id: None,
})
}
}
Expand Down Expand Up @@ -485,7 +486,7 @@ impl api::IncomingWebhook for {{project-name | downcase | pascal_case}} {
fn get_webhook_resource_object(
&self,
_request: &api::IncomingWebhookRequestDetails<'_>,
) -> CustomResult<Box<dyn erased_serde::Serialize>, errors::ConnectorError> {
) -> CustomResult<Box<dyn masking::ErasedMaskSerialize>, errors::ConnectorError> {
Err(errors::ConnectorError::WebhooksNotImplemented).into_report()
}
}
98 changes: 0 additions & 98 deletions crates/api_models/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,104 +147,6 @@ impl Connector {
}
}

#[derive(
Clone,
Copy,
Debug,
Eq,
Hash,
PartialEq,
serde::Serialize,
serde::Deserialize,
strum::Display,
strum::EnumString,
strum::EnumIter,
strum::EnumVariantNames,
)]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum RoutableConnectors {
#[cfg(feature = "dummy_connector")]
#[serde(rename = "phonypay")]
#[strum(serialize = "phonypay")]
DummyConnector1,
#[cfg(feature = "dummy_connector")]
#[serde(rename = "fauxpay")]
#[strum(serialize = "fauxpay")]
DummyConnector2,
#[cfg(feature = "dummy_connector")]
#[serde(rename = "pretendpay")]
#[strum(serialize = "pretendpay")]
DummyConnector3,
#[cfg(feature = "dummy_connector")]
#[serde(rename = "stripe_test")]
#[strum(serialize = "stripe_test")]
DummyConnector4,
#[cfg(feature = "dummy_connector")]
#[serde(rename = "adyen_test")]
#[strum(serialize = "adyen_test")]
DummyConnector5,
#[cfg(feature = "dummy_connector")]
#[serde(rename = "checkout_test")]
#[strum(serialize = "checkout_test")]
DummyConnector6,
#[cfg(feature = "dummy_connector")]
#[serde(rename = "paypal_test")]
#[strum(serialize = "paypal_test")]
DummyConnector7,
Aci,
Adyen,
Airwallex,
Authorizedotnet,
Bankofamerica,
Bitpay,
Bambora,
Bluesnap,
Boku,
Braintree,
Cashtocode,
Checkout,
Coinbase,
Cryptopay,
Cybersource,
Dlocal,
Fiserv,
Forte,
Globalpay,
Globepay,
Gocardless,
Helcim,
Iatapay,
Klarna,
Mollie,
Multisafepay,
Nexinets,
Nmi,
Noon,
Nuvei,
// Opayo, added as template code for future usage
Opennode,
// Payeezy, As psync and rsync are not supported by this connector, it is added as template code for future usage
Payme,
Paypal,
Payu,
Powertranz,
Prophetpay,
Rapyd,
Shift4,
Square,
Stax,
Stripe,
Trustpay,
// Tsys,
Tsys,
Volt,
Wise,
Worldline,
Worldpay,
Zen,
}

#[cfg(feature = "payouts")]
#[derive(
Clone,
Expand Down
67 changes: 1 addition & 66 deletions crates/api_models/src/routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use common_utils::errors::ParsingError;
use error_stack::IntoReport;
use euclid::{
dssa::types::EuclidAnalysable,
enums as euclid_enums,
frontend::{
ast,
dir::{DirKeyKind, EuclidDirFilter},
Expand Down Expand Up @@ -287,71 +286,7 @@ impl From<RoutableConnectorChoice> for RoutableChoiceSerde {
impl From<RoutableConnectorChoice> for ast::ConnectorChoice {
fn from(value: RoutableConnectorChoice) -> Self {
Self {
connector: match value.connector {
#[cfg(feature = "dummy_connector")]
RoutableConnectors::DummyConnector1 => euclid_enums::Connector::DummyConnector1,
#[cfg(feature = "dummy_connector")]
RoutableConnectors::DummyConnector2 => euclid_enums::Connector::DummyConnector2,
#[cfg(feature = "dummy_connector")]
RoutableConnectors::DummyConnector3 => euclid_enums::Connector::DummyConnector3,
#[cfg(feature = "dummy_connector")]
RoutableConnectors::DummyConnector4 => euclid_enums::Connector::DummyConnector4,
#[cfg(feature = "dummy_connector")]
RoutableConnectors::DummyConnector5 => euclid_enums::Connector::DummyConnector5,
#[cfg(feature = "dummy_connector")]
RoutableConnectors::DummyConnector6 => euclid_enums::Connector::DummyConnector6,
#[cfg(feature = "dummy_connector")]
RoutableConnectors::DummyConnector7 => euclid_enums::Connector::DummyConnector7,
RoutableConnectors::Aci => euclid_enums::Connector::Aci,
RoutableConnectors::Adyen => euclid_enums::Connector::Adyen,
RoutableConnectors::Airwallex => euclid_enums::Connector::Airwallex,
RoutableConnectors::Authorizedotnet => euclid_enums::Connector::Authorizedotnet,
RoutableConnectors::Bambora => euclid_enums::Connector::Bambora,
RoutableConnectors::Bankofamerica => euclid_enums::Connector::Bankofamerica,
RoutableConnectors::Bitpay => euclid_enums::Connector::Bitpay,
RoutableConnectors::Bluesnap => euclid_enums::Connector::Bluesnap,
RoutableConnectors::Boku => euclid_enums::Connector::Boku,
RoutableConnectors::Braintree => euclid_enums::Connector::Braintree,
RoutableConnectors::Cashtocode => euclid_enums::Connector::Cashtocode,
RoutableConnectors::Checkout => euclid_enums::Connector::Checkout,
RoutableConnectors::Coinbase => euclid_enums::Connector::Coinbase,
RoutableConnectors::Cryptopay => euclid_enums::Connector::Cryptopay,
RoutableConnectors::Cybersource => euclid_enums::Connector::Cybersource,
RoutableConnectors::Dlocal => euclid_enums::Connector::Dlocal,
RoutableConnectors::Fiserv => euclid_enums::Connector::Fiserv,
RoutableConnectors::Forte => euclid_enums::Connector::Forte,
RoutableConnectors::Globalpay => euclid_enums::Connector::Globalpay,
RoutableConnectors::Globepay => euclid_enums::Connector::Globepay,
RoutableConnectors::Gocardless => euclid_enums::Connector::Gocardless,
RoutableConnectors::Helcim => euclid_enums::Connector::Helcim,
RoutableConnectors::Iatapay => euclid_enums::Connector::Iatapay,
RoutableConnectors::Klarna => euclid_enums::Connector::Klarna,
RoutableConnectors::Mollie => euclid_enums::Connector::Mollie,
RoutableConnectors::Multisafepay => euclid_enums::Connector::Multisafepay,
RoutableConnectors::Nexinets => euclid_enums::Connector::Nexinets,
RoutableConnectors::Nmi => euclid_enums::Connector::Nmi,
RoutableConnectors::Noon => euclid_enums::Connector::Noon,
RoutableConnectors::Nuvei => euclid_enums::Connector::Nuvei,
RoutableConnectors::Opennode => euclid_enums::Connector::Opennode,
RoutableConnectors::Payme => euclid_enums::Connector::Payme,
RoutableConnectors::Paypal => euclid_enums::Connector::Paypal,
RoutableConnectors::Payu => euclid_enums::Connector::Payu,
RoutableConnectors::Powertranz => euclid_enums::Connector::Powertranz,
RoutableConnectors::Prophetpay => euclid_enums::Connector::Prophetpay,
RoutableConnectors::Rapyd => euclid_enums::Connector::Rapyd,
RoutableConnectors::Shift4 => euclid_enums::Connector::Shift4,
RoutableConnectors::Square => euclid_enums::Connector::Square,
RoutableConnectors::Stax => euclid_enums::Connector::Stax,
RoutableConnectors::Stripe => euclid_enums::Connector::Stripe,
RoutableConnectors::Trustpay => euclid_enums::Connector::Trustpay,
RoutableConnectors::Tsys => euclid_enums::Connector::Tsys,
RoutableConnectors::Volt => euclid_enums::Connector::Volt,
RoutableConnectors::Wise => euclid_enums::Connector::Wise,
RoutableConnectors::Worldline => euclid_enums::Connector::Worldline,
RoutableConnectors::Worldpay => euclid_enums::Connector::Worldpay,
RoutableConnectors::Zen => euclid_enums::Connector::Zen,
},

connector: value.connector,
#[cfg(not(feature = "connector_choice_mca_id"))]
sub_label: value.sub_label,
}
Expand Down
4 changes: 4 additions & 0 deletions crates/common_enums/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ rust-version.workspace = true
readme = "README.md"
license.workspace = true

[features]
default = ["dummy_connector"]
dummy_connector = []

[dependencies]
diesel = { version = "2.1.0", features = ["postgres"] }
serde = { version = "1.0.160", features = ["derive"] }
Expand Down
99 changes: 99 additions & 0 deletions crates/common_enums/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,105 @@ pub enum AttemptStatus {
DeviceDataCollectionPending,
}

#[derive(
Clone,
Copy,
Debug,
Eq,
Hash,
PartialEq,
serde::Serialize,
serde::Deserialize,
strum::Display,
strum::EnumString,
strum::EnumIter,
strum::EnumVariantNames,
)]
#[router_derive::diesel_enum(storage_type = "db_enum")]
#[serde(rename_all = "snake_case")]
#[strum(serialize_all = "snake_case")]
pub enum RoutableConnectors {
#[cfg(feature = "dummy_connector")]
#[serde(rename = "phonypay")]
#[strum(serialize = "phonypay")]
DummyConnector1,
#[cfg(feature = "dummy_connector")]
#[serde(rename = "fauxpay")]
#[strum(serialize = "fauxpay")]
DummyConnector2,
#[cfg(feature = "dummy_connector")]
#[serde(rename = "pretendpay")]
#[strum(serialize = "pretendpay")]
DummyConnector3,
#[cfg(feature = "dummy_connector")]
#[serde(rename = "stripe_test")]
#[strum(serialize = "stripe_test")]
DummyConnector4,
#[cfg(feature = "dummy_connector")]
#[serde(rename = "adyen_test")]
#[strum(serialize = "adyen_test")]
DummyConnector5,
#[cfg(feature = "dummy_connector")]
#[serde(rename = "checkout_test")]
#[strum(serialize = "checkout_test")]
DummyConnector6,
#[cfg(feature = "dummy_connector")]
#[serde(rename = "paypal_test")]
#[strum(serialize = "paypal_test")]
DummyConnector7,
Aci,
Adyen,
Airwallex,
Authorizedotnet,
Bankofamerica,
Bitpay,
Bambora,
Bluesnap,
Boku,
Braintree,
Cashtocode,
Checkout,
Coinbase,
Cryptopay,
Cybersource,
Dlocal,
Fiserv,
Forte,
Globalpay,
Globepay,
Gocardless,
Helcim,
Iatapay,
Klarna,
Mollie,
Multisafepay,
Nexinets,
Nmi,
Noon,
Nuvei,
// Opayo, added as template code for future usage
Opennode,
// Payeezy, As psync and rsync are not supported by this connector, it is added as template code for future usage
Payme,
Paypal,
Payu,
Powertranz,
Prophetpay,
Rapyd,
Shift4,
Square,
Stax,
Stripe,
Trustpay,
// Tsys,
Tsys,
Volt,
Wise,
Worldline,
Worldpay,
Zen,
}

impl AttemptStatus {
pub fn is_terminal_status(self) -> bool {
match self {
Expand Down
Loading
Loading