From 33c96c6a30cda50649f59346c994713713ea213c Mon Sep 17 00:00:00 2001 From: Arno Erpenbeck <88486704+arnoerpenbeck@users.noreply.github.com> Date: Wed, 4 Sep 2024 17:24:10 +0200 Subject: [PATCH] feat: add more functions for routing plans --- .../routing-plan/fftRoutingPlanService.ts | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/fft-api/routing-plan/fftRoutingPlanService.ts b/src/fft-api/routing-plan/fftRoutingPlanService.ts index d77a13a..b577dc9 100644 --- a/src/fft-api/routing-plan/fftRoutingPlanService.ts +++ b/src/fft-api/routing-plan/fftRoutingPlanService.ts @@ -1,4 +1,4 @@ -import { RoutingPlans } from '../types'; +import { DecisionLog, RoutingPlan, RoutingPlans } from '../types'; import { FftApiClient } from '../common'; import { ResponseError } from 'superagent'; import { Logger } from 'tslog'; @@ -20,7 +20,34 @@ export class FftRoutingPlanService { httpError.response ? JSON.stringify(httpError.response.body) : '' }` ); + throw err; + } + } + public async getById(routingPlanId: string): Promise { + try { + return await this.apiClient.get(`${this.path}/${routingPlanId}`); + } catch (err) { + const httpError = err as ResponseError; + this.logger.error( + `Could not get routing plan for ID '${routingPlanId}'. Failed with status ${httpError.status}, error: ${ + httpError.response ? JSON.stringify(httpError.response.body) : '' + }` + ); + throw err; + } + } + + public async getDecisionLogForRoutingPlan(routingPlanId: string, routingRun = 1): Promise { + try { + return await this.apiClient.get(`${this.path}/${routingPlanId}/decisionlogs/${routingRun}`); + } catch (err) { + const httpError = err as ResponseError; + this.logger.error( + `Could not get decision log for routing plan '${routingPlanId}'. Failed with status ${ + httpError.status + }, error: ${httpError.response ? JSON.stringify(httpError.response.body) : ''}` + ); throw err; } }