Class: Checkoff::Workspaces

Inherits:
Object
  • Object
show all
Extended by:
CacheMethod::ClassMethods
Defined in:
lib/checkoff/workspaces.rb,
sig/checkoff.rbs

Overview

Query different workspaces of Asana projects

Constant Summary collapse

MINUTE =

Returns:

  • (Object)
60
HOUR =

Returns:

  • (Object)
MINUTE * 60
DAY =

Returns:

  • (Object)
24 * HOUR
REALLY_LONG_CACHE_TIME =

Returns:

  • (Object)
HOUR * 1
LONG_CACHE_TIME =

Returns:

  • (Object)
MINUTE * 15
SHORT_CACHE_TIME =

Returns:

  • (Object)
MINUTE

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config: Checkoff::Internal::ConfigLoader.load(:asana), client: Checkoff::Clients.new(config:).client, asana_workspace: Asana::Resources::Workspace) ⇒ Workspaces

sord warn - Asana::Client wasn't able to be resolved to a constant in this project sord warn - Asana::Resources::Workspace wasn't able to be resolved to a constant in this project @param config

@param client

@param asana_workspace

Parameters:

  • config: (::Hash[untyped, untyped], Checkoff::Internal::EnvFallbackConfigLoader) (defaults to: Checkoff::Internal::ConfigLoader.load(:asana))
  • client: (Asana::Client) (defaults to: Checkoff::Clients.new(config:).client)
  • asana_workspace: (singleton(Asana::Resources::Workspace)) (defaults to: Asana::Resources::Workspace)


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

def initialize(config: Checkoff::Internal::ConfigLoader.load(:asana),
               client: Checkoff::Clients.new(config:).client,
               asana_workspace: Asana::Resources::Workspace)
  @config = config
  @client = client
  @asana_workspace = asana_workspace
end

Instance Attribute Details

#clientAsana::Client (readonly)

sord warn - Asana::Client wasn't able to be resolved to a constant in this project

Returns:

  • (Asana::Client)


72
73
74
# File 'lib/checkoff/workspaces.rb', line 72

def client
  @client
end

Instance Method Details

#default_workspaceAsana::Resources::Workspace

sord warn - Asana::Resources::Workspace wasn't able to be resolved to a constant in this project @sg-ignore

Returns:

  • (Asana::Resources::Workspace)


48
49
50
# File 'lib/checkoff/workspaces.rb', line 48

def default_workspace
  @asana_workspace.find_by_id(client, default_workspace_gid)
end

#default_workspace_gidString

@sg-ignore

Returns:

  • (String)


65
66
67
# File 'lib/checkoff/workspaces.rb', line 65

def default_workspace_gid
  @config.fetch(:default_workspace_gid)
end

#workspace(workspace_name) ⇒ Asana::Resources::Workspace?

sord warn - Asana::Resources::Workspace wasn't able to be resolved to a constant in this project Pulls an Asana workspace object

@param workspace_name

Parameters:

  • workspace_name (String, Symbol)

Returns:

  • (Asana::Resources::Workspace, nil)


39
40
41
42
43
# File 'lib/checkoff/workspaces.rb', line 39

def workspace(workspace_name)
  client.workspaces.find_all.find do |workspace|
    workspace.name == workspace_name
  end
end

#workspace_or_raise(workspace_name) ⇒ Asana::Resources::Workspace

sord warn - Asana::Resources::Workspace wasn't able to be resolved to a constant in this project @sg-ignore workspace() is nil-checked below

@param workspace_name

Parameters:

  • workspace_name (String, Symbol)

Returns:

  • (Asana::Resources::Workspace)


56
57
58
59
60
61
# File 'lib/checkoff/workspaces.rb', line 56

def workspace_or_raise(workspace_name)
  w = workspace(workspace_name)
  raise "Could not find workspace #{workspace_name}" if w.nil?

  w
end