import { WellboreMergeRules } from "src/model/wellboreMergeRules"; import { ConfigureAPI } from "../baseWellsClient"; import { rethrowAsHttpError } from "../errorHandlingUtils"; export class WellboreMergeRulesAPI extends ConfigureAPI { private mergeRulesFromList(rules: string[]): WellboreMergeRules { return { name: rules, description: rules, datum: rules, parents: rules, wellTops: rules, }; } public set = async ( mergeRules: WellboreMergeRules | string[] ): Promise => { const path = this.getPath(`/wellbores/mergerules`); const mergeRulesObject = mergeRules instanceof Array ? this.mergeRulesFromList(mergeRules) : mergeRules; return await this.client .asyncPost(path, { data: mergeRulesObject }) .then((response) => response.data) .catch((err) => { throw rethrowAsHttpError(err); }); }; public retrieve = async (): Promise => { const path = this.getPath(`/wellbores/mergerules`); return await this.client .asyncGet(path) .then((response) => response.data) .catch((err) => { throw rethrowAsHttpError(err); }); }; }