Class: Agile::Tickets
- Inherits:
-
Thor
- Object
- Thor
- Agile::Tickets
- Defined in:
- lib/agile/commands/tickets.rb
Instance Method Summary collapse
Instance Method Details
#create(ticket) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/agile/commands/tickets.rb', line 4 def create(ticket) ticket_name = ticket cli = HighLine.new ticket_description = cli.ask("description for ticket: ", String) RestClient.post"#{CONFIG['current_remote']}/api/v1/tickets/", project_id: CONFIG["current_project_id"], name: ticket_name, user: CONFIG["current_user"], desc: ticket_description say "Successfully added new ticket!" end |
#list ⇒ Object
15 16 17 18 19 20 |
# File 'lib/agile/commands/tickets.rb', line 15 def list response = RestClient.get "#{CONFIG['current_remote']}/api/v1/tickets/" info = JSON.parse(response) say Rainbow("<<All tickets>>").cornflower info.each { |ticket| puts_tickets(info) if ticket["project_id"] == CONFIG["current_project_id"] } end |
#show(ticket) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/agile/commands/tickets.rb', line 23 def show(ticket) response = RestClient.get "#{CONFIG['current_remote']}/api/v1/tickets/#{ticket}" row = JSON.parse(response) say "Ticket: #{row['data']['attributes']['name']}" say "Description: #{row['data']['attributes']['description']}" end |
#update(ticket) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/agile/commands/tickets.rb', line 31 def update(ticket) choice = HighLine.new answer = choice.ask("Choose what you need to edit : name or description (N or D): ", String) if answer == "N" update_name(ticket) elsif answer == "D" update_description(ticket) else say "Try again" end end |