From 84d2ca0101a86c67802824a49388e236f5430d20 Mon Sep 17 00:00:00 2001 From: nessshon Date: Thu, 26 Sep 2024 21:47:42 +0500 Subject: [PATCH] Update `v2/accounts/{account_id}/jettons` and `v2/accounts/{account_id}/jettons/{jetton_id}`: added `currencies` and `supported_extensions` parameters. --- pytonapi/async_tonapi/methods/accounts.py | 29 +++++++++++++++++++---- pytonapi/tonapi/methods/accounts.py | 29 +++++++++++++++++++---- 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/pytonapi/async_tonapi/methods/accounts.py b/pytonapi/async_tonapi/methods/accounts.py index 8cefa21..2aa5b86 100644 --- a/pytonapi/async_tonapi/methods/accounts.py +++ b/pytonapi/async_tonapi/methods/accounts.py @@ -57,28 +57,49 @@ async def get_domains(self, account_id: str) -> DomainNames: return DomainNames(**response) - async def get_jettons_balances(self, account_id: str) -> JettonsBalances: + async def get_jettons_balances( + self, + account_id: str, + currencies: Optional[List[str]] = None, + supported_extensions: Optional[List[str]] = None, + ) -> JettonsBalances: """ Get all Jettons balances by owner address. :param account_id: account ID + :param currencies: accept ton and all possible fiat currencies, separated by commas + :param supported_extensions: comma separated list supported extensions :return: :class:`JettonsBalances` """ method = f"v2/accounts/{account_id}/jettons" - response = await self._get(method=method) + params = {"supported_extensions": ",".join(supported_extensions)} if supported_extensions else {} + if currencies: + params["currencies"] = ",".join(currencies) + response = await self._get(method=method, params=params) return JettonsBalances(**response) - async def get_jetton_balance(self, account_id: str, jetton_id: str) -> JettonBalance: + async def get_jetton_balance( + self, + account_id: str, + jetton_id: str, + currencies: Optional[List[str]] = None, + supported_extensions: Optional[List[str]] = None, + ) -> JettonBalance: """ Get Jetton balance by owner address :param account_id: account ID :param jetton_id: jetton ID + :param currencies: accept ton and all possible fiat currencies, separated by commas + :param supported_extensions: comma separated list supported extensions :return: :class:`JettonBalance` """ method = f"v2/accounts/{account_id}/jettons/{jetton_id}" - response = await self._get(method=method) + params = {"supported_extensions": ",".join(supported_extensions)} if supported_extensions else {} + if currencies: + params["currencies"] = ",".join(currencies) + response = await self._get(method=method, params=params) return JettonBalance(**response) diff --git a/pytonapi/tonapi/methods/accounts.py b/pytonapi/tonapi/methods/accounts.py index e81ef1c..188ad8f 100644 --- a/pytonapi/tonapi/methods/accounts.py +++ b/pytonapi/tonapi/methods/accounts.py @@ -57,28 +57,49 @@ def get_domains(self, account_id: str) -> DomainNames: return DomainNames(**response) - def get_jettons_balances(self, account_id: str) -> JettonsBalances: + def get_jettons_balances( + self, + account_id: str, + currencies: Optional[List[str]] = None, + supported_extensions: Optional[List[str]] = None, + ) -> JettonsBalances: """ Get all Jettons balances by owner address. :param account_id: account ID + :param currencies: accept ton and all possible fiat currencies, separated by commas + :param supported_extensions: comma separated list supported extensions :return: :class:`JettonsBalances` """ method = f"v2/accounts/{account_id}/jettons" - response = self._get(method=method) + params = {"supported_extensions": ",".join(supported_extensions)} if supported_extensions else {} + if currencies: + params["currencies"] = ",".join(currencies) + response = self._get(method=method, params=params) return JettonsBalances(**response) - def get_jetton_balance(self, account_id: str, jetton_id: str) -> JettonBalance: + def get_jetton_balance( + self, + account_id: str, + jetton_id: str, + currencies: Optional[List[str]] = None, + supported_extensions: Optional[List[str]] = None, + ) -> JettonBalance: """ Get Jetton balance by owner address :param account_id: account ID :param jetton_id: jetton ID + :param currencies: accept ton and all possible fiat currencies, separated by commas + :param supported_extensions: comma separated list supported extensions :return: :class:`JettonBalance` """ method = f"v2/accounts/{account_id}/jettons/{jetton_id}" - response = self._get(method=method) + params = {"supported_extensions": ",".join(supported_extensions)} if supported_extensions else {} + if currencies: + params["currencies"] = ",".join(currencies) + response = self._get(method=method, params=params) return JettonBalance(**response)