/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { RFCDate } from "../../types/rfcdate.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type GetAnalyticsMediasMediaIdConversionsRequest = { /** * The hashed ID of the video. */ mediaId: string; /** * Start date for the analytics period in ISO 8601 format (YYYY-MM-DD). Inclusive — the range starts at the beginning of this date. */ startDate: RFCDate; /** * End date for the analytics period in ISO 8601 format (YYYY-MM-DD). Exclusive — the range ends before the beginning of this date. */ endDate: RFCDate; /** * Number of results to return (max 100). */ perPage?: number | undefined; /** * Cursor for pagination. Use the value from the previous response's page_info.end_cursor. */ cursor?: string | undefined; }; export type GetAnalyticsMediasMediaIdConversionsData = { /** * The first name of the form submitter. */ firstName?: string | null | undefined; /** * The last name of the form submitter. */ lastName?: string | null | undefined; /** * The email address of the form submitter. */ email?: string | null | undefined; /** * The timestamp when the form was submitted in ISO 8601 format. */ convertedAt?: Date | undefined; }; export type GetAnalyticsMediasMediaIdConversionsPageInfo = { /** * Whether there are more results after this page. */ hasNextPage?: boolean | undefined; /** * Whether there are results before this page. */ hasPreviousPage?: boolean | undefined; /** * Cursor to use for fetching the next page. */ endCursor?: string | null | undefined; /** * Cursor to use for fetching the previous page. */ startCursor?: string | null | undefined; }; /** * Success response with form conversion data. */ export type GetAnalyticsMediasMediaIdConversionsResponse = { data?: Array | undefined; pageInfo?: GetAnalyticsMediasMediaIdConversionsPageInfo | undefined; }; /** @internal */ export type GetAnalyticsMediasMediaIdConversionsRequest$Outbound = { mediaId: string; start_date: string; end_date: string; per_page: number; cursor?: string | undefined; }; /** @internal */ export const GetAnalyticsMediasMediaIdConversionsRequest$outboundSchema: z.ZodType< GetAnalyticsMediasMediaIdConversionsRequest$Outbound, z.ZodTypeDef, GetAnalyticsMediasMediaIdConversionsRequest > = z.object({ mediaId: z.string(), startDate: z.instanceof(RFCDate).transform(v => v.toString()), endDate: z.instanceof(RFCDate).transform(v => v.toString()), perPage: z.number().int().default(25), cursor: z.string().optional(), }).transform((v) => { return remap$(v, { startDate: "start_date", endDate: "end_date", perPage: "per_page", }); }); export function getAnalyticsMediasMediaIdConversionsRequestToJSON( getAnalyticsMediasMediaIdConversionsRequest: GetAnalyticsMediasMediaIdConversionsRequest, ): string { return JSON.stringify( GetAnalyticsMediasMediaIdConversionsRequest$outboundSchema.parse( getAnalyticsMediasMediaIdConversionsRequest, ), ); } /** @internal */ export const GetAnalyticsMediasMediaIdConversionsData$inboundSchema: z.ZodType< GetAnalyticsMediasMediaIdConversionsData, z.ZodTypeDef, unknown > = z.object({ first_name: z.nullable(z.string()).optional(), last_name: z.nullable(z.string()).optional(), email: z.nullable(z.string()).optional(), converted_at: z.string().datetime({ offset: true }).transform(v => new Date(v) ).optional(), }).transform((v) => { return remap$(v, { "first_name": "firstName", "last_name": "lastName", "converted_at": "convertedAt", }); }); export function getAnalyticsMediasMediaIdConversionsDataFromJSON( jsonString: string, ): SafeParseResult< GetAnalyticsMediasMediaIdConversionsData, SDKValidationError > { return safeParse( jsonString, (x) => GetAnalyticsMediasMediaIdConversionsData$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'GetAnalyticsMediasMediaIdConversionsData' from JSON`, ); } /** @internal */ export const GetAnalyticsMediasMediaIdConversionsPageInfo$inboundSchema: z.ZodType< GetAnalyticsMediasMediaIdConversionsPageInfo, z.ZodTypeDef, unknown > = z.object({ has_next_page: z.boolean().optional(), has_previous_page: z.boolean().optional(), end_cursor: z.nullable(z.string()).optional(), start_cursor: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { "has_next_page": "hasNextPage", "has_previous_page": "hasPreviousPage", "end_cursor": "endCursor", "start_cursor": "startCursor", }); }); export function getAnalyticsMediasMediaIdConversionsPageInfoFromJSON( jsonString: string, ): SafeParseResult< GetAnalyticsMediasMediaIdConversionsPageInfo, SDKValidationError > { return safeParse( jsonString, (x) => GetAnalyticsMediasMediaIdConversionsPageInfo$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'GetAnalyticsMediasMediaIdConversionsPageInfo' from JSON`, ); } /** @internal */ export const GetAnalyticsMediasMediaIdConversionsResponse$inboundSchema: z.ZodType< GetAnalyticsMediasMediaIdConversionsResponse, z.ZodTypeDef, unknown > = z.object({ data: z.array( z.lazy(() => GetAnalyticsMediasMediaIdConversionsData$inboundSchema), ).optional(), page_info: z.lazy(() => GetAnalyticsMediasMediaIdConversionsPageInfo$inboundSchema ).optional(), }).transform((v) => { return remap$(v, { "page_info": "pageInfo", }); }); export function getAnalyticsMediasMediaIdConversionsResponseFromJSON( jsonString: string, ): SafeParseResult< GetAnalyticsMediasMediaIdConversionsResponse, SDKValidationError > { return safeParse( jsonString, (x) => GetAnalyticsMediasMediaIdConversionsResponse$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'GetAnalyticsMediasMediaIdConversionsResponse' from JSON`, ); }