# smsapicom

> JavaScript official client for sending SMS and account management on SMSAPI.com

Latest version **1.5.1** (published 2017-08-07) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install smsapicom
pnpm add smsapicom
yarn add smsapicom
bun add smsapicom
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.5.1 |
| Published | 2017-08-07 |
| First published | 2015-08-29 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Adrian Olczyk |
| Maintainers | smsapi |
| Keywords | smsapi, smsapicom, smsapi-com |

## Links

- npm: https://www.npmjs.com/package/smsapicom
- Repository: https://github.com/smsapicom/smsapicom-javascript-client
- Homepage: https://github.com/smsapicom/smsapicom-javascript-client#readme
- Issues: https://github.com/smsapicom/smsapicom-javascript-client/issues
- npm.io page: https://npm.io/package/smsapicom

## Dependencies (5)

- [md5](https://npm.io/package/md5.md) ^2.0.0
- [rsvp](https://npm.io/package/rsvp.md) ^4.0.1
- [lodash](https://npm.io/package/lodash.md) ^4.6.1
- [js-base64](https://npm.io/package/js-base64.md) ^2.1.8
- [superagent](https://npm.io/package/superagent.md) ^3.5.2

## Recent versions

- 1.5.1 (latest) — 2017-08-07
- 1.5.0 — 2017-05-30
- 1.2.0 — 2016-03-07
- 1.1.7 — 2016-02-15
- 1.1.6 — 2015-09-21
- 1.1.5 — 2015-08-29
- 1.1.4 — 2015-08-29
- 1.1.3 — 2015-08-29

## README

# SMSAPI.com JavaScript (node.js) Client

[![npm version](https://badge.fury.io/js/smsapicom.svg)](http://badge.fury.io/js/smsapicom)

JavaScript client for sending SMS and account management on SMSAPI.com

## Installation (node.js)

```bash

$ npm install smsapicom --save

```

## Example

```javascript

var SMSAPI = require('smsapicom'),
    smsapi = new SMSAPI();

smsapi.authentication
    .login('username', 'password')
    .then(sendMessage)
    .then(displayResult)
    .catch(displayError);

function sendMessage(){
    return smsapi.message
        .sms()
        .from('Info')
        .to('+48605xxxxxx')
        .message('My first message!')
        .execute(); // return Promise
}

function displayResult(result){
    console.log(result);
}

function displayError(err){
    console.error(err);
}

```

## Example (backup server)

```javascript

var SMSAPI = require('smsapi'),
    smsapi = new SMSAPI({
    	server: 'https://api2.smsapi.com/'
    });

smsapi.authentication
    .login('username', 'password')
    .then(sendMessage)
    .then(displayResult)
    .catch(displayError);

function sendMessage(){
    return smsapi.message
        .sms()
        .from('Info')
        .to('605xxxxxx')
        .message('My first message!')
        .execute(); // return Promise
}

function displayResult(result){
    console.log(result);
}

function displayError(err){
    console.error(err);
}

```

# Authentication

Library supports plain text password and md5 hash as a method of authentication. By default [Basic auth](https://en.wikipedia.org/wiki/Basic_access_authentication) is used.

## Plain text example

```javascript
var promise = smsapi.authentication
    .login('username', 'password');
```

## md5 hash example

```javascript
var promise = smsapi.authentication
    .loginHashed('username', '5f4dcc3b5aa765d61d8327deb882cf99');
```

## OAuth

To use OAuth add parameter while SMSAPI object creation:

* `oauth.accessToken`

```javascript
var SMSAPI = require('smsapi'),
    smsapi = new SMSAPI({
        oauth: {
            accessToken: 'your-access-token'
        }
    });

sendMessage()
    .then(displayResult)
    .catch(displayError);

function sendMessage(){
    return smsapi.message
        .sms()
        .from('Info')
        .to('605xxxxxx')
        .message('My first message!')
        .execute(); // return Promise
}

function displayResult(result){
    console.log(result);
}

function displayError(err){
    console.error(err);
}
```

Token can be generated in SMSAPI panel, under address: https://ssl.smsapi.com/webapp#/oauth/manage

# Documentation

REST API documentation: [http://www.smsapi.com/rest](http://www.smsapi.com/rest).

Requests are returning [Promises/A+](https://promisesaplus.com). Used implementation: https://github.com/tildeio/rsvp.js

## List of available operations

* message
    * sms
* points
    * get
* sender
    * add
    * delete
    * status
    * default
    * list
* hlr
    * check
* user
    * add
    * delete
    * update
    * get
    * list
* contacts
    * list
    * add
    * get
    * update
    * delete
    * fields
        * list
        * add
        * update
        * delete
    * groups
        * list
        * add
        * get
        * update
        * delete
        * assignments
            * list
            * add
            * get
            * delete
        * permissions
            * list
            * add
            * get
            * update
            * delete
        * members
            * add
            * get
            * delete

## Examples

Additional examples can be found in test folder (./test).

## Testing

```bash

$ npm install mocha -g
$ npm install .
$ npm test

```

# License

[Apache 2.0 License](LICENSE)

---
_Source: https://npm.io/package/smsapicom · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
