Class: Bl::Category

Inherits:
Thor
  • Object
show all
Includes:
Requestable
Defined in:
lib/bl/category.rb

Instance Method Summary collapse

Methods included from Requestable

client

Constructor Details

#initializeCategory

Returns a new instance of Category.



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

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

Instance Method Details

#add(*names) ⇒ Object



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

def add(*names)
  names.each do |name|
    res = client.post(@url, name: name)
    puts "category added: #{res.body.id}\t#{res.body.name}"
  end
end

#delete(*ids) ⇒ Object



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

def delete(*ids)
  ids.each do |id|
    res = client.delete("#{@url}/#{id}")
    puts "category deleted: #{res.body.id}\t#{res.body.name}"
  end
end

#listObject



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

def list
  client.get(@url).body.each do |c|
    puts [c.id, c.name].join("\t")
  end
end

#update(*ids) ⇒ Object



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

def update(*ids)
  ids.each do |id|
    res = client.patch("#{@url}/#{id}", options)
    puts "category updated: #{res.body.id}\t#{res.body.name}"
  end
end