refactor(subscription): make invoice as an id type (#9488)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: Jagan <jaganelavarasan@gmail.com>
This commit is contained in:
Prajjwal Kumar
2025-09-24 16:08:03 +05:30
committed by GitHub
parent 9dbfeda43d
commit 3a4bc986d4
4 changed files with 31 additions and 7 deletions

View File

@ -86,6 +86,7 @@ pub enum ApiEventsType {
},
Routing,
Subscription,
Invoice,
ResourceListAPI,
#[cfg(feature = "v1")]
PaymentRedirectionResponse {

View File

@ -7,6 +7,7 @@ mod client_secret;
mod customer;
#[cfg(feature = "v2")]
mod global_id;
mod invoice;
mod merchant;
mod merchant_connector_account;
mod organization;
@ -47,6 +48,7 @@ pub use self::{
authentication::AuthenticationId,
client_secret::ClientSecretId,
customer::CustomerId,
invoice::InvoiceId,
merchant::MerchantId,
merchant_connector_account::MerchantConnectorAccountId,
organization::OrganizationId,

View File

@ -0,0 +1,21 @@
crate::id_type!(
InvoiceId,
" A type for invoice_id that can be used for invoice ids"
);
crate::impl_id_type_methods!(InvoiceId, "invoice_id");
// This is to display the `InvoiceId` as InvoiceId(subs)
crate::impl_debug_id_type!(InvoiceId);
crate::impl_try_from_cow_str_id_type!(InvoiceId, "invoice_id");
crate::impl_generate_id_id_type!(InvoiceId, "invoice");
crate::impl_serializable_secret_id_type!(InvoiceId);
crate::impl_queryable_id_type!(InvoiceId);
crate::impl_to_sql_from_sql_id_type!(InvoiceId);
impl crate::events::ApiEventMetric for InvoiceId {
fn get_api_event_type(&self) -> Option<crate::events::ApiEventsType> {
Some(crate::events::ApiEventsType::Invoice)
}
}