export type UpdateApiRulesRuleUIDModuleCategoryIdConfigParamArgs = {ruleUID: string, moduleCategory: string, id: string, param: string, body: BodyInit}; export type UpdateApiRulesRuleUIDModuleCategoryIdConfigParamOptions = {baseUrl: string, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Sets the module's configuration parameter value. * * PUT /rules/{ruleUID}/{moduleCategory}/{id}/config/{param} */ export const updateApiRulesRuleUIDModuleCategoryIdConfigParam = async (args: UpdateApiRulesRuleUIDModuleCategoryIdConfigParamArgs, options: UpdateApiRulesRuleUIDModuleCategoryIdConfigParamOptions) => { const {baseUrl, fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "text/plain") if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/rules/${encodeURIComponent(String(args.ruleUID))}/${encodeURIComponent(String(args.moduleCategory))}/${encodeURIComponent(String(args.id))}/config/${encodeURIComponent(String(args.param))}${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 };