Blame view

lib/report/postpaid.js 578 Bytes
92940f844   Adhidarma Hadiwinoto   Postpaid ready to...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  const MODULE_NAME = 'REPORT.POSTPAID';
  
  const stringify = require('json-stringify-pretty-compact');
  
  const logger = require('komodo-sdk/logger');
  const postpaidSdk = require('komodo-sdk-postpaid');
  
  module.exports = (xid, data) => {
      if (!data) return;
  
      logger.verbose(`${MODULE_NAME} 0682477A: Reporting to CORE`, {
          xid,
          data,
      });
  
      const reportData = JSON.parse(JSON.stringify(data));
      if (typeof reportData.message !== 'string') {
          reportData.message = stringify(reportData.message);
      }
  
      postpaidSdk.report(reportData, xid);
  };