/* * 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 GetAnalyticsMediasMediaIdLanguagesRequest = { /** * 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; }; export type GetAnalyticsMediasMediaIdLanguagesResponse = { /** * The ISO 639-1 language code of the viewer's browser. */ language?: string | undefined; /** * The number of video plays from viewers with this language. */ plays?: number | undefined; /** * The percentage of total plays from this language (between 0 and 1). */ percentOfTotalPlays?: number | undefined; /** * Whether captions are available for this language. */ captionsSupport?: boolean | undefined; }; /** @internal */ export type GetAnalyticsMediasMediaIdLanguagesRequest$Outbound = { mediaId: string; start_date: string; end_date: string; per_page: number; }; /** @internal */ export const GetAnalyticsMediasMediaIdLanguagesRequest$outboundSchema: z.ZodType< GetAnalyticsMediasMediaIdLanguagesRequest$Outbound, z.ZodTypeDef, GetAnalyticsMediasMediaIdLanguagesRequest > = 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(100), }).transform((v) => { return remap$(v, { startDate: "start_date", endDate: "end_date", perPage: "per_page", }); }); export function getAnalyticsMediasMediaIdLanguagesRequestToJSON( getAnalyticsMediasMediaIdLanguagesRequest: GetAnalyticsMediasMediaIdLanguagesRequest, ): string { return JSON.stringify( GetAnalyticsMediasMediaIdLanguagesRequest$outboundSchema.parse( getAnalyticsMediasMediaIdLanguagesRequest, ), ); } /** @internal */ export const GetAnalyticsMediasMediaIdLanguagesResponse$inboundSchema: z.ZodType = z.object({ language: z.string().optional(), plays: z.number().int().optional(), percent_of_total_plays: z.number().optional(), captions_support: z.boolean().optional(), }).transform((v) => { return remap$(v, { "percent_of_total_plays": "percentOfTotalPlays", "captions_support": "captionsSupport", }); }); export function getAnalyticsMediasMediaIdLanguagesResponseFromJSON( jsonString: string, ): SafeParseResult< GetAnalyticsMediasMediaIdLanguagesResponse, SDKValidationError > { return safeParse( jsonString, (x) => GetAnalyticsMediasMediaIdLanguagesResponse$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'GetAnalyticsMediasMediaIdLanguagesResponse' from JSON`, ); }