UNPKG

@vercel/sdk

Version:

<p align="center"> <a href="https://vercel.com"> <img src="https://assets.vercel.com/image/upload/v1588805858/repositories/vercel/logo.png" height="96"> <h3 align="center">Vercel</h3> </a> <p align="center">Develop. Preview. Ship.</p> </p>

179 lines (158 loc) 4.57 kB
/* * 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 * as types from "../types/primitives.js"; import { smartUnion } from "../types/smartUnion.js"; import { HttpApiDecodeError, HttpApiDecodeError$inboundSchema, } from "./httpapidecodeerror.js"; import { SDKValidationError } from "./sdkvalidationerror.js"; import { TldNotSupported, TldNotSupported$inboundSchema, } from "./tldnotsupported.js"; export type GetTldPriceRequest = { tld: string; /** * The number of years to get the price for. If not provided, the minimum number of years for the TLD will be used. */ years?: string | undefined; teamId?: string | undefined; }; /** * There was something wrong with the request */ export type GetTldPriceDomainsRegistrarResponseBody = | TldNotSupported | HttpApiDecodeError; export type PurchasePrice = number | string; export type RenewalPrice = number | string; export type TransferPrice = number | string; /** * Success */ export type GetTldPriceResponseBody = { /** * The number of years the returned price is for. */ years: number; purchasePrice: number | string; renewalPrice: number | string; transferPrice: number | string; }; /** @internal */ export type GetTldPriceRequest$Outbound = { tld: string; years?: string | undefined; teamId?: string | undefined; }; /** @internal */ export const GetTldPriceRequest$outboundSchema: z.ZodType< GetTldPriceRequest$Outbound, z.ZodTypeDef, GetTldPriceRequest > = z.object({ tld: z.string(), years: z.string().optional(), teamId: z.string().optional(), }); export function getTldPriceRequestToJSON( getTldPriceRequest: GetTldPriceRequest, ): string { return JSON.stringify( GetTldPriceRequest$outboundSchema.parse(getTldPriceRequest), ); } /** @internal */ export const GetTldPriceDomainsRegistrarResponseBody$inboundSchema: z.ZodType< GetTldPriceDomainsRegistrarResponseBody, z.ZodTypeDef, unknown > = smartUnion([ TldNotSupported$inboundSchema, HttpApiDecodeError$inboundSchema, ]); export function getTldPriceDomainsRegistrarResponseBodyFromJSON( jsonString: string, ): SafeParseResult< GetTldPriceDomainsRegistrarResponseBody, SDKValidationError > { return safeParse( jsonString, (x) => GetTldPriceDomainsRegistrarResponseBody$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'GetTldPriceDomainsRegistrarResponseBody' from JSON`, ); } /** @internal */ export const PurchasePrice$inboundSchema: z.ZodType< PurchasePrice, z.ZodTypeDef, unknown > = smartUnion([types.number(), types.string()]); export function purchasePriceFromJSON( jsonString: string, ): SafeParseResult<PurchasePrice, SDKValidationError> { return safeParse( jsonString, (x) => PurchasePrice$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PurchasePrice' from JSON`, ); } /** @internal */ export const RenewalPrice$inboundSchema: z.ZodType< RenewalPrice, z.ZodTypeDef, unknown > = smartUnion([types.number(), types.string()]); export function renewalPriceFromJSON( jsonString: string, ): SafeParseResult<RenewalPrice, SDKValidationError> { return safeParse( jsonString, (x) => RenewalPrice$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'RenewalPrice' from JSON`, ); } /** @internal */ export const TransferPrice$inboundSchema: z.ZodType< TransferPrice, z.ZodTypeDef, unknown > = smartUnion([types.number(), types.string()]); export function transferPriceFromJSON( jsonString: string, ): SafeParseResult<TransferPrice, SDKValidationError> { return safeParse( jsonString, (x) => TransferPrice$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TransferPrice' from JSON`, ); } /** @internal */ export const GetTldPriceResponseBody$inboundSchema: z.ZodType< GetTldPriceResponseBody, z.ZodTypeDef, unknown > = z.object({ years: types.number(), purchasePrice: smartUnion([types.number(), types.string()]), renewalPrice: smartUnion([types.number(), types.string()]), transferPrice: smartUnion([types.number(), types.string()]), }); export function getTldPriceResponseBodyFromJSON( jsonString: string, ): SafeParseResult<GetTldPriceResponseBody, SDKValidationError> { return safeParse( jsonString, (x) => GetTldPriceResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetTldPriceResponseBody' from JSON`, ); }