export type DeleteApiSegmentsSegmentIdArgs = {segment_id: string}; export type DeleteApiSegmentsSegmentIdOptions = {baseUrl?: string | undefined, secretAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Delete a segment * * DELETE /segments/{segment_id} */ export const deleteApiSegmentsSegmentId = async (args: DeleteApiSegmentsSegmentIdArgs, options?: DeleteApiSegmentsSegmentIdOptions) => { const {baseUrl = "https://api.qonversion.io/v4", fetch: fetchFn = fetch, secretAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (secretAuth !== undefined) headers.set('authorization', `Bearer ${secretAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/segments/${encodeURIComponent(String(args.segment_id))}${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 };