Class: Bl::Category
- Inherits:
-
Thor
- Object
- Thor
- Bl::Category
- Includes:
- Requestable
- Defined in:
- lib/bl/category.rb
Instance Method Summary collapse
- #add(*names) ⇒ Object
- #delete(*ids) ⇒ Object
-
#initialize ⇒ Category
constructor
A new instance of Category.
- #list ⇒ Object
- #update(*ids) ⇒ Object
Methods included from Requestable
Constructor Details
#initialize ⇒ Category
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 |
#list ⇒ Object
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}", ) puts "category updated: #{res.body.id}\t#{res.body.name}" end end |