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

Conversation

fay-stripe
Copy link
Contributor

need to wait for update to stripe mock

@brandur-stripe
Copy link
Contributor

Thanks! Fay, as discussed in chat, stripe-node is not quite on stripe-mock yet.

Can you see if you can get your failing test fixed? You can see CI for details, but should also be able to reproduce it locally.

  IssuerFraudRecord Resource
    retrieve
      1) Sends the correct request for issfr ID
  216 passing (39s)
  1 failing
  1) IssuerFraudRecord Resource
       retrieve
         Sends the correct request for issfr ID:
     TypeError: Cannot read property 'retrieve' of undefined
      at Context.<anonymous> (test/resources/IssuerFraudRecords.spec.js:9:35)

@fay-stripe fay-stripe self-assigned this May 9, 2018
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

@fay-stripe
Copy link
Contributor Author

I got the tests to pass but I'm not sure if there's a better / more correct way of doing the ?charge= here.
ptal @brandur

@fay-stripe
Copy link
Contributor Author

I think I keep tagging your brandur handle instead of brandur-stripe. Sorry about that!

Copy link
Contributor

@brandur-stripe brandur-stripe left a comment

Choose a reason for hiding this comment

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

Left a couple comments, but I think we're almost there.

ptal @fay-stripe

return 'issuer_fraud_records?charge=' + urlData.chargeId;
},
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',
      });

var stripeMethod = StripeResource.method;

module.exports = StripeResource.extend({
path: '',
Copy link
Contributor

Choose a reason for hiding this comment

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

Why empty the path up here and then pass one in each method? I think you should be able to implement this almost identically to country spec:

module.exports = StripeResource.extend({

  path: 'country_specs',

  includeBasic: [
    'list', 'retrieve',
  ],
});

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 didn't know list could take a param as I missed the other examples of it. When I implemented a new method, the base path automatically tacks on / when anything is appended to it, so I separated it out in order to make sure the / didn't get inserted.

But I'll switch it over to list and that should make everything cleaner. Thanks!

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.

@fay-stripe
Copy link
Contributor Author

This build is taking a long time to start. I think I made the right changes though

ptal @brandur-stripe


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.

👍

headers: {},
});
});
it('Sends the correct request for charge 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.

Let's just remove this test case please. It's not actually exercising any new code that we've written.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@brandur-stripe brandur-stripe left a comment

Choose a reason for hiding this comment

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

Yes, that looks much better! A couple more minor comments, but looks good.

ptal @fay-stripe

@fay-stripe
Copy link
Contributor Author

Made those changes!
ptal @brandur-stripe

@brandur-stripe
Copy link
Contributor

LGTM. Thanks Fay!

@brandur-stripe brandur-stripe merged commit 3ef4d6c into master May 9, 2018
@brandur-stripe brandur-stripe deleted the fay/issfr branch May 9, 2018 23:10
@brandur-stripe
Copy link
Contributor

Released as 5.9.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants