Class: Bl::Commands::Category

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

Instance Method Summary collapse

Methods included from Printer

print_response, printable_issues

Methods included from Requestable

client, formatter, request

Constructor Details

#initializeCategory

Returns a new instance of Category.



4
5
6
7
8
# File 'lib/bl/commands/category.rb', line 4

def initialize(*)
  @config = Bl::Config.instance
  @url = "projects/#{@config[:project_key]}/categories"
  super
end

Instance Method Details

#add(*names) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/bl/commands/category.rb', line 18

def add(*names)
  names.each do |name|
    res = request(:post, @url, name: name)
    puts 'category added'
    print_response(res, :category)
  end
end

#delete(*ids) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/bl/commands/category.rb', line 37

def delete(*ids)
  ids.each do |id|
    res = request(:delete, "#{@url}/#{id}")
    puts 'category deleted'
    print_response(res, :category)
  end
end

#listObject



11
12
13
14
15
# File 'lib/bl/commands/category.rb', line 11

def list
  res = request(:get, @url)
  puts 'categories:'
  print_response(res, :category)
end

#update(*ids) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/bl/commands/category.rb', line 28

def update(*ids)
  ids.each do |id|
    res = request(:patch, "#{@url}/#{id}", delete_class_options(options))
    puts 'category updated'
    print_response(res, :category)
  end
end