/* * 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 { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { RFCDate } from "../../types/rfcdate.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The metric to sort embed locations by. */ export const GetAnalyticsMediasMediaIdEmbedLocationsSortBy = { Plays: "plays", Loads: "loads", EngagementRate: "engagement_rate", PlayRate: "play_rate", } as const; /** * The metric to sort embed locations by. */ export type GetAnalyticsMediasMediaIdEmbedLocationsSortBy = ClosedEnum< typeof GetAnalyticsMediasMediaIdEmbedLocationsSortBy >; /** * The sort direction. */ export const GetAnalyticsMediasMediaIdEmbedLocationsSortDirection = { Asc: "asc", Desc: "desc", } as const; /** * The sort direction. */ export type GetAnalyticsMediasMediaIdEmbedLocationsSortDirection = ClosedEnum< typeof GetAnalyticsMediasMediaIdEmbedLocationsSortDirection >; export type GetAnalyticsMediasMediaIdEmbedLocationsRequest = { /** * 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; /** * The metric to sort embed locations by. */ sortBy?: GetAnalyticsMediasMediaIdEmbedLocationsSortBy | undefined; /** * The sort direction. */ sortDirection?: | GetAnalyticsMediasMediaIdEmbedLocationsSortDirection | undefined; /** * Filter results to a single embed URL. When provided, only analytics for * * @remarks * the page matching this URL are returned. Must be a valid HTTP or HTTPS URL. */ embedUrl?: string | undefined; /** * Number of results to return (max 100). */ perPage?: number | undefined; }; export type GetAnalyticsMediasMediaIdEmbedLocationsResponse = { /** * The domain where the video is embedded. */ embedDomain?: string | undefined; /** * The path on the domain where the video is embedded. */ embedPath?: string | undefined; /** * The full URL where the video is embedded. */ embedUrl?: string | undefined; /** * The title of the page where the video is embedded. */ pageTitle?: string | undefined; /** * The number of video loads from this location. */ loads?: number | undefined; /** * The number of unique video loads from this location (one per visitor session). */ uniqueLoads?: number | undefined; /** * The number of video plays from this location. */ plays?: number | undefined; /** * The number of unique video plays from this location (one per visitor session). */ uniquePlays?: number | undefined; /** * The play rate from this location (between 0 and 1). */ playRate?: number | undefined; /** * Total time spent watching from this location in seconds. */ playedTime?: number | undefined; /** * The average engagement rate from this location (between 0 and 1). */ engagementRate?: number | undefined; /** * The number of unique visitors from this location. */ uniqueVisitors?: number | undefined; /** * The CTA conversion rate from this location (between 0 and 1). */ ctaConversionRate?: number | undefined; }; /** @internal */ export const GetAnalyticsMediasMediaIdEmbedLocationsSortBy$outboundSchema: z.ZodNativeEnum = z .nativeEnum(GetAnalyticsMediasMediaIdEmbedLocationsSortBy); /** @internal */ export const GetAnalyticsMediasMediaIdEmbedLocationsSortDirection$outboundSchema: z.ZodNativeEnum = z.nativeEnum(GetAnalyticsMediasMediaIdEmbedLocationsSortDirection); /** @internal */ export type GetAnalyticsMediasMediaIdEmbedLocationsRequest$Outbound = { mediaId: string; start_date: string; end_date: string; sort_by: string; sort_direction: string; embed_url?: string | undefined; per_page: number; }; /** @internal */ export const GetAnalyticsMediasMediaIdEmbedLocationsRequest$outboundSchema: z.ZodType< GetAnalyticsMediasMediaIdEmbedLocationsRequest$Outbound, z.ZodTypeDef, GetAnalyticsMediasMediaIdEmbedLocationsRequest > = z.object({ mediaId: z.string(), startDate: z.instanceof(RFCDate).transform(v => v.toString()), endDate: z.instanceof(RFCDate).transform(v => v.toString()), sortBy: GetAnalyticsMediasMediaIdEmbedLocationsSortBy$outboundSchema .default("plays"), sortDirection: GetAnalyticsMediasMediaIdEmbedLocationsSortDirection$outboundSchema .default("desc"), embedUrl: z.string().optional(), perPage: z.number().int().default(10), }).transform((v) => { return remap$(v, { startDate: "start_date", endDate: "end_date", sortBy: "sort_by", sortDirection: "sort_direction", embedUrl: "embed_url", perPage: "per_page", }); }); export function getAnalyticsMediasMediaIdEmbedLocationsRequestToJSON( getAnalyticsMediasMediaIdEmbedLocationsRequest: GetAnalyticsMediasMediaIdEmbedLocationsRequest, ): string { return JSON.stringify( GetAnalyticsMediasMediaIdEmbedLocationsRequest$outboundSchema.parse( getAnalyticsMediasMediaIdEmbedLocationsRequest, ), ); } /** @internal */ export const GetAnalyticsMediasMediaIdEmbedLocationsResponse$inboundSchema: z.ZodType< GetAnalyticsMediasMediaIdEmbedLocationsResponse, z.ZodTypeDef, unknown > = z.object({ embed_domain: z.string().optional(), embed_path: z.string().optional(), embed_url: z.string().optional(), page_title: z.string().optional(), loads: z.number().int().optional(), unique_loads: z.number().int().optional(), plays: z.number().int().optional(), unique_plays: z.number().int().optional(), play_rate: z.number().optional(), played_time: z.number().optional(), engagement_rate: z.number().optional(), unique_visitors: z.number().int().optional(), cta_conversion_rate: z.number().optional(), }).transform((v) => { return remap$(v, { "embed_domain": "embedDomain", "embed_path": "embedPath", "embed_url": "embedUrl", "page_title": "pageTitle", "unique_loads": "uniqueLoads", "unique_plays": "uniquePlays", "play_rate": "playRate", "played_time": "playedTime", "engagement_rate": "engagementRate", "unique_visitors": "uniqueVisitors", "cta_conversion_rate": "ctaConversionRate", }); }); export function getAnalyticsMediasMediaIdEmbedLocationsResponseFromJSON( jsonString: string, ): SafeParseResult< GetAnalyticsMediasMediaIdEmbedLocationsResponse, SDKValidationError > { return safeParse( jsonString, (x) => GetAnalyticsMediasMediaIdEmbedLocationsResponse$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'GetAnalyticsMediasMediaIdEmbedLocationsResponse' from JSON`, ); }