diff --git a/src/Endpoints/Files.php b/src/Endpoints/Files.php index 1326cbb8..b016d4c3 100644 --- a/src/Endpoints/Files.php +++ b/src/Endpoints/Files.php @@ -10,8 +10,8 @@ class Files extends Endpoint * @param resource|string $file * * @return \SevenShores\Hubspot\Http\Response - *@see https://legacydocs.hubspot.com/docs/methods/files/v3/upload_new_file * + *@see https://legacydocs.hubspot.com/docs/methods/files/v3/upload_new_file */ public function upload( $file, diff --git a/src/Factory.php b/src/Factory.php index e8ddca05..e47d1049 100644 --- a/src/Factory.php +++ b/src/Factory.php @@ -2,8 +2,8 @@ namespace SevenShores\Hubspot; -use SevenShores\Hubspot\Http\Client; use SevenShores\Hubspot\Endpoints\Endpoint; +use SevenShores\Hubspot\Http\Client; /** * Class Factory. diff --git a/src/Http/Client.php b/src/Http/Client.php index 2043c726..8fa0b8f8 100644 --- a/src/Http/Client.php +++ b/src/Http/Client.php @@ -115,11 +115,13 @@ public function request(string $method, string $endpoint, array $options = [], $ if (false === $this->wrapResponse) { throw $e; } + throw HubspotException::create($e); } catch (ClientException $e) { if (false === $this->wrapResponse) { throw $e; } + throw BadRequest::create($e); } } diff --git a/src/Http/Response.php b/src/Http/Response.php index 5a9d7f7e..67f8ac2b 100644 --- a/src/Http/Response.php +++ b/src/Http/Response.php @@ -12,6 +12,7 @@ class Response implements ResponseInterface, ArrayAccess * @var mixed */ public $data; + /** * @var \Psr\Http\Message\ResponseInterface */ @@ -59,8 +60,6 @@ public function toArray() * Whether a offset exists. * * @param mixed $offset - * - * @return bool */ public function offsetExists($offset): bool { @@ -71,8 +70,6 @@ public function offsetExists($offset): bool * Offset to retrieve. * * @param mixed $offset - * - * @return mixed */ public function offsetGet($offset): mixed { diff --git a/src/RetryMiddlewareFactory.php b/src/RetryMiddlewareFactory.php index 97c150f2..2b4295bb 100644 --- a/src/RetryMiddlewareFactory.php +++ b/src/RetryMiddlewareFactory.php @@ -31,7 +31,8 @@ public static function createMiddlewareByHttpCodes( array $codes, callable $delayFunction, int $maxRetries = 5 - ): callable { + ): callable + { return Middleware::retry( static::getRetryFunction($codes, $maxRetries), $delayFunction @@ -47,7 +48,8 @@ public static function createMiddlewareByHttpCodeRange( int $to, callable $delayFunction, int $maxRetries = 5 - ): callable { + ): callable + { return Middleware::retry( static::getRetryFunctionByRange($from, $to, $maxRetries), $delayFunction diff --git a/src/Utils/Webhooks.php b/src/Utils/Webhooks.php index f085110a..c3dd8d65 100644 --- a/src/Utils/Webhooks.php +++ b/src/Utils/Webhooks.php @@ -6,9 +6,9 @@ class Webhooks { /** * Validation of Hubspot Signature. - * + * * @deprecated - * + * * @param string $signature hubspot signarute * @param string $secret the Secret of your app * @param string $requestBody a set of scopes that your app will need access to diff --git a/tests/Integration/Abstraction/BlogPostTestCase.php b/tests/Integration/Abstraction/BlogPostTestCase.php index a8f11941..30b0ffa0 100644 --- a/tests/Integration/Abstraction/BlogPostTestCase.php +++ b/tests/Integration/Abstraction/BlogPostTestCase.php @@ -3,10 +3,10 @@ namespace SevenShores\Hubspot\Tests\Integration\Abstraction; use DateTime; -use SevenShores\Hubspot\Http\Client; use SevenShores\Hubspot\Endpoints\BlogAuthors; use SevenShores\Hubspot\Endpoints\BlogPosts; use SevenShores\Hubspot\Endpoints\Blogs; +use SevenShores\Hubspot\Http\Client; abstract class BlogPostTestCase extends EntityTestCase { diff --git a/tests/Integration/Endpoints/BlogCommentsTest.php b/tests/Integration/Endpoints/BlogCommentsTest.php index f1a0e98f..a4f9a338 100644 --- a/tests/Integration/Endpoints/BlogCommentsTest.php +++ b/tests/Integration/Endpoints/BlogCommentsTest.php @@ -2,9 +2,9 @@ namespace SevenShores\Hubspot\Tests\Integration\Endpoints; -use SevenShores\Hubspot\Http\Client; use SevenShores\Hubspot\Endpoints\BlogComments; use SevenShores\Hubspot\Endpoints\BlogPosts; +use SevenShores\Hubspot\Http\Client; use SevenShores\Hubspot\Tests\Integration\Abstraction\BlogPostTestCase; /** diff --git a/tests/Integration/Endpoints/CalendarEventsTest.php b/tests/Integration/Endpoints/CalendarEventsTest.php index 3533554e..13bfc08f 100644 --- a/tests/Integration/Endpoints/CalendarEventsTest.php +++ b/tests/Integration/Endpoints/CalendarEventsTest.php @@ -119,7 +119,7 @@ public function allTasks() protected function createEntity() { return $this->resource->createTask([ - 'eventDate' => strtotime('+1 day') * 1000, //timestamp in milliseconds + 'eventDate' => strtotime('+1 day') * 1000, // timestamp in milliseconds 'eventType' => 'PUBLISHING_TASK', 'category' => 'EMAIL', 'state' => 'TODO', diff --git a/tests/Integration/Endpoints/DealsTest.php b/tests/Integration/Endpoints/DealsTest.php index c1ebeb9f..f960ae0b 100644 --- a/tests/Integration/Endpoints/DealsTest.php +++ b/tests/Integration/Endpoints/DealsTest.php @@ -2,10 +2,10 @@ namespace SevenShores\Hubspot\Tests\Integration\Endpoints; -use SevenShores\Hubspot\Http\Client; use SevenShores\Hubspot\Endpoints\Companies; use SevenShores\Hubspot\Endpoints\Contacts; use SevenShores\Hubspot\Endpoints\Deals; +use SevenShores\Hubspot\Http\Client; use SevenShores\Hubspot\Tests\Integration\Abstraction\EntityTestCase; /** @@ -178,7 +178,7 @@ public function associateAndDisassociateWithCompany() ]); $this->assertEquals(204, $associateResponse->getStatusCode()); - //Check what was associated + // Check what was associated $byIdResponse = $this->resource->getById($this->entity->dealId); $associatedCompanies = $byIdResponse->associations->associatedCompanyIds; @@ -189,7 +189,7 @@ public function associateAndDisassociateWithCompany() $this->assertEquals($expectedAssociatedCompanies, $associatedCompanies); - //Now disassociate + // Now disassociate $response = $this->resource->disassociateFromCompany($this->entity->dealId, [ $firstCompanyId, $secondCompanyId, @@ -218,7 +218,7 @@ public function associateAndDisassociateWithContact() ]); $this->assertSame(204, $associateResponse->getStatusCode()); - //Check what was associated + // Check what was associated $byIdResponse = $this->resource->getById($this->entity->dealId); $associatedContacts = $byIdResponse->associations->associatedVids; @@ -229,7 +229,7 @@ public function associateAndDisassociateWithContact() $this->assertEquals($expectedAssociatedContacts, $associatedContacts); - //Now disassociate + // Now disassociate $response = $this->resource->disassociateFromContact($this->entity->dealId, [ $firstContactId, $secondContactId, diff --git a/tests/Integration/Endpoints/EmailEventsTest.php b/tests/Integration/Endpoints/EmailEventsTest.php index a842d641..7c2e34ca 100644 --- a/tests/Integration/Endpoints/EmailEventsTest.php +++ b/tests/Integration/Endpoints/EmailEventsTest.php @@ -2,8 +2,8 @@ namespace SevenShores\Hubspot\Tests\Integration\Endpoints; -use SevenShores\Hubspot\Http\Client; use SevenShores\Hubspot\Endpoints\EmailEvents; +use SevenShores\Hubspot\Http\Client; /** * @internal diff --git a/tests/Integration/Endpoints/EmailSubscriptionTest.php b/tests/Integration/Endpoints/EmailSubscriptionTest.php index a7d3f871..a75a6eb7 100644 --- a/tests/Integration/Endpoints/EmailSubscriptionTest.php +++ b/tests/Integration/Endpoints/EmailSubscriptionTest.php @@ -2,8 +2,8 @@ namespace SevenShores\Hubspot\Tests\Integration\Endpoints; -use SevenShores\Hubspot\Http\Client; use SevenShores\Hubspot\Endpoints\EmailSubscription; +use SevenShores\Hubspot\Http\Client; /** * @internal diff --git a/tests/Integration/Endpoints/EventsTest.php b/tests/Integration/Endpoints/EventsTest.php index f9d71f34..b17ee75c 100644 --- a/tests/Integration/Endpoints/EventsTest.php +++ b/tests/Integration/Endpoints/EventsTest.php @@ -2,8 +2,8 @@ namespace SevenShores\Hubspot\Tests\Integration\Endpoints; -use SevenShores\Hubspot\Http\Client; use SevenShores\Hubspot\Endpoints\Events; +use SevenShores\Hubspot\Http\Client; /** * @internal diff --git a/tests/Integration/Endpoints/IntegrationTest.php b/tests/Integration/Endpoints/IntegrationTest.php index c4ecca7c..bc92bd7a 100644 --- a/tests/Integration/Endpoints/IntegrationTest.php +++ b/tests/Integration/Endpoints/IntegrationTest.php @@ -2,8 +2,8 @@ namespace SevenShores\Hubspot\Tests\Integration\Endpoints; -use SevenShores\Hubspot\Http\Client; use SevenShores\Hubspot\Endpoints\Integration; +use SevenShores\Hubspot\Http\Client; /** * Class IntegrationTest. diff --git a/tests/Integration/Endpoints/KeywordsTest.php b/tests/Integration/Endpoints/KeywordsTest.php index 9e931095..da514591 100644 --- a/tests/Integration/Endpoints/KeywordsTest.php +++ b/tests/Integration/Endpoints/KeywordsTest.php @@ -2,8 +2,8 @@ namespace SevenShores\Hubspot\Tests\Integration\Endpoints; -use SevenShores\Hubspot\Http\Client; use SevenShores\Hubspot\Endpoints\Keywords; +use SevenShores\Hubspot\Http\Client; /** * @internal diff --git a/tests/Integration/Endpoints/LineItemsTest.php b/tests/Integration/Endpoints/LineItemsTest.php index 9e729a75..c45622db 100644 --- a/tests/Integration/Endpoints/LineItemsTest.php +++ b/tests/Integration/Endpoints/LineItemsTest.php @@ -2,9 +2,9 @@ namespace SevenShores\Hubspot\Tests\Integration\Endpoints; -use SevenShores\Hubspot\Http\Client; use SevenShores\Hubspot\Endpoints\LineItems; use SevenShores\Hubspot\Endpoints\Products; +use SevenShores\Hubspot\Http\Client; use SevenShores\Hubspot\Tests\Integration\Abstraction\EntityTestCase; /** diff --git a/tests/Integration/Endpoints/OwnersTest.php b/tests/Integration/Endpoints/OwnersTest.php index 63d2f802..e856353f 100644 --- a/tests/Integration/Endpoints/OwnersTest.php +++ b/tests/Integration/Endpoints/OwnersTest.php @@ -2,8 +2,8 @@ namespace SevenShores\Hubspot\Tests\Integration\Endpoints; -use SevenShores\Hubspot\Http\Client; use SevenShores\Hubspot\Endpoints\Owners; +use SevenShores\Hubspot\Http\Client; /** * Class OwnersTest. diff --git a/tests/unit/Support/QueryBuilderTest.php b/tests/unit/Support/QueryBuilderTest.php index 36af5e8d..68faea46 100644 --- a/tests/unit/Support/QueryBuilderTest.php +++ b/tests/unit/Support/QueryBuilderTest.php @@ -108,10 +108,15 @@ public function encodeFalse() public function buildDataProvider() { yield 'string' => [['firstname' => 'joe', 'lastname' => 'blo'], '&firstname=joe&lastname=blo']; + yield 'int' => [['firstname' => 'joe', 'active' => 1], '&firstname=joe&active=1']; + yield 'bool true' => [['firstname' => 'joe', 'active' => true], '&firstname=joe&active=true']; + yield 'bool false' => [['firstname' => 'joe', 'active' => false], '&firstname=joe']; + yield 'empty array' => [['firstname' => 'joe', 'property' => []], '&firstname=joe']; + yield 'array' => [['firstname' => 'joe', 'property' => ['foo']], '&firstname=joe&property=foo']; } } diff --git a/tests/unit/Utils/SignatureTest.php b/tests/unit/Utils/SignatureTest.php index 653c1c4b..c5ccd056 100644 --- a/tests/unit/Utils/SignatureTest.php +++ b/tests/unit/Utils/SignatureTest.php @@ -19,7 +19,7 @@ public function validationHubspotSignatureValidData() $result = Utils\Signature::isValid([ 'signature' => hash('sha256', $this->secret.$this->requestBody), 'secret' => $this->secret, - 'requestBody' => $this->requestBody + 'requestBody' => $this->requestBody, ]); $this->assertEquals( @@ -34,7 +34,7 @@ public function validationHubspotSignatureInvalidData() $result = Utils\Signature::isValid([ 'signature' => hash('sha256', $this->secret.$this->requestBody.'1'), 'secret' => $this->secret, - 'requestBody' => $this->requestBody + 'requestBody' => $this->requestBody, ]); $this->assertEquals(