refactor(router): move api models into separate crate (#103)

This commit is contained in:
ItsMeShashank
2022-12-12 15:36:45 +05:30
committed by GitHub
parent 81593e0a6b
commit d6afbe8011
49 changed files with 2272 additions and 1863 deletions

View File

@ -0,0 +1,48 @@
use common_utils::custom_serde;
use serde::{Deserialize, Serialize};
use time::PrimitiveDateTime;
use crate::{enums as api_enums, payments};
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum IncomingWebhookEvent {
PaymentIntentSuccess,
}
pub enum WebhookFlow {
Payment,
Refund,
Subscription,
}
impl From<IncomingWebhookEvent> for WebhookFlow {
fn from(evt: IncomingWebhookEvent) -> Self {
match evt {
IncomingWebhookEvent::PaymentIntentSuccess => Self::Payment,
}
}
}
pub type MerchantWebhookConfig = std::collections::HashSet<IncomingWebhookEvent>;
pub struct IncomingWebhookDetails {
pub object_reference_id: String,
pub resource_object: Vec<u8>,
}
#[derive(Debug, Clone, Serialize)]
pub struct OutgoingWebhook {
pub merchant_id: String,
pub event_id: String,
pub event_type: api_enums::EventType,
pub content: OutgoingWebhookContent,
#[serde(default, with = "custom_serde::iso8601")]
pub timestamp: PrimitiveDateTime,
}
#[derive(Debug, Clone, Serialize)]
#[serde(tag = "type", content = "object", rename_all = "snake_case")]
pub enum OutgoingWebhookContent {
PaymentDetails(payments::PaymentsResponse),
}