prepaid.js 560 Bytes
const MODULE_NAME = 'REPORT.PREPAID';

const stringify = require('json-stringify-pretty-compact');

const pull = require('komodo-sdk/gateway/pull');
const logger = require('tektrans-logger');

module.exports = (xid, data) => {
    if (!data) return;

    logger.verbose(`${MODULE_NAME} 0FCACC40: Reporting to CORE`, {
        xid,
        data,
    });

    const reportData = JSON.parse(JSON.stringify(data));
    if (typeof reportData.message !== 'string') {
        reportData.message = stringify(reportData.message);
    }

    pull.report(reportData);
};