public function PardotClient::assignPardotProspect in Pardot Integration 2.x
Assigns activity for a Visitor ID to a Prospect ID in Pardot.
Parameters
string $visitor_id: The Pardot Visitor ID to assign to a Prospect ID.
string $prospect_id: The Pardot Prospect ID to which to assign a Visitor ID.
Return value
boolean TRUE if the Visitor ID is successfully assigned to the Prospect ID; False otherwise.
Overrides PardotClientInterface::assignPardotProspect
File
- src/
Service/ PardotClient.php, line 256
Class
- PardotClient
- Provides methods to execute Pardot API operations.
Namespace
Drupal\pardot\ServiceCode
public function assignPardotProspect(string $visitor_id, string $prospect_id) {
if (!$visitor_id || !$prospect_id) {
$this->logger
->error($this
->t('Unable to assign Pardot prospect. Either Visitor ID or Prospect ID are missing.'));
return FALSE;
}
// Build the request to retrieve prospect data from Pardot.
$post_data = $this
->buildDefaultPostData();
$assign_options = [
'id' => $visitor_id,
'prospect_id' => $prospect_id,
];
$post_data[RequestOptions::FORM_PARAMS] = array_merge($post_data[RequestOptions::FORM_PARAMS], $assign_options);
// Execute the request.
$assign_endpoint = "{$this->apibaseUrl}/api/visitor/version/4/do/assign/id/{$visitor_id}?prospect_id={$prospect_id}";
$response = $this
->executePardotOperation($assign_endpoint, $post_data);
if (is_array($response) && $response['@attributes']['stat'] == 'ok') {
return TRUE;
}
return FALSE;
}