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

loopback-connector-enviossms

v1.0.1

Published

Loopback connector for consume rest api of http://www.enviossms.com

Downloads

2

Readme

Loopback-connector-enviossms

Description

This connector is for consume the REST API of enviossms.com

For more information of the enviossms REST API please read their documentation here.

Requirments

  • Node: >=8.11.1
  • npm: >=5.6.0
  • Loopback: 3.x

Usage

  1. To use this connector install it with the next command
$ npm install loopback-connector-enviossms --save
  1. Create your enviossms datasource in datasource.json, in the "connector": property especify the loopback-connector-enviossms. The properties "username": and "password": are required to connect with the api rest and consume it.
...
"enviossms": {
  "name": "enviossms",
  "connector": "loopback-connector-enviossms",
  "username": "yourUsername",
  "password": "yourPassword",
}
...
  1. Attach your model to the enviossms datasource in model-config.json
...
"sms": {
  "dataSource": "enviossms",
  "public": true
},
...
  1. Then use it in your model sms like this
// sms.js
'use strict';
const chalk = require('chalk'); // chalk is optional

module.exports = function(sms) {
  const options = {
    to: '+5493511122334',
    text: 'My sms text',
  }

  sms.sendSimpleSms(options)
    .then((res) => {
      // res options is an array  with 2 index,
      // which has a parsed response body in index 0
      // and a raw response in index 1
      console.log(chalk.green(JSON.stringify(res[0])));
      next();
    })
    .catch((err) => {
      console.log(chalk.red(err));
      next(new Error(err));
    });
}

or in other models

// notifications.js
'use strict';
const chalk = require('chalk');

module.exports = function(Notifications) {
  Notifications.observe('before save', function(ctx, next) {
    Notifications.app.models.sms.sendSimpleSms(options)
      .then((res) => {
        // res options is an array  with 2 index,
        // which has a parsed response body in index 0
        // and a raw response in index 1
        console.log(chalk.green(JSON.stringify(res[0])));
      })
      .catch((err) => {
        console.log(chalk.red(err));
      });
  });
};

Exposed methods

| Name | Params | return | Description | | :--- | :--- | :--- | :---: | | sendSimpleSms | options: object with to and text properties | This method return a Promise, when resolve it returns an array with parsed body response in first place and the raw response in the second place; if it is reject returns an error object. | This option consumes the /sms/1/text/single endpoint of api.envios.sms using the POST http verb. |

Other methods are in development rigth now.

Contribute

To contribute in this project please read the contributing guide in our github respository (at the moment in development).

Next steps in development

The next steps plained are:

  • Adding unit test with mocha and chai frameworks
  • Develop other endpoints

GitHub

https://github.com/fukuroo-io/loopback-connector-enviossms

License

MIT