Skip to content

Commit

Permalink
add spam filter and updateTokenOwnesrhipSpamStatus (#160)
Browse files Browse the repository at this point in the history
* add spam filter and updateTokenOwnesrhipSpamStatus

* fix SpamTokenOwnershipValues
  • Loading branch information
vsiskin authored Jan 30, 2024
1 parent 3f63423 commit e557bb4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
17 changes: 16 additions & 1 deletion fireblocks_sdk/api_types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from enum import Enum
from enum import StrEnum, auto, Enum
from typing import Optional, List, Union


Expand Down Expand Up @@ -379,6 +379,21 @@ class NFTsWalletTypeValues(str, Enum):
VAULT_ACCOUNT = "VAULT_ACCOUNT"
END_USER_WALLET = "END_USER_WALLET"

class SpamTokenOwnershipValues(StrEnum):
true = auto()
false = auto()
all = auto()

class TokenOwnershipSpamUpdatePayload:
def __init__(self, asset_id: str, spam: bool):
self.asset_id = asset_id
self.spam = spam

def serialize(self) -> dict:
return {
'assetId': self.asset_id,
'spam': self.spam,
}

class OrderValues(str, Enum):
ASC = "ASC"
Expand Down
22 changes: 20 additions & 2 deletions fireblocks_sdk/sdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
UnstakeRequestDto,
WithdrawRequestDto,
Role,
SpamTokenOwnershipValues,
TokenOwnershipSpamUpdatePayload,
)
from .tokenization_api_types import \
CreateTokenRequest, \
Expand Down Expand Up @@ -219,7 +221,7 @@ def get_owned_nfts(self, blockchain_descriptor: str, vault_account_ids: List[str
collection_ids: List[str] = None, page_cursor: str = '', page_size: int = 100,
sort: List[GetOwnedNftsSortValues] = None,
order: OrderValues = None, status: NFTOwnershipStatusValues = None, search: str = None,
ncw_account_ids: List[str] = None, ncw_id: str = None, wallet_type: NFTsWalletTypeValues = None):
ncw_account_ids: List[str] = None, ncw_id: str = None, wallet_type: NFTsWalletTypeValues = None, spam: SpamTokenOwnershipValues = None):
"""
"""
Expand Down Expand Up @@ -266,6 +268,9 @@ def get_owned_nfts(self, blockchain_descriptor: str, vault_account_ids: List[str
if search:
params["search"] = search

if spam:
params["spam"] = spam.value

return self._get_request(url, query_params=params)

def list_owned_collections(self, search: str = None, status: NFTOwnershipStatusValues = None,
Expand Down Expand Up @@ -308,7 +313,7 @@ def list_owned_collections(self, search: str = None, status: NFTOwnershipStatusV
def list_owned_assets(self, search: str = None, status: NFTOwnershipStatusValues = None,
ncw_id: str = None, wallet_type: NFTsWalletTypeValues = None,
sort: List[GetOwnedAssetsSortValues] = None,
order: OrderValues = None, page_cursor: str = '', page_size: int = 100):
order: OrderValues = None, page_cursor: str = '', page_size: int = 100, spam: SpamTokenOwnershipValues = None):
"""
"""
url = f"/v1/nfts/ownership/assets"
Expand Down Expand Up @@ -339,6 +344,9 @@ def list_owned_assets(self, search: str = None, status: NFTOwnershipStatusValues
if order:
params['order'] = order

if spam:
params["spam"] = spam.value

return self._get_request(url, query_params=params)

def update_nft_ownership_status(self, id: str, status: NFTOwnershipStatusValues):
Expand All @@ -362,6 +370,16 @@ def update_nft_ownerships_status(self, payload: List[NFTOwnershipStatusUpdatedPa

return self._put_request(url, list(map((lambda payload_item: payload_item.serialize()), payload)))

def update_nft_token_ownerships_spam_status(self, payload: List[TokenOwnershipSpamUpdatePayload]):
"""Updates tokens spam status for a tenant, in all tenant vaults.
Args:
payload (TokenOwnershipSpamUpdatePayload[]): List of assets with status for update
"""
url = "/v1/nfts/ownership/tokens/spam"

return self._put_request(url, list(map((lambda payload_item: payload_item.serialize()), payload)))

def get_supported_assets(self):
"""Gets all assets that are currently supported by Fireblocks"""

Expand Down

0 comments on commit e557bb4

Please sign in to comment.