class Fastlane::Actions::TrelloMoveCardAction
Public Class Methods
available_options()
click to toggle source
# File lib/fastlane/plugin/trello/actions/trello_move_card.rb, line 82 def self.available_options [ FastlaneCore::ConfigItem.new(key: :api_key, env_name: "TRELLO_API_KEY", description: "Trello API Key (get one at: https://trello.com/app-key)", optional: false, type: String), FastlaneCore::ConfigItem.new(key: :api_token, env_name: "TRELLO_API_TOKEN", description: "Trello API Token (get one at: https://trello.com/app-key)", optional: false, type: String), FastlaneCore::ConfigItem.new(key: :board_id, env_name: "TRELLO_BOARD_ID", description: "The ID of the Trello board. You can find it in the trello board URL", optional: false, type: String), FastlaneCore::ConfigItem.new(key: :list_name, env_name: "TRELLO_LIST_NAME", description: "The name of the list to move the card", optional: false, type: String), FastlaneCore::ConfigItem.new(key: :card_number, env_name: "TRELLO_CARD_NUMBER", description: "The number of the card to be moved the given list", optional: false, type: Integer) ] end
description()
click to toggle source
# File lib/fastlane/plugin/trello/actions/trello_move_card.rb, line 70 def self.description "Moves a Trello card to a given list" end
find_card_by(short_id:)
click to toggle source
# File lib/fastlane/plugin/trello/actions/trello_move_card.rb, line 54 def self.find_card_by(short_id:) url = URI("#{@base_path}/boards/#{@board_id}/cards/#{short_id}?fields=id%2Cname&key=#{@key}&token=#{@token}") request = Net::HTTP::Get.new(url) response = @http.request(request) card = JSON.parse(response.body) return card end
find_list_by(name:)
click to toggle source
# File lib/fastlane/plugin/trello/actions/trello_move_card.rb, line 45 def self.find_list_by(name:) url = URI("#{@base_path}/boards/#{@board_id}/lists?fields=id%2Cname&cards=none&card_fields=all&filter=open&key=#{@key}&token=#{@token}") request = Net::HTTP::Get.new(url) response = @http.request(request) lists = JSON.parse(response.body) list = lists.find { |list| list["name"] == name } return list end
is_supported?(platform)
click to toggle source
# File lib/fastlane/plugin/trello/actions/trello_move_card.rb, line 112 def self.is_supported?(platform) true end
move_card(card_id:, list_id:)
click to toggle source
# File lib/fastlane/plugin/trello/actions/trello_move_card.rb, line 62 def self.move_card(card_id:, list_id:) url = URI("#{@base_path}/cards/#{card_id}?idList=#{list_id}&key=#{@key}&token=#{@token}") request = Net::HTTP::Put.new(url) response = @http.request(request) card = JSON.parse(response.body) return card end
return_value()
click to toggle source
# File lib/fastlane/plugin/trello/actions/trello_move_card.rb, line 78 def self.return_value # If your method provides a return value, you can describe here what it does end
run(params)
click to toggle source
# File lib/fastlane/plugin/trello/actions/trello_move_card.rb, line 17 def self.run(params) @key = params[:api_key] @token = params[:api_token] @board_id = params[:board_id] list_name = params[:list_name] card_number = params[:card_number] UI.message("Fetching Trello list '#{list_name}'...") list = find_list_by(name: list_name) unless list UI.error("List #{list_name} not found.") return end list_id = list["id"] UI.message("Fetching Trello card [##{card_number}]...") card = find_card_by(short_id: card_number) unless card UI.error("Card #{card_number} not found.") return end card_name = card["name"] UI.message("Moving card [##{card_number}] '#{card_name}' to list '#{list_name}'") move_card(card_id: card["id"], list_id: list_id) end