Class: Bl::Commands::Notification

Inherits:
Bl::Command show all
Defined in:
lib/bl/commands/notification.rb

Instance Method Summary collapse

Methods included from Printer

print_response, printable_issues

Methods included from Requestable

client, formatter, request

Constructor Details

#initializeNotification

TODO:



6
7
8
9
10
# File 'lib/bl/commands/notification.rb', line 6

def initialize(*)
  @config = Bl::Config.instance
  @url = 'notifications'
  super
end

Instance Method Details

#countObject



21
22
23
24
# File 'lib/bl/commands/notification.rb', line 21

def count
  # puts request(:get, "#{@url}/count").body.count
  # TODO fix nil error
end

#listObject



14
15
16
17
# File 'lib/bl/commands/notification.rb', line 14

def list
  res = request(:get, @url, options.to_h)
  res.body.map { |n| puts n.pretty_inspect }
end

#mark_as_readObject



27
28
29
30
31
# File 'lib/bl/commands/notification.rb', line 27

def mark_as_read
  res = request(:post, "#{@url}/markAsRead")
  puts 'notifications mark as readed'
  puts res.body.count
end

#read(id) ⇒ Object



34
35
36
37
38
# File 'lib/bl/commands/notification.rb', line 34

def read(id)
  res = request(:post, "#{@url}/#{id}/markAsRead")
  puts "notifications #{id} readed"
  puts res.pretty_inspect
end