Sha256: 4d2442ed90e9ad8a8a9e36db62d760351121b0b74123b5598f9323fd5f6f0f9d

Contents?: true

Size: 1.59 KB

Versions: 7

Compression:

Stored size: 1.59 KB

Contents

module TicketMaster::Provider
  module Zendesk
    # Project class for ticketmaster-zendesk
    # 
    # 
    class Project < TicketMaster::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 tickets(*options)
        Ticket.find(self.name, options)
      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
          TicketMaster::Provider::Zendesk::Ticket
        end
      end

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

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ticketmaster-zendesk-0.4.5 lib/provider/project.rb
ticketmaster-zendesk-0.4.4 lib/provider/project.rb
ticketmaster-zendesk-0.3.4 lib/provider/project.rb
ticketmaster-zendesk-0.3.3 lib/provider/project.rb
ticketmaster-zendesk-0.2.3 lib/provider/project.rb
ticketmaster-zendesk-0.2.2 lib/provider/project.rb
ticketmaster-zendesk-0.1.2 lib/provider/project.rb