Class: CapsuleCRM::Task

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Naming
Includes:
ActiveModel::Conversion, ActiveModel::Validations, Associations, Persistence::Deletable, Persistence::Persistable, Querying::Findable, Serializable
Defined in:
lib/capsule_crm/task.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Serializable

included, #serializer, #to_capsule_json

Methods included from Querying::Findable

included

Methods included from Persistence::Deletable

#build_destroy_path, #destroy

Methods included from Persistence::Persistable

#build_create_path, #build_update_path, #create_record, included, #new_record?, #persisted?, #save, #save!, #update_attributes, #update_attributes!, #update_record

Class Method Details

._for_case(case_id) ⇒ Object



55
56
57
58
59
# File 'lib/capsule_crm/task.rb', line 55

def self._for_case(case_id)
  CapsuleCRM::ResultsProxy.new(
    CapsuleCRM::Task.all.select { |task| task.case_id == case_id }
  )
end

._for_opportunity(opportunity_id) ⇒ Object



47
48
49
50
51
52
53
# File 'lib/capsule_crm/task.rb', line 47

def self._for_opportunity(opportunity_id)
  CapsuleCRM::ResultsProxy.new(
    CapsuleCRM::Task.all.select do |task|
      task.opportunity_id == opportunity_id
    end
  )
end

._for_party(party_id) ⇒ Object Also known as: _for_person, _for_organization



37
38
39
40
41
# File 'lib/capsule_crm/task.rb', line 37

def self._for_party(party_id)
  CapsuleCRM::ResultsProxy.new(
    CapsuleCRM::Task.all.select { |task| task.party_id == party_id }
  )
end

Instance Method Details

#completeObject



67
68
69
70
# File 'lib/capsule_crm/task.rb', line 67

def complete
  CapsuleCRM::Connection.post("/api/task/#{id}/complete")
  self
end

#create_urlObject



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/capsule_crm/task.rb', line 77

def create_url
  if party_id
    "party/#{party_id}/task"
  elsif opportunity_id
    "opportunity/#{opportunity_id}/task"
  elsif case_id
    "kase/#{case_id}/task"
  else
    'task'
  end
end

#owner=(user) ⇒ Object



61
62
63
64
65
# File 'lib/capsule_crm/task.rb', line 61

def owner=(user)
  user = CapsuleCRM::User.find_by_username(user) if user.is_a?(String)
  @owner = user
  self
end

#reopenObject



72
73
74
75
# File 'lib/capsule_crm/task.rb', line 72

def reopen
  CapsuleCRM::Connection.post("/api/task/#{id}/reopen")
  self
end