From 89c716f4fad54d9c3945d7fc89dd27b744aadd52 Mon Sep 17 00:00:00 2001 From: javier-villatoro Date: Mon, 5 Aug 2024 18:45:24 -0600 Subject: [PATCH] Formatting and fix tests --- src/Exceptions/LeverClientException.php | 2 +- src/Http/Client/LeverClient.php | 10 +++++----- tests/OpportunitiesTest.php | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Exceptions/LeverClientException.php b/src/Exceptions/LeverClientException.php index 7550548..706a4f4 100644 --- a/src/Exceptions/LeverClientException.php +++ b/src/Exceptions/LeverClientException.php @@ -8,6 +8,6 @@ class LeverClientException extends RuntimeException { public function __construct($message, $code = 0, \Exception $previous = null) { - parent::__construct("Bluelightco\LeverPhp: " . $message, $code, $previous); + parent::__construct("Bluelightco\LeverPhp: ".$message, $code, $previous); } } diff --git a/src/Http/Client/LeverClient.php b/src/Http/Client/LeverClient.php index 73c481f..3e8aefe 100644 --- a/src/Http/Client/LeverClient.php +++ b/src/Http/Client/LeverClient.php @@ -2,21 +2,21 @@ namespace Bluelightco\LeverPhp\Http\Client; +use Bluelightco\LeverPhp\Exceptions\LeverClientException; use Bluelightco\LeverPhp\Http\Middleware\LeverRateStore; use Bluelightco\LeverPhp\Http\Middleware\QueryStringCleanerMiddleware; use Bluelightco\LeverPhp\Http\Responses\ApiResponse; +use Exception; use GrahamCampbell\GuzzleFactory\GuzzleFactory; use GuzzleHttp\Client; use GuzzleHttp\Exception\ClientException; use GuzzleHttp\HandlerStack; +use Illuminate\Support\Facades\Log; use Illuminate\Support\LazyCollection; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\StreamInterface; use Spatie\GuzzleRateLimiterMiddleware\RateLimiterMiddleware; use Spatie\GuzzleRateLimiterMiddleware\Store; -use Illuminate\Support\Facades\Log; -use Bluelightco\LeverPhp\Exceptions\LeverClientException; -use Exception; class LeverClient { @@ -486,7 +486,7 @@ private function checkExpandOptions(array|string $expand): bool return true; } - private function handleException(\Exception $e, string $method, array $body = []): void + private function handleException(Exception $e, string $method, array $body = []): void { $logDetails = [ 'package' => 'Bluelightco\LeverPhp', @@ -502,7 +502,7 @@ private function handleException(\Exception $e, string $method, array $body = [] $logDetails['response'] = $e->getResponse() ? $e->getResponse()->getBody()->getContents() : null; } - Log::error("HTTP Error in $method: " . $e->getMessage(), $logDetails); + Log::error("HTTP Error in $method: ".$e->getMessage(), $logDetails); $type = $e instanceof ClientException ? 'ClientException' : 'Exception'; diff --git a/tests/OpportunitiesTest.php b/tests/OpportunitiesTest.php index b90df30..d23191d 100644 --- a/tests/OpportunitiesTest.php +++ b/tests/OpportunitiesTest.php @@ -4,7 +4,7 @@ use GuzzleHttp\Psr7\Response; use Illuminate\Support\LazyCollection; -use Bluelightco\LeverPhp\Exceptions\LeverClientException; +use RuntimeException; class OpportunitiesTest extends TestCase { @@ -108,7 +108,7 @@ public function create_opportunity() /** @test */ public function fail_to_create_opportunity_when_no_perform_as_parameter_included() { - $this->expectException(LeverClientException::class); + $this->expectException(RuntimeException::class); $this->mockHandler->append(new Response(400, [], '{"code": "BadRequestError", "message": "Missing perform_as parameter. Please specify a user for which to perform this create."}'