Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .fernignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# Specify files that shouldn't be modified by Fern
src/Legacy
composer.json
phpstan.neon
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,27 @@ foreach ($items->getPages() as $page) {
}
```

## Legacy SDK

While the new SDK has a lot of improvements, we at Intercom understand that it takes time to upgrade when there are breaking changes.
To make the migration easier, the new SDK also exports the legacy SDK as `Intercom\Legacy\...`. Here's an example of how you can use the
legacy SDK alongside the new SDK inside a single file:

```php
use Intercom\IntercomClient;
use Intercom\Legacy\IntercomClient as LegacyIntercomClient;

$intercom = new IntercomClient();
$legacyClient = new LegacyIntercomClient();
```

We recommend migrating to the new SDK using the following steps:

1. Upgrade the package to `^5.1.0`
2. Search and replace all requires and imports from `Intercom\...` to `Intercom\Legacy\...`

3. Gradually move over to use the new SDK by importing it from the `Intercom\...` import.


## Advanced

Expand Down
13 changes: 12 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
"require": {
"php": "^8.1",
"ext-json": "*",
"php-http/client-common": "^2.0",
"php-http/discovery": "^1.0",
"php-http/message": "^1.0",
"psr/http-client": "^1.0",
"psr/http-message": "^1.0 || ^2.0",
"nyholm/psr7": "^1.0",
"guzzlehttp/guzzle": "^7.4"
},
"require-dev": {
Expand Down Expand Up @@ -42,5 +48,10 @@
"homepage": "https://www.intercom.com"
}
],
"config": {
"allow-plugins": {
"php-http/discovery": true
}
},
"homepage": "https://developers.intercom.com/docs"
}
}
4 changes: 3 additions & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ parameters:
reportUnmatchedIgnoredErrors: false
paths:
- src
- tests
- tests
excludePaths:
- src/Legacy
48 changes: 48 additions & 0 deletions src/Legacy/IntercomAdmins.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace Intercom\Legacy;

use Http\Client\Exception;
use stdClass;

class IntercomAdmins extends IntercomResource
{
/**
* Returns list of Admins.
*
* @see https://developers.intercom.io/reference#list-admins
* @param array $options
* @return stdClass
* @throws Exception
*/
public function getAdmins($options = [])
{
return $this->client->get("admins", $options);
}

/**
* Gets a single Admin based on the Intercom ID.
*
* @see https://developers.intercom.com/v2.0/reference#view-an-admin
* @param integer $id
* @param array $options
* @return stdClass
* @throws Exception
*/
public function getAdmin($id, $options = [])
{
$path = $this->adminPath($id);
return $this->client->get($path, $options);
}

/**
* Returns endpoint path to Admin with given ID.
*
* @param string $id
* @return string
*/
public function adminPath($id)
{
return 'admins/' . $id;
}
}
33 changes: 33 additions & 0 deletions src/Legacy/IntercomBulk.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Intercom\Legacy;

use Http\Client\Exception;
use stdClass;

class IntercomBulk extends IntercomResource
{
/**
* Creates Users in bulk.
*
* @param array $options
* @return stdClass
* @throws Exception
*/
public function users($options)
{
return $this->client->post("bulk/users", $options);
}

/**
* Creates Events in bulk.
*
* @param array $options
* @return stdClass
* @throws Exception
*/
public function events($options)
{
return $this->client->post("bulk/events", $options);
}
}
Loading