mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 04:04:55 +08:00
refactor(router): add domain type for merchant_connector_account id (#5685)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Co-authored-by: Sanchith Hegde <sanchith.hegde@juspay.in>
This commit is contained in:
committed by
GitHub
parent
f33e1bb65c
commit
771f48cfe0
@ -5,6 +5,7 @@ use std::{borrow::Cow, fmt::Debug};
|
||||
|
||||
mod customer;
|
||||
mod merchant;
|
||||
mod merchant_connector_account;
|
||||
mod organization;
|
||||
mod profile;
|
||||
|
||||
@ -19,6 +20,7 @@ use diesel::{
|
||||
sql_types,
|
||||
};
|
||||
pub use merchant::MerchantId;
|
||||
pub use merchant_connector_account::MerchantConnectorAccountId;
|
||||
pub use organization::OrganizationId;
|
||||
pub use profile::ProfileId;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
use crate::errors::{CustomResult, ValidationError};
|
||||
|
||||
crate::id_type!(
|
||||
MerchantConnectorAccountId,
|
||||
"A type for merchant_connector_id that can be used for merchant_connector_account ids"
|
||||
);
|
||||
crate::impl_id_type_methods!(MerchantConnectorAccountId, "merchant_connector_id");
|
||||
|
||||
// This is to display the `MerchantConnectorAccountId` as MerchantConnectorAccountId(abcd)
|
||||
crate::impl_debug_id_type!(MerchantConnectorAccountId);
|
||||
crate::impl_generate_id_id_type!(MerchantConnectorAccountId, "mca");
|
||||
crate::impl_try_from_cow_str_id_type!(MerchantConnectorAccountId, "merchant_connector_id");
|
||||
|
||||
crate::impl_serializable_secret_id_type!(MerchantConnectorAccountId);
|
||||
crate::impl_queryable_id_type!(MerchantConnectorAccountId);
|
||||
crate::impl_to_sql_from_sql_id_type!(MerchantConnectorAccountId);
|
||||
|
||||
impl MerchantConnectorAccountId {
|
||||
/// Get a merchant connector account id from String
|
||||
pub fn wrap(merchant_connector_account_id: String) -> CustomResult<Self, ValidationError> {
|
||||
Self::try_from(std::borrow::Cow::from(merchant_connector_account_id))
|
||||
}
|
||||
}
|
||||
@ -233,6 +233,14 @@ pub fn generate_profile_id_of_default_length() -> id_type::ProfileId {
|
||||
id_type::ProfileId::generate()
|
||||
}
|
||||
|
||||
/// Generate a merchant_connector_account id with default length, with prefix as `mca`
|
||||
pub fn generate_merchant_connector_account_id_of_default_length(
|
||||
) -> id_type::MerchantConnectorAccountId {
|
||||
use id_type::GenerateId;
|
||||
|
||||
id_type::MerchantConnectorAccountId::generate()
|
||||
}
|
||||
|
||||
/// Generate a nanoid with the given prefix and a default length
|
||||
#[inline]
|
||||
pub fn generate_id_with_default_len(prefix: &str) -> String {
|
||||
|
||||
Reference in New Issue
Block a user