Skip to content

Commit 64593d4

Browse files
author
Skaelv
committed
update leads
1 parent 446f561 commit 64593d4

File tree

3 files changed

+41
-8
lines changed

3 files changed

+41
-8
lines changed

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,18 @@ $client = new IntercomClient(<insert_token_here>, null);
5151
## Users
5252

5353
```php
54-
// Create/update a user
54+
// Create a user
5555
$client->users->create([
5656
"email" => "[email protected]",
5757
"custom_attributes" => ['foo' => 'bar']
5858
]);
5959

60+
// Update a user (Note: This method is an alias to the create method. In practice you can use create to update users if you wish)
61+
$client->users->update([
62+
"email" => "[email protected]",
63+
"custom_attributes" => ['foo' => 'bar']
64+
]);
65+
6066
// Delete a user by ID
6167
$client->users->deleteUser("570680a8a1bcbca8a90001b9");
6268

@@ -83,13 +89,19 @@ $client->users->getUsers([]);
8389
## Leads
8490

8591
```php
86-
// Create/update a lead
92+
// Create a lead
8793
// See more options here: https://developers.intercom.io/reference#create-lead
8894
$client->leads->create([
8995
"email" => "[email protected]",
9096
"custom_attributes" => ['foo' => 'bar']
9197
]);
9298

99+
// Update a lead (Note: This method is an alias to the create method. In practice you can use create to update leads if you wish)
100+
$client->leads->update([
101+
"email" => "[email protected]",
102+
"custom_attributes" => ['foo' => 'bar']
103+
]);
104+
93105
// List leads
94106
// See more options here: https://developers.intercom.io/reference#list-leads
95107
$client->leads->getLeads([]);

src/IntercomUsers.php

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

31+
/**
32+
* Creates a User.
33+
* @see https://developers.intercom.io/reference#create-or-update-user
34+
* @param array $options
35+
* @return mixed
36+
* @throws \GuzzleHttp\Exception\GuzzleException
37+
*/
38+
public function update($options)
39+
{
40+
return $this->create($options);
41+
}
42+
3143
/**
3244
* Lists Users.
3345
* @see https://developers.intercom.io/reference#list-users
@@ -53,14 +65,14 @@ public function getUser($id, $options = [])
5365
$path = $this->userPath($id);
5466
return $this->client->get($path, $options);
5567
}
56-
68+
5769
/**
5870
* Gets a list of Users through the user scroll API.
5971
* @see https://developers.intercom.com/reference#iterating-over-all-users
6072
* @param array $options
6173
* @return mixed
6274
* @throws \GuzzleHttp\Exception\GuzzleException
63-
*/
75+
*/
6476
public function scrollUsers($options = [])
6577
{
6678
return $this->client->get('users/scroll', $options);

test/IntercomUsersTest.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,25 @@ public function testUserCreate()
1414
$stub = $this->getMockBuilder('Intercom\IntercomClient')->disableOriginalConstructor()->getMock();
1515
$stub->method('post')->willReturn('foo');
1616

17-
$events = new IntercomUsers($stub);
18-
$this->assertEquals('foo', $events->create([]));
17+
$users = new IntercomUsers($stub);
18+
$this->assertEquals('foo', $users->create([]));
19+
}
20+
21+
public function testUserUpdate()
22+
{
23+
$stub = $this->getMockBuilder('Intercom\IntercomClient')->disableOriginalConstructor()->getMock();
24+
$stub->method('post')->willReturn('foo');
25+
26+
$users = new IntercomUsers($stub);
27+
$this->assertEquals('foo', $users->update([]));
1928
}
2029

2130
public function testUserGet()
2231
{
2332
$stub = $this->getMockBuilder('Intercom\IntercomClient')->disableOriginalConstructor()->getMock();
2433
$stub->method('get')->willReturn('foo');
2534

26-
$events = new IntercomUsers($stub);
27-
$this->assertEquals('foo', $events->getUsers([]));
35+
$users = new IntercomUsers($stub);
36+
$this->assertEquals('foo', $users->getUsers([]));
2837
}
2938
}

0 commit comments

Comments
 (0)