/* * 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"; /** * An account restriction. */ export type Restriction = { /** * Indicates whether the restriction is active or not. */ active?: boolean | undefined; /** * The plain-text reason set by a person or system explaining why the restriction was set */ createReason?: string | undefined; /** * The datetime of the object's creation */ createTime?: Date | null | undefined; /** * The user attributed to the restriction's placement on the account; typically expressed as an Auth user ID */ createUserId?: string | undefined; /** * The plain-text reason set by a person or system explaining why the restriction was removed If the restriction is active, the reason will not be set. */ endedReason?: string | undefined; /** * The datetime of a restriction's removal from an account If the restriction is active, the ended time will not be set. */ endedTime?: Date | null | undefined; /** * The user attributed to the restriction's removal from the account; typically expressed as an Auth user ID If the restriction is active, the user will not be set. */ endedUserId?: string | undefined; /** * A enumerated value indicating the nature of a restriction; prefixed by the concerned department (e.g., `MARGIN_CALL_VIOLATION_REG_T`); suspends related entitlements of the account until it is removed; most codes are administrated by the custodian but some are available for use by the integrator */ restrictionCode?: string | undefined; }; /** @internal */ export const Restriction$inboundSchema: z.ZodType< Restriction, z.ZodTypeDef, unknown > = z.object({ active: z.boolean().optional(), create_reason: z.string().optional(), create_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), create_user_id: z.string().optional(), ended_reason: z.string().optional(), ended_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), ended_user_id: z.string().optional(), restriction_code: z.string().optional(), }).transform((v) => { return remap$(v, { "create_reason": "createReason", "create_time": "createTime", "create_user_id": "createUserId", "ended_reason": "endedReason", "ended_time": "endedTime", "ended_user_id": "endedUserId", "restriction_code": "restrictionCode", }); }); /** @internal */ export type Restriction$Outbound = { active?: boolean | undefined; create_reason?: string | undefined; create_time?: string | null | undefined; create_user_id?: string | undefined; ended_reason?: string | undefined; ended_time?: string | null | undefined; ended_user_id?: string | undefined; restriction_code?: string | undefined; }; /** @internal */ export const Restriction$outboundSchema: z.ZodType< Restriction$Outbound, z.ZodTypeDef, Restriction > = z.object({ active: z.boolean().optional(), createReason: z.string().optional(), createTime: z.nullable(z.date().transform(v => v.toISOString())).optional(), createUserId: z.string().optional(), endedReason: z.string().optional(), endedTime: z.nullable(z.date().transform(v => v.toISOString())).optional(), endedUserId: z.string().optional(), restrictionCode: z.string().optional(), }).transform((v) => { return remap$(v, { createReason: "create_reason", createTime: "create_time", createUserId: "create_user_id", endedReason: "ended_reason", endedTime: "ended_time", endedUserId: "ended_user_id", restrictionCode: "restriction_code", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Restriction$ { /** @deprecated use `Restriction$inboundSchema` instead. */ export const inboundSchema = Restriction$inboundSchema; /** @deprecated use `Restriction$outboundSchema` instead. */ export const outboundSchema = Restriction$outboundSchema; /** @deprecated use `Restriction$Outbound` instead. */ export type Outbound = Restriction$Outbound; } export function restrictionToJSON(restriction: Restriction): string { return JSON.stringify(Restriction$outboundSchema.parse(restriction)); } export function restrictionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Restriction$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Restriction' from JSON`, ); }