UNPKG

@ima/plugin-http-client

Version:

Generic http client for the IMA application framework.

56 lines (55 loc) 1.5 kB
/** * Mapper is used to deserialize single value from an API to an entity value * and to serialize property from an entity to a plain value. */ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "BaseMapper", { enumerable: true, get: function() { return BaseMapper; } }); class BaseMapper { /** * Static method createMapperItem converts the disparate definitions in DataFieldValue into a general MapperItem structure. * * @param value * @param key */ static createMapperItem(value, key) { let mapperItem = { mapper: new BaseMapper(), newKey: key }; if (typeof value === 'string') { mapperItem = { mapper: new BaseMapper(), newKey: value }; } else if (value instanceof BaseMapper) { mapperItem = { mapper: value, newKey: key }; } else if ('mapper' in value && 'newKey' in value) { mapperItem = value; } return mapperItem; } /** * Deserialize method is used to convert plain value from API to entity property. * * @param value */ deserialize(value) { return value; } /** * Serialize method is used to convert entity property to plain value. * * @param value */ serialize(value) { return value; } } //# sourceMappingURL=BaseMapper.js.map