Added billing delete payment method doc + schema
MODIFY
src/assets/server/rest/v1/docs/e-mobility-oas.json
src/assets/server/rest/v1/docs/e-mobility-oas.json
}
}
},
+ "/api/users/{id}/payment-methods/{paymentMethodID}": {
+ "get": {
+ "security": [
+ {
+ "bearerAuth": []
+ }
+ ],
+ "description": "Delete user's payment methods",
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/userID"
+ },
+ {
+ "in": "path",
+ "name": "paymentMethodID",
+ "description": "Payment Method ID",
+ "required": true,
+ "schema": {
+ "type": "string"
+ }
+ }
+ ],
+ "tags": [
+ "Billing"
+ ],
+ "responses": {
+ "200": {
+ "description": "Delete user payment methods",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/BillingOperationResult"
+ }
+ }
+ }
+ },
+ "401": {
+ "$ref": "#/components/responses/UnauthorizedError"
+ },
+ "403": {
+ "$ref": "#/components/responses/ForbiddenError"
+ },
+ "500": {
+ "$ref": "#/components/responses/BackendError"
+ },
+ "550": {
+ "$ref": "#/components/responses/ResourceDoesNotExists"
+ }
+ }
+ }
+ },
"/api/tags": {
"get": {
"security": [
"type": "boolean"
}
}
+ },
+ "BillingOperationResult": {
+ "type": "object",
+ "required": [
+ "succeeded"
+ ],
+ "properties": {
+ "succeeded": {
+ "type": "boolean"
+ },
+ "error": {
+ "type": "object"
+ },
+ "internalData": {
+ "type": "object"
+ }
+ }
}
},
"parameters": {

ADD
src/assets/server/rest/v1/schemas/billing/billing-delete-payment-method.json
+{
+ "$id": "billing-delete-payment-method",
+ "title": "Dele user payment method Request",
+ "type": "object",
+ "properties": {
+ "userID": {
+ "$ref": "common#/definitions/id"
+ },
+ "paymentMethodId": {
+ "$ref": "common#/definitions/id"
+ }
+ },
+ "required": [
+ "userID",
+ "paymentMethodId"
+ ]
+}

MODIFY
src/server/rest/v1/service/BillingService.ts
src/server/rest/v1/service/BillingService.ts
@@ -573,7 +573,7 @@ export default class BillingService {
public static async handleBillingDeletePaymentMethod(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
// Filter
- const filteredRequest = BillingSecurity.filterDeletePaymentMethodRequest(req.body);
+ const filteredRequest = BillingValidator.getInstance().validateBillingDeleteUserPaymentMethodReq(req.body);
// Check if component is active
UtilsService.assertComponentIsActiveFromToken(req.user, TenantComponents.BILLING,
Action.BILLING_PAYMENT_METHODS, Entity.BILLING, MODULE_NAME, 'handleBillingDeletePaymentMethod');

MODIFY
src/server/rest/v1/validator/BillingValidator.ts
src/server/rest/v1/validator/BillingValidator.ts
+import { HttpDeletePaymentMethod, HttpPaymentMethods } from '../../../../types/requests/HttpBillingRequest';
+
import { BillingSettings } from '../../../../types/Setting';
-import { HttpPaymentMethods } from '../../../../types/requests/HttpBillingRequest';
import Schema from '../../../../types/validator/Schema';
import SchemaValidator from '../../../../validator/SchemaValidator';
import fs from 'fs';
@@ -9,11 +10,13 @@ export default class BillingValidator extends SchemaValidator {
private static instance: BillingValidator|null = null;
private billingSettingUpdate: Schema;
private billingGetUserPaymentMethods: Schema;
+ private billingDeleteUserPaymentMethod: Schema;
private constructor() {
super('BillingValidator');
this.billingSettingUpdate = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/billing/billing-setting-update.json`, 'utf8'));
this.billingGetUserPaymentMethods = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/billing/billing-payment-methods-get.json`, 'utf8'));
+ this.billingDeleteUserPaymentMethod = JSON.parse(fs.readFileSync(`${global.appRoot}/assets/server/rest/v1/schemas/billing/billing-delete-payment-method.json`, 'utf8'));
}
public static getInstance(): BillingValidator {
@@ -30,4 +33,8 @@ export default class BillingValidator extends SchemaValidator {
public validateBillingGetUserPaymentMethodsReq(data: Record<string, unknown>): HttpPaymentMethods {
return this.validate(this.billingGetUserPaymentMethods, data);
}
+
+ public validateBillingDeleteUserPaymentMethodReq(data: Record<string, unknown>): HttpDeletePaymentMethod {
+ return this.validate(this.billingDeleteUserPaymentMethod, data);
+ }
}

Added billing delete payment method doc + schema