npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-melipayamak

v1.0.9

Published

MeliPayamak Express Rest API

Downloads

9

Readme

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