def send(self, params): """Send notification: fuel notifications --send "message" --topic done """ message = params.send if isinstance(message, list): message = ' '.join(message) result = Notifications.send(message, topic=params.topic) self.serializer.print_to_output( result, "Notification sent")
def mark_as_read(self, params): """Mark given notifications as read. fuel notifications --mark-as-read 1 2 fuel notifications -r 1 2 """ result = Notifications.mark_as_read( ids=getattr(params, 'mark-as-read')) self.serializer.print_to_output( result, 'Notification(s) marked as read' )
def list(self, params): """Print all available notifications: fuel notifications fuel notifications --list """ notifications = Notifications.get_all_data() if not params.all: notifications = [notification for notification in notifications if notification['status'] == 'unread'] self.serializer.print_to_output( notifications, format_table( notifications, acceptable_keys=self.acceptable_keys ) )