Skip to content

Commit

Permalink
API: Add 'object' to the response on Deletion
Browse files Browse the repository at this point in the history
The goal is to be closer to Stripe API. Also, create a new DeletedObject class
that will be easier to use.
  • Loading branch information
feliixx committed Jul 7, 2023
1 parent cb071d2 commit 9ca1bba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 9 additions & 1 deletion localstripe/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def _api_delete(cls, id):
if key not in store.keys():
raise UserError(404, 'Not Found')
del store[key]
return {'deleted': True, 'id': id}
return DeletedObject(id, cls.object)

@classmethod
def _api_list_all(cls, url, limit=None, starting_after=None, **kwargs):
Expand Down Expand Up @@ -244,6 +244,14 @@ def do_expand(path, obj):
return obj


class DeletedObject(StripeObject):
deleted = True

def __init__(self, id, object):
self.id = id
self.object = object


class Balance(object):
object = 'balance'

Expand Down
3 changes: 1 addition & 2 deletions localstripe/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,7 @@ async def f(request):
def api_delete(cls, url):
def f(request):
id = request.match_info['id']
ret = cls._api_delete(id)
return json_response(ret if isinstance(ret, dict) else ret._export())
return json_response(cls._api_delete(id)._export())
return f


Expand Down

0 comments on commit 9ca1bba

Please sign in to comment.