From 1d48310a5a60358329f826b1e94f7fccecf5f78a Mon Sep 17 00:00:00 2001 From: Dominik Kapusta Date: Wed, 2 Oct 2024 06:29:02 -0400 Subject: [PATCH] Use make_asana_client everywhere --- .../actions/asana_create_action_item_action.rb | 5 +---- .../actions/asana_find_release_task_action.rb | 6 +----- .../actions/asana_log_message_action.rb | 5 +---- .../plugin/ddg_apple_automation/helper/asana_helper.rb | 8 ++++++++ 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/lib/fastlane/plugin/ddg_apple_automation/actions/asana_create_action_item_action.rb b/lib/fastlane/plugin/ddg_apple_automation/actions/asana_create_action_item_action.rb index 613d304..7def925 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/actions/asana_create_action_item_action.rb +++ b/lib/fastlane/plugin/ddg_apple_automation/actions/asana_create_action_item_action.rb @@ -145,10 +145,7 @@ def self.create_subtask(token:, task_id:, assignee_id:, task_name:, notes: nil, subtask_options[:notes] = notes unless notes.nil? subtask_options[:html_notes] = html_notes unless html_notes.nil? - asana_client = Asana::Client.new do |c| - c.authentication(:access_token, token) - c.default_headers("Asana-Enable" => "new_goal_memberships,new_user_task_lists") - end + asana_client = Helper::AsanaHelper.make_asana_client(token) asana_client.tasks.create_subtask_for_task(**subtask_options) end end diff --git a/lib/fastlane/plugin/ddg_apple_automation/actions/asana_find_release_task_action.rb b/lib/fastlane/plugin/ddg_apple_automation/actions/asana_find_release_task_action.rb index a1d80d8..3cdf2ad 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/actions/asana_find_release_task_action.rb +++ b/lib/fastlane/plugin/ddg_apple_automation/actions/asana_find_release_task_action.rb @@ -83,11 +83,7 @@ def self.validate_semver(version) end def self.find_release_task(version, asana_access_token) - asana_client = Asana::Client.new do |c| - c.authentication(:access_token, asana_access_token) - c.default_headers("Asana-Enable" => "new_goal_memberships,new_user_task_lists") - end - + asana_client = Helper::AsanaHelper.make_asana_client(asana_access_token) release_task_id = nil begin diff --git a/lib/fastlane/plugin/ddg_apple_automation/actions/asana_log_message_action.rb b/lib/fastlane/plugin/ddg_apple_automation/actions/asana_log_message_action.rb index 3e32b46..1ee44e6 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/actions/asana_log_message_action.rb +++ b/lib/fastlane/plugin/ddg_apple_automation/actions/asana_log_message_action.rb @@ -21,10 +21,7 @@ def self.run(params) asana_user_id = find_asana_user_id(params) args[:assignee_id] = asana_user_id - asana_client = Asana::Client.new do |c| - c.authentication(:access_token, token) - c.default_headers("Asana-Enable" => "new_goal_memberships,new_user_task_lists") - end + asana_client = Helper::AsanaHelper.make_asana_client(token) begin UI.important("Adding user #{asana_user_id} as collaborator on release task's 'Automation' subtask") diff --git a/lib/fastlane/plugin/ddg_apple_automation/helper/asana_helper.rb b/lib/fastlane/plugin/ddg_apple_automation/helper/asana_helper.rb index 2659845..0e0e2ee 100644 --- a/lib/fastlane/plugin/ddg_apple_automation/helper/asana_helper.rb +++ b/lib/fastlane/plugin/ddg_apple_automation/helper/asana_helper.rb @@ -194,6 +194,14 @@ def self.create_release_task(platform, version, assignee_id, asana_access_token) task_id end + # Updates asana tasks for a release + # + # @param github_token [String] GitHub token + # @param asana_access_token [String] Asana access token + # @param release_task_id [String] Asana access token + # @param validation_section_id [String] ID of the 'Validation' section in the Asana project + # @param version [String] version number + # def self.update_asana_tasks_for_release(params) UI.message("Checking latest public release in GitHub") client = Octokit::Client.new(access_token: params[:github_token])