/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ApplicationScope, ApplicationScope$inboundSchema, ApplicationScope$outboundSchema, } from "./applicationscope.js"; import { CapabilityID, CapabilityID$inboundSchema, CapabilityID$outboundSchema, } from "./capabilityid.js"; import { CreateAccount, CreateAccount$inboundSchema, CreateAccount$Outbound, CreateAccount$outboundSchema, } from "./createaccount.js"; import { OnboardingPartnerAccount, OnboardingPartnerAccount$inboundSchema, OnboardingPartnerAccount$Outbound, OnboardingPartnerAccount$outboundSchema, } from "./onboardingpartneraccount.js"; export type OnboardingInvite = { /** * A unique code that identifies an onboarding invite. */ code: string; /** * A unique URL, including the invite code, that the recipient can follow to redeem the invitation. */ link: string; /** * The scopes requested by the inviter. */ returnURL?: string | undefined; /** * The terms of service URL set by the inviter. */ termsOfServiceURL?: string | undefined; /** * List of [scopes](https://docs.moov.io/api/authentication/scopes/) you request to use on this * * @remarks * account. These values are used to determine what can be done with the account onboarded. */ scopes: Array; /** * List of [scopes](https://docs.moov.io/api/authentication/scopes/) you grant to allow being used * * @remarks * by the new account on yourself. These values are used to determine what the account onboarded can do. */ grantScopes?: Array | undefined; /** * List of [capabilities](https://docs.moov.io/guides/accounts/capabilities/) you intend to request for this * * @remarks * account. These values are used to determine what information to collect from the user during onboarding. */ capabilities: Array; /** * List of fee plan codes to assign the account created by the invitee. */ feePlanCodes: Array; /** * The account ID of the account that redeemed the invite. */ redeemedAccountID?: string | undefined; prefill?: CreateAccount | undefined; /** * The account that created the onboarding invite. */ partner?: OnboardingPartnerAccount | undefined; createdOn: Date; revokedOn?: Date | undefined; redeemedOn?: Date | undefined; }; /** @internal */ export const OnboardingInvite$inboundSchema: z.ZodType< OnboardingInvite, z.ZodTypeDef, unknown > = z.object({ code: z.string(), link: z.string(), returnURL: z.string().optional(), termsOfServiceURL: z.string().optional(), scopes: z.array(ApplicationScope$inboundSchema), grantScopes: z.array(ApplicationScope$inboundSchema).optional(), capabilities: z.array(CapabilityID$inboundSchema), feePlanCodes: z.array(z.string()), redeemedAccountID: z.string().optional(), prefill: CreateAccount$inboundSchema.optional(), partner: OnboardingPartnerAccount$inboundSchema.optional(), createdOn: z.string().datetime({ offset: true }).transform(v => new Date(v)), revokedOn: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), redeemedOn: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), }); /** @internal */ export type OnboardingInvite$Outbound = { code: string; link: string; returnURL?: string | undefined; termsOfServiceURL?: string | undefined; scopes: Array; grantScopes?: Array | undefined; capabilities: Array; feePlanCodes: Array; redeemedAccountID?: string | undefined; prefill?: CreateAccount$Outbound | undefined; partner?: OnboardingPartnerAccount$Outbound | undefined; createdOn: string; revokedOn?: string | undefined; redeemedOn?: string | undefined; }; /** @internal */ export const OnboardingInvite$outboundSchema: z.ZodType< OnboardingInvite$Outbound, z.ZodTypeDef, OnboardingInvite > = z.object({ code: z.string(), link: z.string(), returnURL: z.string().optional(), termsOfServiceURL: z.string().optional(), scopes: z.array(ApplicationScope$outboundSchema), grantScopes: z.array(ApplicationScope$outboundSchema).optional(), capabilities: z.array(CapabilityID$outboundSchema), feePlanCodes: z.array(z.string()), redeemedAccountID: z.string().optional(), prefill: CreateAccount$outboundSchema.optional(), partner: OnboardingPartnerAccount$outboundSchema.optional(), createdOn: z.date().transform(v => v.toISOString()), revokedOn: z.date().transform(v => v.toISOString()).optional(), redeemedOn: z.date().transform(v => v.toISOString()).optional(), }); export function onboardingInviteToJSON( onboardingInvite: OnboardingInvite, ): string { return JSON.stringify( OnboardingInvite$outboundSchema.parse(onboardingInvite), ); } export function onboardingInviteFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => OnboardingInvite$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OnboardingInvite' from JSON`, ); }