Sha256: 75704d9ce7d5e521f328c1b506f5ee2b5f51fcebd07f1e908ed03449b0c12739

Contents?: true

Size: 1.27 KB

Versions: 17

Compression:

Stored size: 1.27 KB

Contents

#!/usr/bin/env ruby

# frozen_string_literal: true

require 'forwardable'
require_relative 'internal/config_loader'
require 'asana'

# https://developers.asana.com/docs/clients

module Checkoff
  # Pulls a configured Asana client object which can be used to access the API
  class Clients
    MINUTE = 60
    HOUR = MINUTE * 60
    DAY = 24 * HOUR
    REALLY_LONG_CACHE_TIME = HOUR * 1
    LONG_CACHE_TIME = MINUTE * 15
    SHORT_CACHE_TIME = MINUTE

    def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
                   asana_client_class: Asana::Client)
      @config = config
      @asana_client_class = asana_client_class
    end

    def client
      @client ||= @asana_client_class.new do |c|
        c.authentication :access_token, @config.fetch(:personal_access_token)
        c.default_headers 'asana-enable' => 'new_project_templates,new_user_task_lists'
      end
    end

    private

    attr_reader :workspaces

    # bundle exec ./clients.rb
    # :nocov:
    class << self
      def run
        clients = Checkoff::Clients.new
        client = clients.client
        puts "Results: #{client}"
      end
    end
    # :nocov:
  end
end

# :nocov:
abs_program_name = File.expand_path($PROGRAM_NAME)
Checkoff::Clients.run if abs_program_name == __FILE__
# :nocov:

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
checkoff-0.29.0 lib/checkoff/clients.rb
checkoff-0.28.0 lib/checkoff/clients.rb
checkoff-0.27.0 lib/checkoff/clients.rb
checkoff-0.26.1 lib/checkoff/clients.rb
checkoff-0.26.0 lib/checkoff/clients.rb
checkoff-0.25.0 lib/checkoff/clients.rb
checkoff-0.24.1 lib/checkoff/clients.rb
checkoff-0.24.0 lib/checkoff/clients.rb
checkoff-0.23.0 lib/checkoff/clients.rb
checkoff-0.22.0 lib/checkoff/clients.rb
checkoff-0.21.0 lib/checkoff/clients.rb
checkoff-0.20.0 lib/checkoff/clients.rb
checkoff-0.19.2 lib/checkoff/clients.rb
checkoff-0.19.1 lib/checkoff/clients.rb
checkoff-0.19.0 lib/checkoff/clients.rb
checkoff-0.18.1 lib/checkoff/clients.rb
checkoff-0.18.0 lib/checkoff/clients.rb