1# Generated by scripts/unasync.py from src/wow/_async/resources/item.py. Do not edit.
2"""Routes of the Item, Item Class and Item Set APIs."""
3
4from typing import TYPE_CHECKING
5
6from wow._sync._resource import Resource
7from wow.models._common import Media
8from wow.models.item import Item, ItemClass, ItemClassIndex, ItemSearchData, ItemSet, ItemSetIndex
9from wow.search import MAX_PAGE_SIZE
10
11if TYPE_CHECKING:
12 from collections.abc import Iterator, Mapping, Sequence
13
14 from wow.models._common import SearchPage, SearchResult
15 from wow.search import FilterValue
16
17__all__ = ["ItemClasses", "ItemSets", "Items"]
18
19
[docs]
20class Items(Resource):
21 """``client.items``: items."""
22
23 __slots__ = ()
24
[docs]
25 def get(self, item_id: int) -> Item:
26 """Get one item by id."""
27 return self._get("static", f"/data/wow/item/{item_id}", Item)
28
32
[docs]
33 def search(
34 self,
35 *,
36 name: str | None = None,
37 filters: Mapping[str, FilterValue] | None = None,
38 order_by: str | Sequence[str] | None = None,
39 page: int = 1,
40 page_size: int = 100,
41 ) -> SearchPage[ItemSearchData]:
42 """Search items.
43
44 Args:
45 name: Match this text in the client's locale.
46 filters: Field filters, such as ``{"item_class.id": 2}``.
47 order_by: Field name(s) to sort by, each optionally suffixed ``:desc``.
48 page: The page to fetch, starting at 1.
49 page_size: Results per page.
50 """
51 return self._search(
52 "static",
53 "item",
54 ItemSearchData,
55 filters=self._localized_name(name, filters),
56 order_by=order_by,
57 page=page,
58 page_size=page_size,
59 )
60
[docs]
61 def search_all(
62 self,
63 *,
64 name: str | None = None,
65 filters: Mapping[str, FilterValue] | None = None,
66 order_by: str | Sequence[str] | None = None,
67 page_size: int = MAX_PAGE_SIZE,
68 ) -> Iterator[SearchResult[ItemSearchData]]:
69 """Iterate over every result across pages (Battle.net stops at 1,000).
70
71 Args:
72 name: Match this text in the client's locale.
73 filters: Field filters, such as ``{"item_class.id": 2}``.
74 order_by: Field name(s) to sort by, each optionally suffixed ``:desc``.
75 page_size: Results per page.
76 """
77 return self._search_all(
78 "static",
79 "item",
80 ItemSearchData,
81 filters=self._localized_name(name, filters),
82 order_by=order_by,
83 page_size=page_size,
84 )
85
86
[docs]
87class ItemClasses(Resource):
88 """``client.item_classes``: item classes such as Weapon and Consumable."""
89
90 __slots__ = ()
91
[docs]
92 def index(self) -> ItemClassIndex:
93 """List every item class."""
94 return self._get("static", "/data/wow/item-class/index", ItemClassIndex)
95
[docs]
96 def get(self, class_id: int) -> ItemClass:
97 """Get one item class by id."""
98 return self._get("static", f"/data/wow/item-class/{class_id}", ItemClass)
99
100
[docs]
101class ItemSets(Resource):
102 """``client.item_sets``: equipment sets."""
103
104 __slots__ = ()
105
[docs]
106 def index(self) -> ItemSetIndex:
107 """List every item set."""
108 return self._get("static", "/data/wow/item-set/index", ItemSetIndex)
109
[docs]
110 def get(self, set_id: int) -> ItemSet:
111 """Get one item set by id."""
112 return self._get("static", f"/data/wow/item-set/{set_id}", ItemSet)