SevenShores\Hubspot\Resources\Companies::getAssociatedContacts PHP Method

getAssociatedContacts() public method

Returns an array of the associated contacts for the given company
See also: http://developers.hubspot.com/docs/methods/companies/get_company_contacts
public getAssociatedContacts ( integer $companyId, array $params = [] ) : Response
$companyId integer The id of the company.
$params array Array of optional parameters ['count', 'vidOffset']
return SevenShores\Hubspot\Http\Response
    function getAssociatedContacts($companyId, $params = [])
    {
        $endpoint = "https://api.hubapi.com/companies/v2/companies/{$companyId}/contacts";
        $queryString = build_query_string($params);
        return $this->client->request('get', $endpoint, [], $queryString);
    }

Usage Example

Example #1
0
 /** @test */
 public function getAssociatedContactsWithCountAndOffset()
 {
     $newCompanyResponse = $this->createCompany();
     $companyId = $newCompanyResponse['companyId'];
     list($contactId) = $this->createAssociatedContact($companyId);
     list($contactId2) = $this->createAssociatedContact($companyId);
     $response = $this->companies->getAssociatedContacts($companyId, ['count' => 1, 'vidOffset' => $contactId]);
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertCount(1, $response['contacts']);
     $offsetResponse = $this->companies->getAssociatedContacts($companyId, ['count' => 1, 'vidOffset' => $contactId2 + 1]);
     $this->assertEquals(200, $offsetResponse->getStatusCode());
     $this->assertGreaterThanOrEqual($contactId2 + 1, $offsetResponse['vidOffset']);
 }