adrienverge / localstripe

A fake but stateful Stripe server that you can run locally, for testing purposes.
GNU General Public License v3.0
196 stars 58 forks source link

Charge: Add `customer` and `created` to the list API #140

Closed H--o-l closed 4 years ago

H--o-l commented 4 years ago

Made from Stripe documentation: https://stripe.com/docs/api/charges/list#list_charges-customer


This PR is based on top of the other PR https://github.com/adrienverge/localstripe/pull/141

H--o-l commented 4 years ago

Hey Adrien!

Thanks for the feedback. I became aware this morning that I didn't implement the action of the created : {'gt': timestamp} parameter, thus I add three lines of code, and retested it:

@@ -500,6 +498,9 @@ class Charge(StripeObject):

         li = super(Charge, cls)._api_list_all(url, limit=limit)
         li._list = [c for c in li._list if c.customer == customer]
+        if created.get('gt'):
+            li._list = [c for c in li._list
+                        if c.created > try_convert_to_int(created['gt'])]
         return li

I also rebase the PR since you merge https://github.com/adrienverge/localstripe/pull/141 (thanks!)

H--o-l commented 4 years ago

Thanks!