Commit 0a21f5dfb2968af18d29449011e6802455b93282
1 parent
49ca8506b0
Exists in
master
Router USSD parameter include cusd2
Showing 1 changed file with 2 additions and 1 deletions Inline Diff
lib/http-command-server/router-ussd.js
1 | 'use strict'; | 1 | 'use strict'; |
2 | 2 | ||
3 | const express = require('express'); | 3 | const express = require('express'); |
4 | 4 | ||
5 | const modem = require('../modem'); | 5 | const modem = require('../modem'); |
6 | 6 | ||
7 | const router = express.Router(); | 7 | const router = express.Router(); |
8 | module.exports = router; | 8 | module.exports = router; |
9 | 9 | ||
10 | 10 | ||
11 | async function handlerIndex(req, res) { | 11 | async function handlerIndex(req, res) { |
12 | if (!req.query || !req.query.code || typeof req.query.code !== 'string') { | 12 | if (!req.query || !req.query.code || typeof req.query.code !== 'string') { |
13 | res.json({ | 13 | res.json({ |
14 | status: 'NOT-OK', | 14 | status: 'NOT-OK', |
15 | error: 'INVALID-PARAMETER', | 15 | error: 'INVALID-PARAMETER', |
16 | message: 'Undefined parameter: code', | 16 | message: 'Undefined parameter: code', |
17 | }); | 17 | }); |
18 | 18 | ||
19 | return; | 19 | return; |
20 | } | 20 | } |
21 | 21 | ||
22 | const reply = await modem.executeUSSD(req.query.code); | 22 | const reply = await modem.executeUSSD(req.query.code, req.query.include_cusd2); |
23 | res.json({ | 23 | res.json({ |
24 | status: 'OK', | 24 | status: 'OK', |
25 | error: false, | 25 | error: false, |
26 | code: req.query.code, | 26 | code: req.query.code, |
27 | include_cusd2: req.query.include_cusd2, | ||
27 | result: reply, | 28 | result: reply, |
28 | message: 'USSD executed', | 29 | message: 'USSD executed', |
29 | }); | 30 | }); |
30 | } | 31 | } |
31 | 32 | ||
32 | router.get('/', handlerIndex); | 33 | router.get('/', handlerIndex); |
33 | 34 |