class Dude::ProjectManagement::Trello::MoveTaskToList

Attributes

client[R]
id[R]
list_name[R]

Public Class Methods

new(client, id:, list_name:) click to toggle source
# File lib/dude/project_management/trello/move_task_to_list.rb, line 9
def initialize(client, id:, list_name:)
  @client = client
  @id = id
  @list_name = list_name
end

Public Instance Methods

call() click to toggle source
# File lib/dude/project_management/trello/move_task_to_list.rb, line 15
def call
  response = client.get("/1/boards/#{Dude::SETTINGS.dig(:jira, :board_id)}/cards/#{id}", { fields: 'id' })
  card_id = JSON.parse(response.body)['id']
  client.put("/1/cards/#{card_id}", { idList: list_id })
end

Private Instance Methods

list_id() click to toggle source
# File lib/dude/project_management/trello/move_task_to_list.rb, line 25
def list_id
  if list_name
    lists.find { |list| list['name'] == list_name }['id']
  else
    select_list_for_moving['id']
  end
end
lists() click to toggle source
# File lib/dude/project_management/trello/move_task_to_list.rb, line 47
def lists
  @lists ||= FetchLists.new(client).call
end
print_lists() click to toggle source
select_list_for_moving() click to toggle source
# File lib/dude/project_management/trello/move_task_to_list.rb, line 33
def select_list_for_moving
  puts 'Please, select list for moving:'.green.bold

  print_lists

  print "\nList index: ".bold
  list_index = $stdin.gets.chomp
  lists[list_index.to_i - 1]
end