Skip to content

Commit

Permalink
Add support for the Webhook Endpoint resource
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-stripe committed Oct 30, 2018
1 parent 50d7fea commit 771511f
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/resources/WebhookEndpoints.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';

module.exports = require('../StripeResource').extend({
path: 'webhook_endpoints',
includeBasic: ['create', 'list', 'update', 'retrieve', 'del'],
});

1 change: 1 addition & 0 deletions lib/stripe.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ var resources = {
Transfers: require('./resources/Transfers'),
UsageRecords: require('./resources/UsageRecords'),
UsageRecordSummaries: require('./resources/UsageRecordSummaries'),
WebhookEndpoints: require('./resources/WebhookEndpoints'),

// The following rely on pre-filled IDs:
ApplicationFeeRefunds: require('./resources/ApplicationFeeRefunds'),
Expand Down
77 changes: 77 additions & 0 deletions test/resources/WebhookEndpoints.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
'use strict';

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

describe('WebhookEndpoints Resource', function() {
describe('retrieve', function() {
it('Sends the correct request', function() {
stripe.webhookEndpoints.retrieve('we_123');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/webhook_endpoints/we_123',
headers: {},
data: {},
});
});
});

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

describe('update', function() {
it('Sends the correct request', function() {
stripe.webhookEndpoints.update('we_123', {
enabled_events: ['charge.succeeded'],
});
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/webhook_endpoints/we_123',
headers: {},
data: {
enabled_events: ['charge.succeeded'],
},
});
});
});

describe('create', function() {
it('Sends the correct request', function() {
stripe.webhookEndpoints.create({
enabled_events: ['charge.succeeded'],
url: 'https://stripe.com',
});

expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/webhook_endpoints',
headers: {},
data: {
enabled_events: ['charge.succeeded'],
url: 'https://stripe.com',
},
});
});
});

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

0 comments on commit 771511f

Please sign in to comment.