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

addContact() public method

Associates a given contact to a given company If a contact is already associated to a different company, the contact will be added to the new company
See also: http://developers.hubspot.com/docs/methods/companies/add_contact_to_company
public addContact ( integer $contactId, integer $companyId ) : Response
$contactId integer
$companyId integer
return SevenShores\Hubspot\Http\Response
    function addContact($contactId, $companyId)
    {
        $endpoint = "https://api.hubapi.com/companies/v2/companies/{$companyId}/contacts/{$contactId}";
        return $this->client->request('put', $endpoint);
    }

Usage Example

Example #1
0
 /**
  * Creates an associated contact for a new company with the HubSpotApi
  *
  * @param int $companyId The id of the company where to create the new contact.
  *
  * @return array
  */
 private function createAssociatedContact($companyId)
 {
     $newContactResponse = $this->createContact();
     $contactId = $newContactResponse['vid'];
     $response = $this->companies->addContact($contactId, $companyId);
     sleep(1);
     return [$contactId, $response];
 }