/* * 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"; export type RetrieveLinksRequest = { /** * The ID of the partner to create a link for. Will take precedence over `tenantId` if provided. */ partnerId?: string | null | undefined; /** * The ID of the partner in your system. If both `partnerId` and `tenantId` are not provided, an error will be thrown. */ tenantId?: string | null | undefined; }; export type RetrieveLinksResponseBody = { /** * The unique ID of the short link. */ id: string; /** * The domain of the short link. If not provided, the primary domain for the workspace will be used (or `dub.sh` if the workspace has no domains). */ domain: string; /** * The short link slug. If not provided, a random 7-character slug will be generated. */ key: string; /** * The full URL of the short link, including the https protocol (e.g. `https://dub.sh/try`). */ shortLink: string; /** * The destination URL of the short link. */ url: string; /** * The number of clicks on the short link. */ clicks: number; /** * The number of leads the short link has generated. */ leads: number; /** * The number of leads that converted to paying customers. */ conversions: number; /** * The total number of sales (includes recurring sales) generated by the short link. */ sales: number; /** * The total dollar value of sales (in cents) generated by the short link. */ saleAmount: number; }; /** @internal */ export type RetrieveLinksRequest$Outbound = { partnerId?: string | null | undefined; tenantId?: string | null | undefined; }; /** @internal */ export const RetrieveLinksRequest$outboundSchema: z.ZodType< RetrieveLinksRequest$Outbound, z.ZodTypeDef, RetrieveLinksRequest > = z.object({ partnerId: z.nullable(z.string()).optional(), tenantId: z.nullable(z.string()).optional(), }); export function retrieveLinksRequestToJSON( retrieveLinksRequest: RetrieveLinksRequest, ): string { return JSON.stringify( RetrieveLinksRequest$outboundSchema.parse(retrieveLinksRequest), ); } /** @internal */ export const RetrieveLinksResponseBody$inboundSchema: z.ZodType< RetrieveLinksResponseBody, z.ZodTypeDef, unknown > = z.object({ id: z.string(), domain: z.string(), key: z.string(), shortLink: z.string(), url: z.string(), clicks: z.number().default(0), leads: z.number().default(0), conversions: z.number().default(0), sales: z.number().default(0), saleAmount: z.number().default(0), }); export function retrieveLinksResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => RetrieveLinksResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'RetrieveLinksResponseBody' from JSON`, ); }