Sha256: ad525bfd16de53ae507a3e1f7f7634f1f570d93ccf5e49d26407395786464f15

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

#!/usr/bin/env ruby

# frozen_string_literal: true

require_relative 'sections'

module Checkoff
  # Pull things from 'my tasks' in Asana
  class Tasks
    MINUTE = 60
    HOUR = MINUTE * 60
    DAY = 24 * HOUR
    REALLY_LONG_CACHE_TIME = HOUR
    LONG_CACHE_TIME = MINUTE * 15
    SHORT_CACHE_TIME = MINUTE * 5

    def initialize(config: Checkoff::ConfigLoader.load(:asana),
                   sections: Checkoff::Sections.new,
                   asana_task: Asana::Resources::Task)
      @config = config
      @sections = sections
      @asana_task = asana_task
    end

    def client
      @sections.client
    end

    def tasks_minus_sections(tasks)
      @sections.by_section(tasks).values.flatten
    end

    def add_task(name,
                 workspace_id: default_workspace_id,
                 assignee_id: default_assignee_id)
      @asana_task.create(client,
                         assignee: assignee_id,
                         workspace: workspace_id, name: name)
    end

    def default_assignee_id
      @config[:default_assignee_id]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
checkoff-0.1.6 lib/checkoff/tasks.rb
checkoff-0.1.5 lib/checkoff/tasks.rb