Skip to content

Commit

Permalink
Merge pull request #14 from fugle-dev/add-url-param
Browse files Browse the repository at this point in the history
feat: allow url being passed in as a parameter
  • Loading branch information
bistin authored Nov 17, 2022
2 parents 5e74a46 + faea459 commit f12a156
Show file tree
Hide file tree
Showing 7 changed files with 3,682 additions and 1,197 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
uid=
password=
mobile=
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
node_modules
.env
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ npm install every8d-sms

```
const sms = require('every8d-sms');
const result1 = await sms.send(uid, password, ...);
const result1 = await sms.send(url, uid, password, ...);
console.log(result1);
const result2 = await sms.getCredit(uid, password);
const result2 = await sms.getCredit(url, uid, password);
console.log(result2);
```

Expand Down
12 changes: 6 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const rp = require('request-promise');

/**
* send sms
* @prarm {string} url - API url
* @param {string} uid - login account
* @param {string} password - login password
* @param {string} subject - message subject only for admin use
Expand All @@ -10,11 +11,10 @@ const rp = require('request-promise');
* @param {string} time - time to send msg (leave blank for immediate delivery)
* @returns {object} credit,sended numbers,cost,unsend numbers,batch id,error
*/
exports.send = async function(uid, password, subject, msg, dest, time) {
const url = 'https://api.e8d.tw/API21/HTTP/sendSMS.ashx';
exports.send = async function(url, uid, password, subject, msg, dest, time) {
try {
const result = await rp({
uri: url,
uri: url || 'https://biz3.every8d.com.tw/prepaid/API21/HTTP/sendSMS.ashx',
method: 'GET',
qs: {
UID: uid,
Expand Down Expand Up @@ -48,15 +48,15 @@ exports.send = async function(uid, password, subject, msg, dest, time) {

/**
* get credit
* @prarm {string} url - API url
* @param {string} uid - login account
* @param {string} password - login password
* @returns {object} credit,error
*/
exports.getCredit = async function(uid, password) {
const url = 'https://api.e8d.tw/API21/HTTP/getCredit.ashx';
exports.getCredit = async function(url, uid, password) {
try {
const result = await rp({
uri: url,
uri: url || 'https://biz3.every8d.com.tw/prepaid/API21/HTTP/getCredit.ashx',
method: 'GET',
qs: {
UID: uid,
Expand Down
Loading

0 comments on commit f12a156

Please sign in to comment.