"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.payloadTransform = exports.flattenObj = exports.isPlainObj = void 0;
const isPlainObj = (o) => Boolean(o &&
    o.constructor &&
    o.constructor.prototype &&
    Object.prototype.hasOwnProperty.call(o.constructor.prototype, 'isPrototypeOf'));
exports.isPlainObj = isPlainObj;
const flattenObj = (obj, keys = []) => {
    return Object.keys(obj).reduce((acc, key) => {
        return Object.assign(acc, (0, exports.isPlainObj)(obj[key]) ? (0, exports.flattenObj)(obj[key], keys.concat(key)) : { [keys.concat(key).join('.')]: obj[key] });
    }, {});
};
exports.flattenObj = flattenObj;
const payloadTransform = (payload) => {
    if (payload.attributes && Object.keys(payload.attributes).length > 0) {
        payload.attributes = (0, exports.flattenObj)(payload.attributes);
    }
    return payload;
};
exports.payloadTransform = payloadTransform;
//# sourceMappingURL=utils.js.map