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

import * as z from "zod/v3";
import { safeParse } from "../lib/schemas.js";
import { ClosedEnum } from "../types/enums.js";
import { Result as SafeParseResult } from "../types/fp.js";
import * as types from "../types/primitives.js";
import { SDKValidationError } from "./sdkvalidationerror.js";

export type GetMemberRequest = {
  integrationConfigurationId: string;
  memberId: string;
};

/**
 * "The `ADMIN` role, by default, is provided to users capable of installing integrations, while the `USER` role can be granted to Vercel users with the Vercel `Billing` or Vercel `Viewer` role, which are considered to be Read-Only roles."
 */
export const GetMemberRole = {
  Admin: "ADMIN",
  User: "USER",
} as const;
/**
 * "The `ADMIN` role, by default, is provided to users capable of installing integrations, while the `USER` role can be granted to Vercel users with the Vercel `Billing` or Vercel `Viewer` role, which are considered to be Read-Only roles."
 */
export type GetMemberRole = ClosedEnum<typeof GetMemberRole>;

export type GetMemberResponseBody = {
  id: string;
  /**
   * "The `ADMIN` role, by default, is provided to users capable of installing integrations, while the `USER` role can be granted to Vercel users with the Vercel `Billing` or Vercel `Viewer` role, which are considered to be Read-Only roles."
   */
  role: GetMemberRole;
  globalUserId?: string | undefined;
  userEmail?: string | undefined;
};

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

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

export function getMemberRequestToJSON(
  getMemberRequest: GetMemberRequest,
): string {
  return JSON.stringify(
    GetMemberRequest$outboundSchema.parse(getMemberRequest),
  );
}

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

/** @internal */
export const GetMemberResponseBody$inboundSchema: z.ZodType<
  GetMemberResponseBody,
  z.ZodTypeDef,
  unknown
> = z.object({
  id: types.string(),
  role: GetMemberRole$inboundSchema,
  globalUserId: types.optional(types.string()),
  userEmail: types.optional(types.string()),
});

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