Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
24 changes: 10 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Fintercom%2Fintercom-php)
[![php shield](https://img.shields.io/badge/php-packagist-pink)](https://packagist.org/packages/intercom/intercom-php)

The Intercom PHP library provides convenient access to the Intercom API from PHP.
The Intercom PHP library provides convenient access to the Intercom APIs from PHP.

## Installation

Expand Down Expand Up @@ -656,19 +656,15 @@ Instantiate and use the client with the following:
namespace Example;

use Intercom\IntercomClient;
use Intercom\Articles\Requests\CreateArticleRequest;
use Intercom\Articles\Types\CreateArticleRequestState;
use Intercom\AiContent\Requests\CreateContentImportSourceRequest;

$client = new IntercomClient(
token: '<token>',
);
$client->articles->create(
new CreateArticleRequest([
'title' => 'Thanks for everything',
'description' => 'Description of the Article',
'body' => 'Body of the Article',
'authorId' => 1295,
'state' => CreateArticleRequestState::Published->value,
$client->aiContent->createContentImportSource(
new CreateContentImportSourceRequest([
'syncBehavior' => 'api',
'url' => 'https://www.example.com',
]),
);

Expand All @@ -683,7 +679,7 @@ use Intercom\Exceptions\IntercomApiException;
use Intercom\Exceptions\IntercomException;

try {
$response = $client->articles->create(...);
$response = $client->aiContent->createContentImportSource(...);
} catch (IntercomApiException $e) {
echo 'API Exception occurred: ' . $e->getMessage() . "\n";
echo 'Status Code: ' . $e->getCode() . "\n";
Expand Down Expand Up @@ -739,7 +735,7 @@ A request is deemed retryable when any of the following HTTP status codes is ret
Use the `maxRetries` request option to configure this behavior.

```php
$response = $client->articles->create(
$response = $client->aiContent->createContentImportSource(
...,
options: [
'maxRetries' => 0 // Override maxRetries at the request level
Expand All @@ -752,7 +748,7 @@ $response = $client->articles->create(
The SDK defaults to a 30 second timeout. Use the `timeout` option to configure this behavior.

```php
$response = $client->articles->create(
$response = $client->aiContent->createContentImportSource(
...,
options: [
'timeout' => 3.0 // Override timeout to 3 seconds
Expand All @@ -768,4 +764,4 @@ otherwise they would be overwritten upon the next generated release. Feel free t
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
an issue first to discuss with us!

On the other hand, contributions to the README are always very welcome!
On the other hand, contributions to the README are always very welcome!
14 changes: 6 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "intercom/intercom-php",

"version": "6.0.0",
"description": "Intercom API client.",
"keywords": [
"intercom",
"api",
"sdk"
],
"license": "MIT",
"license": [],
"require": {
"php": "^8.1",
"ext-json": "*",
Expand Down Expand Up @@ -36,11 +36,9 @@
"test": "phpunit",
"analyze": "phpstan analyze src tests --memory-limit=1G"
},
"authors": [
{
"name": "Intercom Platform Team",
"homepage": "https://www.intercom.com"
}
],
"author": {
"name": "Intercom Platform Team",
"url": "https://www.intercom.com"
},
"homepage": "https://developers.intercom.com/docs"
}
21 changes: 15 additions & 6 deletions src/Admins/AdminsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ public function __construct(
* queryParameters?: array<string, mixed>,
* bodyProperties?: array<string, mixed>,
* } $options
* @return AdminWithApp
* @return ?AdminWithApp
* @throws IntercomException
* @throws IntercomApiException
*/
public function identify(?array $options = null): AdminWithApp
public function identify(?array $options = null): ?AdminWithApp
{
$options = array_merge($this->options, $options ?? []);
try {
Expand All @@ -91,6 +91,9 @@ public function identify(?array $options = null): AdminWithApp
$statusCode = $response->getStatusCode();
if ($statusCode >= 200 && $statusCode < 400) {
$json = $response->getBody()->getContents();
if (empty($json)) {
return null;
}
return AdminWithApp::fromJson($json);
}
} catch (JsonException $e) {
Expand Down Expand Up @@ -127,11 +130,11 @@ public function identify(?array $options = null): AdminWithApp
* queryParameters?: array<string, mixed>,
* bodyProperties?: array<string, mixed>,
* } $options
* @return Admin
* @return ?Admin
* @throws IntercomException
* @throws IntercomApiException
*/
public function away(ConfigureAwayAdminRequest $request, ?array $options = null): Admin
public function away(ConfigureAwayAdminRequest $request, ?array $options = null): ?Admin
{
$options = array_merge($this->options, $options ?? []);
try {
Expand All @@ -147,6 +150,9 @@ public function away(ConfigureAwayAdminRequest $request, ?array $options = null)
$statusCode = $response->getStatusCode();
if ($statusCode >= 200 && $statusCode < 400) {
$json = $response->getBody()->getContents();
if (empty($json)) {
return null;
}
return Admin::fromJson($json);
}
} catch (JsonException $e) {
Expand Down Expand Up @@ -298,11 +304,11 @@ public function list(?array $options = null): AdminList
* queryParameters?: array<string, mixed>,
* bodyProperties?: array<string, mixed>,
* } $options
* @return Admin
* @return ?Admin
* @throws IntercomException
* @throws IntercomApiException
*/
public function find(FindAdminRequest $request, ?array $options = null): Admin
public function find(FindAdminRequest $request, ?array $options = null): ?Admin
{
$options = array_merge($this->options, $options ?? []);
try {
Expand All @@ -317,6 +323,9 @@ public function find(FindAdminRequest $request, ?array $options = null): Admin
$statusCode = $response->getStatusCode();
if ($statusCode >= 200 && $statusCode < 400) {
$json = $response->getBody()->getContents();
if (empty($json)) {
return null;
}
return Admin::fromJson($json);
}
} catch (JsonException $e) {
Expand Down
39 changes: 32 additions & 7 deletions src/Admins/Requests/ConfigureAwayAdminRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
class ConfigureAwayAdminRequest extends JsonSerializableType
{
/**
* @var string $adminId The unique identifier of a given admin
* @var int $adminId The unique identifier of a given admin
*/
private string $adminId;
private int $adminId;

/**
* @var bool $awayModeEnabled Set to "true" to change the status of the admin to away.
Expand All @@ -24,11 +24,18 @@ class ConfigureAwayAdminRequest extends JsonSerializableType
#[JsonProperty('away_mode_reassign')]
private bool $awayModeReassign;

/**
* @var ?int $awayStatusReasonId The unique identifier of the away status reason
*/
#[JsonProperty('away_status_reason_id')]
private ?int $awayStatusReasonId;

/**
* @param array{
* adminId: string,
* adminId: int,
* awayModeEnabled: bool,
* awayModeReassign: bool,
* awayStatusReasonId?: ?int,
* } $values
*/
public function __construct(
Expand All @@ -37,20 +44,21 @@ public function __construct(
$this->adminId = $values['adminId'];
$this->awayModeEnabled = $values['awayModeEnabled'];
$this->awayModeReassign = $values['awayModeReassign'];
$this->awayStatusReasonId = $values['awayStatusReasonId'] ?? null;
}

/**
* @return string
* @return int
*/
public function getAdminId(): string
public function getAdminId(): int
{
return $this->adminId;
}

/**
* @param string $value
* @param int $value
*/
public function setAdminId(string $value): self
public function setAdminId(int $value): self
{
$this->adminId = $value;
return $this;
Expand Down Expand Up @@ -89,4 +97,21 @@ public function setAwayModeReassign(bool $value): self
$this->awayModeReassign = $value;
return $this;
}

/**
* @return ?int
*/
public function getAwayStatusReasonId(): ?int
{
return $this->awayStatusReasonId;
}

/**
* @param ?int $value
*/
public function setAwayStatusReasonId(?int $value = null): self
{
$this->awayStatusReasonId = $value;
return $this;
}
}
14 changes: 7 additions & 7 deletions src/Admins/Requests/FindAdminRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
class FindAdminRequest extends JsonSerializableType
{
/**
* @var string $adminId The unique identifier of a given admin
* @var int $adminId The unique identifier of a given admin
*/
private string $adminId;
private int $adminId;

/**
* @param array{
* adminId: string,
* adminId: int,
* } $values
*/
public function __construct(
Expand All @@ -23,17 +23,17 @@ public function __construct(
}

/**
* @return string
* @return int
*/
public function getAdminId(): string
public function getAdminId(): int
{
return $this->adminId;
}

/**
* @param string $value
* @param int $value
*/
public function setAdminId(string $value): self
public function setAdminId(int $value): self
{
$this->adminId = $value;
return $this;
Expand Down
Loading