/* * 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 GetMediasMediaHashedIdStatsRequest = { /** * The hashed ID of the video. */ mediaHashedId: string; }; /** * An object representing the aggregated embed statistics for this video. */ export type Stats = { /** * The total number of times that the page containing the embedded video has been loaded. */ pageLoads?: number | undefined; /** * The number of unique visitors to the page containing the embedded video. */ visitors?: number | undefined; /** * An integer between 0 and 100 that shows what percentage of the time someone who saw the page containing the embedded video played the video. */ percentOfVisitorsClickingPlay?: number | undefined; /** * The total number of times that the video has been played. */ plays?: number | undefined; /** * An integer between 0 and 100. It shows the average percentage of the video that was watched over every time the video was played. */ averagePercentWatched?: number | undefined; }; /** * Successful retrieval of video statistics. */ export type GetMediasMediaHashedIdStatsResponse = { /** * A unique numeric identifier for the video within the system. */ id?: number | undefined; /** * A unique alphanumeric identifier for the video within the system. */ hashedId?: string | undefined; /** * The display name of the video. */ name?: string | undefined; /** * An object representing the aggregated embed statistics for this video. */ stats?: Stats | undefined; }; /** @internal */ export type GetMediasMediaHashedIdStatsRequest$Outbound = { mediaHashedId: string; }; /** @internal */ export const GetMediasMediaHashedIdStatsRequest$outboundSchema: z.ZodType< GetMediasMediaHashedIdStatsRequest$Outbound, z.ZodTypeDef, GetMediasMediaHashedIdStatsRequest > = z.object({ mediaHashedId: z.string(), }); export function getMediasMediaHashedIdStatsRequestToJSON( getMediasMediaHashedIdStatsRequest: GetMediasMediaHashedIdStatsRequest, ): string { return JSON.stringify( GetMediasMediaHashedIdStatsRequest$outboundSchema.parse( getMediasMediaHashedIdStatsRequest, ), ); } /** @internal */ export const Stats$inboundSchema: z.ZodType = z .object({ pageLoads: z.number().int().optional(), visitors: z.number().int().optional(), percentOfVisitorsClickingPlay: z.number().int().optional(), plays: z.number().int().optional(), averagePercentWatched: z.number().int().optional(), }); export function statsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Stats$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Stats' from JSON`, ); } /** @internal */ export const GetMediasMediaHashedIdStatsResponse$inboundSchema: z.ZodType< GetMediasMediaHashedIdStatsResponse, z.ZodTypeDef, unknown > = z.object({ id: z.number().int().optional(), hashed_id: z.string().optional(), name: z.string().optional(), stats: z.lazy(() => Stats$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "hashed_id": "hashedId", }); }); export function getMediasMediaHashedIdStatsResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetMediasMediaHashedIdStatsResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetMediasMediaHashedIdStatsResponse' from JSON`, ); }