Class: Fizzy::CLI::Steps
- Inherits:
-
Thor
- Object
- Thor
- Fizzy::CLI::Steps
- Includes:
- Base
- Defined in:
- lib/fizzy/cli/steps.rb
Instance Method Summary collapse
- #create(description) ⇒ Object
- #delete(step_id) ⇒ Object
- #get(step_id) ⇒ Object
- #update(step_id) ⇒ Object
Methods included from Base
Instance Method Details
#create(description) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/fizzy/cli/steps.rb', line 23 def create(description) resp = client.post("cards/#{[:card]}/steps", body: { content: description }) s = resp.body output_detail(s, pairs: [ ["ID", s["id"]], ["Description", s["content"]] ]) end |
#delete(step_id) ⇒ Object
58 59 60 61 |
# File 'lib/fizzy/cli/steps.rb', line 58 def delete(step_id) client.delete("cards/#{[:card]}/steps/#{step_id}") puts "Step #{step_id} deleted." end |
#get(step_id) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/fizzy/cli/steps.rb', line 10 def get(step_id) resp = client.get("cards/#{[:card]}/steps/#{step_id}") s = resp.body output_detail(s, pairs: [ ["ID", s["id"]], ["Description", s["content"]], ["Completed", s["completed"]], ["Position", s["position"]] ]) end |
#update(step_id) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/fizzy/cli/steps.rb', line 36 def update(step_id) body = {} body[:content] = [:description] if [:description] body[:completed] = [:completed] unless [:completed].nil? raise Thor::Error, "Nothing to update. Provide --description or --completed" if body.empty? path = "cards/#{[:card]}/steps/#{step_id}" resp = client.put(path, body: body) s = resp.body if s output_detail(s, pairs: [ ["ID", s["id"]], ["Description", s["content"]], ["Completed", s["completed"]] ]) else puts "Step #{step_id} updated." end end |