|
1 |
| -require('dotenv').config({ path: __dirname + '/../.env' }) |
| 1 | +require('dotenv').config({ path: __dirname + '/../.env' }); |
2 | 2 |
|
3 |
| -const NEXMO_API_KEY = process.env.NEXMO_API_KEY |
4 |
| -const NEXMO_API_SECRET = process.env.NEXMO_API_SECRET |
5 |
| -const NEXMO_NUMBER = process.env.NEXMO_NUMBER |
6 |
| -const COUNTRY_CODE = process.env.COUNTRY_CODE |
7 |
| -const SMS_CALLBACK_URL = process.env.SMS_CALLBACK_URL |
8 |
| -const MESSAGES_APPLICATION_ID = process.env.MESSAGES_APPLICATION_ID |
9 |
| -const VOICE_CALLBACK_TYPE = process.env.VOICE_CALLBACK_TYPE |
10 |
| -const VOICE_CALLBACK_VALUE = process.env.VOICE_CALLBACK_VALUE |
11 |
| -const VOICE_STATUS_URL = process.env.VOICE_STATUS_URL |
| 3 | +const NEXMO_API_KEY = process.env.NEXMO_API_KEY; |
| 4 | +const NEXMO_API_SECRET = process.env.NEXMO_API_SECRET; |
| 5 | +const NEXMO_NUMBER = process.env.NEXMO_NUMBER; |
| 6 | +const COUNTRY_CODE = process.env.COUNTRY_CODE; |
| 7 | +const SMS_CALLBACK_URL = process.env.SMS_CALLBACK_URL; |
| 8 | +const NEXMO_APPLICATION_ID = process.env.NEXMO_APPLICATION_ID; |
| 9 | +const VOICE_CALLBACK_TYPE = process.env.VOICE_CALLBACK_TYPE; |
| 10 | +const VOICE_CALLBACK_VALUE = process.env.VOICE_CALLBACK_VALUE; |
| 11 | +const VOICE_STATUS_URL = process.env.VOICE_STATUS_URL; |
12 | 12 |
|
13 |
| -const Nexmo = require('nexmo') |
| 13 | +const Nexmo = require('nexmo'); |
14 | 14 |
|
15 | 15 | const nexmo = new Nexmo(
|
16 |
| - { |
17 |
| - apiKey: NEXMO_API_KEY, |
18 |
| - apiSecret: NEXMO_API_SECRET |
19 |
| - }, |
20 |
| - { |
21 |
| - debug: true |
22 |
| - } |
23 |
| -) |
| 16 | + { |
| 17 | + apiKey: NEXMO_API_KEY, |
| 18 | + apiSecret: NEXMO_API_SECRET, |
| 19 | + }, |
| 20 | + { |
| 21 | + debug: true, |
| 22 | + } |
| 23 | +); |
24 | 24 |
|
25 | 25 | nexmo.number.update(
|
26 |
| - COUNTRY_CODE, |
27 |
| - NEXMO_NUMBER, |
28 |
| - { |
29 |
| - messagesCallbackType: 'app', |
30 |
| - messagesCallbackValue: MESSAGES_APPLICATION_ID, |
31 |
| - voiceCallbackType: VOICE_CALLBACK_TYPE, |
32 |
| - voiceCallbackValue: VOICE_CALLBACK_VALUE, |
33 |
| - voiceStatusCallback: VOICE_STATUS_URL, |
34 |
| - moHttpUrl: SMS_CALLBACK_URL |
35 |
| - }, |
36 |
| - (err, res) => { |
37 |
| - if (err) { |
38 |
| - console.error(err) |
39 |
| - } |
40 |
| - else { |
41 |
| - console.log(JSON.stringify(res, null, 2)) |
42 |
| - } |
43 |
| - } |
44 |
| -) |
| 26 | + COUNTRY_CODE, |
| 27 | + NEXMO_NUMBER, |
| 28 | + { |
| 29 | + messagesCallbackType: 'app', |
| 30 | + messagesCallbackValue: NEXMO_APPLICATION_ID, |
| 31 | + voiceCallbackType: VOICE_CALLBACK_TYPE, |
| 32 | + voiceCallbackValue: VOICE_CALLBACK_VALUE, |
| 33 | + voiceStatusCallback: VOICE_STATUS_URL, |
| 34 | + moHttpUrl: SMS_CALLBACK_URL, |
| 35 | + }, |
| 36 | + (err, res) => { |
| 37 | + if (err) { |
| 38 | + console.error(err); |
| 39 | + } else { |
| 40 | + console.log(JSON.stringify(res, null, 2)); |
| 41 | + } |
| 42 | + } |
| 43 | +); |
0 commit comments