You are here

protected function PardotClient::buildDefaultPostData in Pardot Integration 2.x

Build the default post data used by most service operations.

Return value

array|bool Array of default post data or FALSE on failure.

2 calls to PardotClient::buildDefaultPostData()
PardotClient::assignPardotProspect in src/Service/PardotClient.php
Assigns activity for a Visitor ID to a Prospect ID in Pardot.
PardotClient::getPardotProspect in src/Service/PardotClient.php
Retrieve a Pardot Prospect ID using an email address.

File

src/Service/PardotClient.php, line 287

Class

PardotClient
Provides methods to execute Pardot API operations.

Namespace

Drupal\pardot\Service

Code

protected function buildDefaultPostData() {
  $token = $this
    ->authenticate();
  if (!$token) {
    $this->logger
      ->error($this
      ->t('Unable to build POST data for Pardot API. One of the required parameters is missing'));
    return FALSE;
  }

  // Prepare post data.
  $payload = [
    RequestOptions::HEADERS => [
      'Authorization' => "Bearer {$token}",
      'Content-Type' => 'application/x-www-form-urlencoded',
      'Pardot-Business-Unit-Id' => $this->businessId,
    ],
    'data-urlencode' => [
      'id' => 7676,
    ],
    RequestOptions::FORM_PARAMS => [
      'api_key' => $token,
      'format' => 'json',
    ],
  ];
  return $payload;
}