Sha256: 102acc6f16bb10194b9039b571ab4c68b8f542a991eb474b504b21dd85f79898

Contents?: true

Size: 1.5 KB

Versions: 1

Compression:

Stored size: 1.5 KB

Contents

module TaskMapper::Provider
  module Zendesk
    # Project class for taskmapper-zendesk
    # 
    # 
    class Project < TaskMapper::Provider::Base::Project
	 attr_accessor :prefix_options
      #API = ZendeskAPI::Organization
      # declare needed overloaded methods here
      
      def initialize(*object)
        if object.first
          object = object.first
          unless object.is_a? Hash
            @system_data = {:client => object}
            hash = {:repository => object.account,
                    :user => object.username,
                    :name => object.name}
          else
            hash = object
          end
          super hash
        end
      end
      
      # copy from this.copy(that) copies that into this
      def copy(project)
        project.tickets.each do |ticket|
          copy_ticket = self.ticket!(:title => ticket.title, :description => ticket.description)
          ticket.comments.each do |comment|
            copy_ticket.comment!(:body => comment.body)
            sleep 1
          end
        end
      end

      def ticket(*options)
        if options.first.is_a? Fixnum
          ticket_id = options.first
          Ticket.find_by_id(self.name, ticket_id)
        elsif options.first.is_a? Hash
          Ticket.find_by_attributes(self.name, options.first).first
        else
          TaskMapper::Provider::Zendesk::Ticket
        end
      end

      def ticket!(*options)
        Ticket.new ZendeskAPI::Ticket.create(options.first), self.name
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
taskmapper-zendesk-0.5.1 lib/provider/project.rb