Class: Fizzy::CLI::Steps

Inherits:
Thor
  • Object
show all
Includes:
Base
Defined in:
lib/fizzy/cli/steps.rb

Instance Method Summary collapse

Methods included from Base

included

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/#{options[: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/#{options[: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/#{options[: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

Raises:

  • (Thor::Error)


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] = options[:description] if options[:description]
  body[:completed] = options[:completed] unless options[:completed].nil?
  raise Thor::Error, "Nothing to update. Provide --description or --completed" if body.empty?

  path = "cards/#{options[: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