export type SystemToolsHashRequest = {algorithm?: string | undefined, format?: string | undefined, input?: string | undefined, urlalgorithm?: string | undefined}; export type CreateApiSysToolsHashUrlalgorithmArgs = {body: SystemToolsHashRequest}; export type CreateApiSysToolsHashUrlalgorithmOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Generate a hash sum for input data * * POST /sys/tools/hash/{urlalgorithm} */ export const createApiSysToolsHashUrlalgorithm = async (args: CreateApiSysToolsHashUrlalgorithmArgs, options: CreateApiSysToolsHashUrlalgorithmOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/sys/tools/hash/${encodeURIComponent(String(args.urlalgorithm))}${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 };