-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96a6a69
commit 8f116d1
Showing
22 changed files
with
317 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
const mobizon = require('../../src/index'); | ||
import mobizon from '../../src'; | ||
|
||
mobizon.setConfig({ | ||
apiServer: 'https://api.mobizon.com.br', | ||
apiKey: process.env.API_KEY, | ||
format: 'json', | ||
}); | ||
|
||
module.exports = mobizon; | ||
export default mobizon; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true});exports. default = { | ||
/** | ||
* User API key. | ||
* Each user has their key, it represents their access and allows access to API routes. | ||
*/ | ||
apiKey: '', | ||
/** | ||
* User API server depends on user initial registration site. | ||
* Correct API domain could be found in API quick start guide here: https://help.mobizon.com/help/api-docs/sms-api | ||
*/ | ||
apiServer: '', | ||
/** | ||
* API response format - possible formats see in allowedFormats | ||
*/ | ||
format: '', | ||
/** | ||
* API version. | ||
* Default: v1. | ||
*/ | ||
apiVersion: 'v1', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _environment = require('./environment'); var _environment2 = _interopRequireDefault(_environment); | ||
var _balance = require('./structures/balance'); var _balance2 = _interopRequireDefault(_balance); | ||
var _shortlink = require('./structures/shortlink'); var _shortlink2 = _interopRequireDefault(_shortlink); | ||
var _sms = require('./structures/sms'); var _sms2 = _interopRequireDefault(_sms); | ||
|
||
exports. default = { | ||
environment: _environment2.default, | ||
setConfig({ apiServer, apiKey, format }) { | ||
_environment2.default.apiKey = apiKey; | ||
_environment2.default.format = format || 'json'; | ||
_environment2.default.apiServer = apiServer; | ||
}, | ||
getBalance: () => _balance2.default.get(), | ||
getSms: (data) => _sms2.default.get(data), | ||
sendSms: (data) => _sms2.default.send(data), | ||
listSms: (data) => _sms2.default.list(data), | ||
getShort: (data) => _shortlink2.default.get(data), | ||
listShort: (data) => _shortlink2.default.list(data), | ||
createShort: (data) => _shortlink2.default.create(data), | ||
deleteShort: (data) => _shortlink2.default.delete(data), | ||
updateShort: (data) => _shortlink2.default.update(data), | ||
getStatsShort: (data) => _shortlink2.default.getstats(data), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _axios = require('axios'); | ||
var _https = require('https'); | ||
var _qs = require('qs'); | ||
|
||
var _environment = require('../environment'); var _environment2 = _interopRequireDefault(_environment); | ||
|
||
exports. default = async (provider, method, postParams, queryParams) => { | ||
const { format, apiVersion, apiKey, apiServer } = _environment2.default; | ||
|
||
const request = _axios.create.call(void 0, { | ||
baseURL: `${apiServer}/service`, | ||
headers: { | ||
'Content-Type': 'application/x-www-form-urlencoded', | ||
}, | ||
httpsAgent: new (0, _https.Agent)({ | ||
rejectUnauthorized: false, | ||
}), | ||
}); | ||
|
||
const queryDefault = _qs.stringify.call(void 0, { | ||
output: format, | ||
api: apiVersion, | ||
apiKey, | ||
}); | ||
|
||
if (postParams) { | ||
const body = _qs.stringify.call(void 0, postParams); | ||
|
||
const { data } = await request.post( | ||
`${provider}/${method}?${queryDefault}`, | ||
body | ||
); | ||
|
||
return data; | ||
} | ||
|
||
const query = queryParams | ||
? `${_qs.stringify.call(void 0, queryParams)}&${queryDefault}` | ||
: queryDefault; | ||
|
||
const { data } = await request.get(`${provider}/${method}?${query}`); | ||
|
||
return data; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _mobizon = require('../services/mobizon'); var _mobizon2 = _interopRequireDefault(_mobizon); | ||
|
||
exports. default = { | ||
get: () => _mobizon2.default.call(void 0, 'user', 'getownbalance'), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _mobizon = require('../services/mobizon'); var _mobizon2 = _interopRequireDefault(_mobizon); | ||
|
||
exports. default = { | ||
get: (body) => _mobizon2.default.call(void 0, 'link', 'get', body), | ||
list: (body) => _mobizon2.default.call(void 0, 'link', 'list', body), | ||
create: (body) => _mobizon2.default.call(void 0, 'link', 'create', body), | ||
delete: (body) => _mobizon2.default.call(void 0, 'link', 'delete', body), | ||
update: (body) => _mobizon2.default.call(void 0, 'link', 'update', body), | ||
getstats: (body) => _mobizon2.default.call(void 0, 'link', 'getstats', body), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _mobizon = require('../services/mobizon'); var _mobizon2 = _interopRequireDefault(_mobizon); | ||
|
||
exports. default = { | ||
get: (body) => _mobizon2.default.call(void 0, 'message', 'getsmsstatus', body), | ||
list: (body) => _mobizon2.default.call(void 0, 'message', 'list', body), | ||
send: (query) => _mobizon2.default.call(void 0, 'message', 'sendsmsmessage', null, query), | ||
}; |
Oops, something went wrong.