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

export type WorkspaceUserSummary = {
  /**
   * The ID of the user
   */
  userId?: string | undefined;
  /**
   * The email of the user
   */
  email?: string | null | undefined;
  /**
   * The first name of the user
   */
  firstName?: string | null | undefined;
  /**
   * The last name of the user
   */
  lastName?: string | null | undefined;
  /**
   * The ID of the users's role
   */
  roleId?: string | null | undefined;
  /**
   * The name of the user's role
   */
  roleName?: string | null | undefined;
};

/** @internal */
export const WorkspaceUserSummary$inboundSchema: z.ZodType<
  WorkspaceUserSummary,
  z.ZodTypeDef,
  unknown
> = z.object({
  user_id: types.optional(types.string()),
  email: z.nullable(types.string()).optional(),
  first_name: z.nullable(types.string()).optional(),
  last_name: z.nullable(types.string()).optional(),
  role_id: z.nullable(types.string()).optional(),
  role_name: z.nullable(types.string()).optional(),
}).transform((v) => {
  return remap$(v, {
    "user_id": "userId",
    "first_name": "firstName",
    "last_name": "lastName",
    "role_id": "roleId",
    "role_name": "roleName",
  });
});

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