Skip to content

Commit

Permalink
feat: add more functions for routing plans
Browse files Browse the repository at this point in the history
  • Loading branch information
arnoerpenbeck committed Sep 4, 2024
1 parent ee28685 commit 33c96c6
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/fft-api/routing-plan/fftRoutingPlanService.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -20,7 +20,34 @@ export class FftRoutingPlanService {
httpError.response ? JSON.stringify(httpError.response.body) : ''
}`
);
throw err;
}
}

public async getById(routingPlanId: string): Promise<RoutingPlan> {
try {
return await this.apiClient.get<RoutingPlan>(`${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<DecisionLog> {
try {
return await this.apiClient.get<DecisionLog>(`${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;
}
}
Expand Down

0 comments on commit 33c96c6

Please sign in to comment.