import {z} from 'zod' export type SsoSetupDraftRequest = {Step?: number | undefined, IdpProvider?: string | undefined, Protocol?: string | undefined, MetadataSource?: string | undefined, MetadataUrl?: string | undefined, MetadataXml?: string | undefined, MetadataXmlBase64?: string | undefined, EntityId?: string | undefined, SsoLoginUrl?: string | undefined, Certificate?: string | undefined, HandshakeComplete?: boolean | undefined, ClientId?: string | undefined, ClientSecret?: string | undefined, DiscoveryUrl?: string | undefined, TokenEndpoint?: string | undefined, AuthorizationEndpoint?: string | undefined, Scope?: string | undefined, EmailDomains?: Array | undefined, RequireAdmin?: boolean | undefined, RequireEmployee?: boolean | undefined, AutoCreate?: boolean | undefined, AttrEmail?: string | undefined, AttrFirstName?: string | undefined, AttrLastName?: string | undefined, AttrDepartment?: string | undefined, DefaultRole?: string | undefined}; export type UpdateApiV1SsoSetupDraftArgs = {body: SsoSetupDraftRequest}; export type UpdateApiV1SsoSetupDraftOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const updateApiV1SsoSetupDraftResponse = z.object({}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * PUT /v1/sso/setup/draft */ export const updateApiV1SsoSetupDraft = async (args: UpdateApiV1SsoSetupDraftArgs, options?: UpdateApiV1SsoSetupDraftOptions) => { const {baseUrl = "https://api.succeedms.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v1/sso/setup/draft${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(updateApiV1SsoSetupDraftResponse, await res.json()) };