smsir_mh_js
Advanced tools
Comparing version 1.0.2 to 1.0.4
{ | ||
"name": "smsir_mh_js", | ||
"version": "1.0.2", | ||
"description": "This package is for using SMS service from sms.ir should get API and templetId from sms.ir ", | ||
"version": "1.0.4", | ||
"description": "This package is for using SMS service from sms.ir should get API and templetId from sms.ir javaScript,ES6 support ", | ||
"main": "smsir_mh_js.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "jest" | ||
}, | ||
@@ -22,3 +22,6 @@ "repository": { | ||
"axios": "^1.7.2" | ||
}, | ||
"devDependencies": { | ||
"jest": "^29.7.0" | ||
} | ||
} |
@@ -6,4 +6,19 @@ # smsir_mh_js | ||
## Test Resalt | ||
npm test | ||
PASS ./SendAlertSMSIR.spec.js | ||
SendAlertSMSIR | ||
√ should send a POST request with correct data (5 ms) | ||
√ should log an error if the request fails | ||
Test Suites: 1 passed, 1 total | ||
Tests: 2 passed, 2 total | ||
Snapshots: 0 total | ||
Time: 0.78 s | ||
Ran all test suites. | ||
## Author | ||
Mohammad Hadi | ||
@@ -15,2 +30,4 @@ Email: mmm.6336@gmail.com | ||
## Installation | ||
for install last vertion | ||
`npm install smsir_mh_js@latest` | ||
@@ -25,2 +42,3 @@ To install the package, run: | ||
#yarn | ||
@@ -31,2 +49,3 @@ yarn add axios | ||
# Example use: | ||
@@ -33,0 +52,0 @@ |
const axios = require('axios'); | ||
const SendAlertSMSIR = (to, message, api_key, templateId) => { | ||
const SendAlertSMSIR = async (to, message, api_key, templateId) => { | ||
const data = JSON.stringify({ | ||
@@ -23,9 +23,8 @@ "mobile": to, | ||
axios(config) | ||
.then(response => { | ||
console.info(JSON.stringify(response.data)); | ||
}) | ||
.catch(error => { | ||
console.error(error); | ||
}); | ||
try { | ||
const response = await axios(config); | ||
console.info(JSON.stringify(response.data)); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}; | ||
@@ -32,0 +31,0 @@ |
const { SendAlertSMSIR } = require('./smsir_mh_js'); | ||
const apiKey = '1212121212121212121'; //Example API Key get from sms.ir | ||
const apiKey = '121212121212121212121'; //Example API Key | ||
const to = '09100059323'; //Example Phone Number | ||
@@ -5,0 +5,0 @@ const message = 'Hello,this test message!'; //Max 24 Character Length |
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
4597
5
83
1
59
1