Skip to content

Commit ec6b05c

Browse files
committed
Hotfix: removed token_id as a possible order_by parameter for Asset endpoint.
1 parent 0fdb778 commit ec6b05c

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

open_sea_v1/endpoints/assets.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ class AssetsOrderBy(str, Enum):
1212
"""
1313
Helper Enum for remembering the possible values for the order_by param of the AssetsEndpoint class.
1414
"""
15-
TOKEN_ID = "token_id"
1615
SALE_DATE = "sale_date"
1716
SALE_COUNT = "sale_count"
1817
VISITOR_COUNT = "visitor_count"
1918
SALE_PRICE = "sale_price"
2019

20+
@classmethod
21+
def list(cls) -> list[str]:
22+
"""Returns list of values of each attribute of this String Enum."""
23+
return list(map(lambda c: c.value, cls))
24+
2125

2226
@dataclass
2327
class AssetsEndpoint(BaseClient, BaseEndpoint):
@@ -129,7 +133,7 @@ def _validate_order_by(self) -> None:
129133
if self.order_by is None:
130134
return
131135

132-
if self.order_by not in (AssetsOrderBy.TOKEN_ID, AssetsOrderBy.SALE_COUNT, AssetsOrderBy.SALE_DATE, AssetsOrderBy.SALE_PRICE, AssetsOrderBy.VISITOR_COUNT):
136+
if self.order_by not in AssetsOrderBy.list():
133137
raise ValueError(
134138
f"order_by param value ({self.order_by}) is invalid. "
135139
f"Must be a value from {AssetsOrderBy.list()}, case sensitive."

open_sea_v1/endpoints/tests/test_assets.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ def test_param_order_direction_can_only_be_asc_or_desc(self):
4949
params = dict(token_ids=[1], asset_contract_address=self.sample_contract, order_direction=invalid_order)
5050
self.assertRaises((ValueError, TypeError), AssetsEndpoint, **params)
5151

52-
def test_param_order_by_token_id(self):
53-
params = self.default_asset_params | dict(token_ids=[3, 2, 1], order_by=AssetsOrderBy.TOKEN_ID, order_direction='desc')
54-
punks_ids = [punk.token_id for punk in self.create_and_get(**params)]
55-
self.assertEqual(['3', '2', '1'], punks_ids)
56-
5752
def test_param_order_by_sale_date(self):
5853
params = self.default_asset_params | dict(token_ids=[1, 14, 33], order_by=AssetsOrderBy.SALE_DATE)
5954
punks_sales = [punk.last_sale.event_timestamp for punk in self.create_and_get(**params)]

0 commit comments

Comments
 (0)