Show trades

This commit is contained in:
2023-03-10 00:23:05 +00:00
parent 1e7d8f6c8d
commit fa7ea66c65
12 changed files with 236 additions and 16 deletions

View File

@@ -28,6 +28,15 @@ class LocalPlatformClient(ABC):
async def connect(self):
self.api = AgoraDesk(self.instance.token)
async def call_method(self, method, *args, **kwargs):
"""
Call a method using the self.api object.
"""
if hasattr(self.api, method):
return await getattr(self.api, method)(*args, **kwargs)
else:
raise Exception(f"Method {method} not found in {self.name} API.")
# TODO: do in schedules
# def setup_loop(self):
# """
@@ -62,19 +71,18 @@ class LocalPlatformClient(ABC):
async def wrap_dashboard(self, dash=None): # backwards compatibility with TX
if not dash:
dash = await self.api.dashboard()
# dash = await self.api.dashboard()
dash = await self.call("dashboard")
print("DASH22", dash)
# if dash["response"] is None:
# return False
dash_tmp = {}
if not dash:
return False
if not dash["response"]:
return False
if "data" not in dash["response"]:
# log.error(f"Data not in dashboard response: {dash}")
return dash_tmp
if dash["response"]["data"]["contact_count"] > 0:
for contact in dash["response"]["data"]["contact_list"]:
if dash["contact_count"] > 0:
for contact in dash["contact_list"]:
contact_id = contact["data"]["contact_id"]
dash_tmp[contact_id] = contact
return dash_tmp

View File

@@ -6,7 +6,7 @@ from core.clients.platform import LocalPlatformClient
from core.lib.money import Money
class AgoraClient(BaseClient, LocalPlatformClient):
class AgoraClient(LocalPlatformClient, BaseClient):
"""
AgoraDesk API handler.
"""

View File

@@ -87,6 +87,7 @@ class AgoraDesk:
async with aiohttp.ClientSession() as session:
async with session.post(api_call_url, **cast) as response_raw:
response = await response_raw.json()
status_code = response_raw.status
else:
# response = httpx.get(url=api_call_url, headers=headers, params=query_values)
@@ -95,12 +96,15 @@ class AgoraDesk:
async with aiohttp.ClientSession() as session:
async with session.get(api_call_url, **cast) as response_raw:
response = await response_raw.json()
status_code = response_raw.status
if response:
print("YES RESPONSE", response)
logger.debug(response)
result["status"] = response.code
if response.code == 200:
result["status"] = status_code
if status_code == 200:
result["success"] = True
result["message"] = "OK"
result["response"] = response
else:
result["message"] = "API ERROR"