/*
 * 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 CreateWorkspaceUserResponse = {
  /**
   * The ID of the workspace
   */
  workspaceId?: string | undefined;
  /**
   * The ID of the user
   */
  userId?: string | undefined;
  /**
   * The ID of the role assigned to the user
   */
  roleId?: 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;
};

/** @internal */
export const CreateWorkspaceUserResponse$inboundSchema: z.ZodType<
  CreateWorkspaceUserResponse,
  z.ZodTypeDef,
  unknown
> = z.object({
  workspace_id: types.optional(types.string()),
  user_id: types.optional(types.string()),
  role_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(),
}).transform((v) => {
  return remap$(v, {
    "workspace_id": "workspaceId",
    "user_id": "userId",
    "role_id": "roleId",
    "first_name": "firstName",
    "last_name": "lastName",
  });
});

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