forked from FOSS/AutoShop-Djimbo
refactor(api_lolzteam): simplify merchant_id initialization logic
This commit is contained in:
@@ -272,6 +272,7 @@ async def payments_lolzteam_get(message: Message, bot: Bot, state: FSM, arSessio
|
|||||||
update=message,
|
update=message,
|
||||||
skipping_error=True,
|
skipping_error=True,
|
||||||
token=get_token,
|
token=get_token,
|
||||||
|
merchant_id=None,
|
||||||
)
|
)
|
||||||
).check()
|
).check()
|
||||||
|
|
||||||
|
|||||||
@@ -62,16 +62,13 @@ class LolzteamAPI:
|
|||||||
) -> "LolzteamAPI":
|
) -> "LolzteamAPI":
|
||||||
adding = token is not None
|
adding = token is not None
|
||||||
|
|
||||||
if token is None or merchant_id is None:
|
if token is None:
|
||||||
payments = await Paymentsx().get()
|
payments = await Paymentsx().get()
|
||||||
adding = False
|
adding = False
|
||||||
|
|
||||||
if token is None:
|
if token is None:
|
||||||
token = payments.lolzteam_token
|
token = payments.lolzteam_token
|
||||||
|
|
||||||
if merchant_id is None:
|
|
||||||
merchant_id = payments.lolzteam_merchant_id
|
|
||||||
|
|
||||||
return cls(
|
return cls(
|
||||||
bot=bot,
|
bot=bot,
|
||||||
arSession=arSession,
|
arSession=arSession,
|
||||||
@@ -103,12 +100,7 @@ class LolzteamAPI:
|
|||||||
async def check(self) -> Tuple[bool, str]:
|
async def check(self) -> Tuple[bool, str]:
|
||||||
status, response = await self._request("me", method="GET")
|
status, response = await self._request("me", method="GET")
|
||||||
|
|
||||||
if (
|
if status and "errors" not in response and self.merchant_id:
|
||||||
status
|
|
||||||
and "errors" not in response
|
|
||||||
and "balances" in response["user"]
|
|
||||||
and self.merchant_id
|
|
||||||
):
|
|
||||||
# ! Проверка этим способом не работает для мерчантов, у которых нет отдельного
|
# ! Проверка этим способом не работает для мерчантов, у которых нет отдельного
|
||||||
# ! баланса на маркете, и поэтому используется способ ниже
|
# ! баланса на маркете, и поэтому используется способ ниже
|
||||||
# balances = response["user"]["balances"]
|
# balances = response["user"]["balances"]
|
||||||
@@ -133,7 +125,7 @@ class LolzteamAPI:
|
|||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
elif status and "errors" not in response and not self.merchant_id:
|
elif status and "errors" not in response:
|
||||||
return True, ded(
|
return True, ded(
|
||||||
f"""
|
f"""
|
||||||
<b>🟢 Lolzteam функционирует ✅</b>
|
<b>🟢 Lolzteam функционирует ✅</b>
|
||||||
|
|||||||
Reference in New Issue
Block a user