Skip to content

Commit

Permalink
Make operations list explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
ob-stripe committed Oct 18, 2017
1 parent e71181c commit 872b354
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
12 changes: 9 additions & 3 deletions stripe/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def nested_resource_class_methods(resource, path=None, operations=None):
if path is None:
path = "%ss" % resource
if operations is None:
operations = ['create', 'retrieve', 'update', 'delete', 'list']
raise ValueError("operations list required")

def wrapper(cls):
def nested_resource_url(cls, id, nested_id=None):
Expand Down Expand Up @@ -615,7 +615,10 @@ def delete(self, **params):


# API objects
@nested_resource_class_methods('external_account')
@nested_resource_class_methods(
'external_account',
operations=['create', 'retrieve', 'update', 'delete', 'list']
)
@nested_resource_class_methods('login_link', operations=['create'])
class Account(CreateableAPIResource, ListableAPIResource,
UpdateableAPIResource, DeletableAPIResource):
Expand Down Expand Up @@ -865,7 +868,10 @@ def close(self, idempotency_key=None):
return self


@nested_resource_class_methods('source')
@nested_resource_class_methods(
'source',
operations=['create', 'retrieve', 'update', 'delete', 'list']
)
class Customer(CreateableAPIResource, UpdateableAPIResource,
ListableAPIResource, DeletableAPIResource):

Expand Down
5 changes: 4 additions & 1 deletion stripe/test/resources/test_api_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ def test_retrieve(self):


class NestedResourceClassMethodsTests(StripeApiTestCase):
@stripe.resource.nested_resource_class_methods('nested')
@stripe.resource.nested_resource_class_methods(
'nested',
operations=['create', 'retrieve', 'update', 'delete', 'list']
)
class MainResource(stripe.resource.APIResource):
pass

Expand Down

0 comments on commit 872b354

Please sign in to comment.