You are here

public function RestClient::objectDelete in Salesforce Suite 8.4

Same name and namespace in other branches
  1. 8.3 src/Rest/RestClient.php \Drupal\salesforce\Rest\RestClient::objectDelete()
  2. 5.0.x src/Rest/RestClient.php \Drupal\salesforce\Rest\RestClient::objectDelete()

Delete a Salesforce object.

Note: if Object with given $id doesn't exist, objectDelete() will assume success unless $throw_exception is given.

Parameters

string $name: Object type name, E.g., Contact, Account.

string $id: Salesforce id of the object.

bool $throw_exception: (optional) If TRUE, 404 response code will cause RequestException to be thrown. Otherwise, hide those errors. Default is FALSE.

Return value

null Delete() doesn't return any data. Examine HTTP response or Exception.

Overrides RestClientInterface::objectDelete

1 method overrides RestClient::objectDelete()
TestRestClient::objectDelete in src/Tests/TestRestClient.php
Delete a Salesforce object.

File

src/Rest/RestClient.php, line 551

Class

RestClient
Objects, properties, and methods to communicate with the Salesforce REST API.

Namespace

Drupal\salesforce\Rest

Code

public function objectDelete($name, $id, $throw_exception = FALSE) {
  try {
    $this
      ->apiCall("sobjects/{$name}/{$id}", [], 'DELETE');
  } catch (RequestException $e) {
    if ($throw_exception || $e
      ->getResponse()
      ->getStatusCode() != 404) {
      throw $e;
    }
  }
}