/* * 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 * as components from "../components/index.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The interval to retrieve analytics for. If undefined, defaults to 24h. */ export const RetrievePartnerAnalyticsQueryParamInterval = { TwentyFourh: "24h", Sevend: "7d", Thirtyd: "30d", Ninetyd: "90d", Oney: "1y", Mtd: "mtd", Qtd: "qtd", Ytd: "ytd", All: "all", } as const; /** * The interval to retrieve analytics for. If undefined, defaults to 24h. */ export type RetrievePartnerAnalyticsQueryParamInterval = ClosedEnum< typeof RetrievePartnerAnalyticsQueryParamInterval >; /** * The parameter to group the analytics data points by. Defaults to `count` if undefined. */ export const RetrievePartnerAnalyticsQueryParamGroupBy = { TopLinks: "top_links", Timeseries: "timeseries", Count: "count", } as const; /** * The parameter to group the analytics data points by. Defaults to `count` if undefined. */ export type RetrievePartnerAnalyticsQueryParamGroupBy = ClosedEnum< typeof RetrievePartnerAnalyticsQueryParamGroupBy >; export type RetrievePartnerAnalyticsRequest = { /** * 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; /** * The interval to retrieve analytics for. If undefined, defaults to 24h. */ interval?: RetrievePartnerAnalyticsQueryParamInterval | undefined; /** * The start date and time when to retrieve analytics from. If set, takes precedence over `interval`. */ start?: string | undefined; /** * The end date and time when to retrieve analytics from. If not provided, defaults to the current date. If set along with `start`, takes precedence over `interval`. */ end?: string | undefined; /** * The IANA time zone code for aligning timeseries granularity (e.g. America/New_York). Defaults to UTC. */ timezone?: string | undefined; /** * Search the events by a custom metadata value. Only available for lead and sale events. Examples: `metadata['key']:'value'` */ query?: string | undefined; /** * The parameter to group the analytics data points by. Defaults to `count` if undefined. */ groupBy?: RetrievePartnerAnalyticsQueryParamGroupBy | undefined; }; /** * Partner analytics data */ export type RetrievePartnerAnalyticsResponseBody = | components.PartnerAnalyticsCount | Array | Array; /** @internal */ export const RetrievePartnerAnalyticsQueryParamInterval$outboundSchema: z.ZodNativeEnum = z .nativeEnum(RetrievePartnerAnalyticsQueryParamInterval); /** @internal */ export const RetrievePartnerAnalyticsQueryParamGroupBy$outboundSchema: z.ZodNativeEnum = z .nativeEnum(RetrievePartnerAnalyticsQueryParamGroupBy); /** @internal */ export type RetrievePartnerAnalyticsRequest$Outbound = { partnerId?: string | null | undefined; tenantId?: string | null | undefined; interval?: string | undefined; start?: string | undefined; end?: string | undefined; timezone: string; query?: string | undefined; groupBy: string; }; /** @internal */ export const RetrievePartnerAnalyticsRequest$outboundSchema: z.ZodType< RetrievePartnerAnalyticsRequest$Outbound, z.ZodTypeDef, RetrievePartnerAnalyticsRequest > = z.object({ partnerId: z.nullable(z.string()).optional(), tenantId: z.nullable(z.string()).optional(), interval: RetrievePartnerAnalyticsQueryParamInterval$outboundSchema .optional(), start: z.string().optional(), end: z.string().optional(), timezone: z.string().default("UTC"), query: z.string().optional(), groupBy: RetrievePartnerAnalyticsQueryParamGroupBy$outboundSchema.default( "count", ), }); export function retrievePartnerAnalyticsRequestToJSON( retrievePartnerAnalyticsRequest: RetrievePartnerAnalyticsRequest, ): string { return JSON.stringify( RetrievePartnerAnalyticsRequest$outboundSchema.parse( retrievePartnerAnalyticsRequest, ), ); } /** @internal */ export const RetrievePartnerAnalyticsResponseBody$inboundSchema: z.ZodType< RetrievePartnerAnalyticsResponseBody, z.ZodTypeDef, unknown > = z.union([ components.PartnerAnalyticsCount$inboundSchema, z.array(components.PartnerAnalyticsTimeseries$inboundSchema), z.array(components.PartnerAnalyticsTopLinks$inboundSchema), ]); export function retrievePartnerAnalyticsResponseBodyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => RetrievePartnerAnalyticsResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'RetrievePartnerAnalyticsResponseBody' from JSON`, ); }