From df44192ccabd1012ee301534ccfa873960a7fce1 Mon Sep 17 00:00:00 2001 From: Remi Jannel Date: Thu, 2 Aug 2018 23:49:32 +0200 Subject: [PATCH] Add support for the File Link resource --- lib/resources/FileLinks.js | 11 +++++++ lib/stripe.js | 31 +++++++++--------- test/resources/FileLinks.spec.js | 54 ++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 15 deletions(-) create mode 100644 lib/resources/FileLinks.js create mode 100644 test/resources/FileLinks.spec.js diff --git a/lib/resources/FileLinks.js b/lib/resources/FileLinks.js new file mode 100644 index 0000000000..8052fc7f02 --- /dev/null +++ b/lib/resources/FileLinks.js @@ -0,0 +1,11 @@ +'use strict'; + +var StripeResource = require('../StripeResource'); + +module.exports = StripeResource.extend({ + + path: 'file_links', + includeBasic: [ + 'create', 'list', 'retrieve', 'update', 'setMetadata', 'getMetadata', + ], +}); diff --git a/lib/stripe.js b/lib/stripe.js index 32ea96f742..ddaa83000f 100644 --- a/lib/stripe.js +++ b/lib/stripe.js @@ -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'), @@ -42,37 +44,36 @@ 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 @@ -80,8 +81,8 @@ var resources = { 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'), diff --git a/test/resources/FileLinks.spec.js b/test/resources/FileLinks.spec.js new file mode 100644 index 0000000000..01b835148c --- /dev/null +++ b/test/resources/FileLinks.spec.js @@ -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: {}, + }); + }); + }); +});