nimbu-client
A thin wrapper for the Nimbu API
Last updated 8 days ago by dedene .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install nimbu-client 
SYNC missed versions from official npm registry.

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');
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

Current Tags

  • 2.0.0                                ...           latest (8 days ago)

9 Versions

  • 2.0.0                                ...           8 days ago
  • 1.0.7 [deprecated]           ...           9 days ago
  • 1.0.6                                ...           a month ago
  • 1.0.5                                ...           a year ago
  • 1.0.4                                ...           a year ago
  • 1.0.3                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Maintainers (2)
Downloads
Today 0
This Week 3
This Month 0
Last Day 0
Last Week 23
Last Month 27
Dependencies (3)
Dev Dependencies (7)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |