/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v4-mini"; 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 { Member, Member$inboundSchema, Member$Outbound, Member$outboundSchema, } from "./member.js"; import { SeatStatus, SeatStatus$inboundSchema, SeatStatus$outboundSchema, } from "./seatstatus.js"; export type CustomerSeat = { /** * Creation timestamp of the object. */ createdAt: Date; /** * Last modification timestamp of the object. */ modifiedAt: Date | null; /** * The seat ID */ id: string; /** * The subscription ID (for recurring seats) */ subscriptionId?: string | null | undefined; /** * The order ID (for one-time purchase seats) */ orderId?: string | null | undefined; status: SeatStatus; /** * The customer ID. When member_model_enabled is true, this is the billing customer (purchaser). When false, this is the seat member customer. */ customerId?: string | null | undefined; /** * The member ID of the seat occupant */ memberId?: string | null | undefined; /** * The member associated with this seat */ member?: Member | null | undefined; /** * Email of the seat member (set when member_model_enabled is true) */ email?: string | null | undefined; /** * The assigned customer email */ customerEmail?: string | null | undefined; /** * When the invitation token expires */ invitationTokenExpiresAt?: Date | null | undefined; /** * When the seat was claimed */ claimedAt?: Date | null | undefined; /** * When the seat was revoked */ revokedAt?: Date | null | undefined; /** * Additional metadata for the seat */ seatMetadata?: { [k: string]: any } | null | undefined; }; /** @internal */ export const CustomerSeat$inboundSchema: z.ZodMiniType = z.pipe( z.object({ created_at: z.pipe( z.iso.datetime({ offset: true }), z.transform(v => new Date(v)), ), modified_at: z.nullable( z.pipe(z.iso.datetime({ offset: true }), z.transform(v => new Date(v))), ), id: z.string(), subscription_id: z.optional(z.nullable(z.string())), order_id: z.optional(z.nullable(z.string())), status: SeatStatus$inboundSchema, customer_id: z.optional(z.nullable(z.string())), member_id: z.optional(z.nullable(z.string())), member: z.optional(z.nullable(Member$inboundSchema)), email: z.optional(z.nullable(z.string())), customer_email: z.optional(z.nullable(z.string())), invitation_token_expires_at: z.optional( z.nullable(z.pipe( z.iso.datetime({ offset: true }), z.transform(v => new Date(v)), )), ), claimed_at: z.optional( z.nullable(z.pipe( z.iso.datetime({ offset: true }), z.transform(v => new Date(v)), )), ), revoked_at: z.optional( z.nullable(z.pipe( z.iso.datetime({ offset: true }), z.transform(v => new Date(v)), )), ), seat_metadata: z.optional(z.nullable(z.record(z.string(), z.any()))), }), z.transform((v) => { return remap$(v, { "created_at": "createdAt", "modified_at": "modifiedAt", "subscription_id": "subscriptionId", "order_id": "orderId", "customer_id": "customerId", "member_id": "memberId", "customer_email": "customerEmail", "invitation_token_expires_at": "invitationTokenExpiresAt", "claimed_at": "claimedAt", "revoked_at": "revokedAt", "seat_metadata": "seatMetadata", }); }), ); /** @internal */ export type CustomerSeat$Outbound = { created_at: string; modified_at: string | null; id: string; subscription_id?: string | null | undefined; order_id?: string | null | undefined; status: string; customer_id?: string | null | undefined; member_id?: string | null | undefined; member?: Member$Outbound | null | undefined; email?: string | null | undefined; customer_email?: string | null | undefined; invitation_token_expires_at?: string | null | undefined; claimed_at?: string | null | undefined; revoked_at?: string | null | undefined; seat_metadata?: { [k: string]: any } | null | undefined; }; /** @internal */ export const CustomerSeat$outboundSchema: z.ZodMiniType< CustomerSeat$Outbound, CustomerSeat > = z.pipe( z.object({ createdAt: z.pipe(z.date(), z.transform(v => v.toISOString())), modifiedAt: z.nullable(z.pipe(z.date(), z.transform(v => v.toISOString()))), id: z.string(), subscriptionId: z.optional(z.nullable(z.string())), orderId: z.optional(z.nullable(z.string())), status: SeatStatus$outboundSchema, customerId: z.optional(z.nullable(z.string())), memberId: z.optional(z.nullable(z.string())), member: z.optional(z.nullable(Member$outboundSchema)), email: z.optional(z.nullable(z.string())), customerEmail: z.optional(z.nullable(z.string())), invitationTokenExpiresAt: z.optional( z.nullable(z.pipe(z.date(), z.transform(v => v.toISOString()))), ), claimedAt: z.optional( z.nullable(z.pipe(z.date(), z.transform(v => v.toISOString()))), ), revokedAt: z.optional( z.nullable(z.pipe(z.date(), z.transform(v => v.toISOString()))), ), seatMetadata: z.optional(z.nullable(z.record(z.string(), z.any()))), }), z.transform((v) => { return remap$(v, { createdAt: "created_at", modifiedAt: "modified_at", subscriptionId: "subscription_id", orderId: "order_id", customerId: "customer_id", memberId: "member_id", customerEmail: "customer_email", invitationTokenExpiresAt: "invitation_token_expires_at", claimedAt: "claimed_at", revokedAt: "revoked_at", seatMetadata: "seat_metadata", }); }), ); export function customerSeatToJSON(customerSeat: CustomerSeat): string { return JSON.stringify(CustomerSeat$outboundSchema.parse(customerSeat)); } export function customerSeatFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CustomerSeat$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CustomerSeat' from JSON`, ); }