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

import * as z from "zod/v3";
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";
import {
  AiConfigsLink,
  AiConfigsLink$inboundSchema,
  AiConfigsLink$Outbound,
  AiConfigsLink$outboundSchema,
} from "./aiconfigslink.js";

export type AiConfigsMemberSummary = {
  /**
   * The location and content type of related resources
   */
  links: { [k: string]: AiConfigsLink };
  /**
   * The member's ID
   */
  id: string;
  /**
   * The member's first name
   */
  firstName?: string | undefined;
  /**
   * The member's last name
   */
  lastName?: string | undefined;
  /**
   * The member's base role. If the member has no additional roles, this role will be in effect.
   */
  role: string;
  /**
   * The member's email address
   */
  email: string;
};

/** @internal */
export const AiConfigsMemberSummary$inboundSchema: z.ZodType<
  AiConfigsMemberSummary,
  z.ZodTypeDef,
  unknown
> = z.object({
  _links: z.record(AiConfigsLink$inboundSchema),
  _id: z.string(),
  firstName: z.string().optional(),
  lastName: z.string().optional(),
  role: z.string(),
  email: z.string(),
}).transform((v) => {
  return remap$(v, {
    "_links": "links",
    "_id": "id",
  });
});
/** @internal */
export type AiConfigsMemberSummary$Outbound = {
  _links: { [k: string]: AiConfigsLink$Outbound };
  _id: string;
  firstName?: string | undefined;
  lastName?: string | undefined;
  role: string;
  email: string;
};

/** @internal */
export const AiConfigsMemberSummary$outboundSchema: z.ZodType<
  AiConfigsMemberSummary$Outbound,
  z.ZodTypeDef,
  AiConfigsMemberSummary
> = z.object({
  links: z.record(AiConfigsLink$outboundSchema),
  id: z.string(),
  firstName: z.string().optional(),
  lastName: z.string().optional(),
  role: z.string(),
  email: z.string(),
}).transform((v) => {
  return remap$(v, {
    links: "_links",
    id: "_id",
  });
});

export function aiConfigsMemberSummaryToJSON(
  aiConfigsMemberSummary: AiConfigsMemberSummary,
): string {
  return JSON.stringify(
    AiConfigsMemberSummary$outboundSchema.parse(aiConfigsMemberSummary),
  );
}
export function aiConfigsMemberSummaryFromJSON(
  jsonString: string,
): SafeParseResult<AiConfigsMemberSummary, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => AiConfigsMemberSummary$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'AiConfigsMemberSummary' from JSON`,
  );
}
