Skip to content

Commit

Permalink
fix: name of variables
Browse files Browse the repository at this point in the history
  • Loading branch information
caioagiani committed Feb 16, 2021
1 parent 9bd88d4 commit 2a4d9b1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 38 deletions.
8 changes: 4 additions & 4 deletions src/services/mobizon.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const https = require('https');
const { urlEncode } = require('../utils/url');

module.exports = {
async mobizonUrl(provider, method, postParams, queryParams) {
const mobizonUrl = axios.create({
async mobizon(provider, method, postParams, queryParams) {
const request = axios.create({
baseURL: this.environment.apiServer,
headers: { 'Content-Type': 'application/json' },
httpsAgent: new https.Agent({
Expand All @@ -17,7 +17,7 @@ module.exports = {
const queryDefault = urlEncode(loadQuery);

if (postParams) {
const { data } = await mobizonUrl.post(
const { data } = await request.post(
`/service/${provider}/${method}?${queryDefault}`,
postParams
);
Expand All @@ -27,7 +27,7 @@ module.exports = {

const query = queryParams ? `${queryParams}&${queryDefault}` : queryDefault;

const { data } = await mobizonUrl.get(
const { data } = await request.get(
`/service/${provider}/${method}?${query}`
);

Expand Down
6 changes: 2 additions & 4 deletions src/structures/balance.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
const { mobizonUrl } = require('../services/mobizon');
const { mobizon } = require('../services/mobizon');

module.exports = {
get() {
const getBalance = mobizonUrl.call(this, 'user', 'getownbalance');

return getBalance;
return mobizon.call(this, 'user', 'getownbalance');
},
};
18 changes: 5 additions & 13 deletions src/structures/shortlink.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { mobizonUrl } = require('../services/mobizon');
const { mobizon } = require('../services/mobizon');

module.exports = {
create({ fullLink, expirationDate, comment }) {
Expand All @@ -11,27 +11,19 @@ module.exports = {
},
};

const shortCreate = mobizonUrl.call(this, 'link', 'create', body);

return shortCreate;
return mobizon.call(this, 'link', 'create', body);
},
delete(ids) {
const body = { ids };

const shortDelete = mobizonUrl.call(this, 'link', 'delete', body);

return shortDelete;
return mobizon.call(this, 'link', 'delete', body);
},
get(id) {
const body = { code: id };

const shortGet = mobizonUrl.call(this, 'link', 'get', body);

return shortGet;
return mobizon.call(this, 'link', 'get', body);
},
update(body) {
const shortGet = mobizonUrl.call(this, 'link', 'update', body);

return shortGet;
return mobizon.call(this, 'link', 'update', body);
},
};
20 changes: 4 additions & 16 deletions src/structures/sms.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { mobizonUrl } = require('../services/mobizon');
const { mobizon } = require('../services/mobizon');
const { urlEncode } = require('../utils/url');

module.exports = {
Expand All @@ -11,26 +11,14 @@ module.exports = {

const queryParams = urlEncode(query);

const smsSend = mobizonUrl.call(
this,
'message',
'sendsmsmessage',
null,
queryParams
);

return smsSend;
return mobizon.call(this, 'message', 'sendsmsmessage', null, queryParams);
},
list(body) {
const smsList = mobizonUrl.call(this, 'message', 'list', body);

return smsList;
return mobizon.call(this, 'message', 'list', body);
},
get(ids) {
const body = { ids };

const smsGet = mobizonUrl.call(this, 'message', 'getsmsstatus', body);

return smsGet;
return mobizon.call(this, 'message', 'getsmsstatus', body);
},
};
2 changes: 1 addition & 1 deletion src/utils/url.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
urlEncode(query) {
const queryEncode = Object.keys(query)
.map((k) => `${encodeURIComponent(k)}=${encodeURIComponent(query[k])}`)
.map((key) => `${key}=${query[key]}`)
.join('&');

return queryEncode;
Expand Down

0 comments on commit 2a4d9b1

Please sign in to comment.