/* * 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 { ProductPriceSource, ProductPriceSource$inboundSchema, ProductPriceSource$outboundSchema, } from "./productpricesource.js"; import { TaxBehaviorOption, TaxBehaviorOption$inboundSchema, TaxBehaviorOption$outboundSchema, } from "./taxbehavioroption.js"; /** * A fixed price for a product. */ export type ProductPriceFixed = { /** * 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: "fixed"; /** * 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; /** * The price in cents. */ priceAmount: number; }; /** @internal */ export const ProductPriceFixed$inboundSchema: z.ZodMiniType< ProductPriceFixed, 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("fixed"), price_currency: z.string(), tax_behavior: z.nullable(TaxBehaviorOption$inboundSchema), is_archived: z.boolean(), product_id: z.string(), price_amount: z.int(), }), 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", "price_amount": "priceAmount", }); }), ); /** @internal */ export type ProductPriceFixed$Outbound = { created_at: string; modified_at: string | null; id: string; source: string; amount_type: "fixed"; price_currency: string; tax_behavior: string | null; is_archived: boolean; product_id: string; price_amount: number; }; /** @internal */ export const ProductPriceFixed$outboundSchema: z.ZodMiniType< ProductPriceFixed$Outbound, ProductPriceFixed > = 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("fixed"), priceCurrency: z.string(), taxBehavior: z.nullable(TaxBehaviorOption$outboundSchema), isArchived: z.boolean(), productId: z.string(), priceAmount: z.int(), }), 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", priceAmount: "price_amount", }); }), ); export function productPriceFixedToJSON( productPriceFixed: ProductPriceFixed, ): string { return JSON.stringify( ProductPriceFixed$outboundSchema.parse(productPriceFixed), ); } export function productPriceFixedFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ProductPriceFixed$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ProductPriceFixed' from JSON`, ); }