mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
feat(docs): add multiple examples support and webhook schema (#1864)
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
use common_utils::custom_serde;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use time::PrimitiveDateTime;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
use crate::{disputes, enums as api_enums, payments, refunds};
|
||||
|
||||
@ -81,20 +82,33 @@ pub struct IncomingWebhookDetails {
|
||||
pub resource_object: Vec<u8>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
#[derive(Debug, Clone, Serialize, ToSchema)]
|
||||
pub struct OutgoingWebhook {
|
||||
/// The merchant id of the merchant
|
||||
pub merchant_id: String,
|
||||
|
||||
/// The unique event id for each webhook
|
||||
pub event_id: String,
|
||||
|
||||
/// The type of event this webhook corresponds to.
|
||||
#[schema(value_type = EventType)]
|
||||
pub event_type: api_enums::EventType,
|
||||
|
||||
/// This is specific to the flow, for ex: it will be `PaymentsResponse` for payments flow
|
||||
pub content: OutgoingWebhookContent,
|
||||
#[serde(default, with = "custom_serde::iso8601")]
|
||||
|
||||
/// The time at which webhook was sent
|
||||
pub timestamp: PrimitiveDateTime,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
#[derive(Debug, Clone, Serialize, ToSchema)]
|
||||
#[serde(tag = "type", content = "object", rename_all = "snake_case")]
|
||||
pub enum OutgoingWebhookContent {
|
||||
#[schema(value_type = PaymentsResponse)]
|
||||
PaymentDetails(payments::PaymentsResponse),
|
||||
#[schema(value_type = RefundResponse)]
|
||||
RefundDetails(refunds::RefundResponse),
|
||||
#[schema(value_type = DisputeResponse)]
|
||||
DisputeDetails(Box<disputes::DisputeResponse>),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user