55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use GuzzleHttp\Client;
|
|
use GuzzleHttp\Psr7\Request as Psr7Request;
|
|
use LDC\LDCCRM\Enums\ApiError;
|
|
use LDC\LDCCRM\Enums\Country;
|
|
use LDC\LDCCRM\Enums\HttpMethods;
|
|
use LDC\LDCCRM\Exceptions\ApiErrorException;
|
|
use LDC\LDCCRM\Models\Customer;
|
|
use LDC\LDCCRM\Models\SingleOptin;
|
|
use Psr\Http\Message\ResponseInterface;
|
|
|
|
class MailjetTest extends CrmClientTester
|
|
{
|
|
|
|
/** @var \GuzzleHttp\Client */
|
|
private $client;
|
|
|
|
public function testMailjetHtaccess()
|
|
{
|
|
|
|
dd($this->callHttp(HttpMethods::post(), route('mailjet.unsubscribe')));
|
|
}
|
|
|
|
/**
|
|
* Make HTTP Calls
|
|
*
|
|
* @param HttpMethods $method
|
|
* @param string $uri
|
|
* @param array $headers
|
|
* @param array $data
|
|
* @return ResponseInterface
|
|
*/
|
|
private function callHttp(
|
|
HttpMethods $method,
|
|
string $uri,
|
|
array $headers = [],
|
|
array $data = []
|
|
): ResponseInterface {
|
|
$request = new Psr7Request(
|
|
\strtoupper($method),
|
|
$uri,
|
|
$headers,
|
|
$method->equals(HttpMethods::get()) ? null : \json_encode($data)
|
|
);
|
|
if (!$this->client) {
|
|
$this->client = new Client();
|
|
}
|
|
return $this->client->send($request, [
|
|
'http_errors' => false // do not throw http errors
|
|
]);
|
|
}
|
|
}
|