/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The time step to aggregate viewership metrics by * * @remarks */ export enum GetUsageMetricsQueryParamTimeStep { Hour = "hour", Day = "day", } export enum GetUsageMetricsQueryParamBreakdownBy { CreatorId = "creatorId", } export type GetUsageMetricsRequest = { /** * Start millis timestamp for the query range (inclusive) * * @remarks */ from?: number | undefined; /** * End millis timestamp for the query range (exclusive) * * @remarks */ to?: number | undefined; /** * The time step to aggregate viewership metrics by * * @remarks */ timeStep?: GetUsageMetricsQueryParamTimeStep | undefined; /** * The creator ID to filter the query results * * @remarks */ creatorId?: string | undefined; /** * The list of fields to break down the query results. Currently the * * @remarks * only supported breakdown is by `creatorId`. */ breakdownBy?: Array | undefined; }; export type GetUsageMetricsResponse = { /** * HTTP response content type for this operation */ contentType: string; /** * HTTP response status code for this operation */ statusCode: number; /** * Raw HTTP response; suitable for custom response parsing */ rawResponse: Response; /** * A Usage Metric object */ usageMetric?: components.UsageMetric | undefined; /** * Error */ error?: components.ErrorT | undefined; }; /** @internal */ export const GetUsageMetricsQueryParamTimeStep$inboundSchema: z.ZodNativeEnum< typeof GetUsageMetricsQueryParamTimeStep > = z.nativeEnum(GetUsageMetricsQueryParamTimeStep); /** @internal */ export const GetUsageMetricsQueryParamTimeStep$outboundSchema: z.ZodNativeEnum< typeof GetUsageMetricsQueryParamTimeStep > = GetUsageMetricsQueryParamTimeStep$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GetUsageMetricsQueryParamTimeStep$ { /** @deprecated use `GetUsageMetricsQueryParamTimeStep$inboundSchema` instead. */ export const inboundSchema = GetUsageMetricsQueryParamTimeStep$inboundSchema; /** @deprecated use `GetUsageMetricsQueryParamTimeStep$outboundSchema` instead. */ export const outboundSchema = GetUsageMetricsQueryParamTimeStep$outboundSchema; } /** @internal */ export const GetUsageMetricsQueryParamBreakdownBy$inboundSchema: z.ZodNativeEnum = z.nativeEnum( GetUsageMetricsQueryParamBreakdownBy, ); /** @internal */ export const GetUsageMetricsQueryParamBreakdownBy$outboundSchema: z.ZodNativeEnum = GetUsageMetricsQueryParamBreakdownBy$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GetUsageMetricsQueryParamBreakdownBy$ { /** @deprecated use `GetUsageMetricsQueryParamBreakdownBy$inboundSchema` instead. */ export const inboundSchema = GetUsageMetricsQueryParamBreakdownBy$inboundSchema; /** @deprecated use `GetUsageMetricsQueryParamBreakdownBy$outboundSchema` instead. */ export const outboundSchema = GetUsageMetricsQueryParamBreakdownBy$outboundSchema; } /** @internal */ export const GetUsageMetricsRequest$inboundSchema: z.ZodType< GetUsageMetricsRequest, z.ZodTypeDef, unknown > = z.object({ from: z.number().int().optional(), to: z.number().int().optional(), timeStep: GetUsageMetricsQueryParamTimeStep$inboundSchema.optional(), creatorId: z.string().optional(), "breakdownBy[]": z.array(GetUsageMetricsQueryParamBreakdownBy$inboundSchema) .optional(), }).transform((v) => { return remap$(v, { "breakdownBy[]": "breakdownBy", }); }); /** @internal */ export type GetUsageMetricsRequest$Outbound = { from?: number | undefined; to?: number | undefined; timeStep?: string | undefined; creatorId?: string | undefined; "breakdownBy[]"?: Array | undefined; }; /** @internal */ export const GetUsageMetricsRequest$outboundSchema: z.ZodType< GetUsageMetricsRequest$Outbound, z.ZodTypeDef, GetUsageMetricsRequest > = z.object({ from: z.number().int().optional(), to: z.number().int().optional(), timeStep: GetUsageMetricsQueryParamTimeStep$outboundSchema.optional(), creatorId: z.string().optional(), breakdownBy: z.array(GetUsageMetricsQueryParamBreakdownBy$outboundSchema) .optional(), }).transform((v) => { return remap$(v, { breakdownBy: "breakdownBy[]", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GetUsageMetricsRequest$ { /** @deprecated use `GetUsageMetricsRequest$inboundSchema` instead. */ export const inboundSchema = GetUsageMetricsRequest$inboundSchema; /** @deprecated use `GetUsageMetricsRequest$outboundSchema` instead. */ export const outboundSchema = GetUsageMetricsRequest$outboundSchema; /** @deprecated use `GetUsageMetricsRequest$Outbound` instead. */ export type Outbound = GetUsageMetricsRequest$Outbound; } export function getUsageMetricsRequestToJSON( getUsageMetricsRequest: GetUsageMetricsRequest, ): string { return JSON.stringify( GetUsageMetricsRequest$outboundSchema.parse(getUsageMetricsRequest), ); } export function getUsageMetricsRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetUsageMetricsRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetUsageMetricsRequest' from JSON`, ); } /** @internal */ export const GetUsageMetricsResponse$inboundSchema: z.ZodType< GetUsageMetricsResponse, z.ZodTypeDef, unknown > = z.object({ ContentType: z.string(), StatusCode: z.number().int(), RawResponse: z.instanceof(Response), "usage-metric": components.UsageMetric$inboundSchema.optional(), error: components.ErrorT$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "ContentType": "contentType", "StatusCode": "statusCode", "RawResponse": "rawResponse", "usage-metric": "usageMetric", }); }); /** @internal */ export type GetUsageMetricsResponse$Outbound = { ContentType: string; StatusCode: number; RawResponse: never; "usage-metric"?: components.UsageMetric$Outbound | undefined; error?: components.ErrorT$Outbound | undefined; }; /** @internal */ export const GetUsageMetricsResponse$outboundSchema: z.ZodType< GetUsageMetricsResponse$Outbound, z.ZodTypeDef, GetUsageMetricsResponse > = z.object({ contentType: z.string(), statusCode: z.number().int(), rawResponse: z.instanceof(Response).transform(() => { throw new Error("Response cannot be serialized"); }), usageMetric: components.UsageMetric$outboundSchema.optional(), error: components.ErrorT$outboundSchema.optional(), }).transform((v) => { return remap$(v, { contentType: "ContentType", statusCode: "StatusCode", rawResponse: "RawResponse", usageMetric: "usage-metric", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace GetUsageMetricsResponse$ { /** @deprecated use `GetUsageMetricsResponse$inboundSchema` instead. */ export const inboundSchema = GetUsageMetricsResponse$inboundSchema; /** @deprecated use `GetUsageMetricsResponse$outboundSchema` instead. */ export const outboundSchema = GetUsageMetricsResponse$outboundSchema; /** @deprecated use `GetUsageMetricsResponse$Outbound` instead. */ export type Outbound = GetUsageMetricsResponse$Outbound; } export function getUsageMetricsResponseToJSON( getUsageMetricsResponse: GetUsageMetricsResponse, ): string { return JSON.stringify( GetUsageMetricsResponse$outboundSchema.parse(getUsageMetricsResponse), ); } export function getUsageMetricsResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => GetUsageMetricsResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'GetUsageMetricsResponse' from JSON`, ); }