Git Product home page Git Product logo

greensms-node's Introduction

greensms-node

NPM

GitHub release (latest by date) node-current GitHub Workflow Status Coveralls github Codacy Badge

Documentation

The documentation for the GREENSMS API can be found here.

Installation

npm install greensms --save

Sample Usage

Check out these code examples in JavaScript and TypeScript to get up and running quickly.

const GreenSMS = require("greensms");
// Register at my.greeensms.ru first
const client = new GreenSMS({ user: "test", pass: "test" });

client.sms
  .send({
    to: "71231234567",
    txt: "Message to deliver",
  })
  .then((response) => {
    console.log("Request ID: %s", response.request_id);
  })
  .catch((err) => {
    console.error(err);
  });

Environment Variables

greensms-node supports credential storage in environment variables. If no credentials are provided following env vars will be used: GREENSMS_USER/GREENSMS_PASS OR GREENSMS_TOKEN.

Token Auth

const GreenSMS = require("greensms");

const client = new GreenSMS({ token: "token" });

client.account
  .balance()
  .then((response) => {
    console.log("Balance ", response.balance);
  })
  .catch((err) => {
    console.error(err);
  });

Callback Example

const GreenSMS = require("greensms");
// Register at my.greeensms.ru first
const client = new GreenSMS({ user: "test", pass: "test" });

function cb(err, response) {
  console.error("Error ", err);
  console.log("Response", response);
}

greenSmsInstance.account.balance(cb);

Methods

  • You can either use username/password combination or auth token to create an object with constructor
  • All methods support Promises, Async/Await and Callbacks.
  • Each API Function is available as MODULE.FUNCTION()
  • Parameters for each API can be referred from here
  • Response keys by default are available in snake_case. If you want to use camelCase, then pass camelCaseResponse: true, in the constructor

Handling Exceptions

  • Exceptions for Promise are caught in the catch block.
  • For Async/Await, you can catch the error with try/catch block
  • Each Error consists of error, code, message, errorType fields and extends the default javascript Error class

Getting help

If you need help installing or using the library, please contact us: [email protected].

If you've instead found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo!

Contributing

Bug fixes, docs, and library improvements are always welcome. Please refer to our Contributing Guide for detailed information on how you can contribute. If you're not familiar with the GitHub pull request/contribution process, this is a nice tutorial.

Getting Started

If you want to familiarize yourself with the project, you can start by forking the repository and cloning it in your local development environment. The project requires Node.js to be installed on your machine.

After cloning the repository, install the dependencies by running the following command in the directory of your cloned repository:

npm install

You can run the existing tests to see if everything is okay by executing:

npm test

greensms-node's People

Contributors

mananjadhav avatar 2naive avatar

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.