Class: Fizzy::CLI::Notifications

Inherits:
Thor
  • Object
show all
Includes:
Base
Defined in:
lib/fizzy/cli/notifications.rb

Instance Method Summary collapse

Methods included from Base

included

Instance Method Details

#listObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fizzy/cli/notifications.rb', line 9

def list
  data = paginator.all("notifications")
  output_list(data, headers: %w[ID Type Card Read Created]) do |n|
    [
      n["id"],
      n["event_type"],
      n.dig("card", "title") || "",
      n["read_at"] ? "yes" : "no",
      n["created_at"]
    ]
  end
end

#mark_all_readObject



36
37
38
39
# File 'lib/fizzy/cli/notifications.rb', line 36

def mark_all_read
  client.post("notifications/bulk_reading")
  puts "All notifications marked read."
end

#read(id) ⇒ Object



23
24
25
26
# File 'lib/fizzy/cli/notifications.rb', line 23

def read(id)
  client.post("notifications/#{id}/reading")
  puts "Notification #{id} marked read."
end

#unread(id) ⇒ Object



29
30
31
32
# File 'lib/fizzy/cli/notifications.rb', line 29

def unread(id)
  client.delete("notifications/#{id}/reading")
  puts "Notification #{id} marked unread."
end