Class: Fizzy::CLI::Comments
- Inherits:
-
Thor
- Object
- Thor
- Fizzy::CLI::Comments
- Includes:
- Base
- Defined in:
- lib/fizzy/cli/comments.rb
Instance Method Summary collapse
- #create(body_text) ⇒ Object
- #delete(comment_id) ⇒ Object
- #get(comment_id) ⇒ Object
- #list ⇒ Object
- #update(comment_id) ⇒ Object
Methods included from Base
Instance Method Details
#create(body_text) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/fizzy/cli/comments.rb', line 32 def create(body_text) resp = client.post("cards/#{[:card]}/comments", body: { body: body_text }) c = resp.body output_detail(c, pairs: [ ["ID", c["id"]], ["Body", c["body"]] ]) end |
#delete(comment_id) ⇒ Object
59 60 61 62 |
# File 'lib/fizzy/cli/comments.rb', line 59 def delete(comment_id) client.delete("cards/#{[:card]}/comments/#{comment_id}") puts "Comment #{comment_id} deleted." end |
#get(comment_id) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/fizzy/cli/comments.rb', line 19 def get(comment_id) resp = client.get("cards/#{[:card]}/comments/#{comment_id}") c = resp.body output_detail(c, pairs: [ ["ID", c["id"]], ["Author", c.dig("creator", "name")], ["Body", c["body"]], ["Created", c["created_at"]] ]) end |
#list ⇒ Object
10 11 12 13 14 15 |
# File 'lib/fizzy/cli/comments.rb', line 10 def list data = paginator.all("cards/#{[:card]}/comments") output_list(data, headers: %w[ID Author Created]) do |c| [c["id"], c.dig("creator", "name"), c["created_at"]] end end |
#update(comment_id) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/fizzy/cli/comments.rb', line 44 def update(comment_id) resp = client.put("cards/#{[:card]}/comments/#{comment_id}", body: build_body(:body)) c = resp.body if c output_detail(c, pairs: [ ["ID", c["id"]], ["Body", c["body"]] ]) else puts "Comment #{comment_id} updated." end end |