Skip to content

Commit

Permalink
Update v2/accounts/{account_id}/jettons and `v2/accounts/{account_i…
Browse files Browse the repository at this point in the history
…d}/jettons/{jetton_id}`: added `currencies` and `supported_extensions` parameters.
  • Loading branch information
nessshon committed Sep 26, 2024
1 parent 46b9496 commit 84d2ca0
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 8 deletions.
29 changes: 25 additions & 4 deletions pytonapi/async_tonapi/methods/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
29 changes: 25 additions & 4 deletions pytonapi/tonapi/methods/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 84d2ca0

Please sign in to comment.