/*
 * 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 * as types from "../types/primitives.js";
import { SDKValidationError } from "./sdkvalidationerror.js";

export type GetAccountInfoRequest = {
  integrationConfigurationId: string;
};

/**
 * The best contact for the integration, which can change as team members and their roles change.
 */
export type Contact = {
  email: string;
  name?: string | undefined;
};

export type GetAccountInfoResponseBody = {
  /**
   * The name of the team the installation is tied to.
   */
  name?: string | undefined;
  /**
   * A URL linking to the installation in the Vercel Dashboard.
   */
  url: string;
  /**
   * The best contact for the integration, which can change as team members and their roles change.
   */
  contact: Contact | null;
};

/** @internal */
export type GetAccountInfoRequest$Outbound = {
  integrationConfigurationId: string;
};

/** @internal */
export const GetAccountInfoRequest$outboundSchema: z.ZodType<
  GetAccountInfoRequest$Outbound,
  z.ZodTypeDef,
  GetAccountInfoRequest
> = z.object({
  integrationConfigurationId: z.string(),
});

export function getAccountInfoRequestToJSON(
  getAccountInfoRequest: GetAccountInfoRequest,
): string {
  return JSON.stringify(
    GetAccountInfoRequest$outboundSchema.parse(getAccountInfoRequest),
  );
}

/** @internal */
export const Contact$inboundSchema: z.ZodType<Contact, z.ZodTypeDef, unknown> =
  z.object({
    email: types.string(),
    name: types.optional(types.string()),
  });

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

/** @internal */
export const GetAccountInfoResponseBody$inboundSchema: z.ZodType<
  GetAccountInfoResponseBody,
  z.ZodTypeDef,
  unknown
> = z.object({
  name: types.optional(types.string()),
  url: types.string(),
  contact: types.nullable(z.lazy(() => Contact$inboundSchema)),
});

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