export type CreateApiNewEndpointArgs = {Authorization: string, body: {Name: string, 'Skill List'?: string | undefined}}; export type CreateApiNewEndpointOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * POST /new-endpoint */ export const createApiNewEndpoint = async (args: CreateApiNewEndpointArgs, options?: CreateApiNewEndpointOptions) => { const {baseUrl = "https://api-smartflo.tatateleservices.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) const url = `${baseUrl.replace(/\/+$/, '')}/new-endpoint${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 undefined };