# generated by update to not change manually
import dataclasses as dt
import typing as t
from enum import Enum
from bungieapi.json import to_json
[docs]@dt.dataclass(frozen=True)
class TrendingCategories:
categories: t.Optional[t.Sequence["TrendingCategory"]] = None
[docs] def to_json(self) -> t.Mapping[str, t.Any]:
return {
"categories": to_json(self.categories),
}
[docs]@dt.dataclass(frozen=True)
class TrendingCategory:
category_id: t.Optional[str] = None
category_name: t.Optional[str] = None
entries: t.Optional["SearchResultOfTrendingEntry"] = None
[docs] def to_json(self) -> t.Mapping[str, t.Any]:
return {
"categoryName": to_json(self.category_name),
"entries": to_json(self.entries),
"categoryId": to_json(self.category_id),
}
[docs]@dt.dataclass(frozen=True)
class TrendingEntry:
"""The list entry view for trending items.
Returns just enough to show the item on the trending page.
"""
creation_date: t.Optional[
str
] = None # If the entry has a date at which it was created, this is that date.
display_name: t.Optional[
str
] = None # The localized "display name/article title/'primary localized identifier'" of the entity.
end_date: t.Optional[str] = None
entity_type: t.Optional[
"TrendingEntryType"
] = None # An enum - unfortunately - dictating all of the possible kinds of trending items that you might get in your result set, in case you want to do custom rendering or call to get the details of the item.
feature_image: t.Optional[
str
] = None # If isFeatured, this image will be populated with whatever the featured image is. Note that this will likely be a very large image, so don't use it all the time.
identifier: t.Optional[
str
] = None # We don't know whether the identifier will be a string, a uint, or a long... so we're going to cast it all to a string. But either way, we need any trending item created to have a single unique identifier for its type.
image: t.Optional[str] = None
is_featured: t.Optional[bool] = None
items: t.Optional[
t.Sequence["TrendingEntry"]
] = None # If the item is of entityType TrendingEntryType.Container, it may have items - also Trending Entries - contained within it. This is the ordered list of those to display under the Container's header.
link: t.Optional[str] = None
mp4_video: t.Optional[
str
] = None # If this is populated, the entry has a related MP4 video to show. I am 100% certain I am going to regret putting this directly on TrendingEntry, but it will work so yolo
start_date: t.Optional[str] = None
tagline: t.Optional[
str
] = None # If the entity has a localized tagline/subtitle/motto/whatever, that is found here.
webm_video: t.Optional[
str
] = None # If this is populated, the entry has a related WebM video to show. I am 100% certain I am going to regret putting this directly on TrendingEntry, but it will work so yolo
weight: t.Optional[float] = None # The weighted score of this trending item.
[docs] def to_json(self) -> t.Mapping[str, t.Any]:
return {
"weight": to_json(self.weight),
"isFeatured": to_json(self.is_featured),
"identifier": to_json(self.identifier),
"entityType": to_json(self.entity_type),
"displayName": to_json(self.display_name),
"tagline": to_json(self.tagline),
"image": to_json(self.image),
"startDate": to_json(self.start_date),
"endDate": to_json(self.end_date),
"link": to_json(self.link),
"webmVideo": to_json(self.webm_video),
"mp4Video": to_json(self.mp4_video),
"featureImage": to_json(self.feature_image),
"items": to_json(self.items),
"creationDate": to_json(self.creation_date),
}
[docs]class TrendingEntryType(Enum):
"""The known entity types that you can have returned from Trending."""
NEWS = 0
DESTINY_ITEM = 1
DESTINY_ACTIVITY = 2
DESTINY_RITUAL = 3
SUPPORT_ARTICLE = 4
CREATION = 5
STREAM = 6
UPDATE = 7
LINK = 8
FORUM_TAG = 9
CONTAINER = 10
RELEASE = 11
[docs]@dt.dataclass(frozen=True)
class TrendingDetail:
creation: t.Optional["TrendingEntryCommunityCreation"] = None
destiny_activity: t.Optional["TrendingEntryDestinyActivity"] = None
destiny_item: t.Optional["TrendingEntryDestinyItem"] = None
destiny_ritual: t.Optional["TrendingEntryDestinyRitual"] = None
entity_type: t.Optional["TrendingEntryType"] = None
identifier: t.Optional[str] = None
news: t.Optional["TrendingEntryNews"] = None
support: t.Optional["TrendingEntrySupportArticle"] = None
[docs] def to_json(self) -> t.Mapping[str, t.Any]:
return {
"identifier": to_json(self.identifier),
"entityType": to_json(self.entity_type),
"news": to_json(self.news),
"support": to_json(self.support),
"destinyItem": to_json(self.destiny_item),
"destinyActivity": to_json(self.destiny_activity),
"destinyRitual": to_json(self.destiny_ritual),
"creation": to_json(self.creation),
}
[docs]@dt.dataclass(frozen=True)
class TrendingEntryNews:
article: t.Optional["ContentItemPublicContract"] = None
[docs] def to_json(self) -> t.Mapping[str, t.Any]:
return {
"article": to_json(self.article),
}
[docs]@dt.dataclass(frozen=True)
class TrendingEntrySupportArticle:
article: t.Optional["ContentItemPublicContract"] = None
[docs] def to_json(self) -> t.Mapping[str, t.Any]:
return {
"article": to_json(self.article),
}
[docs]@dt.dataclass(frozen=True)
class TrendingEntryDestinyItem:
item_hash: t.Optional[int] = None
[docs] def to_json(self) -> t.Mapping[str, t.Any]:
return {
"itemHash": to_json(self.item_hash),
}
[docs]@dt.dataclass(frozen=True)
class TrendingEntryDestinyActivity:
activity_hash: t.Optional[int] = None
status: t.Optional["DestinyPublicActivityStatus"] = None
[docs] def to_json(self) -> t.Mapping[str, t.Any]:
return {
"activityHash": to_json(self.activity_hash),
"status": to_json(self.status),
}
[docs]@dt.dataclass(frozen=True)
class TrendingEntryDestinyRitual:
date_end: t.Optional[str] = None
date_start: t.Optional[str] = None
event_content: t.Optional[
"DestinyMilestoneContent"
] = None # A destiny event will not necessarily have milestone "custom content", but if it does the details will be here.
icon: t.Optional[str] = None
image: t.Optional[str] = None
milestone_details: t.Optional[
"DestinyPublicMilestone"
] = None # A destiny event does not necessarily have a related Milestone, but if it does the details will be returned here.
subtitle: t.Optional[str] = None
title: t.Optional[str] = None
[docs] def to_json(self) -> t.Mapping[str, t.Any]:
return {
"image": to_json(self.image),
"icon": to_json(self.icon),
"title": to_json(self.title),
"subtitle": to_json(self.subtitle),
"dateStart": to_json(self.date_start),
"dateEnd": to_json(self.date_end),
"milestoneDetails": to_json(self.milestone_details),
"eventContent": to_json(self.event_content),
}
# imported at the end to do not case circular imports for type annotations
from bungieapi.generated.components.schemas import (
SearchResultOfTrendingEntry,
) # noqa: E402
from bungieapi.generated.components.schemas.content import (
ContentItemPublicContract,
) # noqa: E402
from bungieapi.generated.components.schemas.destiny.activities import (
DestinyPublicActivityStatus,
) # noqa: E402
from bungieapi.generated.components.schemas.destiny.milestones import (
DestinyMilestoneContent,
) # noqa: E402
from bungieapi.generated.components.schemas.destiny.milestones import (
DestinyPublicMilestone,
) # noqa: E402