3.1.1 • Published 2 years ago

nimbu-client v3.1.1

Weekly downloads
9
License
MIT
Repository
github
Last release
2 years ago

nimbu-client

Build Status codecov

A thin wrapper around the Nimbu API.

Install

$ npm install nimbu-client --save

Usage

To begin, require the Nimbu module and create the client, passing in an API token:

const Nimbu = require('nimbu-client').default;
const nimbu = new Nimbu({ token: apiToken });

Or in Typescript:

import Nimbu from 'nimbu-client';
const nimbu = new Nimbu({ token: apiToken });

If a customer session token is needed, you can pass this too:

const nimbu = new Nimbu({ token: apiToken, sessionToken: sessionToken });

nimbu-client has get, post, patch, and delete functions which can make requests with the specified HTTP method to any endpoint:

// GET requests
nimbu.get('/channels').then(channels => {
  // do something with channel info
});

// POST requests with body
nimbu.post('/channels', { body: { name: 'foo' } }).then(channel => {});

// PATCH requests with body
nimbu.patch('/channels/foo', { body: { name: 'bar' } }).then(channel => {});

// DELETE requests
nimbu.delete('/channels/bar').then(channel => {});

There is also an even more generic request function that can accept many more options:

nimbu
  .request({
    method: 'GET',
    path: '/channels',
    parseJSON: false,
  })
  .then(response => {});

HTTP Proxies

If you'd like to make requests through an HTTP proxy, set the NIMBU_HTTP_PROXY_HOST environment variable with your proxy host, and NIMBU_HTTP_PROXY_PORT with the desired port (defaults to 8080). nimbu-client will then make requests through this proxy instead of directly to api.nimbu.io.

Running tests

nimbu-client uses ava for tests:

$ npm test
3.1.1

2 years ago

3.0.4

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.5

3 years ago

3.0.0

3 years ago

2.0.0

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago