Class: TicketMaster::Provider::Basecamp::Comment

Inherits:
TicketMaster::Provider::Base::Comment
  • Object
show all
Defined in:
lib/provider/comment.rb

Overview

The comment class for ticketmaster-basecamp

Do any mapping between Ticketmaster and your system’s comment model here versions of the ticket.

Constant Summary collapse

API =

declare needed overloaded methods here

BasecampAPI::Comment

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*object) ⇒ Comment

Returns a new instance of Comment.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/provider/comment.rb', line 12

def initialize(*object)
  if object.first
    object = object.first
    unless object.is_a? Hash
      hash = {:id => object.id,
              :body => object.body,
              :author => object.author_name,
              :created_at => object.created_at,
              :project_id => object.project_id,
              :ticket_id => object.ticket_id}
    else
      hash = object
    end
    super hash
  end
end

Class Method Details

.find_by_attributes(project_id, ticket_id, attributes = {}) ⇒ Object



34
35
36
# File 'lib/provider/comment.rb', line 34

def self.find_by_attributes(project_id, ticket_id, attributes = {})
  self.search(project_id, ticket_id, attributes)
end

.find_by_id(project_id, ticket_id, id) ⇒ Object



29
30
31
32
# File 'lib/provider/comment.rb', line 29

def self.find_by_id(project_id, ticket_id, id)
  basecamp_comment = self::API.find(id, :params => {:todo_item_id => ticket_id})
  self.new basecamp_comment.attributes.merge!(:project_id => project_id, :ticket_id => ticket_id)
end

.search(project_id, ticket_id, options = {}, limit = 1000) ⇒ Object



38
39
40
41
# File 'lib/provider/comment.rb', line 38

def self.search(project_id, ticket_id, options = {}, limit = 1000)
  comments = API.find(:all, :params => {:todo_item_id => ticket_id}).collect {|c| self.new(c.attributes.merge!(:project_id => project_id, :ticket_id => ticket_id)) }
  search_by_attribute(comments, options, limit)
end