mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
feat(routing): add domain type for Routing id (#5733)
Co-authored-by: Sanchith Hegde <sanchith.hegde@juspay.in> Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -8,6 +8,7 @@ mod merchant;
|
||||
mod merchant_connector_account;
|
||||
mod organization;
|
||||
mod profile;
|
||||
mod routing;
|
||||
|
||||
mod global_id;
|
||||
|
||||
@ -23,6 +24,7 @@ pub use merchant::MerchantId;
|
||||
pub use merchant_connector_account::MerchantConnectorAccountId;
|
||||
pub use organization::OrganizationId;
|
||||
pub use profile::ProfileId;
|
||||
pub use routing::RoutingId;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use thiserror::Error;
|
||||
|
||||
|
||||
21
crates/common_utils/src/id_type/routing.rs
Normal file
21
crates/common_utils/src/id_type/routing.rs
Normal file
@ -0,0 +1,21 @@
|
||||
crate::id_type!(
|
||||
RoutingId,
|
||||
" A type for routing_id that can be used for routing ids"
|
||||
);
|
||||
|
||||
crate::impl_id_type_methods!(RoutingId, "routing_id");
|
||||
|
||||
// This is to display the `RoutingId` as RoutingId(abcd)
|
||||
crate::impl_debug_id_type!(RoutingId);
|
||||
crate::impl_try_from_cow_str_id_type!(RoutingId, "routing_id");
|
||||
|
||||
crate::impl_generate_id_id_type!(RoutingId, "routing");
|
||||
crate::impl_serializable_secret_id_type!(RoutingId);
|
||||
crate::impl_queryable_id_type!(RoutingId);
|
||||
crate::impl_to_sql_from_sql_id_type!(RoutingId);
|
||||
|
||||
impl crate::events::ApiEventMetric for RoutingId {
|
||||
fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> {
|
||||
Some(crate::events::ApiEventsType::Routing)
|
||||
}
|
||||
}
|
||||
@ -233,6 +233,12 @@ pub fn generate_profile_id_of_default_length() -> id_type::ProfileId {
|
||||
id_type::ProfileId::generate()
|
||||
}
|
||||
|
||||
/// Generate a routing id with default length, with prefix as `routing`
|
||||
pub fn generate_routing_id_of_default_length() -> id_type::RoutingId {
|
||||
use id_type::GenerateId;
|
||||
|
||||
id_type::RoutingId::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 {
|
||||
|
||||
Reference in New Issue
Block a user