/* * 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 { catchUnrecognizedEnum, OpenEnum, Unrecognized, } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * GRANTED if it was activated via an enrollment, SUSPENDED if a restriction has temporarily disabled it, or DENIED if it has never before been GRANTED */ export enum EntitlementState { EntitlementStateUnspecified = "ENTITLEMENT_STATE_UNSPECIFIED", Granted = "GRANTED", Suspended = "SUSPENDED", Denied = "DENIED", } /** * GRANTED if it was activated via an enrollment, SUSPENDED if a restriction has temporarily disabled it, or DENIED if it has never before been GRANTED */ export type EntitlementStateOpen = OpenEnum; /** * An Entitlement for an Account. Defines what the account is allowed to do. */ export type Entitlement = { /** * A friendly name for the entitlement used primarily for UI display */ displayName?: string | undefined; /** * The enum value of the entitlement being described; e.g., BANKING_CHECK */ entitlementCode?: string | undefined; /** * A system-generated reason about why the last modification occurred - typically due to an enrollment or restriction event */ lastModifiedReason?: string | undefined; /** * The last time the underlying entitlement had its status updated */ lastModifiedTime?: Date | null | undefined; /** * The entitlement above the subject; A model of status inheritance exists which provides context on this value */ parentEntitlements?: Array | undefined; /** * GRANTED if it was activated via an enrollment, SUSPENDED if a restriction has temporarily disabled it, or DENIED if it has never before been GRANTED */ state?: EntitlementStateOpen | undefined; }; /** @internal */ export const EntitlementState$inboundSchema: z.ZodType< EntitlementStateOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(EntitlementState), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const EntitlementState$outboundSchema: z.ZodType< EntitlementStateOpen, z.ZodTypeDef, EntitlementStateOpen > = z.union([ z.nativeEnum(EntitlementState), z.string().and(z.custom>()), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace EntitlementState$ { /** @deprecated use `EntitlementState$inboundSchema` instead. */ export const inboundSchema = EntitlementState$inboundSchema; /** @deprecated use `EntitlementState$outboundSchema` instead. */ export const outboundSchema = EntitlementState$outboundSchema; } /** @internal */ export const Entitlement$inboundSchema: z.ZodType< Entitlement, z.ZodTypeDef, unknown > = z.object({ display_name: z.string().optional(), entitlement_code: z.string().optional(), last_modified_reason: z.string().optional(), last_modified_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), parent_entitlements: z.array(z.string()).optional(), state: EntitlementState$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "display_name": "displayName", "entitlement_code": "entitlementCode", "last_modified_reason": "lastModifiedReason", "last_modified_time": "lastModifiedTime", "parent_entitlements": "parentEntitlements", }); }); /** @internal */ export type Entitlement$Outbound = { display_name?: string | undefined; entitlement_code?: string | undefined; last_modified_reason?: string | undefined; last_modified_time?: string | null | undefined; parent_entitlements?: Array | undefined; state?: string | undefined; }; /** @internal */ export const Entitlement$outboundSchema: z.ZodType< Entitlement$Outbound, z.ZodTypeDef, Entitlement > = z.object({ displayName: z.string().optional(), entitlementCode: z.string().optional(), lastModifiedReason: z.string().optional(), lastModifiedTime: z.nullable(z.date().transform(v => v.toISOString())) .optional(), parentEntitlements: z.array(z.string()).optional(), state: EntitlementState$outboundSchema.optional(), }).transform((v) => { return remap$(v, { displayName: "display_name", entitlementCode: "entitlement_code", lastModifiedReason: "last_modified_reason", lastModifiedTime: "last_modified_time", parentEntitlements: "parent_entitlements", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Entitlement$ { /** @deprecated use `Entitlement$inboundSchema` instead. */ export const inboundSchema = Entitlement$inboundSchema; /** @deprecated use `Entitlement$outboundSchema` instead. */ export const outboundSchema = Entitlement$outboundSchema; /** @deprecated use `Entitlement$Outbound` instead. */ export type Outbound = Entitlement$Outbound; } export function entitlementToJSON(entitlement: Entitlement): string { return JSON.stringify(Entitlement$outboundSchema.parse(entitlement)); } export function entitlementFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Entitlement$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Entitlement' from JSON`, ); }