npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

node-sift

0.0.2 • Public • Published

node-sift

Node client for Sift API

Build Status

Coverage Status

Node JS, Promise Based HTTP Client for Sift's API.

Installation

npm install node-sift --save

Quick Start

Create a Sift HTTP Client using your API Key:

//get the Sift factory
const SiftClient = require('node-sift');
 
//create an instance of the Sift client
const client = new SiftClient('your API Key');
 
//now you can use the client to make requests to Sift's API
client.events.create({
  $type: 'your custom event'
});

Table of Contents

Debug mode

When creating your Sift Client instance you can put it in debug mode to log any errors

const client = new SiftClient('your API Key',{
  debugMode: true
});

Events

Custom Events

client.events.create({
  $type: 'your custom event',
  $user_id : '123',
  $session_id: 'gigtleqddo84l8cm15qe4il'
});

The library also supports shortcuts for Sift's Reserved Events:

Create Order

client.events.createOrder({
  $user_id : '123',
  $session_id: 'gigtleqddo84l8cm15qe4il'
});

Update Order

client.events.updateOrder({
  $user_id : '123',
  $session_id: 'gigtleqddo84l8cm15qe4il'
});

Transaction

client.events.transaction({
  $user_id : '123',
  $session_id: 'gigtleqddo84l8cm15qe4il'
});

Create Account

client.events.createAccount({
  $user_id : '123',
  $session_id: 'gigtleqddo84l8cm15qe4il'
});

Update Account

client.events.updateAccount({
  $user_id : '123',
  $session_id: 'gigtleqddo84l8cm15qe4il'
});

Create Content

client.events.createContent({
  $user_id : '123',
  $session_id: 'gigtleqddo84l8cm15qe4il'
});

Update Content

client.events.updateContent({
  $user_id : '123',
  $session_id: 'gigtleqddo84l8cm15qe4il'
});

Content Status

client.events.contentStatus({
  $user_id : '123',
  $session_id: 'gigtleqddo84l8cm15qe4il'
});

Flag Content

client.events.flagContent({
  $user_id : '123',
  $session_id: 'gigtleqddo84l8cm15qe4il'
});

Add Promotion

client.events.addPromotion({
  $user_id : '123',
  $session_id: 'gigtleqddo84l8cm15qe4il'
});

Add Item To Cart

client.events.addItemToCart({
  $user_id : '123',
  $session_id: 'gigtleqddo84l8cm15qe4il'
});

Remove Item From Cart

client.events.removeItemFromCart({
  $user_id : '123',
  $session_id: 'gigtleqddo84l8cm15qe4il'
});

Submit Review

client.events.submitReview({
  $user_id : '123',
  $session_id: 'gigtleqddo84l8cm15qe4il'
});

Send Message

client.events.sendMessage({
  $user_id : '123',
  $session_id: 'gigtleqddo84l8cm15qe4il'
});

Login

client.events.login({
  $user_id : '123',
  $session_id: 'gigtleqddo84l8cm15qe4il'
});

Logout

client.events.logout({
  $user_id : '123',
  $session_id: 'gigtleqddo84l8cm15qe4il'
});

Link Session To User

client.events.linkSessionToUser({
  $user_id : '123',
  $session_id: 'gigtleqddo84l8cm15qe4il'
});

Chargeback

client.events.chargeback({
  $user_id : '123',
  $session_id: 'gigtleqddo84l8cm15qe4il'
});

Order Status

client.events.orderStatus({
  $user_id : '123',
  $session_id: 'gigtleqddo84l8cm15qe4il'
});

Verification

client.events.verification({
  $user_id : '123',
  $session_id: 'gigtleqddo84l8cm15qe4il'
});

Labels

Label User

client.labels.createByUserId('userId', {
  $type: 'your custom event',
  $is_bad : true,
  $abuse_types: 'payment_abuse,promotion_abuse'
});

Unlabel User

client.labels.deleteByUserId('userId', {
  $abuse_types: 'payment_abuse,promotion_abuse'
});

Score

User Score

client.score.getByUserId('userId', {
  $abuse_types: 'payment_abuse,promotion_abuse'
});

You can also ask the API to return a user's score when creating events.

client.events.create({
  $type: 'your custom event',
  $user_id : '123',
  $session_id: 'gigtleqddo84l8cm15qe4il'
}, { //2nd argument are query string params
  $return_score: true,
  $abuse_types: 'payment_abuse,promotion_abuse'
});

Decisions

Apply Decisions

client.decisions.applyByAccountIdAndUserId('accountId', 'userId', {
  decision_id : 'user_looks_ok_payment_abuse'
});

User Decisions

client.decisions.getByAccountIdAndUserId('accountId', 'userId');

Order Decisions

client.decisions.getByAccountIdAndOrderId('accountId', 'orderId');

Decisions List

client.decisions.listByAccountId('accountId');

install

npm i node-sift

Downloadsweekly downloads

255

version

0.0.2

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability