/* * 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 GetAnalyticsMediasMediaIdRequest = { /** * 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; }; /** * Success response with aggregate analytics for the video. */ export type GetAnalyticsMediasMediaIdResponse = { /** * The number of unique video loads. */ uniqueLoads?: number | null | undefined; /** * The number of unique video plays. */ uniquePlays?: number | null | undefined; /** * The total number of video plays. */ plays?: number | null | undefined; /** * The percentage of loads that resulted in a play (between 0 and 1). */ playRate?: number | null | undefined; /** * Total time spent watching the video in seconds. */ playedTime?: number | null | undefined; /** * The number of unique visitors who loaded the video. */ uniqueVisitors?: number | null | undefined; /** * The average percentage of the video watched (between 0 and 1). */ engagementRate?: number | null | undefined; /** * The number of times a call-to-action was shown. */ ctaImpressions?: number | null | undefined; /** * The number of times a call-to-action was clicked. */ ctaConversions?: number | null | undefined; /** * The rate of CTA clicks over impressions (between 0 and 1). */ ctaConversionRate?: number | null | undefined; /** * The number of form submissions. */ formConversions?: number | null | undefined; }; /** @internal */ export type GetAnalyticsMediasMediaIdRequest$Outbound = { mediaId: string; start_date: string; end_date: string; }; /** @internal */ export const GetAnalyticsMediasMediaIdRequest$outboundSchema: z.ZodType< GetAnalyticsMediasMediaIdRequest$Outbound, z.ZodTypeDef, GetAnalyticsMediasMediaIdRequest > = z.object({ mediaId: z.string(), startDate: z.instanceof(RFCDate).transform(v => v.toString()), endDate: z.instanceof(RFCDate).transform(v => v.toString()), }).transform((v) => { return remap$(v, { startDate: "start_date", endDate: "end_date", }); }); export function getAnalyticsMediasMediaIdRequestToJSON( getAnalyticsMediasMediaIdRequest: GetAnalyticsMediasMediaIdRequest, ): string { return JSON.stringify( GetAnalyticsMediasMediaIdRequest$outboundSchema.parse( getAnalyticsMediasMediaIdRequest, ), ); } /** @internal */ export const GetAnalyticsMediasMediaIdResponse$inboundSchema: z.ZodType< GetAnalyticsMediasMediaIdResponse, z.ZodTypeDef, unknown > = z.object({ unique_loads: z.nullable(z.number().int()).optional(), unique_plays: z.nullable(z.number().int()).optional(), plays: z.nullable(z.number().int()).optional(), play_rate: z.nullable(z.number()).optional(), played_time: z.nullable(z.number().int()).optional(), unique_visitors: z.nullable(z.number().int()).optional(), engagement_rate: z.nullable(z.number()).optional(), cta_impressions: z.nullable(z.number().int()).optional(), cta_conversions: z.nullable(z.number().int()).optional(), cta_conversion_rate: z.nullable(z.number()).optional(), form_conversions: z.nullable(z.number().int()).optional(), }).transform((v) => { return remap$(v, { "unique_loads": "uniqueLoads", "unique_plays": "uniquePlays", "play_rate": "playRate", "played_time": "playedTime", "unique_visitors": "uniqueVisitors", "engagement_rate": "engagementRate", "cta_impressions": "ctaImpressions", "cta_conversions": "ctaConversions", "cta_conversion_rate": "ctaConversionRate", "form_conversions": "formConversions", }); }); export function getAnalyticsMediasMediaIdResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetAnalyticsMediasMediaIdResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetAnalyticsMediasMediaIdResponse' from JSON`, ); }