From 96a6a693022c140ae381e210dbd8854b464043bb Mon Sep 17 00:00:00 2001 From: caioagiani Date: Tue, 16 Feb 2021 21:55:37 -0300 Subject: [PATCH] upgrade: v0.2.3 --- README.md | 32 +++++++++++++------------------- example.js | 8 ++++---- package.json | 6 ++++-- src/index.js | 2 +- src/structures/sms.js | 10 ++-------- 5 files changed, 24 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 07e5ab8..cd29231 100644 --- a/README.md +++ b/README.md @@ -50,11 +50,11 @@ Confira em [docs](https://github.com/caioagiani/mobizon-node/blob/master/docs) t console.log(getBalance); /** Encurtar URL */ - const short = await mobizon.short({ + const short = await mobizon.shortCreate({ fullLink: 'https://mobizon.com.br', status: 1, expirationDate: '', - comment: 'Mobizon', + comment: 'Shortened link.', }); console.log(short); @@ -63,7 +63,7 @@ Confira em [docs](https://github.com/caioagiani/mobizon-node/blob/master/docs) t const sendSms = await mobizon.sendSms({ recipient: process.env.NUMBER, from: '', - text: 'Mobizon', + text: 'SMS sent by Mobizon.', }); console.log(sendSms); @@ -75,24 +75,18 @@ Dê uma olhada em [example.js](https://github.com/caioagiani/mobizon-node/blob/m ## Testes ```javascript - jest --setupFiles dotenv/config --detectOpenHandles --forceExit - PASS tests/mobizon.test.js - Mobizon feature tests - ✓ should receive the account balance (323 ms) - ✓ should create short link (447 ms) - ✓ should get short link (349 ms) - ✓ should update short link (325 ms) - ✓ should delete short link (390 ms) - ✓ should send a test sms (610 ms) - ✓ should list the sms sent by id (312 ms) - ✓ should list the all sms sent (762 ms) - -Test Suites: 1 passed, 1 total -Tests: 8 passed, 8 total +yarn lint && jest --setupFiles dotenv/config --detectOpenHandles --forceExit +$ eslint . --ext .js + PASS __tests__/shortlink.test.js + PASS __tests__/sms.test.js + PASS __tests__/balance.test.js + +Test Suites: 3 passed, 3 total +Tests: 14 passed, 14 total Snapshots: 0 total -Time: 4.208 s +Time: 7.013 s Ran all test suites. -Done in 4.65s. +Done in 8.41s. ``` ## Licença diff --git a/example.js b/example.js index 94ca69f..9df4dd1 100644 --- a/example.js +++ b/example.js @@ -16,11 +16,11 @@ mobizon.setConfig({ console.log(getBalance); /** Encurtar URL */ - const short = await mobizon.short({ + const short = await mobizon.shortCreate({ fullLink: 'https://mobizon.com.br', status: 1, expirationDate: '', - comment: 'Mobizon', + comment: 'Shortened link.', }); console.log(short); @@ -36,7 +36,7 @@ mobizon.setConfig({ data: { status: 0, expirationDate: '', - comment: 'Link atualizado.', + comment: 'Updated link.', }, }); @@ -51,7 +51,7 @@ mobizon.setConfig({ const sendSms = await mobizon.sendSms({ recipient: process.env.NUMBER, from: '', - text: 'Mobizon', + text: 'SMS sent by Mobizon.', }); console.log(sendSms); diff --git a/package.json b/package.json index 4f5591c..6b681eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mobizon-node", - "version": "0.2.2", + "version": "0.2.3", "description": "Mobizon é um poderoso gateway de SMS e ferramentas de marketing online.", "readmeFilename": "README.md", "main": "src/index.js", @@ -9,6 +9,8 @@ "mobizon", "sms", "api", + "shortcode", + "url_shortener", "gateway", "messaging", "A2P" @@ -40,7 +42,7 @@ "dependencies": { "axios": "^0.21.1", "jest": "^26.6.3", - "mobizon-node": "^0.2.2" + "mobizon-node": "^0.2.3" }, "devDependencies": { "dotenv": "^8.2.0", diff --git a/src/index.js b/src/index.js index 7997fc7..bf382e7 100644 --- a/src/index.js +++ b/src/index.js @@ -13,7 +13,7 @@ module.exports = { getBalance() { return balance.get.call(this); }, - short(data) { + shortCreate(data) { return short.create.call(this, data); }, shortDelete(data) { diff --git a/src/structures/sms.js b/src/structures/sms.js index c89af77..043d9db 100644 --- a/src/structures/sms.js +++ b/src/structures/sms.js @@ -2,14 +2,8 @@ const { mobizon } = require('../services/mobizon'); const { urlEncode } = require('../utils/url'); module.exports = { - send({ recipient, from, text }) { - const query = { - recipient, - from, - text, - }; - - const queryParams = urlEncode(query); + send(query) { + const queryParams = query ? urlEncode(query) : undefined; return mobizon.call(this, 'message', 'sendsmsmessage', null, queryParams); },