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

import * as z from "zod/v4-mini";
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 CustomerCustomerSession = {
  expiresAt: Date;
  returnUrl: string | null;
};

/** @internal */
export const CustomerCustomerSession$inboundSchema: z.ZodMiniType<
  CustomerCustomerSession,
  unknown
> = z.pipe(
  z.object({
    expires_at: z.pipe(
      z.iso.datetime({ offset: true }),
      z.transform(v => new Date(v)),
    ),
    return_url: z.nullable(z.string()),
  }),
  z.transform((v) => {
    return remap$(v, {
      "expires_at": "expiresAt",
      "return_url": "returnUrl",
    });
  }),
);

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