Viewing file: NotificationHelper.php (1.01 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
namespace App\Helpers;
use GuzzleHttp\Client;
class NotificationHelper
{
private $client;
public function __construct()
{
$this->client = new Client([
'base_uri' => env('NOTIFICATION_URL'),
'auth' => [env('NOTIFICATION_USER'), env('NOTIFICATION_PASSWORD')],
'headers' => [
'Accept' => 'application/json',
],
]);
}
public function send($endpoint,$body) {
try {
// $response = $this->client->request(
// 'POST',
// $this->buildEndpoint($endpoint, $body)
// );
$response = $this->client->post($endpoint, $body);
$content = json_decode($response->getBody()->getContents(), true);
if ($response->getStatusCode() === 200 ) {
return $content;
}
return null;
}catch (\Exception $exception) {
return null;
}
}
}
|