Skip to content

Commit

Permalink
Merge pull request #684 from stripe/remi/codegen-4bd4c01
Browse files Browse the repository at this point in the history
Add support for the Payout Reverse API
  • Loading branch information
remi-stripe authored Oct 14, 2020
2 parents 15524a9 + 8c930df commit 314f75b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ cache:
env:
global:
# If changing this number, please also change it in `tests/conftest.py`.
- STRIPE_MOCK_VERSION=0.99.0
- STRIPE_MOCK_VERSION=0.101.0

before_install:
# Unpack and start stripe-mock so that the test suite can talk to it
Expand Down
7 changes: 7 additions & 0 deletions stripe/api_resources/payout.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@


@custom_method("cancel", http_verb="post")
@custom_method("reverse", http_verb="post")
class Payout(
CreateableAPIResource, ListableAPIResource, UpdateableAPIResource
):
Expand All @@ -18,3 +19,9 @@ def cancel(self, idempotency_key=None, **params):
headers = util.populate_headers(idempotency_key)
self.refresh_from(self.request("post", url, params, headers))
return self

def reverse(self, idempotency_key=None, **params):
url = self.instance_url() + "/reverse"
headers = util.populate_headers(idempotency_key)
self.refresh_from(self.request("post", url, params, headers))
return self
15 changes: 15 additions & 0 deletions tests/api_resources/test_payout.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,18 @@ def test_can_cancel_classmethod(self, request_mock):
"post", "/v1/payouts/%s/cancel" % TEST_RESOURCE_ID
)
assert isinstance(resource, stripe.Payout)

def test_can_reverse(self, request_mock):
payout = stripe.Payout.retrieve(TEST_RESOURCE_ID)
resource = payout.reverse()
request_mock.assert_requested(
"post", "/v1/payouts/%s/reverse" % TEST_RESOURCE_ID
)
assert isinstance(resource, stripe.Payout)

def test_can_reverse_classmethod(self, request_mock):
resource = stripe.Payout.reverse(TEST_RESOURCE_ID)
request_mock.assert_requested(
"post", "/v1/payouts/%s/reverse" % TEST_RESOURCE_ID
)
assert isinstance(resource, stripe.Payout)
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


# When changing this number, don't forget to change it in `.travis.yml` too.
MOCK_MINIMUM_VERSION = "0.99.0"
MOCK_MINIMUM_VERSION = "0.101.0"

# Starts stripe-mock if an OpenAPI spec override is found in `openapi/`, and
# otherwise fall back to `STRIPE_MOCK_PORT` or 12111.
Expand Down

0 comments on commit 314f75b

Please sign in to comment.