/* * 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"; /** * The unique IDs of the tags assigned to the short link. */ export type CreateReferralsEmbedTokenTagIds = string | Array; /** * The unique name of the tags assigned to the short link (case insensitive). */ export type CreateReferralsEmbedTokenTagNames = string | Array; export type CreateReferralsEmbedTokenTestVariants = { url: string; percentage: number; }; /** * Additional properties that you can pass to the partner's short link. Will be used to override the default link properties for this partner. */ export type CreateReferralsEmbedTokenLinkProps = { /** * The ID of the link in your database. If set, it can be used to identify the link in future API requests (must be prefixed with 'ext_' when passed as a query parameter). This key is unique across your workspace. */ externalId?: string | null | undefined; /** * The ID of the tenant that created the link inside your system. If set, it can be used to fetch all links for a tenant. */ tenantId?: string | null | undefined; /** * Path prefix for each default referral link slug (e.g. `/c/` → `https://{domain}/c/{identity}`). If the group has multiple default links, a short random suffix is appended to the identity segment for uniqueness (e.g. `c/jane-a7f2`). */ prefix?: string | undefined; /** * Whether the short link is archived. Defaults to `false` if not provided. */ archived?: boolean | undefined; /** * The unique IDs of the tags assigned to the short link. */ tagIds?: string | Array | undefined; /** * The unique name of the tags assigned to the short link (case insensitive). */ tagNames?: string | Array | undefined; /** * The comments for the short link. */ comments?: string | null | undefined; /** * The date and time when the short link will expire at. */ expiresAt?: string | null | undefined; /** * The URL to redirect to when the short link has expired. */ expiredUrl?: string | null | undefined; /** * The password required to access the destination URL of the short link. */ password?: string | null | undefined; /** * Whether the short link uses Custom Link Previews feature. Defaults to `false` if not provided. */ proxy?: boolean | undefined; /** * The custom link preview title (og:title). Will be used for Custom Link Previews if `proxy` is true. Learn more: https://d.to/og */ title?: string | null | undefined; /** * The custom link preview description (og:description). Will be used for Custom Link Previews if `proxy` is true. Learn more: https://d.to/og */ description?: string | null | undefined; /** * The custom link preview image (og:image). Will be used for Custom Link Previews if `proxy` is true. Learn more: https://d.to/og */ image?: string | null | undefined; /** * The custom link preview video (og:video). Will be used for Custom Link Previews if `proxy` is true. Learn more: https://d.to/og */ video?: string | null | undefined; /** * Whether the short link uses link cloaking. Defaults to `false` if not provided. */ rewrite?: boolean | undefined; /** * The iOS destination URL for the short link for iOS device targeting. */ ios?: string | null | undefined; /** * The Android destination URL for the short link for Android device targeting. */ android?: string | null | undefined; /** * Allow search engines to index your short link. Defaults to `false` if not provided. Learn more: https://d.to/noindex */ doIndex?: boolean | undefined; /** * An array of A/B test URLs and the percentage of traffic to send to each URL. */ testVariants?: | Array | null | undefined; /** * The date and time when the tests started. */ testStartedAt?: string | null | undefined; /** * The date and time when the tests were or will be completed. */ testCompletedAt?: string | null | undefined; }; export type Partner = { /** * The partner's full name. If undefined, the partner's email will be used in lieu of their name (e.g. `john@acme.com`) */ name?: string | null | undefined; /** * The partner's email address. Partners will be able to claim their profile by signing up at `partners.dub.co` with this email. */ email: string; /** * The partner's unique username in your system (max 100 characters). This will be used to create a short link for the partner using your program's default domain. If not provided, Dub will try to generate a username from the partner's name or email. */ username?: string | null | undefined; /** * The partner's avatar image. If not provided, a default avatar will be used. */ image?: string | null | undefined; /** * The partner's unique ID in your system. Useful for retrieving the partner's links and stats later on. If not provided, the partner will be created as a standalone partner. */ tenantId?: string | undefined; /** * The group ID to add the partner to. If not provided, the partner will be added to the default group. */ groupId?: string | undefined; /** * The partner's country of residence. Must be passed as a 2-letter ISO 3166-1 country code. See https://d.to/geo for more information. */ country?: string | null | undefined; /** * A brief description of the partner and their background. Max 5,000 characters. */ description?: string | null | undefined; /** * Additional properties that you can pass to the partner's short link. Will be used to override the default link properties for this partner. */ linkProps?: CreateReferralsEmbedTokenLinkProps | undefined; }; export type CreateReferralsEmbedTokenRequestBody = { partnerId?: string | undefined; tenantId?: string | undefined; partner?: Partner | undefined; }; /** * The created public embed token. */ export type CreateReferralsEmbedTokenResponseBody = { publicToken: string; expires: string; }; /** @internal */ export type CreateReferralsEmbedTokenTagIds$Outbound = string | Array; /** @internal */ export const CreateReferralsEmbedTokenTagIds$outboundSchema: z.ZodType< CreateReferralsEmbedTokenTagIds$Outbound, z.ZodTypeDef, CreateReferralsEmbedTokenTagIds > = z.union([z.string(), z.array(z.string())]); export function createReferralsEmbedTokenTagIdsToJSON( createReferralsEmbedTokenTagIds: CreateReferralsEmbedTokenTagIds, ): string { return JSON.stringify( CreateReferralsEmbedTokenTagIds$outboundSchema.parse( createReferralsEmbedTokenTagIds, ), ); } /** @internal */ export type CreateReferralsEmbedTokenTagNames$Outbound = string | Array; /** @internal */ export const CreateReferralsEmbedTokenTagNames$outboundSchema: z.ZodType< CreateReferralsEmbedTokenTagNames$Outbound, z.ZodTypeDef, CreateReferralsEmbedTokenTagNames > = z.union([z.string(), z.array(z.string())]); export function createReferralsEmbedTokenTagNamesToJSON( createReferralsEmbedTokenTagNames: CreateReferralsEmbedTokenTagNames, ): string { return JSON.stringify( CreateReferralsEmbedTokenTagNames$outboundSchema.parse( createReferralsEmbedTokenTagNames, ), ); } /** @internal */ export type CreateReferralsEmbedTokenTestVariants$Outbound = { url: string; percentage: number; }; /** @internal */ export const CreateReferralsEmbedTokenTestVariants$outboundSchema: z.ZodType< CreateReferralsEmbedTokenTestVariants$Outbound, z.ZodTypeDef, CreateReferralsEmbedTokenTestVariants > = z.object({ url: z.string(), percentage: z.number(), }); export function createReferralsEmbedTokenTestVariantsToJSON( createReferralsEmbedTokenTestVariants: CreateReferralsEmbedTokenTestVariants, ): string { return JSON.stringify( CreateReferralsEmbedTokenTestVariants$outboundSchema.parse( createReferralsEmbedTokenTestVariants, ), ); } /** @internal */ export type CreateReferralsEmbedTokenLinkProps$Outbound = { externalId?: string | null | undefined; tenantId?: string | null | undefined; prefix?: string | undefined; archived?: boolean | undefined; tagIds?: string | Array | undefined; tagNames?: string | Array | undefined; comments?: string | null | undefined; expiresAt?: string | null | undefined; expiredUrl?: string | null | undefined; password?: string | null | undefined; proxy?: boolean | undefined; title?: string | null | undefined; description?: string | null | undefined; image?: string | null | undefined; video?: string | null | undefined; rewrite?: boolean | undefined; ios?: string | null | undefined; android?: string | null | undefined; doIndex?: boolean | undefined; testVariants?: | Array | null | undefined; testStartedAt?: string | null | undefined; testCompletedAt?: string | null | undefined; }; /** @internal */ export const CreateReferralsEmbedTokenLinkProps$outboundSchema: z.ZodType< CreateReferralsEmbedTokenLinkProps$Outbound, z.ZodTypeDef, CreateReferralsEmbedTokenLinkProps > = z.object({ externalId: z.nullable(z.string()).optional(), tenantId: z.nullable(z.string()).optional(), prefix: z.string().optional(), archived: z.boolean().optional(), tagIds: z.union([z.string(), z.array(z.string())]).optional(), tagNames: z.union([z.string(), z.array(z.string())]).optional(), comments: z.nullable(z.string()).optional(), expiresAt: z.nullable(z.string()).optional(), expiredUrl: z.nullable(z.string()).optional(), password: z.nullable(z.string()).optional(), proxy: z.boolean().optional(), title: z.nullable(z.string()).optional(), description: z.nullable(z.string()).optional(), image: z.nullable(z.string()).optional(), video: z.nullable(z.string()).optional(), rewrite: z.boolean().optional(), ios: z.nullable(z.string()).optional(), android: z.nullable(z.string()).optional(), doIndex: z.boolean().optional(), testVariants: z.nullable( z.array(z.lazy(() => CreateReferralsEmbedTokenTestVariants$outboundSchema)), ).optional(), testStartedAt: z.nullable(z.string()).optional(), testCompletedAt: z.nullable(z.string()).optional(), }); export function createReferralsEmbedTokenLinkPropsToJSON( createReferralsEmbedTokenLinkProps: CreateReferralsEmbedTokenLinkProps, ): string { return JSON.stringify( CreateReferralsEmbedTokenLinkProps$outboundSchema.parse( createReferralsEmbedTokenLinkProps, ), ); } /** @internal */ export type Partner$Outbound = { name?: string | null | undefined; email: string; username?: string | null | undefined; image?: string | null | undefined; tenantId?: string | undefined; groupId?: string | undefined; country?: string | null | undefined; description?: string | null | undefined; linkProps?: CreateReferralsEmbedTokenLinkProps$Outbound | undefined; }; /** @internal */ export const Partner$outboundSchema: z.ZodType< Partner$Outbound, z.ZodTypeDef, Partner > = z.object({ name: z.nullable(z.string()).optional(), email: z.string(), username: z.nullable(z.string()).optional(), image: z.nullable(z.string()).optional(), tenantId: z.string().optional(), groupId: z.string().optional(), country: z.nullable(z.string()).optional(), description: z.nullable(z.string()).optional(), linkProps: z.lazy(() => CreateReferralsEmbedTokenLinkProps$outboundSchema) .optional(), }); export function partnerToJSON(partner: Partner): string { return JSON.stringify(Partner$outboundSchema.parse(partner)); } /** @internal */ export type CreateReferralsEmbedTokenRequestBody$Outbound = { partnerId?: string | undefined; tenantId?: string | undefined; partner?: Partner$Outbound | undefined; }; /** @internal */ export const CreateReferralsEmbedTokenRequestBody$outboundSchema: z.ZodType< CreateReferralsEmbedTokenRequestBody$Outbound, z.ZodTypeDef, CreateReferralsEmbedTokenRequestBody > = z.object({ partnerId: z.string().optional(), tenantId: z.string().optional(), partner: z.lazy(() => Partner$outboundSchema).optional(), }); export function createReferralsEmbedTokenRequestBodyToJSON( createReferralsEmbedTokenRequestBody: CreateReferralsEmbedTokenRequestBody, ): string { return JSON.stringify( CreateReferralsEmbedTokenRequestBody$outboundSchema.parse( createReferralsEmbedTokenRequestBody, ), ); } /** @internal */ export const CreateReferralsEmbedTokenResponseBody$inboundSchema: z.ZodType< CreateReferralsEmbedTokenResponseBody, z.ZodTypeDef, unknown > = z.object({ publicToken: z.string(), expires: z.string(), }); export function createReferralsEmbedTokenResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateReferralsEmbedTokenResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateReferralsEmbedTokenResponseBody' from JSON`, ); }