refactor(subaccounts): public activation endpoint
MODIFY
src/server/rest/v1/router/api/BillingRouter.ts
src/server/rest/v1/router/api/BillingRouter.ts
@@ -44,7 +44,6 @@ export default class BillingRouter {
// ROUTES for SUB-ACCOUNTS
// -----------------------------------
this.buildRouteBillingCreateSubAccount();
- this.buildRouteBillingActivateSubAccount();
return this.router;
}
@@ -149,12 +148,4 @@ export default class BillingRouter {
void RouterUtils.handleRestServerAction(BillingService.handleCreateSubAccount.bind(this), ServerAction.BILLING_SUB_ACCOUNT_CREATE, req, res, next);
});
}
-
-
- private buildRouteBillingActivateSubAccount(): void {
- this.router.patch(`/${RESTServerRoute.REST_BILLING_ACTIVATE_SUB_ACCOUNT}`, (req: Request, res: Response, next: NextFunction) => {
- req.params.subAccountID = req.params.id;
- void RouterUtils.handleRestServerAction(BillingService.handleActivateSubAccount.bind(this), ServerAction.BILLING_SUB_ACCOUNT_ACTIVATE, req, res, next);
- });
- }
}

MODIFY
src/server/rest/v1/router/util/UtilRouter.ts
src/server/rest/v1/router/util/UtilRouter.ts
@@ -2,6 +2,7 @@ import { RESTServerRoute, ServerAction } from '../../../../../types/Server';
import express, { NextFunction, Request, Response } from 'express';
import AssetService from '../../service/AssetService';
+import BillingService from '../../service/BillingService';
import CarService from '../../service/CarService';
import ChargingStationService from '../../service/ChargingStationService';
import CompanyService from '../../service/CompanyService';
@@ -27,6 +28,7 @@ export default class UtilRouter {
this.buildRouteChargingStationDownloadFirmware();
this.buildRouteGetSiteImage();
this.buildRouteGetTenantLogo();
+ this.buildRouteBillingActivateSubAccount();
return this.router;
}
@@ -84,4 +86,11 @@ export default class UtilRouter {
void RouterUtils.handleRestServerAction(SiteService.handleGetSiteImage.bind(this), ServerAction.SITE_IMAGE, req, res, next);
});
}
+
+ private buildRouteBillingActivateSubAccount(): void {
+ this.router.patch(`/${RESTServerRoute.REST_BILLING_SUB_ACCOUNT_ACTIVATE}`, (req: Request, res: Response, next: NextFunction) => {
+ req.params.ID = req.params.id;
+ void RouterUtils.handleRestServerAction(BillingService.handleActivateSubAccount.bind(this), ServerAction.BILLING_SUB_ACCOUNT_ACTIVATE, req, res, next);
+ });
+ }
}

MODIFY
src/types/Authorization.ts
src/types/Authorization.ts
@@ -135,6 +135,7 @@ export enum Action {
BILLING_DELETE_PAYMENT_METHOD = 'BillingDeletePaymentMethod',
BILLING_CHARGE_INVOICE = 'BillingChargeInvoice',
BILLING_CREATE_SUB_ACCOUNT = 'BillingCreateSubAccount',
+ BILLING_ACTIVATE_SUB_ACCOUNT = 'BillingActivateSubAccount',
CHECK_CONNECTION = 'CheckConnection',
CLEAR_BILLING_TEST_DATA = 'ClearBillingTestData',
RETRIEVE_CONSUMPTION = 'RetrieveConsumption',

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -682,7 +682,7 @@ export enum RESTServerRoute {
REST_BILLING_TAXES = 'billing/taxes',
REST_BILLING_SUB_ACCOUNTS = 'billing/sub-accounts',
- REST_BILLING_ACTIVATE_SUB_ACCOUNT = 'billing/sub-accounts/:id/activate',
+ REST_BILLING_SUB_ACCOUNT_ACTIVATE = 'billing/sub-accounts/:id/activate',
// BILLING URLs for CRUD operations on INVOICES
REST_BILLING_INVOICES = 'invoices',

MODIFY
test/api/client/BillingApi.ts
test/api/client/BillingApi.ts
@@ -57,6 +57,6 @@ export default class BillingApi extends CrudApi {
}
public async activateSubAccount(params) {
- return super.patch(params, super.buildRestEndpointUrl(RESTServerRoute.REST_BILLING_ACTIVATE_SUB_ACCOUNT, { id: params.accountID }));
+ return super.patch(params, super.buildRestEndpointUrl(RESTServerRoute.REST_BILLING_SUB_ACCOUNT_ACTIVATE, { id: params.accountID }));
}
}

refactor(subaccounts): public activation endpoint