codingame_tools.client.common.protocol.notification¶
notification
¶
JSON-serializable dataclasses for the findUnseenNotifications and findUnreadNotifications Codingame API methods.
Both methods return a bare JSON array of notification objects (not wrapped in an envelope object), so
there is no dedicated "response" dataclass here--callers should use CgNotification.from_list(raw_list)
to parse the array.
CgNotificationType
module-attribute
¶
CgNotificationType = str
The specific notification type discriminator, e.g. "new-comment", "following". Determines the shape of
CgNotification.data, if present. Only a couple of values have been observed so far, so this is
left as a plain string rather than an enum pending broader coverage.
CgNotificationTypeGroup
module-attribute
¶
CgNotificationTypeGroup = str
The broad category a notification type belongs to, e.g. "comment", "social".
CgNotificationCodingamer
dataclass
¶
CgNotificationCodingamer(user_id, country_id, public_handle, extra_data=dict(), pseudo=None, avatar=None, cover=None)
Bases: JSONWizardX
The codingamer associated with a notification, e.g. the commenter or new follower who triggered it.
pseudo
class-attribute
instance-attribute
¶
pseudo = None
The codingamer's display name. Not always present--observed absent for at least one codingamer returned from a live findUnreadNotifications call, reason unknown.
avatar
class-attribute
instance-attribute
¶
avatar = None
The binary image ID of the codingamer's avatar image. Not always present--e.g. absent for a plain "following" notification.
cover
class-attribute
instance-attribute
¶
cover = None
The binary image ID of the codingamer's cover image. Not always present--e.g. absent for a plain "following" notification.
CgNotification
dataclass
¶
CgNotification(id, type_group, priority, urgent, _date=Alias('date'), notification_type=Alias('type'), extra_data=dict(), codingamer=None, _seen_date=Alias('seenDate', default=None), data=None)
Bases: JSONWizardX
A single notification, as returned (in a bare JSON array) by findUnseenNotifications and findUnreadNotifications.
The shape of data depends on type/type_group, and is not present for all notification types
(e.g. it is absent for "following" notifications). Two shapes have been observed so far:
# "new-comment"/"comment"
{
"commentType": "CONTRIBUTION",
"commentId": <int>,
"commentableId": <int>,
"title": <str>,
"type": {"en": <str>, "fr": <str>},
"typeData": {"handle": <str>, "type": <str>}
}
# "custom"/"custom"
{
"title": {"en": <str>, "fr": <str>},
"description": {"en": <str>, "fr": <str>},
"url": <str>,
"image": <str>
}
data is left as a raw dict pending examples of more notification types.
priority
instance-attribute
¶
priority
Unclear precise semantics (not documented); always observed as 0 so far.
urgent
instance-attribute
¶
urgent
Whether the notification is flagged urgent, e.g. for a time-sensitive clash invite.
codingamer
class-attribute
instance-attribute
¶
codingamer = None
The codingamer who triggered the notification. Not present for all notification types--e.g. absent for a "custom" notification, which is a broadcast rather than tied to a specific user.
data
class-attribute
instance-attribute
¶
data = None
Notification-type-specific payload; see class docstring. Absent for some notification types.
date
property
writable
¶
date
The date/time of the event that triggered the notification, always UTC.
seen_date
property
writable
¶
seen_date
See the field docstring for _seen_date. Always UTC. None if not yet seen.