Class: Checkoff::Clients

Inherits:
Object
  • Object
show all
Defined in:
lib/checkoff/clients.rb

Overview

Pulls a configured Asana client object which can be used to access the API

Constant Summary collapse

MINUTE =
60
HOUR =
MINUTE * 60
DAY =
24 * HOUR
REALLY_LONG_CACHE_TIME =
HOUR * 1
LONG_CACHE_TIME =
MINUTE * 15
SHORT_CACHE_TIME =
MINUTE

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config: Checkoff::Internal::ConfigLoader.load(:asana), asana_client_class: Asana::Client) ⇒ Clients

Returns a new instance of Clients.



21
22
23
24
25
# File 'lib/checkoff/clients.rb', line 21

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

Class Method Details

.runObject



43
44
45
46
47
# File 'lib/checkoff/clients.rb', line 43

def run
  clients = Checkoff::Clients.new
  client = clients.client
  puts "Results: #{client}"
end

Instance Method Details

#clientAsana::Client

Returns:

  • (Asana::Client)


28
29
30
31
32
33
34
# File 'lib/checkoff/clients.rb', line 28

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,new_goal_memberships'
  end
end