|
|
|
@ -17,9 +17,7 @@ __copyright__ = "(C) 2021 https://codeberg.org/MarvinsCryptoTools/agoradesk_py"
|
|
|
|
|
__version__ = "0.1.0"
|
|
|
|
|
|
|
|
|
|
# set logging
|
|
|
|
|
logging.basicConfig(
|
|
|
|
|
level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
|
|
|
|
)
|
|
|
|
|
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
|
|
|
|
|
logging.getLogger("requests.packages.urllib3").setLevel(logging.INFO)
|
|
|
|
|
logging.getLogger("urllib3.connectionpool").setLevel(logging.INFO)
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
@ -60,8 +58,7 @@ class AgoraDesk:
|
|
|
|
|
|
|
|
|
|
headers = {
|
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
|
"User-Agent": f"agoradesk_py/{__version__} "
|
|
|
|
|
f"https://codeberg.org/MarvinsCryptoTools/agoradesk_py",
|
|
|
|
|
"User-Agent": f"agoradesk_py/{__version__} " f"https://codeberg.org/MarvinsCryptoTools/agoradesk_py",
|
|
|
|
|
"Authorization": self.api_key,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -94,9 +91,7 @@ class AgoraDesk:
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
response = httpx.get(
|
|
|
|
|
url=api_call_url, headers=headers, params=query_values
|
|
|
|
|
)
|
|
|
|
|
response = httpx.get(url=api_call_url, headers=headers, params=query_values)
|
|
|
|
|
|
|
|
|
|
logger.debug(response)
|
|
|
|
|
result["response"] = json.loads(response.text)
|
|
|
|
@ -220,9 +215,7 @@ class AgoraDesk:
|
|
|
|
|
# ===========================
|
|
|
|
|
|
|
|
|
|
# post/feedback/{username} • Give feedback to a user
|
|
|
|
|
def feedback(
|
|
|
|
|
self, username: str, feedback: str, msg: Optional[str]
|
|
|
|
|
) -> Dict[str, Any]:
|
|
|
|
|
def feedback(self, username: str, feedback: str, msg: Optional[str]) -> Dict[str, Any]:
|
|
|
|
|
"""See Agoradesk API.
|
|
|
|
|
|
|
|
|
|
https://agoradesk.com/api-docs/v1#operation/setUserFeedback
|
|
|
|
@ -248,9 +241,7 @@ class AgoraDesk:
|
|
|
|
|
|
|
|
|
|
https://agoradesk.com/api-docs/v1#operation/markPaid
|
|
|
|
|
"""
|
|
|
|
|
return self._api_call(
|
|
|
|
|
api_method=f"contact_mark_as_paid/{trade_id}", http_method="POST"
|
|
|
|
|
)
|
|
|
|
|
return self._api_call(api_method=f"contact_mark_as_paid/{trade_id}", http_method="POST")
|
|
|
|
|
|
|
|
|
|
# post/contact_cancel/{trade_id} • Cancel the trade
|
|
|
|
|
def contact_cancel(
|
|
|
|
@ -270,9 +261,7 @@ class AgoraDesk:
|
|
|
|
|
# post/contact_escrow/{trade_id} • Enable escrow
|
|
|
|
|
|
|
|
|
|
# get/contact_messages/{trade_id} • Get trade messages
|
|
|
|
|
def contact_messages(
|
|
|
|
|
self, trade_id: str, after: Optional[arrow.Arrow] = None
|
|
|
|
|
) -> Dict[str, Any]:
|
|
|
|
|
def contact_messages(self, trade_id: str, after: Optional[arrow.Arrow] = None) -> Dict[str, Any]:
|
|
|
|
|
"""See Agoradesk API.
|
|
|
|
|
|
|
|
|
|
https://agoradesk.com/api-docs/v1#operation/getTradeMessages
|
|
|
|
@ -327,9 +316,7 @@ class AgoraDesk:
|
|
|
|
|
|
|
|
|
|
# Todo: Add image upload functionality
|
|
|
|
|
# post/contact_message_post/{trade_id} • Send a chat message/attachment
|
|
|
|
|
def contact_message_post(
|
|
|
|
|
self, trade_id: str, msg: Optional[str] = None
|
|
|
|
|
) -> Dict[str, Any]:
|
|
|
|
|
def contact_message_post(self, trade_id: str, msg: Optional[str] = None) -> Dict[str, Any]:
|
|
|
|
|
"""See Agoradesk API.
|
|
|
|
|
|
|
|
|
|
https://agoradesk.com/api-docs/v1#operation/sendChatMessage
|
|
|
|
@ -479,9 +466,7 @@ class AgoraDesk:
|
|
|
|
|
if track_max_amount:
|
|
|
|
|
params["track_max_amount"] = 1 if track_max_amount else 0
|
|
|
|
|
if require_trusted_by_advertiser:
|
|
|
|
|
params["require_trusted_by_advertiser"] = (
|
|
|
|
|
1 if require_trusted_by_advertiser else 0
|
|
|
|
|
)
|
|
|
|
|
params["require_trusted_by_advertiser"] = 1 if require_trusted_by_advertiser else 0
|
|
|
|
|
if verified_email_required:
|
|
|
|
|
params["verified_email_required"] = 1 if verified_email_required else 0
|
|
|
|
|
if online_provider:
|
|
|
|
@ -652,8 +637,7 @@ class AgoraDesk:
|
|
|
|
|
params = self._generic_search_parameters(amount, page)
|
|
|
|
|
|
|
|
|
|
return self._api_call(
|
|
|
|
|
api_method=f"{direction}-{main_currency}-online/"
|
|
|
|
|
f"{exchange_currency}{add_to_api_method}",
|
|
|
|
|
api_method=f"{direction}-{main_currency}-online/" f"{exchange_currency}{add_to_api_method}",
|
|
|
|
|
query_values=params,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -796,8 +780,7 @@ class AgoraDesk:
|
|
|
|
|
params = self._generic_search_parameters(amount, page)
|
|
|
|
|
|
|
|
|
|
return self._api_call(
|
|
|
|
|
api_method=f"{direction}-{main_currency}-with-cash/"
|
|
|
|
|
f"{exchange_currency}/{country_code}/{lat}/{lon}",
|
|
|
|
|
api_method=f"{direction}-{main_currency}-with-cash/" f"{exchange_currency}/{country_code}/{lat}/{lon}",
|
|
|
|
|
query_values=params,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -912,9 +895,7 @@ class AgoraDesk:
|
|
|
|
|
# Statistics related API Methods
|
|
|
|
|
# ==============================
|
|
|
|
|
|
|
|
|
|
def moneroaverage(
|
|
|
|
|
self, currency: Optional[str] = "ticker-all-currencies"
|
|
|
|
|
) -> Dict[str, Any]:
|
|
|
|
|
def moneroaverage(self, currency: Optional[str] = "ticker-all-currencies") -> Dict[str, Any]:
|
|
|
|
|
"""See Agoradesk API.
|
|
|
|
|
|
|
|
|
|
https://agoradesk.com/api-docs/v1#operation/getXmrTicker and
|
|
|
|
@ -1004,9 +985,7 @@ class AgoraDesk:
|
|
|
|
|
if otp:
|
|
|
|
|
params["otp"] = otp
|
|
|
|
|
|
|
|
|
|
return self._api_call(
|
|
|
|
|
api_method="wallet-send", http_method="POST", query_values=params
|
|
|
|
|
)
|
|
|
|
|
return self._api_call(api_method="wallet-send", http_method="POST", query_values=params)
|
|
|
|
|
|
|
|
|
|
def wallet_send_xmr(
|
|
|
|
|
self,
|
|
|
|
@ -1031,6 +1010,4 @@ class AgoraDesk:
|
|
|
|
|
if otp:
|
|
|
|
|
params["otp"] = otp
|
|
|
|
|
|
|
|
|
|
return self._api_call(
|
|
|
|
|
api_method="wallet-send/XMR", http_method="POST", query_values=params
|
|
|
|
|
)
|
|
|
|
|
return self._api_call(api_method="wallet-send/XMR", http_method="POST", query_values=params)
|
|
|
|
|