-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from miqdadyyy/improvement
Improvement
- Loading branch information
Showing
9 changed files
with
15,041 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages | ||
|
||
name: Node.js Package | ||
|
||
on: | ||
release: | ||
types: [released] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 12 | ||
- run: npm ci | ||
- run: npm test | ||
|
||
publish-npm: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 12 | ||
registry-url: https://registry.npmjs.org/ | ||
- run: npm ci | ||
- run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |
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,6 +1,5 @@ | ||
.idea/ | ||
node_modules/ | ||
test/ | ||
|
||
.env | ||
.DS_Store |
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,4 +1,9 @@ | ||
# Movider | ||
![NPM](https://img.shields.io/npm/l/movider?color=red) | ||
![npm](https://img.shields.io/npm/v/movider?color=blue) | ||
![npm](https://img.shields.io/npm/dy/movider) | ||
![GitHub Workflow Status (branch)](https://img.shields.io/github/workflow/status/miqdadyyy/movider/unit-test/master?color=green) | ||
|
||
Unofficial package for Movider SMS Service | ||
|
||
## Install | ||
|
@@ -23,35 +28,69 @@ const moviderClient = new Movider(MOVIDER_API_KEY, MOVIDER_API_SECRET); | |
// Get Balance | ||
moviderClient.getBalance() | ||
.then(balance => { | ||
console.log(balance); | ||
console.log(balance.amount); | ||
}); | ||
|
||
// Send SMS to number | ||
moviderClient.sendSMS('62888888888', 'Hello World', { | ||
from: 'MOVIDER', // Sender Name | ||
moviderClient.sendSMS('+62888888888', 'Hello World', { | ||
from: 'MOVIDER', // Sender Name ID | ||
callback: { // Callback after message sended to deliver report / data | ||
url: 'https://api.example.com/moivder-callback', | ||
url: 'https://api.example.com/movider-callback', | ||
method: 'POST' | ||
} | ||
}) | ||
``` | ||
|
||
### Usage Response | ||
Check Balance | ||
```json | ||
{ | ||
"type": "USD", | ||
"amount": 20.84 | ||
} | ||
``` | ||
### Response | ||
**Check Balance :** | ||
| Property | Description | | ||
|----------|--------------------------| | ||
| amount | To get amount of balance | | ||
| currency | Currency of balance | | ||
|
||
Send SMS | ||
```json | ||
**Send SMS :** | ||
| Property | Description | | ||
|--------------------|---------------------------------------------| | ||
| message | Your SMS Message | | ||
| balance | Remaining balance after sending SMS | | ||
| total | Get total of number | | ||
| total_price | Get total of sms usage | | ||
| sended_number_list | Get list of sended number (Array of object) | | ||
| failed_number_list | Get list of failed number (Array of object) | | ||
|
||
**Webhook Response :** | ||
``` | ||
{ | ||
"status": 200, | ||
"headers": {}, | ||
"body": { | ||
"headers": { | ||
"host": "your-webhook-url.com", | ||
"x-amzn-trace-id": "Root=1-609cbf32-4ffc63d96531b6a744c8a481", | ||
"content-length": "158", | ||
"content-type": "application/x-www-form-urlencoded", | ||
"accept-encoding": "gzip", | ||
"user-agent": "Go-http-client/2.0" | ||
}, | ||
"body": { | ||
"detail": "DELIVERIED", | ||
"message_id": "ABCDEFGHIJKLMNOP", | ||
"message_price": "0.013", | ||
"sent_date": "2021-05-13 05:52:55 +0000 UTC", | ||
"status": "OK", | ||
"to": "628123456789" | ||
}, | ||
"inferred_body_type": "FORM", | ||
"method": "POST", | ||
"url": "https://your-webhook-url.com/", | ||
"client_ip": "0.1.234.5", | ||
"query": {} | ||
} | ||
} | ||
``` | ||
|
||
## Security | ||
If you discover any security related issues, please email [email protected] instead of using the issue tracker. | ||
If you discover any security related issues, please email [email protected] or using the issue tracker. | ||
|
||
## Credits | ||
- [Miqdad Farcha](https://github.com/miqdadyyy) | ||
|
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,58 @@ | ||
const BalanceResponse = class { | ||
constructor(response) { | ||
this._amount = response.amount; | ||
this._currency = response.type; | ||
} | ||
|
||
get amount() { | ||
return this._amount; | ||
} | ||
|
||
get currency() { | ||
return this._currency; | ||
} | ||
} | ||
|
||
const SMSResponse = class { | ||
constructor(response, message) { | ||
this._message = message; | ||
this._balance = response.remaining_balance; | ||
this._total = response.total_sms; | ||
this._sended_number_list = response.phone_number_list; | ||
this._failed_number_list = response.bad_phone_number_list; | ||
} | ||
|
||
get total_price() { | ||
let totalPrice = 0; | ||
for (const number of this._sended_number_list) { | ||
totalPrice += number.price; | ||
} | ||
|
||
return totalPrice; | ||
} | ||
|
||
get message() { | ||
return this._message; | ||
} | ||
|
||
get balance() { | ||
return this._balance; | ||
} | ||
|
||
get total() { | ||
return this._total; | ||
} | ||
|
||
get sended_number_list() { | ||
return this._sended_number_list; | ||
} | ||
|
||
get failed_number_list() { | ||
return this._failed_number_list; | ||
} | ||
} | ||
|
||
module.exports = { | ||
BalanceResponse, | ||
SMSResponse | ||
} |
Oops, something went wrong.