Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for v1/issuer_fraud_records endpoint #456

Merged
merged 6 commits into from
May 9, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lib/resources/IssuerFraudRecords.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

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

module.exports = StripeResource.extend({
path: 'issuer_fraud_records',
includeBasic: ['list', 'retrieve'],

retrieveFromCharge: stripeMethod({
method: 'GET',
path: function(urlData) {
return '?charge=' + urlData.chargeId;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@brandur @matt-stripe any advice here? This still isn't right, because then the url is /v1/issuer_fraud_records/?charge=.... whereas I want it to be /v1/issuer_fraud_records?charge=....

I haven't found another example of this ^ but please do direct me if there is one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also would actually like the test to be data: {charge: 'ch_123456789'} versus doing the urlparams. At least, I think that's what we'd prefer to test here

},
urlParams: ['chargeId'],
}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like in Ruby, list allows you to pass parameters to it. Here's an example from the subscriptions test suite:

      stripe.subscriptions.list({
        limit: 3,
        customer: 'test_cus',
        plan: 'gold',
      });

});
1 change: 1 addition & 0 deletions lib/stripe.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ var resources = {
ExchangeRates: require('./resources/ExchangeRates'),
Invoices: require('./resources/Invoices'),
InvoiceItems: require('./resources/InvoiceItems'),
IssuerFraudRecords: require('./resources/IssuerFraudRecords'),
LoginLinks: require('./resources/LoginLinks'),
Payouts: require('./resources/Payouts'),
Plans: require('./resources/Plans'),
Expand Down
40 changes: 40 additions & 0 deletions test/resources/IssuerFraudRecords.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
'use strict';

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

describe('IssuerFraudRecord Resource', function() {
describe('retrieve', function() {
it('Sends the correct request for issfr ID', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you truncate this down to just "Sends the correct request" for consistency?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

stripe.issuerFraudRecords.retrieve('issfr_123');
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/issuer_fraud_records/issfr_123',
data: {},
headers: {},
});
});
it('Sends the correct request for charge ID', function() {
stripe.issuerFraudRecords.retrieveFromCharge('ch_123456789');
console.log(stripe);
expect(stripe.LAST_REQUEST).to.deep.equal({
method: 'GET',
url: '/v1/issuer_fraud_records?charge=ch_123456789',
data: {},
headers: {},
});
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can safely drop this test case, but if we don't, it should go in the list block below instead of this retrieve block.

});

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