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

Code before:
    pub payment_created_enabled: Option<bool>,

    /// If this property is true, a webhook message is posted whenever a payment is successful
    #[schema(example = true)]
    pub payment_succeeded_enabled: Option<bool>,

    /// If this property is true, a webhook message is posted whenever a payment fails
    #[schema(example = true)]
    pub payment_failed_enabled: Option<bool>,

    /// List of payment statuses that triggers a webhook for payment intents
    #[schema(value_type = Vec<IntentStatus>, example = json!(["succeeded", "failed", "partially_captured", "requires_merchant_action"]))]
    pub payment_statuses_enabled: Option<Vec<api_enums::IntentStatus>>,

    /// List of refund statuses that triggers a webhook for refunds
    #[schema(value_type = Vec<IntentStatus>, example = json!(["success", "failure"]))]
    pub refund_statuses_enabled: Option<Vec<api_enums::RefundStatus>>,

    /// List of payout statuses that triggers a webhook for payouts
    #[cfg(feature = "payouts")]
    #[schema(value_type = Option<Vec<PayoutStatus>>, example = json!(["success", "failed"]))]
    pub payout_statuses_enabled: Option<Vec<api_enums::PayoutStatus>>,
}

impl WebhookDetails {
    pub fn merge(&mut self, other: Self) {
        let Self {
            webhook_version,
            webhook_username,
            webhook_password,
            webhook_url,
            payment_created_enabled,
            payment_succeeded_enabled,
            payment_failed_enabled,
            payment_statuses_enabled,
            refund_statuses_enabled,
            #[cfg(feature = "payouts")]
            payout_statuses_enabled,
        } = self;

        *webhook_version = other.webhook_version.or(webhook_version.take());
        *webhook_username = other.webhook_username.or(webhook_username.take());
        *webhook_password = other.webhook_password.or(webhook_password.take());
        *webhook_url = other.webhook_url.or(webhook_url.take());
        *payment_created_enabled = other
            .payment_created_enabled
            .or(payment_created_enabled.take());
        *payment_succeeded_enabled = other
            .payment_succeeded_enabled
            .or(payment_succeeded_enabled.take());
        *payment_failed_enabled = other

Review comment (suggestion):
```suggestion
    pub fn merge(self, other: Self) {
```

Code after:
    pub payment_created_enabled: Option<bool>,

    /// If this property is true, a webhook message is posted whenever a payment is successful
    #[schema(example = true)]
    pub payment_succeeded_enabled: Option<bool>,

    /// If this property is true, a webhook message is posted whenever a payment fails
    #[schema(example = true)]
    pub payment_failed_enabled: Option<bool>,

    /// List of payment statuses that triggers a webhook for payment intents
    #[schema(value_type = Vec<IntentStatus>, example = json!(["succeeded", "failed", "partially_captured", "requires_merchant_action"]))]
    pub payment_statuses_enabled: Option<Vec<api_enums::IntentStatus>>,

    /// List of refund statuses that triggers a webhook for refunds
    #[schema(value_type = Vec<IntentStatus>, example = json!(["success", "failure"]))]
    pub refund_statuses_enabled: Option<Vec<api_enums::RefundStatus>>,

    /// List of payout statuses that triggers a webhook for payouts
    #[cfg(feature = "payouts")]
    #[schema(value_type = Option<Vec<PayoutStatus>>, example = json!(["success", "failed"]))]
    pub payout_statuses_enabled: Option<Vec<api_enums::PayoutStatus>>,
}

impl WebhookDetails {
    pub fn merge(self, other: Self) -> Self {
        Self {
            webhook_version: other.webhook_version.or(self.webhook_version),
            webhook_username: other.webhook_username.or(self.webhook_username),
            webhook_password: other.webhook_password.or(self.webhook_password),
            webhook_url: other.webhook_url.or(self.webhook_url),
            payment_created_enabled: other
                .payment_created_enabled
                .or(self.payment_created_enabled),
            payment_succeeded_enabled: other
                .payment_succeeded_enabled
                .or(self.payment_succeeded_enabled),
            payment_failed_enabled: other.payment_failed_enabled.or(self.payment_failed_enabled),
            payment_statuses_enabled: other
                .payment_statuses_enabled
                .or(self.payment_statuses_enabled),
            refund_statuses_enabled: other
                .refund_statuses_enabled
                .or(self.refund_statuses_enabled),
            #[cfg(feature = "payouts")]
            payout_statuses_enabled: other
                .payout_statuses_enabled
                .or(self.payout_statuses_enabled),
        }
    }