import {z} from 'zod' export type Phone = {Id?: number | undefined, Number?: string | undefined, Extension?: number | undefined, Type?: (0 | 1 | 2 | 3 | 4) | undefined}; export type User = {Id?: number | undefined, CompanyId?: number | undefined, Name: string, Username: string, Email?: string | undefined, Active?: boolean | undefined, Phone?: Phone | undefined, Password?: string | undefined}; export type UpdateApiV1OrganizationUserArgs = {body: User}; export type UpdateApiV1OrganizationUserOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const updateApiV1OrganizationUserResponse = 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/organization/user */ export const updateApiV1OrganizationUser = async (args: UpdateApiV1OrganizationUserArgs, options?: UpdateApiV1OrganizationUserOptions) => { 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/organization/user${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(updateApiV1OrganizationUserResponse, await res.json()) };