/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { HttpPushCallbackCreate, HttpPushCallbackCreate$inboundSchema, HttpPushCallbackCreate$Outbound, HttpPushCallbackCreate$outboundSchema, } from "./httppushcallbackcreate.js"; /** * Configuration information about a push subscription */ export type PushSubscriptionCreate = { /** * The id of the account group to receive events for; The subscription will receive events related to any of the accounts in the specified account group; This can only be set at creation time and is mutually exclusive with client_id and correspondent_id */ accountGroupId?: string | undefined; /** * The id of the client to receive events for; The subscription will receive events related to the specified client, and any of its correspondents and accounts; This can only be set at creation time and is mutually exclusive with correspondent_id and account_group_id */ clientId?: string | undefined; /** * The id of the correspondent to receive events for; The subscription will receive events related to the specified correspondent and any of its accounts; This can only be set at creation time and is mutually exclusive with client_id and account_group_id */ correspondentId?: string | undefined; /** * The user-defined name for the subscription */ displayName: string; /** * Filter for event types; ["\*"] matches all values; Suffix wildcards using "\*" (e.g. ["account.\*"]) are supported */ eventTypes: Array; /** * Configuration information about an HTTP target callback */ httpCallback?: HttpPushCallbackCreate | undefined; /** * The organization that owns the subscription; Format: {org_type}/{org_id} This field can only be set at creation time and if it is not specified, then it will default to the target organization, unless the target is an account group, in which case this field is required */ owner?: string | undefined; }; /** @internal */ export const PushSubscriptionCreate$inboundSchema: z.ZodType< PushSubscriptionCreate, z.ZodTypeDef, unknown > = z.object({ account_group_id: z.string().optional(), client_id: z.string().optional(), correspondent_id: z.string().optional(), display_name: z.string(), event_types: z.array(z.string()), http_callback: HttpPushCallbackCreate$inboundSchema.optional(), owner: z.string().optional(), }).transform((v) => { return remap$(v, { "account_group_id": "accountGroupId", "client_id": "clientId", "correspondent_id": "correspondentId", "display_name": "displayName", "event_types": "eventTypes", "http_callback": "httpCallback", }); }); /** @internal */ export type PushSubscriptionCreate$Outbound = { account_group_id?: string | undefined; client_id?: string | undefined; correspondent_id?: string | undefined; display_name: string; event_types: Array; http_callback?: HttpPushCallbackCreate$Outbound | undefined; owner?: string | undefined; }; /** @internal */ export const PushSubscriptionCreate$outboundSchema: z.ZodType< PushSubscriptionCreate$Outbound, z.ZodTypeDef, PushSubscriptionCreate > = z.object({ accountGroupId: z.string().optional(), clientId: z.string().optional(), correspondentId: z.string().optional(), displayName: z.string(), eventTypes: z.array(z.string()), httpCallback: HttpPushCallbackCreate$outboundSchema.optional(), owner: z.string().optional(), }).transform((v) => { return remap$(v, { accountGroupId: "account_group_id", clientId: "client_id", correspondentId: "correspondent_id", displayName: "display_name", eventTypes: "event_types", httpCallback: "http_callback", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace PushSubscriptionCreate$ { /** @deprecated use `PushSubscriptionCreate$inboundSchema` instead. */ export const inboundSchema = PushSubscriptionCreate$inboundSchema; /** @deprecated use `PushSubscriptionCreate$outboundSchema` instead. */ export const outboundSchema = PushSubscriptionCreate$outboundSchema; /** @deprecated use `PushSubscriptionCreate$Outbound` instead. */ export type Outbound = PushSubscriptionCreate$Outbound; } export function pushSubscriptionCreateToJSON( pushSubscriptionCreate: PushSubscriptionCreate, ): string { return JSON.stringify( PushSubscriptionCreate$outboundSchema.parse(pushSubscriptionCreate), ); } export function pushSubscriptionCreateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PushSubscriptionCreate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PushSubscriptionCreate' from JSON`, ); }