/* * 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 { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type GetStatsMediasMediaIdRequest = { /** * The hashed ID or ID of the video for which you want to retrieve stats. */ mediaId: string; }; export type Action = { /** * Type of action (e.g., "Call to Action"). */ type?: string | undefined; /** * Number of actions performed. */ actionCount?: number | undefined; /** * Number of times the action was shown. */ impressionCount?: number | undefined; /** * The rate of actions performed over impressions. */ rate?: number | undefined; }; /** * Success response with the stats of the video. */ export type GetStatsMediasMediaIdResponse = { /** * The total number of times this video has been loaded. */ loadCount?: number | undefined; /** * The total number of times this video has been played. */ playCount?: number | undefined; /** * The percentage of visitors who clicked play (between 0 and 1). */ playRate?: number | undefined; /** * The total time spent watching this video. */ hoursWatched?: number | undefined; /** * The average percentage of the video that gets viewed (between 0 and 1). */ engagement?: number | undefined; /** * The total number of unique people that have loaded this video. */ visitors?: number | undefined; actions?: Array | undefined; }; /** @internal */ export type GetStatsMediasMediaIdRequest$Outbound = { mediaId: string; }; /** @internal */ export const GetStatsMediasMediaIdRequest$outboundSchema: z.ZodType< GetStatsMediasMediaIdRequest$Outbound, z.ZodTypeDef, GetStatsMediasMediaIdRequest > = z.object({ mediaId: z.string(), }); export function getStatsMediasMediaIdRequestToJSON( getStatsMediasMediaIdRequest: GetStatsMediasMediaIdRequest, ): string { return JSON.stringify( GetStatsMediasMediaIdRequest$outboundSchema.parse( getStatsMediasMediaIdRequest, ), ); } /** @internal */ export const Action$inboundSchema: z.ZodType = z .object({ type: z.string().optional(), action_count: z.number().int().optional(), impression_count: z.number().int().optional(), rate: z.number().optional(), }).transform((v) => { return remap$(v, { "action_count": "actionCount", "impression_count": "impressionCount", }); }); export function actionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Action$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Action' from JSON`, ); } /** @internal */ export const GetStatsMediasMediaIdResponse$inboundSchema: z.ZodType< GetStatsMediasMediaIdResponse, z.ZodTypeDef, unknown > = z.object({ load_count: z.number().int().optional(), play_count: z.number().int().optional(), play_rate: z.number().optional(), hours_watched: z.number().optional(), engagement: z.number().optional(), visitors: z.number().int().optional(), actions: z.array(z.lazy(() => Action$inboundSchema)).optional(), }).transform((v) => { return remap$(v, { "load_count": "loadCount", "play_count": "playCount", "play_rate": "playRate", "hours_watched": "hoursWatched", }); }); export function getStatsMediasMediaIdResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetStatsMediasMediaIdResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetStatsMediasMediaIdResponse' from JSON`, ); }