export type TestPlanTestCaseQueryValues = {testplan_id?: number | undefined, testcase_query_id?: number | undefined}; export type CreateApiTestcaseQueryMappingBulkOtherEntitiesArgs = {op?: ('add' | 'update' | 'add_or_update' | 'delete') | undefined, otherEntities: string, body: Array<{ids?: {testcase_query_id: number, testplan_id: number} | undefined, mapped?: TestPlanTestCaseQueryValues | undefined}>}; export type CreateApiTestcaseQueryMappingBulkOtherEntitiesOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Add/remove/update mappings between 'TestCaseQuery' entities and other entities * * POST /testcase-query/mapping/bulk/{otherEntities} */ export const createApiTestcaseQueryMappingBulkOtherEntities = async (args: CreateApiTestcaseQueryMappingBulkOtherEntitiesArgs, options?: CreateApiTestcaseQueryMappingBulkOtherEntitiesOptions) => { const {baseUrl = "https://app.testiny.io/api/v1", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.op != null) query.append("op", String(args.op)) if (ApiKeyAuth !== undefined) headers.set("X-Api-Key", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/testcase-query/mapping/bulk/${encodeURIComponent(String(args.otherEntities))}${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 };