Sha256: 1c8b09e8433f543bf44503cb76ef33dd6b305f3f5b1761023b71880a5fce3878

Contents?: true

Size: 809 Bytes

Versions: 9

Compression:

Stored size: 809 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]
        c.default_headers 'asana-enable' => 'string_ids,new_sections'
      end
    end

    def default_workspace_gid
      @config[:default_workspace_gid]
    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

9 entries across 9 versions & 1 rubygems

Version Path
checkoff-0.6.0 lib/checkoff/workspaces.rb
checkoff-0.5.5 lib/checkoff/workspaces.rb
checkoff-0.5.4 lib/checkoff/workspaces.rb
checkoff-0.5.3 lib/checkoff/workspaces.rb
checkoff-0.5.2 lib/checkoff/workspaces.rb
checkoff-0.5.1 lib/checkoff/workspaces.rb
checkoff-0.5.0 lib/checkoff/workspaces.rb
checkoff-0.4.0 lib/checkoff/workspaces.rb
checkoff-0.3.2 lib/checkoff/workspaces.rb