Commit b8045ff60323ca1a291018b30af75ceea37b28e1

Authored by Adhidarma Hadiwinoto
1 parent c2f5e94fb1
Exists in master

pull report parameter use object

Showing 1 changed file with 10 additions and 10 deletions Side-by-side Diff

... ... @@ -70,20 +70,20 @@ function forwardCoreTaskToPartner(coreMessage) {
70 70 partner.buy(task);
71 71 }
72 72  
73   -function report(trx_id, rc, message, sn) {
  73 +//function report(trx_id, rc, message, sn) {
  74 +function report(data) {
74 75 let options = {
75 76 url: config.pull_url.report.replace('<CORE_APIKEY>', config.core_apikey),
76 77 qs: {
77   - trx_id: trx_id,
78   - rc: rc,
79   - message: message,
80   - handler: config.handler_name
  78 + trx_id: data.trx_id,
  79 + rc: data.rc,
  80 + message: data.message,
  81 + handler: config.handler_name,
  82 + sn: data.sn,
  83 + supplier_price: data.supplier_price
81 84 }
82 85 }
83 86  
84   - if (sn) {
85   - options.qs.sn = sn;
86   - }
87 87  
88 88 request(options, function(error, response, body) {
89 89 if (error) {
... ... @@ -98,13 +98,13 @@ function report(trx_id, rc, message, sn) {
98 98 });
99 99 }
100 100  
101   -function resendReport(trx_id, rc, message, sn) {
  101 +function resendReport(data) {
102 102 let sleepBeforeResend = 1000;
103 103 logger.verbose('Resend report to CORE in ' + sleepBeforeResend + 'ms')
104 104  
105 105 setTimeout(
106 106 function() {
107   - report(trx_id, rc, message, sn);
  107 + report(data);
108 108 },
109 109 sleepBeforeResend
110 110 )