UNPKG

@ima/plugin-http-client

Version:

Generic http client for the IMA application framework.

38 lines (37 loc) 1.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "EntityProcessor", { enumerable: true, get: function() { return EntityProcessor; } }); const _AbstractProcessor = require("../../AbstractProcessor"); class EntityProcessor extends _AbstractProcessor.AbstractProcessor { postRequest(params) { const { response, additionalParams } = params; if (response) { const { body } = response; const entityClass = additionalParams?.resource?.entityClass; if (body && entityClass) { let newBody; if (body instanceof Array) { newBody = body.map((entityData)=>Reflect.construct(entityClass, [ entityData ])); } else { newBody = Reflect.construct(entityClass, [ body ]); } params.response = Object.assign({}, response, { body: newBody }); } } return params; } } //# sourceMappingURL=EntityProcessor.js.map