From 6a8272a8a696da49721a1a85ad7a7e6e25bb7361 Mon Sep 17 00:00:00 2001 From: Emil Sundberg Date: Wed, 3 Mar 2021 13:12:54 +0100 Subject: [PATCH] Add delete company --- README.md | 3 +++ src/IntercomCompanies.php | 14 ++++++++++++++ tests/IntercomCompaniesTest.php | 8 ++++++++ 3 files changed, 25 insertions(+) diff --git a/README.md b/README.md index 3fd8ad3..b8e644a 100644 --- a/README.md +++ b/README.md @@ -383,6 +383,9 @@ $client->companies->update([ 'name' => 'foocorp', ]); +/** Delete a company by ID */ +$client->companies->delete('531ee472cce572a6ec000006'); + /** List Companies */ $client->companies->getCompanies([]); diff --git a/src/IntercomCompanies.php b/src/IntercomCompanies.php index e3256ad..3917f83 100644 --- a/src/IntercomCompanies.php +++ b/src/IntercomCompanies.php @@ -32,6 +32,20 @@ public function update($options) { return $this->create($options); } + + /** + * Deletes a Company. + * + * @see https://developers.intercom.com/intercom-api-reference/reference#delete-a-company + * @param array $options + * @return stdClass + * @throws Exception + */ + public function delete($id, $options = []) + { + $path = $this->companyPath($id); + return $this->client->delete($path, $options); + } /** * Attaches a Contact to a Company. diff --git a/tests/IntercomCompaniesTest.php b/tests/IntercomCompaniesTest.php index 7c3bd1d..9d48787 100644 --- a/tests/IntercomCompaniesTest.php +++ b/tests/IntercomCompaniesTest.php @@ -29,6 +29,14 @@ public function testCompanyGet() $companies = new IntercomCompanies($this->client); $this->assertSame('foo', $companies->getCompanies([])); } + + public function testCompanyDelete() + { + $this->client->method('delete')->willReturn('foo'); + + $companies = new IntercomCompanies($this->client); + $this->assertSame('foo', $companies->delete('')); + } public function testCompanyPath() {