Skip to content

Commit

Permalink
Add support for the Reporting resources
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-stripe committed Aug 31, 2018
1 parent d1c9ea8 commit fcb9dda
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/resources/Reporting/ReportRuns.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: 'reporting/report_runs',
includeBasic: ['create', 'list', 'retrieve'],
});
8 changes: 8 additions & 0 deletions lib/resources/Reporting/ReportTypes.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: 'reporting/report_types',
includeBasic: ['create', 'list', 'retrieve'],
});
4 changes: 4 additions & 0 deletions lib/stripe.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ var resources = {
Disputes: require('./resources/Issuing/Disputes'),
Transactions: require('./resources/Issuing/Transactions'),
}),
Reporting: resourceNamespace('reporting', {
ReportRuns: require('./resources/Reporting/ReportRuns'),
ReportTypes: require('./resources/Reporting/ReportTypes'),
}),
Sigma: resourceNamespace('sigma', {
ScheduledQueryRuns: require('./resources/Sigma/ScheduledQueryRuns'),
}),
Expand Down
56 changes: 56 additions & 0 deletions test/resources/Reporting/ReportRuns.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
'use strict';

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

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

describe('Reporting', function () {
describe('ReportRuns Resource', function () {
describe('retrieve', function () {
it('Sends the correct request', function () {
stripe.reporting.reportRuns.retrieve('frr_123');

expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/reporting/report_runs/frr_123',
headers: {},
data: {},
});
});
});

describe('create', function () {
it('Sends the correct request', function () {
stripe.reporting.reportRuns.create({
parameters: {
connected_account: 'acct_123',
},
report_type: 'activity.summary.1',
});
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/reporting/report_runs',
headers: {},
data: {
parameters: {
connected_account: 'acct_123',
},
report_type: 'activity.summary.1',
},
});
});
});

describe('list', function () {
it('Sends the correct request', function () {
stripe.reporting.reportRuns.list();
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/reporting/report_runs',
headers: {},
data: {},
});
});
});
});
});
34 changes: 34 additions & 0 deletions test/resources/Reporting/ReportTypes.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use strict';

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

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

describe('Reporting', function () {
describe('ReportTypes Resource', function () {
describe('retrieve', function () {
it('Sends the correct request', function () {
stripe.reporting.reportTypes.retrieve('frr_123');

expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/reporting/report_types/frr_123',
headers: {},
data: {},
});
});
});

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

0 comments on commit fcb9dda

Please sign in to comment.