pricing - PricingRouter
MODIFY
src/server/rest/v1/router/GlobalRouter.ts
src/server/rest/v1/router/GlobalRouter.ts
@@ -5,6 +5,7 @@ import AuthRouter from './auth/AuthRouter';
import AuthService from '../service/AuthService';
import BillingRouter from './api/BillingRouter';
import ChargingStationRouter from './api/ChargingStationRouter';
+import PricingRouter from './api/PricingRouter';
import { StatusCodes } from 'http-status-codes';
import SwaggerRouter from './doc/SwaggerRouter';
import TagRouter from './api/TagRouter';
@@ -45,6 +46,7 @@ export default class GlobalRouter {
new TransactionRouter().buildRoutes(),
new UserRouter().buildRoutes(),
new BillingRouter().buildRoutes(),
+ new PricingRouter().buildRoutes(),
]);
}

ADD
src/server/rest/v1/router/api/PricingRouter.ts
+/* eslint-disable @typescript-eslint/no-misused-promises */
+import { ServerAction, ServerRoute } from '../../../../../types/Server';
+import express, { NextFunction, Request, Response } from 'express';
+
+import PricingService from '../../service/PricingService';
+import RouterUtils from '../RouterUtils';
+
+export default class PricingRouter {
+ private router: express.Router;
+
+ public constructor() {
+ this.router = express.Router();
+ }
+
+ public buildRoutes(): express.Router {
+ // -----------------------------------
+ // ROUTES for PRICING MODELS
+ // -----------------------------------
+ this.buildRoutePricingModels();
+ this.buildRoutePricingModel();
+ this.buildRouteCreatePricingModel();
+ this.buildRouteDeletePricingModel();
+ this.buildRouteUpdatePricingModel();
+ return this.router;
+ }
+
+ protected buildRoutePricingModels(): void {
+ this.router.get(`/${ServerRoute.REST_PRICING_MODELS}`, async (req: Request, res: Response, next: NextFunction) => {
+ await RouterUtils.handleServerAction(PricingService.handleGetPricingModels.bind(this), ServerAction.PRICING_MODELS, req, res, next);
+ });
+ }
+
+ protected buildRoutePricingModel(): void {
+ this.router.get(`/${ServerRoute.REST_PRICING_MODEL}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.query.ID = req.params.id;
+ await RouterUtils.handleServerAction(PricingService.handleGetPricingModel.bind(this), ServerAction.PRICING_MODEL, req, res, next);
+ });
+ }
+
+ protected buildRouteCreatePricingModel(): void {
+ this.router.post(`/${ServerRoute.REST_PRICING_MODELS}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.query.ID = req.params.id;
+ await RouterUtils.handleServerAction(PricingService.handleCreatePricingModel.bind(this), ServerAction.PRICING_MODEL_CREATE, req, res, next);
+ });
+ }
+
+ protected buildRouteDeletePricingModel(): void {
+ this.router.delete(`/${ServerRoute.REST_PRICING_MODEL}`, async (req: Request, res: Response, next: NextFunction) => {
+ req.query.ID = req.params.id;
+ await RouterUtils.handleServerAction(PricingService.handleDeletePricingModel.bind(this), ServerAction.PRICING_MODEL_DELETE, req, res, next);
+ });
+ }
+
+ protected buildRouteUpdatePricingModel(): void {
+ this.router.put(`/${ServerRoute.REST_PRICING_MODEL}`, async (req: Request, res: Response, next: NextFunction) => {
+ await RouterUtils.handleServerAction(PricingService.handleUpdatePricingModel.bind(this), ServerAction.PRICING_MODEL_UPDATE, req, res, next);
+ });
+ }
+}

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -429,6 +429,12 @@ export enum ServerAction {
BILLING_WEB_HOOK = 'BillingWebHook',
BILLING_TEST_DATA_CLEANUP = 'BillingTestDataCleanup',
+ PRICING_MODEL = 'PricingModel',
+ PRICING_MODELS = 'PricingModels',
+ PRICING_MODEL_CREATE = 'PricingModelCreate',
+ PRICING_MODEL_UPDATE = 'PricingModelUpdate',
+ PRICING_MODEL_DELETE = 'PricingModelDelete',
+
MONGO_DB = 'MongoDB',
CHECK_AND_APPLY_SMART_CHARGING = 'CheckAndApplySmartCharging',
@@ -542,6 +548,10 @@ export enum ServerRoute {
// BILLING URLs for Non-CRUD operations on INVOICES
REST_BILLING_DOWNLOAD_INVOICE = 'invoices/:invoiceID/download',
+
+ // PRICING URLs for CRUD operations
+ REST_PRICING_MODELS = 'pricing-models',
+ REST_PRICING_MODEL = 'pricing-models/:pricingModelID'
}
export enum ServerProtocol {

pricing - PricingRouter