import { WellMergeRules } from "src/model/wellMergeRules"; import { ConfigureAPI } from "../baseWellsClient"; import { rethrowAsHttpError } from "../errorHandlingUtils"; export class WellMergeRulesAPI extends ConfigureAPI { private mergeRulesFromList(rules: string[]): WellMergeRules { return { name: rules, description: rules, country: rules, quadrant: rules, region: rules, block: rules, field: rules, operator: rules, spudDate: rules, license: rules, wellType: rules, waterDepth: rules, wellhead: rules, }; } public set = async ( mergeRules: WellMergeRules | string[] ): Promise => { const path = this.getPath(`/wells/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(`/wells/mergerules`); return await this.client .asyncGet(path) .then((response) => response.data) .catch((err) => { throw rethrowAsHttpError(err); }); }; }