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

ghasedaksms

v1.0.0

Published

Node.js package for interacting with Ghasedak SMS API

Downloads

11

Readme

Ghasedak SMS Node.js Package

Node.js package for interacting with the Ghasedak SMS API.

Installation

Install the package using npm:

npm install ghasedaksms

Usage

Import and Initialize

const Ghasedak = require('ghasedaksms');

// Replace with your actual API key
const apiKey = 'b7ee4xxxxxxxxxxxxxxxxxxxxxx'; 
const receptor = '09xxxxxxxxx';
const line = '123xxxxxx';

// Create an instance of the Ghasedak class
let ghasedak = new Ghasedak(apiKey);

Example Usage

Below are some examples of how to use the Ghasedak API:

Get Account Information

async function getAccountInformation() {
  const accountInfoResponse = await ghasedak.getAccountInformation();
  console.log('Get Account Information');
  console.log('Output:', accountInfoResponse);
}

Check SMS Status

async function checkSmsStatus() {
  const smsStatusQuery = { type: 1, ids: ['2366799', '2366805'] }; // Replace with valid query parameters
  const smsStatusResponse = await ghasedak.checkSmsStatus(smsStatusQuery);
  console.log('Check SMS Status');
  console.log('Input:', smsStatusQuery);
  console.log('Output:', smsStatusResponse);
}

Get Received SMSes

async function getReceivedSmses() {
  const receivedSmsQuery = { line_number: line, is_read: true }; // Replace with valid query parameters
  const receivedSmsResponse = await ghasedak.getReceivedSmses(receivedSmsQuery);
  console.log('Get Received SMSes');
  console.log('Input:', receivedSmsQuery);
  console.log('Output:', receivedSmsResponse);
}

Get Received SMSes with Paging

async function getReceivedSmsesPaging() {
  const receivedSmsPagingQuery = { line_number: line, is_read: true, page_size: 10, page_number: 1 }; // Replace with valid query parameters
  const receivedSmsPagingResponse = await ghasedak.getReceivedSmsesPaging(receivedSmsPagingQuery);
  console.log('Get Received SMSes Paging');
  console.log('Input:', receivedSmsPagingQuery);
  console.log('Output:', receivedSmsPagingResponse);
}

Get OTP Template Parameters

async function getOtpTemplateParameters() {
  const templateName = 'newOTP'; // Replace with the desired template name
  const otpTemplateResponse = await ghasedak.getOtpTemplateParameters(templateName);
  console.log('Get OTP Template Parameters');
  console.log('Input:', templateName);
  console.log('Output:', otpTemplateResponse);
}

Send Simple SMS

async function sendSimpleSms() {
  const simpleSmsCommand = { 
    sendDate: "2024-07-09T18:45:09.902Z",
    message: 'Test message',
    receptor: receptor,
    linenumber: line,
    clientReferenceId: "strsisdsdsng",
    udh: false
  }; // Replace with valid command parameters
  const simpleSmsResponse = await ghasedak.sendSimpleSms(simpleSmsCommand);
  console.log('Send Simple SMS');
  console.log('Input:', simpleSmsCommand);
  console.log('Output:', simpleSmsResponse);
}

Send Bulk SMS

async function sendBulkSms() {
  const bulkSmsCommand = {
    message: 'Bulk message',
    receptors: [receptor, '09xxxxxxxxx'],
    linenumber: line
  }; // Replace with valid command parameters
  const bulkSmsResponse = await ghasedak.sendBulkSms(bulkSmsCommand);
  console.log('Send Bulk SMS');
  console.log('Input:', bulkSmsCommand);
  console.log('Output:', bulkSmsResponse);
}

Send Pair to Pair SMS

async function sendPairToPairSms() {
  const pairToPairSmsCommand = {
    items: [
      {
        lineNumber: line,
        receptor: receptor,
        message: 'Pair to pair message',
        clientReferenceId: 'your_unique_reference_id',
        sendDate: '2024-07-09T19:29:59.279Z'
      }
    ],
    udh: true
  };
  
  try {
    const pairToPairSmsResponse = await ghasedak.sendPairToPairSms(pairToPairSmsCommand);
    console.log('Send Pair to Pair SMS');
    console.log('Input:', pairToPairSmsCommand);
    console.log('Output:', pairToPairSmsResponse);
  } catch (error) {
    console.error('Error sending SMS:', error.message);
  }
}

Send OTP SMS (old)

async function sendOtpSmsOld() {
  const otpSmsNewCommand = {
    // sendDate: '2024-07-09T19:49:44.539Z',  // Replace with actual send date
    receptors: [
      {
        mobile: receptor,  // Assuming 'receptor' holds the mobile number
        clientReferenceId: 'strsdsding'  // Replace 'string' with actual client reference ID
      }
    ],
    templateName: 'oldOTP',  // Replace with actual template name
    param1: 'string',  // Replace 'string' with actual parameter values
    param2: 'string',
    // param3: 'string',
    // param4: 'string',
    // param5: 'string',
    // param6: 'string',
    // param7: 'string',
    // param8: 'string',
    // param9: 'string',
    // param10: 'string',
    isVoice: false,  // Specify if it's a voice message (if applicable)
    udh: false
  };
  
  try {
    const otpSmsNewResponse = await ghasedak.sendOtpSmsOld(otpSmsNewCommand);  // Adjust function name as per your API
    console.log('Send OTP SMS New');
    console.log('Input:', otpSmsNewCommand);
    console.log('Output:', otpSmsNewResponse);
  } catch (error) {
    console.error('Error sending OTP SMS:', error.message);
  }
}

Send OTP SMS (New)

async function sendOtpSms() {
  const otpSmsCommand = {
    sendDate: '2024-07-09T20:03:25.658Z',  // Replace with actual send date
    receptors: [
      {
        mobile: receptor,  // Replace with actual recipient's mobile number
        clientReferenceId: 'dfsdfsding'  // Replace with actual client reference ID
      }
    ],
    templateName: 'newOTP',  // Replace with actual template name
    inputs: [
      {
        param: 'Code',  // Replace with actual parameter name
        value: 'strisng'  // Replace with actual value for 'Code'
      },
      {
        param: 'Name',  // Replace with actual parameter name
        value: 'strddisng'  // Replace with actual value for 'Name'
      }
    ],
    udh: true
  };
  
  try {
    const otpSmsResponse = await ghasedak.sendOtpSms(otpSmsCommand);  // Adjust function name as per your API
    console.log('Send OTP SMS');
    console.log('Input:', otpSmsCommand);
    console.log('Output:', otpSmsResponse);
  } catch (error) {
    console.error('Error sending OTP SMS:', error.message);
  }
}

Run All Tests

You can run all the above functions in sequence:

async function main() {
  await getAccountInformation();
  await checkSmsStatus();
  await getReceivedSmses();
  await getReceivedSmsesPaging();
  await getOtpTemplateParameters();
  await sendSimpleSms();
  await sendBulkSms();
  await sendPairToPairSms();
  await sendOtpSmsNew();
  await sendOtpSms();
}

main().catch(console.error);

License

This project is licensed under the MIT License.