SevenShores\Hubspot\Resources\Deals::getById PHP Method

getById() public method

public getById ( integer $id ) : mixed
$id integer
return mixed
    function getById($id)
    {
        $endpoint = "https://api.hubapi.com/deals/v1/deal/{$id}";
        return $this->client->request('get', $endpoint);
    }

Usage Example

Example #1
0
 /**
  * @test
  */
 public function associateWithContact()
 {
     $dealId = $this->createDeal()->dealId;
     $firstContactId = $this->createContact();
     $secondContactId = $this->createContact();
     $thirdContactId = $this->createContact();
     $response = $this->deals->associateWithContact($dealId, [$firstContactId, $secondContactId, $thirdContactId]);
     $this->assertSame(204, $response->getStatusCode());
     //Check what was associated
     $response = $this->deals->getById($dealId);
     $associatedContacts = $response->associations->associatedVids;
     $expectedAssociatedContacts = [$firstContactId, $secondContactId, $thirdContactId];
     //sorting as order is not predicatable
     sort($associatedContacts);
     sort($expectedAssociatedContacts);
     $this->assertEquals($expectedAssociatedContacts, $associatedContacts);
     //Now disassociate
     $response = $this->deals->disassociateFromContact($dealId, [$firstContactId, $thirdContactId]);
     $this->assertSame(204, $response->getStatusCode());
     //Ensure that only one associated contact left
     $response = $this->deals->getById($dealId);
     $this->assertSame([$secondContactId], $response->associations->associatedVids);
 }