/*
 * 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 CustomerPortalOAuthAccount = {
  accountId: string;
  accountUsername: string | null;
};

/** @internal */
export const CustomerPortalOAuthAccount$inboundSchema: z.ZodMiniType<
  CustomerPortalOAuthAccount,
  unknown
> = z.pipe(
  z.object({
    account_id: z.string(),
    account_username: z.nullable(z.string()),
  }),
  z.transform((v) => {
    return remap$(v, {
      "account_id": "accountId",
      "account_username": "accountUsername",
    });
  }),
);

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