Format the return from AgoraDesk better
This commit is contained in:
parent
ef9e958467
commit
20b0aef97d
|
@ -32,11 +32,45 @@ class Agora(object):
|
||||||
|
|
||||||
def dashboard(self):
|
def dashboard(self):
|
||||||
dash = self.agora.dashboard_seller()
|
dash = self.agora.dashboard_seller()
|
||||||
return dash
|
dash_tmp = {}
|
||||||
|
if dash["response"]["data"]["contact_count"] > 0:
|
||||||
|
for contact in dash["response"]["data"]["contact_list"]:
|
||||||
|
contact_id = contact["data"]["contact_id"]
|
||||||
|
buyer = contact["data"]["buyer"]["username"]
|
||||||
|
seller = contact["data"]["seller"]["username"]
|
||||||
|
amount = contact["data"]["amount"]
|
||||||
|
amount_xmr = contact["data"]["amount_xmr"]
|
||||||
|
fee_xmr = contact["data"]["fee_xmr"]
|
||||||
|
currency = contact["data"]["currency"]
|
||||||
|
if not contact["data"]["is_selling"]:
|
||||||
|
continue
|
||||||
|
dash_tmp[contact_id] = {
|
||||||
|
"buyer": buyer,
|
||||||
|
"seller": seller,
|
||||||
|
"amount": amount,
|
||||||
|
"amount_xmr": amount_xmr,
|
||||||
|
"fee_xmr": fee_xmr,
|
||||||
|
"currency": currency,
|
||||||
|
}
|
||||||
|
|
||||||
|
return dash_tmp
|
||||||
|
|
||||||
def get_messages(self, contact_id):
|
def get_messages(self, contact_id):
|
||||||
messages = self.agora.contact_messages(contact_id)
|
messages = self.agora.contact_messages(contact_id)
|
||||||
return messages
|
messages_tmp = []
|
||||||
|
for message in messages["response"]["data"]["message_list"]:
|
||||||
|
print("MESSAGE", message["sender"]["username"], message["msg"])
|
||||||
|
messages_tmp.append(f"({message['sender']['username']}): {message['msg']}")
|
||||||
|
return messages_tmp
|
||||||
|
|
||||||
|
def get_all_messages(self):
|
||||||
|
dash = self.dashboard()
|
||||||
|
messages_tmp = {}
|
||||||
|
for contact_id in dash:
|
||||||
|
messages = self.get_messages(contact_id)
|
||||||
|
messages_tmp[contact_id] = messages
|
||||||
|
|
||||||
|
return messages_tmp
|
||||||
|
|
||||||
def get_ads(self):
|
def get_ads(self):
|
||||||
ads = self.agora.ads()
|
ads = self.agora.ads()
|
||||||
|
@ -48,6 +82,10 @@ class Agora(object):
|
||||||
|
|
||||||
def create_ad(self, countrycode, currency):
|
def create_ad(self, countrycode, currency):
|
||||||
rates = self.get_rates_all()
|
rates = self.get_rates_all()
|
||||||
|
if currency == "USD":
|
||||||
|
min_amount = float(settings.Agora.MinUSD)
|
||||||
|
max_amount = float(settings.Agora.MaxUSD)
|
||||||
|
else:
|
||||||
min_amount = rates[currency] * float(settings.Agora.MinUSD)
|
min_amount = rates[currency] * float(settings.Agora.MinUSD)
|
||||||
max_amount = rates[currency] * float(settings.Agora.MaxUSD)
|
max_amount = rates[currency] * float(settings.Agora.MaxUSD)
|
||||||
price_formula = f"coingeckoxmrusd*usd{currency.lower()}*{settings.Agora.Margin}"
|
price_formula = f"coingeckoxmrusd*usd{currency.lower()}*{settings.Agora.Margin}"
|
||||||
|
|
Loading…
Reference in New Issue