/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v3";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type V2PortalExchangeSessionResponseData = {
  /**
   * The browser session token. Store this as an httpOnly cookie for subsequent portal requests.
   *
   * @remarks
   */
  token: string;
  /**
   * Unix timestamp in milliseconds when the browser session expires (24 hours from creation).
   *
   * @remarks
   */
  expiresAt: number;
};

/** @internal */
export const V2PortalExchangeSessionResponseData$inboundSchema: z.ZodType<
  V2PortalExchangeSessionResponseData,
  z.ZodTypeDef,
  unknown
> = z.object({
  token: z.string(),
  expiresAt: z.number().int(),
});

export function v2PortalExchangeSessionResponseDataFromJSON(
  jsonString: string,
): SafeParseResult<V2PortalExchangeSessionResponseData, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) =>
      V2PortalExchangeSessionResponseData$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'V2PortalExchangeSessionResponseData' from JSON`,
  );
}
