Skip to content

Commit

Permalink
Add support for the File Link resource
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-stripe committed Aug 2, 2018
1 parent 3f1efd7 commit df44192
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 15 deletions.
11 changes: 11 additions & 0 deletions lib/resources/FileLinks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict';

var StripeResource = require('../StripeResource');

module.exports = StripeResource.extend({

path: 'file_links',
includeBasic: [
'create', 'list', 'retrieve', 'update', 'setMetadata', 'getMetadata',
],
});
31 changes: 16 additions & 15 deletions lib/stripe.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ var resources = {
Account: require('./resources/Accounts'),
Accounts: require('./resources/Accounts'),
ApplePayDomains: require('./resources/ApplePayDomains'),
ApplicationFees: require('./resources/ApplicationFees'),
Balance: require('./resources/Balance'),
BitcoinReceivers: require('./resources/BitcoinReceivers'),
Charges: require('./resources/Charges'),
CountrySpecs: require('./resources/CountrySpecs'),
Coupons: require('./resources/Coupons'),
Expand All @@ -42,46 +44,45 @@ var resources = {
EphemeralKeys: require('./resources/EphemeralKeys'),
Events: require('./resources/Events'),
ExchangeRates: require('./resources/ExchangeRates'),
Invoices: require('./resources/Invoices'),
FileLinks: require('./resources/FileLinks'),
FileUploads: require('./resources/FileUploads'),
InvoiceItems: require('./resources/InvoiceItems'),
Invoices: require('./resources/Invoices'),
IssuerFraudRecords: require('./resources/IssuerFraudRecords'),
LoginLinks: require('./resources/LoginLinks'),
OrderReturns: require('./resources/OrderReturns'),
Orders: require('./resources/Orders'),
PaymentIntents: require('./resources/PaymentIntents'),
Payouts: require('./resources/Payouts'),
Plans: require('./resources/Plans'),
Products: require('./resources/Products'),
RecipientCards: require('./resources/RecipientCards'),
Recipients: require('./resources/Recipients'),
Refunds: require('./resources/Refunds'),
Tokens: require('./resources/Tokens'),
Topups: require('./resources/Topups'),
Transfers: require('./resources/Transfers'),
ApplicationFees: require('./resources/ApplicationFees'),
FileUploads: require('./resources/FileUploads'),
BitcoinReceivers: require('./resources/BitcoinReceivers'),
Products: require('./resources/Products'),
Skus: require('./resources/SKUs'),
Orders: require('./resources/Orders'),
OrderReturns: require('./resources/OrderReturns'),
Subscriptions: require('./resources/Subscriptions'),
Sources: require('./resources/Sources'),
SubscriptionItems: require('./resources/SubscriptionItems'),
Subscriptions: require('./resources/Subscriptions'),
ThreeDSecure: require('./resources/ThreeDSecure'),
Sources: require('./resources/Sources'),
Tokens: require('./resources/Tokens'),
Topups: require('./resources/Topups'),
Transfers: require('./resources/Transfers'),
UsageRecords: require('./resources/UsageRecords'),

// The following rely on pre-filled IDs:
ApplicationFeeRefunds: require('./resources/ApplicationFeeRefunds'),
ChargeRefunds: require('./resources/ChargeRefunds'),
CustomerCards: require('./resources/CustomerCards'),
CustomerSubscriptions: require('./resources/CustomerSubscriptions'),
ChargeRefunds: require('./resources/ChargeRefunds'),
ApplicationFeeRefunds: require('./resources/ApplicationFeeRefunds'),
TransferReversals: require('./resources/TransferReversals'),

// Namespaced resources
Issuing: resourceNamespace('issuing', {
Authorizations: require('./resources/Issuing/Authorizations'),
Cardholders: require('./resources/Issuing/Cardholders'),
Cards: require('./resources/Issuing/Cards'),
Transactions: require('./resources/Issuing/Transactions'),
Disputes: require('./resources/Issuing/Disputes'),
Transactions: require('./resources/Issuing/Transactions'),
}),
Sigma: resourceNamespace('sigma', {
ScheduledQueryRuns: require('./resources/Sigma/ScheduledQueryRuns'),
Expand Down
54 changes: 54 additions & 0 deletions test/resources/FileLinks.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
'use strict';

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

describe('FileLinks Resource', function() {
describe('retrieve', function() {
it('Sends the correct request', function() {
stripe.fileLinks.retrieve('link_123');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/file_links/link_123',
headers: {},
data: {},
});
});
});

describe('create', function() {
it('Sends the correct request', function() {
stripe.fileLinks.create({file: 'file_123'});
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/file_links',
headers: {},
data: {file: 'file_123'},
});
});
});

describe('update', function() {
it('Sends the correct request', function() {
stripe.fileLinks.update('link_123', {metadata: {key: 'value'}});
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'POST',
url: '/v1/file_links/link_123',
headers: {},
data: {metadata: {key: 'value'}},
});
});
});

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

0 comments on commit df44192

Please sign in to comment.