@ -74,7 +74,6 @@ class LocalPlatformClient(ABC):
# dash = await self.api.dashboard()
# dash = await self.api.dashboard()
dash = await self . call ( " dashboard " )
dash = await self . call ( " dashboard " )
print ( " DASH22 " , dash )
# if dash["response"] is None:
# if dash["response"] is None:
# return False
# return False
dash_tmp = { }
dash_tmp = { }
@ -110,9 +109,9 @@ class LocalPlatformClient(ABC):
# reference = db.tx_to_ref(contact_id)
# reference = db.tx_to_ref(contact_id)
# buyer = contact["data"]["buyer"]["username"]
# buyer = contact["data"]["buyer"]["username"]
# amount = contact["data"]["amount"]
# amount = contact["data"]["amount"]
# if self. platform == "agora":
# if self. name == "agora":
# asset = contact["data"]["advertisement"]["asset"]
# asset = contact["data"]["advertisement"]["asset"]
# elif self. platform == "lbtc":
# elif self. name == "lbtc":
# asset = "BTC"
# asset = "BTC"
# if asset == "XMR":
# if asset == "XMR":
# amount_crypto = contact["data"]["amount_xmr"]
# amount_crypto = contact["data"]["amount_xmr"]
@ -124,7 +123,7 @@ class LocalPlatformClient(ABC):
# continue
# continue
# rtrn.append(
# rtrn.append(
# (
# (
# f"[#] [{reference}] ({self. platform }) <{buyer}>"
# f"[#] [{reference}] ({self. name }) <{buyer}>"
# f" {amount}{currency} {provider} {amount_crypto}{asset}"
# f" {amount}{currency} {provider} {amount_crypto}{asset}"
# )
# )
# )
# )
@ -146,9 +145,9 @@ class LocalPlatformClient(ABC):
current_trades . append ( reference )
current_trades . append ( reference )
buyer = contact [ " data " ] [ " buyer " ] [ " username " ]
buyer = contact [ " data " ] [ " buyer " ] [ " username " ]
amount = contact [ " data " ] [ " amount " ]
amount = contact [ " data " ] [ " amount " ]
if self . platform == " agora " :
if self . name == " agora " :
asset = contact [ " data " ] [ " advertisement " ] [ " asset " ]
asset = contact [ " data " ] [ " advertisement " ] [ " asset " ]
elif self . platform == " lbtc " :
elif self . name == " lbtc " :
asset = " BTC "
asset = " BTC "
provider = contact [ " data " ] [ " advertisement " ] [ " payment_method " ]
provider = contact [ " data " ] [ " advertisement " ] [ " payment_method " ]
if asset == " XMR " :
if asset == " XMR " :
@ -160,7 +159,7 @@ class LocalPlatformClient(ABC):
continue
continue
if reference not in self . last_dash :
if reference not in self . last_dash :
reference = await self . new_trade (
reference = await self . new_trade (
self . platform ,
self . name ,
asset ,
asset ,
contact_id ,
contact_id ,
buyer ,
buyer ,
@ -175,7 +174,7 @@ class LocalPlatformClient(ABC):
# Let us know there is a new trade
# Let us know there is a new trade
title = " New trade "
title = " New trade "
message = (
message = (
f " [#] [ { reference } ] ( { self . platform } ) < { buyer } > "
f " [#] [ { reference } ] ( { self . name } ) < { buyer } > "
f " { amount } { currency } { provider } { amount_crypto } { asset } "
f " { amount } { currency } { provider } { amount_crypto } { asset } "
)
)
await notify . sendmsg ( self . instance . user , message , title = title )
await notify . sendmsg ( self . instance . user , message , title = title )
@ -188,7 +187,7 @@ class LocalPlatformClient(ABC):
self . last_dash . remove ( ref )
self . last_dash . remove ( ref )
if reference and reference not in current_trades :
if reference and reference not in current_trades :
current_trades . append ( reference )
current_trades . append ( reference )
messages = await db . cleanup ( self . platform , current_trades )
messages = await db . cleanup ( self . name , current_trades )
for message in messages :
for message in messages :
await notify . sendmsg ( self . instance . user , message , title = " Cleanup " )
await notify . sendmsg ( self . instance . user , message , title = " Cleanup " )
@ -225,7 +224,7 @@ class LocalPlatformClient(ABC):
if reference in self . last_messages :
if reference in self . last_messages :
if not [ user , message ] in self . last_messages [ reference ] :
if not [ user , message ] in self . last_messages [ reference ] :
self . irc . sendmsg (
self . irc . sendmsg (
f " [ { reference } ] ( { self . platform } ) < { user } > { message } "
f " [ { reference } ] ( { self . name } ) < { user } > { message } "
)
)
# Append sent messages to last_messages so we don't send
# Append sent messages to last_messages so we don't send
# them again
# them again
@ -234,7 +233,7 @@ class LocalPlatformClient(ABC):
self . last_messages [ reference ] = [ [ user , message ] ]
self . last_messages [ reference ] = [ [ user , message ] ]
for x in messages_tmp [ reference ] :
for x in messages_tmp [ reference ] :
self . irc . sendmsg (
self . irc . sendmsg (
f " [ { reference } ] ( { self . platform } ) < { user } > { message } "
f " [ { reference } ] ( { self . name } ) < { user } > { message } "
)
)
# Purge old trades from cache
# Purge old trades from cache
@ -245,7 +244,7 @@ class LocalPlatformClient(ABC):
return messages_tmp
return messages_tmp
async def enum_ad_ids ( self , page = 0 ) :
async def enum_ad_ids ( self , page = 0 ) :
if self . platform == " lbtc " and page == 0 :
if self . name == " lbtc " and page == 0 :
page = 1
page = 1
ads = await self . api . ads ( page = page )
ads = await self . api . ads ( page = page )
# ads = await self.api._api_call(api_method="ads", query_values={"page": page})
# ads = await self.api._api_call(api_method="ads", query_values={"page": page})
@ -269,7 +268,7 @@ class LocalPlatformClient(ABC):
return ads_total
return ads_total
async def enum_ads ( self , requested_asset = None , page = 0 ) :
async def enum_ads ( self , requested_asset = None , page = 0 ) :
if self . platform == " lbtc " and page == 0 :
if self . name == " lbtc " and page == 0 :
page = 1
page = 1
query_values = { " page " : page }
query_values = { " page " : page }
if requested_asset :
if requested_asset :
@ -284,9 +283,9 @@ class LocalPlatformClient(ABC):
if not ads [ " response " ] :
if not ads [ " response " ] :
return False
return False
for ad in ads [ " response " ] [ " data " ] [ " ad_list " ] :
for ad in ads [ " response " ] [ " data " ] [ " ad_list " ] :
if self . platform == " agora " :
if self . name == " agora " :
asset = ad [ " data " ] [ " asset " ]
asset = ad [ " data " ] [ " asset " ]
elif self . platform == " lbtc " :
elif self . name == " lbtc " :
asset = " BTC "
asset = " BTC "
ad_id = ad [ " data " ] [ " ad_id " ]
ad_id = ad [ " data " ] [ " ad_id " ]
country = ad [ " data " ] [ " countrycode " ]
country = ad [ " data " ] [ " countrycode " ]
@ -330,7 +329,7 @@ class LocalPlatformClient(ABC):
return sec_ago_date < 172800
return sec_ago_date < 172800
async def enum_public_ads ( self , asset , currency , providers = None , page = 0 ) :
async def enum_public_ads ( self , asset , currency , providers = None , page = 0 ) :
if self . platform == " lbtc " and page == 0 :
if self . name == " lbtc " and page == 0 :
page = 1
page = 1
to_return = [ ]
to_return = [ ]
# if asset == "XMR":
# if asset == "XMR":
@ -363,7 +362,7 @@ class LocalPlatformClient(ABC):
return False
return False
for ad in ads [ " response " ] [ " data " ] [ " ad_list " ] :
for ad in ads [ " response " ] [ " data " ] [ " ad_list " ] :
provider = ad [ " data " ] [ " online_provider " ]
provider = ad [ " data " ] [ " online_provider " ]
if self . platform == " lbtc " :
if self . name == " lbtc " :
provider_test = self . map_provider ( provider )
provider_test = self . map_provider ( provider )
else :
else :
provider_test = provider
provider_test = provider
@ -423,7 +422,7 @@ class LocalPlatformClient(ABC):
return False
return False
# Get the ads to update
# Get the ads to update
to_update = self . get_new_ad_equations ( self . platform , public_ads , assets )
to_update = self . get_new_ad_equations ( self . name , public_ads , assets )
await self . slow_ad_update ( to_update )
await self . slow_ad_update ( to_update )
async def get_all_public_ads ( self , assets = None , currencies = None , providers = None ) :
async def get_all_public_ads ( self , assets = None , currencies = None , providers = None ) :
@ -438,18 +437,11 @@ class LocalPlatformClient(ABC):
" BTC " : " bitcoin " ,
" BTC " : " bitcoin " ,
}
}
if not assets :
assets = assets or self . instance . ads_assets
assets = self . get_all_assets ( self . platform )
# Get all currencies we have ads for, deduplicated
# Get all currencies we have ads for, deduplicated
if not currencies :
currencies = self . get_all_currencies ( self . platform )
providers = providers or self . instance . ads_providers
if not providers :
currencies = currencies or self . instance . currencies
providers = self . get_all_providers ( self . platform )
sinks_currencies = self . currencies
supported_currencies = [
currency for currency in currencies if currency in sinks_currencies
]
currencies = supported_currencies
# We want to get the ads for each of these currencies and return the result
# We want to get the ads for each of these currencies and return the result
rates = await money . cg . get_price (
rates = await money . cg . get_price (
ids = [ " monero " , " bitcoin " ] , vs_currencies = currencies
ids = [ " monero " , " bitcoin " ] , vs_currencies = currencies
@ -466,7 +458,7 @@ class LocalPlatformClient(ABC):
if not ads_list :
if not ads_list :
log . debug ( " Error getting ads list. " )
log . debug ( " Error getting ads list. " )
continue
continue
ads = await money . lookup_rates ( self . platform , ads_list , rates = rates )
ads = await money . lookup_rates ( self . name , ads_list , rates = rates )
if not ads :
if not ads :
log . debug ( " Error lookup up rates. " )
log . debug ( " Error lookup up rates. " )
continue
continue
@ -493,7 +485,7 @@ class LocalPlatformClient(ABC):
" margin " : ad [ 6 ] ,
" margin " : ad [ 6 ] ,
" ts " : str ( datetime . now ( ) . isoformat ( ) ) ,
" ts " : str ( datetime . now ( ) . isoformat ( ) ) ,
" xtype " : msgtype ,
" xtype " : msgtype ,
" market " : self . platform ,
" market " : self . name ,
" type " : " platform " ,
" type " : " platform " ,
" user_id " : self . instance . user . id ,
" user_id " : self . instance . user . id ,
" platform_id " : self . instance . id ,
" platform_id " : self . instance . id ,
@ -568,6 +560,7 @@ class LocalPlatformClient(ABC):
currency ,
currency ,
provider ,
provider ,
payment_details ,
payment_details ,
ad ,
visible = None ,
visible = None ,
edit = False ,
edit = False ,
ad_id = None ,
ad_id = None ,
@ -590,19 +583,26 @@ class LocalPlatformClient(ABC):
if payment_details :
if payment_details :
payment_details_text = self . format_payment_details (
payment_details_text = self . format_payment_details (
currency , payment_details
currency ,
payment_details ,
ad ,
)
)
ad_text = self . format_ad ( asset , currency , payment_details_text )
ad_text = self . format_ad ( asset , currency , payment_details_text , ad )
min_amount , max_amount = money . get_minmax ( self . platform , asset , currency )
min_amount , max_amount = await money . get_minmax (
if self . platform == " lbtc " :
self . instance . min_trade_size_usd ,
self . instance . max_trade_size_usd ,
asset ,
currency ,
)
if self . name == " lbtc " :
bank_name = payment_details [ " bank " ]
bank_name = payment_details [ " bank " ]
# if self.platform == "agora":
# if self. name == "agora":
price_formula = (
price_formula = (
f " coingecko { asset . lower ( ) } usd* "
f " coingecko { asset . lower ( ) } usd* "
f " usd { currency . lower ( ) } * { self . instance . margin } "
f " usd { currency . lower ( ) } * { self . instance . margin } "
)
)
# elif self. platform == "lbtc":
# elif self. name == "lbtc":
# price_formula = f"btc_in_usd*{self.instance.margin}*USD_in_{currency}"
# price_formula = f"btc_in_usd*{self.instance.margin}*USD_in_{currency}"
form = {
form = {
@ -616,13 +616,12 @@ class LocalPlatformClient(ABC):
" online_provider " : provider ,
" online_provider " : provider ,
" require_feedback_score " : 0 ,
" require_feedback_score " : 0 ,
}
}
if self . platform == " agora " :
if self . name == " agora " :
form [ " asset " ] = asset
form [ " asset " ] = asset
form [ " payment_method_details " ] = " Revolut "
form [ " payment_method_details " ] = ad . payment_method_details
form [ " online_provider " ] = provider
form [ " online_provider " ] = provider
elif self . platform == " lbtc " :
elif self . name == " lbtc " :
form [ " online_provider " ] = self . map_provider ( provider , reverse = True )
form [ " online_provider " ] = self . map_provider ( provider , reverse = True )
if visible is False :
if visible is False :
form [ " visible " ] = False
form [ " visible " ] = False
elif visible is True :
elif visible is True :
@ -632,27 +631,28 @@ class LocalPlatformClient(ABC):
form [ " msg " ] = ad_text
form [ " msg " ] = ad_text
form [ " min_amount " ] = round ( min_amount , 2 )
form [ " min_amount " ] = round ( min_amount , 2 )
form [ " max_amount " ] = round ( max_amount , 2 )
form [ " max_amount " ] = round ( max_amount , 2 )
if self . platform == " lbtc " :
if self . name == " lbtc " :
form [ " bank_name " ] = bank_name
form [ " bank_name " ] = bank_name
if edit :
if edit :
ad = await self . api . ad ( ad_id = ad_id , * * form )
ad = await self . api . ad ( ad_id = ad_id , * * form )
else :
else :
ad = await self . api . ad_create ( * * form )
ad = await self . api . ad_create ( * * form )
return ad
return ad
async def dist_countries ( self , filter_asset= None ) :
async def dist_countries ( self , ad, filter_asset= None ) :
"""
"""
Distribute our advert into all countries and providers listed in the config .
Distribute our advert into all countries and providers listed in the config .
Exits on errors .
Exits on errors .
: return : False or dict with response
: return : False or dict with response
: rtype : bool or dict
: rtype : bool or dict
"""
"""
dist_list = list ( self . create_distribution_list ( self . platform , filter_asset ) )
dist_list = list ( self . create_distribution_list ( self . name, ad , filter_asset ) )
our_ads = await self . enum_ads ( )
our_ads = await self . enum_ads ( )
(
(
supported_currencies ,
supported_currencies ,
account_info ,
account_info ,
) = self . get_valid_account_details ( self . platform )
) = self . get_valid_account_details ( self . name )
# Let's get rid of the ad IDs and make it a tuple like dist_list
# Let's get rid of the ad IDs and make it a tuple like dist_list
our_ads = [ ( x [ 0 ] , x [ 2 ] , x [ 3 ] , x [ 4 ] ) for x in our_ads ]
our_ads = [ ( x [ 0 ] , x [ 2 ] , x [ 3 ] , x [ 4 ] ) for x in our_ads ]
if not our_ads :
if not our_ads :
@ -669,6 +669,8 @@ class LocalPlatformClient(ABC):
currency ,
currency ,
provider ,
provider ,
payment_details = account_info [ currency ] ,
payment_details = account_info [ currency ] ,
ad = ad ,
visible = ad . visible ,
)
)
# Bail on first error, let's not continue
# Bail on first error, let's not continue
if rtrn is False :
if rtrn is False :
@ -676,7 +678,7 @@ class LocalPlatformClient(ABC):
to_return . append ( rtrn )
to_return . append ( rtrn )
return to_return
return to_return
async def redist_countries ( self ):
async def redist_countries ( self , ad ):
"""
"""
Redistribute our advert details into all our listed adverts .
Redistribute our advert details into all our listed adverts .
This will edit all ads and update the details . Only works if we have already
This will edit all ads and update the details . Only works if we have already
@ -690,12 +692,16 @@ class LocalPlatformClient(ABC):
(
(
supported_currencies ,
supported_currencies ,
account_info ,
account_info ,
) = self . get_valid_account_details ( self . platform )
) = self . get_valid_account_details ( self . name )
if not our_ads :
if not our_ads :
log . error ( " Could not get our ads. " )
log . error ( " Could not get our ads. " )
return False
return False
to_return = [ ]
to_return = [ ]
for asset , ad_id , countrycode , currency , provider in our_ads :
for asset , ad_id , countrycode , currency , provider in our_ads :
if asset not in self . instance . ads_assets :
continue
if provider not in self . instance . ads_providers :
continue
if currency in supported_currencies :
if currency in supported_currencies :
rtrn = await self . create_ad (
rtrn = await self . create_ad (
asset ,
asset ,
@ -703,6 +709,8 @@ class LocalPlatformClient(ABC):
currency ,
currency ,
provider ,
provider ,
payment_details = account_info [ currency ] ,
payment_details = account_info [ currency ] ,
ad = ad ,
visible = ad . visible ,
edit = True ,
edit = True ,
ad_id = ad_id ,
ad_id = ad_id ,
)
)
@ -907,7 +915,7 @@ class LocalPlatformClient(ABC):
f " When sending the payment please use reference code: { reference } " ,
f " When sending the payment please use reference code: { reference } " ,
)
)
async def send_bank_details ( self , platform , currency , trade_id ):
async def send_bank_details ( self , platform , currency , trade_id , ad ):
"""
"""
Send the bank details to a trade .
Send the bank details to a trade .
"""
"""
@ -916,7 +924,7 @@ class LocalPlatformClient(ABC):
if send_setting == " 1 " :
if send_setting == " 1 " :
account_info = self . get_matching_account_details ( platform , currency )
account_info = self . get_matching_account_details ( platform , currency )
formatted_account_info = self . format_payment_details (
formatted_account_info = self . format_payment_details (
currency , account_info , real= True
currency , account_info , ad, real= True
)
)
if not formatted_account_info :
if not formatted_account_info :
log . error ( f " Payment info invalid: { formatted_account_info } " )
log . error ( f " Payment info invalid: { formatted_account_info } " )
@ -927,10 +935,10 @@ class LocalPlatformClient(ABC):
)
)
def get_all_assets ( self , platform ) :
def get_all_assets ( self , platform ) :
r eturn [ " XMR " ] # TODO
r aise Exception
def get_all_providers ( self , platform ) :
def get_all_providers ( self , platform ) :
r eturn [ " REVOLUT " ] # TODO
r aise Exception
def get_all_currencies ( self , platform ) :
def get_all_currencies ( self , platform ) :
raise Exception
raise Exception
@ -957,10 +965,9 @@ class LocalPlatformClient(ABC):
# call slow update.
# call slow update.
# (asset, currency, provider)
# (asset, currency, provider)
if not assets :
assets = self . instance . ads_assets
assets = self . get_all_assets ( platform )
currencies = self . currencies
currencies = self . currencies
providers = self . get_all_providers( platform )
providers = self . instance. ads_providers
# if platform == "lbtc":
# if platform == "lbtc":
# providers = [
# providers = [
# self.sources.lbtc.map_provider(x, reverse=True) for x in providers
# self.sources.lbtc.map_provider(x, reverse=True) for x in providers
@ -1092,48 +1099,25 @@ class LocalPlatformClient(ABC):
# log.debug("Cheapest ad above our min that is not us: {x}", x=cheapest_ad)
# log.debug("Cheapest ad above our min that is not us: {x}", x=cheapest_ad)
return cheapest_ad_margin
return cheapest_ad_margin
def create_distribution_list ( self , platform , filter_asset= None ) :
def create_distribution_list ( self , platform , ad, filter_asset= None ) :
"""
"""
Create a list for distribution of ads .
Create a list for distribution of ads .
: return : generator of asset , countrycode , currency , provider
: return : generator of asset , countrycode , currency , provider
: rtype : generator of tuples
: rtype : generator of tuples
"""
"""
distlist = [
dist_list_raw = ad . dist_list
[ " AUD " , " AU " ] ,
dist_list_lines = dist_list_raw . splitlines ( )
[ " BGN " , " BG " ] ,
[ " CAD " , " CA " ] ,
distlist = [ ]
[ " CHF " , " CH " ] ,
for line in dist_list_lines :
[ " CZK " , " CZ " ] ,
l_currency , l_country = line . split ( )
[ " DKK " , " DK " ] ,
distlist . append ( [ l_currency , l_country ] )
[ " GBP " , " GB " ] ,
[ " USD " , " GB " ] ,
[ " EUR " , " GB " ] ,
[ " USD " , " US " ] ,
[ " GBP " , " US " ] ,
[ " EUR " , " US " ] ,
[ " HKD " , " HK " ] ,
[ " HRK " , " HR " ] ,
[ " HUF " , " HU " ] ,
[ " ISK " , " IS " ] ,
[ " JPY " , " JP " ] ,
[ " MXN " , " MX " ] ,
[ " NOK " , " NO " ] ,
[ " NZD " , " NZ " ] ,
[ " PLN " , " PL " ] ,
[ " RON " , " RO " ] ,
[ " RUB " , " RU " ] ,
[ " SEK " , " SE " ] ,
[ " EUR " , " SE " ] ,
[ " SGD " , " SG " ] ,
[ " THB " , " TH " ] ,
[ " TRY " , " TR " ] ,
[ " ZAR " , " ZA " ] ,
]
# Iterate providers like REVOLUT, NATIONAL_BANK
# Iterate providers like REVOLUT, NATIONAL_BANK
for provider in self . get_all_providers( platform ) :
for provider in self . instance . ads_providers :
# Iterate assets like XMR, BTC
# Iterate assets like XMR, BTC
for asset in self . get_all_assets( platform ) :
for asset in self . instance . ads_assets :
# Iterate pairs of currency and country like EUR, GB
# Iterate pairs of currency and country like EUR, GB
for currency , countrycode in distlist :
for currency , countrycode in distlist :
if filter_asset :
if filter_asset :
@ -1144,7 +1128,7 @@ class LocalPlatformClient(ABC):
def get_valid_account_details ( self , platform ) :
def get_valid_account_details ( self , platform ) :
currencies = self . instance . currencies
currencies = self . instance . currencies
account_info = self . s ink s. account_info
account_info = self . instance . account_info
currency_account_info_map = { }
currency_account_info_map = { }
for currency in currencies :
for currency in currencies :
for bank , accounts in account_info . items ( ) :
for bank , accounts in account_info . items ( ) :
@ -1153,7 +1137,7 @@ class LocalPlatformClient(ABC):
currency_account_info_map [ currency ] = account [ " account_number " ]
currency_account_info_map [ currency ] = account [ " account_number " ]
currency_account_info_map [ currency ] [ " bank " ] = bank . split ( " _ " ) [ 0 ]
currency_account_info_map [ currency ] [ " bank " ] = bank . split ( " _ " ) [ 0 ]
currency_account_info_map [ currency ] [ " recipient " ] = account [
currency_account_info_map [ currency ] [ " recipient " ] = account [
" recipient "
" ownerName "
]
]
return ( currencies , currency_account_info_map )
return ( currencies , currency_account_info_map )
@ -1166,104 +1150,104 @@ class LocalPlatformClient(ABC):
return False
return False
return currency_account_info_map [ currency ]
return currency_account_info_map [ currency ]
def _distribute_account_details ( self , platform , currencies = None , account_info = None ) :
# def _distribute_account_details(self, platform, currencies=None, account_info=None):
"""
# """
Distribute account details for ads .
# Distribute account details for ads.
We will disable ads we can ' t support.
# We will disable ads we can't support.
"""
# """
if not currencies :
currencies = self . instance . currencies
if not account_info :
account_info = self . instance . account_info
(
supported_currencies ,
currency_account_info_map ,
) = self . get_valid_account_details ( platform )
# not_supported = [currency for currency in all_currencies if
# currency not in supported_currencies]
our_ads = self . enum_ads ( )
supported_ads = [ ad for ad in our_ads if ad [ 3 ] in supported_currencies ]
not_supported_ads = [ ad for ad in our_ads if ad [ 3 ] not in supported_currencies ]
for ad in supported_ads :
# if not currencies:
asset = ad [ 0 ]
# currencies = self.instance.currencies
countrycode = ad [ 2 ]
# if not account_info:
currency = ad [ 3 ]
# account_info = self.instance.account_info
provider = ad [ 4 ]
# (
payment_details = currency_account_info_map [ currency ]
# supported_currencies,
ad_id = ad [ 1 ]
# currency_account_info_map,
self . create_ad (
# ) = self.get_valid_account_details(platform)
asset ,
countrycode ,
# # not_supported = [currency for currency in all_currencies if
currency ,
# # currency not in supported_currencies]
provider ,
payment_details ,
# our_ads = self.enum_ads()
visible = True ,
edit = True ,
# supported_ads = [ad for ad in our_ads if ad[3] in supported_currencies]
ad_id = ad_id ,
)
# not_supported_ads = [ad for ad in our_ads if ad[3] not in supported_currencies]
# for ad in supported_ads:
# asset = ad[0]
# countrycode = ad[2]
# currency = ad[3]
# provider = ad[4]
# payment_details = currency_account_info_map[currency]
# ad_id = ad[1]
# self.create_ad(
# asset,
# countrycode,
# currency,
# provider,
# payment_details,
# visible=True,
# edit=True,
# ad_id=ad_id,
# )
for ad in not_supported_ads :
# for ad in not_supported_ads :
asset = ad [ 0 ]
# asset = ad[0]
countrycode = ad [ 2 ]
# countrycode = ad[2]
currency = ad [ 3 ]
# currency = ad[3]
provider = ad [ 4 ]
# provider = ad[4]
ad_id = ad [ 1 ]
# ad_id = ad[1]
self . create_ad (
# self.create_ad(
asset ,
# asset,
countrycode ,
# countrycode ,
currency ,
# currency,
provider ,
# provider,
payment_details = False ,
# payment_details=False,
visible = False ,
# visible=False,
edit = True ,
# edit=True,
ad_id = ad_id ,
# ad_id=ad_id,
)
# )
def distribute_account_details ( self , currencies = None , account_info = None ) :
# def distribute_account_details(self, currencies=None, account_info=None) :
"""
# """
Helper to distribute the account details for all platforms .
# Helper to distribute the account details for all platforms .
"""
# """
platforms = " agora "
# platforms = "agora"
for platform in platforms :
# for platform in platforms :
self . _distribute_account_details (
# self._distribute_account_details(
platform , currencies = currencies , account_info = account_info
# platform, currencies=currencies, account_info=account_info
)
# )
def format_ad ( self , asset , currency , payment_details_text ):
def format_ad ( self , asset , currency , payment_details_text , ad ):
"""
"""
Format the ad .
Format the ad .
"""
"""
ad = settings . Platform . Ad # TODO
ad _text = ad . text
# Substitute the currency
# Substitute the currency
ad = ad . replace ( " $CURRENCY$ " , currency )
ad _text = ad _text . replace ( " $CURRENCY$ " , currency )
# Substitute the asset
# Substitute the asset
ad = ad . replace ( " $ASSET$ " , asset )
ad _text = ad _text . replace ( " $ASSET$ " , asset )
# Substitute the payment details
# Substitute the payment details
ad = ad . replace ( " $PAYMENT$ " , payment_details_text )
ad _text = ad _text . replace ( " $PAYMENT$ " , payment_details_text )
# Strip extra tabs
# Strip extra tabs
ad = ad . replace ( " \\ t " , " \t " )
ad _text = ad _text . replace ( " \\ t " , " \t " )
return ad
return ad _text
def format_payment_details ( self , currency , payment_details , real= False ) :
def format_payment_details ( self , currency , payment_details , ad, real= False ) :
"""
"""
Format the payment details .
Format the payment details .
"""
"""
if not payment_details :
if not payment_details :
return False
return False
if real :
if real :
payment = settings. Platform . PaymentDetailsR eal
payment = ad. payment_details_r eal
else :
else :
payment = settings. Platform . PaymentD etails
payment = ad. payment_d etails
payment_text = " "
payment_text = " "
for field , value in payment_details . items ( ) :
for field , value in payment_details . items ( ) :