Repository: juspay/hyperswitch
File: crates/api_models/src/payment_methods.rs (Rust)

Code before:
    /// Card Expiry Month
    #[schema(value_type = String,example = "10")]
    pub card_exp_month: Option<masking::Secret<String>>,

    /// Card Expiry Year
    #[schema(value_type = String,example = "25")]
    pub card_exp_year: Option<masking::Secret<String>>,

    /// Card Holder Name
    #[schema(value_type = String,example = "John Doe")]
    pub card_holder_name: Option<masking::Secret<String>>,

    /// Card Holder's Nick Name
    #[schema(value_type = Option<String>,example = "John Doe")]
    pub nick_name: Option<masking::Secret<String>>,

    /// Card's Last 4 Digits
    #[schema(value_type = Option<String>,example = "1111")]
    pub last4_digits: Option<String>,

    /// Issuing Bank of the Particular Card
    #[schema(value_type = Option<String>,example = "Bank of America")]
    pub card_issuer: Option<String>,

    /// The country where that particular card was issued
    #[schema(value_type = Option<String>,example = "US")]
    pub issuer_country: Option<String>,
}

#[cfg(feature = "v1")]
impl CardDetailUpdate {
    pub fn apply(&self, card_data_from_locker: Card) -> CardDetail {
        CardDetail {
            card_number: card_data_from_locker.card_number,
            card_exp_month: self
                .card_exp_month
                .clone()
                .unwrap_or(card_data_from_locker.card_exp_month),
            card_exp_year: self
                .card_exp_year
                .clone()
                .unwrap_or(card_data_from_locker.card_exp_year),
            card_holder_name: self
                .card_holder_name
                .clone()
                .or(card_data_from_locker.name_on_card),
            nick_name: self
                .nick_name
                .clone()
                .or(card_data_from_locker.nick_name.map(masking::Secret::new)),
            card_issuing_country: None,

Review comment (suggestion):
nit -
```suggestion
    #[schema(value_type = Option<String>, example = "1111")]
    pub last4_digits: Option<String>,

    /// Issuing Bank of the Particular Card
    #[schema(value_type = Option<String>, example = "Bank of America")]
    pub card_issuer: Option<String>,

    /// The country where that particular card was issued
    #[schema(value_type = Option<String>, example = "US")]
```

Code after:

#[cfg(feature = "v1")]
#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)]
#[serde(deny_unknown_fields)]
pub struct CardDetailUpdate {
    /// Card Expiry Month
    #[schema(value_type = String, example = "10")]
    pub card_exp_month: Option<masking::Secret<String>>,

    /// Card Expiry Year
    #[schema(value_type = String, example = "25")]
    pub card_exp_year: Option<masking::Secret<String>>,

    /// Card Holder Name
    #[schema(value_type = String, example = "John Doe")]
    pub card_holder_name: Option<masking::Secret<String>>,

    /// Card Holder's Nick Name
    #[schema(value_type = Option<String>, example = "John Doe")]
    pub nick_name: Option<masking::Secret<String>>,

    /// Card's Last 4 Digits
    #[schema(value_type = Option<String>, example = "1111")]
    pub last4_digits: Option<String>,

    /// Issuing Bank of the Particular Card
    #[schema(value_type = Option<String>, example = "Bank of America")]
    pub card_issuer: Option<String>,

    /// The country where that particular card was issued
    #[schema(value_type = Option<String>, example = "US")]
    pub issuer_country: Option<String>,

    /// The card network
    #[schema(value_type = Option<String>, example = "VISA")]
    pub card_network: Option<common_enums::CardNetwork>,
}

#[cfg(feature = "v1")]
impl CardDetailUpdate {
    pub fn apply(&self, card_data_from_locker: Card) -> CardDetail {
        CardDetail {
            card_number: card_data_from_locker.card_number,
            card_exp_month: self
                .card_exp_month
                .clone()
                .unwrap_or(card_data_from_locker.card_exp_month),
            card_exp_year: self
                .card_exp_year
                .clone()
                .unwrap_or(card_data_from_locker.card_exp_year),