class Abt::Providers::Asana::Commands::HarvestTimeEntryData
Public Class Methods
description()
click to toggle source
# File lib/abt/providers/asana/commands/harvest_time_entry_data.rb, line 12 def self.description "Print Harvest time entry data for Asana task as json. Used by harvest start script." end
usage()
click to toggle source
# File lib/abt/providers/asana/commands/harvest_time_entry_data.rb, line 8 def self.usage "abt harvest-time-entry-data asana[:<project-gid>/<task-gid>]" end
Public Instance Methods
perform()
click to toggle source
# File lib/abt/providers/asana/commands/harvest_time_entry_data.rb, line 16 def perform require_task! ensure_current_is_valid! puts Oj.dump(body, mode: :json) end
Private Instance Methods
body()
click to toggle source
# File lib/abt/providers/asana/commands/harvest_time_entry_data.rb, line 25 def body { notes: task["name"], external_reference: { id: task_gid.to_i, group_id: project_gid.to_i, permalink: task["permalink_url"] } } end
ensure_current_is_valid!()
click to toggle source
# File lib/abt/providers/asana/commands/harvest_time_entry_data.rb, line 36 def ensure_current_is_valid! abort("Invalid task gid: #{task_gid}") if task.nil? return if task["memberships"].any? { |m| m.dig("project", "gid") == project_gid } abort("Invalid or unmatching project gid: #{project_gid}") end
task()
click to toggle source
# File lib/abt/providers/asana/commands/harvest_time_entry_data.rb, line 44 def task @task ||= begin warn("Fetching task...") api.get("tasks/#{task_gid}", opt_fields: "name,permalink_url,memberships.project") rescue Abt::HttpError::NotFoundError nil end end