/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.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 CreatePartnerTagIds = string | Array; /** * The unique name of the tags assigned to the short link (case insensitive). */ export type CreatePartnerTagNames = string | Array; export type CreatePartnerTestVariants = { 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 LinkProps = { /** * 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 CreatePartnerRequestBody = { /** * 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?: LinkProps | undefined; }; /** * The partner's default payout method. Connect: Bank account payouts via Stripe Connect; Stablecoin: USDC payouts directly to a crypto wallet; PayPal: Payouts via PayPal */ export const CreatePartnerDefaultPayoutMethod = { Connect: "connect", Stablecoin: "stablecoin", Paypal: "paypal", } as const; /** * The partner's default payout method. Connect: Bank account payouts via Stripe Connect; Stablecoin: USDC payouts directly to a crypto wallet; PayPal: Payouts via PayPal */ export type CreatePartnerDefaultPayoutMethod = ClosedEnum< typeof CreatePartnerDefaultPayoutMethod >; /** * The status of the partner's enrollment in the program. */ export const CreatePartnerStatus = { Pending: "pending", Approved: "approved", Rejected: "rejected", Invited: "invited", Declined: "declined", Deactivated: "deactivated", Banned: "banned", Archived: "archived", } as const; /** * The status of the partner's enrollment in the program. */ export type CreatePartnerStatus = ClosedEnum; export type CreatePartnerLinks = { /** * 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; }; /** * If the partner was banned from the program, this is the reason for the ban. */ export const CreatePartnerBannedReason = { TosViolation: "tos_violation", InappropriateContent: "inappropriate_content", FakeTraffic: "fake_traffic", Fraud: "fraud", Spam: "spam", BrandAbuse: "brand_abuse", } as const; /** * If the partner was banned from the program, this is the reason for the ban. */ export type CreatePartnerBannedReason = ClosedEnum< typeof CreatePartnerBannedReason >; export type Fields8 = { key: string; label: string; required: boolean; locked: boolean; position: number; type: "phone"; }; export type Fields7 = { key: string; label: string; required: boolean; locked: boolean; position: number; type: "number"; }; export type CreatePartnerFieldsPartnersOptions = { label: string; value: string; }; export type Fields6 = { key: string; label: string; required: boolean; locked: boolean; position: number; type: "multiSelect"; options: Array; }; export type Fields5 = { key: string; label: string; required: boolean; locked: boolean; position: number; type: "date"; }; export type CreatePartnerFields4 = { key: string; label: string; required: boolean; locked: boolean; position: number; type: "country"; }; export type CreatePartnerFieldsOptions = { label: string; value: string; }; export type CreatePartnerFields3 = { key: string; label: string; required: boolean; locked: boolean; position: number; type: "select"; options: Array; }; export type CreatePartnerFieldsPartnersConstraints = { maxLength?: number | undefined; }; export type CreatePartnerFields2 = { key: string; label: string; required: boolean; locked: boolean; position: number; type: "textarea"; constraints?: CreatePartnerFieldsPartnersConstraints | undefined; }; export type CreatePartnerFieldsConstraints = { maxLength?: number | undefined; pattern?: string | undefined; }; export type CreatePartnerFields1 = { key: string; label: string; required: boolean; locked: boolean; position: number; type: "text"; constraints?: CreatePartnerFieldsConstraints | undefined; }; export type CreatePartnerFields = | CreatePartnerFields1 | CreatePartnerFields2 | CreatePartnerFields3 | CreatePartnerFields4 | Fields5 | Fields6 | Fields7 | Fields8; export type CreatePartnerReferralFormData = { fields: Array< | CreatePartnerFields1 | CreatePartnerFields2 | CreatePartnerFields3 | CreatePartnerFields4 | Fields5 | Fields6 | Fields7 | Fields8 >; }; /** * Preset reason when the application was rejected. */ export const CreatePartnerRejectionReason = { NeedsMoreDetail: "needsMoreDetail", DoesNotMeetRequirements: "doesNotMeetRequirements", NotTheRightFit: "notTheRightFit", Other: "other", } as const; /** * Preset reason when the application was rejected. */ export type CreatePartnerRejectionReason = ClosedEnum< typeof CreatePartnerRejectionReason >; /** * Linked program application, including review outcome when applicable. */ export type CreatePartnerApplication = { /** * Preset reason when the application was rejected. */ rejectionReason: CreatePartnerRejectionReason | null; /** * Free-form note when the application was rejected. */ rejectionNote: string | null; /** * When the application was approved or rejected. */ reviewedAt: string | null; }; /** * The created or updated partner */ export type CreatePartnerResponseBody = { /** * The partner's unique ID on Dub. */ id: string; /** * The partner's full legal name. */ name: string; /** * If the partner profile type is a company, this is the partner's legal company name. */ companyName: string | null; /** * The partner's email address. Should be a unique value across Dub. */ email: string | null; /** * The partner's avatar image. */ image: string | null; /** * A brief description of the partner and their background. */ description?: string | null | undefined; /** * The partner's country (required for tax purposes). */ country: string | null; /** * The partner's default payout method. Connect: Bank account payouts via Stripe Connect; Stablecoin: USDC payouts directly to a crypto wallet; PayPal: Payouts via PayPal */ defaultPayoutMethod: CreatePartnerDefaultPayoutMethod | null; /** * The partner's PayPal email (for receiving payouts via PayPal). */ paypalEmail: string | null; /** * The partner's Stripe Connect ID (for receiving payouts via Stripe). */ stripeConnectId: string | null; /** * The date when the partner enabled payouts. */ payoutsEnabledAt: string | null; /** * The date when the partner received the trusted badge in the partner network. */ trustedAt: string | null; /** * The program's unique ID on Dub. */ programId: string; /** * The partner's group ID on Dub. */ groupId?: string | null | undefined; /** * The partner's unique ID on Dub. */ partnerId: string; /** * The partner's unique ID within your database. Can be useful for associating the partner with a user in your database and retrieving/update their data in the future. */ tenantId: string | null; createdAt: string; /** * The status of the partner's enrollment in the program. */ status: CreatePartnerStatus; /** * The partner's referral links in this program. */ links: Array | null; /** * The total commissions paid to the partner for their referrals */ totalCommissions: number; clickRewardId?: string | null | undefined; leadRewardId?: string | null | undefined; saleRewardId?: string | null | undefined; discountId?: string | null | undefined; /** * If the partner submitted an application to join the program, this is the ID of the application. */ applicationId?: string | null | undefined; /** * If the partner was banned from the program, this is the date of the ban. */ bannedAt?: string | null | undefined; /** * If the partner was banned from the program, this is the reason for the ban. */ bannedReason?: CreatePartnerBannedReason | null | undefined; referralFormData?: CreatePartnerReferralFormData | null | undefined; /** * Linked program application, including review outcome when applicable. */ application?: CreatePartnerApplication | null | undefined; /** * The total number of clicks on the partner's links */ totalClicks: number; /** * The total number of leads generated by the partner's links */ totalLeads: number; /** * The total number of leads that converted to paying customers */ totalConversions: number; /** * The total number of sales generated by the partner's links (includes recurring sales) */ totalSales: number; /** * Total revenue generated by the partner's links */ totalSaleAmount: number; /** * Net revenue after commissions (`Total Revenue - Total Commissions`) */ netRevenue: number; /** * Earnings Per Click (EPC) (`Total Revenue ÷ Total Clicks`) */ earningsPerClick?: number | null | undefined; /** * Average lifetime value for each paying customer (`Total Revenue ÷ Total Conversions`) */ averageLifetimeValue?: number | null | undefined; /** * Percentage of clicks that become leads (`Total Leads ÷ Total Clicks`) */ clickToLeadRate?: number | null | undefined; /** * Percentage of clicks that convert to paying customers (`Total Conversions ÷ Total Clicks`) */ clickToConversionRate?: number | null | undefined; /** * Percentage of leads that convert to paying customers (`Total Conversions ÷ Total Leads`) */ leadToConversionRate?: number | null | undefined; /** * Return On Ad Spend (ROAS) (`Total Revenue ÷ Total Commissions`) */ returnOnAdSpend?: number | null | undefined; /** * The partner's website URL (including the https protocol). */ website?: string | null | undefined; /** * The partner's YouTube channel username (e.g. `johndoe`). */ youtube?: string | null | undefined; /** * The partner's Twitter username (e.g. `johndoe`). */ twitter?: string | null | undefined; /** * The partner's LinkedIn username (e.g. `johndoe`). */ linkedin?: string | null | undefined; /** * The partner's Instagram username (e.g. `johndoe`). */ instagram?: string | null | undefined; /** * The partner's TikTok username (e.g. `johndoe`). */ tiktok?: string | null | undefined; }; /** @internal */ export type CreatePartnerTagIds$Outbound = string | Array; /** @internal */ export const CreatePartnerTagIds$outboundSchema: z.ZodType< CreatePartnerTagIds$Outbound, z.ZodTypeDef, CreatePartnerTagIds > = z.union([z.string(), z.array(z.string())]); export function createPartnerTagIdsToJSON( createPartnerTagIds: CreatePartnerTagIds, ): string { return JSON.stringify( CreatePartnerTagIds$outboundSchema.parse(createPartnerTagIds), ); } /** @internal */ export type CreatePartnerTagNames$Outbound = string | Array; /** @internal */ export const CreatePartnerTagNames$outboundSchema: z.ZodType< CreatePartnerTagNames$Outbound, z.ZodTypeDef, CreatePartnerTagNames > = z.union([z.string(), z.array(z.string())]); export function createPartnerTagNamesToJSON( createPartnerTagNames: CreatePartnerTagNames, ): string { return JSON.stringify( CreatePartnerTagNames$outboundSchema.parse(createPartnerTagNames), ); } /** @internal */ export type CreatePartnerTestVariants$Outbound = { url: string; percentage: number; }; /** @internal */ export const CreatePartnerTestVariants$outboundSchema: z.ZodType< CreatePartnerTestVariants$Outbound, z.ZodTypeDef, CreatePartnerTestVariants > = z.object({ url: z.string(), percentage: z.number(), }); export function createPartnerTestVariantsToJSON( createPartnerTestVariants: CreatePartnerTestVariants, ): string { return JSON.stringify( CreatePartnerTestVariants$outboundSchema.parse(createPartnerTestVariants), ); } /** @internal */ export type LinkProps$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 LinkProps$outboundSchema: z.ZodType< LinkProps$Outbound, z.ZodTypeDef, LinkProps > = 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(() => CreatePartnerTestVariants$outboundSchema)), ).optional(), testStartedAt: z.nullable(z.string()).optional(), testCompletedAt: z.nullable(z.string()).optional(), }); export function linkPropsToJSON(linkProps: LinkProps): string { return JSON.stringify(LinkProps$outboundSchema.parse(linkProps)); } /** @internal */ export type CreatePartnerRequestBody$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?: LinkProps$Outbound | undefined; }; /** @internal */ export const CreatePartnerRequestBody$outboundSchema: z.ZodType< CreatePartnerRequestBody$Outbound, z.ZodTypeDef, CreatePartnerRequestBody > = 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(() => LinkProps$outboundSchema).optional(), }); export function createPartnerRequestBodyToJSON( createPartnerRequestBody: CreatePartnerRequestBody, ): string { return JSON.stringify( CreatePartnerRequestBody$outboundSchema.parse(createPartnerRequestBody), ); } /** @internal */ export const CreatePartnerDefaultPayoutMethod$inboundSchema: z.ZodNativeEnum< typeof CreatePartnerDefaultPayoutMethod > = z.nativeEnum(CreatePartnerDefaultPayoutMethod); /** @internal */ export const CreatePartnerStatus$inboundSchema: z.ZodNativeEnum< typeof CreatePartnerStatus > = z.nativeEnum(CreatePartnerStatus); /** @internal */ export const CreatePartnerLinks$inboundSchema: z.ZodType< CreatePartnerLinks, 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 createPartnerLinksFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreatePartnerLinks$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreatePartnerLinks' from JSON`, ); } /** @internal */ export const CreatePartnerBannedReason$inboundSchema: z.ZodNativeEnum< typeof CreatePartnerBannedReason > = z.nativeEnum(CreatePartnerBannedReason); /** @internal */ export const Fields8$inboundSchema: z.ZodType = z.object({ key: z.string(), label: z.string(), required: z.boolean(), locked: z.boolean(), position: z.number().int(), type: z.literal("phone"), }); export function fields8FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Fields8$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Fields8' from JSON`, ); } /** @internal */ export const Fields7$inboundSchema: z.ZodType = z.object({ key: z.string(), label: z.string(), required: z.boolean(), locked: z.boolean(), position: z.number().int(), type: z.literal("number"), }); export function fields7FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Fields7$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Fields7' from JSON`, ); } /** @internal */ export const CreatePartnerFieldsPartnersOptions$inboundSchema: z.ZodType< CreatePartnerFieldsPartnersOptions, z.ZodTypeDef, unknown > = z.object({ label: z.string(), value: z.string(), }); export function createPartnerFieldsPartnersOptionsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreatePartnerFieldsPartnersOptions$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreatePartnerFieldsPartnersOptions' from JSON`, ); } /** @internal */ export const Fields6$inboundSchema: z.ZodType = z.object({ key: z.string(), label: z.string(), required: z.boolean(), locked: z.boolean(), position: z.number().int(), type: z.literal("multiSelect"), options: z.array( z.lazy(() => CreatePartnerFieldsPartnersOptions$inboundSchema), ), }); export function fields6FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Fields6$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Fields6' from JSON`, ); } /** @internal */ export const Fields5$inboundSchema: z.ZodType = z.object({ key: z.string(), label: z.string(), required: z.boolean(), locked: z.boolean(), position: z.number().int(), type: z.literal("date"), }); export function fields5FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Fields5$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Fields5' from JSON`, ); } /** @internal */ export const CreatePartnerFields4$inboundSchema: z.ZodType< CreatePartnerFields4, z.ZodTypeDef, unknown > = z.object({ key: z.string(), label: z.string(), required: z.boolean(), locked: z.boolean(), position: z.number().int(), type: z.literal("country"), }); export function createPartnerFields4FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreatePartnerFields4$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreatePartnerFields4' from JSON`, ); } /** @internal */ export const CreatePartnerFieldsOptions$inboundSchema: z.ZodType< CreatePartnerFieldsOptions, z.ZodTypeDef, unknown > = z.object({ label: z.string(), value: z.string(), }); export function createPartnerFieldsOptionsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreatePartnerFieldsOptions$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreatePartnerFieldsOptions' from JSON`, ); } /** @internal */ export const CreatePartnerFields3$inboundSchema: z.ZodType< CreatePartnerFields3, z.ZodTypeDef, unknown > = z.object({ key: z.string(), label: z.string(), required: z.boolean(), locked: z.boolean(), position: z.number().int(), type: z.literal("select"), options: z.array(z.lazy(() => CreatePartnerFieldsOptions$inboundSchema)), }); export function createPartnerFields3FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreatePartnerFields3$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreatePartnerFields3' from JSON`, ); } /** @internal */ export const CreatePartnerFieldsPartnersConstraints$inboundSchema: z.ZodType< CreatePartnerFieldsPartnersConstraints, z.ZodTypeDef, unknown > = z.object({ maxLength: z.number().int().optional(), }); export function createPartnerFieldsPartnersConstraintsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreatePartnerFieldsPartnersConstraints$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreatePartnerFieldsPartnersConstraints' from JSON`, ); } /** @internal */ export const CreatePartnerFields2$inboundSchema: z.ZodType< CreatePartnerFields2, z.ZodTypeDef, unknown > = z.object({ key: z.string(), label: z.string(), required: z.boolean(), locked: z.boolean(), position: z.number().int(), type: z.literal("textarea"), constraints: z.lazy(() => CreatePartnerFieldsPartnersConstraints$inboundSchema ).optional(), }); export function createPartnerFields2FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreatePartnerFields2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreatePartnerFields2' from JSON`, ); } /** @internal */ export const CreatePartnerFieldsConstraints$inboundSchema: z.ZodType< CreatePartnerFieldsConstraints, z.ZodTypeDef, unknown > = z.object({ maxLength: z.number().int().optional(), pattern: z.string().optional(), }); export function createPartnerFieldsConstraintsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreatePartnerFieldsConstraints$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreatePartnerFieldsConstraints' from JSON`, ); } /** @internal */ export const CreatePartnerFields1$inboundSchema: z.ZodType< CreatePartnerFields1, z.ZodTypeDef, unknown > = z.object({ key: z.string(), label: z.string(), required: z.boolean(), locked: z.boolean(), position: z.number().int(), type: z.literal("text"), constraints: z.lazy(() => CreatePartnerFieldsConstraints$inboundSchema) .optional(), }); export function createPartnerFields1FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreatePartnerFields1$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreatePartnerFields1' from JSON`, ); } /** @internal */ export const CreatePartnerFields$inboundSchema: z.ZodType< CreatePartnerFields, z.ZodTypeDef, unknown > = z.union([ z.lazy(() => CreatePartnerFields1$inboundSchema), z.lazy(() => CreatePartnerFields2$inboundSchema), z.lazy(() => CreatePartnerFields3$inboundSchema), z.lazy(() => CreatePartnerFields4$inboundSchema), z.lazy(() => Fields5$inboundSchema), z.lazy(() => Fields6$inboundSchema), z.lazy(() => Fields7$inboundSchema), z.lazy(() => Fields8$inboundSchema), ]); export function createPartnerFieldsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreatePartnerFields$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreatePartnerFields' from JSON`, ); } /** @internal */ export const CreatePartnerReferralFormData$inboundSchema: z.ZodType< CreatePartnerReferralFormData, z.ZodTypeDef, unknown > = z.object({ fields: z.array( z.union([ z.lazy(() => CreatePartnerFields1$inboundSchema), z.lazy(() => CreatePartnerFields2$inboundSchema), z.lazy(() => CreatePartnerFields3$inboundSchema), z.lazy(() => CreatePartnerFields4$inboundSchema), z.lazy(() => Fields5$inboundSchema), z.lazy(() => Fields6$inboundSchema), z.lazy(() => Fields7$inboundSchema), z.lazy(() => Fields8$inboundSchema), ]), ), }); export function createPartnerReferralFormDataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreatePartnerReferralFormData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreatePartnerReferralFormData' from JSON`, ); } /** @internal */ export const CreatePartnerRejectionReason$inboundSchema: z.ZodNativeEnum< typeof CreatePartnerRejectionReason > = z.nativeEnum(CreatePartnerRejectionReason); /** @internal */ export const CreatePartnerApplication$inboundSchema: z.ZodType< CreatePartnerApplication, z.ZodTypeDef, unknown > = z.object({ rejectionReason: z.nullable(CreatePartnerRejectionReason$inboundSchema), rejectionNote: z.nullable(z.string()), reviewedAt: z.nullable(z.string()), }); export function createPartnerApplicationFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreatePartnerApplication$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreatePartnerApplication' from JSON`, ); } /** @internal */ export const CreatePartnerResponseBody$inboundSchema: z.ZodType< CreatePartnerResponseBody, z.ZodTypeDef, unknown > = z.object({ id: z.string(), name: z.string(), companyName: z.nullable(z.string()), email: z.nullable(z.string()), image: z.nullable(z.string()), description: z.nullable(z.string()).optional(), country: z.nullable(z.string()), defaultPayoutMethod: z.nullable( CreatePartnerDefaultPayoutMethod$inboundSchema, ), paypalEmail: z.nullable(z.string()), stripeConnectId: z.nullable(z.string()), payoutsEnabledAt: z.nullable(z.string()), trustedAt: z.nullable(z.string()), programId: z.string(), groupId: z.nullable(z.string()).optional(), partnerId: z.string(), tenantId: z.nullable(z.string()), createdAt: z.string(), status: CreatePartnerStatus$inboundSchema, links: z.nullable(z.array(z.lazy(() => CreatePartnerLinks$inboundSchema))), totalCommissions: z.number().default(0), clickRewardId: z.nullable(z.string()).optional(), leadRewardId: z.nullable(z.string()).optional(), saleRewardId: z.nullable(z.string()).optional(), discountId: z.nullable(z.string()).optional(), applicationId: z.nullable(z.string()).optional(), bannedAt: z.nullable(z.string()).optional(), bannedReason: z.nullable(CreatePartnerBannedReason$inboundSchema).optional(), referralFormData: z.nullable( z.lazy(() => CreatePartnerReferralFormData$inboundSchema), ).optional(), application: z.nullable(z.lazy(() => CreatePartnerApplication$inboundSchema)) .optional(), totalClicks: z.number().default(0), totalLeads: z.number().default(0), totalConversions: z.number().default(0), totalSales: z.number().default(0), totalSaleAmount: z.number().default(0), netRevenue: z.number().default(0), earningsPerClick: z.nullable(z.number()).optional(), averageLifetimeValue: z.nullable(z.number()).optional(), clickToLeadRate: z.nullable(z.number()).optional(), clickToConversionRate: z.nullable(z.number()).optional(), leadToConversionRate: z.nullable(z.number()).optional(), returnOnAdSpend: z.nullable(z.number()).optional(), website: z.nullable(z.string()).optional(), youtube: z.nullable(z.string()).optional(), twitter: z.nullable(z.string()).optional(), linkedin: z.nullable(z.string()).optional(), instagram: z.nullable(z.string()).optional(), tiktok: z.nullable(z.string()).optional(), }); export function createPartnerResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreatePartnerResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreatePartnerResponseBody' from JSON`, ); }