UNPKG

@aajsa/moyasar-client

Version:

A lightweight and type-safe TypeScript client for interacting with Moyasar Payment Gateway APIs.

95 lines (93 loc) 2.71 kB
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs'); const require_common = require('./common.cjs'); const zod_v4_mini = require_rolldown_runtime.__toESM(require("zod/v4-mini")); //#region src/schema/webhook.ts const WebhooksEventsEnum = zod_v4_mini.z.enum([ "payment_paid", "payment_failed", "payment_voided", "payment_authorized", "payment_captured", "payment_refunded", "payment_abandoned", "payment_verified", "payment_canceled", "payment_expired", "balance_transferred", "payout_initiated", "payout_paid", "payout_failed", "payout_canceled", "payout_returned" ]); const WebhookResponseSchema = zod_v4_mini.z.object({ id: zod_v4_mini.z.uuid(), http_method: zod_v4_mini.z.string(), url: zod_v4_mini.z.url(), events: zod_v4_mini.z.array(WebhooksEventsEnum), created_at: zod_v4_mini.z.string() }); const WebhookAttemptResponseSchema = zod_v4_mini.z.object({ id: zod_v4_mini.z.uuid(), webhook_id: zod_v4_mini.z.uuid(), event_id: zod_v4_mini.z.uuid(), event_type: WebhooksEventsEnum, retry_number: zod_v4_mini.z.number(), result: zod_v4_mini.z.string(), message: zod_v4_mini.z.string(), response_code: zod_v4_mini.z.number(), response_headers: zod_v4_mini.z.string(), response_body: zod_v4_mini.z.string(), created_at: zod_v4_mini.z.string() }); const createWebhookSchema = zod_v4_mini.z.object({ url: zod_v4_mini.z.url(), shared_secret: zod_v4_mini.z.string(), events: zod_v4_mini.z.array(WebhooksEventsEnum) }); const webhooksEndpoints = { getWebhookAttemptId: { path: "/webhooks/attempts/:id", method: "GET", params: require_common.paramPathIdSchema, output: WebhookAttemptResponseSchema }, listWebhookAttempts: { path: "/webhooks/attempts", method: "GET", output: zod_v4_mini.z.object({ webhook_attempts: zod_v4_mini.z.array(WebhookAttemptResponseSchema), meta: require_common.MetaResponseSchema }) }, getWebhookId: { path: "/webhooks/:id", method: "GET", params: require_common.paramPathIdSchema, output: WebhookResponseSchema }, listWebhooks: { path: "/webhooks", method: "GET", output: zod_v4_mini.z.object({ webhooks: zod_v4_mini.z.array(WebhookResponseSchema) }) }, listWebhookEvents: { path: "/webhooks/available_events", method: "GET", output: zod_v4_mini.z.object({ events: zod_v4_mini.z.array(WebhooksEventsEnum) }) }, createWebhook: { path: "/webhooks", method: "POST", input: createWebhookSchema, output: WebhookResponseSchema }, deleteWebhook: { path: "/webhooks/:id", method: "DELETE", params: require_common.paramPathIdSchema, output: zod_v4_mini.z.object({ success: zod_v4_mini.z.boolean() }) } }; //#endregion exports.webhooksEndpoints = webhooksEndpoints;