-
Notifications
You must be signed in to change notification settings - Fork 757
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #622 from stripe/remi-add-account-capabilities
Add support for the Capability resource and APIs
- Loading branch information
Showing
5 changed files
with
166 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict'; | ||
|
||
var StripeResource = require('../StripeResource'); | ||
|
||
module.exports = StripeResource.extend({ | ||
path: 'accounts/{accountId}/capabilities', | ||
includeBasic: ['list', 'retrieve', 'update'], | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
'use strict'; | ||
|
||
var resources = require('../../lib/stripe').resources; | ||
var stripe = require('../../testUtils').getSpyableStripe(); | ||
var expect = require('chai').expect; | ||
|
||
var ACCOUNT_TEST_ID = 'acct_123'; | ||
var CAPABILITY_TEST_ID = 'acap_123'; | ||
|
||
// Create new Capability instance with pre-filled accountId: | ||
var capability = new resources.Capabilities( | ||
stripe, | ||
{accountId: ACCOUNT_TEST_ID} | ||
); | ||
|
||
// Use spy from existing resource: | ||
capability._request = stripe.customers._request; | ||
|
||
describe('Capability Resource', function() { | ||
describe('list', function() { | ||
it('Sends the correct request', function() { | ||
capability.list(); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
method: 'GET', | ||
url: '/v1/accounts/' + ACCOUNT_TEST_ID + '/capabilities', | ||
data: {}, | ||
headers: {}, | ||
}); | ||
}); | ||
}); | ||
|
||
describe('retrieve', function() { | ||
it('Sends the correct request', function() { | ||
capability.retrieve(CAPABILITY_TEST_ID); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
method: 'GET', | ||
url: '/v1/accounts/' + ACCOUNT_TEST_ID + '/capabilities/' + CAPABILITY_TEST_ID, | ||
data: {}, | ||
headers: {}, | ||
}); | ||
}); | ||
}); | ||
|
||
describe('update', function() { | ||
it('Sends the correct request', function() { | ||
capability.update(CAPABILITY_TEST_ID, { | ||
first_name: 'John', | ||
}); | ||
expect(stripe.LAST_REQUEST).to.deep.equal({ | ||
method: 'POST', | ||
url: '/v1/accounts/' + ACCOUNT_TEST_ID + '/capabilities/' + CAPABILITY_TEST_ID, | ||
data: {first_name: 'John'}, | ||
headers: {}, | ||
}); | ||
}); | ||
}); | ||
}); | ||
|