export type UpdateApiV1DataSourcesDataSourceIdDataArgs = {body: BodyInit}; export type UpdateApiV1DataSourcesDataSourceIdDataOptions = {baseUrl?: string | undefined, tokenAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update data source CSV data * * PUT /v1/data-sources/{dataSourceId}/data */ export const updateApiV1DataSourcesDataSourceIdData = async (args: UpdateApiV1DataSourcesDataSourceIdDataArgs, options?: UpdateApiV1DataSourcesDataSourceIdDataOptions) => { const {baseUrl = "https://wmc.wiremockapi.cloud", fetch: fetchFn = fetch, tokenAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "text/csv") if (tokenAuth !== undefined) headers.set("Authorization", tokenAuth) const url = `${baseUrl.replace(/\/+$/, '')}/v1/data-sources/${encodeURIComponent(String(args.dataSourceId))}/data${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };