Skip to content

Commit

Permalink
Пример закрытия сессии после выполнения кода
Browse files Browse the repository at this point in the history
  • Loading branch information
bl4ckm45k committed Oct 24, 2023
1 parent 67f12fe commit cc8906e
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 10 deletions.
19 changes: 19 additions & 0 deletions aioabcpapi/ts/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,25 @@ async def get_list(self, contractor_ids: Union[int, str, List[int]] = None,
date_start: Union[datetime, str] = None, date_end: Union[datetime, str] = None,
credit_limit: Union[float, int] = None,
limit: int = None, skip: int = None):
"""
:param contractor_ids:
:param contractor_requisite_ids:
:param shop_requisite_ids:
:param is_active:
:param is_delete:
:param is_default:
:param agreement_type:
:param relation_type:
:param number:
:param currency:
:param date_start:
:param date_end:
:param credit_limit:
:param limit:
:param skip:
:return:
"""
if isinstance(date_start, datetime):
date_start = generate(date_start.replace(tzinfo=pytz.utc))
if isinstance(date_end, datetime):
Expand Down
9 changes: 8 additions & 1 deletion examples/basket_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,11 @@ async def get_basket_params():


if __name__ == '__main__':
asyncio.run(get_basket_params())
# Необходимо только в Windows для избежания RuntimeError
# asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

loop = asyncio.new_event_loop()
try:
loop.run_until_complete(get_basket_params())
finally:
loop.run_until_complete(api.close())
10 changes: 9 additions & 1 deletion examples/customer_complaint.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,12 @@ async def update_complaint(path_to_file):
if __name__ == '__main__':
cwd = os.getcwd()
path_to_some_file = f'{cwd}/files/some_file.txt'
asyncio.run(update_complaint(path_to_some_file))

# Необходимо только в Windows для избежания RuntimeError
# asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

loop = asyncio.new_event_loop()
try:
loop.run_until_complete(update_complaint(path_to_some_file))
finally:
loop.run_until_complete(api.close())
11 changes: 9 additions & 2 deletions examples/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,12 @@ async def not_enough_rights(update_start, update_end):
if __name__ == '__main__':
date_start = datetime.datetime.now() - datetime.timedelta(days=3)
date_end = datetime.datetime.now()
asyncio.run(orders_list(update_start=date_start, update_end=date_end))
# asyncio.run(not_enough_rights(update_start=date_start, update_end=date_end))

# Необходимо только в Windows для избежания RuntimeError
# asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

loop = asyncio.new_event_loop()
try:
loop.run_until_complete(orders_list(update_start=date_start, update_end=date_end))
finally:
loop.run_until_complete(api.close())
9 changes: 8 additions & 1 deletion examples/manager_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,11 @@ async def update_manager(id, first_name, last_name, sip):


if __name__ == '__main__':
asyncio.run(update_manager(id=25119353, first_name='test_first', last_name='test_last', sip=312))
# Необходимо только в Windows для избежания RuntimeError
# asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

loop = asyncio.new_event_loop()
try:
loop.run_until_complete(update_manager(id=25119353, first_name='test_first', last_name='test_last', sip=312))
finally:
loop.run_until_complete(api.close())
9 changes: 8 additions & 1 deletion examples/payment_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,11 @@ async def get_payments_link(order_number: int, client_id: int, amount: int):


if __name__ == '__main__':
asyncio.run(get_payments_link(order_number=118668754, client_id=6679745, amount=10000))
# Необходимо только в Windows для избежания RuntimeError
# asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

loop = asyncio.new_event_loop()
try:
loop.run_until_complete(get_payments_link(order_number=118668754, client_id=6679745, amount=10000))
finally:
loop.run_until_complete(api.close())
9 changes: 8 additions & 1 deletion examples/profile_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,11 @@ async def edit_profile():


if __name__ == '__main__':
asyncio.run(edit_profile())
# Необходимо только в Windows для избежания RuntimeError
# asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

loop = asyncio.new_event_loop()
try:
loop.run_until_complete(edit_profile())
finally:
loop.run_until_complete(api.close())
10 changes: 7 additions & 3 deletions examples/search_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ async def advices_batch():


if __name__ == '__main__':
# Необходимо только в Windows для избежания RuntimeError
# asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

loop = asyncio.new_event_loop()
try:
asyncio.run(advices_batch())
except RuntimeError:
pass
loop.run_until_complete(advices_batch())
finally:
loop.run_until_complete(api.close())

0 comments on commit cc8906e

Please sign in to comment.