/* * 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 Authorization = { /** * The type of object the permission is being performed on, only media is currently supported */ type: string; /** * The hashed if of the object the permissions are being performed on. */ id: string; /** * The types of permissions, currently only supports edit-transcripts */ permissions: Array; }; export type ExpiringAccessToken = { /** * an ISO8601 string of when the token will expire, defaults to two days from creation */ expiresAt?: string | undefined; /** * a list of authorizations the token will have */ authorizations?: Array | undefined; }; export type PostExpiringTokenRequest = { expiringAccessToken?: ExpiringAccessToken | undefined; }; /** * Successful response */ export type PostExpiringTokenResponse = { /** * A token which can be used to authorize requests to Wistia. Currently only for doing transcript embeds. */ token: string; }; /** @internal */ export type Authorization$Outbound = { type: string; id: string; permissions: Array; }; /** @internal */ export const Authorization$outboundSchema: z.ZodType< Authorization$Outbound, z.ZodTypeDef, Authorization > = z.object({ type: z.string(), id: z.string(), permissions: z.array(z.string()), }); export function authorizationToJSON(authorization: Authorization): string { return JSON.stringify(Authorization$outboundSchema.parse(authorization)); } /** @internal */ export type ExpiringAccessToken$Outbound = { expires_at?: string | undefined; authorizations?: Array | undefined; }; /** @internal */ export const ExpiringAccessToken$outboundSchema: z.ZodType< ExpiringAccessToken$Outbound, z.ZodTypeDef, ExpiringAccessToken > = z.object({ expiresAt: z.string().optional(), authorizations: z.array(z.lazy(() => Authorization$outboundSchema)) .optional(), }).transform((v) => { return remap$(v, { expiresAt: "expires_at", }); }); export function expiringAccessTokenToJSON( expiringAccessToken: ExpiringAccessToken, ): string { return JSON.stringify( ExpiringAccessToken$outboundSchema.parse(expiringAccessToken), ); } /** @internal */ export type PostExpiringTokenRequest$Outbound = { expiring_access_token?: ExpiringAccessToken$Outbound | undefined; }; /** @internal */ export const PostExpiringTokenRequest$outboundSchema: z.ZodType< PostExpiringTokenRequest$Outbound, z.ZodTypeDef, PostExpiringTokenRequest > = z.object({ expiringAccessToken: z.lazy(() => ExpiringAccessToken$outboundSchema) .optional(), }).transform((v) => { return remap$(v, { expiringAccessToken: "expiring_access_token", }); }); export function postExpiringTokenRequestToJSON( postExpiringTokenRequest: PostExpiringTokenRequest, ): string { return JSON.stringify( PostExpiringTokenRequest$outboundSchema.parse(postExpiringTokenRequest), ); } /** @internal */ export const PostExpiringTokenResponse$inboundSchema: z.ZodType< PostExpiringTokenResponse, z.ZodTypeDef, unknown > = z.object({ token: z.string(), }); export function postExpiringTokenResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PostExpiringTokenResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PostExpiringTokenResponse' from JSON`, ); }