0.0.5 • Published 7 years ago

banishbot v0.0.5

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

BanishBot

A NodeJS BanishBot helper library.

Release Update

BanishBot is still in alpha phase with a closed registration. This release provides access to the user/banishObject endpoints

Notes:

  • API version: 0.0.1
  • Package version: 0.0.3

PII Data

You can submit PII data by passing the pii == true flag as part of the request.

Installation

For Node.js

npm

To install via npm:

npm install banishbot --save

git

The library is hosted at: https://github.com/mbmlabs/banishbot you can install it via:

    npm install mbmlabs/banishbot --save

For browser

The library also works in the browser environment via npm and browserify. After following the above steps with Node.js and installing browserify with npm install -g browserify, perform the following (assuming main.js is your entry file):

browserify main.js > bundle.js

Then include bundle.js in the HTML pages.

Getting Started

var banishbot = require('banishbot');
var username = 'TheDoctor'; // Required
var apiKey = 'abc-123-Th1s-Is-My-K3y'; // Required
var pii = true; // Optional

Using Promises

Check if an item has been banished:

banishbot.checkBanishment(username, apiKey, 'dalek@skaro.planet', pii).then(function(result) {
  // Success Result
  console.log(result);
  // {"Banished":false,"BanishedItem":"dalek@skaro.planet"}
})
.fail(function (error) {
  // Error Something died, here is the response
  console.log(error);
});

Banish a new item:

var pii = true; // Optional
banishPayload = {
  banished: true // Required
  type: 'email' // This is optional
  notes: 'These are my optional notes' // This is optional
};
banishbot.banishNewItem(username, apiKey, 'dalek@skaro.planet', banishPayload, pii).then(function(result) {
  // Success Result
  console.log(result);
  // { success: true, username: 'TheDoctor' }
  //{ statusCode: '409', body: { Reason: 'This item is already banished, please check the state of the item in a new request.' } }
})
.fail(function (error) {
  // Error Something died, here is the response
  console.log(error);
});

Update an existing item:

var pii = true; // Optional
banishPayload = {
  banished: true // Required
  notes: 'These are my optional notes' // This is optional
};
banishbot.updateBanishedItem(username, apiKey, 'dalek@skaro.planet', banishPayload, pii).then(function(result) {
  // Success Result
  console.log(result);
  //{ success: true, username: 'TheDoctor' }
})
.fail(function (error) {
  // Error Something died, here is the response
  console.log(error);
});

Delete an item:

var pii = true; // Optional

banishbot.deleteItemFromBanishBot(username, apiKey, 'dalek@skaro.planet', pii).then(function(result) {
  // Success Result
  console.log(result);
  //{"Success":true,"Message":"dalek@skaro.planet has been deleted","Username":"TheDoctor"}
})
.fail(function (error) {
  // Error Something died, here is the response
  console.log(error);
});

Using Error first callback

Check if an item has been banished:

var pii = true; // Optional
banishbot.checkBanishment(username, apiKey, 'dalek@skaro.planet',pii, function (error, result) {
  console.log(result);
  //{"Banished":false,"BanishedItem":"dalek@skaro.planet"}
});

Banish a new item:

var pii = true; // Optional
banishPayload = {
  banished: true // Required
  type: 'email' // This is optional
  notes: 'These are my optional notes' // This is optional
};
banishbot.banishNewItem(username, apiKey, 'dalek@skaro.planet', banishPayload, pii, function (error, result) {
  console.log(result);
  //{ success: true, username: 'TheDoctor' }
  //{ statusCode: '409', body: { Reason: 'This item is already banished, please check the state of the item in a new request.' } }
});

Update an existing item:

var pii = true; // Optional
banishPayload = {
  banished: true // Required
  notes: 'These are my optional notes' // This is optional
};
banishbot.updateBanishedItem(username, apiKey, 'dalek@skaro.planet', banishPayload, pii, function (error, result) {
  console.log(result);
  //{ success: true, username: 'TheDoctor' }
});

Delete an item:

var pii = true; // Optional
banishbot.deleteItemFromBanishBot(username, apiKey, 'dalek@skaro.planet', pii, function (error, result) {
  console.log(result);
  //{"Success":true,"Message":"dalek@skaro.planet has been deleted","Username":"TheDoctor"}
});
0.0.5

7 years ago

0.0.32

7 years ago

0.0.31

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago