Sha256: 191555690c8144b628deeec67333d5439dbf54059c504978aea240aee50d0e4d

Contents?: true

Size: 737 Bytes

Versions: 4

Compression:

Stored size: 737 Bytes

Contents

# frozen_string_literal: true

module Checkoff
  # Query different workspaces of Asana projects
  class Workspaces
    def initialize(config: Checkoff::ConfigLoader.load(:asana),
                   asana_client: Asana::Client)
      @config = config
      @asana_client = asana_client
    end

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

    def default_workspace_id
      @config[:default_workspace_id]
    end

    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
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
checkoff-0.2.0 lib/checkoff/workspaces.rb
checkoff-0.1.7 lib/checkoff/workspaces.rb
checkoff-0.1.6 lib/checkoff/workspaces.rb
checkoff-0.1.5 lib/checkoff/workspaces.rb