Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-melipayamak

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-melipayamak

MeliPayamak Express Rest API

  • 1.0.9
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

AccessControl.js

GitHub tag (latest by date) GitHub GitHub contributors

melipayamak

This is a lib to handle sending sms from melipayamak

Installing

Using npm:

$ npm install node-melipayamak

Using yarn:

$ yarn add node-melipayamak

Building the package:

$ npm run tsc

Example js

const MeliPayamak = require('node-melipayamak');
const sms = new MeliPayamak(process.env.SMS_TOKEN);

Example typescript

import { MeliPayamak } from 'node-melipayamak';
const sms = new MeliPayamak(process.env.SMS_TOKEN);

Sending simple sms

let from = '5000****';
let to   = '0912*******';
let text = 'a test message';

sms.sendSimple({from, to, text}).then(res => {
  let { recId, status } = res;
  console.log(recId, status);
}).catch(error => {
  console.log(error);
});

output example:

{
  "recId": "3741437414",
  "status": "error message if occurred"
}

Sending advance sms

let from = '5000****';
let to   = ['0912*******', '0917******', ...];
let text = 'a test message';
let udh  = '';

sms.sendAdvance({from, to, text, udh}).then(res => {
  let { recIds, status } = res;
  console.log(recIds, status);
}).catch(error => {
  console.log(error);
});

output example:

{
  "recIds": ["3741437414", "3741437415"],
  "status": "error message if occurred"
}

Sending shared sms

(You should create a message template in the site first ex: 'Dear {0}, your registration code is {1}')

let to   = '0912*******';
let bodyId = 254;
let args = ['Mr Smith', '1911'];

sms.sendShared({to, bodyId, args}).then(res => {
  let { recId, status } = res;
  console.log(recIds, status);
}).catch(error => {
  console.log(error);
});

output example:

{
  "recId": "3741437414",
  "status": "error message if occurred"
}

Sending with domain sms

let from   = '5000****';
let to     = '0912*******';
let text   = 'a test message';
let domain = 'www.some-domain.com';

sms.sendWithDomain({from, to, text, domain}).then(res => {
  let { recId, status } = res;
  console.log(recIds, status);
}).catch(error => {
  console.log(error);
});

output example:

{
  "recId": "3741437414",
  "status": "error message if occurred"
}

Getting sms status with its refId

let recIds   = ['3741437414', '3741437415'];

sms.checkStatus({recIds}).then(res => {
  let { results, resultsAsCode,  status} = res;
  console.log(results, resultsAsCode,  status);
}).catch(error => {
  console.log(error);
});

output example:

{
  "results": ['ارسال شده' ,'ارسال نشده'],
  "resultsAsCode": [-1, 200],
  "status": "error message if occurred"
}

Getting messages from server

let type   = 'in';
let number = '5000****';
let index  = 0;
let count  = 100;

sms.receiveMessages({type, number, index, count}).then(res => {
  let { messages,  status} = res;
  console.log(messages,  status);
}).catch(error => {
  console.log(error);
});

output example:

{
  "messages": [{
    "msgID": 1075415042,
    "userID": 0,
    "linkID": 0,
    "numberID": 0,
    "tariff": 0,
    "msgType": 0,
    "body": "A test message",
    "udh": "",
    "sendDate": "2021-07-01T21:06:59.767",
    "sender": "917*******",
    "receiver": "5000****",
    "firstLocation": 1,
    "currentLocation": 1,
    "parts": 1,
    "isFlash": false,
    "isRead": false,
    "isUnicode": true,
    "credit": 0,
    "module": 0,
    "recCount": 1,
    "recFailed": 0,
    "recSuccess": 0,
    "isMoneyBack": false,
    "userStepedMaster": 0,
    "userMaster": 0,
    "moneyBackCount": 0,
    "moneyBackLevel": 0,
    "autoSpeechText": null,
    "shareServiceBodyID": null,
    "irancellBackCount": null
  }, ...],
  "status": "error message if occurred"
}

Getting messages count from server

let isRead   = true;

sms.countMessages({isRead}).then(res => {
  let { count,  status} = res;
  console.log(count,  status);
}).catch(error => {
  console.log(error);
});

output example:

{
  "count": 274,
  "status": "error message if occurred"
}

Getting account remaining credit from server

sms.getCredit().then(res => {
  let { amount,  status} = res;
  console.log(amount,  status);
}).catch(error => {
  console.log(error);
});

output example:

{
  "amount": 37414,
  "status": "error message if occurred"
}

Getting price for sending messages from server

let mtnCount   = 10;
let irancellCount = 20;
let from = '5000****';
let text   = 'a test message';

sms.getPrice({mtnCount, irancellCount, from, text}).then(res => {
  let { price,  status} = res;
  console.log(price,  status);
}).catch(error => {
  console.log(error);
});

output example:

{
  "price": 15000,
  "status": "error message if occurred"
}

API Documentation

https://console.melipayamak.com/send/simple

Support Me

Keywords

FAQs

Package last updated on 02 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc