Sha256: 92c6a51adc091d515bca16268eda2c569ec4268025e44d65cc330882a40f62e6

Contents?: true

Size: 1.39 KB

Versions: 3

Compression:

Stored size: 1.39 KB

Contents

require 'taskmapper'
module TaskMapper::Provider
  # This is the Zendesk Provider for taskmapper
  module Zendesk
    include TaskMapper::Provider::Base
    #PROJECT_API = ZendeskAPI::Organization

    # This is for cases when you want to instantiate using TaskMapper::Provider::Yoursystem.new(auth)
    def self.new(auth = {})
      TaskMapper.new(:zendesk, auth)
    end

    # The authorize and initializer for this provider
    def authorize(auth = {})
      @authentication ||= TaskMapper::Authenticator.new(auth)
      auth = @authentication
      if (auth.account.nil? and auth.username.nil? and auth.password.nil?)
        raise "Please provide at least an url (subdomain), username and password)"
      end
      ZendeskAPI.authenticate(auth.account, auth.username, auth.password)
    end

    def projects(*options)
      [Project.new({:account => @authentication.account, :username => @authentication.username, :name => "#{@authentication.account}-project"})]
    end

    def project(*options)
      unless options.empty?
        Project.new({:account => @authentication.account, :username => @authentication.username, :name => "#{@authentication.account}-project"})
      else
        TaskMapper::Provider::Zendesk::Project
      end
    end

    def valid?
      begin
        !ZendeskAPI::Search.find(:first, :params => {:query => "status:open"}).nil?
      rescue
        false
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
taskmapper-zendesk-0.7.0 lib/provider/zendesk.rb
taskmapper-zendesk-0.6.0 lib/provider/zendesk.rb
taskmapper-zendesk-0.5.1 lib/provider/zendesk.rb