export type DeleteApiV2CustomFieldsFieldNameFieldNameArgs = {fieldName: string}; export type DeleteApiV2CustomFieldsFieldNameFieldNameOptions = {baseUrl: string, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Delete custom field by field name * * DELETE /v2/custom-fields/field-name/{fieldName} * * Also accepts auth: sessionKey */ export const deleteApiV2CustomFieldsFieldNameFieldName = async (args: DeleteApiV2CustomFieldsFieldNameFieldNameArgs, options: DeleteApiV2CustomFieldsFieldNameFieldNameOptions) => { const {baseUrl, fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/custom-fields/field-name/${encodeURIComponent(String(args.fieldName))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };