diff --git a/src/Resources/Companies.php b/src/Resources/Companies.php index cefbb822..695dd239 100644 --- a/src/Resources/Companies.php +++ b/src/Resources/Companies.php @@ -176,16 +176,22 @@ public function searchByDomain( * Returns a company with id $id. * * @param int $id + * @param array $params Array of optional parameters ['includeMergeAudits', 'includePropertyVersions'] * * @see https://developers.hubspot.com/docs/methods/companies/get_company * * @return \SevenShores\Hubspot\Http\Response */ - public function getById($id) + public function getById($id, array $params = []) { $endpoint = "https://api.hubapi.com/companies/v2/companies/{$id}"; - return $this->client->request('get', $endpoint); + return $this->client->request( + 'get', + $endpoint, + [], + build_query_string($params) + ); } /** diff --git a/tests/Integration/Resources/CompaniesTest.php b/tests/Integration/Resources/CompaniesTest.php index 159af976..369d5235 100644 --- a/tests/Integration/Resources/CompaniesTest.php +++ b/tests/Integration/Resources/CompaniesTest.php @@ -151,6 +151,23 @@ public function getById() $this->assertEquals($this->entity->companyId, $response->companyId); } + /** @test */ + public function getByIdWithVersions() + { + // Force a change to the description + $newDescription = 'Better descriptions are not easy to create.'; + $properties = [ + 'name' => 'description', + 'value' => $newDescription, + ]; + $response = $this->resource->update($this->entity->companyId, $properties); + + // Get multiple versions for property + $params = ['includePropertyVersions' => true]; + $response = $this->resource->getById($this->entity->companyId, $params); + $this->assertCount(2, $response->getData()->properties->description->versions); + } + /** @test */ public function getAssociatedContacts() {