/* * 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 { ProductPriceSeatTiersOutput, ProductPriceSeatTiersOutput$inboundSchema, ProductPriceSeatTiersOutput$Outbound, ProductPriceSeatTiersOutput$outboundSchema, } from "./productpriceseattiersoutput.js"; import { ProductPriceSource, ProductPriceSource$inboundSchema, ProductPriceSource$outboundSchema, } from "./productpricesource.js"; import { TaxBehaviorOption, TaxBehaviorOption$inboundSchema, TaxBehaviorOption$outboundSchema, } from "./taxbehavioroption.js"; /** * A seat-based price for a product. */ export type ProductPriceSeatBased = { /** * Creation timestamp of the object. */ createdAt: Date; /** * Last modification timestamp of the object. */ modifiedAt: Date | null; /** * The ID of the price. */ id: string; source: ProductPriceSource; amountType: "seat_based"; /** * The currency in which the customer will be charged. */ priceCurrency: string; /** * The tax behavior of the price. If null, it defaults to the organization's default tax behavior. */ taxBehavior: TaxBehaviorOption | null; /** * Whether the price is archived and no longer available. */ isArchived: boolean; /** * The ID of the product owning the price. */ productId: string; /** * List of pricing tiers for seat-based pricing. * * @remarks * * The minimum and maximum seat limits are derived from the tiers: * - minimum_seats = first tier's min_seats * - maximum_seats = last tier's max_seats (None for unlimited) */ seatTiers: ProductPriceSeatTiersOutput; }; /** @internal */ export const ProductPriceSeatBased$inboundSchema: z.ZodMiniType< ProductPriceSeatBased, unknown > = 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(), source: ProductPriceSource$inboundSchema, amount_type: z.literal("seat_based"), price_currency: z.string(), tax_behavior: z.nullable(TaxBehaviorOption$inboundSchema), is_archived: z.boolean(), product_id: z.string(), seat_tiers: ProductPriceSeatTiersOutput$inboundSchema, }), z.transform((v) => { return remap$(v, { "created_at": "createdAt", "modified_at": "modifiedAt", "amount_type": "amountType", "price_currency": "priceCurrency", "tax_behavior": "taxBehavior", "is_archived": "isArchived", "product_id": "productId", "seat_tiers": "seatTiers", }); }), ); /** @internal */ export type ProductPriceSeatBased$Outbound = { created_at: string; modified_at: string | null; id: string; source: string; amount_type: "seat_based"; price_currency: string; tax_behavior: string | null; is_archived: boolean; product_id: string; seat_tiers: ProductPriceSeatTiersOutput$Outbound; }; /** @internal */ export const ProductPriceSeatBased$outboundSchema: z.ZodMiniType< ProductPriceSeatBased$Outbound, ProductPriceSeatBased > = 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(), source: ProductPriceSource$outboundSchema, amountType: z.literal("seat_based"), priceCurrency: z.string(), taxBehavior: z.nullable(TaxBehaviorOption$outboundSchema), isArchived: z.boolean(), productId: z.string(), seatTiers: ProductPriceSeatTiersOutput$outboundSchema, }), z.transform((v) => { return remap$(v, { createdAt: "created_at", modifiedAt: "modified_at", amountType: "amount_type", priceCurrency: "price_currency", taxBehavior: "tax_behavior", isArchived: "is_archived", productId: "product_id", seatTiers: "seat_tiers", }); }), ); export function productPriceSeatBasedToJSON( productPriceSeatBased: ProductPriceSeatBased, ): string { return JSON.stringify( ProductPriceSeatBased$outboundSchema.parse(productPriceSeatBased), ); } export function productPriceSeatBasedFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ProductPriceSeatBased$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ProductPriceSeatBased' from JSON`, ); }