Skip to content

Commit

Permalink
Merge pull request #515 from stripe/remi-add-radar-list
Browse files Browse the repository at this point in the history
Add support for Radar ValueList and ValueListItem resources
  • Loading branch information
ob-stripe authored Nov 27, 2018
2 parents 7d95364 + d67b7d8 commit 5b09f4e
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/resources/Radar/ValueListItems.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

var StripeResource = require('../../StripeResource');

module.exports = StripeResource.extend({
path: 'radar/value_list_items',
includeBasic: ['create', 'list', 'retrieve', 'del'],
});
8 changes: 8 additions & 0 deletions lib/resources/Radar/ValueLists.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

var StripeResource = require('../../StripeResource');

module.exports = StripeResource.extend({
path: 'radar/value_lists',
includeBasic: ['create', 'list', 'update', 'retrieve', 'del'],
});
4 changes: 4 additions & 0 deletions lib/stripe.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ var resources = {
Disputes: require('./resources/Issuing/Disputes'),
Transactions: require('./resources/Issuing/Transactions'),
}),
Radar: resourceNamespace('radar', {
ValueLists: require('./resources/Radar/ValueLists'),
ValueListItems: require('./resources/Radar/ValueListItems'),
}),
Reporting: resourceNamespace('reporting', {
ReportRuns: require('./resources/Reporting/ReportRuns'),
ReportTypes: require('./resources/Reporting/ReportTypes'),
Expand Down
68 changes: 68 additions & 0 deletions test/resources/Radar/ValueListItems.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
'use strict';

var stripe = require('../../../testUtils').getSpyableStripe();

var expect = require('chai').expect;

describe('Radar', function () {
describe('ValueLists Resource', function () {
describe('retrieve', function () {
it('Sends the correct request', function () {
stripe.radar.valueListItems.retrieve('rsli_123');

expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/radar/value_list_items/rsli_123',
headers: {},
data: {},
});
});
});

describe('create', function () {
it('Sends the correct request', function () {
stripe.radar.valueListItems.create({
value_list: 'rsl_123',
value: 'value',
});
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/radar/value_list_items',
headers: {},
data: {
value_list: 'rsl_123',
value: 'value',
},
});
});
});

describe('list', function () {
it('Sends the correct request', function () {
stripe.radar.valueListItems.list({
value_list: 'rsl_123',
});
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/radar/value_list_items',
headers: {},
data: {
value_list: 'rsl_123',
},
});
});
});

describe('del', function() {
it('Sends the correct request', function() {
stripe.radar.valueListItems.del('rsli_123');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'DELETE',
url: '/v1/radar/value_list_items/rsli_123',
headers: {},
data: {},
});
});
});
});
});
80 changes: 80 additions & 0 deletions test/resources/Radar/ValueLists.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
'use strict';

var stripe = require('../../../testUtils').getSpyableStripe();

var expect = require('chai').expect;

describe('Radar', function () {
describe('ValueLists Resource', function () {
describe('retrieve', function () {
it('Sends the correct request', function () {
stripe.radar.valueLists.retrieve('rsl_123');

expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/radar/value_lists/rsl_123',
headers: {},
data: {},
});
});
});

describe('create', function () {
it('Sends the correct request', function () {
stripe.radar.valueLists.create({
alias: 'alias',
name: 'name',
});
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/radar/value_lists',
headers: {},
data: {
alias: 'alias',
name: 'name',
},
});
});
});

describe('list', function () {
it('Sends the correct request', function () {
stripe.radar.valueLists.list();
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/radar/value_lists',
headers: {},
data: {},
});
});
});

describe('del', function() {
it('Sends the correct request', function() {
stripe.radar.valueLists.del('rsl_123');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'DELETE',
url: '/v1/radar/value_lists/rsl_123',
headers: {},
data: {},
});
});
});

describe('update', function() {
it('Sends the correct request', function() {
stripe.radar.valueLists.update('rsl_123', {
metadata: {a: '1234'},
});
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/radar/value_lists/rsl_123',
headers: {},
data: {
metadata: {a: '1234'},
},
});
});
});
});
});

0 comments on commit 5b09f4e

Please sign in to comment.