-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
48 lines (44 loc) · 1.14 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//// Core modules
//// External modules
const axios = require('axios');
//// Modules
const Auth = require('./service/Auth');
const Settings = require('./service/Settings');
const SMS = require('./service/SMS');
const TwoFA = require('./service/TwoFA');
/**
* Checking the service status
*
* @example
* let infobip = require('node-infobip');
* let status = await infobip.status();
* console.log(status);
*
* @param {string} contentType The type of data the API returns. Values: "json" or "xml"
* @param {string} baseUrl Infobip personal base URL
*
* @returns {string} String in JSON or XML
*/
async function status(contentType = 'json', baseUrl = 'https://api.infobip.com') {
try {
let accept = 'application/json'
if (contentType === 'xml') {
accept = 'application/xml'
}
let response = await axios.get(`${baseUrl}/status`, {
headers: {
'Accept': accept
}
});
return response.data;
} catch (err) {
throw trimError(err)
}
}
module.exports = {
status: status,
Auth: Auth,
Settings: Settings,
SMS: SMS,
TwoFA: TwoFA
}