Source code for bungieapi.generated.components.schemas.queries
# generated by update to not change manually
import dataclasses as dt
import typing as t
from bungieapi.json import to_json
[docs]@dt.dataclass(frozen=True)
class SearchResult:
has_more: t.Optional[bool] = None
query: t.Optional["PagedQuery"] = None
replacement_continuation_token: t.Optional[str] = None
total_results: t.Optional[int] = None
use_total_results: t.Optional[
bool
] = None # If useTotalResults is true, then totalResults represents an accurate count. If False, it does not, and may be estimated/only the size of the current page. Either way, you should probably always only trust hasMore. This is a long-held historical throwback to when we used to do paging with known total results. Those queries toasted our database, and we were left to hastily alter our endpoints and create backward- compatible shims, of which useTotalResults is one.
[docs] def to_json(self) -> t.Mapping[str, t.Any]:
return {
"totalResults": to_json(self.total_results),
"hasMore": to_json(self.has_more),
"query": to_json(self.query),
"replacementContinuationToken": to_json(
self.replacement_continuation_token
),
"useTotalResults": to_json(self.use_total_results),
}
[docs]@dt.dataclass(frozen=True)
class PagedQuery:
current_page: t.Optional[int] = None
items_per_page: t.Optional[int] = None
request_continuation_token: t.Optional[str] = None
[docs] def to_json(self) -> t.Mapping[str, t.Any]:
return {
"itemsPerPage": to_json(self.items_per_page),
"currentPage": to_json(self.current_page),
"requestContinuationToken": to_json(self.request_continuation_token),
}