Sha256: f8531a1ab4ee9ec66b8e6fe6c3d3c6e6bca448f2865935390f0fa7d1ab1ac91c
Contents?: true
Size: 1.28 KB
Versions: 4
Compression:
Stored size: 1.28 KB
Contents
# frozen_string_literal: true require_relative './fetch_lists' module Dude module ProjectManagement module Trello class MoveTaskToList def initialize(client, id:, list_name:) @client = client @id = id @list_name = list_name end 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 attr_reader :client, :id, :list_name def list_id if list_name lists.find { |list| list['name'] == list_name }['id'] else select_list_for_moving['id'] end end 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 def print_lists lists.map { |list| list['name'] }.each_with_index { |name, index| puts "#{index + 1}: #{name.bold}" } end def lists @lists ||= FetchLists.new(client).call end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems