Implement transaction handling
This commit is contained in:
@@ -3,6 +3,9 @@ from pyotp import TOTP
|
||||
|
||||
from core.clients.base import BaseClient
|
||||
from core.clients.platform import LocalPlatformClient
|
||||
from core.util import logs
|
||||
|
||||
log = logs.get_logger("agora")
|
||||
|
||||
|
||||
class AgoraClient(LocalPlatformClient, BaseClient):
|
||||
@@ -20,15 +23,12 @@ class AgoraClient(LocalPlatformClient, BaseClient):
|
||||
"""
|
||||
print("CALLING RELEASE FUNDS", contact_id)
|
||||
if self.instance.dummy:
|
||||
self.log.error(
|
||||
f"Running in dummy mode, not releasing funds for {contact_id}"
|
||||
)
|
||||
log.error(f"Running in dummy mode, not releasing funds for {contact_id}")
|
||||
return
|
||||
payload = {"tradeId": contact_id, "password": self.sets.Pass}
|
||||
rtrn = await self.api._api_call(
|
||||
api_method=f"contact_release/{contact_id}",
|
||||
http_method="POST",
|
||||
query_values=payload,
|
||||
|
||||
rtrn = await self.api.contact_release(
|
||||
contact_id,
|
||||
self.instance.password,
|
||||
)
|
||||
|
||||
# Check if we can withdraw funds
|
||||
|
||||
@@ -88,7 +88,6 @@ class AgoraDesk:
|
||||
async with session.post(api_call_url, **cast) as response_raw:
|
||||
response = await response_raw.json()
|
||||
status_code = response_raw.status
|
||||
|
||||
else:
|
||||
cast["params"] = query_values
|
||||
async with aiohttp.ClientSession() as session:
|
||||
@@ -226,11 +225,23 @@ class AgoraDesk:
|
||||
)
|
||||
|
||||
# Todo:
|
||||
# post/trade/contact_release/{trade_id} • Release trade escrow
|
||||
# post/contact_fund/{trade_id} • Fund a trade
|
||||
# post/contact_dispute/{trade_id} • Start a trade dispute
|
||||
|
||||
# post/contact_mark_as_paid/{trade_id} • Mark a trade as paid
|
||||
|
||||
async def contact_release(self, trade_id: str, password: str) -> Dict[str, Any]:
|
||||
"""See Agoradesk API documentation.
|
||||
|
||||
https://agoradesk.com/api-docs/v1#operation/releaseEscrow
|
||||
"""
|
||||
payload = {"tradeId": trade_id, "password": password}
|
||||
return await self._api_call(
|
||||
api_method=f"contact_release/{trade_id}",
|
||||
http_method="POST",
|
||||
query_values=payload,
|
||||
)
|
||||
|
||||
async def contact_mark_as_paid(self, trade_id: str) -> Dict[str, Any]:
|
||||
"""See Agoradesk API.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user