Class: Checkoff::Workspaces

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

Overview

Query different workspaces of Asana projects

Instance Method Summary collapse

Constructor Details

#initialize(config: Checkoff::ConfigLoader.load(:asana), asana_client: Asana::Client) ⇒ Workspaces

Returns a new instance of Workspaces.



6
7
8
9
10
# File 'lib/checkoff/workspaces.rb', line 6

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

Instance Method Details

#clientObject



12
13
14
15
16
# File 'lib/checkoff/workspaces.rb', line 12

def client
  @client ||= @asana_client.new do |c|
    c.authentication :access_token, @config[:personal_access_token]
  end
end

#default_workspace_idObject



18
19
20
# File 'lib/checkoff/workspaces.rb', line 18

def default_workspace_id
  @config[:default_workspace_id]
end

#workspace_by_name(workspace_name) ⇒ Object



22
23
24
25
26
# File 'lib/checkoff/workspaces.rb', line 22

def workspace_by_name(workspace_name)
  client.workspaces.find_all.find do |workspace|
    workspace.name == workspace_name
  end || raise("Could not find workspace #{workspace_name}")
end