From d67b7d8474f2dcea5051184f3443fc04a0ac0c00 Mon Sep 17 00:00:00 2001 From: Remi Jannel Date: Tue, 30 Oct 2018 20:39:03 -0700 Subject: [PATCH] Add support for Radar List and ListItem resources --- lib/resources/Radar/ValueListItems.js | 8 +++ lib/resources/Radar/ValueLists.js | 8 +++ lib/stripe.js | 4 ++ test/resources/Radar/ValueListItems.spec.js | 68 ++++++++++++++++++ test/resources/Radar/ValueLists.spec.js | 80 +++++++++++++++++++++ 5 files changed, 168 insertions(+) create mode 100644 lib/resources/Radar/ValueListItems.js create mode 100644 lib/resources/Radar/ValueLists.js create mode 100644 test/resources/Radar/ValueListItems.spec.js create mode 100644 test/resources/Radar/ValueLists.spec.js diff --git a/lib/resources/Radar/ValueListItems.js b/lib/resources/Radar/ValueListItems.js new file mode 100644 index 0000000000..f15d4e69b2 --- /dev/null +++ b/lib/resources/Radar/ValueListItems.js @@ -0,0 +1,8 @@ +'use strict'; + +var StripeResource = require('../../StripeResource'); + +module.exports = StripeResource.extend({ + path: 'radar/value_list_items', + includeBasic: ['create', 'list', 'retrieve', 'del'], +}); diff --git a/lib/resources/Radar/ValueLists.js b/lib/resources/Radar/ValueLists.js new file mode 100644 index 0000000000..afda83a75c --- /dev/null +++ b/lib/resources/Radar/ValueLists.js @@ -0,0 +1,8 @@ +'use strict'; + +var StripeResource = require('../../StripeResource'); + +module.exports = StripeResource.extend({ + path: 'radar/value_lists', + includeBasic: ['create', 'list', 'update', 'retrieve', 'del'], +}); diff --git a/lib/stripe.js b/lib/stripe.js index 317c90e90f..e3b0387306 100644 --- a/lib/stripe.js +++ b/lib/stripe.js @@ -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'), diff --git a/test/resources/Radar/ValueListItems.spec.js b/test/resources/Radar/ValueListItems.spec.js new file mode 100644 index 0000000000..3ce40f3e17 --- /dev/null +++ b/test/resources/Radar/ValueListItems.spec.js @@ -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: {}, + }); + }); + }); + }); +}); diff --git a/test/resources/Radar/ValueLists.spec.js b/test/resources/Radar/ValueLists.spec.js new file mode 100644 index 0000000000..8c3743af5e --- /dev/null +++ b/test/resources/Radar/ValueLists.spec.js @@ -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'}, + }, + }); + }); + }); + }); +});