Commit 13b04dfe0df64ba87c6127d2d86d1553c106e848
1 parent
3341641eb4
Exists in
master
ESLINT on command-handler.index
Showing 1 changed file with 35 additions and 56 deletions Side-by-side Diff
lib/command-handler/index.js
... | ... | @@ -31,95 +31,74 @@ const handlerTemporaryBonus = require('./temporarybonus'); |
31 | 31 | const handlerTransferBalance = require('./transferbalance'); |
32 | 32 | |
33 | 33 | function execute(msg, params, cb) { |
34 | - | |
35 | - if ( typeof msg !== 'string' || !msg.trim() ) { | |
34 | + if (typeof msg !== 'string' || !msg.trim()) { | |
36 | 35 | cb(commandError.ERR_EMPTY_MESSAGE); |
37 | 36 | return; |
38 | 37 | } |
39 | - | |
38 | + | |
40 | 39 | const tokens = commandParser.splitToken(msg); |
41 | 40 | const commandGroup = commandParser.extractCommandGroup(tokens); |
41 | + | |
42 | + // eslint-disable-next-line no-param-reassign | |
42 | 43 | params.commandGroup = commandGroup; |
43 | - logger.info('Processing message from partner', { msg, params, tokens, commandGroup }); | |
44 | + | |
45 | + logger.info('Processing message from partner', { | |
46 | + msg, params, tokens, commandGroup, | |
47 | + }); | |
44 | 48 | |
45 | 49 | if (!commandGroup || commandGroup === 'buy') { |
46 | 50 | handlerBuy(tokens, params, cb); |
47 | - } | |
48 | - else if (commandGroup === 'balance') { | |
51 | + } else if (commandGroup === 'balance') { | |
49 | 52 | handlerBalance(tokens, params, cb); |
50 | - } | |
51 | - else if (commandGroup === 'addbalance') { | |
53 | + } else if (commandGroup === 'addbalance') { | |
52 | 54 | handlerAddBalance(tokens, params, cb); |
53 | - } | |
54 | - else if (commandGroup === 'transferbalance') { | |
55 | + } else if (commandGroup === 'transferbalance') { | |
55 | 56 | handlerTransferBalance(tokens, params, cb); |
56 | - } | |
57 | - else if (commandGroup === 'price') { | |
57 | + } else if (commandGroup === 'price') { | |
58 | 58 | handlerPrice(tokens, params, cb); |
59 | - } | |
60 | - else if (commandGroup === 'listdownline') { | |
59 | + } else if (commandGroup === 'listdownline') { | |
61 | 60 | handlerListDownline(tokens, params, cb); |
62 | - } | |
63 | - else if (commandGroup === 'downlineinfo') { | |
61 | + } else if (commandGroup === 'downlineinfo') { | |
64 | 62 | handlerDownlineInfo(tokens, params, cb); |
65 | - } | |
66 | - else if (commandGroup === 'adddownline') { | |
63 | + } else if (commandGroup === 'adddownline') { | |
67 | 64 | handlerAddDownline(tokens, params, cb); |
68 | - } | |
69 | - else if (commandGroup === 'listterminal') { | |
65 | + } else if (commandGroup === 'listterminal') { | |
70 | 66 | handlerListTerminal(tokens, params, cb); |
71 | - } | |
72 | - else if (commandGroup === 'listtrx' || commandGroup === 'listtrxall') { | |
67 | + } else if (commandGroup === 'listtrx' || commandGroup === 'listtrxall') { | |
73 | 68 | handlerListTrx(tokens, params, cb); |
74 | - } | |
75 | - else if (commandGroup === 'listdeposit') { | |
69 | + } else if (commandGroup === 'listdeposit') { | |
76 | 70 | handlerListDeposit(tokens, params, cb); |
77 | - } | |
78 | - else if (commandGroup === 'addterminal') { | |
71 | + } else if (commandGroup === 'addterminal') { | |
79 | 72 | handlerAddTerminal(tokens, params, cb); |
80 | - } | |
81 | - else if (commandGroup === 'changepin') { | |
73 | + } else if (commandGroup === 'changepin') { | |
82 | 74 | handlerChangePin(tokens, params, cb); |
83 | - } | |
84 | - else if (commandGroup === 'enabledownline') { | |
75 | + } else if (commandGroup === 'enabledownline') { | |
85 | 76 | handlerEnableDownline(tokens, params, cb); |
86 | - } | |
87 | - else if (commandGroup === 'daysummary' || commandGroup === 'daysummaryall') { | |
77 | + } else if (commandGroup === 'daysummary' || commandGroup === 'daysummaryall') { | |
88 | 78 | handlerDaySummary(tokens, params, cb); |
89 | - } | |
90 | - else if (commandGroup === 'depositticket') { | |
79 | + } else if (commandGroup === 'depositticket') { | |
91 | 80 | handlerDepositTicket(tokens, params, cb); |
92 | - } | |
93 | - else if (commandGroup === 'disabledownline') { | |
81 | + } else if (commandGroup === 'disabledownline') { | |
94 | 82 | handlerDisableDownline(tokens, params, cb); |
95 | - } | |
96 | - else if (commandGroup === 'supplierbalances') { | |
83 | + } else if (commandGroup === 'supplierbalances') { | |
97 | 84 | handlerSupplierBalances(tokens, params, cb); |
98 | - } | |
99 | - else if (commandGroup === 'claimbonus') { | |
85 | + } else if (commandGroup === 'claimbonus') { | |
100 | 86 | handlerClaimBonus(tokens, params, cb); |
101 | - } | |
102 | - else if (commandGroup === 'temporarybonus') { | |
87 | + } else if (commandGroup === 'temporarybonus') { | |
103 | 88 | handlerTemporaryBonus(tokens, params, cb); |
104 | - } | |
105 | - else if (commandGroup === 'inquiry') { | |
89 | + } else if (commandGroup === 'inquiry') { | |
106 | 90 | handlerInquiry(tokens, params, cb); |
107 | - } | |
108 | - else if (commandGroup === 'pay') { | |
91 | + } else if (commandGroup === 'pay') { | |
109 | 92 | handlerPay(tokens, params, cb); |
110 | - } | |
111 | - else if (commandGroup === 'complain') { | |
93 | + } else if (commandGroup === 'complain') { | |
112 | 94 | handlerComplain(tokens, params, cb); |
113 | - } | |
114 | - else if (commandGroup === 'listcomplain') { | |
95 | + } else if (commandGroup === 'listcomplain') { | |
115 | 96 | handlerListComplain(tokens, params, cb); |
116 | - } | |
117 | - else if (commandGroup === 'help') { | |
118 | - handlerHelp(tokens, params, cb) | |
119 | - } | |
120 | - else { | |
97 | + } else if (commandGroup === 'help') { | |
98 | + handlerHelp(tokens, params, cb); | |
99 | + } else { | |
121 | 100 | cb(commandError.ERR_NOT_IMPLEMENTED); |
122 | 101 | } |
123 | 102 | } |
124 | 103 | |
125 | -module.exports = execute; | |
126 | 104 | \ No newline at end of file |
105 | +module.exports = execute; |