Skip to content

Commit

Permalink
Merge pull request #355 from stvsimons/company-options
Browse files Browse the repository at this point in the history
Support to send options with Company::getById()
  • Loading branch information
ksvirkou-hubspot authored Oct 12, 2021
2 parents 1370a5a + 85d55c5 commit 66f5634
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Resources/Companies.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
}

/**
Expand Down
17 changes: 17 additions & 0 deletions tests/Integration/Resources/CompaniesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down

0 comments on commit 66f5634

Please sign in to comment.