Coder Social home page Coder Social logo

withdustin / geek-sms Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 1.0 149 KB

SMS SDK for Javascript. Written in Typescript. Works on Node.js, browsers, React native. Supports eSMS.vn and more.

Home Page: https://github.com/targeek/geek-sms

License: MIT License

JavaScript 2.08% TypeScript 97.92%
esms sms crm javascript typescript

geek-sms's Introduction

Geek SMS

NPM

dependencies Status devDependencies Status GeekSMS Coverage Status Build Status PRs Welcome npm type definitions

A javascript library that supports multiple Vietnamese SMS service provider APIs.

Supported services

If you really need a service above or another else, you can push us by creating an issue or make a PR. We are very welcome your contributions.

Getting Started

Installation

yarn add geek-sms
// or
npm install --save geek-sms

Usage

import { ESMS } from 'geek-sms'

const esms = new ESMS(
  {
    API_KEY: 'AN_API_KEY',
    SECRET_KEY: 'A_SECRET_KEY',
  },
  {
    loglevel: 'trace',
  },
)

esms.getBalance()
esms.getBrandNameList()
esms.sendMessage(messageInfo)

Running the tests

Run tests once

yarn test
// or
npm run test

Run tests in watch mode

yarn test:watch
// or
npm run test:watch

API Reference

The documentation below is written in ECMAScript 6. If you have any issue please create an issue so we can help.

eSMS.vn

Initialize a new instance

new ESMS(
  {
    API_KEY, // Your API key.
    SECRET_KEY, // Your secret key.
  },
  {
    loglevel, // Could be one of 'trace', 'error', 'debug', 'info', 'silent'. Defaults to 'silent'.
    baseUrl, // Overrides eSMS API URL (w/o trailing slash (`/`)).
    useHttp, // Default API URL is https. Set this value to `true` if you want to use http.
  },
)

Example:

import { ESMS } from 'geek-sms'

const esms = new ESMS(
  {
    API_KEY: 'AN_API_KEY',
    SECRET_KEY: 'A_SECRET_KEY',
  },
  {
    loglevel: 'trace',
    baseUrl: 'http://another-url.esms.vn/MainService.svc/json',
  },
)

Get account balance

Returns the remaining money in your account.

Example:

const balance = await esms.getBalance()
// => 4000000

Get brand name list

Returns the list of registered brand names.

Example:

const brandnames = await esms.getBrandNameList()

/* Resolves
[ { name: 'QCAO_ONLINE', type: 2 },
  { name: 'STORELAMMOC', type: 1 },
  { name: 'STORELAMMOC', type: 2 } ]
*/

Send SMS message(s)

const messageInfo = {
  phone: '0979000001', // A list of numbers to send SMS.
  message: 'Test message jest',
  type: ESMSMessageType,
  brandName: 'STORELAMMOC',
  sandBox: true,
}

await esms.sendMessage(messageInfo)

// with
enum ESMSMessageType {
  /** Advertising message using brand name (send to >= 20 numbers). */
  AdvertisingBrandName = 1,
  /** Customer care message using brand name (send to 1 or more numbers). */
  CustomerCareBrandName = 2,
  /** For both advertising or customer care, using a static phone number to send. */
  StaticNumber = 4,
  /** Static 6394 number. Used for customer care or confirmation. */
  StaticConfirmation = 6,
  /** Use a static 10-digit number for customer care. Must registry message content first. */
  Static10Digit = 8,
}

/* Resolves
{
  id: '871a70d0-0c6c-4b47-9664-5745603da2d0169',
  phone: '0979000001',
  message: 'Test message jest',
  type: 2,
  brandName: 'STORELAMMOC',
  sandBox: true,
}
*/

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

geek-sms's People

Contributors

duongdev avatar renovate-bot avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

geek-sms's Issues

Add supports for eSMS basic fuctionalities

In the very first stage, we are willing to support the basics feature of eSMS.vn:

  • Get account balance.
  • Send SMSs.
    • Advertising Brandname.
    • Customer care Brandname.
  • Get brandname list.

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.