Sha256: 693028d91f9ac9fa7bceb97c8377c0050690b73cc8643a3849a41059010e0427

Contents?: true

Size: 1.29 KB

Versions: 9

Compression:

Stored size: 1.29 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,new_memberships'
      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

9 entries across 9 versions & 1 rubygems

Version Path
checkoff-0.33.1 lib/checkoff/clients.rb
checkoff-0.33.0 lib/checkoff/clients.rb
checkoff-0.32.0 lib/checkoff/clients.rb
checkoff-0.31.0 lib/checkoff/clients.rb
checkoff-0.30.0 lib/checkoff/clients.rb
checkoff-0.29.4 lib/checkoff/clients.rb
checkoff-0.29.3 lib/checkoff/clients.rb
checkoff-0.29.2 lib/checkoff/clients.rb
checkoff-0.29.1 lib/checkoff/clients.rb