Skip to content

Notification

Bases: Notification_

Interface for interacting with planka Notifications

Note

Only notifications that are associated with the current user can be accessed

Source code in src/plankapy/interfaces.py
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
class Notification(Notification_):
    """Interface for interacting with planka Notifications

    Note:
        Only notifications that are associated with the current user can be accessed
    """
    @property
    def user(self) -> User:
        """User that the notification is associated with

        Returns:
            User: User instance
        """
        user_route = self.routes.get_user(id=self.userId)
        return User(**user_route()['item']).bind(self.routes)

    @property
    def action(self) -> Action:
        """Action that the notification is associated with

        Returns:
            Action: Action instance
        """
        action_route = self.routes.get_action(id=self.actionId)
        return Action(**action_route()['item']).bind(self.routes)

    @property
    def card(self) -> Card:
        """Card that the notification is associated with

        Returns:
            Card: Card instance
        """
        card_route = self.routes.get_card(id=self.cardId)
        return Card(**card_route()['item']).bind(self.routes)

    @overload
    def update(self): ...

    @overload
    def update(self, notification: Notification): ...

    @overload
    def update(self, isRead: bool=None): ...

    def update(self, *args, **kwargs) -> Notification:
        """Updates the notification with new values

        Note:
            The only value that can be updated is the 'isRead' value. There is no way to delete a notification
            use the `.mark_as_read()` method to mark the notification as read

        Args:
            isRead (bool): Whether the notification is read (default: None)

        Args: Alternate
            notification (Notification): Notification instance to update with

        Note:
            If no arguments are provided, the notification will update itself with the current values stored in its attributes
        """
        overload = parse_overload(
            args, kwargs, 
            model='notification', 
            options=('isRead',),
            noarg=self)

        route = self.routes.patch_notification(id=self.id)
        self.__init__(**route(**overload)['item'])
        return self

    def mark_as_read(self) -> None:
        """Marks the notification as read

        Note:
            There is no way to delete a notification, only mark it as read
        """
        with self.editor():
            self.isRead = True

    def refresh(self) -> None:
        """Refreshes the notification data"""
        route = self.routes.get_notification(id=self.id)
        self.__init__(**route()['item'])

action property

Action that the notification is associated with

Returns:

Name Type Description
Action Action

Action instance

card property

Card that the notification is associated with

Returns:

Name Type Description
Card Card

Card instance

user property

User that the notification is associated with

Returns:

Name Type Description
User User

User instance

mark_as_read()

Marks the notification as read

Note

There is no way to delete a notification, only mark it as read

Source code in src/plankapy/interfaces.py
1404
1405
1406
1407
1408
1409
1410
1411
def mark_as_read(self) -> None:
    """Marks the notification as read

    Note:
        There is no way to delete a notification, only mark it as read
    """
    with self.editor():
        self.isRead = True

refresh()

Refreshes the notification data

Source code in src/plankapy/interfaces.py
1413
1414
1415
1416
def refresh(self) -> None:
    """Refreshes the notification data"""
    route = self.routes.get_notification(id=self.id)
    self.__init__(**route()['item'])

update(*args, **kwargs)

update()
update(notification: Notification)
update(isRead: bool = None)

Updates the notification with new values

Note

The only value that can be updated is the 'isRead' value. There is no way to delete a notification use the .mark_as_read() method to mark the notification as read

Parameters:

Name Type Description Default
isRead bool

Whether the notification is read (default: None)

required

Alternate

Name Type Description Default
notification Notification

Notification instance to update with

required
Note

If no arguments are provided, the notification will update itself with the current values stored in its attributes

Source code in src/plankapy/interfaces.py
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
def update(self, *args, **kwargs) -> Notification:
    """Updates the notification with new values

    Note:
        The only value that can be updated is the 'isRead' value. There is no way to delete a notification
        use the `.mark_as_read()` method to mark the notification as read

    Args:
        isRead (bool): Whether the notification is read (default: None)

    Args: Alternate
        notification (Notification): Notification instance to update with

    Note:
        If no arguments are provided, the notification will update itself with the current values stored in its attributes
    """
    overload = parse_overload(
        args, kwargs, 
        model='notification', 
        options=('isRead',),
        noarg=self)

    route = self.routes.patch_notification(id=self.id)
    self.__init__(**route(**overload)['item'])
    return self