diff --git a/src/Resources/Companies.php b/src/Resources/Companies.php index b1189161..cefbb822 100644 --- a/src/Resources/Companies.php +++ b/src/Resources/Companies.php @@ -2,6 +2,9 @@ namespace SevenShores\Hubspot\Resources; +/** + * @see https://developers.hubspot.com/docs/methods/companies/companies-overview + */ class Companies extends Resource { /** @@ -16,9 +19,12 @@ class Companies extends Resource public function create(array $properties) { $endpoint = 'https://api.hubapi.com/companies/v2/companies/'; - $options['json'] = ['properties' => $properties]; - return $this->client->request('post', $endpoint, $options); + return $this->client->request( + 'post', + $endpoint, + ['json' => ['properties' => $properties]] + ); } /** @@ -34,9 +40,12 @@ public function create(array $properties) public function update($id, array $properties) { $endpoint = "https://api.hubapi.com/companies/v2/companies/{$id}"; - $options['json'] = ['properties' => $properties]; - return $this->client->request('put', $endpoint, $options); + return $this->client->request( + 'put', + $endpoint, + ['json' => ['properties' => $properties]] + ); } /** @@ -47,9 +56,8 @@ public function update($id, array $properties) public function updateBatch(array $companies) { $endpoint = 'https://api.hubapi.com/companies/v1/batch-async/update'; - $options['json'] = $companies; - return $this->client->request('post', $endpoint, $options); + return $this->client->request('post', $endpoint, ['json' => $companies]); } /** @@ -81,9 +89,12 @@ public function all(array $params = []) { $endpoint = 'https://api.hubapi.com/companies/v2/companies/paged'; - $queryString = build_query_string($params); - - return $this->client->request('get', $endpoint, [], $queryString); + return $this->client->request( + 'get', + $endpoint, + [], + build_query_string($params) + ); } /** @@ -99,9 +110,12 @@ public function getRecentlyModified(array $params = []) { $endpoint = 'https://api.hubapi.com/companies/v2/companies/recent/modified'; - $queryString = build_query_string($params); - - return $this->client->request('get', $endpoint, [], $queryString); + return $this->client->request( + 'get', + $endpoint, + [], + build_query_string($params) + ); } /** @@ -117,35 +131,45 @@ public function getRecentlyCreated(array $params = []) { $endpoint = 'https://api.hubapi.com/companies/v2/companies/recent/created'; - $queryString = build_query_string($params); - - return $this->client->request('get', $endpoint, [], $queryString); + return $this->client->request( + 'get', + $endpoint, + [], + build_query_string($params) + ); } /** - * @param string $domain - * @param int $limit - * @param int $offset + * Search for companies by domain. * * @see https://developers.hubspot.com/docs/methods/companies/search_companies_by_domain * * @return \Psr\Http\Message\ResponseInterface|\SevenShores\Hubspot\Http\Response */ - public function searchByDomain($domain, array $properties = [], $limit = 100, $offset = 0) - { + public function searchByDomain( + string $domain, + array $properties = [], + int $limit = 100, + int $offset = 0 + ) { $endpoint = "https://api.hubapi.com/companies/v2/domains/{$domain}/companies"; - $options['json'] = [ - 'limit' => $limit, - 'offset' => [ - 'isPrimary' => true, - 'companyId' => $offset, - ], - 'requestOptions' => [ - 'properties' => $properties, - ], - ]; - - return $this->client->request('post', $endpoint, $options); + + return $this->client->request( + 'post', + $endpoint, + [ + 'json' => [ + 'limit' => $limit, + 'offset' => [ + 'isPrimary' => true, + 'companyId' => $offset, + ], + 'requestOptions' => [ + 'properties' => $properties, + ], + ], + ] + ); } /** diff --git a/src/Resources/Contacts.php b/src/Resources/Contacts.php index 98a99fc1..f881ffd6 100644 --- a/src/Resources/Contacts.php +++ b/src/Resources/Contacts.php @@ -12,9 +12,9 @@ class Contacts extends Resource * * @param array $properties array of contact properties * - * @return \SevenShores\Hubspot\Http\Response - * * @see https://developers.hubspot.com/docs/methods/contacts/create_contact + * + * @return \SevenShores\Hubspot\Http\Response */ public function create(array $properties) { @@ -33,9 +33,9 @@ public function create(array $properties) * @param int $id the contact id * @param array $properties the contact properties to update * - * @return \SevenShores\Hubspot\Http\Response - * * @see https://developers.hubspot.com/docs/methods/contacts/update_contact + * + * @return \SevenShores\Hubspot\Http\Response */ public function update($id, array $properties) { @@ -54,9 +54,9 @@ public function update($id, array $properties) * @param string $email the contact's email address * @param array $properties the contact properties to update * - * @return \SevenShores\Hubspot\Http\Response - * * @see https://developers.hubspot.com/docs/methods/contacts/update_contact-by-email + * + * @return \SevenShores\Hubspot\Http\Response */ public function updateByEmail(string $email, array $properties) { @@ -75,9 +75,9 @@ public function updateByEmail(string $email, array $properties) * @param string $email the contact's email address * @param array $properties the contact properties * - * @return \SevenShores\Hubspot\Http\Response - * * @see https://developers.hubspot.com/docs/methods/contacts/create_or_update + * + * @return \SevenShores\Hubspot\Http\Response */ public function createOrUpdate(string $email, array $properties = []) { @@ -96,9 +96,9 @@ public function createOrUpdate(string $email, array $properties = []) * @param array $contacts the contacts and properties * @param array $params Array of optional parameters ['auditId'] * - * @return \SevenShores\Hubspot\Http\Response - * * @see https://developers.hubspot.com/docs/methods/contacts/batch_create_or_update + * + * @return \SevenShores\Hubspot\Http\Response */ public function createOrUpdateBatch(array $contacts, array $params = []) { @@ -117,9 +117,9 @@ public function createOrUpdateBatch(array $contacts, array $params = []) * * @param int $id * - * @return \SevenShores\Hubspot\Http\Response - * * @see https://developers.hubspot.com/docs/methods/contacts/delete_contact + * + * @return \SevenShores\Hubspot\Http\Response */ public function delete($id) { @@ -161,11 +161,11 @@ public function all(array $params = []) * A paginated list of contacts will be returned to you, with a maximum of 100 contacts per page, as specified by * the "count" parameter. The endpoint only scrolls back in time 30 days. * - * @see https://developers.hubspot.com/docs/methods/contacts/get_recently_updated_contacts - * * @param array $params Array of optional parameters ['count', 'timeOffset', 'vidOffset', 'property', * 'propertyMode', 'formSubmissionMode', 'showListMemberships'] * + * @see https://developers.hubspot.com/docs/methods/contacts/get_recently_updated_contacts + * * @return \SevenShores\Hubspot\Http\Response */ public function recent(array $params = []) @@ -185,11 +185,11 @@ public function recent(array $params = []) * A paginated list of contacts will be returned to you, with a maximum of 100 contacts per page, as specified by * the "count" parameter. The endpoint only scrolls back in time 30 days. * - * @see https://developers.hubspot.com/docs/methods/contacts/get_recently_updated_contacts - * * @param array $params Array of optional parameters ['count', 'timeOffset', 'vidOffset', 'property', * 'propertyMode', 'formSubmissionMode', 'showListMemberships'] * + * @see https://developers.hubspot.com/docs/methods/contacts/get_recently_updated_contacts + * * @return \SevenShores\Hubspot\Http\Response */ public function recentNew(array $params = []) @@ -211,9 +211,9 @@ public function recentNew(array $params = []) * @param array $params Array of optional parameters ['property', 'propertyMode', 'formSubmissionMode', * 'showListMemberships'] * - * @return \SevenShores\Hubspot\Http\Response - * * @see https://developers.hubspot.com/docs/methods/contacts/get_contact + * + * @return \SevenShores\Hubspot\Http\Response */ public function getById($id, array $params = []) { @@ -234,12 +234,12 @@ public function getById($id, array $params = []) * This method will also return you much of the HubSpot lead "intelligence" for each requested contact record. The * endpoint accepts many query parameters that allow for customization based on a variety of integration use cases. * - * @see https://developers.hubspot.com/docs/methods/contacts/get_batch_by_vid - * * @param array $vids Array of visitor IDs * @param array $params Array of optional parameters ['property', 'propertyMode', 'formSubmissionMode', * 'showListMemberships', 'includeDeletes'] * + * @see https://developers.hubspot.com/docs/methods/contacts/get_batch_by_vid + * * @return \SevenShores\Hubspot\Http\Response */ public function getBatchByIds(array $vids, array $params = []) @@ -262,9 +262,9 @@ public function getBatchByIds(array $vids, array $params = []) * @param array $params Array of optional parameters ['property', 'propertyMode', 'formSubmissionMode', * 'showListMemberships'] * - * @return \SevenShores\Hubspot\Http\Response - * * @see https://developers.hubspot.com/docs/methods/contacts/get_contact_by_email + * + * @return \SevenShores\Hubspot\Http\Response */ public function getByEmail(string $email, array $params = []) { @@ -284,15 +284,15 @@ public function getByEmail(string $email, array $params = []) * This method will also return you much of the HubSpot lead "intelligence" for each requested contact record. The * endpoint accepts many query parameters that allow for customization based on a variety of integration use cases. * - * @see https://developers.hubspot.com/docs/methods/contacts/get_batch_by_email - * * @param array $emails Array of email adresses * @param array $params Array of optional parameters ['property', 'propertyMode', 'formSubmissionMode', * 'showListMemberships', 'includeDeletes'] * + * @see https://developers.hubspot.com/docs/methods/contacts/get_batch_by_email + * * @return \SevenShores\Hubspot\Http\Response */ - public function getBatchByEmails($emails, array $params = []) + public function getBatchByEmails(array $emails, array $params = []) { $endpoint = 'https://api.hubapi.com/contacts/v1/contact/emails/batch/'; @@ -312,9 +312,9 @@ public function getBatchByEmails($emails, array $params = []) * @param array $params Array of optional parameters ['property', 'propertyMode', 'formSubmissionMode', * 'showListMemberships'] * - * @return \SevenShores\Hubspot\Http\Response - * * @see https://developers.hubspot.com/docs/methods/contacts/get_contact_by_utk + * + * @return \SevenShores\Hubspot\Http\Response */ public function getByToken(string $utk, array $params = []) { @@ -338,12 +338,12 @@ public function getByToken(string $utk, array $params = []) * The endpoint does not allow for CORS, so if you are looking up contacts from their user token on the client, * you'll need to spin up a proxy server to interact with the API. * - * @see https://developers.hubspot.com/docs/methods/contacts/get_batch_by_utk - * * @param array $utks Array of hubspot user tokens (hubspotutk) * @param array $params Array of optional parameters ['property', 'propertyMode', 'formSubmissionMode', * 'showListMemberships', 'includeDeletes'] * + * @see https://developers.hubspot.com/docs/methods/contacts/get_batch_by_utk + * * @return \SevenShores\Hubspot\Http\Response */ public function getBatchByTokens(array $utks, array $params = []) @@ -408,9 +408,9 @@ public function statistics() * @param int $id primary contact id * @param int $vidToMerge contact ID of the secondary contact * - * @return \SevenShores\Hubspot\Http\Response - * * @see https://developers.hubspot.com/docs/methods/contacts/merge-contacts + * + * @return \SevenShores\Hubspot\Http\Response */ public function merge($id, $vidToMerge) { diff --git a/tests/Integration/Abstraction/DefaultTestCase.php b/tests/Integration/Abstraction/DefaultTestCase.php index d342a787..b7d895a9 100644 --- a/tests/Integration/Abstraction/DefaultTestCase.php +++ b/tests/Integration/Abstraction/DefaultTestCase.php @@ -31,8 +31,13 @@ public function setUp() parent::setUp(); if (empty($this->resource)) { - $this->resource = new $this->resourceClass(new Client(['key' => getenv($this->key)])); + $this->resource = new $this->resourceClass($this->getClient()); } sleep(1); } + + protected function getClient(): Client + { + return new Client(['key' => getenv($this->key)]); + } } diff --git a/tests/Integration/Resources/CompaniesTest.php b/tests/Integration/Resources/CompaniesTest.php index 86cf5ae7..e5b63331 100644 --- a/tests/Integration/Resources/CompaniesTest.php +++ b/tests/Integration/Resources/CompaniesTest.php @@ -2,9 +2,9 @@ namespace SevenShores\Hubspot\Tests\Integration\Resources; -use SevenShores\Hubspot\Http\Client; use SevenShores\Hubspot\Resources\Companies; use SevenShores\Hubspot\Resources\Contacts; +use SevenShores\Hubspot\Tests\Integration\Abstraction\EntityTestCase; /** * Class CompaniesTest. @@ -14,69 +14,62 @@ * @internal * @coversNothing */ -class CompaniesTest extends \PHPUnit_Framework_TestCase +class CompaniesTest extends EntityTestCase { /** * @var Companies */ - protected $companies; + protected $resource; + + /** + * @var Companies::class + */ + protected $resourceClass = Companies::class; /** * @var Contacts */ - protected $contacts; + protected $contactsResource; public function setUp() { + $this->contactsResource = new Contacts($this->getClient()); parent::setUp(); - $this->companies = new Companies(new Client(['key' => getenv('HUBSPOT_TEST_API_KEY')])); - $this->contacts = new Contacts(new Client(['key' => getenv('HUBSPOT_TEST_API_KEY')])); - sleep(1); } /** @test */ public function create() { - $response = $this->createCompany(); - - $this->assertEquals(200, $response->getStatusCode()); - $this->assertEquals('A company name', $response['properties']['name']['value']); - $this->assertEquals('A company description', $response['properties']['description']['value']); - $this->assertEquals('example.com', $response['properties']['domain']['value']); - - $this->companies->delete($response->companyId); + $this->assertEquals(200, $this->entity->getStatusCode()); + $this->assertEquals('A company name', $this->entity->properties->name->value); + $this->assertEquals('A company description', $this->entity->properties->description->value); + $this->assertEquals('example.com', $this->entity->properties->domain->value); } /** @test */ public function update() { - $newCompanyResponse = $this->createCompany(); - $companyDescription = 'A far better description than before'; $properties = [ 'name' => 'description', 'value' => $companyDescription, ]; - $response = $this->companies->update($newCompanyResponse->companyId, $properties); + $response = $this->resource->update($this->entity->companyId, $properties); $this->assertEquals(200, $response->getStatusCode()); - $this->assertEquals($newCompanyResponse->companyId, $response->companyId); - $this->assertEquals($companyDescription, $response['properties']['description']['value']); - - $this->companies->delete($response->companyId); + $this->assertEquals($this->entity->companyId, $response->companyId); + $this->assertEquals($companyDescription, $response->properties->description->value); } /** @test */ public function updateBatch() { - $newCompanyResponse = $this->createCompany(); - $companyDescription = 'A far better description than before'; $companies = [ [ - 'objectId' => $newCompanyResponse->companyId, + 'objectId' => $this->entity->companyId, 'properties' => [ [ 'name' => 'description', @@ -86,29 +79,27 @@ public function updateBatch() ], ]; - $response = $this->companies->updateBatch($companies); + $response = $this->resource->updateBatch($companies); $this->assertEquals(202, $response->getStatusCode()); - - $this->companies->delete($newCompanyResponse->companyId); } /** @test */ public function delete() { - $newCompanyResponse = $this->createCompany(); - - $response = $this->companies->delete($newCompanyResponse->companyId); + $response = $this->deleteEntity(); $this->assertEquals(200, $response->getStatusCode()); - $this->assertEquals($newCompanyResponse->companyId, $response->companyId); + $this->assertEquals($this->entity->companyId, $response->companyId); $this->assertTrue($response['deleted']); + + $this->entity = null; } /** @test */ public function getAll() { - $response = $this->companies->all(); + $response = $this->resource->all(); $this->assertEquals(200, $response->getStatusCode()); $this->assertGreaterThan(0, count($response->data->companies)); @@ -117,7 +108,7 @@ public function getAll() /** @test */ public function getRecentlyModified() { - $response = $this->companies->getRecentlyModified(); + $response = $this->resource->getRecentlyModified(); $this->assertEquals(200, $response->getStatusCode()); $this->assertGreaterThan(2, $response['results']); @@ -127,7 +118,7 @@ public function getRecentlyModified() public function getRecentlyModifiedWithCountAndOffset() { $params = ['count' => 2, 'offset' => 1]; - $response = $this->companies->getRecentlyModified($params); + $response = $this->resource->getRecentlyModified($params); $this->assertEquals(200, $response->getStatusCode()); $this->assertCount(2, $response['results']); $this->assertEquals(3, $response['offset']); @@ -136,7 +127,7 @@ public function getRecentlyModifiedWithCountAndOffset() /** @test */ public function getRecentlyCreated() { - $response = $this->companies->getRecentlyCreated(); + $response = $this->resource->getRecentlyCreated(); $this->assertEquals(200, $response->getStatusCode()); $this->assertGreaterThan(2, $response['results']); @@ -146,7 +137,7 @@ public function getRecentlyCreated() public function getRecentlyCreatedWithCountAndOffset() { $params = ['count' => 2, 'offset' => 1]; - $response = $this->companies->getRecentlyCreated($params); + $response = $this->resource->getRecentlyCreated($params); $this->assertEquals(200, $response->getStatusCode()); } @@ -154,100 +145,86 @@ public function getRecentlyCreatedWithCountAndOffset() /** @test */ public function getById() { - //Ensure that we have a company to fetch - $newCompanyResponse = $this->createCompany(); - - $response = $this->companies->getById($newCompanyResponse->companyId); + $response = $this->resource->getById($this->entity->companyId); $this->assertEquals(200, $response->getStatusCode()); - $this->assertEquals($newCompanyResponse->companyId, $response->companyId); - - $this->companies->delete($newCompanyResponse->companyId); + $this->assertEquals($this->entity->companyId, $response->companyId); } /** @test */ public function getAssociatedContacts() { - $newCompanyResponse = $this->createCompany(); - list($contactId) = $this->createAssociatedContact($newCompanyResponse->companyId); + list($contactId) = $this->createAssociatedContact($this->entity->companyId); - $response = $this->companies->getAssociatedContacts($newCompanyResponse->companyId); + $response = $this->resource->getAssociatedContacts($this->entity->companyId); $this->assertEquals(200, $response->getStatusCode()); - $this->assertCount(1, $response['contacts']); - $this->assertEquals($contactId, $response['contacts'][0]['vid']); + $this->assertCount(1, $response->contacts); + $this->assertEquals($contactId, $response->contacts[0]->vid); - $this->deleteCompanyWithContacts($newCompanyResponse->companyId, [$contactId]); + $this->deleteAssociatedContacts($this->entity->companyId, [$contactId]); } /** @test */ public function getAssociatedContactsWithCountAndOffset() { - $newCompanyResponse = $this->createCompany(); - $companyId = $newCompanyResponse->companyId; - list($contactId) = $this->createAssociatedContact($companyId); - list($contactId2) = $this->createAssociatedContact($companyId); + list($contactId) = $this->createAssociatedContact($this->entity->companyId); + list($contactId2) = $this->createAssociatedContact($this->entity->companyId); - $response = $this->companies->getAssociatedContacts($companyId, ['count' => 1]); + $response = $this->resource->getAssociatedContacts($this->entity->companyId, ['count' => 1]); $this->assertEquals(200, $response->getStatusCode()); $this->assertCount(1, $response->contacts); - $offsetResponse = $this->companies->getAssociatedContacts($companyId, ['count' => 1, 'vidOffset' => $contactId]); + $offsetResponse = $this->resource->getAssociatedContacts($this->entity->companyId, ['count' => 1, 'vidOffset' => $contactId]); $this->assertEquals(200, $offsetResponse->getStatusCode()); $this->assertGreaterThanOrEqual($contactId2, $offsetResponse->vidOffset); - $this->deleteCompanyWithContacts($companyId, [$contactId, $contactId2]); + $this->deleteAssociatedContacts($this->entity->companyId, [$contactId, $contactId2]); } /** @test */ public function getAssociatedContactIds() { - $newCompanyResponse = $this->createCompany(); - $companyId = $newCompanyResponse['companyId']; - list($contactId1) = $this->createAssociatedContact($companyId); - list($contactId2) = $this->createAssociatedContact($companyId); + list($contactId1) = $this->createAssociatedContact($this->entity->companyId); + list($contactId2) = $this->createAssociatedContact($this->entity->companyId); - $response = $this->companies->getAssociatedContactIds($companyId); + $response = $this->resource->getAssociatedContactIds($this->entity->companyId); $this->assertEquals(200, $response->getStatusCode()); $this->assertGreaterThanOrEqual(1, $response->vids); $this->assertContains($contactId1, $response->vids); $this->assertContains($contactId2, $response->vids); - $this->deleteCompanyWithContacts($newCompanyResponse->companyId, $response->vids); + $this->deleteAssociatedContacts($this->entity->companyId, $response->vids); } /** @test */ public function getAssociatedContactIdsWithCountAndOffset() { - $newCompanyResponse = $this->createCompany(); - $companyId = $newCompanyResponse->companyId; - list($contactId1) = $this->createAssociatedContact($companyId); - list($contactId2) = $this->createAssociatedContact($companyId); + list($contactId1) = $this->createAssociatedContact($this->entity->companyId); + list($contactId2) = $this->createAssociatedContact($this->entity->companyId); - $response = $this->companies->getAssociatedContactIds($companyId, ['count' => 1]); + $response = $this->resource->getAssociatedContactIds($this->entity->companyId, ['count' => 1]); $this->assertEquals(200, $response->getStatusCode()); $this->assertCount(1, $response->vids); - $offsetResponse = $this->companies->getAssociatedContactIds($companyId, ['count' => 1, 'vidOffset' => $contactId1]); + $offsetResponse = $this->resource->getAssociatedContactIds($this->entity->companyId, ['count' => 1, 'vidOffset' => $contactId1]); $this->assertEquals(200, $offsetResponse->getStatusCode()); $this->assertGreaterThanOrEqual($contactId2, $offsetResponse->vidOffset); - $this->deleteCompanyWithContacts($companyId, [$contactId1, $contactId2]); + $this->deleteAssociatedContacts($this->entity->companyId, [$contactId1, $contactId2]); } /** @test */ public function removeContact() { - $newCompanyResponse = $this->createCompany(); - list($contactId) = $this->createAssociatedContact($newCompanyResponse->companyId); + list($contactId) = $this->createAssociatedContact($this->entity->companyId); - $response = $this->companies->removeContact($contactId, $newCompanyResponse->companyId); + $response = $this->resource->removeContact($contactId, $this->entity->companyId); $this->assertEquals(204, $response->getStatusCode()); - $this->companies->delete($newCompanyResponse->companyId); - $this->contacts->delete($contactId); + $this->contactsResource->delete($contactId); } /** @@ -255,45 +232,10 @@ public function removeContact() */ public function searchCompanyByDomain() { - $newCompanyResponse = $this->createCompany(); - - $response = $this->companies->searchByDomain('example.com', ['name', 'domain']); + $response = $this->resource->searchByDomain('example.com', ['name', 'domain']); $this->assertEquals(200, $response->getStatusCode()); $results = $response->getData()->results; $this->assertEquals('example.com', current($results)->properties->domain->value); - - $this->companies->delete($newCompanyResponse->companyId); - } - - /** - * Creates a Company with the HubSpotApi. - * - * @return \SevenShores\Hubspot\Http\Response - */ - protected function createCompany() - { - $companyName = 'A company name'; - $companyDescription = 'A company description'; - $properties = [ - [ - 'name' => 'name', - 'value' => $companyName, - ], - [ - 'name' => 'description', - 'value' => $companyDescription, - ], - [ - 'name' => 'domain', - 'value' => 'example.com', - ], - ]; - - $response = $this->companies->create($properties); - - sleep(1); - - return $response; } /** @@ -303,7 +245,7 @@ protected function createCompany() */ protected function createContact() { - $contactResponse = $this->contacts->create([ + $response = $this->contactsResource->create([ ['property' => 'email', 'value' => 'rw_test'.uniqid().'@hubspot.com'], ['property' => 'firstname', 'value' => 'joe'], ['property' => 'lastname', 'value' => 'user'], @@ -311,7 +253,7 @@ protected function createContact() sleep(1); - return $contactResponse; + return $response; } /** @@ -323,23 +265,43 @@ protected function createContact() */ protected function createAssociatedContact($companyId) { - $newContactResponse = $this->createContact(); - $contactId = $newContactResponse['vid']; + $contact = $this->createContact(); - $response = $this->companies->addContact($contactId, $companyId); + $response = $this->resource->addContact($contact->vid, $companyId); sleep(1); - return [$contactId, $response]; + return [$contact->vid, $response]; } - protected function deleteCompanyWithContacts($companyId, $contactIds = []) + protected function deleteAssociatedContacts($companyId, $contactIds = []) { foreach ($contactIds as $contactId) { - $this->companies->removeContact($contactId, $companyId); - $this->contacts->delete($contactId); + $this->resource->removeContact($contactId, $companyId); + $this->contactsResource->delete($contactId); } + } - $this->companies->delete($companyId); + protected function createEntity() + { + return $this->resource->create([ + [ + 'name' => 'name', + 'value' => 'A company name', + ], + [ + 'name' => 'description', + 'value' => 'A company description', + ], + [ + 'name' => 'domain', + 'value' => 'example.com', + ], + ]); + } + + protected function deleteEntity() + { + return $this->resource->delete($this->entity->companyId); } } diff --git a/tests/Integration/Resources/ContactsTest.php b/tests/Integration/Resources/ContactsTest.php index 1a7aa7ed..0c3f59f1 100644 --- a/tests/Integration/Resources/ContactsTest.php +++ b/tests/Integration/Resources/ContactsTest.php @@ -83,6 +83,7 @@ public function updateByEmail() /** @test */ public function createOrUpdate() { + sleep(1); $response = $this->resource->createOrUpdate($this->entity->properties->email->value, [ ['property' => 'firstname', 'value' => 'joe'], ['property' => 'lastname', 'value' => 'user'],