Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: officert/node-siftscience
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.0.1
Choose a base ref
...
head repository: officert/node-siftscience
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Jun 12, 2017

  1. Copy the full SHA
    ec63790 View commit details
  2. bump version

    officert committed Jun 12, 2017
    Copy the full SHA
    274269d View commit details

Commits on Jun 13, 2017

  1. wrap in Bluebird promises,

    return the response body
    officert committed Jun 13, 2017
    Copy the full SHA
    ba015be View commit details
  2. bump

    officert committed Jun 13, 2017
    Copy the full SHA
    942d985 View commit details
  3. update readme

    officert committed Jun 13, 2017
    Copy the full SHA
    2203f4d View commit details
  4. update readme

    officert committed Jun 13, 2017
    Copy the full SHA
    8984c57 View commit details
  5. update readme

    officert committed Jun 13, 2017
    Copy the full SHA
    e9aeb75 View commit details
  6. readme

    officert committed Jun 13, 2017
    Copy the full SHA
    2f5e94b View commit details
  7. readme

    officert committed Jun 13, 2017
    Copy the full SHA
    2b974c1 View commit details
  8. fix readme

    officert committed Jun 13, 2017
    Copy the full SHA
    d9a3d99 View commit details
  9. add score api,

    update read me
    officert committed Jun 13, 2017
    Copy the full SHA
    7b49ff1 View commit details
  10. bump version

    officert committed Jun 13, 2017
    Copy the full SHA
    9d64473 View commit details
  11. Copy the full SHA
    e3992e5 View commit details
  12. Copy the full SHA
    66eb625 View commit details
  13. fix Axios base url key,

    bump version
    officert committed Jun 13, 2017
    Copy the full SHA
    dfcd3b0 View commit details
  14. Axios returns a response with a data key, not body,

    bump version
    officert committed Jun 13, 2017
    Copy the full SHA
    b33f011 View commit details
  15. Copy the full SHA
    f5b4b36 View commit details
  16. start decisions API

    officert committed Jun 13, 2017
    Copy the full SHA
    3e269bb View commit details

Commits on Jun 14, 2017

  1. Copy the full SHA
    2e42ac1 View commit details
  2. rethrow error,

    bump version
    officert committed Jun 14, 2017
    Copy the full SHA
    f9b8eef View commit details
  3. bump

    officert committed Jun 14, 2017
    Copy the full SHA
    e96aac9 View commit details
  4. Copy the full SHA
    26f622b View commit details
  5. fix score api url

    officert committed Jun 14, 2017
    Copy the full SHA
    c948e65 View commit details
  6. Copy the full SHA
    55f685e View commit details
  7. Copy the full SHA
    df74aca View commit details

Commits on Jun 15, 2017

  1. change method name,

    bump
    officert committed Jun 15, 2017
    Copy the full SHA
    6cd7103 View commit details

Commits on Jun 19, 2017

  1. Copy the full SHA
    1d29eff View commit details

Commits on Aug 14, 2017

  1. Copy the full SHA
    671e20f View commit details
  2. Bump version to 0.0.17

    AndrewBarba authored Aug 14, 2017
    Copy the full SHA
    6e37e03 View commit details

Commits on Aug 23, 2017

  1. Merge pull request #2 from AndrewBarba/master

    Allow higher version of Node.js and dependencies
    officert authored Aug 23, 2017
    Copy the full SHA
    ed53c24 View commit details

Commits on Nov 2, 2018

  1. Copy the full SHA
    e2fe605 View commit details

Commits on Nov 20, 2018

  1. Copy the full SHA
    357f054 View commit details

Commits on Dec 4, 2018

  1. Merge pull request #3 from grantgasp/add-apply-decision-to-order

    Add apply decision to orders functionality
    officert authored Dec 4, 2018
    Copy the full SHA
    4613852 View commit details
  2. Copy the full SHA
    0ce8021 View commit details

Commits on Nov 19, 2019

  1. Copy the full SHA
    5dc50ed View commit details

Commits on Mar 30, 2020

  1. Copy the full SHA
    8b92c48 View commit details
  2. Copy the full SHA
    d8a3040 View commit details
  3. Copy the full SHA
    d79a387 View commit details

Commits on Mar 31, 2020

  1. Merge pull request #5 from tchaffee/feat/update_password

    feat: add Sift $update_password event.
    officert authored Mar 31, 2020
    Copy the full SHA
    a258fca View commit details
  2. Merge pull request #6 from denis-vanat/master

    add(decisions): apply decisions by accountId, userId and sessionId
    officert authored Mar 31, 2020
    Copy the full SHA
    54198cc View commit details
  3. update version

    officert committed Mar 31, 2020
    Copy the full SHA
    56db14f View commit details
Showing with 5,660 additions and 1,093 deletions.
  1. +0 −5 Makefile
  2. +314 −6 README.md
  3. +139 −0 lib/client/decisions.js
  4. +108 −84 lib/client/events.js
  5. +53 −0 lib/client/httpClient.js
  6. +12 −7 lib/client/index.js
  7. +25 −9 lib/client/labels.js
  8. +32 −0 lib/client/score.js
  9. +0 −38 lib/client/v204/httpClient.js
  10. +0 −1 lib/client/v204/index.js
  11. +5 −0 lib/client/v205HttpClient.js
  12. +5 −0 lib/client/v3HttpClient.js
  13. +0 −9 lib/factory.js
  14. +3 −1 lib/index.js
  15. +35 −0 lib/logger.js
  16. +2,396 −0 package-lock.json
  17. +6 −6 package.json
  18. +2 −2 tests/{siftScience → lib}/client/constructor-test.js
  19. +179 −0 tests/lib/client/decision/applyByAccountIdAndOrderId-test.js
  20. +179 −0 tests/lib/client/decision/applyByAccountIdAndSessionId-test.js
  21. +157 −0 tests/lib/client/decision/applyByAccountIdAndUserId-test.js
  22. +160 −0 tests/lib/client/decision/getByAccountIdAndOrderId-test.js
  23. +160 −0 tests/lib/client/decision/getByAccountIdAndUserId-test.js
  24. +142 −0 tests/lib/client/decision/listByAccountId-test.js
  25. +20 −16 tests/{siftScience → lib}/client/events/addItemToCart-test.js
  26. +20 −16 tests/{siftScience → lib}/client/events/addPromotion-test.js
  27. +20 −16 tests/{siftScience → lib}/client/events/chargeback-test.js
  28. +20 −16 tests/{siftScience → lib}/client/events/contentStatus-test.js
  29. +129 −0 tests/lib/client/events/create-test.js
  30. +20 −16 tests/{siftScience → lib}/client/events/createAccount-test.js
  31. +20 −16 tests/{siftScience → lib}/client/events/createContent-test.js
  32. +20 −16 tests/{siftScience → lib}/client/events/createOrder-test.js
  33. +20 −16 tests/{siftScience → lib}/client/events/flagContent-test.js
  34. +20 −16 tests/{siftScience → lib}/client/events/linkSessionToUser-test.js
  35. +20 −16 tests/{siftScience → lib}/client/events/login-test.js
  36. +20 −16 tests/{siftScience → lib}/client/events/logout-test.js
  37. +20 −16 tests/{siftScience → lib}/client/events/orderStatus-test.js
  38. +20 −16 tests/{siftScience → lib}/client/events/removeItemFromCart-test.js
  39. +20 −16 tests/{siftScience → lib}/client/events/sendMessage-test.js
  40. +20 −16 tests/{siftScience → lib}/client/events/submitReview-test.js
  41. +20 −16 tests/{siftScience → lib}/client/events/transaction-test.js
  42. +20 −16 tests/{siftScience → lib}/client/events/updateAccount-test.js
  43. +20 −16 tests/{siftScience → lib}/client/events/updateContent-test.js
  44. +20 −16 tests/{siftScience → lib}/client/events/updateOrder-test.js
  45. +93 −0 tests/lib/client/events/updatePassword.js
  46. +20 −16 tests/{siftScience → lib}/client/events/verification-test.js
  47. +33 −0 tests/lib/client/httpClient/constructor-test.js
  48. +141 −0 tests/lib/client/httpClient/delete-test.js
  49. +141 −0 tests/lib/client/httpClient/get-test.js
  50. +176 −0 tests/lib/client/httpClient/post-test.js
  51. +101 −0 tests/lib/client/labels/createByUserId-test.js
  52. +100 −0 tests/lib/client/labels/deleteByUserId-test.js
  53. +100 −0 tests/lib/client/score/getByUserId-test.js
  54. +65 −0 tests/lib/logger/log-test.js
  55. +69 −0 tests/lib/logger/logRequestError-test.js
  56. +0 −87 tests/siftScience/client/events/create-test.js
  57. +0 −73 tests/siftScience/client/labels/createByUserId-test.js
  58. +0 −75 tests/siftScience/client/labels/deleteByUserId-test.js
  59. +0 −102 tests/siftScience/client/v204/httpClient/delete-test.js
  60. +0 −102 tests/siftScience/client/v204/httpClient/get-test.js
  61. +0 −133 tests/siftScience/client/v204/httpClient/post-test.js
  62. +0 −33 tests/siftScience/factory/init-test.js
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -8,11 +8,6 @@ default:
clean:
rm -rf coverage;

post-install:
cd node_modules; \
ln -nsf ../lib; \
ln -nsf ../tests; \

test: eslint test-unit

test-unit:
320 changes: 314 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# node-siftscience

Node client for Sift Science API

[![Build Status](https://travis-ci.org/officert/node-siftscience.svg?branch=master)](https://travis-ci.org/officert/node-siftscience)
@@ -7,25 +8,332 @@ Node client for Sift Science API

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

### Installation
## Installation

``` shell
```shell
npm install node-siftscience --save
```

### Quick Start
## Quick Start

Create a Sift Science HTTP Client using your API Key:

``` js
```javascript
//get the Sift Science factory
const siftScience = require('node-siftscience');
const SiftScienceClient = require('node-siftscience');

//create an instance of the Sift Science client
const client = siftScience.init('your API Key');
const client = new SiftScienceClient('your API Key');

//now you can use the client to make requests to Sift Science's API
client.events.create({
$type: 'your custom event'
});
```

## Table of Contents

- [Debug Mode](<#debug mode>)

- [Events](#events)

- [Labels](#labels)
- [Score](#score)
- [Decisions](#decisions)

## Debug mode

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

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

## Events

### [Custom Events](https://siftscience.com/developers/docs/curl/events-api/custom-events)

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

The library also supports shortcuts for Sift Science's [Reserved Events](https://siftscience.com/developers/docs/curl/events-api/reserved-events):

### [Create Order](https://siftscience.com/developers/docs/curl/events-api/reserved-events/create-order)

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

### [Update Order](https://siftscience.com/developers/docs/curl/events-api/reserved-events/update-order)

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

### [Transaction](https://siftscience.com/developers/docs/curl/events-api/reserved-events/transaction)

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

### [Create Account](https://siftscience.com/developers/docs/curl/events-api/reserved-events/create-account)

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

### [Update Account](https://siftscience.com/developers/docs/curl/events-api/reserved-events/update-account)

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

### [Update Password](https://sift.com/developers/docs/curl/events-api/reserved-events/update-password)

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

### [Create Content](https://siftscience.com/developers/docs/curl/events-api/reserved-events/create-content)

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

### [Update Content](https://siftscience.com/developers/docs/curl/events-api/reserved-events/update-content)

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

### [Content Status](https://siftscience.com/developers/docs/curl/events-api/reserved-events/content-status)

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

### [Flag Content](https://siftscience.com/developers/docs/curl/events-api/reserved-events/flag-content)

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

### [Add Promotion](https://siftscience.com/developers/docs/curl/events-api/reserved-events/add-promotion)

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

### [Add Item To Cart](https://siftscience.com/developers/docs/curl/events-api/reserved-events/add-item-to-cart)

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

### [Remove Item From Cart](https://siftscience.com/developers/docs/curl/events-api/reserved-events/remove-item-from-cart)

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

### [Submit Review](https://siftscience.com/developers/docs/curl/events-api/reserved-events/submit-review)

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

### [Send Message](https://siftscience.com/developers/docs/curl/events-api/reserved-events/send-message)

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

### [Login](https://siftscience.com/developers/docs/curl/events-api/reserved-events/login)

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

### [Logout](https://siftscience.com/developers/docs/curl/events-api/reserved-events/logout)

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

### [Link Session To User](https://siftscience.com/developers/docs/curl/events-api/reserved-events/link-session-to-user)

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

### [Chargeback](https://siftscience.com/developers/docs/curl/events-api/reserved-events/chargeback)

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

### [Order Status](https://siftscience.com/developers/docs/curl/events-api/reserved-events/order-status)

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

### [Verification](https://siftscience.com/developers/docs/curl/events-api/reserved-events/verification)

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

## Labels

### [Label User](https://siftscience.com/developers/docs/curl/labels-api/label-user)

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

### [Unlabel User](https://siftscience.com/developers/docs/curl/labels-api/unlabel-user)

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

## Score

### [User Score](https://siftscience.com/developers/docs/curl/score-api/score-api)

```javascript
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](#events).

```javascript
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](https://siftscience.com/developers/docs/curl/decisions-api/apply-decisions)

#### User decision
```javascript
client.decisions.applyByAccountIdAndUserId('accountId', 'userId', {
decision_id : 'user_looks_ok_payment_abuse'
});
```
#### Order decision
```javascript
client.decisions.applyByAccountIdAndOrderId('accountId', 'userId', 'orderId', {
decision_id : 'user_looks_ok_payment_abuse'
});
```
#### Session decision
```javascript
client.decisions.applyByAccountIdAndSessionId('accountId', 'userId', 'sessionId', {
decision_id : 'user_looks_ok_payment_abuse'
});
```

### [User Decisions](https://siftscience.com/developers/docs/curl/decisions-api/decision-status)

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

### [Order Decisions](https://siftscience.com/developers/docs/curl/decisions-api/decision-status)

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

### [Decisions List](https://siftscience.com/developers/docs/curl/decisions-api/decisions-list)

```javascript
client.decisions.listByAccountId('accountId');
```
Loading