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

import * as z from "zod/v4-mini";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  CustomerOrganization,
  CustomerOrganization$inboundSchema,
} from "./customerorganization.js";
import {
  CustomerProduct,
  CustomerProduct$inboundSchema,
} from "./customerproduct.js";

/**
 * Schema of an organization and related data for customer portal.
 */
export type CustomerOrganizationData = {
  organization: CustomerOrganization;
  products: Array<CustomerProduct>;
};

/** @internal */
export const CustomerOrganizationData$inboundSchema: z.ZodMiniType<
  CustomerOrganizationData,
  unknown
> = z.object({
  organization: CustomerOrganization$inboundSchema,
  products: z.array(CustomerProduct$inboundSchema),
});

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