Skip to content

Commit

Permalink
Add support for Radar List and ListItem resources
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-stripe committed Oct 31, 2018
1 parent a80088d commit c6b9278
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/ListItems.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/list_items',
includeBasic: ['create', 'list', 'retrieve', 'del'],
});
8 changes: 8 additions & 0 deletions lib/resources/Radar/Lists.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/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', {
Lists: require('./resources/Radar/Lists'),
ListItems: require('./resources/Radar/ListItems'),
}),
Reporting: resourceNamespace('reporting', {
ReportRuns: require('./resources/Reporting/ReportRuns'),
ReportTypes: require('./resources/Reporting/ReportTypes'),
Expand Down
68 changes: 68 additions & 0 deletions test/resources/Radar/ListItems.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('Lists Resource', function () {
describe('retrieve', function () {
it('Sends the correct request', function () {
stripe.radar.listItems.retrieve('rsli_123');

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

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

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

describe('del', function() {
it('Sends the correct request', function() {
stripe.radar.listItems.del('rsli_123');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'DELETE',
url: '/v1/radar/list_items/rsli_123',
headers: {},
data: {},
});
});
});
});
});
80 changes: 80 additions & 0 deletions test/resources/Radar/Lists.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('Lists Resource', function () {
describe('retrieve', function () {
it('Sends the correct request', function () {
stripe.radar.lists.retrieve('rsl_123');

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

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

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

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

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

0 comments on commit c6b9278

Please sign in to comment.