You are here

public function SendinblueHttpClient::doRequestDirect in SendinBlue 8

Same name and namespace in other branches
  1. 8.2 src/Tools/Http/SendinblueHttpClient.php \Drupal\sendinblue\Tools\Http\SendinblueHttpClient::doRequestDirect()

Do CURL request directly into sendinblue.

Parameters

string $called_url: URL.

string $method: cURL method.

array $data: A data of curl request.

array $options: A data of curl options.

Return value

array An associate array with respond data.

Throws

\GuzzleHttp\Exception\GuzzleException

File

src/Tools/Http/SendinblueHttpClient.php, line 147

Class

SendinblueHttpClient
Sendinblue REST client.

Namespace

Drupal\sendinblue\Tools\Http

Code

public function doRequestDirect(string $called_url, string $method, array $data, array $options) {
  if (!function_exists('curl_init')) {
    $msg = 'SendinBlue requires CURL module';
    $this->loggerFactory
      ->get('sendinblue')
      ->error($msg);
    return NULL;
  }
  try {
    $clientRequest = $this->client
      ->request($method, $called_url, $options);
    $body = $clientRequest
      ->getBody();
  } catch (RequestException $e) {
    $this->loggerFactory
      ->get('sendinblue')
      ->error('Curl error: @error', [
      '@error' => $e
        ->getMessage(),
    ]);
  }
  return Json::decode($body);
}