Giter Site home page Giter Site logo

smsgateway.me's Introduction

smsgateway.me

A Node.js wrapper of smsgateway.me v4 api.

Installing

Via npm:

$ npm install [-g] smsgateway.me

Available methods

  • message.send(messages: INewMessage[]): Promise<IMessage[]>
  • message.info(messageId: number): Promise
  • message.search(query: IQuery): Promise<ISearchResult>
  • message.cancel(messages: IMessageCancel[]): Promise<IMessage[]>
  • device.info(deviceId: number)
  • device.search(query: IQuery)

Usage

Send message

import { IMessage, INewMessage, SmsGateway } from 'smsgateway.me';

/* You can get token from https://smsgateway.me/dashboard/settings */
const token = 'YOUR_TOKEN';
/* You can get deviceId from https://smsgateway.me/dashboard/devices or by calling gateway.device.search() */
const deviceId = 'YOUR_DEVICE';
const gateway = new SmsGateway(token);

const newMessages: INewMessage[] = [
  {
    device_id: deviceId,
    message: 'some message',
    phone_number: 'phone number',
  },
  {
    device_id: deviceId,
    message: 'another some message',
    phone_number: 'other or same phone number',
  },
];

gateway.message.send(newMessages)
  .then((messages: IMessage[]) => console.info('Messages send:', messages))
  .catch((err: any) => console.error(err));

Search for messages

import { IMessage, IQuery, ISearchResult, SmsGateway } from 'smsgateway.me';

const gateway = new SmsGateway('YOUR_TOKEN');
const query: IQuery<IMessage> = {
  filters: [
    [
      {
        field: 'status',
        operator: '=',
        value: 'canceled',
      },
    ],
  ],
  limit: 1,
};

gateway.message.search(query)
  .then((response: ISearchResult<IMessage>) => console.info('Messages found:', response))
  .catch((err: any) => console.error(err));

Fetch info about message

import { IMessage, IQuery, ISearchResult, SmsGateway } from 'smsgateway.me';

const gateway = new SmsGateway('YOUR_TOKEN');
const messageId: number = 71234567;

gateway.message.info(messageId)
  .then((message: IMessage) => console.info('Message info:', message))
  .catch((err: any) => console.error(err));

Cancel messages

import { IMessage, IMessageCancel, IQuery, ISearchResult, SmsGateway } from 'smsgateway.me';

const gateway = new SmsGateway('YOUR_TOKEN');
const messagesToCancel: IMessageCancel[] = [{ id: 71234567 }];

gateway.message.cancel(messagesToCancel)
  .then((messages: IMessage[]) => console.info('Canceled message: ', messages))
  .catch((err: any) => console.error(err));

Search for devices

import { IDevice, IQuery, ISearchResult, SmsGateway } from 'smsgateway.me';

const gateway = new SmsGateway('YOUR_TOKEN');
const query: IQuery<IDevice> = {};

gateway.device.search(query)
  .then((response: ISearchResult<IDevice>) => console.info('Found devices:', response))
  .catch((err: any) => console.error(err));

Fetch device info

import { IDevice, IQuery, ISearchResult, SmsGateway } from 'smsgateway.me';

const gateway = new SmsGateway('YOUR_TOKEN');
const deviceId: number = 101234;

gateway.device.info(deviceId)
  .then((device: IDevice) => console.info('Device info:', device))
  .catch((err: any) => console.error(err));

smsgateway.me's People

Contributors

hakier avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

smsgateway.me's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.