notifme/notifme-sdk

View on GitHub
docs/index.html

Summary

Maintainability
Test Coverage
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <link rel="shortcut icon" href="https://notifme.github.io/notifme-sdk/img/favicon.ico">

    <title>notifme/notifme-sdk: A Node.js library to send all kinds of transactional notifications.</title>
    <meta name="description" content="notifme-sdk - A Node.js library to send all kinds of transactional notifications.">

    <link crossorigin="anonymous" href="https://assets-cdn.github.com/assets/frameworks-77c3b874f32e71b14cded5a120f42f5c7288fa52e0a37f2d5919fbd8bcfca63c.css" integrity="sha256-d8O4dPMucbFM3tWhIPQvXHKI+lLgo38tWRn72Lz8pjw=" media="all" rel="stylesheet" />
    <link crossorigin="anonymous" href="https://assets-cdn.github.com/assets/github-6ebe72f92d204144cdef3a835e71687c40074733c90b94f104db80cdf5754533.css" integrity="sha256-br5y+S0gQUTN7zqDXnFofEAHRzPJC5TxBNuAzfV1RTM=" media="all" rel="stylesheet" />
    <style>
      article {
        max-width: 900px;
        margin: 0 auto;
        padding: 2% 0;
      }
      a.github-link {
        background-color: #08ac69;
        color: #fff;
        text-decoration: none;
        padding: 8px 14px;
        font-size: 18px;
        border-radius: 2px;
      }
    </style>
  </head>
  <body>
    <a href="https://github.com/notifme/notifme-sdk"><img style="position: fixed; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/e7bbb0521b397edbd5fe43e7f760759336b5e05f/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677265656e5f3030373230302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_green_007200.png"></a>
    <article class="markdown-body entry-content" itemprop="text">
      <p align="center">
      <img alt="Notif.me" src="https://camo.githubusercontent.com/1908277165dceb6bcfe338f85b06fdbe834ad8c9/68747470733a2f2f6e6f7469666d652e6769746875622e696f2f6e6f7469666d652d73646b2f696d672f6c6f676f2e706e67" data-canonical-src="https://notifme.github.io/notifme-sdk/img/logo.png" style="max-width:100%;">
    </p>
    <p align="center">
      A Node.js library to send all kinds of transactional notifications.
    </p>
    <p align="center">
      <a href="https://www.npmjs.com/package/notifme-sdk"><img alt="npm-status" src="https://camo.githubusercontent.com/f4ae2e918299730f46f1c24be73582eb37aeb58e/68747470733a2f2f696d672e736869656c64732e696f2f6e706d2f762f6e6f7469666d652d73646b2e7376673f7374796c653d666c6174" data-canonical-src="https://img.shields.io/npm/v/notifme-sdk.svg?style=flat" style="max-width:100%;"></a>
      <a href="https://travis-ci.org/notifme/notifme-sdk"><img alt="travis-build-status" src="https://camo.githubusercontent.com/7078531ef35ac38d56f648cbf31c2c099b533028/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6e6f7469666d652f6e6f7469666d652d73646b2e7376673f7374796c653d666c6174" data-canonical-src="https://img.shields.io/travis/notifme/notifme-sdk.svg?style=flat" style="max-width:100%;"></a>
      <a href="https://codeclimate.com/github/notifme/notifme-sdk/coverage"><img alt="codeclimate-code-coverage" src="https://camo.githubusercontent.com/92e31798cd934f057236f4c229bffcd3627a7cf6/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f636f7665726167652f6769746875622f6e6f7469666d652f6e6f7469666d652d73646b2e7376673f7374796c653d666c6174" data-canonical-src="https://img.shields.io/codeclimate/coverage/github/notifme/notifme-sdk.svg?style=flat" style="max-width:100%;"></a>
      <a href="https://codeclimate.com/github/notifme/notifme-sdk"><img alt="codeclimate" src="https://camo.githubusercontent.com/99380bb2e1bb65886487004ea023200eaeaacb4e/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6769746875622f6e6f7469666d652f6e6f7469666d652d73646b2e7376673f7374796c653d666c6174" data-canonical-src="https://img.shields.io/codeclimate/github/notifme/notifme-sdk.svg?style=flat" style="max-width:100%;"></a>
      <a href="https://david-dm.org/notifme/notifme-sdk"><img alt="dependencies" src="https://camo.githubusercontent.com/12d930fb1e16a773ddfde8393353f2d584e014e3/68747470733a2f2f64617669642d646d2e6f72672f6e6f7469666d652f6e6f7469666d652d73646b2e737667" data-canonical-src="https://david-dm.org/notifme/notifme-sdk.svg" style="max-width:100%;"></a>
      <a href="https://github.com/notifme/notifme-sdk/blob/master/LICENSE"><img alt="license" src="https://camo.githubusercontent.com/d2db02b966169f67c346ccd253a63f61077ea86a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49545f4c6963656e73652d626c75652e7376673f7374796c653d666c6174" data-canonical-src="https://img.shields.io/badge/license-MIT_License-blue.svg?style=flat" style="max-width:100%;"></a>
      <a href="https://slackin-notifme.now.sh"><img alt="slack" src="https://camo.githubusercontent.com/ce0f51c4697554565c472468d7dd4b4220384718/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f536c61636b2d4a6f696e5f7573212d6530313536332e737667" data-canonical-src="https://img.shields.io/badge/Slack-Join_us!-e01563.svg" style="max-width:100%;"></a>
      <a href="https://github.com/notifme/notifme-sdk"><img alt="github-stars" src="https://img.shields.io/github/stars/notifme/notifme-sdk.svg?style=social&label=Stars" /></a>
    </p>
    <p><strong>*New: we created a <a href="https://slackin-notifme.now.sh">Slack for support and discuss new features</a>.</strong></p>
    <h2 id="features"><a id="user-content-features" class="anchor" href="#features" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Features</h2>
    <ul>
      <li>
        <p><strong>Easy channel integration</strong> — Want to start sending <code>emails</code> | <code>SMS</code> | <code>pushes</code> | <code>webpushes</code>? Do so in no time!</p>
      </li>
      <li>
        <p><strong>Unique documentation</strong> — Don't look everywhere for the parameters you need to pass, just do it once. <strong>Switching provider becomes a no-brainer</strong>.</p>
      </li>
      <li>
        <p><strong>Multiple providers strategies</strong> — Want to use more than one provider? Use <code>fallback</code> and <code>round-robin</code> strategies out of the box.</p>
      </li>
      <li>
        <p><strong>Tools for local testing</strong> — Run a catcher locally to intercept all your notifications and display them in a web interface.</p>
      </li>
      <li>
        <p><strong>MIT license</strong> — Use it like you want.</p>
      </li>
    </ul>
    <h2 id="getting-started"><a id="user-content-getting-started" class="anchor" href="#getting-started" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Getting Started</h2>
<div class="highlight highlight-source-shell"><pre>$ yarn add notifme-sdk</pre></div>
<div class="highlight highlight-source-js"><pre><span class="pl-k">import</span> <span class="pl-smi">NotifmeSdk</span> <span class="pl-k">from</span> <span class="pl-s"><span class="pl-pds">'</span>notifme-sdk<span class="pl-pds">'</span></span>

<span class="pl-k">const</span> <span class="pl-c1">notifmeSdk</span> <span class="pl-k">=</span> <span class="pl-k">new</span> <span class="pl-en">NotifmeSdk</span>({}) <span class="pl-c"><span class="pl-c">//</span> empty config = all providers are set to console.log</span>
notifmeSdk
  .<span class="pl-c1">send</span>({sms<span class="pl-k">:</span> {from<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>+15000000000<span class="pl-pds">'</span></span>, to<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>+15000000001<span class="pl-pds">'</span></span>, text<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>Hello, how are you?<span class="pl-pds">'</span></span>}})
  .<span class="pl-en">then</span>(<span class="pl-en">console</span>.<span class="pl-smi">log</span>)</pre></div>
      <p><g-emoji alias="sparkles" fallback-src="https://assets-cdn.github.com/images/icons/emoji/unicode/2728.png" ios-version="6.0"><img class="emoji" alt=":sparkles:" height="20" width="20" src="https://assets-cdn.github.com/images/icons/emoji/unicode/2728.png"></g-emoji> Congratulations, you should see the following lines in your console:</p>
      <p><a href="https://camo.githubusercontent.com/aa71fb0c880074170b430517d8f40b302c610d10/68747470733a2f2f6e6f7469666d652e6769746875622e696f2f6e6f7469666d652d73646b2f696d672f67657474696e672d737461727465642d736d732d6c6f672e706e67" target="_blank"><img src="https://camo.githubusercontent.com/aa71fb0c880074170b430517d8f40b302c610d10/68747470733a2f2f6e6f7469666d652e6769746875622e696f2f6e6f7469666d652d73646b2f696d672f67657474696e672d737461727465642d736d732d6c6f672e706e67" alt="Getting started SMS log" data-canonical-src="https://notifme.github.io/notifme-sdk/img/getting-started-sms-log.png" style="max-width:100%;"></a>
        <br><br></p>
        <h3 id="recommended-setup-notification-catcher-for-your-local-tests"><a id="user-content-recommended-setup-notification-catcher-for-your-local-tests" class="anchor" href="#recommended-setup-notification-catcher-for-your-local-tests" aria-hidden="true"><svg aria-hidden="true" class="octicon octicon-link" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>[Recommended] Setup Notification Catcher for your local tests</h3>
        <p><a href="https://github.com/notifme/catcher">Notification Catcher</a> is a web interface for viewing and testing notifications during development.</p>
<div class="highlight highlight-source-shell"><pre>$ yarn add --dev notification-catcher
$ yarn run notification-catcher</pre></div>
<div class="highlight highlight-source-js"><pre><span class="pl-k">import</span> <span class="pl-smi">NotifmeSdk</span> <span class="pl-k">from</span> <span class="pl-s"><span class="pl-pds">'</span>notifme-sdk<span class="pl-pds">'</span></span>

<span class="pl-k">const</span> <span class="pl-c1">notifmeSdk</span> <span class="pl-k">=</span> <span class="pl-k">new</span> <span class="pl-en">NotifmeSdk</span>({
  useNotificationCatcher<span class="pl-k">:</span> <span class="pl-c1">true</span> <span class="pl-c"><span class="pl-c">//</span> &lt;= this sends all your notifications to the catcher running on port 1025</span>
})
notifmeSdk
  .<span class="pl-c1">send</span>({sms<span class="pl-k">:</span> {from<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>+15000000000<span class="pl-pds">'</span></span>, to<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>+15000000001<span class="pl-pds">'</span></span>, text<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>Hello, how are you?<span class="pl-pds">'</span></span>}})
  .<span class="pl-en">then</span>(<span class="pl-en">console</span>.<span class="pl-smi">log</span>)</pre></div>
      <p><g-emoji alias="heart_eyes_cat" fallback-src="https://assets-cdn.github.com/images/icons/emoji/unicode/1f63b.png" ios-version="6.0"><img class="emoji" alt=":heart_eyes_cat:" height="20" width="20" src="https://assets-cdn.github.com/images/icons/emoji/unicode/1f63b.png"></g-emoji> Open <a href="http://localhost:1080">http://localhost:1080</a> on your favorite browser, you should see the notification:</p>
      <p><a href="https://camo.githubusercontent.com/b14996dbc9205f19c133f958d728b328fbf90e1a/68747470733a2f2f6e6f7469666d652e6769746875622e696f2f6e6f7469666d652d73646b2f696d672f67657474696e672d737461727465642d736d732d636174636865722e706e67" target="_blank"><img src="https://camo.githubusercontent.com/b14996dbc9205f19c133f958d728b328fbf90e1a/68747470733a2f2f6e6f7469666d652e6769746875622e696f2f6e6f7469666d652d73646b2f696d672f67657474696e672d737461727465642d736d732d636174636865722e706e67" alt="Getting started SMS catcher" data-canonical-src="https://notifme.github.io/notifme-sdk/img/getting-started-sms-catcher.png" style="max-width:100%;"></a></p>
      <br>
      <p align="center">
        <a href="https://github.com/notifme/notifme-sdk" class="github-link">See complete documentation on GitHub</a>
      </p>
      <br>
    </article>
  </body>
</html>