Skip to content

Commit

Permalink
fix critical bug
Browse files Browse the repository at this point in the history
  • Loading branch information
GLEF1X committed Apr 4, 2021
1 parent 3ff6755 commit 99c6abb
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,18 @@ async def main():
print((await w.get_balance()).amount)


# Also you can use it like here
my_wallet = QiwiWrapper(
api_access_token='your_token',
phone_number='+phone_number'
)


async def main_2():
async with my_wallet as w:
print(await w.get_balance())


asyncio.run(main())
```

Expand Down
12 changes: 9 additions & 3 deletions examples/without_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@
)


async def old_usage():
print(await wallet.get_balance())
async def main():
async with QiwiWrapper(secret_p2p='my_p2p') as w:
w.public_p2p = 'my_public_p2p'
bill = await w.create_p2p_bill(amount=1)
# new version
new_status = await bill.check()
# old version
old_status = (await w.check_p2p_bill_status(bill.bill_id)) == 'PAID'


asyncio.run(old_usage())
asyncio.run(main())
1 change: 0 additions & 1 deletion glQiwiApi/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import abc
import asyncio
from itertools import repeat
from typing import Literal, Optional, Union, Dict, List, Tuple, Any, AsyncGenerator
Expand Down
3 changes: 2 additions & 1 deletion glQiwiApi/data_models/basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ def initialize(self, w: Any):
return self

async def check(self) -> bool:
return (await self._w.check_p2p_bill_status(bill_id=self.bill_id)) == 'PAID'
async with self._w:
return (await self._w.check_p2p_bill_status(bill_id=self.bill_id)) == 'PAID'


__all__ = [
Expand Down
8 changes: 4 additions & 4 deletions glQiwiApi/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ def __repr__(self) -> str:

def json(self) -> str:
import json
return json.dumps(
self._json_info, indent=2,
ensure_ascii=False
) if self._json_info is not None else self.__str__()

if isinstance(self._json_info, dict):
return json.dumps(self._json_info, indent=2, ensure_ascii=False)
return self.__str__()


__all__ = [
Expand Down

0 comments on commit 99c6abb

Please sign in to comment.