Skip to content

Commit 6fa19f1

Browse files
author
Kevin Antoine
authored
Merge pull request #196 from intercom/missing_companies
Missing companies
2 parents b3b1bdc + 0d8529f commit 6fa19f1

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,11 @@ $client->companies->create([
163163
"name" => "foocorp", "company_id" => "3"
164164
]);
165165

166+
// Update a company (Note: This method is an alias to the create method. In practice you can use create to update companies if you wish)
167+
$client->companies->update([
168+
"name" => "foocorp", "id" => "3"
169+
]);
170+
166171
// List Companies
167172
$client->companies->getCompanies([]);
168173
```

src/IntercomCompanies.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ public function create($options)
2828
return $this->client->post("companies", $options);
2929
}
3030

31+
/**
32+
* Updates a Company.
33+
* @see https://developers.intercom.io/reference#create-or-update-company
34+
* @param array $options
35+
* @return mixed
36+
* @throws \GuzzleHttp\Exception\GuzzleException
37+
*/
38+
public function update($options) {
39+
return $this->create($options);
40+
}
41+
3142
/**
3243
* Returns list of Companies.
3344
* @see https://developers.intercom.io/reference#list-companies

test/IntercomCompaniesTest.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use GuzzleHttp\Middleware;
1010

1111
class IntercomCompaniesTest extends PHPUnit_Framework_TestCase {
12-
public function testUserCreate()
12+
public function testCompanyCreate()
1313
{
1414
$stub = $this->getMockBuilder('Intercom\IntercomClient')->disableOriginalConstructor()->getMock();
1515
$stub->method('post')->willReturn('foo');
@@ -18,7 +18,16 @@ public function testUserCreate()
1818
$this->assertEquals('foo', $companies->create([]));
1919
}
2020

21-
public function testUserGet()
21+
public function testCompanyUpdate()
22+
{
23+
$stub = $this->getMockBuilder('Intercom\IntercomClient')->disableOriginalConstructor()->getMock();
24+
$stub->method('post')->willReturn('foo');
25+
26+
$companies = new IntercomCompanies($stub);
27+
$this->assertEquals('foo', $companies->update([]));
28+
}
29+
30+
public function testCompanyGet()
2231
{
2332
$stub = $this->getMockBuilder('Intercom\IntercomClient')->disableOriginalConstructor()->getMock();
2433
$stub->method('get')->willReturn('foo');

0 commit comments

Comments
 (0)