Skip to content

Commit

Permalink
Use new v205 version of API instead of v204
Browse files Browse the repository at this point in the history
  • Loading branch information
grantgasp committed Nov 20, 2018
1 parent e2fe605 commit 357f054
Show file tree
Hide file tree
Showing 30 changed files with 211 additions and 211 deletions.
4 changes: 2 additions & 2 deletions lib/client/events.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Promise = require('bluebird');
const v204HttpClient = require('./v204HttpClient');
const v205HttpClient = require('./v205HttpClient');
const _ = require('lodash');

function getEventsApi(siftScienceClient) {
Expand All @@ -17,7 +17,7 @@ function getEventsApi(siftScienceClient) {
$api_key: key
});

return Promise.resolve(v204HttpClient.post('/events', data, params))
return Promise.resolve(v205HttpClient.post('/events', data, params))
.then(response => response.data)
.catch(error => {
logger.logRequestError(error);
Expand Down
6 changes: 3 additions & 3 deletions lib/client/labels.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Promise = require('bluebird');
const v204HttpClient = require('./v204HttpClient');
const v205HttpClient = require('./v205HttpClient');
const _ = require('lodash');

function getLabelsApi(siftScienceClient) {
Expand All @@ -20,7 +20,7 @@ function getLabelsApi(siftScienceClient) {
$api_key: key
});

return Promise.resolve(v204HttpClient.post(`/users/${userId}/labels`, data, params))
return Promise.resolve(v205HttpClient.post(`/users/${userId}/labels`, data, params))
.then(response => response.data)
.catch(error => {
logger.logRequestError(error);
Expand All @@ -39,7 +39,7 @@ function getLabelsApi(siftScienceClient) {
api_key: key
});

return Promise.resolve(v204HttpClient.delete(`/users/${userId}/labels`, params))
return Promise.resolve(v205HttpClient.delete(`/users/${userId}/labels`, params))
.then(response => response.data)
.catch(error => {
logger.logRequestError(error);
Expand Down
6 changes: 3 additions & 3 deletions lib/client/score.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Promise = require('bluebird');
const v204HttpClient = require('./v204HttpClient');
const v205HttpClient = require('./v205HttpClient');
const _ = require('lodash');

function getScoreApi(siftScienceClient) {
Expand All @@ -8,7 +8,7 @@ function getScoreApi(siftScienceClient) {

return {
/**
* @param {Object} [data]
* @param {Object} [userId]
* @param {Object} [params]
* https://siftscience.com/developers/docs/curl/score-api/score-api
*/
Expand All @@ -19,7 +19,7 @@ function getScoreApi(siftScienceClient) {
api_key: key
});

return Promise.resolve(v204HttpClient.get(`/score/${userId}`, params))
return Promise.resolve(v205HttpClient.get(`/score/${userId}`, params))
.then(response => response.data)
.catch(error => {
logger.logRequestError(error);
Expand Down
5 changes: 0 additions & 5 deletions lib/client/v204HttpClient.js

This file was deleted.

5 changes: 5 additions & 0 deletions lib/client/v205HttpClient.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const HttpClient = require('./httpClient');

const V205_BASE_URL = 'https://api.siftscience.com/v205';

module.exports = new HttpClient(V205_BASE_URL);
16 changes: 8 additions & 8 deletions tests/lib/client/events/addItemToCart-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ const sinon = require('sinon');
const _ = require('lodash');

let siftScience;
let v204HttpClient;
let v205HttpClient;
let sandbox;

before(() => {
siftScience = require('../../../../lib');
v204HttpClient = require('../../../../lib/client/v204HttpClient');
v205HttpClient = require('../../../../lib/client/v205HttpClient');

sandbox = sinon.sandbox.create();
});
Expand All @@ -36,12 +36,12 @@ describe('lib', () => {
data: {}
};

before('stub v204HttpClient.post()', () => {
postStub = sandbox.stub(v204HttpClient, 'post')
before('stub v205HttpClient.post()', () => {
postStub = sandbox.stub(v205HttpClient, 'post')
.returns(Promise.resolve(response));
});

it('should call v204HttpClient.post()', () => {
it('should call v205HttpClient.post()', () => {
return siftScienceClient.events.addItemToCart()
.then(result => {
should.exist(result);
Expand All @@ -67,12 +67,12 @@ describe('lib', () => {
data: {}
};

before('stub v204HttpClient.post()', () => {
postStub = sandbox.stub(v204HttpClient, 'post')
before('stub v205HttpClient.post()', () => {
postStub = sandbox.stub(v205HttpClient, 'post')
.returns(Promise.resolve(response));
});

it('should call v204HttpClient.post()', () => {
it('should call v205HttpClient.post()', () => {
return siftScienceClient.events.addItemToCart(data)
.then(result => {
should.exist(result);
Expand Down
16 changes: 8 additions & 8 deletions tests/lib/client/events/addPromotion-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ const sinon = require('sinon');
const _ = require('lodash');

let siftScience;
let v204HttpClient;
let v205HttpClient;
let sandbox;

before(() => {
siftScience = require('../../../../lib');
v204HttpClient = require('../../../../lib/client/v204HttpClient');
v205HttpClient = require('../../../../lib/client/v205HttpClient');

sandbox = sinon.sandbox.create();
});
Expand All @@ -36,12 +36,12 @@ describe('lib', () => {
data: {}
};

before('stub v204HttpClient.post()', () => {
postStub = sandbox.stub(v204HttpClient, 'post')
before('stub v205HttpClient.post()', () => {
postStub = sandbox.stub(v205HttpClient, 'post')
.returns(Promise.resolve(response));
});

it('should call v204HttpClient.post()', () => {
it('should call v205HttpClient.post()', () => {
return siftScienceClient.events.addPromotion()
.then(result => {
should.exist(result);
Expand All @@ -67,12 +67,12 @@ describe('lib', () => {
data: {}
};

before('stub v204HttpClient.post()', () => {
postStub = sandbox.stub(v204HttpClient, 'post')
before('stub v205HttpClient.post()', () => {
postStub = sandbox.stub(v205HttpClient, 'post')
.returns(Promise.resolve(response));
});

it('should call v204HttpClient.post()', () => {
it('should call v205HttpClient.post()', () => {
return siftScienceClient.events.addPromotion(data)
.then(result => {
should.exist(result);
Expand Down
16 changes: 8 additions & 8 deletions tests/lib/client/events/chargeback-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ const sinon = require('sinon');
const _ = require('lodash');

let siftScience;
let v204HttpClient;
let v205HttpClient;
let sandbox;

before(() => {
siftScience = require('../../../../lib');
v204HttpClient = require('../../../../lib/client/v204HttpClient');
v205HttpClient = require('../../../../lib/client/v205HttpClient');

sandbox = sinon.sandbox.create();
});
Expand All @@ -36,12 +36,12 @@ describe('lib', () => {
data: {}
};

before('stub v204HttpClient.post()', () => {
postStub = sandbox.stub(v204HttpClient, 'post')
before('stub v205HttpClient.post()', () => {
postStub = sandbox.stub(v205HttpClient, 'post')
.returns(Promise.resolve(response));
});

it('should call v204HttpClient.post()', () => {
it('should call v205HttpClient.post()', () => {
return siftScienceClient.events.chargeback()
.then(result => {
should.exist(result);
Expand All @@ -67,12 +67,12 @@ describe('lib', () => {
data: {}
};

before('stub v204HttpClient.post()', () => {
postStub = sandbox.stub(v204HttpClient, 'post')
before('stub v205HttpClient.post()', () => {
postStub = sandbox.stub(v205HttpClient, 'post')
.returns(Promise.resolve(response));
});

it('should call v204HttpClient.post()', () => {
it('should call v205HttpClient.post()', () => {
return siftScienceClient.events.chargeback(data)
.then(result => {
should.exist(result);
Expand Down
16 changes: 8 additions & 8 deletions tests/lib/client/events/contentStatus-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ const sinon = require('sinon');
const _ = require('lodash');

let siftScience;
let v204HttpClient;
let v205HttpClient;
let sandbox;

before(() => {
siftScience = require('../../../../lib');
v204HttpClient = require('../../../../lib/client/v204HttpClient');
v205HttpClient = require('../../../../lib/client/v205HttpClient');

sandbox = sinon.sandbox.create();
});
Expand All @@ -36,12 +36,12 @@ describe('lib', () => {
data: {}
};

before('stub v204HttpClient.post()', () => {
postStub = sandbox.stub(v204HttpClient, 'post')
before('stub v205HttpClient.post()', () => {
postStub = sandbox.stub(v205HttpClient, 'post')
.returns(Promise.resolve(response));
});

it('should call v204HttpClient.post()', () => {
it('should call v205HttpClient.post()', () => {
return siftScienceClient.events.contentStatus()
.then(result => {
should.exist(result);
Expand All @@ -67,12 +67,12 @@ describe('lib', () => {
data: {}
};

before('stub v204HttpClient.post()', () => {
postStub = sandbox.stub(v204HttpClient, 'post')
before('stub v205HttpClient.post()', () => {
postStub = sandbox.stub(v205HttpClient, 'post')
.returns(Promise.resolve(response));
});

it('should call v204HttpClient.post()', () => {
it('should call v205HttpClient.post()', () => {
return siftScienceClient.events.contentStatus(data)
.then(result => {
should.exist(result);
Expand Down
22 changes: 11 additions & 11 deletions tests/lib/client/events/create-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ const sinon = require('sinon');
const _ = require('lodash');

let siftScience;
let v204HttpClient;
let v205HttpClient;
let sandbox;

before(() => {
siftScience = require('../../../../lib');
v204HttpClient = require('../../../../lib/client/v204HttpClient');
v205HttpClient = require('../../../../lib/client/v205HttpClient');

sandbox = sinon.sandbox.create();
});
Expand All @@ -36,12 +36,12 @@ describe('lib', () => {
data: {}
};

before('stub v204HttpClient.post()', () => {
postStub = sandbox.stub(v204HttpClient, 'post')
before('stub v205HttpClient.post()', () => {
postStub = sandbox.stub(v205HttpClient, 'post')
.returns(Promise.resolve(response));
});

it('should call v204HttpClient.post()', () => {
it('should call v205HttpClient.post()', () => {
return siftScienceClient.events.create()
.then(result => {
should.exist(result);
Expand All @@ -66,12 +66,12 @@ describe('lib', () => {
data: {}
};

before('stub v204HttpClient.post()', () => {
postStub = sandbox.stub(v204HttpClient, 'post')
before('stub v205HttpClient.post()', () => {
postStub = sandbox.stub(v205HttpClient, 'post')
.returns(Promise.resolve(response));
});

it('should call v204HttpClient.post()', () => {
it('should call v205HttpClient.post()', () => {
return siftScienceClient.events.create(data)
.then(result => {
should.exist(result);
Expand Down Expand Up @@ -103,12 +103,12 @@ describe('lib', () => {
data: {}
};

before('stub v204HttpClient.post()', () => {
postStub = sandbox.stub(v204HttpClient, 'post')
before('stub v205HttpClient.post()', () => {
postStub = sandbox.stub(v205HttpClient, 'post')
.returns(Promise.resolve(response));
});

it('should call v204HttpClient.post()', () => {
it('should call v205HttpClient.post()', () => {
return siftScienceClient.events.create(data, params)
.then(result => {
should.exist(result);
Expand Down
16 changes: 8 additions & 8 deletions tests/lib/client/events/createAccount-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ const sinon = require('sinon');
const _ = require('lodash');

let siftScience;
let v204HttpClient;
let v205HttpClient;
let sandbox;

before(() => {
siftScience = require('../../../../lib');
v204HttpClient = require('../../../../lib/client/v204HttpClient');
v205HttpClient = require('../../../../lib/client/v205HttpClient');

sandbox = sinon.sandbox.create();
});
Expand All @@ -36,12 +36,12 @@ describe('lib', () => {
data: {}
};

before('stub v204HttpClient.post()', () => {
postStub = sandbox.stub(v204HttpClient, 'post')
before('stub v205HttpClient.post()', () => {
postStub = sandbox.stub(v205HttpClient, 'post')
.returns(Promise.resolve(response));
});

it('should call v204HttpClient.post()', () => {
it('should call v205HttpClient.post()', () => {
return siftScienceClient.events.createAccount()
.then(result => {
should.exist(result);
Expand All @@ -67,12 +67,12 @@ describe('lib', () => {
data: {}
};

before('stub v204HttpClient.post()', () => {
postStub = sandbox.stub(v204HttpClient, 'post')
before('stub v205HttpClient.post()', () => {
postStub = sandbox.stub(v205HttpClient, 'post')
.returns(Promise.resolve(response));
});

it('should call v204HttpClient.post()', () => {
it('should call v205HttpClient.post()', () => {
return siftScienceClient.events.createAccount(data)
.then(result => {
should.exist(result);
Expand Down
Loading

0 comments on commit 357f054

Please sign in to comment.