/*
 * 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 { ClosedEnum } from "../types/enums.js";

/**
 * The role of the user to invite
 */
export const InviteUserToTeamRole = {
  Owner: "OWNER",
  Member: "MEMBER",
  Developer: "DEVELOPER",
  Security: "SECURITY",
  Billing: "BILLING",
  Viewer: "VIEWER",
  ViewerForPlus: "VIEWER_FOR_PLUS",
  Contributor: "CONTRIBUTOR",
} as const;
/**
 * The role of the user to invite
 */
export type InviteUserToTeamRole = ClosedEnum<typeof InviteUserToTeamRole>;

/**
 * Sets the project roles for the invited user
 */
export const InviteUserToTeamTeamsRole = {
  Admin: "ADMIN",
  ProjectViewer: "PROJECT_VIEWER",
  ProjectDeveloper: "PROJECT_DEVELOPER",
  ProjectGuest: "PROJECT_GUEST",
} as const;
/**
 * Sets the project roles for the invited user
 */
export type InviteUserToTeamTeamsRole = ClosedEnum<
  typeof InviteUserToTeamTeamsRole
>;

export type InviteUserToTeamProjects = {
  /**
   * The ID of the project.
   */
  projectId: string;
  /**
   * Sets the project roles for the invited user
   */
  role: InviteUserToTeamTeamsRole;
};

export type InviteUserToTeamRequestBody = {
  /**
   * The email address of the user to invite
   */
  email: string;
  /**
   * The role of the user to invite
   */
  role?: InviteUserToTeamRole | undefined;
  projects?: Array<InviteUserToTeamProjects> | undefined;
};

export type InviteUserToTeamRequest = {
  /**
   * The Team identifier to perform the request on behalf of.
   */
  teamId: string;
  /**
   * The Team slug to perform the request on behalf of.
   */
  slug?: string | undefined;
  requestBody?: Array<InviteUserToTeamRequestBody> | undefined;
};

/** @internal */
export const InviteUserToTeamRole$outboundSchema: z.ZodNativeEnum<
  typeof InviteUserToTeamRole
> = z.nativeEnum(InviteUserToTeamRole);

/** @internal */
export const InviteUserToTeamTeamsRole$outboundSchema: z.ZodNativeEnum<
  typeof InviteUserToTeamTeamsRole
> = z.nativeEnum(InviteUserToTeamTeamsRole);

/** @internal */
export type InviteUserToTeamProjects$Outbound = {
  projectId: string;
  role: string;
};

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

export function inviteUserToTeamProjectsToJSON(
  inviteUserToTeamProjects: InviteUserToTeamProjects,
): string {
  return JSON.stringify(
    InviteUserToTeamProjects$outboundSchema.parse(inviteUserToTeamProjects),
  );
}

/** @internal */
export type InviteUserToTeamRequestBody$Outbound = {
  email: string;
  role: string;
  projects?: Array<InviteUserToTeamProjects$Outbound> | undefined;
};

/** @internal */
export const InviteUserToTeamRequestBody$outboundSchema: z.ZodType<
  InviteUserToTeamRequestBody$Outbound,
  z.ZodTypeDef,
  InviteUserToTeamRequestBody
> = z.object({
  email: z.string(),
  role: InviteUserToTeamRole$outboundSchema.default("VIEWER"),
  projects: z.array(z.lazy(() => InviteUserToTeamProjects$outboundSchema))
    .optional(),
});

export function inviteUserToTeamRequestBodyToJSON(
  inviteUserToTeamRequestBody: InviteUserToTeamRequestBody,
): string {
  return JSON.stringify(
    InviteUserToTeamRequestBody$outboundSchema.parse(
      inviteUserToTeamRequestBody,
    ),
  );
}

/** @internal */
export type InviteUserToTeamRequest$Outbound = {
  teamId: string;
  slug?: string | undefined;
  RequestBody?: Array<InviteUserToTeamRequestBody$Outbound> | undefined;
};

/** @internal */
export const InviteUserToTeamRequest$outboundSchema: z.ZodType<
  InviteUserToTeamRequest$Outbound,
  z.ZodTypeDef,
  InviteUserToTeamRequest
> = z.object({
  teamId: z.string(),
  slug: z.string().optional(),
  requestBody: z.array(z.lazy(() => InviteUserToTeamRequestBody$outboundSchema))
    .optional(),
}).transform((v) => {
  return remap$(v, {
    requestBody: "RequestBody",
  });
});

export function inviteUserToTeamRequestToJSON(
  inviteUserToTeamRequest: InviteUserToTeamRequest,
): string {
  return JSON.stringify(
    InviteUserToTeamRequest$outboundSchema.parse(inviteUserToTeamRequest),
  );
}
