/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { lazySchema as lazySchema$, safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as types from "../../types/primitives.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { UnifiedApiId, UnifiedApiId$inboundSchema } from "./unifiedapiid.js"; /** * Apideck service provider associated with event. */ export type WebhookEventLogService = { /** * Apideck service provider id. */ id: string; /** * Apideck service provider name. */ name: string; }; export type Attempts = { /** * ISO Date and time when the request was made. */ timestamp?: string | undefined; /** * Number of attempts webhook endpoint was called before a success was returned or eventually failed */ executionAttempt?: number | undefined; /** * HTTP Status code that was returned. */ statusCode?: number | undefined; /** * Whether or not the request was successful. */ success?: boolean | undefined; }; export type WebhookEventLog = { id?: string | undefined; /** * HTTP Status code that was returned. */ statusCode?: number | undefined; /** * Whether or not the request was successful. */ success?: boolean | undefined; /** * ID of your Apideck Application */ applicationId?: string | undefined; /** * Unique consumer identifier. You can freely choose a consumer ID yourself. Most of the time, this is an ID of your internal data model that represents a user or account in your system (for example account:12345). If the consumer doesn't exist yet, Vault will upsert a consumer based on your ID. */ consumerId?: string | undefined; /** * Name of Apideck Unified API */ unifiedApi?: UnifiedApiId | undefined; /** * Apideck service provider associated with event. */ service?: WebhookEventLogService | undefined; /** * The URL of the webhook endpoint. */ endpoint?: string | undefined; /** * Name of source event that webhook is subscribed to. */ eventType?: string | undefined; /** * Number of attempts webhook endpoint was called before a success was returned or eventually failed */ executionAttempt?: number | undefined; /** * HTTP Method of request to endpoint. */ httpMethod?: string | undefined; /** * ISO Date and time when the request was made. */ timestamp?: string | undefined; /** * Name of the Entity described by the attributes delivered within payload */ entityType?: string | undefined; /** * The JSON stringified payload that was delivered to the webhook endpoint. */ requestBody?: string | undefined; /** * The JSON stringified response that was returned from the webhook endpoint. */ responseBody?: string | undefined; /** * If the request has not hit the max retry limit and will be retried. */ retryScheduled?: boolean | undefined; /** * record of each attempt to call webhook endpoint */ attempts?: Array | undefined; }; /** @internal */ export const WebhookEventLogService$inboundSchema: z.ZodType< WebhookEventLogService, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.string(), name: types.string(), }) ); export function webhookEventLogServiceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WebhookEventLogService$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WebhookEventLogService' from JSON`, ); } /** @internal */ export const Attempts$inboundSchema: z.ZodType< Attempts, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ timestamp: types.optional(types.string()), execution_attempt: types.optional(types.number()), status_code: types.optional(types.number()), success: types.optional(types.boolean()), }).transform((v) => { return remap$(v, { "execution_attempt": "executionAttempt", "status_code": "statusCode", }); }) ); export function attemptsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Attempts$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Attempts' from JSON`, ); } /** @internal */ export const WebhookEventLog$inboundSchema: z.ZodType< WebhookEventLog, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), status_code: types.optional(types.number()), success: types.optional(types.boolean()), application_id: types.optional(types.string()), consumer_id: types.optional(types.string()), unified_api: types.optional(UnifiedApiId$inboundSchema), service: types.optional(z.lazy(() => WebhookEventLogService$inboundSchema)), endpoint: types.optional(types.string()), event_type: types.optional(types.string()), execution_attempt: types.optional(types.number()), http_method: types.optional(types.string()), timestamp: types.optional(types.string()), entity_type: types.optional(types.string()), request_body: types.optional(types.string()), response_body: types.optional(types.string()), retry_scheduled: types.optional(types.boolean()), attempts: types.optional(z.array(z.lazy(() => Attempts$inboundSchema))), }).transform((v) => { return remap$(v, { "status_code": "statusCode", "application_id": "applicationId", "consumer_id": "consumerId", "unified_api": "unifiedApi", "event_type": "eventType", "execution_attempt": "executionAttempt", "http_method": "httpMethod", "entity_type": "entityType", "request_body": "requestBody", "response_body": "responseBody", "retry_scheduled": "retryScheduled", }); }) ); export function webhookEventLogFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => WebhookEventLog$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'WebhookEventLog' from JSON`, ); }