Class: Highrise::Subject

Inherits:
Base
  • Object
show all
Defined in:
lib/highrise/subject.rb

Direct Known Subclasses

Company, Deal, Kase, Person

Instance Method Summary collapse

Instance Method Details

#add_deal!(name, category, status = nil, background = nil) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/highrise/subject.rb', line 21

def add_deal!(name, category, status=nil, background=nil)
  category_object = Deal::DealCategory.find_by_name(category)
  category_id = category_object ? category_object.id : nil
  deal = Deal.new(:name => name, :background => background, :status => status || "pending", :category_id => category_id)
  deal.price_type = 'fixed'
  deal.party_id   = self.id
  deal.save
end

#add_note!(note_body) ⇒ Object



15
16
17
18
19
# File 'lib/highrise/subject.rb', line 15

def add_note!(note_body)
  return if note_body.blank?
  note = Note.new(:body => note_body)
  self.post(:notes, {}, note.to_xml)
end

#add_task!(body, due_date, arguments = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/highrise/subject.rb', line 30

def add_task!(body, due_date, arguments = {})
  category = Task::TaskCategory.find_by_name(arguments[:category])
  category_id = category ? category.id : nil

  task = Task.new(arguments.merge(:body => body, :category_id => category_id))

  if Task::DUE_DATES.include?(due_date.to_s)
    task.frame = due_date
  else
    task.frame = 'specific'
    task.due_at = due_date
  end

  task.subject_type = self.instance_of?(Kase) ? 'Kase' : 'Party'
  task.subject_id   = self.id
  task.save
end

#emailsObject



7
8
9
# File 'lib/highrise/subject.rb', line 7

def emails
  Email.find_all_across_pages(:from => "/#{self.class.collection_name}/#{id}/emails.xml")
end

#notesObject



3
4
5
# File 'lib/highrise/subject.rb', line 3

def notes
  Note.find_all_across_pages(:from => "/#{self.class.collection_name}/#{id}/notes.xml")
end

#upcoming_tasksObject



11
12
13
# File 'lib/highrise/subject.rb', line 11

def upcoming_tasks
  Task.find(:all, :from => "/#{self.class.collection_name}/#{id}/tasks.xml")
end