Module: CiviCrm::Actions::Destroy

Included in:
BaseResource
Defined in:
lib/civicrm/actions/destroy.rb

Instance Method Summary collapse

Instance Method Details

#deleteObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/civicrm/actions/destroy.rb', line 4

def delete
  params = {
    'entity' => self.class.entity_class_name,
    'action' => 'delete',
    'id' => id
  }

  response = CiviCrm::Client.request(:post, params)
  response = response.first if response.is_a?(Array)

  if response < 1
    raise Error, "Couldn't delete #{entity_class_name}##{id}"
  end
end

#delete!Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/civicrm/actions/destroy.rb', line 19

def delete!
  params = {
    'entity' => self.class.entity_class_name,
    'action' => 'delete',
    'skip_undelete' => 1,
    'id' => id
  }

  response = CiviCrm::Client.request(:post, params)
  response = response.first if response.is_a?(Array)

  if response < 1
    raise Error, "Couldn't delete #{entity_class_name}##{id}"
  end
end