/* * 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"; /** * A filter on the list based on the partner's `status` field. */ export const ListPartnersQueryParamStatus = { Pending: "pending", Approved: "approved", Rejected: "rejected", Invited: "invited", Declined: "declined", Deactivated: "deactivated", Banned: "banned", Archived: "archived", } as const; /** * A filter on the list based on the partner's `status` field. */ export type ListPartnersQueryParamStatus = ClosedEnum< typeof ListPartnersQueryParamStatus >; /** * The field to sort the partners by. The default is `totalSaleAmount`. */ export const ListPartnersQueryParamSortBy = { CreatedAt: "createdAt", TotalClicks: "totalClicks", TotalLeads: "totalLeads", TotalConversions: "totalConversions", TotalSaleAmount: "totalSaleAmount", TotalCommissions: "totalCommissions", NetRevenue: "netRevenue", EarningsPerClick: "earningsPerClick", AverageLifetimeValue: "averageLifetimeValue", ClickToLeadRate: "clickToLeadRate", ClickToConversionRate: "clickToConversionRate", LeadToConversionRate: "leadToConversionRate", ReturnOnAdSpend: "returnOnAdSpend", } as const; /** * The field to sort the partners by. The default is `totalSaleAmount`. */ export type ListPartnersQueryParamSortBy = ClosedEnum< typeof ListPartnersQueryParamSortBy >; /** * The sort order. The default is `desc`. */ export const ListPartnersQueryParamSortOrder = { Asc: "asc", Desc: "desc", } as const; /** * The sort order. The default is `desc`. */ export type ListPartnersQueryParamSortOrder = ClosedEnum< typeof ListPartnersQueryParamSortOrder >; export type ListPartnersRequest = { /** * A filter on the list based on the partner's `groupId` field. */ groupId?: string | undefined; /** * A filter on the list based on the partner's `status` field. */ status?: ListPartnersQueryParamStatus | undefined; /** * A filter on the list based on the partner's `country` field. */ country?: string | undefined; /** * The field to sort the partners by. The default is `totalSaleAmount`. */ sortBy?: ListPartnersQueryParamSortBy | undefined; /** * The sort order. The default is `desc`. */ sortOrder?: ListPartnersQueryParamSortOrder | undefined; /** * Filter the partner list based on the partner's `email`. The value must be a string. Takes precedence over `search`. */ email?: string | undefined; /** * Filter the partner list based on the partner's `tenantId`. The value must be a string. Takes precedence over `email` and `search`. */ tenantId?: string | undefined; /** * A search query to filter partners by ID, name, email, or link. */ search?: string | undefined; /** * The page number for pagination. */ page?: number | undefined; /** * The number of items per page. */ pageSize?: number | 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 DefaultPayoutMethod = { 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 DefaultPayoutMethod = ClosedEnum; /** * The status of the partner's enrollment in the program. */ export const ListPartnersStatus = { 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 ListPartnersStatus = ClosedEnum; export type Links = { /** * 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 BannedReason = { 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 BannedReason = ClosedEnum; export type Eight = { key: string; label: string; required: boolean; locked: boolean; position: number; type: "phone"; }; export type Seven = { key: string; label: string; required: boolean; locked: boolean; position: number; type: "number"; }; export type FieldsOptions = { label: string; value: string; }; export type Six = { key: string; label: string; required: boolean; locked: boolean; position: number; type: "multiSelect"; options: Array; }; export type Five = { key: string; label: string; required: boolean; locked: boolean; position: number; type: "date"; }; export type Fields4 = { key: string; label: string; required: boolean; locked: boolean; position: number; type: "country"; }; export type Options = { label: string; value: string; }; export type Fields3 = { key: string; label: string; required: boolean; locked: boolean; position: number; type: "select"; options: Array; }; export type FieldsConstraints = { maxLength?: number | undefined; }; export type Fields2 = { key: string; label: string; required: boolean; locked: boolean; position: number; type: "textarea"; constraints?: FieldsConstraints | undefined; }; export type Constraints = { maxLength?: number | undefined; pattern?: string | undefined; }; export type Fields1 = { key: string; label: string; required: boolean; locked: boolean; position: number; type: "text"; constraints?: Constraints | undefined; }; export type Fields = | Fields1 | Fields2 | Fields3 | Fields4 | Five | Six | Seven | Eight; export type ReferralFormData = { fields: Array< Fields1 | Fields2 | Fields3 | Fields4 | Five | Six | Seven | Eight >; }; /** * Preset reason when the application was rejected. */ export const ListPartnersRejectionReason = { NeedsMoreDetail: "needsMoreDetail", DoesNotMeetRequirements: "doesNotMeetRequirements", NotTheRightFit: "notTheRightFit", Other: "other", } as const; /** * Preset reason when the application was rejected. */ export type ListPartnersRejectionReason = ClosedEnum< typeof ListPartnersRejectionReason >; /** * Linked program application, including review outcome when applicable. */ export type Application = { /** * Preset reason when the application was rejected. */ rejectionReason: ListPartnersRejectionReason | null; /** * Free-form note when the application was rejected. */ rejectionNote: string | null; /** * When the application was approved or rejected. */ reviewedAt: string | null; }; export type ListPartnersResponseBody = { /** * 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: DefaultPayoutMethod | 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: ListPartnersStatus; /** * 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?: BannedReason | null | undefined; referralFormData?: ReferralFormData | null | undefined; /** * Linked program application, including review outcome when applicable. */ application?: Application | 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 const ListPartnersQueryParamStatus$outboundSchema: z.ZodNativeEnum< typeof ListPartnersQueryParamStatus > = z.nativeEnum(ListPartnersQueryParamStatus); /** @internal */ export const ListPartnersQueryParamSortBy$outboundSchema: z.ZodNativeEnum< typeof ListPartnersQueryParamSortBy > = z.nativeEnum(ListPartnersQueryParamSortBy); /** @internal */ export const ListPartnersQueryParamSortOrder$outboundSchema: z.ZodNativeEnum< typeof ListPartnersQueryParamSortOrder > = z.nativeEnum(ListPartnersQueryParamSortOrder); /** @internal */ export type ListPartnersRequest$Outbound = { groupId?: string | undefined; status?: string | undefined; country?: string | undefined; sortBy: string; sortOrder: string; email?: string | undefined; tenantId?: string | undefined; search?: string | undefined; page?: number | undefined; pageSize: number; }; /** @internal */ export const ListPartnersRequest$outboundSchema: z.ZodType< ListPartnersRequest$Outbound, z.ZodTypeDef, ListPartnersRequest > = z.object({ groupId: z.string().optional(), status: ListPartnersQueryParamStatus$outboundSchema.optional(), country: z.string().optional(), sortBy: ListPartnersQueryParamSortBy$outboundSchema.default( "totalSaleAmount", ), sortOrder: ListPartnersQueryParamSortOrder$outboundSchema.default("desc"), email: z.string().optional(), tenantId: z.string().optional(), search: z.string().optional(), page: z.number().optional(), pageSize: z.number().default(100), }); export function listPartnersRequestToJSON( listPartnersRequest: ListPartnersRequest, ): string { return JSON.stringify( ListPartnersRequest$outboundSchema.parse(listPartnersRequest), ); } /** @internal */ export const DefaultPayoutMethod$inboundSchema: z.ZodNativeEnum< typeof DefaultPayoutMethod > = z.nativeEnum(DefaultPayoutMethod); /** @internal */ export const ListPartnersStatus$inboundSchema: z.ZodNativeEnum< typeof ListPartnersStatus > = z.nativeEnum(ListPartnersStatus); /** @internal */ export const Links$inboundSchema: z.ZodType = 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 linksFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Links$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Links' from JSON`, ); } /** @internal */ export const BannedReason$inboundSchema: z.ZodNativeEnum = z.nativeEnum(BannedReason); /** @internal */ export const Eight$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 eightFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Eight$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Eight' from JSON`, ); } /** @internal */ export const Seven$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 sevenFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Seven$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Seven' from JSON`, ); } /** @internal */ export const FieldsOptions$inboundSchema: z.ZodType< FieldsOptions, z.ZodTypeDef, unknown > = z.object({ label: z.string(), value: z.string(), }); export function fieldsOptionsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FieldsOptions$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FieldsOptions' from JSON`, ); } /** @internal */ export const Six$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(() => FieldsOptions$inboundSchema)), }); export function sixFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Six$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Six' from JSON`, ); } /** @internal */ export const Five$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 fiveFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Five$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Five' from JSON`, ); } /** @internal */ export const Fields4$inboundSchema: z.ZodType = z.object({ key: z.string(), label: z.string(), required: z.boolean(), locked: z.boolean(), position: z.number().int(), type: z.literal("country"), }); export function fields4FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Fields4$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Fields4' from JSON`, ); } /** @internal */ export const Options$inboundSchema: z.ZodType = z.object({ label: z.string(), value: z.string(), }); export function optionsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Options$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Options' from JSON`, ); } /** @internal */ export const Fields3$inboundSchema: z.ZodType = 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(() => Options$inboundSchema)), }); export function fields3FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Fields3$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Fields3' from JSON`, ); } /** @internal */ export const FieldsConstraints$inboundSchema: z.ZodType< FieldsConstraints, z.ZodTypeDef, unknown > = z.object({ maxLength: z.number().int().optional(), }); export function fieldsConstraintsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FieldsConstraints$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FieldsConstraints' from JSON`, ); } /** @internal */ export const Fields2$inboundSchema: z.ZodType = 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(() => FieldsConstraints$inboundSchema).optional(), }); export function fields2FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Fields2$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Fields2' from JSON`, ); } /** @internal */ export const Constraints$inboundSchema: z.ZodType< Constraints, z.ZodTypeDef, unknown > = z.object({ maxLength: z.number().int().optional(), pattern: z.string().optional(), }); export function constraintsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Constraints$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Constraints' from JSON`, ); } /** @internal */ export const Fields1$inboundSchema: z.ZodType = 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(() => Constraints$inboundSchema).optional(), }); export function fields1FromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Fields1$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Fields1' from JSON`, ); } /** @internal */ export const Fields$inboundSchema: z.ZodType = z .union([ z.lazy(() => Fields1$inboundSchema), z.lazy(() => Fields2$inboundSchema), z.lazy(() => Fields3$inboundSchema), z.lazy(() => Fields4$inboundSchema), z.lazy(() => Five$inboundSchema), z.lazy(() => Six$inboundSchema), z.lazy(() => Seven$inboundSchema), z.lazy(() => Eight$inboundSchema), ]); export function fieldsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Fields$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Fields' from JSON`, ); } /** @internal */ export const ReferralFormData$inboundSchema: z.ZodType< ReferralFormData, z.ZodTypeDef, unknown > = z.object({ fields: z.array( z.union([ z.lazy(() => Fields1$inboundSchema), z.lazy(() => Fields2$inboundSchema), z.lazy(() => Fields3$inboundSchema), z.lazy(() => Fields4$inboundSchema), z.lazy(() => Five$inboundSchema), z.lazy(() => Six$inboundSchema), z.lazy(() => Seven$inboundSchema), z.lazy(() => Eight$inboundSchema), ]), ), }); export function referralFormDataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ReferralFormData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ReferralFormData' from JSON`, ); } /** @internal */ export const ListPartnersRejectionReason$inboundSchema: z.ZodNativeEnum< typeof ListPartnersRejectionReason > = z.nativeEnum(ListPartnersRejectionReason); /** @internal */ export const Application$inboundSchema: z.ZodType< Application, z.ZodTypeDef, unknown > = z.object({ rejectionReason: z.nullable(ListPartnersRejectionReason$inboundSchema), rejectionNote: z.nullable(z.string()), reviewedAt: z.nullable(z.string()), }); export function applicationFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Application$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Application' from JSON`, ); } /** @internal */ export const ListPartnersResponseBody$inboundSchema: z.ZodType< ListPartnersResponseBody, 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(DefaultPayoutMethod$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: ListPartnersStatus$inboundSchema, links: z.nullable(z.array(z.lazy(() => Links$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(BannedReason$inboundSchema).optional(), referralFormData: z.nullable(z.lazy(() => ReferralFormData$inboundSchema)) .optional(), application: z.nullable(z.lazy(() => Application$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 listPartnersResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ListPartnersResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ListPartnersResponseBody' from JSON`, ); }