diff --git a/README.md b/README.md index 983c94b..a21e3de 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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: '', ); -$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', ]), ); @@ -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"; @@ -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 @@ -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 @@ -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! \ No newline at end of file diff --git a/composer.json b/composer.json index e69df79..2949cf4 100644 --- a/composer.json +++ b/composer.json @@ -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": "*", @@ -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" } \ No newline at end of file diff --git a/src/Admins/AdminsClient.php b/src/Admins/AdminsClient.php index 82600c0..68476db 100644 --- a/src/Admins/AdminsClient.php +++ b/src/Admins/AdminsClient.php @@ -72,11 +72,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $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 { @@ -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) { @@ -127,11 +130,11 @@ public function identify(?array $options = null): AdminWithApp * queryParameters?: array, * bodyProperties?: array, * } $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 { @@ -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) { @@ -298,11 +304,11 @@ public function list(?array $options = null): AdminList * queryParameters?: array, * bodyProperties?: array, * } $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 { @@ -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) { diff --git a/src/Admins/Requests/ConfigureAwayAdminRequest.php b/src/Admins/Requests/ConfigureAwayAdminRequest.php index 37cee6d..caf75c2 100644 --- a/src/Admins/Requests/ConfigureAwayAdminRequest.php +++ b/src/Admins/Requests/ConfigureAwayAdminRequest.php @@ -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. @@ -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( @@ -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; @@ -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; + } } diff --git a/src/Admins/Requests/FindAdminRequest.php b/src/Admins/Requests/FindAdminRequest.php index 3145be7..e21f226 100644 --- a/src/Admins/Requests/FindAdminRequest.php +++ b/src/Admins/Requests/FindAdminRequest.php @@ -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( @@ -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; diff --git a/src/Admins/Types/Admin.php b/src/Admins/Types/Admin.php index 6a01234..f3fa63a 100644 --- a/src/Admins/Types/Admin.php +++ b/src/Admins/Types/Admin.php @@ -13,7 +13,7 @@ class Admin extends JsonSerializableType { /** - * @var ?'admin' $type String representing the object's type. Always has the value `admin`. + * @var ?string $type String representing the object's type. Always has the value `admin`. */ #[JsonProperty('type')] private ?string $type; @@ -54,6 +54,12 @@ class Admin 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; + /** * @var bool $hasInboxSeat Identifies if this admin has a paid inbox seat to restrict/allow features that require them. */ @@ -67,10 +73,10 @@ class Admin extends JsonSerializableType private array $teamIds; /** - * @var ?AdminAvatar $avatar The avatar object associated with the admin + * @var ?string $avatar Image for the associated team or teammate */ #[JsonProperty('avatar')] - private ?AdminAvatar $avatar; + private ?string $avatar; /** * @var ?TeamPriorityLevel $teamPriorityLevel @@ -87,9 +93,10 @@ class Admin extends JsonSerializableType * awayModeReassign: bool, * hasInboxSeat: bool, * teamIds: array, - * type?: ?'admin', + * type?: ?string, * jobTitle?: ?string, - * avatar?: ?AdminAvatar, + * awayStatusReasonId?: ?int, + * avatar?: ?string, * teamPriorityLevel?: ?TeamPriorityLevel, * } $values */ @@ -103,6 +110,7 @@ public function __construct( $this->jobTitle = $values['jobTitle'] ?? null; $this->awayModeEnabled = $values['awayModeEnabled']; $this->awayModeReassign = $values['awayModeReassign']; + $this->awayStatusReasonId = $values['awayStatusReasonId'] ?? null; $this->hasInboxSeat = $values['hasInboxSeat']; $this->teamIds = $values['teamIds']; $this->avatar = $values['avatar'] ?? null; @@ -110,7 +118,7 @@ public function __construct( } /** - * @return ?'admin' + * @return ?string */ public function getType(): ?string { @@ -118,7 +126,7 @@ public function getType(): ?string } /** - * @param ?'admin' $value + * @param ?string $value */ public function setType(?string $value = null): self { @@ -228,6 +236,23 @@ public function setAwayModeReassign(bool $value): self 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; + } + /** * @return bool */ @@ -263,17 +288,17 @@ public function setTeamIds(array $value): self } /** - * @return ?AdminAvatar + * @return ?string */ - public function getAvatar(): ?AdminAvatar + public function getAvatar(): ?string { return $this->avatar; } /** - * @param ?AdminAvatar $value + * @param ?string $value */ - public function setAvatar(?AdminAvatar $value = null): self + public function setAvatar(?string $value = null): self { $this->avatar = $value; return $this; diff --git a/src/Admins/Types/AdminAvatar.php b/src/Admins/Types/AdminAvatar.php deleted file mode 100644 index b0a255c..0000000 --- a/src/Admins/Types/AdminAvatar.php +++ /dev/null @@ -1,54 +0,0 @@ -imageUrl = $values['imageUrl']; - } - - /** - * @return string - */ - public function getImageUrl(): string - { - return $this->imageUrl; - } - - /** - * @param string $value - */ - public function setImageUrl(string $value): self - { - $this->imageUrl = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/AiAgent/Types/AiAgent.php b/src/AiAgent/Types/AiAgent.php index 76dc4b7..b3d2011 100644 --- a/src/AiAgent/Types/AiAgent.php +++ b/src/AiAgent/Types/AiAgent.php @@ -12,10 +12,10 @@ class AiAgent extends JsonSerializableType { /** - * @var value-of $sourceType The type of the source that triggered AI Agent involvement in the conversation. + * @var ?value-of $sourceType The type of the source that triggered AI Agent involvement in the conversation. */ #[JsonProperty('source_type')] - private string $sourceType; + private ?string $sourceType; /** * @var ?string $sourceTitle The title of the source that triggered AI Agent involvement in the conversation. If this is `essentials_plan_setup` then it will return `null`. @@ -47,6 +47,18 @@ class AiAgent extends JsonSerializableType #[JsonProperty('rating_remark')] private ?string $ratingRemark; + /** + * @var ?int $createdAt The time when the AI agent rating was created. + */ + #[JsonProperty('created_at')] + private ?int $createdAt; + + /** + * @var ?int $updatedAt The time when the AI agent rating was last updated. + */ + #[JsonProperty('updated_at')] + private ?int $updatedAt; + /** * @var ?ContentSourcesList $contentSources */ @@ -55,39 +67,43 @@ class AiAgent extends JsonSerializableType /** * @param array{ - * sourceType: value-of, + * sourceType?: ?value-of, * sourceTitle?: ?string, * lastAnswerType?: ?string, * resolutionState?: ?string, * rating?: ?int, * ratingRemark?: ?string, + * createdAt?: ?int, + * updatedAt?: ?int, * contentSources?: ?ContentSourcesList, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->sourceType = $values['sourceType']; + $this->sourceType = $values['sourceType'] ?? null; $this->sourceTitle = $values['sourceTitle'] ?? null; $this->lastAnswerType = $values['lastAnswerType'] ?? null; $this->resolutionState = $values['resolutionState'] ?? null; $this->rating = $values['rating'] ?? null; $this->ratingRemark = $values['ratingRemark'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; $this->contentSources = $values['contentSources'] ?? null; } /** - * @return value-of + * @return ?value-of */ - public function getSourceType(): string + public function getSourceType(): ?string { return $this->sourceType; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setSourceType(string $value): self + public function setSourceType(?string $value = null): self { $this->sourceType = $value; return $this; @@ -178,6 +194,40 @@ public function setRatingRemark(?string $value = null): self return $this; } + /** + * @return ?int + */ + public function getCreatedAt(): ?int + { + return $this->createdAt; + } + + /** + * @param ?int $value + */ + public function setCreatedAt(?int $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getUpdatedAt(): ?int + { + return $this->updatedAt; + } + + /** + * @param ?int $value + */ + public function setUpdatedAt(?int $value = null): self + { + $this->updatedAt = $value; + return $this; + } + /** * @return ?ContentSourcesList */ diff --git a/src/AiContent/AiContentClient.php b/src/AiContent/AiContentClient.php new file mode 100644 index 0000000..cc1da89 --- /dev/null +++ b/src/AiContent/AiContentClient.php @@ -0,0 +1,609 @@ +, + * } $options + */ + private array $options; + + /** + * @var RawClient $client + */ + private RawClient $client; + + /** + * @param RawClient $client + * @param ?array{ + * baseUrl?: string, + * client?: ClientInterface, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * } $options + */ + public function __construct( + RawClient $client, + ?array $options = null, + ) { + $this->client = $client; + $this->options = $options ?? []; + } + + /** + * You can retrieve a list of all content import sources for a workspace. + * + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ContentImportSourcesList + * @throws IntercomException + * @throws IntercomApiException + */ + public function listContentImportSources(?array $options = null): ContentImportSourcesList + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "ai/content_import_sources", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ContentImportSourcesList::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can create a new content import source by sending a POST request to this endpoint. + * + * @param CreateContentImportSourceRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ContentImportSource + * @throws IntercomException + * @throws IntercomApiException + */ + public function createContentImportSource(CreateContentImportSourceRequest $request, ?array $options = null): ContentImportSource + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "ai/content_import_sources", + method: HttpMethod::POST, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ContentImportSource::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * @param GetContentImportSourceRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ContentImportSource + * @throws IntercomException + * @throws IntercomApiException + */ + public function getContentImportSource(GetContentImportSourceRequest $request, ?array $options = null): ContentImportSource + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "ai/content_import_sources/{$request->getSourceId()}", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ContentImportSource::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can update an existing content import source. + * + * @param UpdateContentImportSourceRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ContentImportSource + * @throws IntercomException + * @throws IntercomApiException + */ + public function updateContentImportSource(UpdateContentImportSourceRequest $request, ?array $options = null): ContentImportSource + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "ai/content_import_sources/{$request->getSourceId()}", + method: HttpMethod::PUT, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ContentImportSource::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can delete a content import source by making a DELETE request this endpoint. This will also delete all external pages that were imported from this source. + * + * @param DeleteContentImportSourceRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @throws IntercomException + * @throws IntercomApiException + */ + public function deleteContentImportSource(DeleteContentImportSourceRequest $request, ?array $options = null): void + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "ai/content_import_sources/{$request->getSourceId()}", + method: HttpMethod::DELETE, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + return; + } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can retrieve a list of all external pages for a workspace. + * + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ExternalPagesList + * @throws IntercomException + * @throws IntercomApiException + */ + public function listExternalPages(?array $options = null): ExternalPagesList + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "ai/external_pages", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ExternalPagesList::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can create a new external page by sending a POST request to this endpoint. If an external page already exists with the specified source_id and external_id, it will be updated instead. + * + * @param CreateExternalPageRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ExternalPage + * @throws IntercomException + * @throws IntercomApiException + */ + public function createExternalPage(CreateExternalPageRequest $request, ?array $options = null): ExternalPage + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "ai/external_pages", + method: HttpMethod::POST, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ExternalPage::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can retrieve an external page. + * + * @param GetExternalPageRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ExternalPage + * @throws IntercomException + * @throws IntercomApiException + */ + public function getExternalPage(GetExternalPageRequest $request, ?array $options = null): ExternalPage + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "ai/external_pages/{$request->getPageId()}", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ExternalPage::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can update an existing external page (if it was created via the API). + * + * @param UpdateExternalPageRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ExternalPage + * @throws IntercomException + * @throws IntercomApiException + */ + public function updateExternalPage(UpdateExternalPageRequest $request, ?array $options = null): ExternalPage + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "ai/external_pages/{$request->getPageId()}", + method: HttpMethod::PUT, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ExternalPage::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Sending a DELETE request for an external page will remove it from the content library UI and from being used for AI answers. + * + * @param DeleteExternalPageRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ExternalPage + * @throws IntercomException + * @throws IntercomApiException + */ + public function deleteExternalPage(DeleteExternalPageRequest $request, ?array $options = null): ExternalPage + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "ai/external_pages/{$request->getPageId()}", + method: HttpMethod::DELETE, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ExternalPage::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } +} diff --git a/src/AiContent/Requests/CreateContentImportSourceRequest.php b/src/AiContent/Requests/CreateContentImportSourceRequest.php new file mode 100644 index 0000000..123096c --- /dev/null +++ b/src/AiContent/Requests/CreateContentImportSourceRequest.php @@ -0,0 +1,94 @@ + $status The status of the content import source. + */ + #[JsonProperty('status')] + private ?string $status; + + /** + * @var string $url The URL of the content import source. + */ + #[JsonProperty('url')] + private string $url; + + /** + * @param array{ + * syncBehavior: 'api', + * url: string, + * status?: ?value-of, + * } $values + */ + public function __construct( + array $values, + ) { + $this->syncBehavior = $values['syncBehavior']; + $this->status = $values['status'] ?? null; + $this->url = $values['url']; + } + + /** + * @return 'api' + */ + public function getSyncBehavior(): string + { + return $this->syncBehavior; + } + + /** + * @param 'api' $value + */ + public function setSyncBehavior(string $value): self + { + $this->syncBehavior = $value; + return $this; + } + + /** + * @return ?value-of + */ + public function getStatus(): ?string + { + return $this->status; + } + + /** + * @param ?value-of $value + */ + public function setStatus(?string $value = null): self + { + $this->status = $value; + return $this; + } + + /** + * @return string + */ + public function getUrl(): string + { + return $this->url; + } + + /** + * @param string $value + */ + public function setUrl(string $value): self + { + $this->url = $value; + return $this; + } +} diff --git a/src/AiContent/Requests/CreateExternalPageRequest.php b/src/AiContent/Requests/CreateExternalPageRequest.php new file mode 100644 index 0000000..d4bc323 --- /dev/null +++ b/src/AiContent/Requests/CreateExternalPageRequest.php @@ -0,0 +1,218 @@ +title = $values['title']; + $this->html = $values['html']; + $this->url = $values['url'] ?? null; + $this->aiAgentAvailability = $values['aiAgentAvailability'] ?? null; + $this->aiCopilotAvailability = $values['aiCopilotAvailability'] ?? null; + $this->locale = $values['locale']; + $this->sourceId = $values['sourceId']; + $this->externalId = $values['externalId']; + } + + /** + * @return string + */ + public function getTitle(): string + { + return $this->title; + } + + /** + * @param string $value + */ + public function setTitle(string $value): self + { + $this->title = $value; + return $this; + } + + /** + * @return string + */ + public function getHtml(): string + { + return $this->html; + } + + /** + * @param string $value + */ + public function setHtml(string $value): self + { + $this->html = $value; + return $this; + } + + /** + * @return ?string + */ + public function getUrl(): ?string + { + return $this->url; + } + + /** + * @param ?string $value + */ + public function setUrl(?string $value = null): self + { + $this->url = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getAiAgentAvailability(): ?bool + { + return $this->aiAgentAvailability; + } + + /** + * @param ?bool $value + */ + public function setAiAgentAvailability(?bool $value = null): self + { + $this->aiAgentAvailability = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getAiCopilotAvailability(): ?bool + { + return $this->aiCopilotAvailability; + } + + /** + * @param ?bool $value + */ + public function setAiCopilotAvailability(?bool $value = null): self + { + $this->aiCopilotAvailability = $value; + return $this; + } + + /** + * @return 'en' + */ + public function getLocale(): string + { + return $this->locale; + } + + /** + * @param 'en' $value + */ + public function setLocale(string $value): self + { + $this->locale = $value; + return $this; + } + + /** + * @return int + */ + public function getSourceId(): int + { + return $this->sourceId; + } + + /** + * @param int $value + */ + public function setSourceId(int $value): self + { + $this->sourceId = $value; + return $this; + } + + /** + * @return string + */ + public function getExternalId(): string + { + return $this->externalId; + } + + /** + * @param string $value + */ + public function setExternalId(string $value): self + { + $this->externalId = $value; + return $this; + } +} diff --git a/src/AiContent/Requests/DeleteContentImportSourceRequest.php b/src/AiContent/Requests/DeleteContentImportSourceRequest.php new file mode 100644 index 0000000..ce218ec --- /dev/null +++ b/src/AiContent/Requests/DeleteContentImportSourceRequest.php @@ -0,0 +1,41 @@ +sourceId = $values['sourceId']; + } + + /** + * @return string + */ + public function getSourceId(): string + { + return $this->sourceId; + } + + /** + * @param string $value + */ + public function setSourceId(string $value): self + { + $this->sourceId = $value; + return $this; + } +} diff --git a/src/AiContent/Requests/DeleteExternalPageRequest.php b/src/AiContent/Requests/DeleteExternalPageRequest.php new file mode 100644 index 0000000..03748fc --- /dev/null +++ b/src/AiContent/Requests/DeleteExternalPageRequest.php @@ -0,0 +1,41 @@ +pageId = $values['pageId']; + } + + /** + * @return string + */ + public function getPageId(): string + { + return $this->pageId; + } + + /** + * @param string $value + */ + public function setPageId(string $value): self + { + $this->pageId = $value; + return $this; + } +} diff --git a/src/AiContent/Requests/GetContentImportSourceRequest.php b/src/AiContent/Requests/GetContentImportSourceRequest.php new file mode 100644 index 0000000..53bde83 --- /dev/null +++ b/src/AiContent/Requests/GetContentImportSourceRequest.php @@ -0,0 +1,41 @@ +sourceId = $values['sourceId']; + } + + /** + * @return string + */ + public function getSourceId(): string + { + return $this->sourceId; + } + + /** + * @param string $value + */ + public function setSourceId(string $value): self + { + $this->sourceId = $value; + return $this; + } +} diff --git a/src/AiContent/Requests/GetExternalPageRequest.php b/src/AiContent/Requests/GetExternalPageRequest.php new file mode 100644 index 0000000..c6b1074 --- /dev/null +++ b/src/AiContent/Requests/GetExternalPageRequest.php @@ -0,0 +1,41 @@ +pageId = $values['pageId']; + } + + /** + * @return string + */ + public function getPageId(): string + { + return $this->pageId; + } + + /** + * @param string $value + */ + public function setPageId(string $value): self + { + $this->pageId = $value; + return $this; + } +} diff --git a/src/AiContent/Requests/UpdateContentImportSourceRequest.php b/src/AiContent/Requests/UpdateContentImportSourceRequest.php new file mode 100644 index 0000000..c97d52c --- /dev/null +++ b/src/AiContent/Requests/UpdateContentImportSourceRequest.php @@ -0,0 +1,119 @@ + $syncBehavior If you intend to create or update External Pages via the API, this should be set to `api`. You can not change the value to or from api. + */ + #[JsonProperty('sync_behavior')] + private string $syncBehavior; + + /** + * @var ?value-of $status The status of the content import source. + */ + #[JsonProperty('status')] + private ?string $status; + + /** + * @var string $url The URL of the content import source. This may only be different from the existing value if the sync behavior is API. + */ + #[JsonProperty('url')] + private string $url; + + /** + * @param array{ + * sourceId: string, + * syncBehavior: value-of, + * url: string, + * status?: ?value-of, + * } $values + */ + public function __construct( + array $values, + ) { + $this->sourceId = $values['sourceId']; + $this->syncBehavior = $values['syncBehavior']; + $this->status = $values['status'] ?? null; + $this->url = $values['url']; + } + + /** + * @return string + */ + public function getSourceId(): string + { + return $this->sourceId; + } + + /** + * @param string $value + */ + public function setSourceId(string $value): self + { + $this->sourceId = $value; + return $this; + } + + /** + * @return value-of + */ + public function getSyncBehavior(): string + { + return $this->syncBehavior; + } + + /** + * @param value-of $value + */ + public function setSyncBehavior(string $value): self + { + $this->syncBehavior = $value; + return $this; + } + + /** + * @return ?value-of + */ + public function getStatus(): ?string + { + return $this->status; + } + + /** + * @param ?value-of $value + */ + public function setStatus(?string $value = null): self + { + $this->status = $value; + return $this; + } + + /** + * @return string + */ + public function getUrl(): string + { + return $this->url; + } + + /** + * @param string $value + */ + public function setUrl(string $value): self + { + $this->url = $value; + return $this; + } +} diff --git a/src/AiContent/Requests/UpdateExternalPageRequest.php b/src/AiContent/Requests/UpdateExternalPageRequest.php new file mode 100644 index 0000000..e77aa99 --- /dev/null +++ b/src/AiContent/Requests/UpdateExternalPageRequest.php @@ -0,0 +1,217 @@ +pageId = $values['pageId']; + $this->title = $values['title']; + $this->html = $values['html']; + $this->url = $values['url']; + $this->finAvailability = $values['finAvailability'] ?? null; + $this->locale = $values['locale']; + $this->sourceId = $values['sourceId']; + $this->externalId = $values['externalId'] ?? null; + } + + /** + * @return string + */ + public function getPageId(): string + { + return $this->pageId; + } + + /** + * @param string $value + */ + public function setPageId(string $value): self + { + $this->pageId = $value; + return $this; + } + + /** + * @return string + */ + public function getTitle(): string + { + return $this->title; + } + + /** + * @param string $value + */ + public function setTitle(string $value): self + { + $this->title = $value; + return $this; + } + + /** + * @return string + */ + public function getHtml(): string + { + return $this->html; + } + + /** + * @param string $value + */ + public function setHtml(string $value): self + { + $this->html = $value; + return $this; + } + + /** + * @return string + */ + public function getUrl(): string + { + return $this->url; + } + + /** + * @param string $value + */ + public function setUrl(string $value): self + { + $this->url = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getFinAvailability(): ?bool + { + return $this->finAvailability; + } + + /** + * @param ?bool $value + */ + public function setFinAvailability(?bool $value = null): self + { + $this->finAvailability = $value; + return $this; + } + + /** + * @return 'en' + */ + public function getLocale(): string + { + return $this->locale; + } + + /** + * @param 'en' $value + */ + public function setLocale(string $value): self + { + $this->locale = $value; + return $this; + } + + /** + * @return int + */ + public function getSourceId(): int + { + return $this->sourceId; + } + + /** + * @param int $value + */ + public function setSourceId(int $value): self + { + $this->sourceId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getExternalId(): ?string + { + return $this->externalId; + } + + /** + * @param ?string $value + */ + public function setExternalId(?string $value = null): self + { + $this->externalId = $value; + return $this; + } +} diff --git a/src/AiContent/Types/ContentImportSource.php b/src/AiContent/Types/ContentImportSource.php new file mode 100644 index 0000000..f0ef072 --- /dev/null +++ b/src/AiContent/Types/ContentImportSource.php @@ -0,0 +1,229 @@ + $syncBehavior If you intend to create or update External Pages via the API, this should be set to `api`. + */ + #[JsonProperty('sync_behavior')] + private string $syncBehavior; + + /** + * @var value-of $status The status of the content import source. + */ + #[JsonProperty('status')] + private string $status; + + /** + * @var string $url The URL of the root of the external source. + */ + #[JsonProperty('url')] + private string $url; + + /** + * @var int $createdAt The time when the content import source was created. + */ + #[JsonProperty('created_at')] + private int $createdAt; + + /** + * @var int $updatedAt The time when the content import source was last updated. + */ + #[JsonProperty('updated_at')] + private int $updatedAt; + + /** + * @param array{ + * type: 'content_import_source', + * id: int, + * lastSyncedAt: int, + * syncBehavior: value-of, + * status: value-of, + * url: string, + * createdAt: int, + * updatedAt: int, + * } $values + */ + public function __construct( + array $values, + ) { + $this->type = $values['type']; + $this->id = $values['id']; + $this->lastSyncedAt = $values['lastSyncedAt']; + $this->syncBehavior = $values['syncBehavior']; + $this->status = $values['status']; + $this->url = $values['url']; + $this->createdAt = $values['createdAt']; + $this->updatedAt = $values['updatedAt']; + } + + /** + * @return 'content_import_source' + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param 'content_import_source' $value + */ + public function setType(string $value): self + { + $this->type = $value; + return $this; + } + + /** + * @return int + */ + public function getId(): int + { + return $this->id; + } + + /** + * @param int $value + */ + public function setId(int $value): self + { + $this->id = $value; + return $this; + } + + /** + * @return int + */ + public function getLastSyncedAt(): int + { + return $this->lastSyncedAt; + } + + /** + * @param int $value + */ + public function setLastSyncedAt(int $value): self + { + $this->lastSyncedAt = $value; + return $this; + } + + /** + * @return value-of + */ + public function getSyncBehavior(): string + { + return $this->syncBehavior; + } + + /** + * @param value-of $value + */ + public function setSyncBehavior(string $value): self + { + $this->syncBehavior = $value; + return $this; + } + + /** + * @return value-of + */ + public function getStatus(): string + { + return $this->status; + } + + /** + * @param value-of $value + */ + public function setStatus(string $value): self + { + $this->status = $value; + return $this; + } + + /** + * @return string + */ + public function getUrl(): string + { + return $this->url; + } + + /** + * @param string $value + */ + public function setUrl(string $value): self + { + $this->url = $value; + return $this; + } + + /** + * @return int + */ + public function getCreatedAt(): int + { + return $this->createdAt; + } + + /** + * @param int $value + */ + public function setCreatedAt(int $value): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return int + */ + public function getUpdatedAt(): int + { + return $this->updatedAt; + } + + /** + * @param int $value + */ + public function setUpdatedAt(int $value): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/AiContent/Types/ContentImportSourceStatus.php b/src/AiContent/Types/ContentImportSourceStatus.php new file mode 100644 index 0000000..4c29bcf --- /dev/null +++ b/src/AiContent/Types/ContentImportSourceStatus.php @@ -0,0 +1,9 @@ + $data An array of Content Import Source objects + */ + #[JsonProperty('data'), ArrayType([ContentImportSource::class])] + private ?array $data; + + /** + * @param array{ + * type?: ?'list', + * pages?: ?PagesLink, + * totalCount?: ?int, + * data?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->pages = $values['pages'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return ?'list' + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?'list' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?PagesLink + */ + public function getPages(): ?PagesLink + { + return $this->pages; + } + + /** + * @param ?PagesLink $value + */ + public function setPages(?PagesLink $value = null): self + { + $this->pages = $value; + return $this; + } + + /** + * @return ?int + */ + public function getTotalCount(): ?int + { + return $this->totalCount; + } + + /** + * @param ?int $value + */ + public function setTotalCount(?int $value = null): self + { + $this->totalCount = $value; + return $this; + } + + /** + * @return ?array + */ + public function getData(): ?array + { + return $this->data; + } + + /** + * @param ?array $value + */ + public function setData(?array $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/AiContent/Types/CreateContentImportSourceRequestStatus.php b/src/AiContent/Types/CreateContentImportSourceRequestStatus.php new file mode 100644 index 0000000..449fdd7 --- /dev/null +++ b/src/AiContent/Types/CreateContentImportSourceRequestStatus.php @@ -0,0 +1,9 @@ +type = $values['type']; + $this->id = $values['id']; + $this->title = $values['title']; + $this->html = $values['html']; + $this->url = $values['url'] ?? null; + $this->aiAgentAvailability = $values['aiAgentAvailability']; + $this->aiCopilotAvailability = $values['aiCopilotAvailability']; + $this->finAvailability = $values['finAvailability'] ?? null; + $this->locale = $values['locale']; + $this->sourceId = $values['sourceId']; + $this->externalId = $values['externalId']; + $this->createdAt = $values['createdAt']; + $this->updatedAt = $values['updatedAt']; + $this->lastIngestedAt = $values['lastIngestedAt']; + } + + /** + * @return 'external_page' + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param 'external_page' $value + */ + public function setType(string $value): self + { + $this->type = $value; + return $this; + } + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $value + */ + public function setId(string $value): self + { + $this->id = $value; + return $this; + } + + /** + * @return string + */ + public function getTitle(): string + { + return $this->title; + } + + /** + * @param string $value + */ + public function setTitle(string $value): self + { + $this->title = $value; + return $this; + } + + /** + * @return string + */ + public function getHtml(): string + { + return $this->html; + } + + /** + * @param string $value + */ + public function setHtml(string $value): self + { + $this->html = $value; + return $this; + } + + /** + * @return ?string + */ + public function getUrl(): ?string + { + return $this->url; + } + + /** + * @param ?string $value + */ + public function setUrl(?string $value = null): self + { + $this->url = $value; + return $this; + } + + /** + * @return bool + */ + public function getAiAgentAvailability(): bool + { + return $this->aiAgentAvailability; + } + + /** + * @param bool $value + */ + public function setAiAgentAvailability(bool $value): self + { + $this->aiAgentAvailability = $value; + return $this; + } + + /** + * @return bool + */ + public function getAiCopilotAvailability(): bool + { + return $this->aiCopilotAvailability; + } + + /** + * @param bool $value + */ + public function setAiCopilotAvailability(bool $value): self + { + $this->aiCopilotAvailability = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getFinAvailability(): ?bool + { + return $this->finAvailability; + } + + /** + * @param ?bool $value + */ + public function setFinAvailability(?bool $value = null): self + { + $this->finAvailability = $value; + return $this; + } + + /** + * @return 'en' + */ + public function getLocale(): string + { + return $this->locale; + } + + /** + * @param 'en' $value + */ + public function setLocale(string $value): self + { + $this->locale = $value; + return $this; + } + + /** + * @return int + */ + public function getSourceId(): int + { + return $this->sourceId; + } + + /** + * @param int $value + */ + public function setSourceId(int $value): self + { + $this->sourceId = $value; + return $this; + } + + /** + * @return string + */ + public function getExternalId(): string + { + return $this->externalId; + } + + /** + * @param string $value + */ + public function setExternalId(string $value): self + { + $this->externalId = $value; + return $this; + } + + /** + * @return int + */ + public function getCreatedAt(): int + { + return $this->createdAt; + } + + /** + * @param int $value + */ + public function setCreatedAt(int $value): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return int + */ + public function getUpdatedAt(): int + { + return $this->updatedAt; + } + + /** + * @param int $value + */ + public function setUpdatedAt(int $value): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return int + */ + public function getLastIngestedAt(): int + { + return $this->lastIngestedAt; + } + + /** + * @param int $value + */ + public function setLastIngestedAt(int $value): self + { + $this->lastIngestedAt = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/AiContent/Types/ExternalPagesList.php b/src/AiContent/Types/ExternalPagesList.php new file mode 100644 index 0000000..edb5cbc --- /dev/null +++ b/src/AiContent/Types/ExternalPagesList.php @@ -0,0 +1,131 @@ + $data An array of External Page objects + */ + #[JsonProperty('data'), ArrayType([ExternalPage::class])] + private ?array $data; + + /** + * @param array{ + * type?: ?'list', + * pages?: ?PagesLink, + * totalCount?: ?int, + * data?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->pages = $values['pages'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return ?'list' + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?'list' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?PagesLink + */ + public function getPages(): ?PagesLink + { + return $this->pages; + } + + /** + * @param ?PagesLink $value + */ + public function setPages(?PagesLink $value = null): self + { + $this->pages = $value; + return $this; + } + + /** + * @return ?int + */ + public function getTotalCount(): ?int + { + return $this->totalCount; + } + + /** + * @param ?int $value + */ + public function setTotalCount(?int $value = null): self + { + $this->totalCount = $value; + return $this; + } + + /** + * @return ?array + */ + public function getData(): ?array + { + return $this->data; + } + + /** + * @param ?array $value + */ + public function setData(?array $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/AiContent/Types/UpdateContentImportSourceRequestStatus.php b/src/AiContent/Types/UpdateContentImportSourceRequestStatus.php new file mode 100644 index 0000000..05f7273 --- /dev/null +++ b/src/AiContent/Types/UpdateContentImportSourceRequestStatus.php @@ -0,0 +1,9 @@ +contentType = $values['contentType']; - $this->url = $values['url']; - $this->title = $values['title']; - $this->locale = $values['locale']; + $this->contentType = $values['contentType'] ?? null; + $this->url = $values['url'] ?? null; + $this->title = $values['title'] ?? null; + $this->locale = $values['locale'] ?? null; } /** - * @return 'custom_answer' + * @return ?'custom_answer' */ - public function getContentType(): string + public function getContentType(): ?string { return $this->contentType; } /** - * @param 'custom_answer' $value + * @param ?'custom_answer' $value */ - public function setContentType(string $value): self + public function setContentType(?string $value = null): self { $this->contentType = $value; return $this; } /** - * @return string + * @return ?string */ - public function getUrl(): string + public function getUrl(): ?string { return $this->url; } /** - * @param string $value + * @param ?string $value */ - public function setUrl(string $value): self + public function setUrl(?string $value = null): self { $this->url = $value; return $this; } /** - * @return string + * @return ?string */ - public function getTitle(): string + public function getTitle(): ?string { return $this->title; } /** - * @param string $value + * @param ?string $value */ - public function setTitle(string $value): self + public function setTitle(?string $value = null): self { $this->title = $value; return $this; } /** - * @return string + * @return ?string */ - public function getLocale(): string + public function getLocale(): ?string { return $this->locale; } /** - * @param string $value + * @param ?string $value */ - public function setLocale(string $value): self + public function setLocale(?string $value = null): self { $this->locale = $value; return $this; diff --git a/src/Articles/ArticlesClient.php b/src/Articles/ArticlesClient.php index cc81580..6af2ac3 100644 --- a/src/Articles/ArticlesClient.php +++ b/src/Articles/ArticlesClient.php @@ -9,7 +9,7 @@ use Intercom\Articles\Types\ArticleListItem; use Intercom\Core\Pagination\OffsetPager; use Intercom\Types\ArticleList; -use Intercom\Articles\Requests\CreateArticleRequest; +use Intercom\Types\CreateArticleRequest; use Intercom\Articles\Types\Article; use Intercom\Exceptions\IntercomException; use Intercom\Exceptions\IntercomApiException; @@ -24,7 +24,7 @@ use Intercom\Articles\Requests\DeleteArticleRequest; use Intercom\Types\DeletedArticleObject; use Intercom\Articles\Requests\SearchArticlesRequest; -use Intercom\Articles\Types\SearchArticlesResponse; +use Intercom\Articles\Types\ArticleSearchResponse; class ArticlesClient { @@ -101,7 +101,7 @@ public function list(ListArticlesRequest $request = new ListArticlesRequest(), ? /** * You can create a new article by making a POST request to `https://api.intercom.io/articles`. * - * @param CreateArticleRequest $request + * @param ?CreateArticleRequest $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -114,7 +114,7 @@ public function list(ListArticlesRequest $request = new ListArticlesRequest(), ? * @throws IntercomException * @throws IntercomApiException */ - public function create(CreateArticleRequest $request, ?array $options = null): Article + public function create(?CreateArticleRequest $request = null, ?array $options = null): Article { $options = array_merge($this->options, $options ?? []); try { @@ -332,11 +332,11 @@ public function delete(DeleteArticleRequest $request, ?array $options = null): D * queryParameters?: array, * bodyProperties?: array, * } $options - * @return SearchArticlesResponse + * @return ArticleSearchResponse * @throws IntercomException * @throws IntercomApiException */ - public function search(SearchArticlesRequest $request = new SearchArticlesRequest(), ?array $options = null): SearchArticlesResponse + public function search(SearchArticlesRequest $request = new SearchArticlesRequest(), ?array $options = null): ArticleSearchResponse { $options = array_merge($this->options, $options ?? []); $query = []; @@ -365,7 +365,7 @@ public function search(SearchArticlesRequest $request = new SearchArticlesReques $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); - return SearchArticlesResponse::fromJson($json); + return ArticleSearchResponse::fromJson($json); } } catch (JsonException $e) { throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); diff --git a/src/Articles/Requests/DeleteArticleRequest.php b/src/Articles/Requests/DeleteArticleRequest.php index ecc8079..de8e346 100644 --- a/src/Articles/Requests/DeleteArticleRequest.php +++ b/src/Articles/Requests/DeleteArticleRequest.php @@ -7,13 +7,13 @@ class DeleteArticleRequest extends JsonSerializableType { /** - * @var string $articleId The unique identifier for the article which is given by Intercom. + * @var int $articleId The unique identifier for the article which is given by Intercom. */ - private string $articleId; + private int $articleId; /** * @param array{ - * articleId: string, + * articleId: int, * } $values */ public function __construct( @@ -23,17 +23,17 @@ public function __construct( } /** - * @return string + * @return int */ - public function getArticleId(): string + public function getArticleId(): int { return $this->articleId; } /** - * @param string $value + * @param int $value */ - public function setArticleId(string $value): self + public function setArticleId(int $value): self { $this->articleId = $value; return $this; diff --git a/src/Articles/Requests/FindArticleRequest.php b/src/Articles/Requests/FindArticleRequest.php index ff372e2..999e915 100644 --- a/src/Articles/Requests/FindArticleRequest.php +++ b/src/Articles/Requests/FindArticleRequest.php @@ -7,13 +7,13 @@ class FindArticleRequest extends JsonSerializableType { /** - * @var string $articleId The unique identifier for the article which is given by Intercom. + * @var int $articleId The unique identifier for the article which is given by Intercom. */ - private string $articleId; + private int $articleId; /** * @param array{ - * articleId: string, + * articleId: int, * } $values */ public function __construct( @@ -23,17 +23,17 @@ public function __construct( } /** - * @return string + * @return int */ - public function getArticleId(): string + public function getArticleId(): int { return $this->articleId; } /** - * @param string $value + * @param int $value */ - public function setArticleId(string $value): self + public function setArticleId(int $value): self { $this->articleId = $value; return $this; diff --git a/src/Articles/Requests/UpdateArticleRequest.php b/src/Articles/Requests/UpdateArticleRequest.php index fdafae3..e29534e 100644 --- a/src/Articles/Requests/UpdateArticleRequest.php +++ b/src/Articles/Requests/UpdateArticleRequest.php @@ -4,16 +4,15 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; -use Intercom\Articles\Types\UpdateArticleRequestBodyState; -use Intercom\Articles\Types\UpdateArticleRequestBodyParentType; +use Intercom\Articles\Types\UpdateArticleRequestState; use Intercom\Types\ArticleTranslatedContent; class UpdateArticleRequest extends JsonSerializableType { /** - * @var string $articleId The unique identifier for the article which is given by Intercom. + * @var int $articleId The unique identifier for the article which is given by Intercom. */ - private string $articleId; + private int $articleId; /** * @var ?string $title The title of the article.For multilingual articles, this will be the title of the default language's content. @@ -40,7 +39,7 @@ class UpdateArticleRequest extends JsonSerializableType private ?int $authorId; /** - * @var ?value-of $state Whether the article will be `published` or will be a `draft`. Defaults to draft. For multilingual articles, this will be the state of the default language's content. + * @var ?value-of $state Whether the article will be `published` or will be a `draft`. Defaults to draft. For multilingual articles, this will be the state of the default language's content. */ #[JsonProperty('state')] private ?string $state; @@ -52,7 +51,7 @@ class UpdateArticleRequest extends JsonSerializableType private ?string $parentId; /** - * @var ?value-of $parentType The type of parent, which can either be a `collection` or `section`. + * @var ?string $parentType The type of parent, which can either be a `collection` or `section`. */ #[JsonProperty('parent_type')] private ?string $parentType; @@ -65,14 +64,14 @@ class UpdateArticleRequest extends JsonSerializableType /** * @param array{ - * articleId: string, + * articleId: int, * title?: ?string, * description?: ?string, * body?: ?string, * authorId?: ?int, - * state?: ?value-of, + * state?: ?value-of, * parentId?: ?string, - * parentType?: ?value-of, + * parentType?: ?string, * translatedContent?: ?ArticleTranslatedContent, * } $values */ @@ -91,17 +90,17 @@ public function __construct( } /** - * @return string + * @return int */ - public function getArticleId(): string + public function getArticleId(): int { return $this->articleId; } /** - * @param string $value + * @param int $value */ - public function setArticleId(string $value): self + public function setArticleId(int $value): self { $this->articleId = $value; return $this; @@ -176,7 +175,7 @@ public function setAuthorId(?int $value = null): self } /** - * @return ?value-of + * @return ?value-of */ public function getState(): ?string { @@ -184,7 +183,7 @@ public function getState(): ?string } /** - * @param ?value-of $value + * @param ?value-of $value */ public function setState(?string $value = null): self { @@ -210,7 +209,7 @@ public function setParentId(?string $value = null): self } /** - * @return ?value-of + * @return ?string */ public function getParentType(): ?string { @@ -218,7 +217,7 @@ public function getParentType(): ?string } /** - * @param ?value-of $value + * @param ?string $value */ public function setParentType(?string $value = null): self { diff --git a/src/Articles/Types/ArticleSearchHighlights.php b/src/Articles/Types/ArticleSearchHighlights.php index 7b88fe4..8cbd810 100644 --- a/src/Articles/Types/ArticleSearchHighlights.php +++ b/src/Articles/Types/ArticleSearchHighlights.php @@ -12,84 +12,84 @@ class ArticleSearchHighlights extends JsonSerializableType { /** - * @var string $articleId The ID of the corresponding article. + * @var ?string $articleId The ID of the corresponding article. */ #[JsonProperty('article_id')] - private string $articleId; + private ?string $articleId; /** - * @var array $highlightedTitle An Article title highlighted. + * @var ?array $highlightedTitle An Article title highlighted. */ #[JsonProperty('highlighted_title'), ArrayType([ArticleSearchHighlightsHighlightedTitleItem::class])] - private array $highlightedTitle; + private ?array $highlightedTitle; /** - * @var array> $highlightedSummary An Article description and body text highlighted. + * @var ?array> $highlightedSummary An Article description and body text highlighted. */ #[JsonProperty('highlighted_summary'), ArrayType([[ArticleSearchHighlightsHighlightedSummaryItemItem::class]])] - private array $highlightedSummary; + private ?array $highlightedSummary; /** * @param array{ - * articleId: string, - * highlightedTitle: array, - * highlightedSummary: array>, + * articleId?: ?string, + * highlightedTitle?: ?array, + * highlightedSummary?: ?array>, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->articleId = $values['articleId']; - $this->highlightedTitle = $values['highlightedTitle']; - $this->highlightedSummary = $values['highlightedSummary']; + $this->articleId = $values['articleId'] ?? null; + $this->highlightedTitle = $values['highlightedTitle'] ?? null; + $this->highlightedSummary = $values['highlightedSummary'] ?? null; } /** - * @return string + * @return ?string */ - public function getArticleId(): string + public function getArticleId(): ?string { return $this->articleId; } /** - * @param string $value + * @param ?string $value */ - public function setArticleId(string $value): self + public function setArticleId(?string $value = null): self { $this->articleId = $value; return $this; } /** - * @return array + * @return ?array */ - public function getHighlightedTitle(): array + public function getHighlightedTitle(): ?array { return $this->highlightedTitle; } /** - * @param array $value + * @param ?array $value */ - public function setHighlightedTitle(array $value): self + public function setHighlightedTitle(?array $value = null): self { $this->highlightedTitle = $value; return $this; } /** - * @return array> + * @return ?array> */ - public function getHighlightedSummary(): array + public function getHighlightedSummary(): ?array { return $this->highlightedSummary; } /** - * @param array> $value + * @param ?array> $value */ - public function setHighlightedSummary(array $value): self + public function setHighlightedSummary(?array $value = null): self { $this->highlightedSummary = $value; return $this; diff --git a/src/Articles/Types/SearchArticlesResponse.php b/src/Articles/Types/ArticleSearchResponse.php similarity index 56% rename from src/Articles/Types/SearchArticlesResponse.php rename to src/Articles/Types/ArticleSearchResponse.php index 79b8cd0..d432863 100644 --- a/src/Articles/Types/SearchArticlesResponse.php +++ b/src/Articles/Types/ArticleSearchResponse.php @@ -9,25 +9,25 @@ /** * The results of an Article search */ -class SearchArticlesResponse extends JsonSerializableType +class ArticleSearchResponse extends JsonSerializableType { /** - * @var 'list' $type The type of the object - `list`. + * @var ?'list' $type The type of the object - `list`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var int $totalCount The total number of Articles matching the search query + * @var ?int $totalCount The total number of Articles matching the search query */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** - * @var SearchArticlesResponseData $data An object containing the results of the search. + * @var ?ArticleSearchResponseData $data An object containing the results of the search. */ #[JsonProperty('data')] - private SearchArticlesResponseData $data; + private ?ArticleSearchResponseData $data; /** * @var ?CursorPages $pages @@ -37,67 +37,67 @@ class SearchArticlesResponse extends JsonSerializableType /** * @param array{ - * type: 'list', - * totalCount: int, - * data: SearchArticlesResponseData, + * type?: ?'list', + * totalCount?: ?int, + * data?: ?ArticleSearchResponseData, * pages?: ?CursorPages, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->totalCount = $values['totalCount']; - $this->data = $values['data']; + $this->type = $values['type'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->data = $values['data'] ?? null; $this->pages = $values['pages'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; } /** - * @return SearchArticlesResponseData + * @return ?ArticleSearchResponseData */ - public function getData(): SearchArticlesResponseData + public function getData(): ?ArticleSearchResponseData { return $this->data; } /** - * @param SearchArticlesResponseData $value + * @param ?ArticleSearchResponseData $value */ - public function setData(SearchArticlesResponseData $value): self + public function setData(?ArticleSearchResponseData $value = null): self { $this->data = $value; return $this; diff --git a/src/Articles/Types/SearchArticlesResponseData.php b/src/Articles/Types/ArticleSearchResponseData.php similarity index 96% rename from src/Articles/Types/SearchArticlesResponseData.php rename to src/Articles/Types/ArticleSearchResponseData.php index f1634af..56054d1 100644 --- a/src/Articles/Types/SearchArticlesResponseData.php +++ b/src/Articles/Types/ArticleSearchResponseData.php @@ -9,7 +9,7 @@ /** * An object containing the results of the search. */ -class SearchArticlesResponseData extends JsonSerializableType +class ArticleSearchResponseData extends JsonSerializableType { /** * @var ?array
$articles An array of Article objects diff --git a/src/Articles/Types/UpdateArticleRequestBodyState.php b/src/Articles/Types/UpdateArticleRequestBodyState.php deleted file mode 100644 index b803af9..0000000 --- a/src/Articles/Types/UpdateArticleRequestBodyState.php +++ /dev/null @@ -1,9 +0,0 @@ -, + * } $options + */ + private array $options; + + /** + * @var RawClient $client + */ + private RawClient $client; + + /** + * @param RawClient $client + * @param ?array{ + * baseUrl?: string, + * client?: ClientInterface, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * } $options + */ + public function __construct( + RawClient $client, + ?array $options = null, + ) { + $this->client = $client; + $this->options = $options ?? []; + } + + /** + * Returns a list of all away status reasons configured for the workspace, including deleted ones. + * + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return array + * @throws IntercomException + * @throws IntercomApiException + */ + public function listAwayStatusReasons(?array $options = null): array + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "away_status_reasons", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return JsonDecoder::decodeArray($json, [AwayStatusReason::class]); // @phpstan-ignore-line + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } +} diff --git a/src/Calls/CallsClient.php b/src/Calls/CallsClient.php new file mode 100644 index 0000000..e0aaffa --- /dev/null +++ b/src/Calls/CallsClient.php @@ -0,0 +1,337 @@ +, + * } $options + */ + private array $options; + + /** + * @var RawClient $client + */ + private RawClient $client; + + /** + * @param RawClient $client + * @param ?array{ + * baseUrl?: string, + * client?: ClientInterface, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * } $options + */ + public function __construct( + RawClient $client, + ?array $options = null, + ) { + $this->client = $client; + $this->options = $options ?? []; + } + + /** + * Retrieve a paginated list of calls. + * + * @param ListCallsRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return CallList + * @throws IntercomException + * @throws IntercomApiException + */ + public function listCalls(ListCallsRequest $request = new ListCallsRequest(), ?array $options = null): CallList + { + $options = array_merge($this->options, $options ?? []); + $query = []; + if ($request->getPage() != null) { + $query['page'] = $request->getPage(); + } + if ($request->getPerPage() != null) { + $query['per_page'] = $request->getPerPage(); + } + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "calls", + method: HttpMethod::GET, + query: $query, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return CallList::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Retrieve a single call by id. + * + * @param ShowCallRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return Call + * @throws IntercomException + * @throws IntercomApiException + */ + public function showCall(ShowCallRequest $request, ?array $options = null): Call + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "calls/{$request->getCallId()}", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return Call::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Redirects to a signed URL for the call's recording if it exists. + * + * @param ShowCallRecordingRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @throws IntercomException + * @throws IntercomApiException + */ + public function showCallRecording(ShowCallRecordingRequest $request, ?array $options = null): void + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "calls/{$request->getCallId()}/recording", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + return; + } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Returns the transcript for the specified call as a downloadable text file. + * + * @param ShowCallTranscriptRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return string + * @throws IntercomException + * @throws IntercomApiException + */ + public function showCallTranscript(ShowCallTranscriptRequest $request, ?array $options = null): string + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "calls/{$request->getCallId()}/transcript", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + return $response->getBody()->getContents(); + } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Retrieve calls by a list of conversation ids and include transcripts when available. + * A maximum of 20 `conversation_ids` can be provided. If none are provided or more than 20 are provided, a 400 error is returned. + * + * @param ListCallsWithTranscriptsRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ListCallsWithTranscriptsResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function listCallsWithTranscripts(ListCallsWithTranscriptsRequest $request, ?array $options = null): ListCallsWithTranscriptsResponse + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "calls/search", + method: HttpMethod::POST, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ListCallsWithTranscriptsResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } +} diff --git a/src/Calls/Requests/ListCallsRequest.php b/src/Calls/Requests/ListCallsRequest.php new file mode 100644 index 0000000..cdfedbd --- /dev/null +++ b/src/Calls/Requests/ListCallsRequest.php @@ -0,0 +1,65 @@ +page = $values['page'] ?? null; + $this->perPage = $values['perPage'] ?? null; + } + + /** + * @return ?int + */ + public function getPage(): ?int + { + return $this->page; + } + + /** + * @param ?int $value + */ + public function setPage(?int $value = null): self + { + $this->page = $value; + return $this; + } + + /** + * @return ?int + */ + public function getPerPage(): ?int + { + return $this->perPage; + } + + /** + * @param ?int $value + */ + public function setPerPage(?int $value = null): self + { + $this->perPage = $value; + return $this; + } +} diff --git a/src/Calls/Requests/ListCallsWithTranscriptsRequest.php b/src/Calls/Requests/ListCallsWithTranscriptsRequest.php new file mode 100644 index 0000000..b6b3786 --- /dev/null +++ b/src/Calls/Requests/ListCallsWithTranscriptsRequest.php @@ -0,0 +1,44 @@ + $conversationIds A list of conversation ids to fetch calls for. Maximum 20. + */ + #[JsonProperty('conversation_ids'), ArrayType(['string'])] + private array $conversationIds; + + /** + * @param array{ + * conversationIds: array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->conversationIds = $values['conversationIds']; + } + + /** + * @return array + */ + public function getConversationIds(): array + { + return $this->conversationIds; + } + + /** + * @param array $value + */ + public function setConversationIds(array $value): self + { + $this->conversationIds = $value; + return $this; + } +} diff --git a/src/Calls/Requests/ShowCallRecordingRequest.php b/src/Calls/Requests/ShowCallRecordingRequest.php new file mode 100644 index 0000000..b4a66ba --- /dev/null +++ b/src/Calls/Requests/ShowCallRecordingRequest.php @@ -0,0 +1,41 @@ +callId = $values['callId']; + } + + /** + * @return string + */ + public function getCallId(): string + { + return $this->callId; + } + + /** + * @param string $value + */ + public function setCallId(string $value): self + { + $this->callId = $value; + return $this; + } +} diff --git a/src/Calls/Requests/ShowCallRequest.php b/src/Calls/Requests/ShowCallRequest.php new file mode 100644 index 0000000..36756bd --- /dev/null +++ b/src/Calls/Requests/ShowCallRequest.php @@ -0,0 +1,41 @@ +callId = $values['callId']; + } + + /** + * @return string + */ + public function getCallId(): string + { + return $this->callId; + } + + /** + * @param string $value + */ + public function setCallId(string $value): self + { + $this->callId = $value; + return $this; + } +} diff --git a/src/Calls/Requests/ShowCallTranscriptRequest.php b/src/Calls/Requests/ShowCallTranscriptRequest.php new file mode 100644 index 0000000..3d35445 --- /dev/null +++ b/src/Calls/Requests/ShowCallTranscriptRequest.php @@ -0,0 +1,41 @@ +callId = $values['callId']; + } + + /** + * @return string + */ + public function getCallId(): string + { + return $this->callId; + } + + /** + * @param string $value + */ + public function setCallId(string $value): self + { + $this->callId = $value; + return $this; + } +} diff --git a/src/Calls/Traits/Call.php b/src/Calls/Traits/Call.php new file mode 100644 index 0000000..4643d07 --- /dev/null +++ b/src/Calls/Traits/Call.php @@ -0,0 +1,506 @@ +type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getConversationId(): ?string + { + return $this->conversationId; + } + + /** + * @param ?string $value + */ + public function setConversationId(?string $value = null): self + { + $this->conversationId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getAdminId(): ?string + { + return $this->adminId; + } + + /** + * @param ?string $value + */ + public function setAdminId(?string $value = null): self + { + $this->adminId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getContactId(): ?string + { + return $this->contactId; + } + + /** + * @param ?string $value + */ + public function setContactId(?string $value = null): self + { + $this->contactId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getState(): ?string + { + return $this->state; + } + + /** + * @param ?string $value + */ + public function setState(?string $value = null): self + { + $this->state = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getInitiatedAt(): DateTime|int|null + { + return $this->initiatedAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setInitiatedAt(DateTime|int|null $value = null): self + { + $this->initiatedAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getAnsweredAt(): DateTime|int|null + { + return $this->answeredAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setAnsweredAt(DateTime|int|null $value = null): self + { + $this->answeredAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getEndedAt(): DateTime|int|null + { + return $this->endedAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setEndedAt(DateTime|int|null $value = null): self + { + $this->endedAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getCreatedAt(): DateTime|int|null + { + return $this->createdAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setCreatedAt(DateTime|int|null $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getUpdatedAt(): DateTime|int|null + { + return $this->updatedAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setUpdatedAt(DateTime|int|null $value = null): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return ?string + */ + public function getRecordingUrl(): ?string + { + return $this->recordingUrl; + } + + /** + * @param ?string $value + */ + public function setRecordingUrl(?string $value = null): self + { + $this->recordingUrl = $value; + return $this; + } + + /** + * @return ?string + */ + public function getCallType(): ?string + { + return $this->callType; + } + + /** + * @param ?string $value + */ + public function setCallType(?string $value = null): self + { + $this->callType = $value; + return $this; + } + + /** + * @return ?string + */ + public function getDirection(): ?string + { + return $this->direction; + } + + /** + * @param ?string $value + */ + public function setDirection(?string $value = null): self + { + $this->direction = $value; + return $this; + } + + /** + * @return ?string + */ + public function getEndedReason(): ?string + { + return $this->endedReason; + } + + /** + * @param ?string $value + */ + public function setEndedReason(?string $value = null): self + { + $this->endedReason = $value; + return $this; + } + + /** + * @return ?string + */ + public function getPhone(): ?string + { + return $this->phone; + } + + /** + * @param ?string $value + */ + public function setPhone(?string $value = null): self + { + $this->phone = $value; + return $this; + } + + /** + * @return ?string + */ + public function getFinRecordingUrl(): ?string + { + return $this->finRecordingUrl; + } + + /** + * @param ?string $value + */ + public function setFinRecordingUrl(?string $value = null): self + { + $this->finRecordingUrl = $value; + return $this; + } + + /** + * @return ?string + */ + public function getFinTranscriptionUrl(): ?string + { + return $this->finTranscriptionUrl; + } + + /** + * @param ?string $value + */ + public function setFinTranscriptionUrl(?string $value = null): self + { + $this->finTranscriptionUrl = $value; + return $this; + } +} diff --git a/src/Calls/Types/Call.php b/src/Calls/Types/Call.php new file mode 100644 index 0000000..d403fd0 --- /dev/null +++ b/src/Calls/Types/Call.php @@ -0,0 +1,541 @@ +type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->conversationId = $values['conversationId'] ?? null; + $this->adminId = $values['adminId'] ?? null; + $this->contactId = $values['contactId'] ?? null; + $this->state = $values['state'] ?? null; + $this->initiatedAt = $values['initiatedAt'] ?? null; + $this->answeredAt = $values['answeredAt'] ?? null; + $this->endedAt = $values['endedAt'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->recordingUrl = $values['recordingUrl'] ?? null; + $this->callType = $values['callType'] ?? null; + $this->direction = $values['direction'] ?? null; + $this->endedReason = $values['endedReason'] ?? null; + $this->phone = $values['phone'] ?? null; + $this->finRecordingUrl = $values['finRecordingUrl'] ?? null; + $this->finTranscriptionUrl = $values['finTranscriptionUrl'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getConversationId(): ?string + { + return $this->conversationId; + } + + /** + * @param ?string $value + */ + public function setConversationId(?string $value = null): self + { + $this->conversationId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getAdminId(): ?string + { + return $this->adminId; + } + + /** + * @param ?string $value + */ + public function setAdminId(?string $value = null): self + { + $this->adminId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getContactId(): ?string + { + return $this->contactId; + } + + /** + * @param ?string $value + */ + public function setContactId(?string $value = null): self + { + $this->contactId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getState(): ?string + { + return $this->state; + } + + /** + * @param ?string $value + */ + public function setState(?string $value = null): self + { + $this->state = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getInitiatedAt(): DateTime|int|null + { + return $this->initiatedAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setInitiatedAt(DateTime|int|null $value = null): self + { + $this->initiatedAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getAnsweredAt(): DateTime|int|null + { + return $this->answeredAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setAnsweredAt(DateTime|int|null $value = null): self + { + $this->answeredAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getEndedAt(): DateTime|int|null + { + return $this->endedAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setEndedAt(DateTime|int|null $value = null): self + { + $this->endedAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getCreatedAt(): DateTime|int|null + { + return $this->createdAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setCreatedAt(DateTime|int|null $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getUpdatedAt(): DateTime|int|null + { + return $this->updatedAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setUpdatedAt(DateTime|int|null $value = null): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return ?string + */ + public function getRecordingUrl(): ?string + { + return $this->recordingUrl; + } + + /** + * @param ?string $value + */ + public function setRecordingUrl(?string $value = null): self + { + $this->recordingUrl = $value; + return $this; + } + + /** + * @return ?string + */ + public function getCallType(): ?string + { + return $this->callType; + } + + /** + * @param ?string $value + */ + public function setCallType(?string $value = null): self + { + $this->callType = $value; + return $this; + } + + /** + * @return ?string + */ + public function getDirection(): ?string + { + return $this->direction; + } + + /** + * @param ?string $value + */ + public function setDirection(?string $value = null): self + { + $this->direction = $value; + return $this; + } + + /** + * @return ?string + */ + public function getEndedReason(): ?string + { + return $this->endedReason; + } + + /** + * @param ?string $value + */ + public function setEndedReason(?string $value = null): self + { + $this->endedReason = $value; + return $this; + } + + /** + * @return ?string + */ + public function getPhone(): ?string + { + return $this->phone; + } + + /** + * @param ?string $value + */ + public function setPhone(?string $value = null): self + { + $this->phone = $value; + return $this; + } + + /** + * @return ?string + */ + public function getFinRecordingUrl(): ?string + { + return $this->finRecordingUrl; + } + + /** + * @param ?string $value + */ + public function setFinRecordingUrl(?string $value = null): self + { + $this->finRecordingUrl = $value; + return $this; + } + + /** + * @return ?string + */ + public function getFinTranscriptionUrl(): ?string + { + return $this->finTranscriptionUrl; + } + + /** + * @param ?string $value + */ + public function setFinTranscriptionUrl(?string $value = null): self + { + $this->finTranscriptionUrl = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Calls/Types/ListCallsWithTranscriptsResponse.php b/src/Calls/Types/ListCallsWithTranscriptsResponse.php new file mode 100644 index 0000000..811de6e --- /dev/null +++ b/src/Calls/Types/ListCallsWithTranscriptsResponse.php @@ -0,0 +1,77 @@ + $data + */ + #[JsonProperty('data'), ArrayType([ListCallsWithTranscriptsResponseDataItem::class])] + private ?array $data; + + /** + * @param array{ + * type?: ?string, + * data?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?array + */ + public function getData(): ?array + { + return $this->data; + } + + /** + * @param ?array $value + */ + public function setData(?array $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Calls/Types/ListCallsWithTranscriptsResponseDataItem.php b/src/Calls/Types/ListCallsWithTranscriptsResponseDataItem.php new file mode 100644 index 0000000..151bf97 --- /dev/null +++ b/src/Calls/Types/ListCallsWithTranscriptsResponseDataItem.php @@ -0,0 +1,132 @@ +> $transcript The call transcript if available, otherwise an empty array. + */ + #[JsonProperty('transcript'), ArrayType([['string' => 'mixed']])] + private ?array $transcript; + + /** + * @var ?string $transcriptStatus The status of the transcript if available. + */ + #[JsonProperty('transcript_status')] + private ?string $transcriptStatus; + + /** + * @param array{ + * type?: ?string, + * id?: ?string, + * conversationId?: ?string, + * adminId?: ?string, + * contactId?: ?string, + * state?: ?string, + * initiatedAt?: ( + * DateTime + * |int + * )|null, + * answeredAt?: ( + * DateTime + * |int + * )|null, + * endedAt?: ( + * DateTime + * |int + * )|null, + * createdAt?: ( + * DateTime + * |int + * )|null, + * updatedAt?: ( + * DateTime + * |int + * )|null, + * recordingUrl?: ?string, + * callType?: ?string, + * direction?: ?string, + * endedReason?: ?string, + * phone?: ?string, + * finRecordingUrl?: ?string, + * finTranscriptionUrl?: ?string, + * transcript?: ?array>, + * transcriptStatus?: ?string, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->conversationId = $values['conversationId'] ?? null; + $this->adminId = $values['adminId'] ?? null; + $this->contactId = $values['contactId'] ?? null; + $this->state = $values['state'] ?? null; + $this->initiatedAt = $values['initiatedAt'] ?? null; + $this->answeredAt = $values['answeredAt'] ?? null; + $this->endedAt = $values['endedAt'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->recordingUrl = $values['recordingUrl'] ?? null; + $this->callType = $values['callType'] ?? null; + $this->direction = $values['direction'] ?? null; + $this->endedReason = $values['endedReason'] ?? null; + $this->phone = $values['phone'] ?? null; + $this->finRecordingUrl = $values['finRecordingUrl'] ?? null; + $this->finTranscriptionUrl = $values['finTranscriptionUrl'] ?? null; + $this->transcript = $values['transcript'] ?? null; + $this->transcriptStatus = $values['transcriptStatus'] ?? null; + } + + /** + * @return ?array> + */ + public function getTranscript(): ?array + { + return $this->transcript; + } + + /** + * @param ?array> $value + */ + public function setTranscript(?array $value = null): self + { + $this->transcript = $value; + return $this; + } + + /** + * @return ?string + */ + public function getTranscriptStatus(): ?string + { + return $this->transcriptStatus; + } + + /** + * @param ?string $value + */ + public function setTranscriptStatus(?string $value = null): self + { + $this->transcriptStatus = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Companies/CompaniesClient.php b/src/Companies/CompaniesClient.php index e28bf0a..9467d78 100644 --- a/src/Companies/CompaniesClient.php +++ b/src/Companies/CompaniesClient.php @@ -14,7 +14,7 @@ use JsonException; use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; -use Intercom\Companies\Requests\CreateOrUpdateCompanyRequest; +use Intercom\Types\CreateOrUpdateCompanyRequest; use Intercom\Companies\Types\Company; use Intercom\Companies\Requests\FindCompanyRequest; use Intercom\Companies\Requests\UpdateCompanyRequest; @@ -166,7 +166,7 @@ public function retrieve(RetrieveCompanyRequest $request = new RetrieveCompanyRe * You can set a unique `company_id` value when creating a company. However, it is not possible to update `company_id`. Be sure to set a unique value once upon creation of the company. * {% /admonition %} * - * @param CreateOrUpdateCompanyRequest $request + * @param ?CreateOrUpdateCompanyRequest $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -179,7 +179,7 @@ public function retrieve(RetrieveCompanyRequest $request = new RetrieveCompanyRe * @throws IntercomException * @throws IntercomApiException */ - public function createOrUpdate(CreateOrUpdateCompanyRequest $request = new CreateOrUpdateCompanyRequest(), ?array $options = null): Company + public function createOrUpdate(?CreateOrUpdateCompanyRequest $request = null, ?array $options = null): Company { $options = array_merge($this->options, $options ?? []); try { @@ -407,20 +407,12 @@ public function delete(DeleteCompanyRequest $request, ?array $options = null): D public function listAttachedContacts(ListAttachedContactsRequest $request, ?array $options = null): CompanyAttachedContacts { $options = array_merge($this->options, $options ?? []); - $query = []; - if ($request->getPage() != null) { - $query['page'] = $request->getPage(); - } - if ($request->getPerPage() != null) { - $query['per_page'] = $request->getPerPage(); - } try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, path: "companies/{$request->getCompanyId()}/contacts", method: HttpMethod::GET, - query: $query, ), $options, ); @@ -583,9 +575,9 @@ public function scroll(ScrollCompaniesRequest $request = new ScrollCompaniesRequ $request->setScrollParam($cursor); }, /* @phpstan-ignore-next-line */ - getNextCursor: fn (CompanyScroll $response) => $response?->getScrollParam() ?? null, + getNextCursor: fn (?CompanyScroll $response) => $response?->getScrollParam() ?? null, /* @phpstan-ignore-next-line */ - getItems: fn (CompanyScroll $response) => $response?->getData() ?? [], + getItems: fn (?CompanyScroll $response) => $response?->getData() ?? [], ); } @@ -800,11 +792,11 @@ private function _list(ListCompaniesRequest $request = new ListCompaniesRequest( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return CompanyScroll + * @return ?CompanyScroll * @throws IntercomException * @throws IntercomApiException */ - private function _scroll(ScrollCompaniesRequest $request = new ScrollCompaniesRequest(), ?array $options = null): CompanyScroll + private function _scroll(ScrollCompaniesRequest $request = new ScrollCompaniesRequest(), ?array $options = null): ?CompanyScroll { $options = array_merge($this->options, $options ?? []); $query = []; @@ -824,6 +816,9 @@ private function _scroll(ScrollCompaniesRequest $request = new ScrollCompaniesRe $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return CompanyScroll::fromJson($json); } } catch (JsonException $e) { diff --git a/src/Companies/Requests/AttachContactToCompanyRequest.php b/src/Companies/Requests/AttachContactToCompanyRequest.php index 974fb13..903a510 100644 --- a/src/Companies/Requests/AttachContactToCompanyRequest.php +++ b/src/Companies/Requests/AttachContactToCompanyRequest.php @@ -8,9 +8,9 @@ class AttachContactToCompanyRequest extends JsonSerializableType { /** - * @var string $contactId The unique identifier for the contact which is given by Intercom + * @var int $contactId The unique identifier for the contact which is given by Intercom */ - private string $contactId; + private int $contactId; /** * @var string $companyId The unique identifier for the company which is given by Intercom @@ -20,7 +20,7 @@ class AttachContactToCompanyRequest extends JsonSerializableType /** * @param array{ - * contactId: string, + * contactId: int, * companyId: string, * } $values */ @@ -32,17 +32,17 @@ public function __construct( } /** - * @return string + * @return int */ - public function getContactId(): string + public function getContactId(): int { return $this->contactId; } /** - * @param string $value + * @param int $value */ - public function setContactId(string $value): self + public function setContactId(int $value): self { $this->contactId = $value; return $this; diff --git a/src/Companies/Requests/ListAttachedContactsRequest.php b/src/Companies/Requests/ListAttachedContactsRequest.php index edcc04f..c10f4d5 100644 --- a/src/Companies/Requests/ListAttachedContactsRequest.php +++ b/src/Companies/Requests/ListAttachedContactsRequest.php @@ -11,29 +11,15 @@ class ListAttachedContactsRequest extends JsonSerializableType */ private string $companyId; - /** - * @var ?int $page The page of results to fetch. Defaults to first page - */ - private ?int $page; - - /** - * @var ?int $perPage How many results to return per page. Defaults to 15 - */ - private ?int $perPage; - /** * @param array{ * companyId: string, - * page?: ?int, - * perPage?: ?int, * } $values */ public function __construct( array $values, ) { $this->companyId = $values['companyId']; - $this->page = $values['page'] ?? null; - $this->perPage = $values['perPage'] ?? null; } /** @@ -52,38 +38,4 @@ public function setCompanyId(string $value): self $this->companyId = $value; return $this; } - - /** - * @return ?int - */ - public function getPage(): ?int - { - return $this->page; - } - - /** - * @param ?int $value - */ - public function setPage(?int $value = null): self - { - $this->page = $value; - return $this; - } - - /** - * @return ?int - */ - public function getPerPage(): ?int - { - return $this->perPage; - } - - /** - * @param ?int $value - */ - public function setPerPage(?int $value = null): self - { - $this->perPage = $value; - return $this; - } } diff --git a/src/Companies/Types/CompanyPlan.php b/src/Companies/Types/CompanyPlan.php index 5e4a0a8..af27360 100644 --- a/src/Companies/Types/CompanyPlan.php +++ b/src/Companies/Types/CompanyPlan.php @@ -8,7 +8,7 @@ class CompanyPlan extends JsonSerializableType { /** - * @var ?'plan' $type Value is always "plan" + * @var ?string $type Value is always "plan" */ #[JsonProperty('type')] private ?string $type; @@ -27,7 +27,7 @@ class CompanyPlan extends JsonSerializableType /** * @param array{ - * type?: ?'plan', + * type?: ?string, * id?: ?string, * name?: ?string, * } $values @@ -41,7 +41,7 @@ public function __construct( } /** - * @return ?'plan' + * @return ?string */ public function getType(): ?string { @@ -49,7 +49,7 @@ public function getType(): ?string } /** - * @param ?'plan' $value + * @param ?string $value */ public function setType(?string $value = null): self { diff --git a/src/Contacts/ContactsClient.php b/src/Contacts/ContactsClient.php index b389651..efc30d8 100644 --- a/src/Contacts/ContactsClient.php +++ b/src/Contacts/ContactsClient.php @@ -27,12 +27,15 @@ use Intercom\Contacts\Requests\ListTagsAttachedToContactRequest; use Intercom\Types\TagList; use Intercom\Contacts\Requests\FindContactRequest; -use Intercom\Contacts\Types\Contact; +use Intercom\Contacts\Types\ContactsFindResponse; use Intercom\Contacts\Requests\UpdateContactRequest; +use Intercom\Contacts\Types\ContactsUpdateResponse; use Intercom\Contacts\Requests\DeleteContactRequest; use Intercom\Types\ContactDeleted; use Intercom\Contacts\Requests\MergeContactsRequest; +use Intercom\Contacts\Types\ContactsMergeLeadInUserResponse; use Intercom\Types\SearchRequest; +use Intercom\Contacts\Types\Contact; use Intercom\Core\Pagination\CursorPager; use Intercom\Core\Pagination\PaginationHelper; use Intercom\Types\ContactList; @@ -40,12 +43,17 @@ use Intercom\Types\CreateContactRequestWithEmail; use Intercom\Types\CreateContactRequestWithExternalId; use Intercom\Types\CreateContactRequestWithRole; +use Intercom\Contacts\Types\ContactsCreateResponse; use Intercom\Core\Json\JsonSerializer; use Intercom\Core\Types\Union; +use Intercom\Contacts\Requests\ShowContactByExternalIdRequest; +use Intercom\Contacts\Types\ShowContactByExternalIdResponse; use Intercom\Contacts\Requests\ArchiveContactRequest; use Intercom\Types\ContactArchived; use Intercom\Contacts\Requests\UnarchiveContactRequest; use Intercom\Types\ContactUnarchived; +use Intercom\Contacts\Requests\BlockContactRequest; +use Intercom\Types\ContactBlocked; class ContactsClient { @@ -415,11 +423,11 @@ public function listAttachedTags(ListTagsAttachedToContactRequest $request, ?arr * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Contact + * @return ContactsFindResponse * @throws IntercomException * @throws IntercomApiException */ - public function find(FindContactRequest $request, ?array $options = null): Contact + public function find(FindContactRequest $request, ?array $options = null): ContactsFindResponse { $options = array_merge($this->options, $options ?? []); try { @@ -434,7 +442,7 @@ public function find(FindContactRequest $request, ?array $options = null): Conta $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); - return Contact::fromJson($json); + return ContactsFindResponse::fromJson($json); } } catch (JsonException $e) { throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); @@ -461,6 +469,12 @@ public function find(FindContactRequest $request, ?array $options = null): Conta /** * You can update an existing contact (ie. user or lead). * + * {% admonition type="info" %} + * This endpoint handles both **contact updates** and **custom object associations**. + * + * See _`update a contact with an association to a custom object instance`_ in the request/response examples to see the custom object association format. + * {% /admonition %} + * * @param UpdateContactRequest $request * @param ?array{ * baseUrl?: string, @@ -470,11 +484,11 @@ public function find(FindContactRequest $request, ?array $options = null): Conta * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Contact + * @return ContactsUpdateResponse * @throws IntercomException * @throws IntercomApiException */ - public function update(UpdateContactRequest $request, ?array $options = null): Contact + public function update(UpdateContactRequest $request, ?array $options = null): ContactsUpdateResponse { $options = array_merge($this->options, $options ?? []); try { @@ -490,7 +504,7 @@ public function update(UpdateContactRequest $request, ?array $options = null): C $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); - return Contact::fromJson($json); + return ContactsUpdateResponse::fromJson($json); } } catch (JsonException $e) { throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); @@ -581,11 +595,11 @@ public function delete(DeleteContactRequest $request, ?array $options = null): C * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Contact + * @return ContactsMergeLeadInUserResponse * @throws IntercomException * @throws IntercomApiException */ - public function mergeLeadInUser(MergeContactsRequest $request, ?array $options = null): Contact + public function mergeLeadInUser(MergeContactsRequest $request = new MergeContactsRequest(), ?array $options = null): ContactsMergeLeadInUserResponse { $options = array_merge($this->options, $options ?? []); try { @@ -601,7 +615,7 @@ public function mergeLeadInUser(MergeContactsRequest $request, ?array $options = $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); - return Contact::fromJson($json); + return ContactsMergeLeadInUserResponse::fromJson($json); } } catch (JsonException $e) { throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); @@ -801,11 +815,11 @@ public function list(ListContactsRequest $request = new ListContactsRequest(), ? * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Contact + * @return ContactsCreateResponse * @throws IntercomException * @throws IntercomApiException */ - public function create(CreateContactRequestWithEmail|CreateContactRequestWithExternalId|CreateContactRequestWithRole $request, ?array $options = null): Contact + public function create(CreateContactRequestWithEmail|CreateContactRequestWithExternalId|CreateContactRequestWithRole $request, ?array $options = null): ContactsCreateResponse { $options = array_merge($this->options, $options ?? []); try { @@ -821,7 +835,62 @@ public function create(CreateContactRequestWithEmail|CreateContactRequestWithExt $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); - return Contact::fromJson($json); + return ContactsCreateResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. + * + * @param ShowContactByExternalIdRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ShowContactByExternalIdResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function showContactByExternalId(ShowContactByExternalIdRequest $request, ?array $options = null): ShowContactByExternalIdResponse + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "contacts/find_by_external_id/{$request->getExternalId()}", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ShowContactByExternalIdResponse::fromJson($json); } } catch (JsonException $e) { throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); @@ -955,6 +1024,61 @@ public function unarchive(UnarchiveContactRequest $request, ?array $options = nu ); } + /** + * Block a single contact.
**Note:** conversations of the contact will also be archived during the process.
More details in [FAQ How do I block Inbox spam?](https://www.intercom.com/help/en/articles/8838656-inbox-faqs) + * + * @param BlockContactRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ContactBlocked + * @throws IntercomException + * @throws IntercomApiException + */ + public function blockContact(BlockContactRequest $request, ?array $options = null): ContactBlocked + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "contacts/{$request->getContactId()}/block", + method: HttpMethod::POST, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ContactBlocked::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + /** * You can fetch a list of companies that are associated to a contact. * diff --git a/src/Contacts/Requests/ArchiveContactRequest.php b/src/Contacts/Requests/ArchiveContactRequest.php index ba17d66..33e0383 100644 --- a/src/Contacts/Requests/ArchiveContactRequest.php +++ b/src/Contacts/Requests/ArchiveContactRequest.php @@ -7,7 +7,7 @@ class ArchiveContactRequest extends JsonSerializableType { /** - * @var string $contactId id + * @var string $contactId contact_id */ private string $contactId; diff --git a/src/Contacts/Requests/BlockContactRequest.php b/src/Contacts/Requests/BlockContactRequest.php new file mode 100644 index 0000000..97efed0 --- /dev/null +++ b/src/Contacts/Requests/BlockContactRequest.php @@ -0,0 +1,41 @@ +contactId = $values['contactId']; + } + + /** + * @return string + */ + public function getContactId(): string + { + return $this->contactId; + } + + /** + * @param string $value + */ + public function setContactId(string $value): self + { + $this->contactId = $value; + return $this; + } +} diff --git a/src/Contacts/Requests/DeleteContactRequest.php b/src/Contacts/Requests/DeleteContactRequest.php index d8e5171..bd7f7ad 100644 --- a/src/Contacts/Requests/DeleteContactRequest.php +++ b/src/Contacts/Requests/DeleteContactRequest.php @@ -7,7 +7,7 @@ class DeleteContactRequest extends JsonSerializableType { /** - * @var string $contactId id + * @var string $contactId contact_id */ private string $contactId; diff --git a/src/Contacts/Requests/FindContactRequest.php b/src/Contacts/Requests/FindContactRequest.php index 3383919..59294ed 100644 --- a/src/Contacts/Requests/FindContactRequest.php +++ b/src/Contacts/Requests/FindContactRequest.php @@ -7,7 +7,7 @@ class FindContactRequest extends JsonSerializableType { /** - * @var string $contactId id + * @var string $contactId contact_id */ private string $contactId; diff --git a/src/Contacts/Requests/MergeContactsRequest.php b/src/Contacts/Requests/MergeContactsRequest.php index cb58677..785c3f9 100644 --- a/src/Contacts/Requests/MergeContactsRequest.php +++ b/src/Contacts/Requests/MergeContactsRequest.php @@ -8,59 +8,59 @@ class MergeContactsRequest extends JsonSerializableType { /** - * @var string $leadId The unique identifier for the contact to merge away from. Must be a lead. + * @var ?string $leadId The unique identifier for the contact to merge away from. Must be a lead. */ #[JsonProperty('from')] - private string $leadId; + private ?string $leadId; /** - * @var string $contactId The unique identifier for the contact to merge into. Must be a user. + * @var ?string $contactId The unique identifier for the contact to merge into. Must be a user. */ #[JsonProperty('into')] - private string $contactId; + private ?string $contactId; /** * @param array{ - * leadId: string, - * contactId: string, + * leadId?: ?string, + * contactId?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->leadId = $values['leadId']; - $this->contactId = $values['contactId']; + $this->leadId = $values['leadId'] ?? null; + $this->contactId = $values['contactId'] ?? null; } /** - * @return string + * @return ?string */ - public function getLeadId(): string + public function getLeadId(): ?string { return $this->leadId; } /** - * @param string $value + * @param ?string $value */ - public function setLeadId(string $value): self + public function setLeadId(?string $value = null): self { $this->leadId = $value; return $this; } /** - * @return string + * @return ?string */ - public function getContactId(): string + public function getContactId(): ?string { return $this->contactId; } /** - * @param string $value + * @param ?string $value */ - public function setContactId(string $value): self + public function setContactId(?string $value = null): self { $this->contactId = $value; return $this; diff --git a/src/Contacts/Requests/ShowContactByExternalIdRequest.php b/src/Contacts/Requests/ShowContactByExternalIdRequest.php new file mode 100644 index 0000000..4a367e7 --- /dev/null +++ b/src/Contacts/Requests/ShowContactByExternalIdRequest.php @@ -0,0 +1,41 @@ +externalId = $values['externalId']; + } + + /** + * @return string + */ + public function getExternalId(): string + { + return $this->externalId; + } + + /** + * @param string $value + */ + public function setExternalId(string $value): self + { + $this->externalId = $value; + return $this; + } +} diff --git a/src/Contacts/Requests/UnarchiveContactRequest.php b/src/Contacts/Requests/UnarchiveContactRequest.php index 4e5da9c..aaf4f5e 100644 --- a/src/Contacts/Requests/UnarchiveContactRequest.php +++ b/src/Contacts/Requests/UnarchiveContactRequest.php @@ -7,7 +7,7 @@ class UnarchiveContactRequest extends JsonSerializableType { /** - * @var string $contactId id + * @var string $contactId contact_id */ private string $contactId; diff --git a/src/Contacts/Traits/Contact.php b/src/Contacts/Traits/Contact.php new file mode 100644 index 0000000..068664e --- /dev/null +++ b/src/Contacts/Traits/Contact.php @@ -0,0 +1,1098 @@ + $customAttributes + * @property ?string $avatar + * @property ?ContactTags $tags + * @property ?ContactNotes $notes + * @property ?ContactCompanies $companies + * @property ?ContactLocation $location + * @property ?ContactSocialProfiles $socialProfiles + */ +trait Contact +{ + /** + * @var ?'contact' $type The type of object. + */ + #[JsonProperty('type')] + private ?string $type; + + /** + * @var ?string $id The unique identifier for the contact which is given by Intercom. + */ + #[JsonProperty('id')] + private ?string $id; + + /** + * @var ?string $externalId The unique identifier for the contact which is provided by the Client. + */ + #[JsonProperty('external_id')] + private ?string $externalId; + + /** + * @var ?string $workspaceId The id of the workspace which the contact belongs to. + */ + #[JsonProperty('workspace_id')] + private ?string $workspaceId; + + /** + * @var ?string $role The role of the contact. + */ + #[JsonProperty('role')] + private ?string $role; + + /** + * @var ?string $email The contact's email. + */ + #[JsonProperty('email')] + private ?string $email; + + /** + * @var ?string $emailDomain The contact's email domain. + */ + #[JsonProperty('email_domain')] + private ?string $emailDomain; + + /** + * @var ?string $phone The contacts phone. + */ + #[JsonProperty('phone')] + private ?string $phone; + + /** + * @var ?string $name The contacts name. + */ + #[JsonProperty('name')] + private ?string $name; + + /** + * @var ?int $ownerId The id of an admin that has been assigned account ownership of the contact. + */ + #[JsonProperty('owner_id')] + private ?int $ownerId; + + /** + * @var ?bool $hasHardBounced Whether the contact has had an email sent to them hard bounce. + */ + #[JsonProperty('has_hard_bounced')] + private ?bool $hasHardBounced; + + /** + * @var ?bool $markedEmailAsSpam Whether the contact has marked an email sent to them as spam. + */ + #[JsonProperty('marked_email_as_spam')] + private ?bool $markedEmailAsSpam; + + /** + * @var ?bool $unsubscribedFromEmails Whether the contact is unsubscribed from emails. + */ + #[JsonProperty('unsubscribed_from_emails')] + private ?bool $unsubscribedFromEmails; + + /** + * @var ?int $createdAt (UNIX timestamp) The time when the contact was created. + */ + #[JsonProperty('created_at')] + private ?int $createdAt; + + /** + * @var ?int $updatedAt (UNIX timestamp) The time when the contact was last updated. + */ + #[JsonProperty('updated_at')] + private ?int $updatedAt; + + /** + * @var ?int $signedUpAt (UNIX timestamp) The time specified for when a contact signed up. + */ + #[JsonProperty('signed_up_at')] + private ?int $signedUpAt; + + /** + * @var ?int $lastSeenAt (UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually). + */ + #[JsonProperty('last_seen_at')] + private ?int $lastSeenAt; + + /** + * @var ?int $lastRepliedAt (UNIX timestamp) The time when the contact last messaged in. + */ + #[JsonProperty('last_replied_at')] + private ?int $lastRepliedAt; + + /** + * @var ?int $lastContactedAt (UNIX timestamp) The time when the contact was last messaged. + */ + #[JsonProperty('last_contacted_at')] + private ?int $lastContactedAt; + + /** + * @var ?int $lastEmailOpenedAt (UNIX timestamp) The time when the contact last opened an email. + */ + #[JsonProperty('last_email_opened_at')] + private ?int $lastEmailOpenedAt; + + /** + * @var ?int $lastEmailClickedAt (UNIX timestamp) The time when the contact last clicked a link in an email. + */ + #[JsonProperty('last_email_clicked_at')] + private ?int $lastEmailClickedAt; + + /** + * @var ?string $languageOverride A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change. + */ + #[JsonProperty('language_override')] + private ?string $languageOverride; + + /** + * @var ?string $browser The name of the browser which the contact is using. + */ + #[JsonProperty('browser')] + private ?string $browser; + + /** + * @var ?string $browserVersion The version of the browser which the contact is using. + */ + #[JsonProperty('browser_version')] + private ?string $browserVersion; + + /** + * @var ?string $browserLanguage The language set by the browser which the contact is using. + */ + #[JsonProperty('browser_language')] + private ?string $browserLanguage; + + /** + * @var ?string $os The operating system which the contact is using. + */ + #[JsonProperty('os')] + private ?string $os; + + /** + * @var ?string $androidAppName The name of the Android app which the contact is using. + */ + #[JsonProperty('android_app_name')] + private ?string $androidAppName; + + /** + * @var ?string $androidAppVersion The version of the Android app which the contact is using. + */ + #[JsonProperty('android_app_version')] + private ?string $androidAppVersion; + + /** + * @var ?string $androidDevice The Android device which the contact is using. + */ + #[JsonProperty('android_device')] + private ?string $androidDevice; + + /** + * @var ?string $androidOsVersion The version of the Android OS which the contact is using. + */ + #[JsonProperty('android_os_version')] + private ?string $androidOsVersion; + + /** + * @var ?string $androidSdkVersion The version of the Android SDK which the contact is using. + */ + #[JsonProperty('android_sdk_version')] + private ?string $androidSdkVersion; + + /** + * @var ?int $androidLastSeenAt (UNIX timestamp) The time when the contact was last seen on an Android device. + */ + #[JsonProperty('android_last_seen_at')] + private ?int $androidLastSeenAt; + + /** + * @var ?string $iosAppName The name of the iOS app which the contact is using. + */ + #[JsonProperty('ios_app_name')] + private ?string $iosAppName; + + /** + * @var ?string $iosAppVersion The version of the iOS app which the contact is using. + */ + #[JsonProperty('ios_app_version')] + private ?string $iosAppVersion; + + /** + * @var ?string $iosDevice The iOS device which the contact is using. + */ + #[JsonProperty('ios_device')] + private ?string $iosDevice; + + /** + * @var ?string $iosOsVersion The version of iOS which the contact is using. + */ + #[JsonProperty('ios_os_version')] + private ?string $iosOsVersion; + + /** + * @var ?string $iosSdkVersion The version of the iOS SDK which the contact is using. + */ + #[JsonProperty('ios_sdk_version')] + private ?string $iosSdkVersion; + + /** + * @var ?int $iosLastSeenAt (UNIX timestamp) The last time the contact used the iOS app. + */ + #[JsonProperty('ios_last_seen_at')] + private ?int $iosLastSeenAt; + + /** + * @var ?array $customAttributes The custom attributes which are set for the contact. + */ + #[JsonProperty('custom_attributes'), ArrayType(['string' => 'mixed'])] + private ?array $customAttributes; + + /** + * @var ?string $avatar An image URL containing the avatar of a contact. + */ + #[JsonProperty('avatar')] + private ?string $avatar; + + /** + * @var ?ContactTags $tags + */ + #[JsonProperty('tags')] + private ?ContactTags $tags; + + /** + * @var ?ContactNotes $notes + */ + #[JsonProperty('notes')] + private ?ContactNotes $notes; + + /** + * @var ?ContactCompanies $companies + */ + #[JsonProperty('companies')] + private ?ContactCompanies $companies; + + /** + * @var ?ContactLocation $location + */ + #[JsonProperty('location')] + private ?ContactLocation $location; + + /** + * @var ?ContactSocialProfiles $socialProfiles + */ + #[JsonProperty('social_profiles')] + private ?ContactSocialProfiles $socialProfiles; + + /** + * @return ?'contact' + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?'contact' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getExternalId(): ?string + { + return $this->externalId; + } + + /** + * @param ?string $value + */ + public function setExternalId(?string $value = null): self + { + $this->externalId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getWorkspaceId(): ?string + { + return $this->workspaceId; + } + + /** + * @param ?string $value + */ + public function setWorkspaceId(?string $value = null): self + { + $this->workspaceId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getRole(): ?string + { + return $this->role; + } + + /** + * @param ?string $value + */ + public function setRole(?string $value = null): self + { + $this->role = $value; + return $this; + } + + /** + * @return ?string + */ + public function getEmail(): ?string + { + return $this->email; + } + + /** + * @param ?string $value + */ + public function setEmail(?string $value = null): self + { + $this->email = $value; + return $this; + } + + /** + * @return ?string + */ + public function getEmailDomain(): ?string + { + return $this->emailDomain; + } + + /** + * @param ?string $value + */ + public function setEmailDomain(?string $value = null): self + { + $this->emailDomain = $value; + return $this; + } + + /** + * @return ?string + */ + public function getPhone(): ?string + { + return $this->phone; + } + + /** + * @param ?string $value + */ + public function setPhone(?string $value = null): self + { + $this->phone = $value; + return $this; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return ?int + */ + public function getOwnerId(): ?int + { + return $this->ownerId; + } + + /** + * @param ?int $value + */ + public function setOwnerId(?int $value = null): self + { + $this->ownerId = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getHasHardBounced(): ?bool + { + return $this->hasHardBounced; + } + + /** + * @param ?bool $value + */ + public function setHasHardBounced(?bool $value = null): self + { + $this->hasHardBounced = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getMarkedEmailAsSpam(): ?bool + { + return $this->markedEmailAsSpam; + } + + /** + * @param ?bool $value + */ + public function setMarkedEmailAsSpam(?bool $value = null): self + { + $this->markedEmailAsSpam = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getUnsubscribedFromEmails(): ?bool + { + return $this->unsubscribedFromEmails; + } + + /** + * @param ?bool $value + */ + public function setUnsubscribedFromEmails(?bool $value = null): self + { + $this->unsubscribedFromEmails = $value; + return $this; + } + + /** + * @return ?int + */ + public function getCreatedAt(): ?int + { + return $this->createdAt; + } + + /** + * @param ?int $value + */ + public function setCreatedAt(?int $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getUpdatedAt(): ?int + { + return $this->updatedAt; + } + + /** + * @param ?int $value + */ + public function setUpdatedAt(?int $value = null): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getSignedUpAt(): ?int + { + return $this->signedUpAt; + } + + /** + * @param ?int $value + */ + public function setSignedUpAt(?int $value = null): self + { + $this->signedUpAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getLastSeenAt(): ?int + { + return $this->lastSeenAt; + } + + /** + * @param ?int $value + */ + public function setLastSeenAt(?int $value = null): self + { + $this->lastSeenAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getLastRepliedAt(): ?int + { + return $this->lastRepliedAt; + } + + /** + * @param ?int $value + */ + public function setLastRepliedAt(?int $value = null): self + { + $this->lastRepliedAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getLastContactedAt(): ?int + { + return $this->lastContactedAt; + } + + /** + * @param ?int $value + */ + public function setLastContactedAt(?int $value = null): self + { + $this->lastContactedAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getLastEmailOpenedAt(): ?int + { + return $this->lastEmailOpenedAt; + } + + /** + * @param ?int $value + */ + public function setLastEmailOpenedAt(?int $value = null): self + { + $this->lastEmailOpenedAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getLastEmailClickedAt(): ?int + { + return $this->lastEmailClickedAt; + } + + /** + * @param ?int $value + */ + public function setLastEmailClickedAt(?int $value = null): self + { + $this->lastEmailClickedAt = $value; + return $this; + } + + /** + * @return ?string + */ + public function getLanguageOverride(): ?string + { + return $this->languageOverride; + } + + /** + * @param ?string $value + */ + public function setLanguageOverride(?string $value = null): self + { + $this->languageOverride = $value; + return $this; + } + + /** + * @return ?string + */ + public function getBrowser(): ?string + { + return $this->browser; + } + + /** + * @param ?string $value + */ + public function setBrowser(?string $value = null): self + { + $this->browser = $value; + return $this; + } + + /** + * @return ?string + */ + public function getBrowserVersion(): ?string + { + return $this->browserVersion; + } + + /** + * @param ?string $value + */ + public function setBrowserVersion(?string $value = null): self + { + $this->browserVersion = $value; + return $this; + } + + /** + * @return ?string + */ + public function getBrowserLanguage(): ?string + { + return $this->browserLanguage; + } + + /** + * @param ?string $value + */ + public function setBrowserLanguage(?string $value = null): self + { + $this->browserLanguage = $value; + return $this; + } + + /** + * @return ?string + */ + public function getOs(): ?string + { + return $this->os; + } + + /** + * @param ?string $value + */ + public function setOs(?string $value = null): self + { + $this->os = $value; + return $this; + } + + /** + * @return ?string + */ + public function getAndroidAppName(): ?string + { + return $this->androidAppName; + } + + /** + * @param ?string $value + */ + public function setAndroidAppName(?string $value = null): self + { + $this->androidAppName = $value; + return $this; + } + + /** + * @return ?string + */ + public function getAndroidAppVersion(): ?string + { + return $this->androidAppVersion; + } + + /** + * @param ?string $value + */ + public function setAndroidAppVersion(?string $value = null): self + { + $this->androidAppVersion = $value; + return $this; + } + + /** + * @return ?string + */ + public function getAndroidDevice(): ?string + { + return $this->androidDevice; + } + + /** + * @param ?string $value + */ + public function setAndroidDevice(?string $value = null): self + { + $this->androidDevice = $value; + return $this; + } + + /** + * @return ?string + */ + public function getAndroidOsVersion(): ?string + { + return $this->androidOsVersion; + } + + /** + * @param ?string $value + */ + public function setAndroidOsVersion(?string $value = null): self + { + $this->androidOsVersion = $value; + return $this; + } + + /** + * @return ?string + */ + public function getAndroidSdkVersion(): ?string + { + return $this->androidSdkVersion; + } + + /** + * @param ?string $value + */ + public function setAndroidSdkVersion(?string $value = null): self + { + $this->androidSdkVersion = $value; + return $this; + } + + /** + * @return ?int + */ + public function getAndroidLastSeenAt(): ?int + { + return $this->androidLastSeenAt; + } + + /** + * @param ?int $value + */ + public function setAndroidLastSeenAt(?int $value = null): self + { + $this->androidLastSeenAt = $value; + return $this; + } + + /** + * @return ?string + */ + public function getIosAppName(): ?string + { + return $this->iosAppName; + } + + /** + * @param ?string $value + */ + public function setIosAppName(?string $value = null): self + { + $this->iosAppName = $value; + return $this; + } + + /** + * @return ?string + */ + public function getIosAppVersion(): ?string + { + return $this->iosAppVersion; + } + + /** + * @param ?string $value + */ + public function setIosAppVersion(?string $value = null): self + { + $this->iosAppVersion = $value; + return $this; + } + + /** + * @return ?string + */ + public function getIosDevice(): ?string + { + return $this->iosDevice; + } + + /** + * @param ?string $value + */ + public function setIosDevice(?string $value = null): self + { + $this->iosDevice = $value; + return $this; + } + + /** + * @return ?string + */ + public function getIosOsVersion(): ?string + { + return $this->iosOsVersion; + } + + /** + * @param ?string $value + */ + public function setIosOsVersion(?string $value = null): self + { + $this->iosOsVersion = $value; + return $this; + } + + /** + * @return ?string + */ + public function getIosSdkVersion(): ?string + { + return $this->iosSdkVersion; + } + + /** + * @param ?string $value + */ + public function setIosSdkVersion(?string $value = null): self + { + $this->iosSdkVersion = $value; + return $this; + } + + /** + * @return ?int + */ + public function getIosLastSeenAt(): ?int + { + return $this->iosLastSeenAt; + } + + /** + * @param ?int $value + */ + public function setIosLastSeenAt(?int $value = null): self + { + $this->iosLastSeenAt = $value; + return $this; + } + + /** + * @return ?array + */ + public function getCustomAttributes(): ?array + { + return $this->customAttributes; + } + + /** + * @param ?array $value + */ + public function setCustomAttributes(?array $value = null): self + { + $this->customAttributes = $value; + return $this; + } + + /** + * @return ?string + */ + public function getAvatar(): ?string + { + return $this->avatar; + } + + /** + * @param ?string $value + */ + public function setAvatar(?string $value = null): self + { + $this->avatar = $value; + return $this; + } + + /** + * @return ?ContactTags + */ + public function getTags(): ?ContactTags + { + return $this->tags; + } + + /** + * @param ?ContactTags $value + */ + public function setTags(?ContactTags $value = null): self + { + $this->tags = $value; + return $this; + } + + /** + * @return ?ContactNotes + */ + public function getNotes(): ?ContactNotes + { + return $this->notes; + } + + /** + * @param ?ContactNotes $value + */ + public function setNotes(?ContactNotes $value = null): self + { + $this->notes = $value; + return $this; + } + + /** + * @return ?ContactCompanies + */ + public function getCompanies(): ?ContactCompanies + { + return $this->companies; + } + + /** + * @param ?ContactCompanies $value + */ + public function setCompanies(?ContactCompanies $value = null): self + { + $this->companies = $value; + return $this; + } + + /** + * @return ?ContactLocation + */ + public function getLocation(): ?ContactLocation + { + return $this->location; + } + + /** + * @param ?ContactLocation $value + */ + public function setLocation(?ContactLocation $value = null): self + { + $this->location = $value; + return $this; + } + + /** + * @return ?ContactSocialProfiles + */ + public function getSocialProfiles(): ?ContactSocialProfiles + { + return $this->socialProfiles; + } + + /** + * @param ?ContactSocialProfiles $value + */ + public function setSocialProfiles(?ContactSocialProfiles $value = null): self + { + $this->socialProfiles = $value; + return $this; + } +} diff --git a/src/Contacts/Types/Contact.php b/src/Contacts/Types/Contact.php index 22d2496..c16c44f 100644 --- a/src/Contacts/Types/Contact.php +++ b/src/Contacts/Types/Contact.php @@ -12,7 +12,7 @@ use Intercom\Types\ContactSocialProfiles; /** - * Contact are the objects that represent your leads and users in Intercom. + * Contacts represent your leads and users in Intercom. */ class Contact extends JsonSerializableType { @@ -23,10 +23,10 @@ class Contact extends JsonSerializableType private ?string $type; /** - * @var string $id The unique identifier for the contact which is given by Intercom. + * @var ?string $id The unique identifier for the contact which is given by Intercom. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** * @var ?string $externalId The unique identifier for the contact which is provided by the Client. @@ -35,16 +35,16 @@ class Contact extends JsonSerializableType private ?string $externalId; /** - * @var string $workspaceId The id of the workspace which the contact belongs to. + * @var ?string $workspaceId The id of the workspace which the contact belongs to. */ #[JsonProperty('workspace_id')] - private string $workspaceId; + private ?string $workspaceId; /** - * @var string $role The role of the contact. + * @var ?string $role The role of the contact. */ #[JsonProperty('role')] - private string $role; + private ?string $role; /** * @var ?string $email The contact's email. @@ -64,12 +64,6 @@ class Contact extends JsonSerializableType #[JsonProperty('phone')] private ?string $phone; - /** - * @var ?string $formattedPhone The contacts phone number normalized to the E164 format - */ - #[JsonProperty('formatted_phone')] - private ?string $formattedPhone; - /** * @var ?string $name The contacts name. */ @@ -83,34 +77,34 @@ class Contact extends JsonSerializableType private ?int $ownerId; /** - * @var bool $hasHardBounced Whether the contact has had an email sent to them hard bounce. + * @var ?bool $hasHardBounced Whether the contact has had an email sent to them hard bounce. */ #[JsonProperty('has_hard_bounced')] - private bool $hasHardBounced; + private ?bool $hasHardBounced; /** - * @var bool $markedEmailAsSpam Whether the contact has marked an email sent to them as spam. + * @var ?bool $markedEmailAsSpam Whether the contact has marked an email sent to them as spam. */ #[JsonProperty('marked_email_as_spam')] - private bool $markedEmailAsSpam; + private ?bool $markedEmailAsSpam; /** - * @var bool $unsubscribedFromEmails Whether the contact is unsubscribed from emails. + * @var ?bool $unsubscribedFromEmails Whether the contact is unsubscribed from emails. */ #[JsonProperty('unsubscribed_from_emails')] - private bool $unsubscribedFromEmails; + private ?bool $unsubscribedFromEmails; /** - * @var int $createdAt (UNIX timestamp) The time when the contact was created. + * @var ?int $createdAt (UNIX timestamp) The time when the contact was created. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** - * @var int $updatedAt (UNIX timestamp) The time when the contact was last updated. + * @var ?int $updatedAt (UNIX timestamp) The time when the contact was last updated. */ #[JsonProperty('updated_at')] - private int $updatedAt; + private ?int $updatedAt; /** * @var ?int $signedUpAt (UNIX timestamp) The time specified for when a contact signed up. @@ -281,37 +275,34 @@ class Contact extends JsonSerializableType private ?ContactCompanies $companies; /** - * @var ContactLocation $location + * @var ?ContactLocation $location */ #[JsonProperty('location')] - private ContactLocation $location; + private ?ContactLocation $location; /** - * @var ContactSocialProfiles $socialProfiles + * @var ?ContactSocialProfiles $socialProfiles */ #[JsonProperty('social_profiles')] - private ContactSocialProfiles $socialProfiles; + private ?ContactSocialProfiles $socialProfiles; /** * @param array{ - * id: string, - * workspaceId: string, - * role: string, - * hasHardBounced: bool, - * markedEmailAsSpam: bool, - * unsubscribedFromEmails: bool, - * createdAt: int, - * updatedAt: int, - * location: ContactLocation, - * socialProfiles: ContactSocialProfiles, * type?: ?'contact', + * id?: ?string, * externalId?: ?string, + * workspaceId?: ?string, + * role?: ?string, * email?: ?string, * emailDomain?: ?string, * phone?: ?string, - * formattedPhone?: ?string, * name?: ?string, * ownerId?: ?int, + * hasHardBounced?: ?bool, + * markedEmailAsSpam?: ?bool, + * unsubscribedFromEmails?: ?bool, + * createdAt?: ?int, + * updatedAt?: ?int, * signedUpAt?: ?int, * lastSeenAt?: ?int, * lastRepliedAt?: ?int, @@ -340,27 +331,28 @@ class Contact extends JsonSerializableType * tags?: ?ContactTags, * notes?: ?ContactNotes, * companies?: ?ContactCompanies, + * location?: ?ContactLocation, + * socialProfiles?: ?ContactSocialProfiles, * } $values */ public function __construct( - array $values, + array $values = [], ) { $this->type = $values['type'] ?? null; - $this->id = $values['id']; + $this->id = $values['id'] ?? null; $this->externalId = $values['externalId'] ?? null; - $this->workspaceId = $values['workspaceId']; - $this->role = $values['role']; + $this->workspaceId = $values['workspaceId'] ?? null; + $this->role = $values['role'] ?? null; $this->email = $values['email'] ?? null; $this->emailDomain = $values['emailDomain'] ?? null; $this->phone = $values['phone'] ?? null; - $this->formattedPhone = $values['formattedPhone'] ?? null; $this->name = $values['name'] ?? null; $this->ownerId = $values['ownerId'] ?? null; - $this->hasHardBounced = $values['hasHardBounced']; - $this->markedEmailAsSpam = $values['markedEmailAsSpam']; - $this->unsubscribedFromEmails = $values['unsubscribedFromEmails']; - $this->createdAt = $values['createdAt']; - $this->updatedAt = $values['updatedAt']; + $this->hasHardBounced = $values['hasHardBounced'] ?? null; + $this->markedEmailAsSpam = $values['markedEmailAsSpam'] ?? null; + $this->unsubscribedFromEmails = $values['unsubscribedFromEmails'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; $this->signedUpAt = $values['signedUpAt'] ?? null; $this->lastSeenAt = $values['lastSeenAt'] ?? null; $this->lastRepliedAt = $values['lastRepliedAt'] ?? null; @@ -389,8 +381,8 @@ public function __construct( $this->tags = $values['tags'] ?? null; $this->notes = $values['notes'] ?? null; $this->companies = $values['companies'] ?? null; - $this->location = $values['location']; - $this->socialProfiles = $values['socialProfiles']; + $this->location = $values['location'] ?? null; + $this->socialProfiles = $values['socialProfiles'] ?? null; } /** @@ -411,17 +403,17 @@ public function setType(?string $value = null): self } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; @@ -445,34 +437,34 @@ public function setExternalId(?string $value = null): self } /** - * @return string + * @return ?string */ - public function getWorkspaceId(): string + public function getWorkspaceId(): ?string { return $this->workspaceId; } /** - * @param string $value + * @param ?string $value */ - public function setWorkspaceId(string $value): self + public function setWorkspaceId(?string $value = null): self { $this->workspaceId = $value; return $this; } /** - * @return string + * @return ?string */ - public function getRole(): string + public function getRole(): ?string { return $this->role; } /** - * @param string $value + * @param ?string $value */ - public function setRole(string $value): self + public function setRole(?string $value = null): self { $this->role = $value; return $this; @@ -529,23 +521,6 @@ public function setPhone(?string $value = null): self return $this; } - /** - * @return ?string - */ - public function getFormattedPhone(): ?string - { - return $this->formattedPhone; - } - - /** - * @param ?string $value - */ - public function setFormattedPhone(?string $value = null): self - { - $this->formattedPhone = $value; - return $this; - } - /** * @return ?string */ @@ -581,85 +556,85 @@ public function setOwnerId(?int $value = null): self } /** - * @return bool + * @return ?bool */ - public function getHasHardBounced(): bool + public function getHasHardBounced(): ?bool { return $this->hasHardBounced; } /** - * @param bool $value + * @param ?bool $value */ - public function setHasHardBounced(bool $value): self + public function setHasHardBounced(?bool $value = null): self { $this->hasHardBounced = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getMarkedEmailAsSpam(): bool + public function getMarkedEmailAsSpam(): ?bool { return $this->markedEmailAsSpam; } /** - * @param bool $value + * @param ?bool $value */ - public function setMarkedEmailAsSpam(bool $value): self + public function setMarkedEmailAsSpam(?bool $value = null): self { $this->markedEmailAsSpam = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getUnsubscribedFromEmails(): bool + public function getUnsubscribedFromEmails(): ?bool { return $this->unsubscribedFromEmails; } /** - * @param bool $value + * @param ?bool $value */ - public function setUnsubscribedFromEmails(bool $value): self + public function setUnsubscribedFromEmails(?bool $value = null): self { $this->unsubscribedFromEmails = $value; return $this; } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; } /** - * @return int + * @return ?int */ - public function getUpdatedAt(): int + public function getUpdatedAt(): ?int { return $this->updatedAt; } /** - * @param int $value + * @param ?int $value */ - public function setUpdatedAt(int $value): self + public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; return $this; @@ -1142,34 +1117,34 @@ public function setCompanies(?ContactCompanies $value = null): self } /** - * @return ContactLocation + * @return ?ContactLocation */ - public function getLocation(): ContactLocation + public function getLocation(): ?ContactLocation { return $this->location; } /** - * @param ContactLocation $value + * @param ?ContactLocation $value */ - public function setLocation(ContactLocation $value): self + public function setLocation(?ContactLocation $value = null): self { $this->location = $value; return $this; } /** - * @return ContactSocialProfiles + * @return ?ContactSocialProfiles */ - public function getSocialProfiles(): ContactSocialProfiles + public function getSocialProfiles(): ?ContactSocialProfiles { return $this->socialProfiles; } /** - * @param ContactSocialProfiles $value + * @param ?ContactSocialProfiles $value */ - public function setSocialProfiles(ContactSocialProfiles $value): self + public function setSocialProfiles(?ContactSocialProfiles $value = null): self { $this->socialProfiles = $value; return $this; diff --git a/src/Contacts/Types/ContactsCreateResponse.php b/src/Contacts/Types/ContactsCreateResponse.php new file mode 100644 index 0000000..c01ea0b --- /dev/null +++ b/src/Contacts/Types/ContactsCreateResponse.php @@ -0,0 +1,149 @@ +, + * avatar?: ?string, + * tags?: ?ContactTags, + * notes?: ?ContactNotes, + * companies?: ?ContactCompanies, + * location?: ?ContactLocation, + * socialProfiles?: ?ContactSocialProfiles, + * enabledPushMessaging?: ?bool, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->externalId = $values['externalId'] ?? null; + $this->workspaceId = $values['workspaceId'] ?? null; + $this->role = $values['role'] ?? null; + $this->email = $values['email'] ?? null; + $this->emailDomain = $values['emailDomain'] ?? null; + $this->phone = $values['phone'] ?? null; + $this->name = $values['name'] ?? null; + $this->ownerId = $values['ownerId'] ?? null; + $this->hasHardBounced = $values['hasHardBounced'] ?? null; + $this->markedEmailAsSpam = $values['markedEmailAsSpam'] ?? null; + $this->unsubscribedFromEmails = $values['unsubscribedFromEmails'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->signedUpAt = $values['signedUpAt'] ?? null; + $this->lastSeenAt = $values['lastSeenAt'] ?? null; + $this->lastRepliedAt = $values['lastRepliedAt'] ?? null; + $this->lastContactedAt = $values['lastContactedAt'] ?? null; + $this->lastEmailOpenedAt = $values['lastEmailOpenedAt'] ?? null; + $this->lastEmailClickedAt = $values['lastEmailClickedAt'] ?? null; + $this->languageOverride = $values['languageOverride'] ?? null; + $this->browser = $values['browser'] ?? null; + $this->browserVersion = $values['browserVersion'] ?? null; + $this->browserLanguage = $values['browserLanguage'] ?? null; + $this->os = $values['os'] ?? null; + $this->androidAppName = $values['androidAppName'] ?? null; + $this->androidAppVersion = $values['androidAppVersion'] ?? null; + $this->androidDevice = $values['androidDevice'] ?? null; + $this->androidOsVersion = $values['androidOsVersion'] ?? null; + $this->androidSdkVersion = $values['androidSdkVersion'] ?? null; + $this->androidLastSeenAt = $values['androidLastSeenAt'] ?? null; + $this->iosAppName = $values['iosAppName'] ?? null; + $this->iosAppVersion = $values['iosAppVersion'] ?? null; + $this->iosDevice = $values['iosDevice'] ?? null; + $this->iosOsVersion = $values['iosOsVersion'] ?? null; + $this->iosSdkVersion = $values['iosSdkVersion'] ?? null; + $this->iosLastSeenAt = $values['iosLastSeenAt'] ?? null; + $this->customAttributes = $values['customAttributes'] ?? null; + $this->avatar = $values['avatar'] ?? null; + $this->tags = $values['tags'] ?? null; + $this->notes = $values['notes'] ?? null; + $this->companies = $values['companies'] ?? null; + $this->location = $values['location'] ?? null; + $this->socialProfiles = $values['socialProfiles'] ?? null; + $this->enabledPushMessaging = $values['enabledPushMessaging'] ?? null; + } + + /** + * @return ?bool + */ + public function getEnabledPushMessaging(): ?bool + { + return $this->enabledPushMessaging; + } + + /** + * @param ?bool $value + */ + public function setEnabledPushMessaging(?bool $value = null): self + { + $this->enabledPushMessaging = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Contacts/Types/ContactsFindResponse.php b/src/Contacts/Types/ContactsFindResponse.php new file mode 100644 index 0000000..c108e48 --- /dev/null +++ b/src/Contacts/Types/ContactsFindResponse.php @@ -0,0 +1,149 @@ +, + * avatar?: ?string, + * tags?: ?ContactTags, + * notes?: ?ContactNotes, + * companies?: ?ContactCompanies, + * location?: ?ContactLocation, + * socialProfiles?: ?ContactSocialProfiles, + * enabledPushMessaging?: ?bool, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->externalId = $values['externalId'] ?? null; + $this->workspaceId = $values['workspaceId'] ?? null; + $this->role = $values['role'] ?? null; + $this->email = $values['email'] ?? null; + $this->emailDomain = $values['emailDomain'] ?? null; + $this->phone = $values['phone'] ?? null; + $this->name = $values['name'] ?? null; + $this->ownerId = $values['ownerId'] ?? null; + $this->hasHardBounced = $values['hasHardBounced'] ?? null; + $this->markedEmailAsSpam = $values['markedEmailAsSpam'] ?? null; + $this->unsubscribedFromEmails = $values['unsubscribedFromEmails'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->signedUpAt = $values['signedUpAt'] ?? null; + $this->lastSeenAt = $values['lastSeenAt'] ?? null; + $this->lastRepliedAt = $values['lastRepliedAt'] ?? null; + $this->lastContactedAt = $values['lastContactedAt'] ?? null; + $this->lastEmailOpenedAt = $values['lastEmailOpenedAt'] ?? null; + $this->lastEmailClickedAt = $values['lastEmailClickedAt'] ?? null; + $this->languageOverride = $values['languageOverride'] ?? null; + $this->browser = $values['browser'] ?? null; + $this->browserVersion = $values['browserVersion'] ?? null; + $this->browserLanguage = $values['browserLanguage'] ?? null; + $this->os = $values['os'] ?? null; + $this->androidAppName = $values['androidAppName'] ?? null; + $this->androidAppVersion = $values['androidAppVersion'] ?? null; + $this->androidDevice = $values['androidDevice'] ?? null; + $this->androidOsVersion = $values['androidOsVersion'] ?? null; + $this->androidSdkVersion = $values['androidSdkVersion'] ?? null; + $this->androidLastSeenAt = $values['androidLastSeenAt'] ?? null; + $this->iosAppName = $values['iosAppName'] ?? null; + $this->iosAppVersion = $values['iosAppVersion'] ?? null; + $this->iosDevice = $values['iosDevice'] ?? null; + $this->iosOsVersion = $values['iosOsVersion'] ?? null; + $this->iosSdkVersion = $values['iosSdkVersion'] ?? null; + $this->iosLastSeenAt = $values['iosLastSeenAt'] ?? null; + $this->customAttributes = $values['customAttributes'] ?? null; + $this->avatar = $values['avatar'] ?? null; + $this->tags = $values['tags'] ?? null; + $this->notes = $values['notes'] ?? null; + $this->companies = $values['companies'] ?? null; + $this->location = $values['location'] ?? null; + $this->socialProfiles = $values['socialProfiles'] ?? null; + $this->enabledPushMessaging = $values['enabledPushMessaging'] ?? null; + } + + /** + * @return ?bool + */ + public function getEnabledPushMessaging(): ?bool + { + return $this->enabledPushMessaging; + } + + /** + * @param ?bool $value + */ + public function setEnabledPushMessaging(?bool $value = null): self + { + $this->enabledPushMessaging = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Contacts/Types/ContactsMergeLeadInUserResponse.php b/src/Contacts/Types/ContactsMergeLeadInUserResponse.php new file mode 100644 index 0000000..5c68910 --- /dev/null +++ b/src/Contacts/Types/ContactsMergeLeadInUserResponse.php @@ -0,0 +1,149 @@ +, + * avatar?: ?string, + * tags?: ?ContactTags, + * notes?: ?ContactNotes, + * companies?: ?ContactCompanies, + * location?: ?ContactLocation, + * socialProfiles?: ?ContactSocialProfiles, + * enabledPushMessaging?: ?bool, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->externalId = $values['externalId'] ?? null; + $this->workspaceId = $values['workspaceId'] ?? null; + $this->role = $values['role'] ?? null; + $this->email = $values['email'] ?? null; + $this->emailDomain = $values['emailDomain'] ?? null; + $this->phone = $values['phone'] ?? null; + $this->name = $values['name'] ?? null; + $this->ownerId = $values['ownerId'] ?? null; + $this->hasHardBounced = $values['hasHardBounced'] ?? null; + $this->markedEmailAsSpam = $values['markedEmailAsSpam'] ?? null; + $this->unsubscribedFromEmails = $values['unsubscribedFromEmails'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->signedUpAt = $values['signedUpAt'] ?? null; + $this->lastSeenAt = $values['lastSeenAt'] ?? null; + $this->lastRepliedAt = $values['lastRepliedAt'] ?? null; + $this->lastContactedAt = $values['lastContactedAt'] ?? null; + $this->lastEmailOpenedAt = $values['lastEmailOpenedAt'] ?? null; + $this->lastEmailClickedAt = $values['lastEmailClickedAt'] ?? null; + $this->languageOverride = $values['languageOverride'] ?? null; + $this->browser = $values['browser'] ?? null; + $this->browserVersion = $values['browserVersion'] ?? null; + $this->browserLanguage = $values['browserLanguage'] ?? null; + $this->os = $values['os'] ?? null; + $this->androidAppName = $values['androidAppName'] ?? null; + $this->androidAppVersion = $values['androidAppVersion'] ?? null; + $this->androidDevice = $values['androidDevice'] ?? null; + $this->androidOsVersion = $values['androidOsVersion'] ?? null; + $this->androidSdkVersion = $values['androidSdkVersion'] ?? null; + $this->androidLastSeenAt = $values['androidLastSeenAt'] ?? null; + $this->iosAppName = $values['iosAppName'] ?? null; + $this->iosAppVersion = $values['iosAppVersion'] ?? null; + $this->iosDevice = $values['iosDevice'] ?? null; + $this->iosOsVersion = $values['iosOsVersion'] ?? null; + $this->iosSdkVersion = $values['iosSdkVersion'] ?? null; + $this->iosLastSeenAt = $values['iosLastSeenAt'] ?? null; + $this->customAttributes = $values['customAttributes'] ?? null; + $this->avatar = $values['avatar'] ?? null; + $this->tags = $values['tags'] ?? null; + $this->notes = $values['notes'] ?? null; + $this->companies = $values['companies'] ?? null; + $this->location = $values['location'] ?? null; + $this->socialProfiles = $values['socialProfiles'] ?? null; + $this->enabledPushMessaging = $values['enabledPushMessaging'] ?? null; + } + + /** + * @return ?bool + */ + public function getEnabledPushMessaging(): ?bool + { + return $this->enabledPushMessaging; + } + + /** + * @param ?bool $value + */ + public function setEnabledPushMessaging(?bool $value = null): self + { + $this->enabledPushMessaging = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Contacts/Types/ContactsUpdateResponse.php b/src/Contacts/Types/ContactsUpdateResponse.php new file mode 100644 index 0000000..c4a2e14 --- /dev/null +++ b/src/Contacts/Types/ContactsUpdateResponse.php @@ -0,0 +1,149 @@ +, + * avatar?: ?string, + * tags?: ?ContactTags, + * notes?: ?ContactNotes, + * companies?: ?ContactCompanies, + * location?: ?ContactLocation, + * socialProfiles?: ?ContactSocialProfiles, + * enabledPushMessaging?: ?bool, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->externalId = $values['externalId'] ?? null; + $this->workspaceId = $values['workspaceId'] ?? null; + $this->role = $values['role'] ?? null; + $this->email = $values['email'] ?? null; + $this->emailDomain = $values['emailDomain'] ?? null; + $this->phone = $values['phone'] ?? null; + $this->name = $values['name'] ?? null; + $this->ownerId = $values['ownerId'] ?? null; + $this->hasHardBounced = $values['hasHardBounced'] ?? null; + $this->markedEmailAsSpam = $values['markedEmailAsSpam'] ?? null; + $this->unsubscribedFromEmails = $values['unsubscribedFromEmails'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->signedUpAt = $values['signedUpAt'] ?? null; + $this->lastSeenAt = $values['lastSeenAt'] ?? null; + $this->lastRepliedAt = $values['lastRepliedAt'] ?? null; + $this->lastContactedAt = $values['lastContactedAt'] ?? null; + $this->lastEmailOpenedAt = $values['lastEmailOpenedAt'] ?? null; + $this->lastEmailClickedAt = $values['lastEmailClickedAt'] ?? null; + $this->languageOverride = $values['languageOverride'] ?? null; + $this->browser = $values['browser'] ?? null; + $this->browserVersion = $values['browserVersion'] ?? null; + $this->browserLanguage = $values['browserLanguage'] ?? null; + $this->os = $values['os'] ?? null; + $this->androidAppName = $values['androidAppName'] ?? null; + $this->androidAppVersion = $values['androidAppVersion'] ?? null; + $this->androidDevice = $values['androidDevice'] ?? null; + $this->androidOsVersion = $values['androidOsVersion'] ?? null; + $this->androidSdkVersion = $values['androidSdkVersion'] ?? null; + $this->androidLastSeenAt = $values['androidLastSeenAt'] ?? null; + $this->iosAppName = $values['iosAppName'] ?? null; + $this->iosAppVersion = $values['iosAppVersion'] ?? null; + $this->iosDevice = $values['iosDevice'] ?? null; + $this->iosOsVersion = $values['iosOsVersion'] ?? null; + $this->iosSdkVersion = $values['iosSdkVersion'] ?? null; + $this->iosLastSeenAt = $values['iosLastSeenAt'] ?? null; + $this->customAttributes = $values['customAttributes'] ?? null; + $this->avatar = $values['avatar'] ?? null; + $this->tags = $values['tags'] ?? null; + $this->notes = $values['notes'] ?? null; + $this->companies = $values['companies'] ?? null; + $this->location = $values['location'] ?? null; + $this->socialProfiles = $values['socialProfiles'] ?? null; + $this->enabledPushMessaging = $values['enabledPushMessaging'] ?? null; + } + + /** + * @return ?bool + */ + public function getEnabledPushMessaging(): ?bool + { + return $this->enabledPushMessaging; + } + + /** + * @param ?bool $value + */ + public function setEnabledPushMessaging(?bool $value = null): self + { + $this->enabledPushMessaging = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Contacts/Types/ShowContactByExternalIdResponse.php b/src/Contacts/Types/ShowContactByExternalIdResponse.php new file mode 100644 index 0000000..1407850 --- /dev/null +++ b/src/Contacts/Types/ShowContactByExternalIdResponse.php @@ -0,0 +1,149 @@ +, + * avatar?: ?string, + * tags?: ?ContactTags, + * notes?: ?ContactNotes, + * companies?: ?ContactCompanies, + * location?: ?ContactLocation, + * socialProfiles?: ?ContactSocialProfiles, + * enabledPushMessaging?: ?bool, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->externalId = $values['externalId'] ?? null; + $this->workspaceId = $values['workspaceId'] ?? null; + $this->role = $values['role'] ?? null; + $this->email = $values['email'] ?? null; + $this->emailDomain = $values['emailDomain'] ?? null; + $this->phone = $values['phone'] ?? null; + $this->name = $values['name'] ?? null; + $this->ownerId = $values['ownerId'] ?? null; + $this->hasHardBounced = $values['hasHardBounced'] ?? null; + $this->markedEmailAsSpam = $values['markedEmailAsSpam'] ?? null; + $this->unsubscribedFromEmails = $values['unsubscribedFromEmails'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->signedUpAt = $values['signedUpAt'] ?? null; + $this->lastSeenAt = $values['lastSeenAt'] ?? null; + $this->lastRepliedAt = $values['lastRepliedAt'] ?? null; + $this->lastContactedAt = $values['lastContactedAt'] ?? null; + $this->lastEmailOpenedAt = $values['lastEmailOpenedAt'] ?? null; + $this->lastEmailClickedAt = $values['lastEmailClickedAt'] ?? null; + $this->languageOverride = $values['languageOverride'] ?? null; + $this->browser = $values['browser'] ?? null; + $this->browserVersion = $values['browserVersion'] ?? null; + $this->browserLanguage = $values['browserLanguage'] ?? null; + $this->os = $values['os'] ?? null; + $this->androidAppName = $values['androidAppName'] ?? null; + $this->androidAppVersion = $values['androidAppVersion'] ?? null; + $this->androidDevice = $values['androidDevice'] ?? null; + $this->androidOsVersion = $values['androidOsVersion'] ?? null; + $this->androidSdkVersion = $values['androidSdkVersion'] ?? null; + $this->androidLastSeenAt = $values['androidLastSeenAt'] ?? null; + $this->iosAppName = $values['iosAppName'] ?? null; + $this->iosAppVersion = $values['iosAppVersion'] ?? null; + $this->iosDevice = $values['iosDevice'] ?? null; + $this->iosOsVersion = $values['iosOsVersion'] ?? null; + $this->iosSdkVersion = $values['iosSdkVersion'] ?? null; + $this->iosLastSeenAt = $values['iosLastSeenAt'] ?? null; + $this->customAttributes = $values['customAttributes'] ?? null; + $this->avatar = $values['avatar'] ?? null; + $this->tags = $values['tags'] ?? null; + $this->notes = $values['notes'] ?? null; + $this->companies = $values['companies'] ?? null; + $this->location = $values['location'] ?? null; + $this->socialProfiles = $values['socialProfiles'] ?? null; + $this->enabledPushMessaging = $values['enabledPushMessaging'] ?? null; + } + + /** + * @return ?bool + */ + public function getEnabledPushMessaging(): ?bool + { + return $this->enabledPushMessaging; + } + + /** + * @param ?bool $value + */ + public function setEnabledPushMessaging(?bool $value = null): self + { + $this->enabledPushMessaging = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Conversations/ConversationsClient.php b/src/Conversations/ConversationsClient.php index 159776c..dd47a92 100644 --- a/src/Conversations/ConversationsClient.php +++ b/src/Conversations/ConversationsClient.php @@ -8,7 +8,7 @@ use Intercom\Core\Pagination\Pager; use Intercom\Conversations\Types\Conversation; use Intercom\Core\Pagination\CursorPager; -use Intercom\Types\PaginatedConversationResponse; +use Intercom\Types\ConversationList; use Intercom\Conversations\Requests\CreateConversationRequest; use Intercom\Messages\Types\Message; use Intercom\Exceptions\IntercomException; @@ -21,16 +21,18 @@ use Psr\Http\Client\ClientExceptionInterface; use Intercom\Conversations\Requests\FindConversationRequest; use Intercom\Conversations\Requests\UpdateConversationRequest; +use Intercom\Conversations\Requests\DeleteConversationRequest; +use Intercom\Types\ConversationDeleted; use Intercom\Types\SearchRequest; use Intercom\Core\Pagination\PaginationHelper; use Intercom\Conversations\Requests\ReplyToConversationRequest; use Intercom\Conversations\Requests\ManageConversationPartsRequest; -use Intercom\Conversations\Requests\AutoAssignConversationRequest; use Intercom\Conversations\Requests\AttachContactToConversationRequest; use Intercom\Conversations\Requests\DetachContactFromConversationRequest; use Intercom\Types\RedactConversationRequest; use Intercom\Conversations\Requests\ConvertConversationToTicketRequest; use Intercom\Tickets\Types\Ticket; +use Intercom\Conversations\Requests\AutoAssignConversationRequest; class ConversationsClient { @@ -97,9 +99,9 @@ public function list(ListConversationsRequest $request = new ListConversationsRe $request->setStartingAfter($cursor); }, /* @phpstan-ignore-next-line */ - getNextCursor: fn (PaginatedConversationResponse $response) => $response?->getPages()?->getNext()?->getStartingAfter() ?? null, + getNextCursor: fn (ConversationList $response) => $response?->getPages()?->getNext()?->getStartingAfter() ?? null, /* @phpstan-ignore-next-line */ - getItems: fn (PaginatedConversationResponse $response) => $response?->getConversations() ?? [], + getItems: fn (ConversationList $response) => $response?->getConversations() ?? [], ); } @@ -199,6 +201,9 @@ public function find(FindConversationRequest $request, ?array $options = null): if ($request->getDisplayAs() != null) { $query['display_as'] = $request->getDisplayAs(); } + if ($request->getIncludeTranslations() != null) { + $query['include_translations'] = $request->getIncludeTranslations(); + } try { $response = $this->client->sendRequest( new JsonApiRequest( @@ -244,6 +249,12 @@ public function find(FindConversationRequest $request, ?array $options = null): * If you want to reply to a coveration or take an action such as assign, unassign, open, close or snooze, take a look at the reply and manage endpoints. * {% /admonition %} * + * {% admonition type="info" %} + * This endpoint handles both **conversation updates** and **custom object associations**. + * + * See _`update a conversation with an association to a custom object instance`_ in the request/response examples to see the custom object association format. + * {% /admonition %} + * * @param UpdateConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -302,6 +313,61 @@ public function update(UpdateConversationRequest $request, ?array $options = nul ); } + /** + * You can delete a single conversation. + * + * @param DeleteConversationRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ConversationDeleted + * @throws IntercomException + * @throws IntercomApiException + */ + public function deleteConversation(DeleteConversationRequest $request, ?array $options = null): ConversationDeleted + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "conversations/{$request->getConversationId()}", + method: HttpMethod::DELETE, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ConversationDeleted::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + /** * You can search for multiple conversations by the value of their attributes in order to fetch exactly which ones you want. * @@ -324,7 +390,7 @@ public function update(UpdateConversationRequest $request, ?array $options = nul * * ### Accepted Fields * - * Most keys listed as part of the The conversation model is searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foorbar"`). + * Most keys listed in the conversation model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foorbar"`). * The `source.body` field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a `"I need support"` body - the query should contain a `=` operator with the value `"support"` for such conversation to be returned. A query with a `=` operator and a `"need support"` value will not yield a result. * * | Field | Type | @@ -423,9 +489,9 @@ public function search(SearchRequest $request, ?array $options = null): Pager PaginationHelper::setDeep($request, ["pagination", "startingAfter"], $cursor); }, /* @phpstan-ignore-next-line */ - getNextCursor: fn (PaginatedConversationResponse $response) => $response?->getPages()?->getNext()?->getStartingAfter() ?? null, + getNextCursor: fn (ConversationList $response) => $response?->getPages()?->getNext()?->getStartingAfter() ?? null, /* @phpstan-ignore-next-line */ - getItems: fn (PaginatedConversationResponse $response) => $response?->getConversations() ?? [], + getItems: fn (ConversationList $response) => $response?->getConversations() ?? [], ); } @@ -546,15 +612,13 @@ public function manage(ManageConversationPartsRequest $request, ?array $options } /** - * {% admonition type="danger" name="Deprecation of Run Assignment Rules" %} - * Run assignment rules is now deprecated in version 2.12 and future versions and will be permanently removed on December 31, 2026. After this date, any requests made to this endpoint will fail. - * {% /admonition %} - * You can let a conversation be automatically assigned following assignment rules. - * {% admonition type="warning" name="When using workflows" %} - * It is not possible to use this endpoint with Workflows. + * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + * + * {% admonition type="warning" name="Contacts without an email" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with `role` set to `lead`. * {% /admonition %} * - * @param AutoAssignConversationRequest $request + * @param AttachContactToConversationRequest $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -567,15 +631,16 @@ public function manage(ManageConversationPartsRequest $request, ?array $options * @throws IntercomException * @throws IntercomApiException */ - public function runAssignmentRules(AutoAssignConversationRequest $request, ?array $options = null): Conversation + public function attachContactAsAdmin(AttachContactToConversationRequest $request, ?array $options = null): Conversation { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "conversations/{$request->getConversationId()}/run_assignment_rules", + path: "conversations/{$request->getConversationId()}/customers", method: HttpMethod::POST, + body: $request, ), $options, ); @@ -613,7 +678,7 @@ public function runAssignmentRules(AutoAssignConversationRequest $request, ?arra * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with `role` set to `lead`. * {% /admonition %} * - * @param AttachContactToConversationRequest $request + * @param DetachContactFromConversationRequest $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -626,15 +691,15 @@ public function runAssignmentRules(AutoAssignConversationRequest $request, ?arra * @throws IntercomException * @throws IntercomApiException */ - public function attachContactAsAdmin(AttachContactToConversationRequest $request, ?array $options = null): Conversation + public function detachContactAsAdmin(DetachContactFromConversationRequest $request, ?array $options = null): Conversation { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "conversations/{$request->getConversationId()}/customers", - method: HttpMethod::POST, + path: "conversations/{$request->getConversationId()}/customers/{$request->getContactId()}", + method: HttpMethod::DELETE, body: $request, ), $options, @@ -667,13 +732,13 @@ public function attachContactAsAdmin(AttachContactToConversationRequest $request } /** - * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + * You can redact a conversation part or the source message of a conversation (as seen in the source object). * - * {% admonition type="warning" name="Contacts without an email" %} - * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with `role` set to `lead`. + * {% admonition type="info" name="Redacting parts and messages" %} + * If you are redacting a conversation part, it must have a `body`. If you are redacting a source message, it must have been created by a contact. We will return a `conversation_part_not_redactable` error if these criteria are not met. * {% /admonition %} * - * @param DetachContactFromConversationRequest $request + * @param RedactConversationRequest $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -686,15 +751,15 @@ public function attachContactAsAdmin(AttachContactToConversationRequest $request * @throws IntercomException * @throws IntercomApiException */ - public function detachContactAsAdmin(DetachContactFromConversationRequest $request, ?array $options = null): Conversation + public function redactConversationPart(RedactConversationRequest $request, ?array $options = null): Conversation { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "conversations/{$request->getConversationId()}/customers/{$request->getContactId()}", - method: HttpMethod::DELETE, + path: "conversations/redact", + method: HttpMethod::POST, body: $request, ), $options, @@ -727,13 +792,9 @@ public function detachContactAsAdmin(DetachContactFromConversationRequest $reque } /** - * You can redact a conversation part or the source message of a conversation (as seen in the source object). - * - * {% admonition type="info" name="Redacting parts and messages" %} - * If you are redacting a conversation part, it must have a `body`. If you are redacting a source message, it must have been created by a contact. We will return a `conversation_part_not_redactable` error if these criteria are not met. - * {% /admonition %} + * You can convert a conversation to a ticket. * - * @param RedactConversationRequest $request + * @param ConvertConversationToTicketRequest $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -742,18 +803,18 @@ public function detachContactAsAdmin(DetachContactFromConversationRequest $reque * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Conversation + * @return ?Ticket * @throws IntercomException * @throws IntercomApiException */ - public function redactConversationPart(RedactConversationRequest $request, ?array $options = null): Conversation + public function convertToTicket(ConvertConversationToTicketRequest $request, ?array $options = null): ?Ticket { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "conversations/redact", + path: "conversations/{$request->getConversationId()}/convert", method: HttpMethod::POST, body: $request, ), @@ -762,7 +823,10 @@ public function redactConversationPart(RedactConversationRequest $request, ?arra $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); - return Conversation::fromJson($json); + if (empty($json)) { + return null; + } + return Ticket::fromJson($json); } } catch (JsonException $e) { throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); @@ -787,9 +851,7 @@ public function redactConversationPart(RedactConversationRequest $request, ?arra } /** - * You can convert a conversation to a ticket. - * - * @param ConvertConversationToTicketRequest $request + * @param AutoAssignConversationRequest $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -798,30 +860,25 @@ public function redactConversationPart(RedactConversationRequest $request, ?arra * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Ticket * @throws IntercomException * @throws IntercomApiException */ - public function convertToTicket(ConvertConversationToTicketRequest $request, ?array $options = null): Ticket + public function runAssignmentRules(AutoAssignConversationRequest $request, ?array $options = null): void { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "conversations/{$request->getConversationId()}/convert", + path: "conversations/{$request->getConversationId()}/run_assignment_rules", method: HttpMethod::POST, - body: $request, ), $options, ); $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { - $json = $response->getBody()->getContents(); - return Ticket::fromJson($json); + return; } - } catch (JsonException $e) { - throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); } catch (RequestException $e) { $response = $e->getResponse(); if ($response === null) { @@ -860,11 +917,11 @@ public function convertToTicket(ConvertConversationToTicketRequest $request, ?ar * queryParameters?: array, * bodyProperties?: array, * } $options - * @return PaginatedConversationResponse + * @return ConversationList * @throws IntercomException * @throws IntercomApiException */ - private function _list(ListConversationsRequest $request = new ListConversationsRequest(), ?array $options = null): PaginatedConversationResponse + private function _list(ListConversationsRequest $request = new ListConversationsRequest(), ?array $options = null): ConversationList { $options = array_merge($this->options, $options ?? []); $query = []; @@ -887,7 +944,7 @@ private function _list(ListConversationsRequest $request = new ListConversations $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); - return PaginatedConversationResponse::fromJson($json); + return ConversationList::fromJson($json); } } catch (JsonException $e) { throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); @@ -933,7 +990,7 @@ private function _list(ListConversationsRequest $request = new ListConversations * * ### Accepted Fields * - * Most keys listed as part of the The conversation model is searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foorbar"`). + * Most keys listed in the conversation model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foorbar"`). * The `source.body` field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a `"I need support"` body - the query should contain a `=` operator with the value `"support"` for such conversation to be returned. A query with a `=` operator and a `"need support"` value will not yield a result. * * | Field | Type | @@ -1021,11 +1078,11 @@ private function _list(ListConversationsRequest $request = new ListConversations * queryParameters?: array, * bodyProperties?: array, * } $options - * @return PaginatedConversationResponse + * @return ConversationList * @throws IntercomException * @throws IntercomApiException */ - private function _search(SearchRequest $request, ?array $options = null): PaginatedConversationResponse + private function _search(SearchRequest $request, ?array $options = null): ConversationList { $options = array_merge($this->options, $options ?? []); try { @@ -1041,7 +1098,7 @@ private function _search(SearchRequest $request, ?array $options = null): Pagina $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); - return PaginatedConversationResponse::fromJson($json); + return ConversationList::fromJson($json); } } catch (JsonException $e) { throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); diff --git a/src/Conversations/Requests/AutoAssignConversationRequest.php b/src/Conversations/Requests/AutoAssignConversationRequest.php index 0309f14..2183af6 100644 --- a/src/Conversations/Requests/AutoAssignConversationRequest.php +++ b/src/Conversations/Requests/AutoAssignConversationRequest.php @@ -7,7 +7,7 @@ class AutoAssignConversationRequest extends JsonSerializableType { /** - * @var string $conversationId The identifier for the conversation as given by Intercom. + * @var string $conversationId */ private string $conversationId; diff --git a/src/Conversations/Requests/ConvertConversationToTicketRequest.php b/src/Conversations/Requests/ConvertConversationToTicketRequest.php index 71ed79e..d206e5c 100644 --- a/src/Conversations/Requests/ConvertConversationToTicketRequest.php +++ b/src/Conversations/Requests/ConvertConversationToTicketRequest.php @@ -9,9 +9,9 @@ class ConvertConversationToTicketRequest extends JsonSerializableType { /** - * @var string $conversationId The id of the conversation to target + * @var int $conversationId The id of the conversation to target */ - private string $conversationId; + private int $conversationId; /** * @var string $ticketTypeId The ID of the type of ticket you want to convert the conversation to @@ -27,7 +27,7 @@ class ConvertConversationToTicketRequest extends JsonSerializableType /** * @param array{ - * conversationId: string, + * conversationId: int, * ticketTypeId: string, * attributes?: ?array, * } $values @@ -41,17 +41,17 @@ public function __construct( } /** - * @return string + * @return int */ - public function getConversationId(): string + public function getConversationId(): int { return $this->conversationId; } /** - * @param string $value + * @param int $value */ - public function setConversationId(string $value): self + public function setConversationId(int $value): self { $this->conversationId = $value; return $this; diff --git a/src/Conversations/Requests/DeleteConversationRequest.php b/src/Conversations/Requests/DeleteConversationRequest.php new file mode 100644 index 0000000..915714d --- /dev/null +++ b/src/Conversations/Requests/DeleteConversationRequest.php @@ -0,0 +1,41 @@ +conversationId = $values['conversationId']; + } + + /** + * @return int + */ + public function getConversationId(): int + { + return $this->conversationId; + } + + /** + * @param int $value + */ + public function setConversationId(int $value): self + { + $this->conversationId = $value; + return $this; + } +} diff --git a/src/Conversations/Requests/FindConversationRequest.php b/src/Conversations/Requests/FindConversationRequest.php index 72b9922..f8c77f0 100644 --- a/src/Conversations/Requests/FindConversationRequest.php +++ b/src/Conversations/Requests/FindConversationRequest.php @@ -7,19 +7,25 @@ class FindConversationRequest extends JsonSerializableType { /** - * @var string $conversationId The id of the conversation to target + * @var int $conversationId The id of the conversation to target */ - private string $conversationId; + private int $conversationId; /** * @var ?string $displayAs Set to plaintext to retrieve conversation messages in plain text. */ private ?string $displayAs; + /** + * @var ?bool $includeTranslations If set to true, conversation parts will be translated to the detected language of the conversation. + */ + private ?bool $includeTranslations; + /** * @param array{ - * conversationId: string, + * conversationId: int, * displayAs?: ?string, + * includeTranslations?: ?bool, * } $values */ public function __construct( @@ -27,20 +33,21 @@ public function __construct( ) { $this->conversationId = $values['conversationId']; $this->displayAs = $values['displayAs'] ?? null; + $this->includeTranslations = $values['includeTranslations'] ?? null; } /** - * @return string + * @return int */ - public function getConversationId(): string + public function getConversationId(): int { return $this->conversationId; } /** - * @param string $value + * @param int $value */ - public function setConversationId(string $value): self + public function setConversationId(int $value): self { $this->conversationId = $value; return $this; @@ -62,4 +69,21 @@ public function setDisplayAs(?string $value = null): self $this->displayAs = $value; return $this; } + + /** + * @return ?bool + */ + public function getIncludeTranslations(): ?bool + { + return $this->includeTranslations; + } + + /** + * @param ?bool $value + */ + public function setIncludeTranslations(?bool $value = null): self + { + $this->includeTranslations = $value; + return $this; + } } diff --git a/src/Conversations/Requests/UpdateConversationRequest.php b/src/Conversations/Requests/UpdateConversationRequest.php index e4dda34..eb7b3c6 100644 --- a/src/Conversations/Requests/UpdateConversationRequest.php +++ b/src/Conversations/Requests/UpdateConversationRequest.php @@ -4,14 +4,17 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; +use DateTime; +use Intercom\Types\CustomObjectInstanceList; use Intercom\Core\Types\ArrayType; +use Intercom\Core\Types\Union; class UpdateConversationRequest extends JsonSerializableType { /** - * @var string $conversationId The id of the conversation to target + * @var int $conversationId The id of the conversation to target */ - private string $conversationId; + private int $conversationId; /** * @var ?string $displayAs Set to plaintext to retrieve conversation messages in plain text. @@ -25,17 +28,41 @@ class UpdateConversationRequest extends JsonSerializableType private ?bool $read; /** - * @var ?array $customAttributes + * @var ?string $title The title given to the conversation */ - #[JsonProperty('custom_attributes'), ArrayType(['string' => 'mixed'])] + #[JsonProperty('title')] + private ?string $title; + + /** + * @var ?array $customAttributes + */ + #[JsonProperty('custom_attributes'), ArrayType(['string' => new Union('string', 'integer', 'datetime', CustomObjectInstanceList::class)])] private ?array $customAttributes; + /** + * @var ?string $companyId The ID of the company that the conversation is associated with. The unique identifier for the company which is given by Intercom. Set to nil to remove company. + */ + #[JsonProperty('company_id')] + private ?string $companyId; + /** * @param array{ - * conversationId: string, + * conversationId: int, * displayAs?: ?string, * read?: ?bool, - * customAttributes?: ?array, + * title?: ?string, + * customAttributes?: ?array, + * companyId?: ?string, * } $values */ public function __construct( @@ -44,21 +71,23 @@ public function __construct( $this->conversationId = $values['conversationId']; $this->displayAs = $values['displayAs'] ?? null; $this->read = $values['read'] ?? null; + $this->title = $values['title'] ?? null; $this->customAttributes = $values['customAttributes'] ?? null; + $this->companyId = $values['companyId'] ?? null; } /** - * @return string + * @return int */ - public function getConversationId(): string + public function getConversationId(): int { return $this->conversationId; } /** - * @param string $value + * @param int $value */ - public function setConversationId(string $value): self + public function setConversationId(int $value): self { $this->conversationId = $value; return $this; @@ -99,7 +128,29 @@ public function setRead(?bool $value = null): self } /** - * @return ?array + * @return ?string + */ + public function getTitle(): ?string + { + return $this->title; + } + + /** + * @param ?string $value + */ + public function setTitle(?string $value = null): self + { + $this->title = $value; + return $this; + } + + /** + * @return ?array */ public function getCustomAttributes(): ?array { @@ -107,11 +158,33 @@ public function getCustomAttributes(): ?array } /** - * @param ?array $value + * @param ?array $value */ public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; return $this; } + + /** + * @return ?string + */ + public function getCompanyId(): ?string + { + return $this->companyId; + } + + /** + * @param ?string $value + */ + public function setCompanyId(?string $value = null): self + { + $this->companyId = $value; + return $this; + } } diff --git a/src/Conversations/Types/Conversation.php b/src/Conversations/Types/Conversation.php index 1e693fb..90fa29b 100644 --- a/src/Conversations/Types/Conversation.php +++ b/src/Conversations/Types/Conversation.php @@ -9,7 +9,10 @@ use Intercom\Types\ConversationSource; use Intercom\Types\ConversationContacts; use Intercom\Types\ConversationTeammates; +use DateTime; +use Intercom\Types\CustomObjectInstanceList; use Intercom\Core\Types\ArrayType; +use Intercom\Core\Types\Union; use Intercom\Types\ConversationFirstContactReply; use Intercom\Types\SlaApplied; use Intercom\Types\ConversationStatistics; @@ -23,16 +26,16 @@ class Conversation extends JsonSerializableType { /** - * @var ?'conversation' $type Always conversation. + * @var ?string $type Always conversation. */ #[JsonProperty('type')] private ?string $type; /** - * @var string $id The id representing the conversation. + * @var ?string $id The id representing the conversation. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** * @var ?string $title The title given to the conversation. @@ -41,16 +44,16 @@ class Conversation extends JsonSerializableType private ?string $title; /** - * @var int $createdAt The time the conversation was created. + * @var ?int $createdAt The time the conversation was created. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** - * @var int $updatedAt The last time the conversation was updated. + * @var ?int $updatedAt The last time the conversation was updated. */ #[JsonProperty('updated_at')] - private int $updatedAt; + private ?int $updatedAt; /** * @var ?int $waitingSince The last time a Contact responded to an Admin. In other words, the time a customer started waiting for a response. Set to null if last reply is from an Admin. @@ -65,22 +68,22 @@ class Conversation extends JsonSerializableType private ?int $snoozedUntil; /** - * @var bool $open Indicates whether a conversation is open (true) or closed (false). + * @var ?bool $open Indicates whether a conversation is open (true) or closed (false). */ #[JsonProperty('open')] - private bool $open; + private ?bool $open; /** - * @var value-of $state Can be set to "open", "closed" or "snoozed". + * @var ?value-of $state Can be set to "open", "closed" or "snoozed". */ #[JsonProperty('state')] - private string $state; + private ?string $state; /** - * @var bool $read Indicates whether a conversation has been read. + * @var ?bool $read Indicates whether a conversation has been read. */ #[JsonProperty('read')] - private bool $read; + private ?bool $read; /** * @var ?value-of $priority If marked as priority, it will return priority or else not_priority. @@ -100,6 +103,12 @@ class Conversation extends JsonSerializableType #[JsonProperty('team_assignee_id')] private ?string $teamAssigneeId; + /** + * @var ?string $companyId The ID of the company that the conversation is associated with. The unique identifier for the company which is given by Intercom. + */ + #[JsonProperty('company_id')] + private ?string $companyId; + /** * @var ?Tags $tags */ @@ -113,28 +122,33 @@ class Conversation extends JsonSerializableType private ?ConversationRating $conversationRating; /** - * @var ConversationSource $source + * @var ?ConversationSource $source */ #[JsonProperty('source')] - private ConversationSource $source; + private ?ConversationSource $source; /** - * @var ConversationContacts $contacts + * @var ?ConversationContacts $contacts */ #[JsonProperty('contacts')] - private ConversationContacts $contacts; + private ?ConversationContacts $contacts; /** - * @var ConversationTeammates $teammates + * @var ?ConversationTeammates $teammates */ #[JsonProperty('teammates')] - private ConversationTeammates $teammates; + private ?ConversationTeammates $teammates; /** - * @var array $customAttributes + * @var ?array $customAttributes */ - #[JsonProperty('custom_attributes'), ArrayType(['string' => 'mixed'])] - private array $customAttributes; + #[JsonProperty('custom_attributes'), ArrayType(['string' => new Union('string', 'integer', 'datetime', CustomObjectInstanceList::class)])] + private ?array $customAttributes; /** * @var ?ConversationFirstContactReply $firstContactReply @@ -180,25 +194,31 @@ class Conversation extends JsonSerializableType /** * @param array{ - * id: string, - * createdAt: int, - * updatedAt: int, - * open: bool, - * state: value-of, - * read: bool, - * source: ConversationSource, - * contacts: ConversationContacts, - * teammates: ConversationTeammates, - * customAttributes: array, - * type?: ?'conversation', + * type?: ?string, + * id?: ?string, * title?: ?string, + * createdAt?: ?int, + * updatedAt?: ?int, * waitingSince?: ?int, * snoozedUntil?: ?int, + * open?: ?bool, + * state?: ?value-of, + * read?: ?bool, * priority?: ?value-of, * adminAssigneeId?: ?int, * teamAssigneeId?: ?string, + * companyId?: ?string, * tags?: ?Tags, * conversationRating?: ?ConversationRating, + * source?: ?ConversationSource, + * contacts?: ?ConversationContacts, + * teammates?: ?ConversationTeammates, + * customAttributes?: ?array, * firstContactReply?: ?ConversationFirstContactReply, * slaApplied?: ?SlaApplied, * statistics?: ?ConversationStatistics, @@ -209,27 +229,28 @@ class Conversation extends JsonSerializableType * } $values */ public function __construct( - array $values, + array $values = [], ) { $this->type = $values['type'] ?? null; - $this->id = $values['id']; + $this->id = $values['id'] ?? null; $this->title = $values['title'] ?? null; - $this->createdAt = $values['createdAt']; - $this->updatedAt = $values['updatedAt']; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; $this->waitingSince = $values['waitingSince'] ?? null; $this->snoozedUntil = $values['snoozedUntil'] ?? null; - $this->open = $values['open']; - $this->state = $values['state']; - $this->read = $values['read']; + $this->open = $values['open'] ?? null; + $this->state = $values['state'] ?? null; + $this->read = $values['read'] ?? null; $this->priority = $values['priority'] ?? null; $this->adminAssigneeId = $values['adminAssigneeId'] ?? null; $this->teamAssigneeId = $values['teamAssigneeId'] ?? null; + $this->companyId = $values['companyId'] ?? null; $this->tags = $values['tags'] ?? null; $this->conversationRating = $values['conversationRating'] ?? null; - $this->source = $values['source']; - $this->contacts = $values['contacts']; - $this->teammates = $values['teammates']; - $this->customAttributes = $values['customAttributes']; + $this->source = $values['source'] ?? null; + $this->contacts = $values['contacts'] ?? null; + $this->teammates = $values['teammates'] ?? null; + $this->customAttributes = $values['customAttributes'] ?? null; $this->firstContactReply = $values['firstContactReply'] ?? null; $this->slaApplied = $values['slaApplied'] ?? null; $this->statistics = $values['statistics'] ?? null; @@ -240,7 +261,7 @@ public function __construct( } /** - * @return ?'conversation' + * @return ?string */ public function getType(): ?string { @@ -248,7 +269,7 @@ public function getType(): ?string } /** - * @param ?'conversation' $value + * @param ?string $value */ public function setType(?string $value = null): self { @@ -257,17 +278,17 @@ public function setType(?string $value = null): self } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; @@ -291,34 +312,34 @@ public function setTitle(?string $value = null): self } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; } /** - * @return int + * @return ?int */ - public function getUpdatedAt(): int + public function getUpdatedAt(): ?int { return $this->updatedAt; } /** - * @param int $value + * @param ?int $value */ - public function setUpdatedAt(int $value): self + public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; return $this; @@ -359,51 +380,51 @@ public function setSnoozedUntil(?int $value = null): self } /** - * @return bool + * @return ?bool */ - public function getOpen(): bool + public function getOpen(): ?bool { return $this->open; } /** - * @param bool $value + * @param ?bool $value */ - public function setOpen(bool $value): self + public function setOpen(?bool $value = null): self { $this->open = $value; return $this; } /** - * @return value-of + * @return ?value-of */ - public function getState(): string + public function getState(): ?string { return $this->state; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setState(string $value): self + public function setState(?string $value = null): self { $this->state = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getRead(): bool + public function getRead(): ?bool { return $this->read; } /** - * @param bool $value + * @param ?bool $value */ - public function setRead(bool $value): self + public function setRead(?bool $value = null): self { $this->read = $value; return $this; @@ -460,6 +481,23 @@ public function setTeamAssigneeId(?string $value = null): self return $this; } + /** + * @return ?string + */ + public function getCompanyId(): ?string + { + return $this->companyId; + } + + /** + * @param ?string $value + */ + public function setCompanyId(?string $value = null): self + { + $this->companyId = $value; + return $this; + } + /** * @return ?Tags */ @@ -495,68 +533,78 @@ public function setConversationRating(?ConversationRating $value = null): self } /** - * @return ConversationSource + * @return ?ConversationSource */ - public function getSource(): ConversationSource + public function getSource(): ?ConversationSource { return $this->source; } /** - * @param ConversationSource $value + * @param ?ConversationSource $value */ - public function setSource(ConversationSource $value): self + public function setSource(?ConversationSource $value = null): self { $this->source = $value; return $this; } /** - * @return ConversationContacts + * @return ?ConversationContacts */ - public function getContacts(): ConversationContacts + public function getContacts(): ?ConversationContacts { return $this->contacts; } /** - * @param ConversationContacts $value + * @param ?ConversationContacts $value */ - public function setContacts(ConversationContacts $value): self + public function setContacts(?ConversationContacts $value = null): self { $this->contacts = $value; return $this; } /** - * @return ConversationTeammates + * @return ?ConversationTeammates */ - public function getTeammates(): ConversationTeammates + public function getTeammates(): ?ConversationTeammates { return $this->teammates; } /** - * @param ConversationTeammates $value + * @param ?ConversationTeammates $value */ - public function setTeammates(ConversationTeammates $value): self + public function setTeammates(?ConversationTeammates $value = null): self { $this->teammates = $value; return $this; } /** - * @return array + * @return ?array */ - public function getCustomAttributes(): array + public function getCustomAttributes(): ?array { return $this->customAttributes; } /** - * @param array $value + * @param ?array $value */ - public function setCustomAttributes(array $value): self + public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; return $this; diff --git a/src/CustomChannelEvents/CustomChannelEventsClient.php b/src/CustomChannelEvents/CustomChannelEventsClient.php new file mode 100644 index 0000000..3d4ad87 --- /dev/null +++ b/src/CustomChannelEvents/CustomChannelEventsClient.php @@ -0,0 +1,284 @@ +, + * } $options + */ + private array $options; + + /** + * @var RawClient $client + */ + private RawClient $client; + + /** + * @param RawClient $client + * @param ?array{ + * baseUrl?: string, + * client?: ClientInterface, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * } $options + */ + public function __construct( + RawClient $client, + ?array $options = null, + ) { + $this->client = $client; + $this->options = $options ?? []; + } + + /** + * Notifies Intercom that a new conversation was created in your custom channel/platform. This triggers conversation creation and workflow automations within Intercom for your custom channel integration. + * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. + * + * @param CustomChannelBaseEvent $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return CustomChannelNotificationResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function notifyNewConversation(CustomChannelBaseEvent $request, ?array $options = null): CustomChannelNotificationResponse + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "custom_channel_events/notify_new_conversation", + method: HttpMethod::POST, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return CustomChannelNotificationResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Notifies Intercom that a new message was sent in a conversation on your custom channel/platform. This allows Intercom to process the message and trigger any relevant workflow automations. + * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. + * + * @param NotifyNewMessageRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return CustomChannelNotificationResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function notifyNewMessage(NotifyNewMessageRequest $request, ?array $options = null): CustomChannelNotificationResponse + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "custom_channel_events/notify_new_message", + method: HttpMethod::POST, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return CustomChannelNotificationResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Notifies Intercom that a user selected a quick reply option in your custom channel/platform. This allows Intercom to process the response and trigger any relevant workflow automations. + * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. + * + * @param NotifyQuickReplySelectedRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return CustomChannelNotificationResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function notifyQuickReplySelected(NotifyQuickReplySelectedRequest $request, ?array $options = null): CustomChannelNotificationResponse + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "custom_channel_events/notify_quick_reply_selected", + method: HttpMethod::POST, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return CustomChannelNotificationResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Notifies Intercom that a user provided a response to an attribute collector in your custom channel/platform. This allows Intercom to process the attribute and trigger any relevant workflow automations. + * > **Note:** This endpoint is currently under managed availability. Please reach out to your accounts team to discuss access and tailored, hands-on support. + * + * @param NotifyAttributeCollectedRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return CustomChannelNotificationResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function notifyAttributeCollected(NotifyAttributeCollectedRequest $request, ?array $options = null): CustomChannelNotificationResponse + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "custom_channel_events/notify_attribute_collected", + method: HttpMethod::POST, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return CustomChannelNotificationResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } +} diff --git a/src/CustomChannelEvents/Requests/NotifyAttributeCollectedRequest.php b/src/CustomChannelEvents/Requests/NotifyAttributeCollectedRequest.php new file mode 100644 index 0000000..e553b23 --- /dev/null +++ b/src/CustomChannelEvents/Requests/NotifyAttributeCollectedRequest.php @@ -0,0 +1,54 @@ +attribute = $values['attribute']; + $this->eventId = $values['eventId']; + $this->externalConversationId = $values['externalConversationId']; + $this->contact = $values['contact']; + } + + /** + * @return CustomChannelAttribute + */ + public function getAttribute(): CustomChannelAttribute + { + return $this->attribute; + } + + /** + * @param CustomChannelAttribute $value + */ + public function setAttribute(CustomChannelAttribute $value): self + { + $this->attribute = $value; + return $this; + } +} diff --git a/src/CustomChannelEvents/Requests/NotifyNewMessageRequest.php b/src/CustomChannelEvents/Requests/NotifyNewMessageRequest.php new file mode 100644 index 0000000..c505f7f --- /dev/null +++ b/src/CustomChannelEvents/Requests/NotifyNewMessageRequest.php @@ -0,0 +1,53 @@ +body = $values['body']; + $this->eventId = $values['eventId']; + $this->externalConversationId = $values['externalConversationId']; + $this->contact = $values['contact']; + } + + /** + * @return string + */ + public function getBody(): string + { + return $this->body; + } + + /** + * @param string $value + */ + public function setBody(string $value): self + { + $this->body = $value; + return $this; + } +} diff --git a/src/CustomChannelEvents/Requests/NotifyQuickReplySelectedRequest.php b/src/CustomChannelEvents/Requests/NotifyQuickReplySelectedRequest.php new file mode 100644 index 0000000..8c8ab64 --- /dev/null +++ b/src/CustomChannelEvents/Requests/NotifyQuickReplySelectedRequest.php @@ -0,0 +1,53 @@ +quickReplyOptionId = $values['quickReplyOptionId']; + $this->eventId = $values['eventId']; + $this->externalConversationId = $values['externalConversationId']; + $this->contact = $values['contact']; + } + + /** + * @return string + */ + public function getQuickReplyOptionId(): string + { + return $this->quickReplyOptionId; + } + + /** + * @param string $value + */ + public function setQuickReplyOptionId(string $value): self + { + $this->quickReplyOptionId = $value; + return $this; + } +} diff --git a/src/CustomObjectInstances/CustomObjectInstancesClient.php b/src/CustomObjectInstances/CustomObjectInstancesClient.php new file mode 100644 index 0000000..eaeedcc --- /dev/null +++ b/src/CustomObjectInstances/CustomObjectInstancesClient.php @@ -0,0 +1,349 @@ +, + * } $options + */ + private array $options; + + /** + * @var RawClient $client + */ + private RawClient $client; + + /** + * @param RawClient $client + * @param ?array{ + * baseUrl?: string, + * client?: ClientInterface, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * } $options + */ + public function __construct( + RawClient $client, + ?array $options = null, + ) { + $this->client = $client; + $this->options = $options ?? []; + } + + /** + * Fetch a Custom Object Instance by external_id. + * + * @param GetCustomObjectInstancesByExternalIdRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ?CustomObjectInstance + * @throws IntercomException + * @throws IntercomApiException + */ + public function getCustomObjectInstancesByExternalId(GetCustomObjectInstancesByExternalIdRequest $request, ?array $options = null): ?CustomObjectInstance + { + $options = array_merge($this->options, $options ?? []); + $query = []; + $query['external_id'] = $request->getExternalId(); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "custom_object_instances/{$request->getCustomObjectTypeIdentifier()}", + method: HttpMethod::GET, + query: $query, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } + return CustomObjectInstance::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Create or update a custom object instance + * + * @param CreateOrUpdateCustomObjectInstanceRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ?CustomObjectInstance + * @throws IntercomException + * @throws IntercomApiException + */ + public function createCustomObjectInstances(CreateOrUpdateCustomObjectInstanceRequest $request, ?array $options = null): ?CustomObjectInstance + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "custom_object_instances/{$request->getCustomObjectTypeIdentifier()}", + method: HttpMethod::POST, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } + return CustomObjectInstance::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Delete a single Custom Object instance by external_id. + * + * @param DeleteCustomObjectInstancesByIdRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return CustomObjectInstanceDeleted + * @throws IntercomException + * @throws IntercomApiException + */ + public function deleteCustomObjectInstancesById(DeleteCustomObjectInstancesByIdRequest $request, ?array $options = null): CustomObjectInstanceDeleted + { + $options = array_merge($this->options, $options ?? []); + $query = []; + $query['external_id'] = $request->getExternalId(); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "custom_object_instances/{$request->getCustomObjectTypeIdentifier()}", + method: HttpMethod::DELETE, + query: $query, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return CustomObjectInstanceDeleted::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Fetch a Custom Object Instance by id. + * + * @param GetCustomObjectInstancesByIdRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ?CustomObjectInstance + * @throws IntercomException + * @throws IntercomApiException + */ + public function getCustomObjectInstancesById(GetCustomObjectInstancesByIdRequest $request, ?array $options = null): ?CustomObjectInstance + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "custom_object_instances/{$request->getCustomObjectTypeIdentifier()}/{$request->getCustomObjectInstanceId()}", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } + return CustomObjectInstance::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Delete a single Custom Object instance using the Intercom defined id. + * + * @param DeleteCustomObjectInstancesByExternalIdRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return CustomObjectInstanceDeleted + * @throws IntercomException + * @throws IntercomApiException + */ + public function deleteCustomObjectInstancesByExternalId(DeleteCustomObjectInstancesByExternalIdRequest $request, ?array $options = null): CustomObjectInstanceDeleted + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "custom_object_instances/{$request->getCustomObjectTypeIdentifier()}/{$request->getCustomObjectInstanceId()}", + method: HttpMethod::DELETE, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return CustomObjectInstanceDeleted::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } +} diff --git a/src/CustomObjectInstances/Requests/CreateOrUpdateCustomObjectInstanceRequest.php b/src/CustomObjectInstances/Requests/CreateOrUpdateCustomObjectInstanceRequest.php new file mode 100644 index 0000000..87d7f75 --- /dev/null +++ b/src/CustomObjectInstances/Requests/CreateOrUpdateCustomObjectInstanceRequest.php @@ -0,0 +1,144 @@ + $customAttributes The custom attributes which are set for the Custom Object instance. + */ + #[JsonProperty('custom_attributes'), ArrayType(['string' => new Union('string', 'null')])] + private ?array $customAttributes; + + /** + * @param array{ + * customObjectTypeIdentifier: string, + * externalId?: ?string, + * externalCreatedAt?: ?int, + * externalUpdatedAt?: ?int, + * customAttributes?: ?array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->customObjectTypeIdentifier = $values['customObjectTypeIdentifier']; + $this->externalId = $values['externalId'] ?? null; + $this->externalCreatedAt = $values['externalCreatedAt'] ?? null; + $this->externalUpdatedAt = $values['externalUpdatedAt'] ?? null; + $this->customAttributes = $values['customAttributes'] ?? null; + } + + /** + * @return string + */ + public function getCustomObjectTypeIdentifier(): string + { + return $this->customObjectTypeIdentifier; + } + + /** + * @param string $value + */ + public function setCustomObjectTypeIdentifier(string $value): self + { + $this->customObjectTypeIdentifier = $value; + return $this; + } + + /** + * @return ?string + */ + public function getExternalId(): ?string + { + return $this->externalId; + } + + /** + * @param ?string $value + */ + public function setExternalId(?string $value = null): self + { + $this->externalId = $value; + return $this; + } + + /** + * @return ?int + */ + public function getExternalCreatedAt(): ?int + { + return $this->externalCreatedAt; + } + + /** + * @param ?int $value + */ + public function setExternalCreatedAt(?int $value = null): self + { + $this->externalCreatedAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getExternalUpdatedAt(): ?int + { + return $this->externalUpdatedAt; + } + + /** + * @param ?int $value + */ + public function setExternalUpdatedAt(?int $value = null): self + { + $this->externalUpdatedAt = $value; + return $this; + } + + /** + * @return ?array + */ + public function getCustomAttributes(): ?array + { + return $this->customAttributes; + } + + /** + * @param ?array $value + */ + public function setCustomAttributes(?array $value = null): self + { + $this->customAttributes = $value; + return $this; + } +} diff --git a/src/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByExternalIdRequest.php b/src/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByExternalIdRequest.php new file mode 100644 index 0000000..23b3ac8 --- /dev/null +++ b/src/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByExternalIdRequest.php @@ -0,0 +1,65 @@ +customObjectTypeIdentifier = $values['customObjectTypeIdentifier']; + $this->customObjectInstanceId = $values['customObjectInstanceId']; + } + + /** + * @return string + */ + public function getCustomObjectTypeIdentifier(): string + { + return $this->customObjectTypeIdentifier; + } + + /** + * @param string $value + */ + public function setCustomObjectTypeIdentifier(string $value): self + { + $this->customObjectTypeIdentifier = $value; + return $this; + } + + /** + * @return string + */ + public function getCustomObjectInstanceId(): string + { + return $this->customObjectInstanceId; + } + + /** + * @param string $value + */ + public function setCustomObjectInstanceId(string $value): self + { + $this->customObjectInstanceId = $value; + return $this; + } +} diff --git a/src/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByIdRequest.php b/src/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByIdRequest.php new file mode 100644 index 0000000..ce7cd94 --- /dev/null +++ b/src/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByIdRequest.php @@ -0,0 +1,65 @@ +customObjectTypeIdentifier = $values['customObjectTypeIdentifier']; + $this->externalId = $values['externalId']; + } + + /** + * @return string + */ + public function getCustomObjectTypeIdentifier(): string + { + return $this->customObjectTypeIdentifier; + } + + /** + * @param string $value + */ + public function setCustomObjectTypeIdentifier(string $value): self + { + $this->customObjectTypeIdentifier = $value; + return $this; + } + + /** + * @return string + */ + public function getExternalId(): string + { + return $this->externalId; + } + + /** + * @param string $value + */ + public function setExternalId(string $value): self + { + $this->externalId = $value; + return $this; + } +} diff --git a/src/CustomObjectInstances/Requests/GetCustomObjectInstancesByExternalIdRequest.php b/src/CustomObjectInstances/Requests/GetCustomObjectInstancesByExternalIdRequest.php new file mode 100644 index 0000000..dd31e84 --- /dev/null +++ b/src/CustomObjectInstances/Requests/GetCustomObjectInstancesByExternalIdRequest.php @@ -0,0 +1,65 @@ +customObjectTypeIdentifier = $values['customObjectTypeIdentifier']; + $this->externalId = $values['externalId']; + } + + /** + * @return string + */ + public function getCustomObjectTypeIdentifier(): string + { + return $this->customObjectTypeIdentifier; + } + + /** + * @param string $value + */ + public function setCustomObjectTypeIdentifier(string $value): self + { + $this->customObjectTypeIdentifier = $value; + return $this; + } + + /** + * @return string + */ + public function getExternalId(): string + { + return $this->externalId; + } + + /** + * @param string $value + */ + public function setExternalId(string $value): self + { + $this->externalId = $value; + return $this; + } +} diff --git a/src/CustomObjectInstances/Requests/GetCustomObjectInstancesByIdRequest.php b/src/CustomObjectInstances/Requests/GetCustomObjectInstancesByIdRequest.php new file mode 100644 index 0000000..71cf8a5 --- /dev/null +++ b/src/CustomObjectInstances/Requests/GetCustomObjectInstancesByIdRequest.php @@ -0,0 +1,65 @@ +customObjectTypeIdentifier = $values['customObjectTypeIdentifier']; + $this->customObjectInstanceId = $values['customObjectInstanceId']; + } + + /** + * @return string + */ + public function getCustomObjectTypeIdentifier(): string + { + return $this->customObjectTypeIdentifier; + } + + /** + * @param string $value + */ + public function setCustomObjectTypeIdentifier(string $value): self + { + $this->customObjectTypeIdentifier = $value; + return $this; + } + + /** + * @return string + */ + public function getCustomObjectInstanceId(): string + { + return $this->customObjectInstanceId; + } + + /** + * @param string $value + */ + public function setCustomObjectInstanceId(string $value): self + { + $this->customObjectInstanceId = $value; + return $this; + } +} diff --git a/src/CustomObjectInstances/Types/CustomObjectInstance.php b/src/CustomObjectInstances/Types/CustomObjectInstance.php new file mode 100644 index 0000000..85cab79 --- /dev/null +++ b/src/CustomObjectInstances/Types/CustomObjectInstance.php @@ -0,0 +1,230 @@ + $customAttributes The custom attributes you have set on the custom object instance. + */ + #[JsonProperty('custom_attributes'), ArrayType(['string' => 'string'])] + private ?array $customAttributes; + + /** + * @param array{ + * id?: ?string, + * externalId?: ?string, + * externalCreatedAt?: ?int, + * externalUpdatedAt?: ?int, + * createdAt?: ?int, + * updatedAt?: ?int, + * type?: ?string, + * customAttributes?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->id = $values['id'] ?? null; + $this->externalId = $values['externalId'] ?? null; + $this->externalCreatedAt = $values['externalCreatedAt'] ?? null; + $this->externalUpdatedAt = $values['externalUpdatedAt'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->type = $values['type'] ?? null; + $this->customAttributes = $values['customAttributes'] ?? null; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getExternalId(): ?string + { + return $this->externalId; + } + + /** + * @param ?string $value + */ + public function setExternalId(?string $value = null): self + { + $this->externalId = $value; + return $this; + } + + /** + * @return ?int + */ + public function getExternalCreatedAt(): ?int + { + return $this->externalCreatedAt; + } + + /** + * @param ?int $value + */ + public function setExternalCreatedAt(?int $value = null): self + { + $this->externalCreatedAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getExternalUpdatedAt(): ?int + { + return $this->externalUpdatedAt; + } + + /** + * @param ?int $value + */ + public function setExternalUpdatedAt(?int $value = null): self + { + $this->externalUpdatedAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getCreatedAt(): ?int + { + return $this->createdAt; + } + + /** + * @param ?int $value + */ + public function setCreatedAt(?int $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getUpdatedAt(): ?int + { + return $this->updatedAt; + } + + /** + * @param ?int $value + */ + public function setUpdatedAt(?int $value = null): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?array + */ + public function getCustomAttributes(): ?array + { + return $this->customAttributes; + } + + /** + * @param ?array $value + */ + public function setCustomAttributes(?array $value = null): self + { + $this->customAttributes = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/DataAttributes/DataAttributesClient.php b/src/DataAttributes/DataAttributesClient.php index 067b71a..9b23d5b 100644 --- a/src/DataAttributes/DataAttributesClient.php +++ b/src/DataAttributes/DataAttributesClient.php @@ -14,8 +14,11 @@ use JsonException; use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; -use Intercom\DataAttributes\Requests\CreateDataAttributeRequest; +use Intercom\Types\CreateDataAttributeRequestOptions; +use Intercom\Types\CreateDataAttributeRequestOne; use Intercom\DataAttributes\Types\DataAttribute; +use Intercom\Core\Json\JsonSerializer; +use Intercom\Core\Types\Union; use Intercom\DataAttributes\Requests\UpdateDataAttributeRequest; class DataAttributesClient @@ -120,7 +123,10 @@ public function list(ListDataAttributesRequest $request = new ListDataAttributes /** * You can create a data attributes for a `contact` or a `company`. * - * @param CreateDataAttributeRequest $request + * @param ( + * CreateDataAttributeRequestOptions + * |CreateDataAttributeRequestOne + * ) $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -133,7 +139,7 @@ public function list(ListDataAttributesRequest $request = new ListDataAttributes * @throws IntercomException * @throws IntercomApiException */ - public function create(CreateDataAttributeRequest $request, ?array $options = null): DataAttribute + public function create(CreateDataAttributeRequestOptions|CreateDataAttributeRequestOne $request, ?array $options = null): DataAttribute { $options = array_merge($this->options, $options ?? []); try { @@ -142,7 +148,7 @@ public function create(CreateDataAttributeRequest $request, ?array $options = nu baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, path: "data_attributes", method: HttpMethod::POST, - body: $request, + body: JsonSerializer::serializeUnion($request, new Union(CreateDataAttributeRequestOptions::class, CreateDataAttributeRequestOne::class)), ), $options, ); @@ -203,7 +209,7 @@ public function update(UpdateDataAttributeRequest $request, ?array $options = nu baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, path: "data_attributes/{$request->getDataAttributeId()}", method: HttpMethod::PUT, - body: $request, + body: $request->getBody(), ), $options, ); diff --git a/src/DataAttributes/Requests/CreateDataAttributeRequest.php b/src/DataAttributes/Requests/CreateDataAttributeRequest.php deleted file mode 100644 index cc9a533..0000000 --- a/src/DataAttributes/Requests/CreateDataAttributeRequest.php +++ /dev/null @@ -1,171 +0,0 @@ - $model The model that the data attribute belongs to. - */ - #[JsonProperty('model')] - private string $model; - - /** - * @var value-of $dataType The type of data stored for this attribute. - */ - #[JsonProperty('data_type')] - private string $dataType; - - /** - * @var ?string $description The readable description you see in the UI for the attribute. - */ - #[JsonProperty('description')] - private ?string $description; - - /** - * @var ?array $options To create list attributes. Provide a set of hashes with `value` as the key of the options you want to make. `data_type` must be `string`. - */ - #[JsonProperty('options'), ArrayType(['string'])] - private ?array $options; - - /** - * @var ?bool $messengerWritable Can this attribute be updated by the Messenger - */ - #[JsonProperty('messenger_writable')] - private ?bool $messengerWritable; - - /** - * @param array{ - * name: string, - * model: value-of, - * dataType: value-of, - * description?: ?string, - * options?: ?array, - * messengerWritable?: ?bool, - * } $values - */ - public function __construct( - array $values, - ) { - $this->name = $values['name']; - $this->model = $values['model']; - $this->dataType = $values['dataType']; - $this->description = $values['description'] ?? null; - $this->options = $values['options'] ?? null; - $this->messengerWritable = $values['messengerWritable'] ?? null; - } - - /** - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * @param string $value - */ - public function setName(string $value): self - { - $this->name = $value; - return $this; - } - - /** - * @return value-of - */ - public function getModel(): string - { - return $this->model; - } - - /** - * @param value-of $value - */ - public function setModel(string $value): self - { - $this->model = $value; - return $this; - } - - /** - * @return value-of - */ - public function getDataType(): string - { - return $this->dataType; - } - - /** - * @param value-of $value - */ - public function setDataType(string $value): self - { - $this->dataType = $value; - return $this; - } - - /** - * @return ?string - */ - public function getDescription(): ?string - { - return $this->description; - } - - /** - * @param ?string $value - */ - public function setDescription(?string $value = null): self - { - $this->description = $value; - return $this; - } - - /** - * @return ?array - */ - public function getOptions(): ?array - { - return $this->options; - } - - /** - * @param ?array $value - */ - public function setOptions(?array $value = null): self - { - $this->options = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getMessengerWritable(): ?bool - { - return $this->messengerWritable; - } - - /** - * @param ?bool $value - */ - public function setMessengerWritable(?bool $value = null): self - { - $this->messengerWritable = $value; - return $this; - } -} diff --git a/src/DataAttributes/Requests/UpdateDataAttributeRequest.php b/src/DataAttributes/Requests/UpdateDataAttributeRequest.php index 89d7986..b33619e 100644 --- a/src/DataAttributes/Requests/UpdateDataAttributeRequest.php +++ b/src/DataAttributes/Requests/UpdateDataAttributeRequest.php @@ -3,142 +3,76 @@ namespace Intercom\DataAttributes\Requests; use Intercom\Core\Json\JsonSerializableType; -use Intercom\Core\Json\JsonProperty; -use Intercom\DataAttributes\Types\UpdateDataAttributeRequestOptionsItem; -use Intercom\Core\Types\ArrayType; +use Intercom\Types\UpdateDataAttributeRequestOptions; class UpdateDataAttributeRequest extends JsonSerializableType { /** - * @var string $dataAttributeId The data attribute id + * @var int $dataAttributeId The data attribute id */ - private string $dataAttributeId; + private int $dataAttributeId; /** - * @var ?bool $archived Whether the attribute is to be archived or not. + * @var ( + * UpdateDataAttributeRequestOptions + * |mixed + * ) $body */ - #[JsonProperty('archived')] - private ?bool $archived; - - /** - * @var ?string $description The readable description you see in the UI for the attribute. - */ - #[JsonProperty('description')] - private ?string $description; - - /** - * @var ?array $options To create list attributes. Provide a set of hashes with `value` as the key of the options you want to make. `data_type` must be `string`. - */ - #[JsonProperty('options'), ArrayType([UpdateDataAttributeRequestOptionsItem::class])] - private ?array $options; - - /** - * @var ?bool $messengerWritable Can this attribute be updated by the Messenger - */ - #[JsonProperty('messenger_writable')] - private ?bool $messengerWritable; + private mixed $body; /** * @param array{ - * dataAttributeId: string, - * archived?: ?bool, - * description?: ?string, - * options?: ?array, - * messengerWritable?: ?bool, + * dataAttributeId: int, + * body: ( + * UpdateDataAttributeRequestOptions + * |mixed + * ), * } $values */ public function __construct( array $values, ) { $this->dataAttributeId = $values['dataAttributeId']; - $this->archived = $values['archived'] ?? null; - $this->description = $values['description'] ?? null; - $this->options = $values['options'] ?? null; - $this->messengerWritable = $values['messengerWritable'] ?? null; + $this->body = $values['body']; } /** - * @return string + * @return int */ - public function getDataAttributeId(): string + public function getDataAttributeId(): int { return $this->dataAttributeId; } /** - * @param string $value + * @param int $value */ - public function setDataAttributeId(string $value): self + public function setDataAttributeId(int $value): self { $this->dataAttributeId = $value; return $this; } /** - * @return ?bool - */ - public function getArchived(): ?bool - { - return $this->archived; - } - - /** - * @param ?bool $value - */ - public function setArchived(?bool $value = null): self - { - $this->archived = $value; - return $this; - } - - /** - * @return ?string - */ - public function getDescription(): ?string - { - return $this->description; - } - - /** - * @param ?string $value - */ - public function setDescription(?string $value = null): self - { - $this->description = $value; - return $this; - } - - /** - * @return ?array - */ - public function getOptions(): ?array - { - return $this->options; - } - - /** - * @param ?array $value - */ - public function setOptions(?array $value = null): self - { - $this->options = $value; - return $this; - } - - /** - * @return ?bool + * @return ( + * UpdateDataAttributeRequestOptions + * |mixed + * ) */ - public function getMessengerWritable(): ?bool + public function getBody(): mixed { - return $this->messengerWritable; + return $this->body; } /** - * @param ?bool $value + * @param ( + * UpdateDataAttributeRequestOptions + * |mixed + * ) $value */ - public function setMessengerWritable(?bool $value = null): self + public function setBody(mixed $value): self { - $this->messengerWritable = $value; + $this->body = $value; return $this; } } diff --git a/src/DataAttributes/Types/CreateDataAttributeRequestModel.php b/src/DataAttributes/Types/CreateDataAttributeRequestModel.php deleted file mode 100644 index 3049f73..0000000 --- a/src/DataAttributes/Types/CreateDataAttributeRequestModel.php +++ /dev/null @@ -1,9 +0,0 @@ -options = $options ?? []; } + /** + * @param ExportReportingDataRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return DataExportExportReportingDataResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function exportReportingData(ExportReportingDataRequest $request, ?array $options = null): DataExportExportReportingDataResponse + { + $options = array_merge($this->options, $options ?? []); + $query = []; + $query['app_id'] = $request->getAppId(); + $query['client_id'] = $request->getClientId(); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "export/reporting_data/{$request->getJobIdentifier()}", + method: HttpMethod::GET, + query: $query, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return DataExportExportReportingDataResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * @param DownloadReportingDataExportRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @throws IntercomException + * @throws IntercomApiException + */ + public function downloadReportingDataExport(DownloadReportingDataExportRequest $request, ?array $options = null): void + { + $options = array_merge($this->options, $options ?? []); + $query = []; + $query['app_id'] = $request->getAppId(); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "download/reporting_data/{$request->getJobIdentifier()}", + method: HttpMethod::GET, + query: $query, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + return; + } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + /** * To create your export job, you need to send a `POST` request to the export endpoint `https://api.intercom.io/export/content/data`. * diff --git a/src/DataExport/Requests/DownloadReportingDataExportRequest.php b/src/DataExport/Requests/DownloadReportingDataExportRequest.php new file mode 100644 index 0000000..3dc3da4 --- /dev/null +++ b/src/DataExport/Requests/DownloadReportingDataExportRequest.php @@ -0,0 +1,65 @@ +jobIdentifier = $values['jobIdentifier']; + $this->appId = $values['appId']; + } + + /** + * @return string + */ + public function getJobIdentifier(): string + { + return $this->jobIdentifier; + } + + /** + * @param string $value + */ + public function setJobIdentifier(string $value): self + { + $this->jobIdentifier = $value; + return $this; + } + + /** + * @return string + */ + public function getAppId(): string + { + return $this->appId; + } + + /** + * @param string $value + */ + public function setAppId(string $value): self + { + $this->appId = $value; + return $this; + } +} diff --git a/src/DataExport/Requests/ExportReportingDataRequest.php b/src/DataExport/Requests/ExportReportingDataRequest.php new file mode 100644 index 0000000..28ec1d2 --- /dev/null +++ b/src/DataExport/Requests/ExportReportingDataRequest.php @@ -0,0 +1,89 @@ +jobIdentifier = $values['jobIdentifier']; + $this->appId = $values['appId']; + $this->clientId = $values['clientId']; + } + + /** + * @return string + */ + public function getJobIdentifier(): string + { + return $this->jobIdentifier; + } + + /** + * @param string $value + */ + public function setJobIdentifier(string $value): self + { + $this->jobIdentifier = $value; + return $this; + } + + /** + * @return string + */ + public function getAppId(): string + { + return $this->appId; + } + + /** + * @param string $value + */ + public function setAppId(string $value): self + { + $this->appId = $value; + return $this; + } + + /** + * @return string + */ + public function getClientId(): string + { + return $this->clientId; + } + + /** + * @param string $value + */ + public function setClientId(string $value): self + { + $this->clientId = $value; + return $this; + } +} diff --git a/src/DataExport/Types/DataExport.php b/src/DataExport/Types/DataExport.php index 9b67502..e00d26d 100644 --- a/src/DataExport/Types/DataExport.php +++ b/src/DataExport/Types/DataExport.php @@ -11,109 +11,109 @@ class DataExport extends JsonSerializableType { /** - * @var string $jobIdentifier The identifier for your job. + * @var ?string $jobIdentfier The identifier for your job. */ - #[JsonProperty('job_identifier')] - private string $jobIdentifier; + #[JsonProperty('job_identfier')] + private ?string $jobIdentfier; /** - * @var value-of $status The current state of your job. + * @var ?value-of $status The current state of your job. */ #[JsonProperty('status')] - private string $status; + private ?string $status; /** - * @var string $downloadExpiresAt The time after which you will not be able to access the data. + * @var ?string $downloadExpiresAt The time after which you will not be able to access the data. */ #[JsonProperty('download_expires_at')] - private string $downloadExpiresAt; + private ?string $downloadExpiresAt; /** - * @var string $downloadUrl The location where you can download your data. + * @var ?string $downloadUrl The location where you can download your data. */ #[JsonProperty('download_url')] - private string $downloadUrl; + private ?string $downloadUrl; /** * @param array{ - * jobIdentifier: string, - * status: value-of, - * downloadExpiresAt: string, - * downloadUrl: string, + * jobIdentfier?: ?string, + * status?: ?value-of, + * downloadExpiresAt?: ?string, + * downloadUrl?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->jobIdentifier = $values['jobIdentifier']; - $this->status = $values['status']; - $this->downloadExpiresAt = $values['downloadExpiresAt']; - $this->downloadUrl = $values['downloadUrl']; + $this->jobIdentfier = $values['jobIdentfier'] ?? null; + $this->status = $values['status'] ?? null; + $this->downloadExpiresAt = $values['downloadExpiresAt'] ?? null; + $this->downloadUrl = $values['downloadUrl'] ?? null; } /** - * @return string + * @return ?string */ - public function getJobIdentifier(): string + public function getJobIdentfier(): ?string { - return $this->jobIdentifier; + return $this->jobIdentfier; } /** - * @param string $value + * @param ?string $value */ - public function setJobIdentifier(string $value): self + public function setJobIdentfier(?string $value = null): self { - $this->jobIdentifier = $value; + $this->jobIdentfier = $value; return $this; } /** - * @return value-of + * @return ?value-of */ - public function getStatus(): string + public function getStatus(): ?string { return $this->status; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setStatus(string $value): self + public function setStatus(?string $value = null): self { $this->status = $value; return $this; } /** - * @return string + * @return ?string */ - public function getDownloadExpiresAt(): string + public function getDownloadExpiresAt(): ?string { return $this->downloadExpiresAt; } /** - * @param string $value + * @param ?string $value */ - public function setDownloadExpiresAt(string $value): self + public function setDownloadExpiresAt(?string $value = null): self { $this->downloadExpiresAt = $value; return $this; } /** - * @return string + * @return ?string */ - public function getDownloadUrl(): string + public function getDownloadUrl(): ?string { return $this->downloadUrl; } /** - * @param string $value + * @param ?string $value */ - public function setDownloadUrl(string $value): self + public function setDownloadUrl(?string $value = null): self { $this->downloadUrl = $value; return $this; diff --git a/src/DataExport/Types/DataExportExportReportingDataResponse.php b/src/DataExport/Types/DataExportExportReportingDataResponse.php new file mode 100644 index 0000000..2c7db6f --- /dev/null +++ b/src/DataExport/Types/DataExportExportReportingDataResponse.php @@ -0,0 +1,126 @@ +jobIdentifier = $values['jobIdentifier'] ?? null; + $this->status = $values['status'] ?? null; + $this->downloadUrl = $values['downloadUrl'] ?? null; + $this->downloadExpiresAt = $values['downloadExpiresAt'] ?? null; + } + + /** + * @return ?string + */ + public function getJobIdentifier(): ?string + { + return $this->jobIdentifier; + } + + /** + * @param ?string $value + */ + public function setJobIdentifier(?string $value = null): self + { + $this->jobIdentifier = $value; + return $this; + } + + /** + * @return ?string + */ + public function getStatus(): ?string + { + return $this->status; + } + + /** + * @param ?string $value + */ + public function setStatus(?string $value = null): self + { + $this->status = $value; + return $this; + } + + /** + * @return ?string + */ + public function getDownloadUrl(): ?string + { + return $this->downloadUrl; + } + + /** + * @param ?string $value + */ + public function setDownloadUrl(?string $value = null): self + { + $this->downloadUrl = $value; + return $this; + } + + /** + * @return ?string + */ + public function getDownloadExpiresAt(): ?string + { + return $this->downloadExpiresAt; + } + + /** + * @param ?string $value + */ + public function setDownloadExpiresAt(?string $value = null): self + { + $this->downloadExpiresAt = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Export/ExportClient.php b/src/Export/ExportClient.php new file mode 100644 index 0000000..03ee040 --- /dev/null +++ b/src/Export/ExportClient.php @@ -0,0 +1,160 @@ +, + * } $options + */ + private array $options; + + /** + * @var RawClient $client + */ + private RawClient $client; + + /** + * @param RawClient $client + * @param ?array{ + * baseUrl?: string, + * client?: ClientInterface, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * } $options + */ + public function __construct( + RawClient $client, + ?array $options = null, + ) { + $this->client = $client; + $this->options = $options ?? []; + } + + /** + * @param PostExportReportingDataEnqueueRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return PostExportReportingDataEnqueueResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function enqueueANewReportingDataExportJob(PostExportReportingDataEnqueueRequest $request, ?array $options = null): PostExportReportingDataEnqueueResponse + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "export/reporting_data/enqueue", + method: HttpMethod::POST, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return PostExportReportingDataEnqueueResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return GetExportReportingDataGetDatasetsResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function listAvailableDatasetsAndAttributes(?array $options = null): GetExportReportingDataGetDatasetsResponse + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "export/reporting_data/get_datasets", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return GetExportReportingDataGetDatasetsResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } +} diff --git a/src/Export/Requests/PostExportReportingDataEnqueueRequest.php b/src/Export/Requests/PostExportReportingDataEnqueueRequest.php new file mode 100644 index 0000000..7be7a76 --- /dev/null +++ b/src/Export/Requests/PostExportReportingDataEnqueueRequest.php @@ -0,0 +1,119 @@ + $attributeIds + */ + #[JsonProperty('attribute_ids'), ArrayType(['string'])] + private array $attributeIds; + + /** + * @var int $startTime + */ + #[JsonProperty('start_time')] + private int $startTime; + + /** + * @var int $endTime + */ + #[JsonProperty('end_time')] + private int $endTime; + + /** + * @param array{ + * datasetId: string, + * attributeIds: array, + * startTime: int, + * endTime: int, + * } $values + */ + public function __construct( + array $values, + ) { + $this->datasetId = $values['datasetId']; + $this->attributeIds = $values['attributeIds']; + $this->startTime = $values['startTime']; + $this->endTime = $values['endTime']; + } + + /** + * @return string + */ + public function getDatasetId(): string + { + return $this->datasetId; + } + + /** + * @param string $value + */ + public function setDatasetId(string $value): self + { + $this->datasetId = $value; + return $this; + } + + /** + * @return array + */ + public function getAttributeIds(): array + { + return $this->attributeIds; + } + + /** + * @param array $value + */ + public function setAttributeIds(array $value): self + { + $this->attributeIds = $value; + return $this; + } + + /** + * @return int + */ + public function getStartTime(): int + { + return $this->startTime; + } + + /** + * @param int $value + */ + public function setStartTime(int $value): self + { + $this->startTime = $value; + return $this; + } + + /** + * @return int + */ + public function getEndTime(): int + { + return $this->endTime; + } + + /** + * @param int $value + */ + public function setEndTime(int $value): self + { + $this->endTime = $value; + return $this; + } +} diff --git a/src/Export/Types/GetExportReportingDataGetDatasetsResponse.php b/src/Export/Types/GetExportReportingDataGetDatasetsResponse.php new file mode 100644 index 0000000..76383f1 --- /dev/null +++ b/src/Export/Types/GetExportReportingDataGetDatasetsResponse.php @@ -0,0 +1,77 @@ + $data + */ + #[JsonProperty('data'), ArrayType([GetExportReportingDataGetDatasetsResponseDataItem::class])] + private ?array $data; + + /** + * @param array{ + * type?: ?string, + * data?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?array + */ + public function getData(): ?array + { + return $this->data; + } + + /** + * @param ?array $value + */ + public function setData(?array $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Export/Types/GetExportReportingDataGetDatasetsResponseDataItem.php b/src/Export/Types/GetExportReportingDataGetDatasetsResponseDataItem.php new file mode 100644 index 0000000..6ee1fed --- /dev/null +++ b/src/Export/Types/GetExportReportingDataGetDatasetsResponseDataItem.php @@ -0,0 +1,152 @@ + $attributes + */ + #[JsonProperty('attributes'), ArrayType([GetExportReportingDataGetDatasetsResponseDataItemAttributesItem::class])] + private ?array $attributes; + + /** + * @param array{ + * id?: ?string, + * name?: ?string, + * description?: ?string, + * defaultTimeAttributeId?: ?string, + * attributes?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->id = $values['id'] ?? null; + $this->name = $values['name'] ?? null; + $this->description = $values['description'] ?? null; + $this->defaultTimeAttributeId = $values['defaultTimeAttributeId'] ?? null; + $this->attributes = $values['attributes'] ?? null; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return ?string + */ + public function getDescription(): ?string + { + return $this->description; + } + + /** + * @param ?string $value + */ + public function setDescription(?string $value = null): self + { + $this->description = $value; + return $this; + } + + /** + * @return ?string + */ + public function getDefaultTimeAttributeId(): ?string + { + return $this->defaultTimeAttributeId; + } + + /** + * @param ?string $value + */ + public function setDefaultTimeAttributeId(?string $value = null): self + { + $this->defaultTimeAttributeId = $value; + return $this; + } + + /** + * @return ?array + */ + public function getAttributes(): ?array + { + return $this->attributes; + } + + /** + * @param ?array $value + */ + public function setAttributes(?array $value = null): self + { + $this->attributes = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DividerComponent.php b/src/Export/Types/GetExportReportingDataGetDatasetsResponseDataItemAttributesItem.php similarity index 54% rename from src/Types/DividerComponent.php rename to src/Export/Types/GetExportReportingDataGetDatasetsResponseDataItemAttributesItem.php index 5423f26..498da2b 100644 --- a/src/Types/DividerComponent.php +++ b/src/Export/Types/GetExportReportingDataGetDatasetsResponseDataItemAttributesItem.php @@ -1,38 +1,35 @@ id = $values['id'] ?? null; - $this->bottomMargin = $values['bottomMargin'] ?? null; + $this->name = $values['name'] ?? null; } /** @@ -53,19 +50,19 @@ public function setId(?string $value = null): self } /** - * @return ?'none' + * @return ?string */ - public function getBottomMargin(): ?string + public function getName(): ?string { - return $this->bottomMargin; + return $this->name; } /** - * @param ?'none' $value + * @param ?string $value */ - public function setBottomMargin(?string $value = null): self + public function setName(?string $value = null): self { - $this->bottomMargin = $value; + $this->name = $value; return $this; } diff --git a/src/Export/Types/PostExportReportingDataEnqueueResponse.php b/src/Export/Types/PostExportReportingDataEnqueueResponse.php new file mode 100644 index 0000000..58a1807 --- /dev/null +++ b/src/Export/Types/PostExportReportingDataEnqueueResponse.php @@ -0,0 +1,126 @@ +jobIdentifier = $values['jobIdentifier'] ?? null; + $this->status = $values['status'] ?? null; + $this->downloadUrl = $values['downloadUrl'] ?? null; + $this->downloadExpiresAt = $values['downloadExpiresAt'] ?? null; + } + + /** + * @return ?string + */ + public function getJobIdentifier(): ?string + { + return $this->jobIdentifier; + } + + /** + * @param ?string $value + */ + public function setJobIdentifier(?string $value = null): self + { + $this->jobIdentifier = $value; + return $this; + } + + /** + * @return ?string + */ + public function getStatus(): ?string + { + return $this->status; + } + + /** + * @param ?string $value + */ + public function setStatus(?string $value = null): self + { + $this->status = $value; + return $this; + } + + /** + * @return ?string + */ + public function getDownloadUrl(): ?string + { + return $this->downloadUrl; + } + + /** + * @param ?string $value + */ + public function setDownloadUrl(?string $value = null): self + { + $this->downloadUrl = $value; + return $this; + } + + /** + * @return ?string + */ + public function getDownloadExpiresAt(): ?string + { + return $this->downloadExpiresAt; + } + + /** + * @param ?string $value + */ + public function setDownloadExpiresAt(?string $value = null): self + { + $this->downloadExpiresAt = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/HelpCenter/Types/HelpCenter.php b/src/HelpCenter/Types/HelpCenter.php index 2cf0b60..228b4de 100644 --- a/src/HelpCenter/Types/HelpCenter.php +++ b/src/HelpCenter/Types/HelpCenter.php @@ -11,22 +11,22 @@ class HelpCenter extends JsonSerializableType { /** - * @var string $id The unique identifier for the Help Center which is given by Intercom. + * @var ?string $id The unique identifier for the Help Center which is given by Intercom. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $workspaceId The id of the workspace which the Help Center belongs to. + * @var ?string $workspaceId The id of the workspace which the Help Center belongs to. */ #[JsonProperty('workspace_id')] - private string $workspaceId; + private ?string $workspaceId; /** - * @var int $createdAt The time when the Help Center was created. + * @var ?int $createdAt The time when the Help Center was created. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** * @var ?int $updatedAt The time when the Help Center was last updated. @@ -35,92 +35,108 @@ class HelpCenter extends JsonSerializableType private ?int $updatedAt; /** - * @var string $identifier The identifier of the Help Center. This is used in the URL of the Help Center. + * @var ?string $identifier The identifier of the Help Center. This is used in the URL of the Help Center. */ #[JsonProperty('identifier')] - private string $identifier; + private ?string $identifier; /** - * @var bool $websiteTurnedOn Whether the Help Center is turned on or not. This is controlled in your Help Center settings. + * @var ?bool $websiteTurnedOn Whether the Help Center is turned on or not. This is controlled in your Help Center settings. */ #[JsonProperty('website_turned_on')] - private bool $websiteTurnedOn; + private ?bool $websiteTurnedOn; /** - * @var string $displayName The display name of the Help Center only seen by teammates. + * @var ?string $displayName The display name of the Help Center only seen by teammates. */ #[JsonProperty('display_name')] - private string $displayName; + private ?string $displayName; + + /** + * @var ?string $url The URL for the help center, if you have a custom domain then this will show the URL using the custom domain. + */ + #[JsonProperty('url')] + private ?string $url; + + /** + * @var ?string $customDomain Custom domain configured for the help center + */ + #[JsonProperty('custom_domain')] + private ?string $customDomain; /** * @param array{ - * id: string, - * workspaceId: string, - * createdAt: int, - * identifier: string, - * websiteTurnedOn: bool, - * displayName: string, + * id?: ?string, + * workspaceId?: ?string, + * createdAt?: ?int, * updatedAt?: ?int, + * identifier?: ?string, + * websiteTurnedOn?: ?bool, + * displayName?: ?string, + * url?: ?string, + * customDomain?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->id = $values['id']; - $this->workspaceId = $values['workspaceId']; - $this->createdAt = $values['createdAt']; + $this->id = $values['id'] ?? null; + $this->workspaceId = $values['workspaceId'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; $this->updatedAt = $values['updatedAt'] ?? null; - $this->identifier = $values['identifier']; - $this->websiteTurnedOn = $values['websiteTurnedOn']; - $this->displayName = $values['displayName']; + $this->identifier = $values['identifier'] ?? null; + $this->websiteTurnedOn = $values['websiteTurnedOn'] ?? null; + $this->displayName = $values['displayName'] ?? null; + $this->url = $values['url'] ?? null; + $this->customDomain = $values['customDomain'] ?? null; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getWorkspaceId(): string + public function getWorkspaceId(): ?string { return $this->workspaceId; } /** - * @param string $value + * @param ?string $value */ - public function setWorkspaceId(string $value): self + public function setWorkspaceId(?string $value = null): self { $this->workspaceId = $value; return $this; } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; @@ -144,56 +160,90 @@ public function setUpdatedAt(?int $value = null): self } /** - * @return string + * @return ?string */ - public function getIdentifier(): string + public function getIdentifier(): ?string { return $this->identifier; } /** - * @param string $value + * @param ?string $value */ - public function setIdentifier(string $value): self + public function setIdentifier(?string $value = null): self { $this->identifier = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getWebsiteTurnedOn(): bool + public function getWebsiteTurnedOn(): ?bool { return $this->websiteTurnedOn; } /** - * @param bool $value + * @param ?bool $value */ - public function setWebsiteTurnedOn(bool $value): self + public function setWebsiteTurnedOn(?bool $value = null): self { $this->websiteTurnedOn = $value; return $this; } /** - * @return string + * @return ?string */ - public function getDisplayName(): string + public function getDisplayName(): ?string { return $this->displayName; } /** - * @param string $value + * @param ?string $value */ - public function setDisplayName(string $value): self + public function setDisplayName(?string $value = null): self { $this->displayName = $value; return $this; } + /** + * @return ?string + */ + public function getUrl(): ?string + { + return $this->url; + } + + /** + * @param ?string $value + */ + public function setUrl(?string $value = null): self + { + $this->url = $value; + return $this; + } + + /** + * @return ?string + */ + public function getCustomDomain(): ?string + { + return $this->customDomain; + } + + /** + * @param ?string $value + */ + public function setCustomDomain(?string $value = null): self + { + $this->customDomain = $value; + return $this; + } + /** * @return string */ diff --git a/src/HelpCenter/Types/HelpCenterList.php b/src/HelpCenter/Types/HelpCenterList.php index 6165aa1..e9af781 100644 --- a/src/HelpCenter/Types/HelpCenterList.php +++ b/src/HelpCenter/Types/HelpCenterList.php @@ -12,59 +12,59 @@ class HelpCenterList extends JsonSerializableType { /** - * @var 'list' $type The type of the object - `list`. + * @var ?'list' $type The type of the object - `list`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $data An array of Help Center objects + * @var ?array $data An array of Help Center objects */ #[JsonProperty('data'), ArrayType([HelpCenter::class])] - private array $data; + private ?array $data; /** * @param array{ - * type: 'list', - * data: array, + * type?: ?'list', + * data?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->data = $values['data']; + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; diff --git a/src/HelpCenters/Collections/Requests/DeleteCollectionRequest.php b/src/HelpCenters/Collections/Requests/DeleteCollectionRequest.php index 0e91e4b..a1e9af1 100644 --- a/src/HelpCenters/Collections/Requests/DeleteCollectionRequest.php +++ b/src/HelpCenters/Collections/Requests/DeleteCollectionRequest.php @@ -7,13 +7,13 @@ class DeleteCollectionRequest extends JsonSerializableType { /** - * @var string $collectionId The unique identifier for the collection which is given by Intercom. + * @var int $collectionId The unique identifier for the collection which is given by Intercom. */ - private string $collectionId; + private int $collectionId; /** * @param array{ - * collectionId: string, + * collectionId: int, * } $values */ public function __construct( @@ -23,17 +23,17 @@ public function __construct( } /** - * @return string + * @return int */ - public function getCollectionId(): string + public function getCollectionId(): int { return $this->collectionId; } /** - * @param string $value + * @param int $value */ - public function setCollectionId(string $value): self + public function setCollectionId(int $value): self { $this->collectionId = $value; return $this; diff --git a/src/HelpCenters/Collections/Requests/FindCollectionRequest.php b/src/HelpCenters/Collections/Requests/FindCollectionRequest.php index d09948e..88e8f24 100644 --- a/src/HelpCenters/Collections/Requests/FindCollectionRequest.php +++ b/src/HelpCenters/Collections/Requests/FindCollectionRequest.php @@ -7,13 +7,13 @@ class FindCollectionRequest extends JsonSerializableType { /** - * @var string $collectionId The unique identifier for the collection which is given by Intercom. + * @var int $collectionId The unique identifier for the collection which is given by Intercom. */ - private string $collectionId; + private int $collectionId; /** * @param array{ - * collectionId: string, + * collectionId: int, * } $values */ public function __construct( @@ -23,17 +23,17 @@ public function __construct( } /** - * @return string + * @return int */ - public function getCollectionId(): string + public function getCollectionId(): int { return $this->collectionId; } /** - * @param string $value + * @param int $value */ - public function setCollectionId(string $value): self + public function setCollectionId(int $value): self { $this->collectionId = $value; return $this; diff --git a/src/HelpCenters/Collections/Requests/UpdateCollectionRequest.php b/src/HelpCenters/Collections/Requests/UpdateCollectionRequest.php index dfe8d95..77b90e8 100644 --- a/src/HelpCenters/Collections/Requests/UpdateCollectionRequest.php +++ b/src/HelpCenters/Collections/Requests/UpdateCollectionRequest.php @@ -9,9 +9,9 @@ class UpdateCollectionRequest extends JsonSerializableType { /** - * @var string $collectionId The unique identifier for the collection which is given by Intercom. + * @var int $collectionId The unique identifier for the collection which is given by Intercom. */ - private string $collectionId; + private int $collectionId; /** * @var ?string $name The name of the collection. For multilingual collections, this will be the name of the default language's content. @@ -39,7 +39,7 @@ class UpdateCollectionRequest extends JsonSerializableType /** * @param array{ - * collectionId: string, + * collectionId: int, * name?: ?string, * description?: ?string, * translatedContent?: ?GroupTranslatedContent, @@ -57,17 +57,17 @@ public function __construct( } /** - * @return string + * @return int */ - public function getCollectionId(): string + public function getCollectionId(): int { return $this->collectionId; } /** - * @param string $value + * @param int $value */ - public function setCollectionId(string $value): self + public function setCollectionId(int $value): self { $this->collectionId = $value; return $this; diff --git a/src/HelpCenters/Requests/FindHelpCenterRequest.php b/src/HelpCenters/Requests/FindHelpCenterRequest.php index 72f7191..081e65b 100644 --- a/src/HelpCenters/Requests/FindHelpCenterRequest.php +++ b/src/HelpCenters/Requests/FindHelpCenterRequest.php @@ -7,13 +7,13 @@ class FindHelpCenterRequest extends JsonSerializableType { /** - * @var string $helpCenterId The unique identifier for the Help Center which is given by Intercom. + * @var int $helpCenterId The unique identifier for the collection which is given by Intercom. */ - private string $helpCenterId; + private int $helpCenterId; /** * @param array{ - * helpCenterId: string, + * helpCenterId: int, * } $values */ public function __construct( @@ -23,17 +23,17 @@ public function __construct( } /** - * @return string + * @return int */ - public function getHelpCenterId(): string + public function getHelpCenterId(): int { return $this->helpCenterId; } /** - * @param string $value + * @param int $value */ - public function setHelpCenterId(string $value): self + public function setHelpCenterId(int $value): self { $this->helpCenterId = $value; return $this; diff --git a/src/IntercomClient.php b/src/IntercomClient.php index b9c8a5e..0936f9b 100644 --- a/src/IntercomClient.php +++ b/src/IntercomClient.php @@ -3,21 +3,30 @@ namespace Intercom; use Intercom\Admins\AdminsClient; +use Intercom\AiContent\AiContentClient; use Intercom\Articles\ArticlesClient; +use Intercom\AwayStatusReasons\AwayStatusReasonsClient; +use Intercom\Export\ExportClient; +use Intercom\DataExport\DataExportClient; use Intercom\HelpCenters\HelpCentersClient; +use Intercom\InternalArticles\InternalArticlesClient; use Intercom\Companies\CompaniesClient; use Intercom\Contacts\ContactsClient; use Intercom\Notes\NotesClient; use Intercom\Tags\TagsClient; use Intercom\Conversations\ConversationsClient; +use Intercom\CustomChannelEvents\CustomChannelEventsClient; +use Intercom\CustomObjectInstances\CustomObjectInstancesClient; use Intercom\DataAttributes\DataAttributesClient; use Intercom\Events\EventsClient; -use Intercom\DataExport\DataExportClient; +use Intercom\Jobs\JobsClient; use Intercom\Messages\MessagesClient; use Intercom\Segments\SegmentsClient; use Intercom\SubscriptionTypes\SubscriptionTypesClient; use Intercom\PhoneCallRedirects\PhoneCallRedirectsClient; +use Intercom\Calls\CallsClient; use Intercom\Teams\TeamsClient; +use Intercom\TicketStates\TicketStatesClient; use Intercom\TicketTypes\TicketTypesClient; use Intercom\Tickets\TicketsClient; use Intercom\Visitors\VisitorsClient; @@ -34,16 +43,41 @@ class IntercomClient */ public AdminsClient $admins; + /** + * @var AiContentClient $aiContent + */ + public AiContentClient $aiContent; + /** * @var ArticlesClient $articles */ public ArticlesClient $articles; + /** + * @var AwayStatusReasonsClient $awayStatusReasons + */ + public AwayStatusReasonsClient $awayStatusReasons; + + /** + * @var ExportClient $export + */ + public ExportClient $export; + + /** + * @var DataExportClient $dataExport + */ + public DataExportClient $dataExport; + /** * @var HelpCentersClient $helpCenters */ public HelpCentersClient $helpCenters; + /** + * @var InternalArticlesClient $internalArticles + */ + public InternalArticlesClient $internalArticles; + /** * @var CompaniesClient $companies */ @@ -69,6 +103,16 @@ class IntercomClient */ public ConversationsClient $conversations; + /** + * @var CustomChannelEventsClient $customChannelEvents + */ + public CustomChannelEventsClient $customChannelEvents; + + /** + * @var CustomObjectInstancesClient $customObjectInstances + */ + public CustomObjectInstancesClient $customObjectInstances; + /** * @var DataAttributesClient $dataAttributes */ @@ -80,9 +124,9 @@ class IntercomClient public EventsClient $events; /** - * @var DataExportClient $dataExport + * @var JobsClient $jobs */ - public DataExportClient $dataExport; + public JobsClient $jobs; /** * @var MessagesClient $messages @@ -104,11 +148,21 @@ class IntercomClient */ public PhoneCallRedirectsClient $phoneCallRedirects; + /** + * @var CallsClient $calls + */ + public CallsClient $calls; + /** * @var TeamsClient $teams */ public TeamsClient $teams; + /** + * @var TicketStatesClient $ticketStates + */ + public TicketStatesClient $ticketStates; + /** * @var TicketTypesClient $ticketTypes */ @@ -169,8 +223,8 @@ public function __construct( 'Authorization' => "Bearer $token", 'X-Fern-Language' => 'PHP', 'X-Fern-SDK-Name' => 'Intercom', - 'X-Fern-SDK-Version' => '0.0.325', - 'User-Agent' => 'intercom/intercom-php/0.0.325', + 'X-Fern-SDK-Version' => '6.0.0', + 'User-Agent' => 'intercom/intercom-php/6.0.0', 'Intercom-Version' => '2.11', ]; @@ -185,21 +239,30 @@ public function __construct( ); $this->admins = new AdminsClient($this->client, $this->options); + $this->aiContent = new AiContentClient($this->client, $this->options); $this->articles = new ArticlesClient($this->client, $this->options); + $this->awayStatusReasons = new AwayStatusReasonsClient($this->client, $this->options); + $this->export = new ExportClient($this->client, $this->options); + $this->dataExport = new DataExportClient($this->client, $this->options); $this->helpCenters = new HelpCentersClient($this->client, $this->options); + $this->internalArticles = new InternalArticlesClient($this->client, $this->options); $this->companies = new CompaniesClient($this->client, $this->options); $this->contacts = new ContactsClient($this->client, $this->options); $this->notes = new NotesClient($this->client, $this->options); $this->tags = new TagsClient($this->client, $this->options); $this->conversations = new ConversationsClient($this->client, $this->options); + $this->customChannelEvents = new CustomChannelEventsClient($this->client, $this->options); + $this->customObjectInstances = new CustomObjectInstancesClient($this->client, $this->options); $this->dataAttributes = new DataAttributesClient($this->client, $this->options); $this->events = new EventsClient($this->client, $this->options); - $this->dataExport = new DataExportClient($this->client, $this->options); + $this->jobs = new JobsClient($this->client, $this->options); $this->messages = new MessagesClient($this->client, $this->options); $this->segments = new SegmentsClient($this->client, $this->options); $this->subscriptionTypes = new SubscriptionTypesClient($this->client, $this->options); $this->phoneCallRedirects = new PhoneCallRedirectsClient($this->client, $this->options); + $this->calls = new CallsClient($this->client, $this->options); $this->teams = new TeamsClient($this->client, $this->options); + $this->ticketStates = new TicketStatesClient($this->client, $this->options); $this->ticketTypes = new TicketTypesClient($this->client, $this->options); $this->tickets = new TicketsClient($this->client, $this->options); $this->visitors = new VisitorsClient($this->client, $this->options); diff --git a/src/InternalArticles/InternalArticlesClient.php b/src/InternalArticles/InternalArticlesClient.php new file mode 100644 index 0000000..135d0ed --- /dev/null +++ b/src/InternalArticles/InternalArticlesClient.php @@ -0,0 +1,396 @@ +, + * } $options + */ + private array $options; + + /** + * @var RawClient $client + */ + private RawClient $client; + + /** + * @param RawClient $client + * @param ?array{ + * baseUrl?: string, + * client?: ClientInterface, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * } $options + */ + public function __construct( + RawClient $client, + ?array $options = null, + ) { + $this->client = $client; + $this->options = $options ?? []; + } + + /** + * You can fetch a list of all internal articles by making a GET request to `https://api.intercom.io/internal_articles`. + * + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return InternalArticleList + * @throws IntercomException + * @throws IntercomApiException + */ + public function listInternalArticles(?array $options = null): InternalArticleList + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "internal_articles", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return InternalArticleList::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can create a new internal article by making a POST request to `https://api.intercom.io/internal_articles`. + * + * @param ?CreateInternalArticleRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return InternalArticleListItem + * @throws IntercomException + * @throws IntercomApiException + */ + public function createInternalArticle(?CreateInternalArticleRequest $request = null, ?array $options = null): InternalArticleListItem + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "internal_articles", + method: HttpMethod::POST, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return InternalArticleListItem::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can fetch the details of a single internal article by making a GET request to `https://api.intercom.io/internal_articles/`. + * + * @param RetrieveInternalArticleRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return InternalArticleListItem + * @throws IntercomException + * @throws IntercomApiException + */ + public function retrieveInternalArticle(RetrieveInternalArticleRequest $request, ?array $options = null): InternalArticleListItem + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "internal_articles/{$request->getInternalArticleId()}", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return InternalArticleListItem::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can update the details of a single internal article by making a PUT request to `https://api.intercom.io/internal_articles/`. + * + * @param UpdateInternalArticleRequestBody $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return InternalArticleListItem + * @throws IntercomException + * @throws IntercomApiException + */ + public function updateInternalArticle(UpdateInternalArticleRequestBody $request, ?array $options = null): InternalArticleListItem + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "internal_articles/{$request->getInternalArticleId()}", + method: HttpMethod::PUT, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return InternalArticleListItem::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can delete a single internal article by making a DELETE request to `https://api.intercom.io/internal_articles/`. + * + * @param DeleteInternalArticleRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return DeletedInternalArticleObject + * @throws IntercomException + * @throws IntercomApiException + */ + public function deleteInternalArticle(DeleteInternalArticleRequest $request, ?array $options = null): DeletedInternalArticleObject + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "internal_articles/{$request->getInternalArticleId()}", + method: HttpMethod::DELETE, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return DeletedInternalArticleObject::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can search for internal articles by making a GET request to `https://api.intercom.io/internal_articles/search`. + * + * @param SearchInternalArticlesRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return InternalArticleSearchResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function searchInternalArticles(SearchInternalArticlesRequest $request = new SearchInternalArticlesRequest(), ?array $options = null): InternalArticleSearchResponse + { + $options = array_merge($this->options, $options ?? []); + $query = []; + if ($request->getFolderId() != null) { + $query['folder_id'] = $request->getFolderId(); + } + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "internal_articles/search", + method: HttpMethod::GET, + query: $query, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return InternalArticleSearchResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } +} diff --git a/src/InternalArticles/Requests/DeleteInternalArticleRequest.php b/src/InternalArticles/Requests/DeleteInternalArticleRequest.php new file mode 100644 index 0000000..2bdeb18 --- /dev/null +++ b/src/InternalArticles/Requests/DeleteInternalArticleRequest.php @@ -0,0 +1,41 @@ +internalArticleId = $values['internalArticleId']; + } + + /** + * @return int + */ + public function getInternalArticleId(): int + { + return $this->internalArticleId; + } + + /** + * @param int $value + */ + public function setInternalArticleId(int $value): self + { + $this->internalArticleId = $value; + return $this; + } +} diff --git a/src/InternalArticles/Requests/RetrieveInternalArticleRequest.php b/src/InternalArticles/Requests/RetrieveInternalArticleRequest.php new file mode 100644 index 0000000..cf95e1c --- /dev/null +++ b/src/InternalArticles/Requests/RetrieveInternalArticleRequest.php @@ -0,0 +1,41 @@ +internalArticleId = $values['internalArticleId']; + } + + /** + * @return int + */ + public function getInternalArticleId(): int + { + return $this->internalArticleId; + } + + /** + * @param int $value + */ + public function setInternalArticleId(int $value): self + { + $this->internalArticleId = $value; + return $this; + } +} diff --git a/src/InternalArticles/Requests/SearchInternalArticlesRequest.php b/src/InternalArticles/Requests/SearchInternalArticlesRequest.php new file mode 100644 index 0000000..1e6e267 --- /dev/null +++ b/src/InternalArticles/Requests/SearchInternalArticlesRequest.php @@ -0,0 +1,41 @@ +folderId = $values['folderId'] ?? null; + } + + /** + * @return ?string + */ + public function getFolderId(): ?string + { + return $this->folderId; + } + + /** + * @param ?string $value + */ + public function setFolderId(?string $value = null): self + { + $this->folderId = $value; + return $this; + } +} diff --git a/src/InternalArticles/Requests/UpdateInternalArticleRequestBody.php b/src/InternalArticles/Requests/UpdateInternalArticleRequestBody.php new file mode 100644 index 0000000..f947e15 --- /dev/null +++ b/src/InternalArticles/Requests/UpdateInternalArticleRequestBody.php @@ -0,0 +1,142 @@ +internalArticleId = $values['internalArticleId']; + $this->title = $values['title'] ?? null; + $this->body = $values['body'] ?? null; + $this->authorId = $values['authorId'] ?? null; + $this->ownerId = $values['ownerId'] ?? null; + } + + /** + * @return int + */ + public function getInternalArticleId(): int + { + return $this->internalArticleId; + } + + /** + * @param int $value + */ + public function setInternalArticleId(int $value): self + { + $this->internalArticleId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getTitle(): ?string + { + return $this->title; + } + + /** + * @param ?string $value + */ + public function setTitle(?string $value = null): self + { + $this->title = $value; + return $this; + } + + /** + * @return ?string + */ + public function getBody(): ?string + { + return $this->body; + } + + /** + * @param ?string $value + */ + public function setBody(?string $value = null): self + { + $this->body = $value; + return $this; + } + + /** + * @return ?int + */ + public function getAuthorId(): ?int + { + return $this->authorId; + } + + /** + * @param ?int $value + */ + public function setAuthorId(?int $value = null): self + { + $this->authorId = $value; + return $this; + } + + /** + * @return ?int + */ + public function getOwnerId(): ?int + { + return $this->ownerId; + } + + /** + * @param ?int $value + */ + public function setOwnerId(?int $value = null): self + { + $this->ownerId = $value; + return $this; + } +} diff --git a/src/InternalArticles/Types/InternalArticleListItem.php b/src/InternalArticles/Types/InternalArticleListItem.php new file mode 100644 index 0000000..b548435 --- /dev/null +++ b/src/InternalArticles/Types/InternalArticleListItem.php @@ -0,0 +1,254 @@ +type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->title = $values['title'] ?? null; + $this->body = $values['body'] ?? null; + $this->ownerId = $values['ownerId'] ?? null; + $this->authorId = $values['authorId'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->locale = $values['locale'] ?? null; + } + + /** + * @return ?'internal_article' + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?'internal_article' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getTitle(): ?string + { + return $this->title; + } + + /** + * @param ?string $value + */ + public function setTitle(?string $value = null): self + { + $this->title = $value; + return $this; + } + + /** + * @return ?string + */ + public function getBody(): ?string + { + return $this->body; + } + + /** + * @param ?string $value + */ + public function setBody(?string $value = null): self + { + $this->body = $value; + return $this; + } + + /** + * @return ?int + */ + public function getOwnerId(): ?int + { + return $this->ownerId; + } + + /** + * @param ?int $value + */ + public function setOwnerId(?int $value = null): self + { + $this->ownerId = $value; + return $this; + } + + /** + * @return ?int + */ + public function getAuthorId(): ?int + { + return $this->authorId; + } + + /** + * @param ?int $value + */ + public function setAuthorId(?int $value = null): self + { + $this->authorId = $value; + return $this; + } + + /** + * @return ?int + */ + public function getCreatedAt(): ?int + { + return $this->createdAt; + } + + /** + * @param ?int $value + */ + public function setCreatedAt(?int $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getUpdatedAt(): ?int + { + return $this->updatedAt; + } + + /** + * @param ?int $value + */ + public function setUpdatedAt(?int $value = null): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return ?string + */ + public function getLocale(): ?string + { + return $this->locale; + } + + /** + * @param ?string $value + */ + public function setLocale(?string $value = null): self + { + $this->locale = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/InternalArticles/Types/InternalArticleSearchResponse.php b/src/InternalArticles/Types/InternalArticleSearchResponse.php new file mode 100644 index 0000000..bd420ad --- /dev/null +++ b/src/InternalArticles/Types/InternalArticleSearchResponse.php @@ -0,0 +1,130 @@ +type = $values['type'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->data = $values['data'] ?? null; + $this->pages = $values['pages'] ?? null; + } + + /** + * @return ?'list' + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?'list' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?int + */ + public function getTotalCount(): ?int + { + return $this->totalCount; + } + + /** + * @param ?int $value + */ + public function setTotalCount(?int $value = null): self + { + $this->totalCount = $value; + return $this; + } + + /** + * @return ?InternalArticleSearchResponseData + */ + public function getData(): ?InternalArticleSearchResponseData + { + return $this->data; + } + + /** + * @param ?InternalArticleSearchResponseData $value + */ + public function setData(?InternalArticleSearchResponseData $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return ?CursorPages + */ + public function getPages(): ?CursorPages + { + return $this->pages; + } + + /** + * @param ?CursorPages $value + */ + public function setPages(?CursorPages $value = null): self + { + $this->pages = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/InternalArticles/Types/InternalArticleSearchResponseData.php b/src/InternalArticles/Types/InternalArticleSearchResponseData.php new file mode 100644 index 0000000..7dbcedd --- /dev/null +++ b/src/InternalArticles/Types/InternalArticleSearchResponseData.php @@ -0,0 +1,55 @@ + $internalArticles An array of Internal Article objects + */ + #[JsonProperty('internal_articles'), ArrayType([InternalArticleListItem::class])] + private ?array $internalArticles; + + /** + * @param array{ + * internalArticles?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->internalArticles = $values['internalArticles'] ?? null; + } + + /** + * @return ?array + */ + public function getInternalArticles(): ?array + { + return $this->internalArticles; + } + + /** + * @param ?array $value + */ + public function setInternalArticles(?array $value = null): self + { + $this->internalArticles = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Jobs/JobsClient.php b/src/Jobs/JobsClient.php new file mode 100644 index 0000000..a261387 --- /dev/null +++ b/src/Jobs/JobsClient.php @@ -0,0 +1,108 @@ +, + * } $options + */ + private array $options; + + /** + * @var RawClient $client + */ + private RawClient $client; + + /** + * @param RawClient $client + * @param ?array{ + * baseUrl?: string, + * client?: ClientInterface, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * } $options + */ + public function __construct( + RawClient $client, + ?array $options = null, + ) { + $this->client = $client; + $this->options = $options ?? []; + } + + /** + * Retrieve the status of job execution. + * + * @param JobsStatusRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return Jobs + * @throws IntercomException + * @throws IntercomApiException + */ + public function status(JobsStatusRequest $request, ?array $options = null): Jobs + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "jobs/status/{$request->getJobId()}", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return Jobs::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } +} diff --git a/src/Jobs/Requests/JobsStatusRequest.php b/src/Jobs/Requests/JobsStatusRequest.php new file mode 100644 index 0000000..e5ee7be --- /dev/null +++ b/src/Jobs/Requests/JobsStatusRequest.php @@ -0,0 +1,41 @@ +jobId = $values['jobId']; + } + + /** + * @return string + */ + public function getJobId(): string + { + return $this->jobId; + } + + /** + * @param string $value + */ + public function setJobId(string $value): self + { + $this->jobId = $value; + return $this; + } +} diff --git a/src/Jobs/Types/Jobs.php b/src/Jobs/Types/Jobs.php new file mode 100644 index 0000000..6a096ea --- /dev/null +++ b/src/Jobs/Types/Jobs.php @@ -0,0 +1,204 @@ + $status The status of the job execution. + */ + #[JsonProperty('status')] + private ?string $status; + + /** + * @var ?string $resourceType The type of resource created during job execution. + */ + #[JsonProperty('resource_type')] + private ?string $resourceType; + + /** + * @var ?string $resourceId The id of the resource created during job execution (e.g. ticket id) + */ + #[JsonProperty('resource_id')] + private ?string $resourceId; + + /** + * @var ?string $resourceUrl The url of the resource created during job exeuction. Use this url to fetch the resource. + */ + #[JsonProperty('resource_url')] + private ?string $resourceUrl; + + /** + * @param array{ + * id: string, + * type?: ?'job', + * url?: ?string, + * status?: ?value-of, + * resourceType?: ?string, + * resourceId?: ?string, + * resourceUrl?: ?string, + * } $values + */ + public function __construct( + array $values, + ) { + $this->type = $values['type'] ?? null; + $this->id = $values['id']; + $this->url = $values['url'] ?? null; + $this->status = $values['status'] ?? null; + $this->resourceType = $values['resourceType'] ?? null; + $this->resourceId = $values['resourceId'] ?? null; + $this->resourceUrl = $values['resourceUrl'] ?? null; + } + + /** + * @return ?'job' + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?'job' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $value + */ + public function setId(string $value): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getUrl(): ?string + { + return $this->url; + } + + /** + * @param ?string $value + */ + public function setUrl(?string $value = null): self + { + $this->url = $value; + return $this; + } + + /** + * @return ?value-of + */ + public function getStatus(): ?string + { + return $this->status; + } + + /** + * @param ?value-of $value + */ + public function setStatus(?string $value = null): self + { + $this->status = $value; + return $this; + } + + /** + * @return ?string + */ + public function getResourceType(): ?string + { + return $this->resourceType; + } + + /** + * @param ?string $value + */ + public function setResourceType(?string $value = null): self + { + $this->resourceType = $value; + return $this; + } + + /** + * @return ?string + */ + public function getResourceId(): ?string + { + return $this->resourceId; + } + + /** + * @param ?string $value + */ + public function setResourceId(?string $value = null): self + { + $this->resourceId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getResourceUrl(): ?string + { + return $this->resourceUrl; + } + + /** + * @param ?string $value + */ + public function setResourceUrl(?string $value = null): self + { + $this->resourceUrl = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Jobs/Types/JobsStatus.php b/src/Jobs/Types/JobsStatus.php new file mode 100644 index 0000000..d613621 --- /dev/null +++ b/src/Jobs/Types/JobsStatus.php @@ -0,0 +1,10 @@ + * > As this is a message, there will be no conversation present until the contact responds. Once they do, you will have to search for a contact's conversations with the id of the message. * - * @param CreateMessageRequest $request + * @param ?CreateMessageRequest $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -77,7 +77,7 @@ public function __construct( * @throws IntercomException * @throws IntercomApiException */ - public function create(CreateMessageRequest $request, ?array $options = null): Message + public function create(?CreateMessageRequest $request = null, ?array $options = null): Message { $options = array_merge($this->options, $options ?? []); try { diff --git a/src/Messages/Types/Message.php b/src/Messages/Types/Message.php index 9572fd3..18bc460 100644 --- a/src/Messages/Types/Message.php +++ b/src/Messages/Types/Message.php @@ -29,10 +29,10 @@ class Message extends JsonSerializableType private int $createdAt; /** - * @var string $subject The subject of the message. Only present if message_type: email. + * @var ?string $subject The subject of the message. Only present if message_type: email. */ #[JsonProperty('subject')] - private string $subject; + private ?string $subject; /** * @var string $body The message body, which may contain HTML. @@ -47,20 +47,20 @@ class Message extends JsonSerializableType private string $messageType; /** - * @var string $conversationId The associated conversation_id + * @var ?string $conversationId The associated conversation_id */ #[JsonProperty('conversation_id')] - private string $conversationId; + private ?string $conversationId; /** * @param array{ * type: string, * id: string, * createdAt: int, - * subject: string, * body: string, * messageType: value-of, - * conversationId: string, + * subject?: ?string, + * conversationId?: ?string, * } $values */ public function __construct( @@ -69,10 +69,10 @@ public function __construct( $this->type = $values['type']; $this->id = $values['id']; $this->createdAt = $values['createdAt']; - $this->subject = $values['subject']; + $this->subject = $values['subject'] ?? null; $this->body = $values['body']; $this->messageType = $values['messageType']; - $this->conversationId = $values['conversationId']; + $this->conversationId = $values['conversationId'] ?? null; } /** @@ -127,17 +127,17 @@ public function setCreatedAt(int $value): self } /** - * @return string + * @return ?string */ - public function getSubject(): string + public function getSubject(): ?string { return $this->subject; } /** - * @param string $value + * @param ?string $value */ - public function setSubject(string $value): self + public function setSubject(?string $value = null): self { $this->subject = $value; return $this; @@ -178,17 +178,17 @@ public function setMessageType(string $value): self } /** - * @return string + * @return ?string */ - public function getConversationId(): string + public function getConversationId(): ?string { return $this->conversationId; } /** - * @param string $value + * @param ?string $value */ - public function setConversationId(string $value): self + public function setConversationId(?string $value = null): self { $this->conversationId = $value; return $this; diff --git a/src/News/Feeds/FeedsClient.php b/src/News/Feeds/FeedsClient.php index 82fdded..754444e 100644 --- a/src/News/Feeds/FeedsClient.php +++ b/src/News/Feeds/FeedsClient.php @@ -5,7 +5,7 @@ use GuzzleHttp\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\News\Feeds\Requests\ListNewsFeedItemsRequest; -use Intercom\Types\PaginatedNewsItemResponse; +use Intercom\Types\PaginatedResponse; use Intercom\Exceptions\IntercomException; use Intercom\Exceptions\IntercomApiException; use Intercom\Core\Json\JsonApiRequest; @@ -14,7 +14,6 @@ use JsonException; use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; -use Intercom\Types\PaginatedNewsfeedResponse; use Intercom\News\Feeds\Requests\FindNewsFeedRequest; use Intercom\News\Types\Newsfeed; @@ -66,11 +65,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return PaginatedNewsItemResponse + * @return PaginatedResponse * @throws IntercomException * @throws IntercomApiException */ - public function listItems(ListNewsFeedItemsRequest $request, ?array $options = null): PaginatedNewsItemResponse + public function listItems(ListNewsFeedItemsRequest $request, ?array $options = null): PaginatedResponse { $options = array_merge($this->options, $options ?? []); try { @@ -85,7 +84,7 @@ public function listItems(ListNewsFeedItemsRequest $request, ?array $options = n $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); - return PaginatedNewsItemResponse::fromJson($json); + return PaginatedResponse::fromJson($json); } } catch (JsonException $e) { throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); @@ -120,11 +119,11 @@ public function listItems(ListNewsFeedItemsRequest $request, ?array $options = n * queryParameters?: array, * bodyProperties?: array, * } $options - * @return PaginatedNewsfeedResponse + * @return PaginatedResponse * @throws IntercomException * @throws IntercomApiException */ - public function list(?array $options = null): PaginatedNewsfeedResponse + public function list(?array $options = null): PaginatedResponse { $options = array_merge($this->options, $options ?? []); try { @@ -139,7 +138,7 @@ public function list(?array $options = null): PaginatedNewsfeedResponse $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); - return PaginatedNewsfeedResponse::fromJson($json); + return PaginatedResponse::fromJson($json); } } catch (JsonException $e) { throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); diff --git a/src/News/Items/ItemsClient.php b/src/News/Items/ItemsClient.php index d6a5a64..88a82fd 100644 --- a/src/News/Items/ItemsClient.php +++ b/src/News/Items/ItemsClient.php @@ -4,7 +4,7 @@ use GuzzleHttp\ClientInterface; use Intercom\Core\Client\RawClient; -use Intercom\Types\PaginatedNewsItemResponse; +use Intercom\Types\PaginatedResponse; use Intercom\Exceptions\IntercomException; use Intercom\Exceptions\IntercomApiException; use Intercom\Core\Json\JsonApiRequest; @@ -67,11 +67,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return PaginatedNewsItemResponse + * @return PaginatedResponse * @throws IntercomException * @throws IntercomApiException */ - public function list(?array $options = null): PaginatedNewsItemResponse + public function list(?array $options = null): PaginatedResponse { $options = array_merge($this->options, $options ?? []); try { @@ -86,7 +86,7 @@ public function list(?array $options = null): PaginatedNewsItemResponse $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); - return PaginatedNewsItemResponse::fromJson($json); + return PaginatedResponse::fromJson($json); } } catch (JsonException $e) { throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); diff --git a/src/News/Items/Requests/DeleteNewsItemRequest.php b/src/News/Items/Requests/DeleteNewsItemRequest.php index 395f60f..ffaeaaa 100644 --- a/src/News/Items/Requests/DeleteNewsItemRequest.php +++ b/src/News/Items/Requests/DeleteNewsItemRequest.php @@ -7,13 +7,13 @@ class DeleteNewsItemRequest extends JsonSerializableType { /** - * @var string $newsItemId The unique identifier for the news item which is given by Intercom. + * @var int $newsItemId The unique identifier for the news item which is given by Intercom. */ - private string $newsItemId; + private int $newsItemId; /** * @param array{ - * newsItemId: string, + * newsItemId: int, * } $values */ public function __construct( @@ -23,17 +23,17 @@ public function __construct( } /** - * @return string + * @return int */ - public function getNewsItemId(): string + public function getNewsItemId(): int { return $this->newsItemId; } /** - * @param string $value + * @param int $value */ - public function setNewsItemId(string $value): self + public function setNewsItemId(int $value): self { $this->newsItemId = $value; return $this; diff --git a/src/News/Items/Requests/FindNewsItemRequest.php b/src/News/Items/Requests/FindNewsItemRequest.php index c4ab230..9d019d4 100644 --- a/src/News/Items/Requests/FindNewsItemRequest.php +++ b/src/News/Items/Requests/FindNewsItemRequest.php @@ -7,13 +7,13 @@ class FindNewsItemRequest extends JsonSerializableType { /** - * @var string $newsItemId The unique identifier for the news item which is given by Intercom. + * @var int $newsItemId The unique identifier for the news item which is given by Intercom. */ - private string $newsItemId; + private int $newsItemId; /** * @param array{ - * newsItemId: string, + * newsItemId: int, * } $values */ public function __construct( @@ -23,17 +23,17 @@ public function __construct( } /** - * @return string + * @return int */ - public function getNewsItemId(): string + public function getNewsItemId(): int { return $this->newsItemId; } /** - * @param string $value + * @param int $value */ - public function setNewsItemId(string $value): self + public function setNewsItemId(int $value): self { $this->newsItemId = $value; return $this; diff --git a/src/News/Items/Requests/UpdateNewsItemRequest.php b/src/News/Items/Requests/UpdateNewsItemRequest.php index ee86162..79d0c2c 100644 --- a/src/News/Items/Requests/UpdateNewsItemRequest.php +++ b/src/News/Items/Requests/UpdateNewsItemRequest.php @@ -8,9 +8,9 @@ class UpdateNewsItemRequest extends JsonSerializableType { /** - * @var string $newsItemId The unique identifier for the news item which is given by Intercom. + * @var int $newsItemId The unique identifier for the news item which is given by Intercom. */ - private string $newsItemId; + private int $newsItemId; /** * @var NewsItemRequest $body @@ -19,7 +19,7 @@ class UpdateNewsItemRequest extends JsonSerializableType /** * @param array{ - * newsItemId: string, + * newsItemId: int, * body: NewsItemRequest, * } $values */ @@ -31,17 +31,17 @@ public function __construct( } /** - * @return string + * @return int */ - public function getNewsItemId(): string + public function getNewsItemId(): int { return $this->newsItemId; } /** - * @param string $value + * @param int $value */ - public function setNewsItemId(string $value): self + public function setNewsItemId(int $value): self { $this->newsItemId = $value; return $this; diff --git a/src/News/Types/NewsItem.php b/src/News/Types/NewsItem.php index 9666a61..211b9e1 100644 --- a/src/News/Types/NewsItem.php +++ b/src/News/Types/NewsItem.php @@ -13,46 +13,40 @@ class NewsItem extends JsonSerializableType { /** - * @var 'news-item' $type The type of object. - */ - #[JsonProperty('type')] - private string $type; - - /** - * @var string $id The unique identifier for the news item which is given by Intercom. + * @var ?string $id The unique identifier for the news item which is given by Intercom. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $workspaceId The id of the workspace which the news item belongs to. + * @var ?string $workspaceId The id of the workspace which the news item belongs to. */ #[JsonProperty('workspace_id')] - private string $workspaceId; + private ?string $workspaceId; /** - * @var string $title The title of the news item. + * @var ?string $title The title of the news item. */ #[JsonProperty('title')] - private string $title; + private ?string $title; /** - * @var string $body The news item body, which may contain HTML. + * @var ?string $body The news item body, which may contain HTML. */ #[JsonProperty('body')] - private string $body; + private ?string $body; /** - * @var int $senderId The id of the sender of the news item. Must be a teammate on the workspace. + * @var ?int $senderId The id of the sender of the news item. Must be a teammate on the workspace. */ #[JsonProperty('sender_id')] - private int $senderId; + private ?int $senderId; /** - * @var value-of $state News items will not be visible to your users in the assigned newsfeeds until they are set live. + * @var ?value-of $state News items will not be visible to your users in the assigned newsfeeds until they are set live. */ #[JsonProperty('state')] - private string $state; + private ?string $state; /** * @var ?array $newsfeedAssignments A list of newsfeed_assignments to assign to the specified newsfeed. @@ -85,10 +79,10 @@ class NewsItem extends JsonSerializableType private ?bool $deliverSilently; /** - * @var int $createdAt Timestamp for when the news item was created. + * @var ?int $createdAt Timestamp for when the news item was created. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** * @var ?int $updatedAt Timestamp for when the news item was last updated. @@ -98,155 +92,136 @@ class NewsItem extends JsonSerializableType /** * @param array{ - * type: 'news-item', - * id: string, - * workspaceId: string, - * title: string, - * body: string, - * senderId: int, - * state: value-of, - * createdAt: int, + * id?: ?string, + * workspaceId?: ?string, + * title?: ?string, + * body?: ?string, + * senderId?: ?int, + * state?: ?value-of, * newsfeedAssignments?: ?array, * labels?: ?array, * coverImageUrl?: ?string, * reactions?: ?array, * deliverSilently?: ?bool, + * createdAt?: ?int, * updatedAt?: ?int, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->workspaceId = $values['workspaceId']; - $this->title = $values['title']; - $this->body = $values['body']; - $this->senderId = $values['senderId']; - $this->state = $values['state']; + $this->id = $values['id'] ?? null; + $this->workspaceId = $values['workspaceId'] ?? null; + $this->title = $values['title'] ?? null; + $this->body = $values['body'] ?? null; + $this->senderId = $values['senderId'] ?? null; + $this->state = $values['state'] ?? null; $this->newsfeedAssignments = $values['newsfeedAssignments'] ?? null; $this->labels = $values['labels'] ?? null; $this->coverImageUrl = $values['coverImageUrl'] ?? null; $this->reactions = $values['reactions'] ?? null; $this->deliverSilently = $values['deliverSilently'] ?? null; - $this->createdAt = $values['createdAt']; + $this->createdAt = $values['createdAt'] ?? null; $this->updatedAt = $values['updatedAt'] ?? null; } /** - * @return 'news-item' - */ - public function getType(): string - { - return $this->type; - } - - /** - * @param 'news-item' $value - */ - public function setType(string $value): self - { - $this->type = $value; - return $this; - } - - /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getWorkspaceId(): string + public function getWorkspaceId(): ?string { return $this->workspaceId; } /** - * @param string $value + * @param ?string $value */ - public function setWorkspaceId(string $value): self + public function setWorkspaceId(?string $value = null): self { $this->workspaceId = $value; return $this; } /** - * @return string + * @return ?string */ - public function getTitle(): string + public function getTitle(): ?string { return $this->title; } /** - * @param string $value + * @param ?string $value */ - public function setTitle(string $value): self + public function setTitle(?string $value = null): self { $this->title = $value; return $this; } /** - * @return string + * @return ?string */ - public function getBody(): string + public function getBody(): ?string { return $this->body; } /** - * @param string $value + * @param ?string $value */ - public function setBody(string $value): self + public function setBody(?string $value = null): self { $this->body = $value; return $this; } /** - * @return int + * @return ?int */ - public function getSenderId(): int + public function getSenderId(): ?int { return $this->senderId; } /** - * @param int $value + * @param ?int $value */ - public function setSenderId(int $value): self + public function setSenderId(?int $value = null): self { $this->senderId = $value; return $this; } /** - * @return value-of + * @return ?value-of */ - public function getState(): string + public function getState(): ?string { return $this->state; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setState(string $value): self + public function setState(?string $value = null): self { $this->state = $value; return $this; @@ -338,17 +313,17 @@ public function setDeliverSilently(?bool $value = null): self } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; diff --git a/src/News/Types/Newsfeed.php b/src/News/Types/Newsfeed.php index 76e4150..9dc0c49 100644 --- a/src/News/Types/Newsfeed.php +++ b/src/News/Types/Newsfeed.php @@ -13,28 +13,22 @@ class Newsfeed extends JsonSerializableType { /** - * @var string $id The unique identifier for the newsfeed which is given by Intercom. + * @var ?string $id The unique identifier for the newsfeed which is given by Intercom. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var 'newsfeed' $type The type of object. - */ - #[JsonProperty('type')] - private string $type; - - /** - * @var string $name The name of the newsfeed. This name will never be visible to your users. + * @var ?string $name The name of the newsfeed. This name will never be visible to your users. */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var int $createdAt Timestamp for when the newsfeed was created. + * @var ?int $createdAt Timestamp for when the newsfeed was created. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** * @var ?int $updatedAt Timestamp for when the newsfeed was last updated. @@ -44,86 +38,67 @@ class Newsfeed extends JsonSerializableType /** * @param array{ - * id: string, - * type: 'newsfeed', - * name: string, - * createdAt: int, + * id?: ?string, + * name?: ?string, + * createdAt?: ?int, * updatedAt?: ?int, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->id = $values['id']; - $this->type = $values['type']; - $this->name = $values['name']; - $this->createdAt = $values['createdAt']; + $this->id = $values['id'] ?? null; + $this->name = $values['name'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; $this->updatedAt = $values['updatedAt'] ?? null; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return 'newsfeed' - */ - public function getType(): string - { - return $this->type; - } - - /** - * @param 'newsfeed' $value - */ - public function setType(string $value): self - { - $this->type = $value; - return $this; - } - - /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; diff --git a/src/News/Types/NewsfeedAssignment.php b/src/News/Types/NewsfeedAssignment.php index eff051f..58995f6 100644 --- a/src/News/Types/NewsfeedAssignment.php +++ b/src/News/Types/NewsfeedAssignment.php @@ -11,59 +11,59 @@ class NewsfeedAssignment extends JsonSerializableType { /** - * @var int $newsfeedId The unique identifier for the newsfeed which is given by Intercom. Publish dates cannot be in the future, to schedule news items use the dedicated feature in app (see this article). + * @var ?int $newsfeedId The unique identifier for the newsfeed which is given by Intercom. Publish dates cannot be in the future, to schedule news items use the dedicated feature in app (see this article). */ #[JsonProperty('newsfeed_id')] - private int $newsfeedId; + private ?int $newsfeedId; /** - * @var int $publishedAt Publish date of the news item on the newsfeed, use this field if you want to set a publish date in the past (e.g. when importing existing news items). On write, this field will be ignored if the news item state is "draft". + * @var ?int $publishedAt Publish date of the news item on the newsfeed, use this field if you want to set a publish date in the past (e.g. when importing existing news items). On write, this field will be ignored if the news item state is "draft". */ #[JsonProperty('published_at')] - private int $publishedAt; + private ?int $publishedAt; /** * @param array{ - * newsfeedId: int, - * publishedAt: int, + * newsfeedId?: ?int, + * publishedAt?: ?int, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->newsfeedId = $values['newsfeedId']; - $this->publishedAt = $values['publishedAt']; + $this->newsfeedId = $values['newsfeedId'] ?? null; + $this->publishedAt = $values['publishedAt'] ?? null; } /** - * @return int + * @return ?int */ - public function getNewsfeedId(): int + public function getNewsfeedId(): ?int { return $this->newsfeedId; } /** - * @param int $value + * @param ?int $value */ - public function setNewsfeedId(int $value): self + public function setNewsfeedId(?int $value = null): self { $this->newsfeedId = $value; return $this; } /** - * @return int + * @return ?int */ - public function getPublishedAt(): int + public function getPublishedAt(): ?int { return $this->publishedAt; } /** - * @param int $value + * @param ?int $value */ - public function setPublishedAt(int $value): self + public function setPublishedAt(?int $value = null): self { $this->publishedAt = $value; return $this; diff --git a/src/Notes/Requests/FindNoteRequest.php b/src/Notes/Requests/FindNoteRequest.php index 1e3cede..7142d97 100644 --- a/src/Notes/Requests/FindNoteRequest.php +++ b/src/Notes/Requests/FindNoteRequest.php @@ -7,13 +7,13 @@ class FindNoteRequest extends JsonSerializableType { /** - * @var string $noteId The unique identifier of a given note + * @var int $noteId The unique identifier of a given note */ - private string $noteId; + private int $noteId; /** * @param array{ - * noteId: string, + * noteId: int, * } $values */ public function __construct( @@ -23,17 +23,17 @@ public function __construct( } /** - * @return string + * @return int */ - public function getNoteId(): string + public function getNoteId(): int { return $this->noteId; } /** - * @param string $value + * @param int $value */ - public function setNoteId(string $value): self + public function setNoteId(int $value): self { $this->noteId = $value; return $this; diff --git a/src/Notes/Types/Note.php b/src/Notes/Types/Note.php index f1cf502..5e47daa 100644 --- a/src/Notes/Types/Note.php +++ b/src/Notes/Types/Note.php @@ -12,22 +12,22 @@ class Note extends JsonSerializableType { /** - * @var 'note' $type String representing the object's type. Always has the value `note`. + * @var ?string $type String representing the object's type. Always has the value `note`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The id of the note. + * @var ?string $id The id of the note. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var int $createdAt The time the note was created. + * @var ?int $createdAt The time the note was created. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** * @var ?NoteContact $contact Represents the contact that the note was created about. @@ -36,84 +36,84 @@ class Note extends JsonSerializableType private ?NoteContact $contact; /** - * @var Admin $author Optional. Represents the Admin that created the note. + * @var ?Admin $author Optional. Represents the Admin that created the note. */ #[JsonProperty('author')] - private Admin $author; + private ?Admin $author; /** - * @var string $body The body text of the note. + * @var ?string $body The body text of the note. */ #[JsonProperty('body')] - private string $body; + private ?string $body; /** * @param array{ - * type: 'note', - * id: string, - * createdAt: int, - * author: Admin, - * body: string, + * type?: ?string, + * id?: ?string, + * createdAt?: ?int, * contact?: ?NoteContact, + * author?: ?Admin, + * body?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->createdAt = $values['createdAt']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; $this->contact = $values['contact'] ?? null; - $this->author = $values['author']; - $this->body = $values['body']; + $this->author = $values['author'] ?? null; + $this->body = $values['body'] ?? null; } /** - * @return 'note' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'note' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; @@ -137,34 +137,34 @@ public function setContact(?NoteContact $value = null): self } /** - * @return Admin + * @return ?Admin */ - public function getAuthor(): Admin + public function getAuthor(): ?Admin { return $this->author; } /** - * @param Admin $value + * @param ?Admin $value */ - public function setAuthor(Admin $value): self + public function setAuthor(?Admin $value = null): self { $this->author = $value; return $this; } /** - * @return string + * @return ?string */ - public function getBody(): string + public function getBody(): ?string { return $this->body; } /** - * @param string $value + * @param ?string $value */ - public function setBody(string $value): self + public function setBody(?string $value = null): self { $this->body = $value; return $this; diff --git a/src/Notes/Types/NoteContact.php b/src/Notes/Types/NoteContact.php index fc3623b..d6b0fc1 100644 --- a/src/Notes/Types/NoteContact.php +++ b/src/Notes/Types/NoteContact.php @@ -11,7 +11,7 @@ class NoteContact extends JsonSerializableType { /** - * @var ?'contact' $type String representing the object's type. Always has the value `contact`. + * @var ?string $type String representing the object's type. Always has the value `contact`. */ #[JsonProperty('type')] private ?string $type; @@ -24,7 +24,7 @@ class NoteContact extends JsonSerializableType /** * @param array{ - * type?: ?'contact', + * type?: ?string, * id?: ?string, * } $values */ @@ -36,7 +36,7 @@ public function __construct( } /** - * @return ?'contact' + * @return ?string */ public function getType(): ?string { @@ -44,7 +44,7 @@ public function getType(): ?string } /** - * @param ?'contact' $value + * @param ?string $value */ public function setType(?string $value = null): self { diff --git a/src/PhoneCallRedirects/PhoneCallRedirectsClient.php b/src/PhoneCallRedirects/PhoneCallRedirectsClient.php index bc05457..61a23b6 100644 --- a/src/PhoneCallRedirects/PhoneCallRedirectsClient.php +++ b/src/PhoneCallRedirects/PhoneCallRedirectsClient.php @@ -4,7 +4,7 @@ use GuzzleHttp\ClientInterface; use Intercom\Core\Client\RawClient; -use Intercom\PhoneCallRedirects\Requests\CreatePhoneCallRedirectRequest; +use Intercom\Types\CreatePhoneSwitchRequest; use Intercom\Types\PhoneSwitch; use Intercom\Exceptions\IntercomException; use Intercom\Exceptions\IntercomApiException; @@ -57,7 +57,7 @@ public function __construct( * * If custom attributes are specified, they will be added to the user or lead's custom data attributes. * - * @param CreatePhoneCallRedirectRequest $request + * @param ?CreatePhoneSwitchRequest $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -66,11 +66,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return PhoneSwitch + * @return ?PhoneSwitch * @throws IntercomException * @throws IntercomApiException */ - public function create(CreatePhoneCallRedirectRequest $request, ?array $options = null): PhoneSwitch + public function create(?CreatePhoneSwitchRequest $request = null, ?array $options = null): ?PhoneSwitch { $options = array_merge($this->options, $options ?? []); try { @@ -86,6 +86,9 @@ public function create(CreatePhoneCallRedirectRequest $request, ?array $options $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return PhoneSwitch::fromJson($json); } } catch (JsonException $e) { diff --git a/src/Segments/Types/Segment.php b/src/Segments/Types/Segment.php index 77799c9..5dac3f5 100644 --- a/src/Segments/Types/Segment.php +++ b/src/Segments/Types/Segment.php @@ -11,28 +11,28 @@ class Segment extends JsonSerializableType { /** - * @var 'segment' $type The type of object. + * @var ?'segment' $type The type of object. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The unique identifier representing the segment. + * @var ?string $id The unique identifier representing the segment. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $name The name of the segment. + * @var ?string $name The name of the segment. */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var int $createdAt The time the segment was created. + * @var ?int $createdAt The time the segment was created. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** * @var ?int $updatedAt The time the segment was updated. @@ -41,10 +41,10 @@ class Segment extends JsonSerializableType private ?int $updatedAt; /** - * @var value-of $personType Type of the contact: contact (lead) or user. + * @var ?value-of $personType Type of the contact: contact (lead) or user. */ #[JsonProperty('person_type')] - private string $personType; + private ?string $personType; /** * @var ?int $count The number of items in the user segment. It's returned when `include_count=true` is included in the request. @@ -54,90 +54,90 @@ class Segment extends JsonSerializableType /** * @param array{ - * type: 'segment', - * id: string, - * name: string, - * createdAt: int, - * personType: value-of, + * type?: ?'segment', + * id?: ?string, + * name?: ?string, + * createdAt?: ?int, * updatedAt?: ?int, + * personType?: ?value-of, * count?: ?int, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->name = $values['name']; - $this->createdAt = $values['createdAt']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->name = $values['name'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; $this->updatedAt = $values['updatedAt'] ?? null; - $this->personType = $values['personType']; + $this->personType = $values['personType'] ?? null; $this->count = $values['count'] ?? null; } /** - * @return 'segment' + * @return ?'segment' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'segment' $value + * @param ?'segment' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; @@ -161,17 +161,17 @@ public function setUpdatedAt(?int $value = null): self } /** - * @return value-of + * @return ?value-of */ - public function getPersonType(): string + public function getPersonType(): ?string { return $this->personType; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setPersonType(string $value): self + public function setPersonType(?string $value = null): self { $this->personType = $value; return $this; diff --git a/src/SubscriptionTypes/Types/SubscriptionType.php b/src/SubscriptionTypes/Types/SubscriptionType.php index f2f03cb..78c12fd 100644 --- a/src/SubscriptionTypes/Types/SubscriptionType.php +++ b/src/SubscriptionTypes/Types/SubscriptionType.php @@ -13,184 +13,184 @@ class SubscriptionType extends JsonSerializableType { /** - * @var 'subscription' $type The type of the object - subscription + * @var ?'subscription' $type The type of the object - subscription */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The unique identifier representing the subscription type. + * @var ?string $id The unique identifier representing the subscription type. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var value-of $state The state of the subscription type. + * @var ?value-of $state The state of the subscription type. */ #[JsonProperty('state')] - private string $state; + private ?string $state; /** - * @var Translation $defaultTranslation + * @var ?Translation $defaultTranslation */ #[JsonProperty('default_translation')] - private Translation $defaultTranslation; + private ?Translation $defaultTranslation; /** - * @var array $translations An array of translations objects with the localised version of the subscription type in each available locale within your translation settings. + * @var ?array $translations An array of translations objects with the localised version of the subscription type in each available locale within your translation settings. */ #[JsonProperty('translations'), ArrayType([Translation::class])] - private array $translations; + private ?array $translations; /** - * @var value-of $consentType Describes the type of consent. + * @var ?value-of $consentType Describes the type of consent. */ #[JsonProperty('consent_type')] - private string $consentType; + private ?string $consentType; /** - * @var array> $contentTypes The message types that this subscription supports - can contain `email` or `sms_message`. + * @var ?array> $contentTypes The message types that this subscription supports - can contain `email` or `sms_message`. */ #[JsonProperty('content_types'), ArrayType(['string'])] - private array $contentTypes; + private ?array $contentTypes; /** * @param array{ - * type: 'subscription', - * id: string, - * state: value-of, - * defaultTranslation: Translation, - * translations: array, - * consentType: value-of, - * contentTypes: array>, + * type?: ?'subscription', + * id?: ?string, + * state?: ?value-of, + * defaultTranslation?: ?Translation, + * translations?: ?array, + * consentType?: ?value-of, + * contentTypes?: ?array>, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->state = $values['state']; - $this->defaultTranslation = $values['defaultTranslation']; - $this->translations = $values['translations']; - $this->consentType = $values['consentType']; - $this->contentTypes = $values['contentTypes']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->state = $values['state'] ?? null; + $this->defaultTranslation = $values['defaultTranslation'] ?? null; + $this->translations = $values['translations'] ?? null; + $this->consentType = $values['consentType'] ?? null; + $this->contentTypes = $values['contentTypes'] ?? null; } /** - * @return 'subscription' + * @return ?'subscription' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'subscription' $value + * @param ?'subscription' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return value-of + * @return ?value-of */ - public function getState(): string + public function getState(): ?string { return $this->state; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setState(string $value): self + public function setState(?string $value = null): self { $this->state = $value; return $this; } /** - * @return Translation + * @return ?Translation */ - public function getDefaultTranslation(): Translation + public function getDefaultTranslation(): ?Translation { return $this->defaultTranslation; } /** - * @param Translation $value + * @param ?Translation $value */ - public function setDefaultTranslation(Translation $value): self + public function setDefaultTranslation(?Translation $value = null): self { $this->defaultTranslation = $value; return $this; } /** - * @return array + * @return ?array */ - public function getTranslations(): array + public function getTranslations(): ?array { return $this->translations; } /** - * @param array $value + * @param ?array $value */ - public function setTranslations(array $value): self + public function setTranslations(?array $value = null): self { $this->translations = $value; return $this; } /** - * @return value-of + * @return ?value-of */ - public function getConsentType(): string + public function getConsentType(): ?string { return $this->consentType; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setConsentType(string $value): self + public function setConsentType(?string $value = null): self { $this->consentType = $value; return $this; } /** - * @return array> + * @return ?array> */ - public function getContentTypes(): array + public function getContentTypes(): ?array { return $this->contentTypes; } /** - * @param array> $value + * @param ?array> $value */ - public function setContentTypes(array $value): self + public function setContentTypes(?array $value = null): self { $this->contentTypes = $value; return $this; diff --git a/src/Tags/Requests/UntagConversationRequest.php b/src/Tags/Requests/UntagConversationRequest.php index 04f641e..5ea02a2 100644 --- a/src/Tags/Requests/UntagConversationRequest.php +++ b/src/Tags/Requests/UntagConversationRequest.php @@ -13,7 +13,7 @@ class UntagConversationRequest extends JsonSerializableType private string $conversationId; /** - * @var string $tagId id + * @var string $tagId tag_id */ private string $tagId; diff --git a/src/Tags/Types/TagBasic.php b/src/Tags/Types/TagBasic.php new file mode 100644 index 0000000..db26e45 --- /dev/null +++ b/src/Tags/Types/TagBasic.php @@ -0,0 +1,104 @@ +type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->name = $values['name'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Teams/Types/Team.php b/src/Teams/Types/Team.php index 7c4dd31..4c7879d 100644 --- a/src/Teams/Types/Team.php +++ b/src/Teams/Types/Team.php @@ -13,28 +13,28 @@ class Team extends JsonSerializableType { /** - * @var 'team' $type Value is always "team" + * @var ?string $type Value is always "team" */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The id of the team + * @var ?string $id The id of the team */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $name The name of the team + * @var ?string $name The name of the team */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var array $adminIds The list of admin IDs that are a part of the team. + * @var ?array $adminIds The list of admin IDs that are a part of the team. */ #[JsonProperty('admin_ids'), ArrayType(['integer'])] - private array $adminIds; + private ?array $adminIds; /** * @var ?AdminPriorityLevel $adminPriorityLevel @@ -44,86 +44,86 @@ class Team extends JsonSerializableType /** * @param array{ - * type: 'team', - * id: string, - * name: string, - * adminIds: array, + * type?: ?string, + * id?: ?string, + * name?: ?string, + * adminIds?: ?array, * adminPriorityLevel?: ?AdminPriorityLevel, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->name = $values['name']; - $this->adminIds = $values['adminIds']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->name = $values['name'] ?? null; + $this->adminIds = $values['adminIds'] ?? null; $this->adminPriorityLevel = $values['adminPriorityLevel'] ?? null; } /** - * @return 'team' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'team' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return array + * @return ?array */ - public function getAdminIds(): array + public function getAdminIds(): ?array { return $this->adminIds; } /** - * @param array $value + * @param ?array $value */ - public function setAdminIds(array $value): self + public function setAdminIds(?array $value = null): self { $this->adminIds = $value; return $this; diff --git a/src/TicketStates/TicketStatesClient.php b/src/TicketStates/TicketStatesClient.php new file mode 100644 index 0000000..de1568c --- /dev/null +++ b/src/TicketStates/TicketStatesClient.php @@ -0,0 +1,106 @@ +, + * } $options + */ + private array $options; + + /** + * @var RawClient $client + */ + private RawClient $client; + + /** + * @param RawClient $client + * @param ?array{ + * baseUrl?: string, + * client?: ClientInterface, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * } $options + */ + public function __construct( + RawClient $client, + ?array $options = null, + ) { + $this->client = $client; + $this->options = $options ?? []; + } + + /** + * You can get a list of all ticket states for a workspace. + * + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return TicketStateList + * @throws IntercomException + * @throws IntercomApiException + */ + public function listTicketStates(?array $options = null): TicketStateList + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "ticket_states", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return TicketStateList::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } +} diff --git a/src/TicketTypes/Attributes/AttributesClient.php b/src/TicketTypes/Attributes/AttributesClient.php index 4ce5155..e13a491 100644 --- a/src/TicketTypes/Attributes/AttributesClient.php +++ b/src/TicketTypes/Attributes/AttributesClient.php @@ -64,11 +64,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return TicketTypeAttribute + * @return ?TicketTypeAttribute * @throws IntercomException * @throws IntercomApiException */ - public function create(CreateTicketTypeAttributeRequest $request, ?array $options = null): TicketTypeAttribute + public function create(CreateTicketTypeAttributeRequest $request, ?array $options = null): ?TicketTypeAttribute { $options = array_merge($this->options, $options ?? []); try { @@ -84,6 +84,9 @@ public function create(CreateTicketTypeAttributeRequest $request, ?array $option $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return TicketTypeAttribute::fromJson($json); } } catch (JsonException $e) { @@ -120,11 +123,11 @@ public function create(CreateTicketTypeAttributeRequest $request, ?array $option * queryParameters?: array, * bodyProperties?: array, * } $options - * @return TicketTypeAttribute + * @return ?TicketTypeAttribute * @throws IntercomException * @throws IntercomApiException */ - public function update(UpdateTicketTypeAttributeRequest $request, ?array $options = null): TicketTypeAttribute + public function update(UpdateTicketTypeAttributeRequest $request, ?array $options = null): ?TicketTypeAttribute { $options = array_merge($this->options, $options ?? []); try { @@ -140,6 +143,9 @@ public function update(UpdateTicketTypeAttributeRequest $request, ?array $option $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return TicketTypeAttribute::fromJson($json); } } catch (JsonException $e) { diff --git a/src/TicketTypes/Requests/UpdateTicketTypeRequest.php b/src/TicketTypes/Requests/UpdateTicketTypeRequest.php index d6d02f2..b3b7a62 100644 --- a/src/TicketTypes/Requests/UpdateTicketTypeRequest.php +++ b/src/TicketTypes/Requests/UpdateTicketTypeRequest.php @@ -4,7 +4,7 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; -use Intercom\TicketTypes\Types\UpdateTicketTypeRequestBodyCategory; +use Intercom\TicketTypes\Types\UpdateTicketTypeRequestCategory; class UpdateTicketTypeRequest extends JsonSerializableType { @@ -26,7 +26,7 @@ class UpdateTicketTypeRequest extends JsonSerializableType private ?string $description; /** - * @var ?value-of $category Category of the Ticket Type. + * @var ?value-of $category Category of the Ticket Type. */ #[JsonProperty('category')] private ?string $category; @@ -54,7 +54,7 @@ class UpdateTicketTypeRequest extends JsonSerializableType * ticketTypeId: string, * name?: ?string, * description?: ?string, - * category?: ?value-of, + * category?: ?value-of, * icon?: ?string, * archived?: ?bool, * isInternal?: ?bool, @@ -124,7 +124,7 @@ public function setDescription(?string $value = null): self } /** - * @return ?value-of + * @return ?value-of */ public function getCategory(): ?string { @@ -132,7 +132,7 @@ public function getCategory(): ?string } /** - * @param ?value-of $value + * @param ?value-of $value */ public function setCategory(?string $value = null): self { diff --git a/src/TicketTypes/TicketTypesClient.php b/src/TicketTypes/TicketTypesClient.php index 8b179fa..ea7b668 100644 --- a/src/TicketTypes/TicketTypesClient.php +++ b/src/TicketTypes/TicketTypesClient.php @@ -14,7 +14,7 @@ use JsonException; use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; -use Intercom\TicketTypes\Requests\CreateTicketTypeRequest; +use Intercom\Types\CreateTicketTypeRequest; use Intercom\Tickets\Types\TicketType; use Intercom\TicketTypes\Requests\FindTicketTypeRequest; use Intercom\TicketTypes\Requests\UpdateTicketTypeRequest; @@ -122,7 +122,7 @@ public function list(?array $options = null): TicketTypeList * > Every ticket type will be created with two default attributes: _default_title_ and _default_description_. * > For the `icon` propery, use an emoji from [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app/) * - * @param CreateTicketTypeRequest $request + * @param ?CreateTicketTypeRequest $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -131,11 +131,11 @@ public function list(?array $options = null): TicketTypeList * queryParameters?: array, * bodyProperties?: array, * } $options - * @return TicketType + * @return ?TicketType * @throws IntercomException * @throws IntercomApiException */ - public function create(CreateTicketTypeRequest $request, ?array $options = null): TicketType + public function create(?CreateTicketTypeRequest $request = null, ?array $options = null): ?TicketType { $options = array_merge($this->options, $options ?? []); try { @@ -151,6 +151,9 @@ public function create(CreateTicketTypeRequest $request, ?array $options = null) $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return TicketType::fromJson($json); } } catch (JsonException $e) { @@ -187,11 +190,11 @@ public function create(CreateTicketTypeRequest $request, ?array $options = null) * queryParameters?: array, * bodyProperties?: array, * } $options - * @return TicketType + * @return ?TicketType * @throws IntercomException * @throws IntercomApiException */ - public function get(FindTicketTypeRequest $request, ?array $options = null): TicketType + public function get(FindTicketTypeRequest $request, ?array $options = null): ?TicketType { $options = array_merge($this->options, $options ?? []); try { @@ -206,6 +209,9 @@ public function get(FindTicketTypeRequest $request, ?array $options = null): Tic $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return TicketType::fromJson($json); } } catch (JsonException $e) { @@ -247,11 +253,11 @@ public function get(FindTicketTypeRequest $request, ?array $options = null): Tic * queryParameters?: array, * bodyProperties?: array, * } $options - * @return TicketType + * @return ?TicketType * @throws IntercomException * @throws IntercomApiException */ - public function update(UpdateTicketTypeRequest $request, ?array $options = null): TicketType + public function update(UpdateTicketTypeRequest $request, ?array $options = null): ?TicketType { $options = array_merge($this->options, $options ?? []); try { @@ -267,6 +273,9 @@ public function update(UpdateTicketTypeRequest $request, ?array $options = null) $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return TicketType::fromJson($json); } } catch (JsonException $e) { diff --git a/src/Unstable/Types/UpdateTicketTypeRequestCategory.php b/src/TicketTypes/Types/UpdateTicketTypeRequestCategory.php similarity index 80% rename from src/Unstable/Types/UpdateTicketTypeRequestCategory.php rename to src/TicketTypes/Types/UpdateTicketTypeRequestCategory.php index afab4ff..8cbdebc 100644 --- a/src/Unstable/Types/UpdateTicketTypeRequestCategory.php +++ b/src/TicketTypes/Types/UpdateTicketTypeRequestCategory.php @@ -1,6 +1,6 @@ , + * skipNotifications?: ?bool, + * conversationToLinkId?: ?string, + * companyId?: ?string, + * createdAt?: ?int, + * assignment?: ?CreateTicketRequestAssignment, + * } $values + */ + public function __construct( + array $values, + ) { + $this->skipNotifications = $values['skipNotifications'] ?? null; + $this->ticketTypeId = $values['ticketTypeId']; + $this->contacts = $values['contacts']; + $this->conversationToLinkId = $values['conversationToLinkId'] ?? null; + $this->companyId = $values['companyId'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->assignment = $values['assignment'] ?? null; + } + + /** + * @return ?bool + */ + public function getSkipNotifications(): ?bool + { + return $this->skipNotifications; + } + + /** + * @param ?bool $value + */ + public function setSkipNotifications(?bool $value = null): self + { + $this->skipNotifications = $value; + return $this; + } +} diff --git a/src/Tickets/Requests/DeleteTicketRequest.php b/src/Tickets/Requests/DeleteTicketRequest.php new file mode 100644 index 0000000..baaf0c8 --- /dev/null +++ b/src/Tickets/Requests/DeleteTicketRequest.php @@ -0,0 +1,41 @@ +ticketId = $values['ticketId']; + } + + /** + * @return string + */ + public function getTicketId(): string + { + return $this->ticketId; + } + + /** + * @param string $value + */ + public function setTicketId(string $value): self + { + $this->ticketId = $value; + return $this; + } +} diff --git a/src/Tickets/Requests/EnqueueCreateTicketRequest.php b/src/Tickets/Requests/EnqueueCreateTicketRequest.php new file mode 100644 index 0000000..ae05130 --- /dev/null +++ b/src/Tickets/Requests/EnqueueCreateTicketRequest.php @@ -0,0 +1,66 @@ +, + * skipNotifications?: ?bool, + * conversationToLinkId?: ?string, + * companyId?: ?string, + * createdAt?: ?int, + * assignment?: ?CreateTicketRequestAssignment, + * } $values + */ + public function __construct( + array $values, + ) { + $this->skipNotifications = $values['skipNotifications'] ?? null; + $this->ticketTypeId = $values['ticketTypeId']; + $this->contacts = $values['contacts']; + $this->conversationToLinkId = $values['conversationToLinkId'] ?? null; + $this->companyId = $values['companyId'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->assignment = $values['assignment'] ?? null; + } + + /** + * @return ?bool + */ + public function getSkipNotifications(): ?bool + { + return $this->skipNotifications; + } + + /** + * @param ?bool $value + */ + public function setSkipNotifications(?bool $value = null): self + { + $this->skipNotifications = $value; + return $this; + } +} diff --git a/src/Tickets/Requests/UpdateTicketRequest.php b/src/Tickets/Requests/UpdateTicketRequest.php index ee986ee..97dc6cd 100644 --- a/src/Tickets/Requests/UpdateTicketRequest.php +++ b/src/Tickets/Requests/UpdateTicketRequest.php @@ -5,8 +5,6 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; use Intercom\Core\Types\ArrayType; -use Intercom\Tickets\Types\UpdateTicketRequestState; -use Intercom\Tickets\Types\UpdateTicketRequestAssignment; class UpdateTicketRequest extends JsonSerializableType { @@ -22,10 +20,16 @@ class UpdateTicketRequest extends JsonSerializableType private ?array $ticketAttributes; /** - * @var ?value-of $state The state of the ticket. + * @var ?string $ticketStateId The ID of the ticket state associated with the ticket type. */ - #[JsonProperty('state')] - private ?string $state; + #[JsonProperty('ticket_state_id')] + private ?string $ticketStateId; + + /** + * @var ?string $companyId The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom. Set to nil to remove company. + */ + #[JsonProperty('company_id')] + private ?string $companyId; /** * @var ?bool $open Specify if a ticket is open. Set to false to close a ticket. Closing a ticket will also unsnooze it. @@ -46,20 +50,28 @@ class UpdateTicketRequest extends JsonSerializableType private ?int $snoozedUntil; /** - * @var ?UpdateTicketRequestAssignment $assignment + * @var ?int $adminId The ID of the admin performing ticket update. Needed for workflows execution and attributing actions to specific admins. + */ + #[JsonProperty('admin_id')] + private ?int $adminId; + + /** + * @var ?string $assigneeId The ID of the admin or team to which the ticket is assigned. Set this 0 to unassign it. */ - #[JsonProperty('assignment')] - private ?UpdateTicketRequestAssignment $assignment; + #[JsonProperty('assignee_id')] + private ?string $assigneeId; /** * @param array{ * ticketId: string, * ticketAttributes?: ?array, - * state?: ?value-of, + * ticketStateId?: ?string, + * companyId?: ?string, * open?: ?bool, * isShared?: ?bool, * snoozedUntil?: ?int, - * assignment?: ?UpdateTicketRequestAssignment, + * adminId?: ?int, + * assigneeId?: ?string, * } $values */ public function __construct( @@ -67,11 +79,13 @@ public function __construct( ) { $this->ticketId = $values['ticketId']; $this->ticketAttributes = $values['ticketAttributes'] ?? null; - $this->state = $values['state'] ?? null; + $this->ticketStateId = $values['ticketStateId'] ?? null; + $this->companyId = $values['companyId'] ?? null; $this->open = $values['open'] ?? null; $this->isShared = $values['isShared'] ?? null; $this->snoozedUntil = $values['snoozedUntil'] ?? null; - $this->assignment = $values['assignment'] ?? null; + $this->adminId = $values['adminId'] ?? null; + $this->assigneeId = $values['assigneeId'] ?? null; } /** @@ -109,19 +123,36 @@ public function setTicketAttributes(?array $value = null): self } /** - * @return ?value-of + * @return ?string + */ + public function getTicketStateId(): ?string + { + return $this->ticketStateId; + } + + /** + * @param ?string $value + */ + public function setTicketStateId(?string $value = null): self + { + $this->ticketStateId = $value; + return $this; + } + + /** + * @return ?string */ - public function getState(): ?string + public function getCompanyId(): ?string { - return $this->state; + return $this->companyId; } /** - * @param ?value-of $value + * @param ?string $value */ - public function setState(?string $value = null): self + public function setCompanyId(?string $value = null): self { - $this->state = $value; + $this->companyId = $value; return $this; } @@ -177,19 +208,36 @@ public function setSnoozedUntil(?int $value = null): self } /** - * @return ?UpdateTicketRequestAssignment + * @return ?int + */ + public function getAdminId(): ?int + { + return $this->adminId; + } + + /** + * @param ?int $value + */ + public function setAdminId(?int $value = null): self + { + $this->adminId = $value; + return $this; + } + + /** + * @return ?string */ - public function getAssignment(): ?UpdateTicketRequestAssignment + public function getAssigneeId(): ?string { - return $this->assignment; + return $this->assigneeId; } /** - * @param ?UpdateTicketRequestAssignment $value + * @param ?string $value */ - public function setAssignment(?UpdateTicketRequestAssignment $value = null): self + public function setAssigneeId(?string $value = null): self { - $this->assignment = $value; + $this->assigneeId = $value; return $this; } } diff --git a/src/Tickets/TicketsClient.php b/src/Tickets/TicketsClient.php index 7b740ea..740bec6 100644 --- a/src/Tickets/TicketsClient.php +++ b/src/Tickets/TicketsClient.php @@ -14,10 +14,14 @@ use JsonException; use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; -use Intercom\Types\CreateTicketRequest; +use Intercom\Tickets\Requests\CreateTicketRequest; use Intercom\Tickets\Types\Ticket; +use Intercom\Tickets\Requests\EnqueueCreateTicketRequest; +use Intercom\Jobs\Types\Jobs; use Intercom\Tickets\Requests\FindTicketRequest; use Intercom\Tickets\Requests\UpdateTicketRequest; +use Intercom\Tickets\Requests\DeleteTicketRequest; +use Intercom\Tickets\Types\DeleteTicketResponse; use Intercom\Types\SearchRequest; use Intercom\Core\Pagination\Pager; use Intercom\Core\Pagination\CursorPager; @@ -128,11 +132,11 @@ public function reply(ReplyToTicketRequest $request, ?array $options = null): Ti * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Ticket + * @return ?Ticket * @throws IntercomException * @throws IntercomApiException */ - public function create(CreateTicketRequest $request, ?array $options = null): Ticket + public function create(CreateTicketRequest $request, ?array $options = null): ?Ticket { $options = array_merge($this->options, $options ?? []); try { @@ -148,6 +152,9 @@ public function create(CreateTicketRequest $request, ?array $options = null): Ti $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Ticket::fromJson($json); } } catch (JsonException $e) { @@ -172,6 +179,62 @@ public function create(CreateTicketRequest $request, ?array $options = null): Ti ); } + /** + * Enqueues ticket creation for asynchronous processing, returning if the job was enqueued successfully to be processed. We attempt to perform a best-effort validation on inputs before tasks are enqueued. If the given parameters are incorrect, we won't enqueue the job. + * + * @param EnqueueCreateTicketRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return Jobs + * @throws IntercomException + * @throws IntercomApiException + */ + public function enqueueCreateTicket(EnqueueCreateTicketRequest $request, ?array $options = null): Jobs + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "tickets/enqueue", + method: HttpMethod::POST, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return Jobs::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + /** * You can fetch the details of a single ticket. * @@ -184,11 +247,11 @@ public function create(CreateTicketRequest $request, ?array $options = null): Ti * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Ticket + * @return ?Ticket * @throws IntercomException * @throws IntercomApiException */ - public function get(FindTicketRequest $request, ?array $options = null): Ticket + public function get(FindTicketRequest $request, ?array $options = null): ?Ticket { $options = array_merge($this->options, $options ?? []); try { @@ -203,6 +266,9 @@ public function get(FindTicketRequest $request, ?array $options = null): Ticket $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Ticket::fromJson($json); } } catch (JsonException $e) { @@ -239,11 +305,11 @@ public function get(FindTicketRequest $request, ?array $options = null): Ticket * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Ticket + * @return ?Ticket * @throws IntercomException * @throws IntercomApiException */ - public function update(UpdateTicketRequest $request, ?array $options = null): Ticket + public function update(UpdateTicketRequest $request, ?array $options = null): ?Ticket { $options = array_merge($this->options, $options ?? []); try { @@ -259,6 +325,9 @@ public function update(UpdateTicketRequest $request, ?array $options = null): Ti $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Ticket::fromJson($json); } } catch (JsonException $e) { @@ -283,6 +352,61 @@ public function update(UpdateTicketRequest $request, ?array $options = null): Ti ); } + /** + * You can delete a ticket using the Intercom provided ID. + * + * @param DeleteTicketRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return DeleteTicketResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function deleteTicket(DeleteTicketRequest $request, ?array $options = null): DeleteTicketResponse + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "tickets/{$request->getTicketId()}", + method: HttpMethod::DELETE, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return DeleteTicketResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + /** * You can search for multiple tickets by the value of their attributes in order to fetch exactly which ones you want. * @@ -306,6 +430,7 @@ public function update(UpdateTicketRequest $request, ?array $options = null): Ti * ### Accepted Fields * * Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foobar"`). + * The `source.body` field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a `"I need support"` body - the query should contain a `=` operator with the value `"support"` for such conversation to be returned. A query with a `=` operator and a `"need support"` value will not yield a result. * * | Field | Type | * | :---------------------------------------- | :--------------------------------------------------------------------------------------- | @@ -325,6 +450,13 @@ public function update(UpdateTicketRequest $request, ?array $options = null): Ti * | snoozed_until | Date (UNIX timestamp) | * | ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer | * + * {% admonition type="info" name="Searching by Category" %} + * When searching for tickets by the **`category`** field, specific terms must be used instead of the category names: + * * For **Customer** category tickets, use the term `request`. + * * For **Back-office** category tickets, use the term `task`. + * * For **Tracker** category tickets, use the term `tracker`. + * {% /admonition %} + * * ### Accepted Operators * * {% admonition type="info" name="Searching based on `created_at`" %} @@ -355,7 +487,7 @@ public function update(UpdateTicketRequest $request, ?array $options = null): Ti * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Pager + * @return Pager */ public function search(SearchRequest $request, ?array $options = null): Pager { @@ -395,6 +527,7 @@ public function search(SearchRequest $request, ?array $options = null): Pager * ### Accepted Fields * * Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foobar"`). + * The `source.body` field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a `"I need support"` body - the query should contain a `=` operator with the value `"support"` for such conversation to be returned. A query with a `=` operator and a `"need support"` value will not yield a result. * * | Field | Type | * | :---------------------------------------- | :--------------------------------------------------------------------------------------- | @@ -414,6 +547,13 @@ public function search(SearchRequest $request, ?array $options = null): Pager * | snoozed_until | Date (UNIX timestamp) | * | ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer | * + * {% admonition type="info" name="Searching by Category" %} + * When searching for tickets by the **`category`** field, specific terms must be used instead of the category names: + * * For **Customer** category tickets, use the term `request`. + * * For **Back-office** category tickets, use the term `task`. + * * For **Tracker** category tickets, use the term `tracker`. + * {% /admonition %} + * * ### Accepted Operators * * {% admonition type="info" name="Searching based on `created_at`" %} diff --git a/src/Tickets/Types/DeleteTicketResponse.php b/src/Tickets/Types/DeleteTicketResponse.php new file mode 100644 index 0000000..8bd5bc3 --- /dev/null +++ b/src/Tickets/Types/DeleteTicketResponse.php @@ -0,0 +1,104 @@ +id = $values['id'] ?? null; + $this->object = $values['object'] ?? null; + $this->deleted = $values['deleted'] ?? null; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?'ticket' + */ + public function getObject(): ?string + { + return $this->object; + } + + /** + * @param ?'ticket' $value + */ + public function setObject(?string $value = null): self + { + $this->object = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getDeleted(): ?bool + { + return $this->deleted; + } + + /** + * @param ?bool $value + */ + public function setDeleted(?bool $value = null): self + { + $this->deleted = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Tickets/Types/Ticket.php b/src/Tickets/Types/Ticket.php index 4e3cdf8..55be236 100644 --- a/src/Tickets/Types/Ticket.php +++ b/src/Tickets/Types/Ticket.php @@ -14,52 +14,52 @@ class Ticket extends JsonSerializableType { /** - * @var 'ticket' $type Always ticket + * @var ?'ticket' $type Always ticket */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The unique identifier for the ticket which is given by Intercom. + * @var ?string $id The unique identifier for the ticket which is given by Intercom. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $ticketId The ID of the Ticket used in the Intercom Inbox and Messenger. Do not use ticket_id for API queries. + * @var ?string $ticketId The ID of the Ticket used in the Intercom Inbox and Messenger. Do not use ticket_id for API queries. */ #[JsonProperty('ticket_id')] - private string $ticketId; + private ?string $ticketId; /** - * @var value-of $category Category of the Ticket. + * @var ?value-of $category Category of the Ticket. */ #[JsonProperty('category')] - private string $category; + private ?string $category; /** - * @var array $ticketAttributes + * @var ?array $ticketAttributes */ #[JsonProperty('ticket_attributes'), ArrayType(['string' => 'mixed'])] - private array $ticketAttributes; + private ?array $ticketAttributes; /** - * @var value-of $ticketState The state the ticket is currently in + * @var ?TicketState $ticketState */ #[JsonProperty('ticket_state')] - private string $ticketState; + private ?TicketState $ticketState; /** - * @var TicketType $ticketType + * @var ?TicketType $ticketType */ #[JsonProperty('ticket_type')] - private TicketType $ticketType; + private ?TicketType $ticketType; /** - * @var TicketContacts $contacts + * @var ?TicketContacts $contacts */ #[JsonProperty('contacts')] - private TicketContacts $contacts; + private ?TicketContacts $contacts; /** * @var ?string $adminAssigneeId The id representing the admin assigned to the ticket. @@ -115,28 +115,16 @@ class Ticket extends JsonSerializableType #[JsonProperty('is_shared')] private ?bool $isShared; - /** - * @var ?string $ticketStateInternalLabel The state the ticket is currently in, in a human readable form - visible in Intercom - */ - #[JsonProperty('ticket_state_internal_label')] - private ?string $ticketStateInternalLabel; - - /** - * @var ?string $ticketStateExternalLabel The state the ticket is currently in, in a human readable form - visible to customers, in the messenger, email and tickets portal. - */ - #[JsonProperty('ticket_state_external_label')] - private ?string $ticketStateExternalLabel; - /** * @param array{ - * type: 'ticket', - * id: string, - * ticketId: string, - * category: value-of, - * ticketAttributes: array, - * ticketState: value-of, - * ticketType: TicketType, - * contacts: TicketContacts, + * type?: ?'ticket', + * id?: ?string, + * ticketId?: ?string, + * category?: ?value-of, + * ticketAttributes?: ?array, + * ticketState?: ?TicketState, + * ticketType?: ?TicketType, + * contacts?: ?TicketContacts, * adminAssigneeId?: ?string, * teamAssigneeId?: ?string, * createdAt?: ?int, @@ -146,21 +134,19 @@ class Ticket extends JsonSerializableType * linkedObjects?: ?LinkedObjectList, * ticketParts?: ?TicketParts, * isShared?: ?bool, - * ticketStateInternalLabel?: ?string, - * ticketStateExternalLabel?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->ticketId = $values['ticketId']; - $this->category = $values['category']; - $this->ticketAttributes = $values['ticketAttributes']; - $this->ticketState = $values['ticketState']; - $this->ticketType = $values['ticketType']; - $this->contacts = $values['contacts']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->ticketId = $values['ticketId'] ?? null; + $this->category = $values['category'] ?? null; + $this->ticketAttributes = $values['ticketAttributes'] ?? null; + $this->ticketState = $values['ticketState'] ?? null; + $this->ticketType = $values['ticketType'] ?? null; + $this->contacts = $values['contacts'] ?? null; $this->adminAssigneeId = $values['adminAssigneeId'] ?? null; $this->teamAssigneeId = $values['teamAssigneeId'] ?? null; $this->createdAt = $values['createdAt'] ?? null; @@ -170,141 +156,139 @@ public function __construct( $this->linkedObjects = $values['linkedObjects'] ?? null; $this->ticketParts = $values['ticketParts'] ?? null; $this->isShared = $values['isShared'] ?? null; - $this->ticketStateInternalLabel = $values['ticketStateInternalLabel'] ?? null; - $this->ticketStateExternalLabel = $values['ticketStateExternalLabel'] ?? null; } /** - * @return 'ticket' + * @return ?'ticket' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'ticket' $value + * @param ?'ticket' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getTicketId(): string + public function getTicketId(): ?string { return $this->ticketId; } /** - * @param string $value + * @param ?string $value */ - public function setTicketId(string $value): self + public function setTicketId(?string $value = null): self { $this->ticketId = $value; return $this; } /** - * @return value-of + * @return ?value-of */ - public function getCategory(): string + public function getCategory(): ?string { return $this->category; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setCategory(string $value): self + public function setCategory(?string $value = null): self { $this->category = $value; return $this; } /** - * @return array + * @return ?array */ - public function getTicketAttributes(): array + public function getTicketAttributes(): ?array { return $this->ticketAttributes; } /** - * @param array $value + * @param ?array $value */ - public function setTicketAttributes(array $value): self + public function setTicketAttributes(?array $value = null): self { $this->ticketAttributes = $value; return $this; } /** - * @return value-of + * @return ?TicketState */ - public function getTicketState(): string + public function getTicketState(): ?TicketState { return $this->ticketState; } /** - * @param value-of $value + * @param ?TicketState $value */ - public function setTicketState(string $value): self + public function setTicketState(?TicketState $value = null): self { $this->ticketState = $value; return $this; } /** - * @return TicketType + * @return ?TicketType */ - public function getTicketType(): TicketType + public function getTicketType(): ?TicketType { return $this->ticketType; } /** - * @param TicketType $value + * @param ?TicketType $value */ - public function setTicketType(TicketType $value): self + public function setTicketType(?TicketType $value = null): self { $this->ticketType = $value; return $this; } /** - * @return TicketContacts + * @return ?TicketContacts */ - public function getContacts(): TicketContacts + public function getContacts(): ?TicketContacts { return $this->contacts; } /** - * @param TicketContacts $value + * @param ?TicketContacts $value */ - public function setContacts(TicketContacts $value): self + public function setContacts(?TicketContacts $value = null): self { $this->contacts = $value; return $this; @@ -463,40 +447,6 @@ public function setIsShared(?bool $value = null): self return $this; } - /** - * @return ?string - */ - public function getTicketStateInternalLabel(): ?string - { - return $this->ticketStateInternalLabel; - } - - /** - * @param ?string $value - */ - public function setTicketStateInternalLabel(?string $value = null): self - { - $this->ticketStateInternalLabel = $value; - return $this; - } - - /** - * @return ?string - */ - public function getTicketStateExternalLabel(): ?string - { - return $this->ticketStateExternalLabel; - } - - /** - * @param ?string $value - */ - public function setTicketStateExternalLabel(?string $value = null): self - { - $this->ticketStateExternalLabel = $value; - return $this; - } - /** * @return string */ diff --git a/src/Tickets/Types/TicketContacts.php b/src/Tickets/Types/TicketContacts.php index 593c9f7..34c40e1 100644 --- a/src/Tickets/Types/TicketContacts.php +++ b/src/Tickets/Types/TicketContacts.php @@ -13,59 +13,59 @@ class TicketContacts extends JsonSerializableType { /** - * @var 'contact.list' $type always contact.list + * @var ?'contact.list' $type always contact.list */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $contacts The list of contacts affected by this ticket. + * @var ?array $contacts The list of contacts affected by this ticket. */ #[JsonProperty('contacts'), ArrayType([ContactReference::class])] - private array $contacts; + private ?array $contacts; /** * @param array{ - * type: 'contact.list', - * contacts: array, + * type?: ?'contact.list', + * contacts?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->contacts = $values['contacts']; + $this->type = $values['type'] ?? null; + $this->contacts = $values['contacts'] ?? null; } /** - * @return 'contact.list' + * @return ?'contact.list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'contact.list' $value + * @param ?'contact.list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getContacts(): array + public function getContacts(): ?array { return $this->contacts; } /** - * @param array $value + * @param ?array $value */ - public function setContacts(array $value): self + public function setContacts(?array $value = null): self { $this->contacts = $value; return $this; diff --git a/src/Tickets/Types/TicketPart.php b/src/Tickets/Types/TicketPart.php index cdccddd..d522f6d 100644 --- a/src/Tickets/Types/TicketPart.php +++ b/src/Tickets/Types/TicketPart.php @@ -15,22 +15,22 @@ class TicketPart extends JsonSerializableType { /** - * @var 'ticket_part' $type Always ticket_part + * @var ?string $type Always ticket_part */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The id representing the ticket part. + * @var ?string $id The id representing the ticket part. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $partType The type of ticket part. + * @var ?string $partType The type of ticket part. */ #[JsonProperty('part_type')] - private string $partType; + private ?string $partType; /** * @var ?string $body The message body, which may contain HTML. @@ -45,16 +45,16 @@ class TicketPart extends JsonSerializableType private ?string $previousTicketState; /** - * @var value-of $ticketState The state of the ticket. + * @var ?value-of $ticketState The state of the ticket. */ #[JsonProperty('ticket_state')] - private string $ticketState; + private ?string $ticketState; /** - * @var int $createdAt The time the ticket part was created. + * @var ?int $createdAt The time the ticket part was created. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** * @var ?int $updatedAt The last time the ticket part was updated. @@ -92,87 +92,103 @@ class TicketPart extends JsonSerializableType #[JsonProperty('redacted')] private ?bool $redacted; + /** + * @var ?string $appPackageCode The app package code if this part was created via API. Note this field won't show if the part was not created via API. + */ + #[JsonProperty('app_package_code')] + private ?string $appPackageCode; + + /** + * @var ?TicketPartUpdatedAttributeData $updatedAttributeData The updated attribute data of the ticket part. Only present for attribute update parts. + */ + #[JsonProperty('updated_attribute_data')] + private ?TicketPartUpdatedAttributeData $updatedAttributeData; + /** * @param array{ - * type: 'ticket_part', - * id: string, - * partType: string, - * ticketState: value-of, - * createdAt: int, + * type?: ?string, + * id?: ?string, + * partType?: ?string, * body?: ?string, * previousTicketState?: ?value-of, + * ticketState?: ?value-of, + * createdAt?: ?int, * updatedAt?: ?int, * assignedTo?: ?Reference, * author?: ?TicketPartAuthor, * attachments?: ?array, * externalId?: ?string, * redacted?: ?bool, + * appPackageCode?: ?string, + * updatedAttributeData?: ?TicketPartUpdatedAttributeData, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->partType = $values['partType']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->partType = $values['partType'] ?? null; $this->body = $values['body'] ?? null; $this->previousTicketState = $values['previousTicketState'] ?? null; - $this->ticketState = $values['ticketState']; - $this->createdAt = $values['createdAt']; + $this->ticketState = $values['ticketState'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; $this->updatedAt = $values['updatedAt'] ?? null; $this->assignedTo = $values['assignedTo'] ?? null; $this->author = $values['author'] ?? null; $this->attachments = $values['attachments'] ?? null; $this->externalId = $values['externalId'] ?? null; $this->redacted = $values['redacted'] ?? null; + $this->appPackageCode = $values['appPackageCode'] ?? null; + $this->updatedAttributeData = $values['updatedAttributeData'] ?? null; } /** - * @return 'ticket_part' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'ticket_part' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getPartType(): string + public function getPartType(): ?string { return $this->partType; } /** - * @param string $value + * @param ?string $value */ - public function setPartType(string $value): self + public function setPartType(?string $value = null): self { $this->partType = $value; return $this; @@ -213,34 +229,34 @@ public function setPreviousTicketState(?string $value = null): self } /** - * @return value-of + * @return ?value-of */ - public function getTicketState(): string + public function getTicketState(): ?string { return $this->ticketState; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setTicketState(string $value): self + public function setTicketState(?string $value = null): self { $this->ticketState = $value; return $this; } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; @@ -348,6 +364,40 @@ public function setRedacted(?bool $value = null): self return $this; } + /** + * @return ?string + */ + public function getAppPackageCode(): ?string + { + return $this->appPackageCode; + } + + /** + * @param ?string $value + */ + public function setAppPackageCode(?string $value = null): self + { + $this->appPackageCode = $value; + return $this; + } + + /** + * @return ?TicketPartUpdatedAttributeData + */ + public function getUpdatedAttributeData(): ?TicketPartUpdatedAttributeData + { + return $this->updatedAttributeData; + } + + /** + * @param ?TicketPartUpdatedAttributeData $value + */ + public function setUpdatedAttributeData(?TicketPartUpdatedAttributeData $value = null): self + { + $this->updatedAttributeData = $value; + return $this; + } + /** * @return string */ diff --git a/src/Tickets/Types/TicketPartUpdatedAttributeData.php b/src/Tickets/Types/TicketPartUpdatedAttributeData.php new file mode 100644 index 0000000..7686470 --- /dev/null +++ b/src/Tickets/Types/TicketPartUpdatedAttributeData.php @@ -0,0 +1,79 @@ +attribute = $values['attribute']; + $this->value = $values['value']; + } + + /** + * @return TicketPartUpdatedAttributeDataAttribute + */ + public function getAttribute(): TicketPartUpdatedAttributeDataAttribute + { + return $this->attribute; + } + + /** + * @param TicketPartUpdatedAttributeDataAttribute $value + */ + public function setAttribute(TicketPartUpdatedAttributeDataAttribute $value): self + { + $this->attribute = $value; + return $this; + } + + /** + * @return TicketPartUpdatedAttributeDataValue + */ + public function getValue(): TicketPartUpdatedAttributeDataValue + { + return $this->value; + } + + /** + * @param TicketPartUpdatedAttributeDataValue $value + */ + public function setValue(TicketPartUpdatedAttributeDataValue $value): self + { + $this->value = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ContactCompany.php b/src/Tickets/Types/TicketPartUpdatedAttributeDataAttribute.php similarity index 62% rename from src/Types/ContactCompany.php rename to src/Tickets/Types/TicketPartUpdatedAttributeDataAttribute.php index 47daced..7acf082 100644 --- a/src/Types/ContactCompany.php +++ b/src/Tickets/Types/TicketPartUpdatedAttributeDataAttribute.php @@ -1,96 +1,96 @@ id = $values['id']; $this->type = $values['type']; - $this->url = $values['url']; + $this->id = $values['id']; + $this->label = $values['label']; } /** - * @return string + * @return 'attribute' */ - public function getId(): string + public function getType(): string { - return $this->id; + return $this->type; } /** - * @param string $value + * @param 'attribute' $value */ - public function setId(string $value): self + public function setType(string $value): self { - $this->id = $value; + $this->type = $value; return $this; } /** - * @return 'company' + * @return string */ - public function getType(): string + public function getId(): string { - return $this->type; + return $this->id; } /** - * @param 'company' $value + * @param string $value */ - public function setType(string $value): self + public function setId(string $value): self { - $this->type = $value; + $this->id = $value; return $this; } /** * @return string */ - public function getUrl(): string + public function getLabel(): string { - return $this->url; + return $this->label; } /** * @param string $value */ - public function setUrl(string $value): self + public function setLabel(string $value): self { - $this->url = $value; + $this->label = $value; return $this; } diff --git a/src/Tickets/Types/TicketPartUpdatedAttributeDataValue.php b/src/Tickets/Types/TicketPartUpdatedAttributeDataValue.php new file mode 100644 index 0000000..771084e --- /dev/null +++ b/src/Tickets/Types/TicketPartUpdatedAttributeDataValue.php @@ -0,0 +1,133 @@ + + * |null + * ) $id + */ + #[JsonProperty('id'), Union(new Union('string', 'null'), ['integer'])] + private string|array|null $id; + + /** + * @var ( + * string + * |array + * ) $label + */ + #[JsonProperty('label'), Union('string', ['string'])] + private string|array $label; + + /** + * @param array{ + * type: 'value', + * id: ( + * string + * |array + * |null + * ), + * label: ( + * string + * |array + * ), + * } $values + */ + public function __construct( + array $values, + ) { + $this->type = $values['type']; + $this->id = $values['id']; + $this->label = $values['label']; + } + + /** + * @return 'value' + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param 'value' $value + */ + public function setType(string $value): self + { + $this->type = $value; + return $this; + } + + /** + * @return ( + * string + * |array + * |null + * ) + */ + public function getId(): string|array|null + { + return $this->id; + } + + /** + * @param ( + * string + * |array + * |null + * ) $value + */ + public function setId(string|array|null $value): self + { + $this->id = $value; + return $this; + } + + /** + * @return ( + * string + * |array + * ) + */ + public function getLabel(): string|array + { + return $this->label; + } + + /** + * @param ( + * string + * |array + * ) $value + */ + public function setLabel(string|array $value): self + { + $this->label = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Tickets/Types/TicketState.php b/src/Tickets/Types/TicketState.php new file mode 100644 index 0000000..5a2a5d9 --- /dev/null +++ b/src/Tickets/Types/TicketState.php @@ -0,0 +1,154 @@ + $category The category of the ticket state + */ + #[JsonProperty('category')] + private ?string $category; + + /** + * @var ?string $internalLabel The state the ticket is currently in, in a human readable form - visible in Intercom + */ + #[JsonProperty('internal_label')] + private ?string $internalLabel; + + /** + * @var ?string $externalLabel The state the ticket is currently in, in a human readable form - visible to customers, in the messenger, email and tickets portal. + */ + #[JsonProperty('external_label')] + private ?string $externalLabel; + + /** + * @param array{ + * type?: ?string, + * id?: ?string, + * category?: ?value-of, + * internalLabel?: ?string, + * externalLabel?: ?string, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->category = $values['category'] ?? null; + $this->internalLabel = $values['internalLabel'] ?? null; + $this->externalLabel = $values['externalLabel'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?value-of + */ + public function getCategory(): ?string + { + return $this->category; + } + + /** + * @param ?value-of $value + */ + public function setCategory(?string $value = null): self + { + $this->category = $value; + return $this; + } + + /** + * @return ?string + */ + public function getInternalLabel(): ?string + { + return $this->internalLabel; + } + + /** + * @param ?string $value + */ + public function setInternalLabel(?string $value = null): self + { + $this->internalLabel = $value; + return $this; + } + + /** + * @return ?string + */ + public function getExternalLabel(): ?string + { + return $this->externalLabel; + } + + /** + * @param ?string $value + */ + public function setExternalLabel(?string $value = null): self + { + $this->externalLabel = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Tickets/Types/TicketTicketState.php b/src/Tickets/Types/TicketStateCategory.php similarity index 85% rename from src/Tickets/Types/TicketTicketState.php rename to src/Tickets/Types/TicketStateCategory.php index 1d0c664..9845f97 100644 --- a/src/Tickets/Types/TicketTicketState.php +++ b/src/Tickets/Types/TicketStateCategory.php @@ -2,7 +2,7 @@ namespace Intercom\Tickets\Types; -enum TicketTicketState: string +enum TicketStateCategory: string { case Submitted = "submitted"; case InProgress = "in_progress"; diff --git a/src/Tickets/Types/TicketStateDetailed.php b/src/Tickets/Types/TicketStateDetailed.php new file mode 100644 index 0000000..26803e2 --- /dev/null +++ b/src/Tickets/Types/TicketStateDetailed.php @@ -0,0 +1,204 @@ + $category The category of the ticket state + */ + #[JsonProperty('category')] + private ?string $category; + + /** + * @var ?string $internalLabel The state the ticket is currently in, in a human readable form - visible in Intercom + */ + #[JsonProperty('internal_label')] + private ?string $internalLabel; + + /** + * @var ?string $externalLabel The state the ticket is currently in, in a human readable form - visible to customers, in the messenger, email and tickets portal. + */ + #[JsonProperty('external_label')] + private ?string $externalLabel; + + /** + * @var ?bool $archived Whether the ticket state is archived + */ + #[JsonProperty('archived')] + private ?bool $archived; + + /** + * @var ?TicketStateDetailedTicketTypes $ticketTypes A list of ticket types associated with a given ticket state. + */ + #[JsonProperty('ticket_types')] + private ?TicketStateDetailedTicketTypes $ticketTypes; + + /** + * @param array{ + * type?: ?string, + * id?: ?string, + * category?: ?value-of, + * internalLabel?: ?string, + * externalLabel?: ?string, + * archived?: ?bool, + * ticketTypes?: ?TicketStateDetailedTicketTypes, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->category = $values['category'] ?? null; + $this->internalLabel = $values['internalLabel'] ?? null; + $this->externalLabel = $values['externalLabel'] ?? null; + $this->archived = $values['archived'] ?? null; + $this->ticketTypes = $values['ticketTypes'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?value-of + */ + public function getCategory(): ?string + { + return $this->category; + } + + /** + * @param ?value-of $value + */ + public function setCategory(?string $value = null): self + { + $this->category = $value; + return $this; + } + + /** + * @return ?string + */ + public function getInternalLabel(): ?string + { + return $this->internalLabel; + } + + /** + * @param ?string $value + */ + public function setInternalLabel(?string $value = null): self + { + $this->internalLabel = $value; + return $this; + } + + /** + * @return ?string + */ + public function getExternalLabel(): ?string + { + return $this->externalLabel; + } + + /** + * @param ?string $value + */ + public function setExternalLabel(?string $value = null): self + { + $this->externalLabel = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getArchived(): ?bool + { + return $this->archived; + } + + /** + * @param ?bool $value + */ + public function setArchived(?bool $value = null): self + { + $this->archived = $value; + return $this; + } + + /** + * @return ?TicketStateDetailedTicketTypes + */ + public function getTicketTypes(): ?TicketStateDetailedTicketTypes + { + return $this->ticketTypes; + } + + /** + * @param ?TicketStateDetailedTicketTypes $value + */ + public function setTicketTypes(?TicketStateDetailedTicketTypes $value = null): self + { + $this->ticketTypes = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Tickets/Types/UpdateTicketRequestState.php b/src/Tickets/Types/TicketStateDetailedCategory.php similarity index 69% rename from src/Tickets/Types/UpdateTicketRequestState.php rename to src/Tickets/Types/TicketStateDetailedCategory.php index 89728a6..b0b6643 100644 --- a/src/Tickets/Types/UpdateTicketRequestState.php +++ b/src/Tickets/Types/TicketStateDetailedCategory.php @@ -2,8 +2,9 @@ namespace Intercom\Tickets\Types; -enum UpdateTicketRequestState: string +enum TicketStateDetailedCategory: string { + case Submitted = "submitted"; case InProgress = "in_progress"; case WaitingOnCustomer = "waiting_on_customer"; case Resolved = "resolved"; diff --git a/src/Tickets/Types/TicketStateDetailedTicketTypes.php b/src/Tickets/Types/TicketStateDetailedTicketTypes.php new file mode 100644 index 0000000..cee96e1 --- /dev/null +++ b/src/Tickets/Types/TicketStateDetailedTicketTypes.php @@ -0,0 +1,81 @@ + $data A list of ticket type attributes associated with a given ticket type. + */ + #[JsonProperty('data'), ArrayType([new Union(TicketType::class, 'null')])] + private ?array $data; + + /** + * @param array{ + * type?: ?string, + * data?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?array + */ + public function getData(): ?array + { + return $this->data; + } + + /** + * @param ?array $value + */ + public function setData(?array $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Tickets/Types/TicketType.php b/src/Tickets/Types/TicketType.php index 82724e3..5e1bcd3 100644 --- a/src/Tickets/Types/TicketType.php +++ b/src/Tickets/Types/TicketType.php @@ -12,64 +12,70 @@ class TicketType extends JsonSerializableType { /** - * @var 'ticket_type' $type String representing the object's type. Always has the value `ticket_type`. + * @var ?string $type String representing the object's type. Always has the value `ticket_type`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The id representing the ticket type. + * @var ?string $id The id representing the ticket type. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var value-of $category Category of the Ticket Type. + * @var ?value-of $category Category of the Ticket Type. */ #[JsonProperty('category')] - private string $category; + private ?string $category; /** - * @var string $name The name of the ticket type + * @var ?string $name The name of the ticket type */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var string $description The description of the ticket type + * @var ?string $description The description of the ticket type */ #[JsonProperty('description')] - private string $description; + private ?string $description; /** - * @var string $icon The icon of the ticket type + * @var ?string $icon The icon of the ticket type */ #[JsonProperty('icon')] - private string $icon; + private ?string $icon; /** - * @var string $workspaceId The id of the workspace that the ticket type belongs to. + * @var ?string $workspaceId The id of the workspace that the ticket type belongs to. */ #[JsonProperty('workspace_id')] - private string $workspaceId; + private ?string $workspaceId; /** - * @var TicketTypeAttributeList $ticketTypeAttributes + * @var ?TicketTypeAttributeList $ticketTypeAttributes */ #[JsonProperty('ticket_type_attributes')] - private TicketTypeAttributeList $ticketTypeAttributes; + private ?TicketTypeAttributeList $ticketTypeAttributes; /** - * @var bool $archived Whether the ticket type is archived or not. + * @var ?TicketTypeTicketStates $ticketStates A list of ticket states associated with a given ticket type. + */ + #[JsonProperty('ticket_states')] + private ?TicketTypeTicketStates $ticketStates; + + /** + * @var ?bool $archived Whether the ticket type is archived or not. */ #[JsonProperty('archived')] - private bool $archived; + private ?bool $archived; /** - * @var int $createdAt The date and time the ticket type was created. + * @var ?int $createdAt The date and time the ticket type was created. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** * @var ?int $updatedAt The date and time the ticket type was last updated. @@ -79,200 +85,219 @@ class TicketType extends JsonSerializableType /** * @param array{ - * type: 'ticket_type', - * id: string, - * category: value-of, - * name: string, - * description: string, - * icon: string, - * workspaceId: string, - * ticketTypeAttributes: TicketTypeAttributeList, - * archived: bool, - * createdAt: int, + * type?: ?string, + * id?: ?string, + * category?: ?value-of, + * name?: ?string, + * description?: ?string, + * icon?: ?string, + * workspaceId?: ?string, + * ticketTypeAttributes?: ?TicketTypeAttributeList, + * ticketStates?: ?TicketTypeTicketStates, + * archived?: ?bool, + * createdAt?: ?int, * updatedAt?: ?int, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->category = $values['category']; - $this->name = $values['name']; - $this->description = $values['description']; - $this->icon = $values['icon']; - $this->workspaceId = $values['workspaceId']; - $this->ticketTypeAttributes = $values['ticketTypeAttributes']; - $this->archived = $values['archived']; - $this->createdAt = $values['createdAt']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->category = $values['category'] ?? null; + $this->name = $values['name'] ?? null; + $this->description = $values['description'] ?? null; + $this->icon = $values['icon'] ?? null; + $this->workspaceId = $values['workspaceId'] ?? null; + $this->ticketTypeAttributes = $values['ticketTypeAttributes'] ?? null; + $this->ticketStates = $values['ticketStates'] ?? null; + $this->archived = $values['archived'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; $this->updatedAt = $values['updatedAt'] ?? null; } /** - * @return 'ticket_type' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'ticket_type' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return value-of + * @return ?value-of */ - public function getCategory(): string + public function getCategory(): ?string { return $this->category; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setCategory(string $value): self + public function setCategory(?string $value = null): self { $this->category = $value; return $this; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return string + * @return ?string */ - public function getDescription(): string + public function getDescription(): ?string { return $this->description; } /** - * @param string $value + * @param ?string $value */ - public function setDescription(string $value): self + public function setDescription(?string $value = null): self { $this->description = $value; return $this; } /** - * @return string + * @return ?string */ - public function getIcon(): string + public function getIcon(): ?string { return $this->icon; } /** - * @param string $value + * @param ?string $value */ - public function setIcon(string $value): self + public function setIcon(?string $value = null): self { $this->icon = $value; return $this; } /** - * @return string + * @return ?string */ - public function getWorkspaceId(): string + public function getWorkspaceId(): ?string { return $this->workspaceId; } /** - * @param string $value + * @param ?string $value */ - public function setWorkspaceId(string $value): self + public function setWorkspaceId(?string $value = null): self { $this->workspaceId = $value; return $this; } /** - * @return TicketTypeAttributeList + * @return ?TicketTypeAttributeList */ - public function getTicketTypeAttributes(): TicketTypeAttributeList + public function getTicketTypeAttributes(): ?TicketTypeAttributeList { return $this->ticketTypeAttributes; } /** - * @param TicketTypeAttributeList $value + * @param ?TicketTypeAttributeList $value */ - public function setTicketTypeAttributes(TicketTypeAttributeList $value): self + public function setTicketTypeAttributes(?TicketTypeAttributeList $value = null): self { $this->ticketTypeAttributes = $value; return $this; } /** - * @return bool + * @return ?TicketTypeTicketStates */ - public function getArchived(): bool + public function getTicketStates(): ?TicketTypeTicketStates + { + return $this->ticketStates; + } + + /** + * @param ?TicketTypeTicketStates $value + */ + public function setTicketStates(?TicketTypeTicketStates $value = null): self + { + $this->ticketStates = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getArchived(): ?bool { return $this->archived; } /** - * @param bool $value + * @param ?bool $value */ - public function setArchived(bool $value): self + public function setArchived(?bool $value = null): self { $this->archived = $value; return $this; } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; diff --git a/src/Tickets/Types/TicketTypeTicketStates.php b/src/Tickets/Types/TicketTypeTicketStates.php new file mode 100644 index 0000000..8217a6b --- /dev/null +++ b/src/Tickets/Types/TicketTypeTicketStates.php @@ -0,0 +1,81 @@ + $data A list of ticket states associated with a given ticket type. + */ + #[JsonProperty('data'), ArrayType([new Union(TicketState::class, 'null')])] + private ?array $data; + + /** + * @param array{ + * type?: ?string, + * data?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?array + */ + public function getData(): ?array + { + return $this->data; + } + + /** + * @param ?array $value + */ + public function setData(?array $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Tickets/Types/UpdateTicketRequestAssignment.php b/src/Tickets/Types/UpdateTicketRequestAssignment.php deleted file mode 100644 index 0b55572..0000000 --- a/src/Tickets/Types/UpdateTicketRequestAssignment.php +++ /dev/null @@ -1,76 +0,0 @@ -adminId = $values['adminId'] ?? null; - $this->assigneeId = $values['assigneeId'] ?? null; - } - - /** - * @return ?string - */ - public function getAdminId(): ?string - { - return $this->adminId; - } - - /** - * @param ?string $value - */ - public function setAdminId(?string $value = null): self - { - $this->adminId = $value; - return $this; - } - - /** - * @return ?string - */ - public function getAssigneeId(): ?string - { - return $this->assigneeId; - } - - /** - * @param ?string $value - */ - public function setAssigneeId(?string $value = null): self - { - $this->assigneeId = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Traits/ContactReference.php b/src/Traits/ContactReference.php new file mode 100644 index 0000000..93d488a --- /dev/null +++ b/src/Traits/ContactReference.php @@ -0,0 +1,84 @@ +type; + } + + /** + * @param ?'contact' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getExternalId(): ?string + { + return $this->externalId; + } + + /** + * @param ?string $value + */ + public function setExternalId(?string $value = null): self + { + $this->externalId = $value; + return $this; + } +} diff --git a/src/Traits/ContactReplyBaseRequest.php b/src/Traits/ContactReplyBaseRequest.php index ec445fa..55b0e56 100644 --- a/src/Traits/ContactReplyBaseRequest.php +++ b/src/Traits/ContactReplyBaseRequest.php @@ -2,6 +2,7 @@ namespace Intercom\Traits; +use Intercom\Types\ContactReplyBaseRequestReplyOptionsItem; use Intercom\Core\Json\JsonProperty; use Intercom\Core\Types\ArrayType; @@ -11,6 +12,7 @@ * @property string $body * @property ?int $createdAt * @property ?array $attachmentUrls + * @property ?array $replyOptions */ trait ContactReplyBaseRequest { @@ -44,6 +46,12 @@ trait ContactReplyBaseRequest #[JsonProperty('attachment_urls'), ArrayType(['string'])] private ?array $attachmentUrls; + /** + * @var ?array $replyOptions The quick reply selection the contact wishes to respond with. These map to buttons displayed in the Messenger UI if sent by a bot, or the reply options sent by an Admin via the API. + */ + #[JsonProperty('reply_options'), ArrayType([ContactReplyBaseRequestReplyOptionsItem::class])] + private ?array $replyOptions; + /** * @return 'comment' */ @@ -128,4 +136,21 @@ public function setAttachmentUrls(?array $value = null): self $this->attachmentUrls = $value; return $this; } + + /** + * @return ?array + */ + public function getReplyOptions(): ?array + { + return $this->replyOptions; + } + + /** + * @param ?array $value + */ + public function setReplyOptions(?array $value = null): self + { + $this->replyOptions = $value; + return $this; + } } diff --git a/src/Traits/CreateTicketRequestBody.php b/src/Traits/CreateTicketRequestBody.php new file mode 100644 index 0000000..d4f36a9 --- /dev/null +++ b/src/Traits/CreateTicketRequestBody.php @@ -0,0 +1,184 @@ + $contacts + * @property ?string $conversationToLinkId + * @property ?string $companyId + * @property ?int $createdAt + * @property ?CreateTicketRequestAssignment $assignment + */ +trait CreateTicketRequestBody +{ + /** + * @var string $ticketTypeId The ID of the type of ticket you want to create + */ + #[JsonProperty('ticket_type_id')] + private string $ticketTypeId; + + /** + * @var array<( + * CreateTicketRequestContactsItemId + * |CreateTicketRequestContactsItemExternalId + * |CreateTicketRequestContactsItemEmail + * )> $contacts The list of contacts (users or leads) affected by this ticket. Currently only one is allowed + */ + #[JsonProperty('contacts'), ArrayType([new Union(CreateTicketRequestContactsItemId::class, CreateTicketRequestContactsItemExternalId::class, CreateTicketRequestContactsItemEmail::class)])] + private array $contacts; + + /** + * The ID of the conversation you want to link to the ticket. Here are the valid ways of linking two tickets: + * - conversation | back-office ticket + * - customer tickets | non-shared back-office ticket + * - conversation | tracker ticket + * - customer ticket | tracker ticket + * + * @var ?string $conversationToLinkId + */ + #[JsonProperty('conversation_to_link_id')] + private ?string $conversationToLinkId; + + /** + * @var ?string $companyId The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom + */ + #[JsonProperty('company_id')] + private ?string $companyId; + + /** + * @var ?int $createdAt The time the ticket was created. If not provided, the current time will be used. + */ + #[JsonProperty('created_at')] + private ?int $createdAt; + + /** + * @var ?CreateTicketRequestAssignment $assignment + */ + #[JsonProperty('assignment')] + private ?CreateTicketRequestAssignment $assignment; + + /** + * @return string + */ + public function getTicketTypeId(): string + { + return $this->ticketTypeId; + } + + /** + * @param string $value + */ + public function setTicketTypeId(string $value): self + { + $this->ticketTypeId = $value; + return $this; + } + + /** + * @return array<( + * CreateTicketRequestContactsItemId + * |CreateTicketRequestContactsItemExternalId + * |CreateTicketRequestContactsItemEmail + * )> + */ + public function getContacts(): array + { + return $this->contacts; + } + + /** + * @param array<( + * CreateTicketRequestContactsItemId + * |CreateTicketRequestContactsItemExternalId + * |CreateTicketRequestContactsItemEmail + * )> $value + */ + public function setContacts(array $value): self + { + $this->contacts = $value; + return $this; + } + + /** + * @return ?string + */ + public function getConversationToLinkId(): ?string + { + return $this->conversationToLinkId; + } + + /** + * @param ?string $value + */ + public function setConversationToLinkId(?string $value = null): self + { + $this->conversationToLinkId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getCompanyId(): ?string + { + return $this->companyId; + } + + /** + * @param ?string $value + */ + public function setCompanyId(?string $value = null): self + { + $this->companyId = $value; + return $this; + } + + /** + * @return ?int + */ + public function getCreatedAt(): ?int + { + return $this->createdAt; + } + + /** + * @param ?int $value + */ + public function setCreatedAt(?int $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ?CreateTicketRequestAssignment + */ + public function getAssignment(): ?CreateTicketRequestAssignment + { + return $this->assignment; + } + + /** + * @param ?CreateTicketRequestAssignment $value + */ + public function setAssignment(?CreateTicketRequestAssignment $value = null): self + { + $this->assignment = $value; + return $this; + } +} diff --git a/src/Traits/CustomChannelBaseEvent.php b/src/Traits/CustomChannelBaseEvent.php new file mode 100644 index 0000000..6e4cbae --- /dev/null +++ b/src/Traits/CustomChannelBaseEvent.php @@ -0,0 +1,83 @@ +eventId; + } + + /** + * @param string $value + */ + public function setEventId(string $value): self + { + $this->eventId = $value; + return $this; + } + + /** + * @return string + */ + public function getExternalConversationId(): string + { + return $this->externalConversationId; + } + + /** + * @param string $value + */ + public function setExternalConversationId(string $value): self + { + $this->externalConversationId = $value; + return $this; + } + + /** + * @return CustomChannelContact + */ + public function getContact(): CustomChannelContact + { + return $this->contact; + } + + /** + * @param CustomChannelContact $value + */ + public function setContact(CustomChannelContact $value): self + { + $this->contact = $value; + return $this; + } +} diff --git a/src/Traits/ListItem.php b/src/Traits/ListItem.php deleted file mode 100644 index ecf6ecb..0000000 --- a/src/Traits/ListItem.php +++ /dev/null @@ -1,205 +0,0 @@ -type; - } - - /** - * @param 'item' $value - */ - public function setType(string $value): self - { - $this->type = $value; - return $this; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return string - */ - public function getTitle(): string - { - return $this->title; - } - - /** - * @param string $value - */ - public function setTitle(string $value): self - { - $this->title = $value; - return $this; - } - - /** - * @return ?string - */ - public function getSubtitle(): ?string - { - return $this->subtitle; - } - - /** - * @param ?string $value - */ - public function setSubtitle(?string $value = null): self - { - $this->subtitle = $value; - return $this; - } - - /** - * @return ?string - */ - public function getTertiaryText(): ?string - { - return $this->tertiaryText; - } - - /** - * @param ?string $value - */ - public function setTertiaryText(?string $value = null): self - { - $this->tertiaryText = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getRoundedImage(): ?bool - { - return $this->roundedImage; - } - - /** - * @param ?bool $value - */ - public function setRoundedImage(?bool $value = null): self - { - $this->roundedImage = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getDisabled(): ?bool - { - return $this->disabled; - } - - /** - * @param ?bool $value - */ - public function setDisabled(?bool $value = null): self - { - $this->disabled = $value; - return $this; - } - - /** - * @return ?ActionComponent - */ - public function getAction(): ?ActionComponent - { - return $this->action; - } - - /** - * @param ?ActionComponent $value - */ - public function setAction(?ActionComponent $value = null): self - { - $this->action = $value; - return $this; - } -} diff --git a/src/Traits/QuickReplyOption.php b/src/Traits/QuickReplyOption.php new file mode 100644 index 0000000..077aee8 --- /dev/null +++ b/src/Traits/QuickReplyOption.php @@ -0,0 +1,58 @@ +text; + } + + /** + * @param string $value + */ + public function setText(string $value): self + { + $this->text = $value; + return $this; + } + + /** + * @return string + */ + public function getUuid(): string + { + return $this->uuid; + } + + /** + * @param string $value + */ + public function setUuid(string $value): self + { + $this->uuid = $value; + return $this; + } +} diff --git a/src/Types/ActivityLog.php b/src/Types/ActivityLog.php index d5d5687..c0c7f22 100644 --- a/src/Types/ActivityLog.php +++ b/src/Types/ActivityLog.php @@ -11,16 +11,16 @@ class ActivityLog extends JsonSerializableType { /** - * @var string $id The id representing the activity. + * @var ?string $id The id representing the activity. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var ActivityLogPerformedBy $performedBy Details about the Admin involved in the activity. + * @var ?ActivityLogPerformedBy $performedBy Details about the Admin involved in the activity. */ #[JsonProperty('performed_by')] - private ActivityLogPerformedBy $performedBy; + private ?ActivityLogPerformedBy $performedBy; /** * @var ?ActivityLogMetadata $metadata @@ -35,10 +35,10 @@ class ActivityLog extends JsonSerializableType private ?int $createdAt; /** - * @var value-of $activityType + * @var ?value-of $activityType */ #[JsonProperty('activity_type')] - private string $activityType; + private ?string $activityType; /** * @var ?string $activityDescription A sentence or two describing the activity. @@ -48,54 +48,54 @@ class ActivityLog extends JsonSerializableType /** * @param array{ - * id: string, - * performedBy: ActivityLogPerformedBy, - * activityType: value-of, + * id?: ?string, + * performedBy?: ?ActivityLogPerformedBy, * metadata?: ?ActivityLogMetadata, * createdAt?: ?int, + * activityType?: ?value-of, * activityDescription?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->id = $values['id']; - $this->performedBy = $values['performedBy']; + $this->id = $values['id'] ?? null; + $this->performedBy = $values['performedBy'] ?? null; $this->metadata = $values['metadata'] ?? null; $this->createdAt = $values['createdAt'] ?? null; - $this->activityType = $values['activityType']; + $this->activityType = $values['activityType'] ?? null; $this->activityDescription = $values['activityDescription'] ?? null; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return ActivityLogPerformedBy + * @return ?ActivityLogPerformedBy */ - public function getPerformedBy(): ActivityLogPerformedBy + public function getPerformedBy(): ?ActivityLogPerformedBy { return $this->performedBy; } /** - * @param ActivityLogPerformedBy $value + * @param ?ActivityLogPerformedBy $value */ - public function setPerformedBy(ActivityLogPerformedBy $value): self + public function setPerformedBy(?ActivityLogPerformedBy $value = null): self { $this->performedBy = $value; return $this; @@ -136,17 +136,17 @@ public function setCreatedAt(?int $value = null): self } /** - * @return value-of + * @return ?value-of */ - public function getActivityType(): string + public function getActivityType(): ?string { return $this->activityType; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setActivityType(string $value): self + public function setActivityType(?string $value = null): self { $this->activityType = $value; return $this; diff --git a/src/Types/ActivityLogActivityType.php b/src/Types/ActivityLogActivityType.php index 82eb0da..43823ef 100644 --- a/src/Types/ActivityLogActivityType.php +++ b/src/Types/ActivityLogActivityType.php @@ -4,7 +4,8 @@ enum ActivityLogActivityType: string { - case AdminAssignmentLimitChange = "admin_assignment_limit_change"; + case AdminConversationAssignmentLimitChange = "admin_conversation_assignment_limit_change"; + case AdminTicketAssignmentLimitChange = "admin_ticket_assignment_limit_change"; case AdminAwayModeChange = "admin_away_mode_change"; case AdminDeletion = "admin_deletion"; case AdminDeprovisioned = "admin_deprovisioned"; diff --git a/src/Types/ActivityLogList.php b/src/Types/ActivityLogList.php index 348cada..1f7695b 100644 --- a/src/Types/ActivityLogList.php +++ b/src/Types/ActivityLogList.php @@ -5,6 +5,7 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; use Intercom\Core\Types\ArrayType; +use Intercom\Core\Types\Union; /** * A paginated list of activity logs. @@ -12,10 +13,10 @@ class ActivityLogList extends JsonSerializableType { /** - * @var 'activity_log.list' $type String representing the object's type. Always has the value `activity_log.list`. + * @var ?string $type String representing the object's type. Always has the value `activity_log.list`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** * @var ?CursorPages $pages @@ -24,38 +25,38 @@ class ActivityLogList extends JsonSerializableType private ?CursorPages $pages; /** - * @var array $activityLogs An array of activity logs + * @var ?array $activityLogs An array of activity logs */ - #[JsonProperty('activity_logs'), ArrayType([ActivityLog::class])] - private array $activityLogs; + #[JsonProperty('activity_logs'), ArrayType([new Union(ActivityLog::class, 'null')])] + private ?array $activityLogs; /** * @param array{ - * type: 'activity_log.list', - * activityLogs: array, + * type?: ?string, * pages?: ?CursorPages, + * activityLogs?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; + $this->type = $values['type'] ?? null; $this->pages = $values['pages'] ?? null; - $this->activityLogs = $values['activityLogs']; + $this->activityLogs = $values['activityLogs'] ?? null; } /** - * @return 'activity_log.list' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'activity_log.list' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; @@ -79,17 +80,17 @@ public function setPages(?CursorPages $value = null): self } /** - * @return array + * @return ?array */ - public function getActivityLogs(): array + public function getActivityLogs(): ?array { return $this->activityLogs; } /** - * @param array $value + * @param ?array $value */ - public function setActivityLogs(array $value): self + public function setActivityLogs(?array $value = null): self { $this->activityLogs = $value; return $this; diff --git a/src/Types/ActivityLogMetadata.php b/src/Types/ActivityLogMetadata.php index 2990717..1371594 100644 --- a/src/Types/ActivityLogMetadata.php +++ b/src/Types/ActivityLogMetadata.php @@ -64,6 +64,18 @@ class ActivityLogMetadata extends JsonSerializableType #[JsonProperty('update_by_name')] private ?string $updateByName; + /** + * @var ?int $conversationAssignmentLimit The conversation assignment limit value for an admin. + */ + #[JsonProperty('conversation_assignment_limit')] + private ?int $conversationAssignmentLimit; + + /** + * @var ?int $ticketAssignmentLimit The ticket assignment limit value for an admin. + */ + #[JsonProperty('ticket_assignment_limit')] + private ?int $ticketAssignmentLimit; + /** * @param array{ * signInMethod?: ?string, @@ -75,6 +87,8 @@ class ActivityLogMetadata extends JsonSerializableType * autoChanged?: ?string, * updateBy?: ?int, * updateByName?: ?string, + * conversationAssignmentLimit?: ?int, + * ticketAssignmentLimit?: ?int, * } $values */ public function __construct( @@ -89,6 +103,8 @@ public function __construct( $this->autoChanged = $values['autoChanged'] ?? null; $this->updateBy = $values['updateBy'] ?? null; $this->updateByName = $values['updateByName'] ?? null; + $this->conversationAssignmentLimit = $values['conversationAssignmentLimit'] ?? null; + $this->ticketAssignmentLimit = $values['ticketAssignmentLimit'] ?? null; } /** @@ -244,6 +260,40 @@ public function setUpdateByName(?string $value = null): self return $this; } + /** + * @return ?int + */ + public function getConversationAssignmentLimit(): ?int + { + return $this->conversationAssignmentLimit; + } + + /** + * @param ?int $value + */ + public function setConversationAssignmentLimit(?int $value = null): self + { + $this->conversationAssignmentLimit = $value; + return $this; + } + + /** + * @return ?int + */ + public function getTicketAssignmentLimit(): ?int + { + return $this->ticketAssignmentLimit; + } + + /** + * @param ?int $value + */ + public function setTicketAssignmentLimit(?int $value = null): self + { + $this->ticketAssignmentLimit = $value; + return $this; + } + /** * @return string */ diff --git a/src/Types/ActivityLogPerformedBy.php b/src/Types/ActivityLogPerformedBy.php index 0f2fee6..6abcfbd 100644 --- a/src/Types/ActivityLogPerformedBy.php +++ b/src/Types/ActivityLogPerformedBy.php @@ -11,7 +11,7 @@ class ActivityLogPerformedBy extends JsonSerializableType { /** - * @var ?'admin' $type String representing the object's type. Always has the value `admin`. + * @var ?string $type String representing the object's type. Always has the value `admin`. */ #[JsonProperty('type')] private ?string $type; @@ -36,7 +36,7 @@ class ActivityLogPerformedBy extends JsonSerializableType /** * @param array{ - * type?: ?'admin', + * type?: ?string, * id?: ?string, * email?: ?string, * ip?: ?string, @@ -52,7 +52,7 @@ public function __construct( } /** - * @return ?'admin' + * @return ?string */ public function getType(): ?string { @@ -60,7 +60,7 @@ public function getType(): ?string } /** - * @param ?'admin' $value + * @param ?string $value */ public function setType(?string $value = null): self { diff --git a/src/Types/AddressableList.php b/src/Types/AddressableList.php index 54942c8..b19309c 100644 --- a/src/Types/AddressableList.php +++ b/src/Types/AddressableList.php @@ -11,84 +11,84 @@ class AddressableList extends JsonSerializableType { /** - * @var string $type The addressable object type + * @var ?string $type The addressable object type */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The id of the addressable object + * @var ?string $id The id of the addressable object */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $url Url to get more company resources for this contact + * @var ?string $url Url to get more company resources for this contact */ #[JsonProperty('url')] - private string $url; + private ?string $url; /** * @param array{ - * type: string, - * id: string, - * url: string, + * type?: ?string, + * id?: ?string, + * url?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->url = $values['url']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->url = $values['url'] ?? null; } /** - * @return string + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param string $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getUrl(): string + public function getUrl(): ?string { return $this->url; } /** - * @param string $value + * @param ?string $value */ - public function setUrl(string $value): self + public function setUrl(?string $value = null): self { $this->url = $value; return $this; diff --git a/src/Types/AdminList.php b/src/Types/AdminList.php index cd10008..780b63b 100644 --- a/src/Types/AdminList.php +++ b/src/Types/AdminList.php @@ -6,6 +6,7 @@ use Intercom\Core\Json\JsonProperty; use Intercom\Admins\Types\Admin; use Intercom\Core\Types\ArrayType; +use Intercom\Core\Types\Union; /** * A list of admins associated with a given workspace. @@ -13,59 +14,59 @@ class AdminList extends JsonSerializableType { /** - * @var 'admin.list' $type String representing the object's type. Always has the value `admin.list`. + * @var ?string $type String representing the object's type. Always has the value `admin.list`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $admins A list of admins associated with a given workspace. + * @var ?array $admins A list of admins associated with a given workspace. */ - #[JsonProperty('admins'), ArrayType([Admin::class])] - private array $admins; + #[JsonProperty('admins'), ArrayType([new Union(Admin::class, 'null')])] + private ?array $admins; /** * @param array{ - * type: 'admin.list', - * admins: array, + * type?: ?string, + * admins?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->admins = $values['admins']; + $this->type = $values['type'] ?? null; + $this->admins = $values['admins'] ?? null; } /** - * @return 'admin.list' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'admin.list' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getAdmins(): array + public function getAdmins(): ?array { return $this->admins; } /** - * @param array $value + * @param ?array $value */ - public function setAdmins(array $value): self + public function setAdmins(?array $value = null): self { $this->admins = $value; return $this; diff --git a/src/Types/AdminReplyConversationRequest.php b/src/Types/AdminReplyConversationRequest.php index e68388f..dbdabde 100644 --- a/src/Types/AdminReplyConversationRequest.php +++ b/src/Types/AdminReplyConversationRequest.php @@ -41,6 +41,12 @@ class AdminReplyConversationRequest extends JsonSerializableType #[JsonProperty('created_at')] private ?int $createdAt; + /** + * @var ?array $replyOptions The quick reply options to display to the end user. Must be present for quick_reply message types. + */ + #[JsonProperty('reply_options'), ArrayType([QuickReplyOption::class])] + private ?array $replyOptions; + /** * @var ?array $attachmentUrls A list of image URLs that will be added as attachments. You can include up to 10 URLs. */ @@ -60,6 +66,7 @@ class AdminReplyConversationRequest extends JsonSerializableType * adminId: string, * body?: ?string, * createdAt?: ?int, + * replyOptions?: ?array, * attachmentUrls?: ?array, * attachmentFiles?: ?array, * } $values @@ -72,6 +79,7 @@ public function __construct( $this->body = $values['body'] ?? null; $this->adminId = $values['adminId']; $this->createdAt = $values['createdAt'] ?? null; + $this->replyOptions = $values['replyOptions'] ?? null; $this->attachmentUrls = $values['attachmentUrls'] ?? null; $this->attachmentFiles = $values['attachmentFiles'] ?? null; } @@ -161,6 +169,23 @@ public function setCreatedAt(?int $value = null): self return $this; } + /** + * @return ?array + */ + public function getReplyOptions(): ?array + { + return $this->replyOptions; + } + + /** + * @param ?array $value + */ + public function setReplyOptions(?array $value = null): self + { + $this->replyOptions = $value; + return $this; + } + /** * @return ?array */ diff --git a/src/Types/AdminReplyConversationRequestMessageType.php b/src/Types/AdminReplyConversationRequestMessageType.php index a7c7fae..6cfcb82 100644 --- a/src/Types/AdminReplyConversationRequestMessageType.php +++ b/src/Types/AdminReplyConversationRequestMessageType.php @@ -6,4 +6,5 @@ enum AdminReplyConversationRequestMessageType: string { case Comment = "comment"; case Note = "note"; + case QuickReply = "quick_reply"; } diff --git a/src/Types/AdminWithApp.php b/src/Types/AdminWithApp.php index 4a1a2b9..0e37f30 100644 --- a/src/Types/AdminWithApp.php +++ b/src/Types/AdminWithApp.php @@ -12,58 +12,58 @@ class AdminWithApp extends JsonSerializableType { /** - * @var 'admin' $type String representing the object's type. Always has the value `admin`. + * @var ?string $type String representing the object's type. Always has the value `admin`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The id representing the admin. + * @var ?string $id The id representing the admin. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $name The name of the admin. + * @var ?string $name The name of the admin. */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var string $email The email of the admin. + * @var ?string $email The email of the admin. */ #[JsonProperty('email')] - private string $email; + private ?string $email; /** - * @var string $jobTitle The job title of the admin. + * @var ?string $jobTitle The job title of the admin. */ #[JsonProperty('job_title')] - private string $jobTitle; + private ?string $jobTitle; /** - * @var bool $awayModeEnabled Identifies if this admin is currently set in away mode. + * @var ?bool $awayModeEnabled Identifies if this admin is currently set in away mode. */ #[JsonProperty('away_mode_enabled')] - private bool $awayModeEnabled; + private ?bool $awayModeEnabled; /** - * @var bool $awayModeReassign Identifies if this admin is set to automatically reassign new conversations to the apps default inbox. + * @var ?bool $awayModeReassign Identifies if this admin is set to automatically reassign new conversations to the apps default inbox. */ #[JsonProperty('away_mode_reassign')] - private bool $awayModeReassign; + private ?bool $awayModeReassign; /** - * @var bool $hasInboxSeat Identifies if this admin has a paid inbox seat to restrict/allow features that require them. + * @var ?bool $hasInboxSeat Identifies if this admin has a paid inbox seat to restrict/allow features that require them. */ #[JsonProperty('has_inbox_seat')] - private bool $hasInboxSeat; + private ?bool $hasInboxSeat; /** - * @var array $teamIds This is a list of ids of the teams that this admin is part of. + * @var ?array $teamIds This is a list of ids of the teams that this admin is part of. */ #[JsonProperty('team_ids'), ArrayType(['integer'])] - private array $teamIds; + private ?array $teamIds; /** * @var ?AdminWithAppAvatar $avatar This object represents the avatar associated with the admin. @@ -85,185 +85,185 @@ class AdminWithApp extends JsonSerializableType /** * @param array{ - * type: 'admin', - * id: string, - * name: string, - * email: string, - * jobTitle: string, - * awayModeEnabled: bool, - * awayModeReassign: bool, - * hasInboxSeat: bool, - * teamIds: array, + * type?: ?string, + * id?: ?string, + * name?: ?string, + * email?: ?string, + * jobTitle?: ?string, + * awayModeEnabled?: ?bool, + * awayModeReassign?: ?bool, + * hasInboxSeat?: ?bool, + * teamIds?: ?array, * avatar?: ?AdminWithAppAvatar, * emailVerified?: ?bool, * app?: ?App, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->name = $values['name']; - $this->email = $values['email']; - $this->jobTitle = $values['jobTitle']; - $this->awayModeEnabled = $values['awayModeEnabled']; - $this->awayModeReassign = $values['awayModeReassign']; - $this->hasInboxSeat = $values['hasInboxSeat']; - $this->teamIds = $values['teamIds']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->name = $values['name'] ?? null; + $this->email = $values['email'] ?? null; + $this->jobTitle = $values['jobTitle'] ?? null; + $this->awayModeEnabled = $values['awayModeEnabled'] ?? null; + $this->awayModeReassign = $values['awayModeReassign'] ?? null; + $this->hasInboxSeat = $values['hasInboxSeat'] ?? null; + $this->teamIds = $values['teamIds'] ?? null; $this->avatar = $values['avatar'] ?? null; $this->emailVerified = $values['emailVerified'] ?? null; $this->app = $values['app'] ?? null; } /** - * @return 'admin' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'admin' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return string + * @return ?string */ - public function getEmail(): string + public function getEmail(): ?string { return $this->email; } /** - * @param string $value + * @param ?string $value */ - public function setEmail(string $value): self + public function setEmail(?string $value = null): self { $this->email = $value; return $this; } /** - * @return string + * @return ?string */ - public function getJobTitle(): string + public function getJobTitle(): ?string { return $this->jobTitle; } /** - * @param string $value + * @param ?string $value */ - public function setJobTitle(string $value): self + public function setJobTitle(?string $value = null): self { $this->jobTitle = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getAwayModeEnabled(): bool + public function getAwayModeEnabled(): ?bool { return $this->awayModeEnabled; } /** - * @param bool $value + * @param ?bool $value */ - public function setAwayModeEnabled(bool $value): self + public function setAwayModeEnabled(?bool $value = null): self { $this->awayModeEnabled = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getAwayModeReassign(): bool + public function getAwayModeReassign(): ?bool { return $this->awayModeReassign; } /** - * @param bool $value + * @param ?bool $value */ - public function setAwayModeReassign(bool $value): self + public function setAwayModeReassign(?bool $value = null): self { $this->awayModeReassign = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getHasInboxSeat(): bool + public function getHasInboxSeat(): ?bool { return $this->hasInboxSeat; } /** - * @param bool $value + * @param ?bool $value */ - public function setHasInboxSeat(bool $value): self + public function setHasInboxSeat(?bool $value = null): self { $this->hasInboxSeat = $value; return $this; } /** - * @return array + * @return ?array */ - public function getTeamIds(): array + public function getTeamIds(): ?array { return $this->teamIds; } /** - * @param array $value + * @param ?array $value */ - public function setTeamIds(array $value): self + public function setTeamIds(?array $value = null): self { $this->teamIds = $value; return $this; diff --git a/src/Types/AdminWithAppAvatar.php b/src/Types/AdminWithAppAvatar.php index 9066188..41f290c 100644 --- a/src/Types/AdminWithAppAvatar.php +++ b/src/Types/AdminWithAppAvatar.php @@ -11,7 +11,7 @@ class AdminWithAppAvatar extends JsonSerializableType { /** - * @var ?'avatar' $type This is a string that identifies the type of the object. It will always have the value `avatar`. + * @var ?string $type This is a string that identifies the type of the object. It will always have the value `avatar`. */ #[JsonProperty('type')] private ?string $type; @@ -24,7 +24,7 @@ class AdminWithAppAvatar extends JsonSerializableType /** * @param array{ - * type?: ?'avatar', + * type?: ?string, * imageUrl?: ?string, * } $values */ @@ -36,7 +36,7 @@ public function __construct( } /** - * @return ?'avatar' + * @return ?string */ public function getType(): ?string { @@ -44,7 +44,7 @@ public function getType(): ?string } /** - * @param ?'avatar' $value + * @param ?string $value */ public function setType(?string $value = null): self { diff --git a/src/Types/App.php b/src/Types/App.php index ee8a586..8d24f8a 100644 --- a/src/Types/App.php +++ b/src/Types/App.php @@ -11,184 +11,184 @@ class App extends JsonSerializableType { /** - * @var string $type + * @var ?string $type */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $idCode The id of the app. + * @var ?string $idCode The id of the app. */ #[JsonProperty('id_code')] - private string $idCode; + private ?string $idCode; /** - * @var string $name The name of the app. + * @var ?string $name The name of the app. */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var string $region The Intercom region the app is located in. + * @var ?string $region The Intercom region the app is located in. */ #[JsonProperty('region')] - private string $region; + private ?string $region; /** - * @var string $timezone The timezone of the region where the app is located. + * @var ?string $timezone The timezone of the region where the app is located. */ #[JsonProperty('timezone')] - private string $timezone; + private ?string $timezone; /** - * @var int $createdAt When the app was created. + * @var ?int $createdAt When the app was created. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** - * @var bool $identityVerification Whether or not the app uses identity verification. + * @var ?bool $identityVerification Whether or not the app uses identity verification. */ #[JsonProperty('identity_verification')] - private bool $identityVerification; + private ?bool $identityVerification; /** * @param array{ - * type: string, - * idCode: string, - * name: string, - * region: string, - * timezone: string, - * createdAt: int, - * identityVerification: bool, + * type?: ?string, + * idCode?: ?string, + * name?: ?string, + * region?: ?string, + * timezone?: ?string, + * createdAt?: ?int, + * identityVerification?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->idCode = $values['idCode']; - $this->name = $values['name']; - $this->region = $values['region']; - $this->timezone = $values['timezone']; - $this->createdAt = $values['createdAt']; - $this->identityVerification = $values['identityVerification']; + $this->type = $values['type'] ?? null; + $this->idCode = $values['idCode'] ?? null; + $this->name = $values['name'] ?? null; + $this->region = $values['region'] ?? null; + $this->timezone = $values['timezone'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->identityVerification = $values['identityVerification'] ?? null; } /** - * @return string + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param string $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getIdCode(): string + public function getIdCode(): ?string { return $this->idCode; } /** - * @param string $value + * @param ?string $value */ - public function setIdCode(string $value): self + public function setIdCode(?string $value = null): self { $this->idCode = $value; return $this; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return string + * @return ?string */ - public function getRegion(): string + public function getRegion(): ?string { return $this->region; } /** - * @param string $value + * @param ?string $value */ - public function setRegion(string $value): self + public function setRegion(?string $value = null): self { $this->region = $value; return $this; } /** - * @return string + * @return ?string */ - public function getTimezone(): string + public function getTimezone(): ?string { return $this->timezone; } /** - * @param string $value + * @param ?string $value */ - public function setTimezone(string $value): self + public function setTimezone(?string $value = null): self { $this->timezone = $value; return $this; } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getIdentityVerification(): bool + public function getIdentityVerification(): ?bool { return $this->identityVerification; } /** - * @param bool $value + * @param ?bool $value */ - public function setIdentityVerification(bool $value): self + public function setIdentityVerification(?bool $value = null): self { $this->identityVerification = $value; return $this; diff --git a/src/Types/ArticleContent.php b/src/Types/ArticleContent.php index 9581cf4..2a65347 100644 --- a/src/Types/ArticleContent.php +++ b/src/Types/ArticleContent.php @@ -11,40 +11,40 @@ class ArticleContent extends JsonSerializableType { /** - * @var 'article_content' $type The type of object - `article_content` . + * @var ?string $type The type of object - `article_content` . */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $title The title of the article. + * @var ?string $title The title of the article. */ #[JsonProperty('title')] - private string $title; + private ?string $title; /** - * @var string $description The description of the article. + * @var ?string $description The description of the article. */ #[JsonProperty('description')] - private string $description; + private ?string $description; /** - * @var string $body The body of the article. + * @var ?string $body The body of the article. */ #[JsonProperty('body')] - private string $body; + private ?string $body; /** - * @var int $authorId The ID of the author of the article. + * @var ?int $authorId The ID of the author of the article. */ #[JsonProperty('author_id')] - private int $authorId; + private ?int $authorId; /** - * @var value-of $state Whether the article is `published` or is a `draft` . + * @var ?value-of $state Whether the article is `published` or is a `draft` . */ #[JsonProperty('state')] - private string $state; + private ?string $state; /** * @var ?int $createdAt The time when the article was created (seconds). @@ -66,128 +66,128 @@ class ArticleContent extends JsonSerializableType /** * @param array{ - * type: 'article_content', - * title: string, - * description: string, - * body: string, - * authorId: int, - * state: value-of, + * type?: ?string, + * title?: ?string, + * description?: ?string, + * body?: ?string, + * authorId?: ?int, + * state?: ?value-of, * createdAt?: ?int, * updatedAt?: ?int, * url?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->title = $values['title']; - $this->description = $values['description']; - $this->body = $values['body']; - $this->authorId = $values['authorId']; - $this->state = $values['state']; + $this->type = $values['type'] ?? null; + $this->title = $values['title'] ?? null; + $this->description = $values['description'] ?? null; + $this->body = $values['body'] ?? null; + $this->authorId = $values['authorId'] ?? null; + $this->state = $values['state'] ?? null; $this->createdAt = $values['createdAt'] ?? null; $this->updatedAt = $values['updatedAt'] ?? null; $this->url = $values['url'] ?? null; } /** - * @return 'article_content' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'article_content' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getTitle(): string + public function getTitle(): ?string { return $this->title; } /** - * @param string $value + * @param ?string $value */ - public function setTitle(string $value): self + public function setTitle(?string $value = null): self { $this->title = $value; return $this; } /** - * @return string + * @return ?string */ - public function getDescription(): string + public function getDescription(): ?string { return $this->description; } /** - * @param string $value + * @param ?string $value */ - public function setDescription(string $value): self + public function setDescription(?string $value = null): self { $this->description = $value; return $this; } /** - * @return string + * @return ?string */ - public function getBody(): string + public function getBody(): ?string { return $this->body; } /** - * @param string $value + * @param ?string $value */ - public function setBody(string $value): self + public function setBody(?string $value = null): self { $this->body = $value; return $this; } /** - * @return int + * @return ?int */ - public function getAuthorId(): int + public function getAuthorId(): ?int { return $this->authorId; } /** - * @param int $value + * @param ?int $value */ - public function setAuthorId(int $value): self + public function setAuthorId(?int $value = null): self { $this->authorId = $value; return $this; } /** - * @return value-of + * @return ?value-of */ - public function getState(): string + public function getState(): ?string { return $this->state; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setState(string $value): self + public function setState(?string $value = null): self { $this->state = $value; return $this; diff --git a/src/Types/ArticleList.php b/src/Types/ArticleList.php index c5a0907..f3600c2 100644 --- a/src/Types/ArticleList.php +++ b/src/Types/ArticleList.php @@ -13,10 +13,10 @@ class ArticleList extends JsonSerializableType { /** - * @var 'list' $type The type of the object - `list`. + * @var ?'list' $type The type of the object - `list`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** * @var mixed $pages @@ -25,46 +25,46 @@ class ArticleList extends JsonSerializableType private mixed $pages; /** - * @var int $totalCount A count of the total number of articles. + * @var ?int $totalCount A count of the total number of articles. */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** - * @var array $data An array of Article objects + * @var ?array $data An array of Article objects */ #[JsonProperty('data'), ArrayType([ArticleListItem::class])] - private array $data; + private ?array $data; /** * @param array{ - * type: 'list', - * totalCount: int, - * data: array, + * type?: ?'list', * pages?: mixed, + * totalCount?: ?int, + * data?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; + $this->type = $values['type'] ?? null; $this->pages = $values['pages'] ?? null; - $this->totalCount = $values['totalCount']; - $this->data = $values['data']; + $this->totalCount = $values['totalCount'] ?? null; + $this->data = $values['data'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; @@ -88,34 +88,34 @@ public function setPages(mixed $value = null): self } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; diff --git a/src/Types/ArticleTranslatedContent.php b/src/Types/ArticleTranslatedContent.php index c1e9df1..98a2e11 100644 --- a/src/Types/ArticleTranslatedContent.php +++ b/src/Types/ArticleTranslatedContent.php @@ -11,7 +11,7 @@ class ArticleTranslatedContent extends JsonSerializableType { /** - * @var ?'article_translated_content' $type The type of object - article_translated_content. + * @var ?string $type The type of object - article_translated_content. */ #[JsonProperty('type')] private ?string $type; @@ -240,7 +240,7 @@ class ArticleTranslatedContent extends JsonSerializableType /** * @param array{ - * type?: ?'article_translated_content', + * type?: ?string, * ar?: ?ArticleContent, * bg?: ?ArticleContent, * bs?: ?ArticleContent, @@ -324,7 +324,7 @@ public function __construct( } /** - * @return ?'article_translated_content' + * @return ?string */ public function getType(): ?string { @@ -332,7 +332,7 @@ public function getType(): ?string } /** - * @param ?'article_translated_content' $value + * @param ?string $value */ public function setType(?string $value = null): self { diff --git a/src/Types/AwayStatusReason.php b/src/Types/AwayStatusReason.php new file mode 100644 index 0000000..47e4886 --- /dev/null +++ b/src/Types/AwayStatusReason.php @@ -0,0 +1,226 @@ +type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->label = $values['label'] ?? null; + $this->emoji = $values['emoji'] ?? null; + $this->order = $values['order'] ?? null; + $this->deleted = $values['deleted'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getLabel(): ?string + { + return $this->label; + } + + /** + * @param ?string $value + */ + public function setLabel(?string $value = null): self + { + $this->label = $value; + return $this; + } + + /** + * @return ?string + */ + public function getEmoji(): ?string + { + return $this->emoji; + } + + /** + * @param ?string $value + */ + public function setEmoji(?string $value = null): self + { + $this->emoji = $value; + return $this; + } + + /** + * @return ?int + */ + public function getOrder(): ?int + { + return $this->order; + } + + /** + * @param ?int $value + */ + public function setOrder(?int $value = null): self + { + $this->order = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getDeleted(): ?bool + { + return $this->deleted; + } + + /** + * @param ?bool $value + */ + public function setDeleted(?bool $value = null): self + { + $this->deleted = $value; + return $this; + } + + /** + * @return ?int + */ + public function getCreatedAt(): ?int + { + return $this->createdAt; + } + + /** + * @param ?int $value + */ + public function setCreatedAt(?int $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getUpdatedAt(): ?int + { + return $this->updatedAt; + } + + /** + * @param ?int $value + */ + public function setUpdatedAt(?int $value = null): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ButtonComponent.php b/src/Types/ButtonComponent.php deleted file mode 100644 index 99441a6..0000000 --- a/src/Types/ButtonComponent.php +++ /dev/null @@ -1,157 +0,0 @@ - $style Styles the button. Default is 'primary'. - */ - #[JsonProperty('style')] - private ?string $style; - - /** - * @var ?bool $disabled Styles the button and prevents the action. Default is false. - */ - #[JsonProperty('disabled')] - private ?bool $disabled; - - /** - * @param array{ - * id: string, - * label: string, - * action: ActionComponent, - * style?: ?value-of, - * disabled?: ?bool, - * } $values - */ - public function __construct( - array $values, - ) { - $this->id = $values['id']; - $this->label = $values['label']; - $this->action = $values['action']; - $this->style = $values['style'] ?? null; - $this->disabled = $values['disabled'] ?? null; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return string - */ - public function getLabel(): string - { - return $this->label; - } - - /** - * @param string $value - */ - public function setLabel(string $value): self - { - $this->label = $value; - return $this; - } - - /** - * @return ActionComponent - */ - public function getAction(): ActionComponent - { - return $this->action; - } - - /** - * @param ActionComponent $value - */ - public function setAction(ActionComponent $value): self - { - $this->action = $value; - return $this; - } - - /** - * @return ?value-of - */ - public function getStyle(): ?string - { - return $this->style; - } - - /** - * @param ?value-of $value - */ - public function setStyle(?string $value = null): self - { - $this->style = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getDisabled(): ?bool - { - return $this->disabled; - } - - /** - * @param ?bool $value - */ - public function setDisabled(?bool $value = null): self - { - $this->disabled = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/ButtonComponentStyle.php b/src/Types/ButtonComponentStyle.php deleted file mode 100644 index f048958..0000000 --- a/src/Types/ButtonComponentStyle.php +++ /dev/null @@ -1,10 +0,0 @@ - $data A list of calls. */ - #[JsonProperty('pages')] - private ?CursorPages $pages; + #[JsonProperty('data'), ArrayType([Call::class])] + private ?array $data; /** - * @var int $totalCount A count of the total number of News Items. + * @var ?int $totalCount Total number of items available. */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** - * @var array $data An array of News Items + * @var ?CursorPages $pages */ - #[JsonProperty('data'), ArrayType([NewsItem::class])] - private array $data; + #[JsonProperty('pages')] + private ?CursorPages $pages; /** * @param array{ - * type: 'list', - * totalCount: int, - * data: array, + * type?: ?string, + * data?: ?array, + * totalCount?: ?int, * pages?: ?CursorPages, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; $this->pages = $values['pages'] ?? null; - $this->totalCount = $values['totalCount']; - $this->data = $values['data']; } /** - * @return 'list' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return ?CursorPages + * @return ?array */ - public function getPages(): ?CursorPages + public function getData(): ?array { - return $this->pages; + return $this->data; } /** - * @param ?CursorPages $value + * @param ?array $value */ - public function setPages(?CursorPages $value = null): self + public function setData(?array $value = null): self { - $this->pages = $value; + $this->data = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; } /** - * @return array + * @return ?CursorPages */ - public function getData(): array + public function getPages(): ?CursorPages { - return $this->data; + return $this->pages; } /** - * @param array $value + * @param ?CursorPages $value */ - public function setData(array $value): self + public function setPages(?CursorPages $value = null): self { - $this->data = $value; + $this->pages = $value; return $this; } diff --git a/src/Types/CanvasObject.php b/src/Types/CanvasObject.php deleted file mode 100644 index 42288ca..0000000 --- a/src/Types/CanvasObject.php +++ /dev/null @@ -1,110 +0,0 @@ - $storedData Optional Stored Data that you want to be returned in the next sent request. Max Size is 64KB. - */ - #[JsonProperty('stored_data'), ArrayType(['string' => 'mixed'])] - private ?array $storedData; - - /** - * @param array{ - * content: ContentObject, - * contentUrl?: ?string, - * storedData?: ?array, - * } $values - */ - public function __construct( - array $values, - ) { - $this->content = $values['content']; - $this->contentUrl = $values['contentUrl'] ?? null; - $this->storedData = $values['storedData'] ?? null; - } - - /** - * @return ContentObject - */ - public function getContent(): ContentObject - { - return $this->content; - } - - /** - * @param ContentObject $value - */ - public function setContent(ContentObject $value): self - { - $this->content = $value; - return $this; - } - - /** - * @return ?string - */ - public function getContentUrl(): ?string - { - return $this->contentUrl; - } - - /** - * @param ?string $value - */ - public function setContentUrl(?string $value = null): self - { - $this->contentUrl = $value; - return $this; - } - - /** - * @return ?array - */ - public function getStoredData(): ?array - { - return $this->storedData; - } - - /** - * @param ?array $value - */ - public function setStoredData(?array $value = null): self - { - $this->storedData = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/CheckboxComponent.php b/src/Types/CheckboxComponent.php deleted file mode 100644 index 8029155..0000000 --- a/src/Types/CheckboxComponent.php +++ /dev/null @@ -1,184 +0,0 @@ - $option The list of options. Minimum of 1. - */ - #[JsonProperty('option'), ArrayType([CheckboxOption::class])] - private array $option; - - /** - * @var string $label The text shown above the options. - */ - #[JsonProperty('label')] - private string $label; - - /** - * @var ?array $value The option's that are selected by default. - */ - #[JsonProperty('value'), ArrayType(['string'])] - private ?array $value; - - /** - * @var ?value-of $saveState Styles the input. Default is `unsaved`. Prevent action with `saved`. - */ - #[JsonProperty('save_state')] - private ?string $saveState; - - /** - * @var ?bool $disabled Styles all options and prevents the action. Default is false. Will be overridden if save_state is saved. - */ - #[JsonProperty('disabled')] - private ?bool $disabled; - - /** - * @param array{ - * id: string, - * option: array, - * label: string, - * value?: ?array, - * saveState?: ?value-of, - * disabled?: ?bool, - * } $values - */ - public function __construct( - array $values, - ) { - $this->id = $values['id']; - $this->option = $values['option']; - $this->label = $values['label']; - $this->value = $values['value'] ?? null; - $this->saveState = $values['saveState'] ?? null; - $this->disabled = $values['disabled'] ?? null; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return array - */ - public function getOption(): array - { - return $this->option; - } - - /** - * @param array $value - */ - public function setOption(array $value): self - { - $this->option = $value; - return $this; - } - - /** - * @return string - */ - public function getLabel(): string - { - return $this->label; - } - - /** - * @param string $value - */ - public function setLabel(string $value): self - { - $this->label = $value; - return $this; - } - - /** - * @return ?array - */ - public function getValue(): ?array - { - return $this->value; - } - - /** - * @param ?array $value - */ - public function setValue(?array $value = null): self - { - $this->value = $value; - return $this; - } - - /** - * @return ?value-of - */ - public function getSaveState(): ?string - { - return $this->saveState; - } - - /** - * @param ?value-of $value - */ - public function setSaveState(?string $value = null): self - { - $this->saveState = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getDisabled(): ?bool - { - return $this->disabled; - } - - /** - * @param ?bool $value - */ - public function setDisabled(?bool $value = null): self - { - $this->disabled = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/CheckboxComponentSaveState.php b/src/Types/CheckboxComponentSaveState.php deleted file mode 100644 index fc07bc6..0000000 --- a/src/Types/CheckboxComponentSaveState.php +++ /dev/null @@ -1,10 +0,0 @@ -type = $values['type']; - $this->id = $values['id']; - $this->text = $values['text']; - $this->disabled = $values['disabled'] ?? null; - } - - /** - * @return 'option' - */ - public function getType(): string - { - return $this->type; - } - - /** - * @param 'option' $value - */ - public function setType(string $value): self - { - $this->type = $value; - return $this; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return string - */ - public function getText(): string - { - return $this->text; - } - - /** - * @param string $value - */ - public function setText(string $value): self - { - $this->text = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getDisabled(): ?bool - { - return $this->disabled; - } - - /** - * @param ?bool $value - */ - public function setDisabled(?bool $value = null): self - { - $this->disabled = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/CollectionList.php b/src/Types/CollectionList.php index 22e19ca..42714b4 100644 --- a/src/Types/CollectionList.php +++ b/src/Types/CollectionList.php @@ -13,10 +13,10 @@ class CollectionList extends JsonSerializableType { /** - * @var 'list' $type The type of the object - `list`. + * @var ?'list' $type The type of the object - `list`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** * @var ?OffsetPages $pages @@ -25,46 +25,46 @@ class CollectionList extends JsonSerializableType private ?OffsetPages $pages; /** - * @var int $totalCount A count of the total number of collections. + * @var ?int $totalCount A count of the total number of collections. */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** - * @var array $data An array of collection objects + * @var ?array $data An array of collection objects */ #[JsonProperty('data'), ArrayType([Collection::class])] - private array $data; + private ?array $data; /** * @param array{ - * type: 'list', - * totalCount: int, - * data: array, + * type?: ?'list', * pages?: ?OffsetPages, + * totalCount?: ?int, + * data?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; + $this->type = $values['type'] ?? null; $this->pages = $values['pages'] ?? null; - $this->totalCount = $values['totalCount']; - $this->data = $values['data']; + $this->totalCount = $values['totalCount'] ?? null; + $this->data = $values['data'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; @@ -88,34 +88,34 @@ public function setPages(?OffsetPages $value = null): self } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; diff --git a/src/Types/CompanyAttachedContacts.php b/src/Types/CompanyAttachedContacts.php index a6f51d7..58daef1 100644 --- a/src/Types/CompanyAttachedContacts.php +++ b/src/Types/CompanyAttachedContacts.php @@ -13,22 +13,22 @@ class CompanyAttachedContacts extends JsonSerializableType { /** - * @var 'list' $type The type of object - `list` + * @var ?'list' $type The type of object - `list` */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $data An array containing Contact Objects + * @var ?array $data An array containing Contact Objects */ #[JsonProperty('data'), ArrayType([Contact::class])] - private array $data; + private ?array $data; /** - * @var int $totalCount The total number of contacts + * @var ?int $totalCount The total number of contacts */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** * @var ?CursorPages $pages @@ -38,67 +38,67 @@ class CompanyAttachedContacts extends JsonSerializableType /** * @param array{ - * type: 'list', - * data: array, - * totalCount: int, + * type?: ?'list', + * data?: ?array, + * totalCount?: ?int, * pages?: ?CursorPages, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->data = $values['data']; - $this->totalCount = $values['totalCount']; + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; $this->pages = $values['pages'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; diff --git a/src/Types/CompanyAttachedSegments.php b/src/Types/CompanyAttachedSegments.php index 29efd83..4fd56eb 100644 --- a/src/Types/CompanyAttachedSegments.php +++ b/src/Types/CompanyAttachedSegments.php @@ -13,59 +13,59 @@ class CompanyAttachedSegments extends JsonSerializableType { /** - * @var 'list' $type The type of object - `list` + * @var ?'list' $type The type of object - `list` */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $data An array containing Segment Objects + * @var ?array $data An array containing Segment Objects */ #[JsonProperty('data'), ArrayType([Segment::class])] - private array $data; + private ?array $data; /** * @param array{ - * type: 'list', - * data: array, + * type?: ?'list', + * data?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->data = $values['data']; + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; diff --git a/src/Types/CompanyData.php b/src/Types/CompanyData.php new file mode 100644 index 0000000..11bef28 --- /dev/null +++ b/src/Types/CompanyData.php @@ -0,0 +1,104 @@ +id = $values['id'] ?? null; + $this->type = $values['type'] ?? null; + $this->url = $values['url'] ?? null; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?'company' + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?'company' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getUrl(): ?string + { + return $this->url; + } + + /** + * @param ?string $value + */ + public function setUrl(?string $value = null): self + { + $this->url = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/CompanyList.php b/src/Types/CompanyList.php index 7999660..71de1a6 100644 --- a/src/Types/CompanyList.php +++ b/src/Types/CompanyList.php @@ -19,30 +19,30 @@ class CompanyList extends JsonSerializableType private ?OffsetPages $pages; /** - * @var int $totalCount The total number of companies. + * @var ?int $totalCount The total number of companies. */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** - * @var array $data An array containing Company Objects. + * @var ?array $data An array containing Company Objects. */ #[JsonProperty('data'), ArrayType([Company::class])] - private array $data; + private ?array $data; /** * @param array{ - * totalCount: int, - * data: array, * pages?: ?OffsetPages, + * totalCount?: ?int, + * data?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { $this->pages = $values['pages'] ?? null; - $this->totalCount = $values['totalCount']; - $this->data = $values['data']; + $this->totalCount = $values['totalCount'] ?? null; + $this->data = $values['data'] ?? null; } /** @@ -63,34 +63,34 @@ public function setPages(?OffsetPages $value = null): self } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; diff --git a/src/Types/CompanyScroll.php b/src/Types/CompanyScroll.php index 4cdedff..88c3774 100644 --- a/src/Types/CompanyScroll.php +++ b/src/Types/CompanyScroll.php @@ -13,16 +13,16 @@ class CompanyScroll extends JsonSerializableType { /** - * @var 'list' $type The type of object - `list` + * @var ?'list' $type The type of object - `list` */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $data + * @var ?array $data */ #[JsonProperty('data'), ArrayType([Company::class])] - private array $data; + private ?array $data; /** * @var ?CursorPages $pages @@ -44,52 +44,52 @@ class CompanyScroll extends JsonSerializableType /** * @param array{ - * type: 'list', - * data: array, + * type?: ?'list', + * data?: ?array, * pages?: ?CursorPages, * totalCount?: ?int, * scrollParam?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->data = $values['data']; + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; $this->pages = $values['pages'] ?? null; $this->totalCount = $values['totalCount'] ?? null; $this->scrollParam = $values['scrollParam'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; diff --git a/src/Types/Component.php b/src/Types/Component.php deleted file mode 100644 index 425b440..0000000 --- a/src/Types/Component.php +++ /dev/null @@ -1,703 +0,0 @@ -type = $values['type']; - $this->value = $values['value']; - } - - /** - * @return ( - * 'button' - * |'checkbox' - * |'dropdown' - * |'input' - * |'list' - * |'single-select' - * |'textarea' - * |'data-table' - * |'divider' - * |'image' - * |'spacer' - * |'text' - * |'_unknown' - * ) - */ - public function getType(): string - { - return $this->type; - } - - /** - * @return ( - * ButtonComponent - * |CheckboxComponent - * |DropdownComponent - * |InputComponent - * |ListComponent - * |SingleSelectComponent - * |TextAreaComponent - * |DataTableComponent - * |DividerComponent - * |ImageComponent - * |SpacerComponent - * |TextComponent - * |mixed - * ) - */ - public function getValue(): mixed - { - return $this->value; - } - - /** - * @param ButtonComponent $button - * @return Component - */ - public static function button(ButtonComponent $button): Component - { - return new Component([ - 'type' => 'button', - 'value' => $button, - ]); - } - - /** - * @param CheckboxComponent $checkbox - * @return Component - */ - public static function checkbox(CheckboxComponent $checkbox): Component - { - return new Component([ - 'type' => 'checkbox', - 'value' => $checkbox, - ]); - } - - /** - * @param DropdownComponent $dropdown - * @return Component - */ - public static function dropdown(DropdownComponent $dropdown): Component - { - return new Component([ - 'type' => 'dropdown', - 'value' => $dropdown, - ]); - } - - /** - * @param InputComponent $input - * @return Component - */ - public static function input(InputComponent $input): Component - { - return new Component([ - 'type' => 'input', - 'value' => $input, - ]); - } - - /** - * @param ListComponent $list - * @return Component - */ - public static function list(ListComponent $list): Component - { - return new Component([ - 'type' => 'list', - 'value' => $list, - ]); - } - - /** - * @param SingleSelectComponent $singleSelect - * @return Component - */ - public static function singleSelect(SingleSelectComponent $singleSelect): Component - { - return new Component([ - 'type' => 'single-select', - 'value' => $singleSelect, - ]); - } - - /** - * @param TextAreaComponent $textarea - * @return Component - */ - public static function textarea(TextAreaComponent $textarea): Component - { - return new Component([ - 'type' => 'textarea', - 'value' => $textarea, - ]); - } - - /** - * @param DataTableComponent $dataTable - * @return Component - */ - public static function dataTable(DataTableComponent $dataTable): Component - { - return new Component([ - 'type' => 'data-table', - 'value' => $dataTable, - ]); - } - - /** - * @param DividerComponent $divider - * @return Component - */ - public static function divider(DividerComponent $divider): Component - { - return new Component([ - 'type' => 'divider', - 'value' => $divider, - ]); - } - - /** - * @param ImageComponent $image - * @return Component - */ - public static function image(ImageComponent $image): Component - { - return new Component([ - 'type' => 'image', - 'value' => $image, - ]); - } - - /** - * @param SpacerComponent $spacer - * @return Component - */ - public static function spacer(SpacerComponent $spacer): Component - { - return new Component([ - 'type' => 'spacer', - 'value' => $spacer, - ]); - } - - /** - * @param TextComponent $text - * @return Component - */ - public static function text(TextComponent $text): Component - { - return new Component([ - 'type' => 'text', - 'value' => $text, - ]); - } - - /** - * @return bool - */ - public function isButton(): bool - { - return $this->value instanceof ButtonComponent && $this->type === 'button'; - } - - /** - * @return ButtonComponent - */ - public function asButton(): ButtonComponent - { - if (!($this->value instanceof ButtonComponent && $this->type === 'button')) { - throw new Exception( - "Expected button; got " . $this->type . " with value of type " . get_debug_type($this->value), - ); - } - - return $this->value; - } - - /** - * @return bool - */ - public function isCheckbox(): bool - { - return $this->value instanceof CheckboxComponent && $this->type === 'checkbox'; - } - - /** - * @return CheckboxComponent - */ - public function asCheckbox(): CheckboxComponent - { - if (!($this->value instanceof CheckboxComponent && $this->type === 'checkbox')) { - throw new Exception( - "Expected checkbox; got " . $this->type . " with value of type " . get_debug_type($this->value), - ); - } - - return $this->value; - } - - /** - * @return bool - */ - public function isDropdown(): bool - { - return $this->value instanceof DropdownComponent && $this->type === 'dropdown'; - } - - /** - * @return DropdownComponent - */ - public function asDropdown(): DropdownComponent - { - if (!($this->value instanceof DropdownComponent && $this->type === 'dropdown')) { - throw new Exception( - "Expected dropdown; got " . $this->type . " with value of type " . get_debug_type($this->value), - ); - } - - return $this->value; - } - - /** - * @return bool - */ - public function isInput(): bool - { - return $this->value instanceof InputComponent && $this->type === 'input'; - } - - /** - * @return InputComponent - */ - public function asInput(): InputComponent - { - if (!($this->value instanceof InputComponent && $this->type === 'input')) { - throw new Exception( - "Expected input; got " . $this->type . " with value of type " . get_debug_type($this->value), - ); - } - - return $this->value; - } - - /** - * @return bool - */ - public function isList_(): bool - { - return $this->value instanceof ListComponent && $this->type === 'list'; - } - - /** - * @return ListComponent - */ - public function asList_(): ListComponent - { - if (!($this->value instanceof ListComponent && $this->type === 'list')) { - throw new Exception( - "Expected list; got " . $this->type . " with value of type " . get_debug_type($this->value), - ); - } - - return $this->value; - } - - /** - * @return bool - */ - public function isSingleSelect(): bool - { - return $this->value instanceof SingleSelectComponent && $this->type === 'single-select'; - } - - /** - * @return SingleSelectComponent - */ - public function asSingleSelect(): SingleSelectComponent - { - if (!($this->value instanceof SingleSelectComponent && $this->type === 'single-select')) { - throw new Exception( - "Expected single-select; got " . $this->type . " with value of type " . get_debug_type($this->value), - ); - } - - return $this->value; - } - - /** - * @return bool - */ - public function isTextarea(): bool - { - return $this->value instanceof TextAreaComponent && $this->type === 'textarea'; - } - - /** - * @return TextAreaComponent - */ - public function asTextarea(): TextAreaComponent - { - if (!($this->value instanceof TextAreaComponent && $this->type === 'textarea')) { - throw new Exception( - "Expected textarea; got " . $this->type . " with value of type " . get_debug_type($this->value), - ); - } - - return $this->value; - } - - /** - * @return bool - */ - public function isDataTable(): bool - { - return $this->value instanceof DataTableComponent && $this->type === 'data-table'; - } - - /** - * @return DataTableComponent - */ - public function asDataTable(): DataTableComponent - { - if (!($this->value instanceof DataTableComponent && $this->type === 'data-table')) { - throw new Exception( - "Expected data-table; got " . $this->type . " with value of type " . get_debug_type($this->value), - ); - } - - return $this->value; - } - - /** - * @return bool - */ - public function isDivider(): bool - { - return $this->value instanceof DividerComponent && $this->type === 'divider'; - } - - /** - * @return DividerComponent - */ - public function asDivider(): DividerComponent - { - if (!($this->value instanceof DividerComponent && $this->type === 'divider')) { - throw new Exception( - "Expected divider; got " . $this->type . " with value of type " . get_debug_type($this->value), - ); - } - - return $this->value; - } - - /** - * @return bool - */ - public function isImage(): bool - { - return $this->value instanceof ImageComponent && $this->type === 'image'; - } - - /** - * @return ImageComponent - */ - public function asImage(): ImageComponent - { - if (!($this->value instanceof ImageComponent && $this->type === 'image')) { - throw new Exception( - "Expected image; got " . $this->type . " with value of type " . get_debug_type($this->value), - ); - } - - return $this->value; - } - - /** - * @return bool - */ - public function isSpacer(): bool - { - return $this->value instanceof SpacerComponent && $this->type === 'spacer'; - } - - /** - * @return SpacerComponent - */ - public function asSpacer(): SpacerComponent - { - if (!($this->value instanceof SpacerComponent && $this->type === 'spacer')) { - throw new Exception( - "Expected spacer; got " . $this->type . " with value of type " . get_debug_type($this->value), - ); - } - - return $this->value; - } - - /** - * @return bool - */ - public function isText(): bool - { - return $this->value instanceof TextComponent && $this->type === 'text'; - } - - /** - * @return TextComponent - */ - public function asText(): TextComponent - { - if (!($this->value instanceof TextComponent && $this->type === 'text')) { - throw new Exception( - "Expected text; got " . $this->type . " with value of type " . get_debug_type($this->value), - ); - } - - return $this->value; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } - - /** - * @return array - */ - public function jsonSerialize(): array - { - $result = []; - $result['type'] = $this->type; - - $base = parent::jsonSerialize(); - $result = array_merge($base, $result); - - switch ($this->type) { - case 'button': - $value = $this->asButton()->jsonSerialize(); - $result = array_merge($value, $result); - break; - case 'checkbox': - $value = $this->asCheckbox()->jsonSerialize(); - $result = array_merge($value, $result); - break; - case 'dropdown': - $value = $this->asDropdown()->jsonSerialize(); - $result = array_merge($value, $result); - break; - case 'input': - $value = $this->asInput()->jsonSerialize(); - $result = array_merge($value, $result); - break; - case 'list': - $value = $this->asList_()->jsonSerialize(); - $result = array_merge($value, $result); - break; - case 'single-select': - $value = $this->asSingleSelect()->jsonSerialize(); - $result = array_merge($value, $result); - break; - case 'textarea': - $value = $this->asTextarea()->jsonSerialize(); - $result = array_merge($value, $result); - break; - case 'data-table': - $value = $this->asDataTable()->jsonSerialize(); - $result = array_merge($value, $result); - break; - case 'divider': - $value = $this->asDivider()->jsonSerialize(); - $result = array_merge($value, $result); - break; - case 'image': - $value = $this->asImage()->jsonSerialize(); - $result = array_merge($value, $result); - break; - case 'spacer': - $value = $this->asSpacer()->jsonSerialize(); - $result = array_merge($value, $result); - break; - case 'text': - $value = $this->asText()->jsonSerialize(); - $result = array_merge($value, $result); - break; - case '_unknown': - default: - if (is_null($this->value)) { - break; - } - if ($this->value instanceof JsonSerializableType) { - $value = $this->value->jsonSerialize(); - $result = array_merge($value, $result); - } elseif (is_array($this->value)) { - $result = array_merge($this->value, $result); - } - } - - return $result; - } - - /** - * @param string $json - */ - public static function fromJson(string $json): static - { - $decodedJson = JsonDecoder::decode($json); - if (!is_array($decodedJson)) { - throw new Exception("Unexpected non-array decoded type: " . gettype($decodedJson)); - } - return self::jsonDeserialize($decodedJson); - } - - /** - * @param array $data - */ - public static function jsonDeserialize(array $data): static - { - $args = []; - if (!array_key_exists('type', $data)) { - throw new Exception( - "JSON data is missing property 'type'", - ); - } - $type = $data['type']; - if (!(is_string($type))) { - throw new Exception( - "Expected property 'type' in JSON data to be string, instead received " . get_debug_type($data['type']), - ); - } - - $args['type'] = $type; - switch ($type) { - case 'button': - $args['value'] = ButtonComponent::jsonDeserialize($data); - break; - case 'checkbox': - $args['value'] = CheckboxComponent::jsonDeserialize($data); - break; - case 'dropdown': - $args['value'] = DropdownComponent::jsonDeserialize($data); - break; - case 'input': - $args['value'] = InputComponent::jsonDeserialize($data); - break; - case 'list': - $args['value'] = ListComponent::jsonDeserialize($data); - break; - case 'single-select': - $args['value'] = SingleSelectComponent::jsonDeserialize($data); - break; - case 'textarea': - $args['value'] = TextAreaComponent::jsonDeserialize($data); - break; - case 'data-table': - $args['value'] = DataTableComponent::jsonDeserialize($data); - break; - case 'divider': - $args['value'] = DividerComponent::jsonDeserialize($data); - break; - case 'image': - $args['value'] = ImageComponent::jsonDeserialize($data); - break; - case 'spacer': - $args['value'] = SpacerComponent::jsonDeserialize($data); - break; - case 'text': - $args['value'] = TextComponent::jsonDeserialize($data); - break; - case '_unknown': - default: - $args['type'] = '_unknown'; - $args['value'] = $data; - } - - // @phpstan-ignore-next-line - return new static($args); - } -} diff --git a/src/Types/ConfigureRequestComponentId.php b/src/Types/ConfigureRequestComponentId.php deleted file mode 100644 index f7308bb..0000000 --- a/src/Types/ConfigureRequestComponentId.php +++ /dev/null @@ -1,203 +0,0 @@ - $inputValues A list of key/value pairs of data, inputted by the teammate on the current canvas. - */ - #[JsonProperty('input_values'), ArrayType(['string' => 'mixed'])] - private array $inputValues; - - /** - * @param array{ - * workspaceId: string, - * workspaceRegion: string, - * componentId: string, - * admin: Admin, - * context: Context, - * currentCanvas: CanvasObject, - * inputValues: array, - * } $values - */ - public function __construct( - array $values, - ) { - $this->workspaceId = $values['workspaceId']; - $this->workspaceRegion = $values['workspaceRegion']; - $this->componentId = $values['componentId']; - $this->admin = $values['admin']; - $this->context = $values['context']; - $this->currentCanvas = $values['currentCanvas']; - $this->inputValues = $values['inputValues']; - } - - /** - * @return string - */ - public function getWorkspaceId(): string - { - return $this->workspaceId; - } - - /** - * @param string $value - */ - public function setWorkspaceId(string $value): self - { - $this->workspaceId = $value; - return $this; - } - - /** - * @return string - */ - public function getWorkspaceRegion(): string - { - return $this->workspaceRegion; - } - - /** - * @param string $value - */ - public function setWorkspaceRegion(string $value): self - { - $this->workspaceRegion = $value; - return $this; - } - - /** - * @return string - */ - public function getComponentId(): string - { - return $this->componentId; - } - - /** - * @param string $value - */ - public function setComponentId(string $value): self - { - $this->componentId = $value; - return $this; - } - - /** - * @return Admin - */ - public function getAdmin(): Admin - { - return $this->admin; - } - - /** - * @param Admin $value - */ - public function setAdmin(Admin $value): self - { - $this->admin = $value; - return $this; - } - - /** - * @return Context - */ - public function getContext(): Context - { - return $this->context; - } - - /** - * @param Context $value - */ - public function setContext(Context $value): self - { - $this->context = $value; - return $this; - } - - /** - * @return CanvasObject - */ - public function getCurrentCanvas(): CanvasObject - { - return $this->currentCanvas; - } - - /** - * @param CanvasObject $value - */ - public function setCurrentCanvas(CanvasObject $value): self - { - $this->currentCanvas = $value; - return $this; - } - - /** - * @return array - */ - public function getInputValues(): array - { - return $this->inputValues; - } - - /** - * @param array $value - */ - public function setInputValues(array $value): self - { - $this->inputValues = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/ConfigureRequestZero.php b/src/Types/ConfigureRequestZero.php deleted file mode 100644 index 0ed4292..0000000 --- a/src/Types/ConfigureRequestZero.php +++ /dev/null @@ -1,102 +0,0 @@ -workspaceId = $values['workspaceId']; - $this->admin = $values['admin']; - $this->context = $values['context']; - } - - /** - * @return string - */ - public function getWorkspaceId(): string - { - return $this->workspaceId; - } - - /** - * @param string $value - */ - public function setWorkspaceId(string $value): self - { - $this->workspaceId = $value; - return $this; - } - - /** - * @return Admin - */ - public function getAdmin(): Admin - { - return $this->admin; - } - - /** - * @param Admin $value - */ - public function setAdmin(Admin $value): self - { - $this->admin = $value; - return $this; - } - - /** - * @return Context - */ - public function getContext(): Context - { - return $this->context; - } - - /** - * @param Context $value - */ - public function setContext(Context $value): self - { - $this->context = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/ConfigureResponseCanvas.php b/src/Types/ConfigureResponseCanvas.php deleted file mode 100644 index cfe2f39..0000000 --- a/src/Types/ConfigureResponseCanvas.php +++ /dev/null @@ -1,51 +0,0 @@ -canvas = $values['canvas']; - } - - /** - * @return CanvasObject - */ - public function getCanvas(): CanvasObject - { - return $this->canvas; - } - - /** - * @param CanvasObject $value - */ - public function setCanvas(CanvasObject $value): self - { - $this->canvas = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/ContactArchived.php b/src/Types/ContactArchived.php index 5624a93..7e22c6c 100644 --- a/src/Types/ContactArchived.php +++ b/src/Types/ContactArchived.php @@ -3,6 +3,7 @@ namespace Intercom\Types; use Intercom\Core\Json\JsonSerializableType; +use Intercom\Traits\ContactReference; use Intercom\Core\Json\JsonProperty; /** @@ -10,110 +11,43 @@ */ class ContactArchived extends JsonSerializableType { - /** - * @var 'contact' $type always contact - */ - #[JsonProperty('type')] - private string $type; - - /** - * @var string $id The unique identifier for the contact which is given by Intercom. - */ - #[JsonProperty('id')] - private string $id; + use ContactReference; /** - * @var ?string $externalId The unique identifier for the contact which is provided by the Client. - */ - #[JsonProperty('external_id')] - private ?string $externalId; - - /** - * @var bool $archived Whether the contact is archived or not. + * @var ?bool $archived Whether the contact is archived or not. */ #[JsonProperty('archived')] - private bool $archived; + private ?bool $archived; /** * @param array{ - * type: 'contact', - * id: string, - * archived: bool, + * type?: ?'contact', + * id?: ?string, * externalId?: ?string, + * archived?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; $this->externalId = $values['externalId'] ?? null; - $this->archived = $values['archived']; - } - - /** - * @return 'contact' - */ - public function getType(): string - { - return $this->type; - } - - /** - * @param 'contact' $value - */ - public function setType(string $value): self - { - $this->type = $value; - return $this; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return ?string - */ - public function getExternalId(): ?string - { - return $this->externalId; - } - - /** - * @param ?string $value - */ - public function setExternalId(?string $value = null): self - { - $this->externalId = $value; - return $this; + $this->archived = $values['archived'] ?? null; } /** - * @return bool + * @return ?bool */ - public function getArchived(): bool + public function getArchived(): ?bool { return $this->archived; } /** - * @param bool $value + * @param ?bool $value */ - public function setArchived(bool $value): self + public function setArchived(?bool $value = null): self { $this->archived = $value; return $this; diff --git a/src/Types/ContactAttachedCompanies.php b/src/Types/ContactAttachedCompanies.php index f4de347..913eb5a 100644 --- a/src/Types/ContactAttachedCompanies.php +++ b/src/Types/ContactAttachedCompanies.php @@ -13,22 +13,22 @@ class ContactAttachedCompanies extends JsonSerializableType { /** - * @var 'list' $type The type of object + * @var ?'list' $type The type of object */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $companies An array containing Company Objects + * @var ?array $companies An array containing Company Objects */ #[JsonProperty('companies'), ArrayType([Company::class])] - private array $companies; + private ?array $companies; /** - * @var int $totalCount The total number of companies associated to this contact + * @var ?int $totalCount The total number of companies associated to this contact */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** * @var ?PagesLink $pages @@ -38,67 +38,67 @@ class ContactAttachedCompanies extends JsonSerializableType /** * @param array{ - * type: 'list', - * companies: array, - * totalCount: int, + * type?: ?'list', + * companies?: ?array, + * totalCount?: ?int, * pages?: ?PagesLink, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->companies = $values['companies']; - $this->totalCount = $values['totalCount']; + $this->type = $values['type'] ?? null; + $this->companies = $values['companies'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; $this->pages = $values['pages'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getCompanies(): array + public function getCompanies(): ?array { return $this->companies; } /** - * @param array $value + * @param ?array $value */ - public function setCompanies(array $value): self + public function setCompanies(?array $value = null): self { $this->companies = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; diff --git a/src/Types/ContactBlocked.php b/src/Types/ContactBlocked.php new file mode 100644 index 0000000..f362170 --- /dev/null +++ b/src/Types/ContactBlocked.php @@ -0,0 +1,63 @@ +type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->externalId = $values['externalId'] ?? null; + $this->blocked = $values['blocked'] ?? null; + } + + /** + * @return ?bool + */ + public function getBlocked(): ?bool + { + return $this->blocked; + } + + /** + * @param ?bool $value + */ + public function setBlocked(?bool $value = null): self + { + $this->blocked = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ContactCompanies.php b/src/Types/ContactCompanies.php index e70b4cd..683bb06 100644 --- a/src/Types/ContactCompanies.php +++ b/src/Types/ContactCompanies.php @@ -7,78 +7,53 @@ use Intercom\Core\Types\ArrayType; /** - * An object containing companies meta data about the companies that a contact has. Up to 10 will be displayed here. Use the url to get more. + * An object with metadata about companies attached to a contact . Up to 10 will be displayed here. Use the url to get more. */ class ContactCompanies extends JsonSerializableType { /** - * @var ?'list' $type The type of object + * @var ?array $data An array of company data objects attached to the contact. */ - #[JsonProperty('type')] - private ?string $type; - - /** - * @var ?array $data An array containing Company Objects - */ - #[JsonProperty('data'), ArrayType([ContactCompany::class])] + #[JsonProperty('data'), ArrayType([CompanyData::class])] private ?array $data; /** - * @var string $url Url to get more company resources for this contact + * @var ?string $url Url to get more company resources for this contact */ #[JsonProperty('url')] - private string $url; + private ?string $url; /** - * @var int $totalCount Int representing the total number of companyies attached to this contact + * @var ?int $totalCount Integer representing the total number of companies attached to this contact */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** - * @var bool $hasMore Whether there's more Addressable Objects to be viewed. If true, use the url to view all + * @var ?bool $hasMore Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ #[JsonProperty('has_more')] - private bool $hasMore; + private ?bool $hasMore; /** * @param array{ - * url: string, - * totalCount: int, - * hasMore: bool, - * type?: ?'list', - * data?: ?array, + * data?: ?array, + * url?: ?string, + * totalCount?: ?int, + * hasMore?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type'] ?? null; $this->data = $values['data'] ?? null; - $this->url = $values['url']; - $this->totalCount = $values['totalCount']; - $this->hasMore = $values['hasMore']; - } - - /** - * @return ?'list' - */ - public function getType(): ?string - { - return $this->type; + $this->url = $values['url'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->hasMore = $values['hasMore'] ?? null; } /** - * @param ?'list' $value - */ - public function setType(?string $value = null): self - { - $this->type = $value; - return $this; - } - - /** - * @return ?array + * @return ?array */ public function getData(): ?array { @@ -86,7 +61,7 @@ public function getData(): ?array } /** - * @param ?array $value + * @param ?array $value */ public function setData(?array $value = null): self { @@ -95,51 +70,51 @@ public function setData(?array $value = null): self } /** - * @return string + * @return ?string */ - public function getUrl(): string + public function getUrl(): ?string { return $this->url; } /** - * @param string $value + * @param ?string $value */ - public function setUrl(string $value): self + public function setUrl(?string $value = null): self { $this->url = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getHasMore(): bool + public function getHasMore(): ?bool { return $this->hasMore; } /** - * @param bool $value + * @param ?bool $value */ - public function setHasMore(bool $value): self + public function setHasMore(?bool $value = null): self { $this->hasMore = $value; return $this; diff --git a/src/Types/ContactDeleted.php b/src/Types/ContactDeleted.php index f9750ce..d87c3de 100644 --- a/src/Types/ContactDeleted.php +++ b/src/Types/ContactDeleted.php @@ -3,6 +3,7 @@ namespace Intercom\Types; use Intercom\Core\Json\JsonSerializableType; +use Intercom\Traits\ContactReference; use Intercom\Core\Json\JsonProperty; /** @@ -10,110 +11,43 @@ */ class ContactDeleted extends JsonSerializableType { - /** - * @var 'contact' $type always contact - */ - #[JsonProperty('type')] - private string $type; - - /** - * @var string $id The unique identifier for the contact which is given by Intercom. - */ - #[JsonProperty('id')] - private string $id; + use ContactReference; /** - * @var ?string $externalId The unique identifier for the contact which is provided by the Client. - */ - #[JsonProperty('external_id')] - private ?string $externalId; - - /** - * @var bool $deleted Whether the contact is deleted or not. + * @var ?bool $deleted Whether the contact is deleted or not. */ #[JsonProperty('deleted')] - private bool $deleted; + private ?bool $deleted; /** * @param array{ - * type: 'contact', - * id: string, - * deleted: bool, + * type?: ?'contact', + * id?: ?string, * externalId?: ?string, + * deleted?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; $this->externalId = $values['externalId'] ?? null; - $this->deleted = $values['deleted']; - } - - /** - * @return 'contact' - */ - public function getType(): string - { - return $this->type; - } - - /** - * @param 'contact' $value - */ - public function setType(string $value): self - { - $this->type = $value; - return $this; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return ?string - */ - public function getExternalId(): ?string - { - return $this->externalId; - } - - /** - * @param ?string $value - */ - public function setExternalId(?string $value = null): self - { - $this->externalId = $value; - return $this; + $this->deleted = $values['deleted'] ?? null; } /** - * @return bool + * @return ?bool */ - public function getDeleted(): bool + public function getDeleted(): ?bool { return $this->deleted; } /** - * @param bool $value + * @param ?bool $value */ - public function setDeleted(bool $value): self + public function setDeleted(?bool $value = null): self { $this->deleted = $value; return $this; diff --git a/src/Types/ContactList.php b/src/Types/ContactList.php index 0484f4e..4e70fc7 100644 --- a/src/Types/ContactList.php +++ b/src/Types/ContactList.php @@ -13,22 +13,22 @@ class ContactList extends JsonSerializableType { /** - * @var 'list' $type Always list + * @var ?'list' $type Always list */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $data The list of contact objects + * @var ?array $data The list of contact objects */ #[JsonProperty('data'), ArrayType([Contact::class])] - private array $data; + private ?array $data; /** - * @var int $totalCount A count of the total number of objects. + * @var ?int $totalCount A count of the total number of objects. */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** * @var ?CursorPages $pages @@ -38,67 +38,67 @@ class ContactList extends JsonSerializableType /** * @param array{ - * type: 'list', - * data: array, - * totalCount: int, + * type?: ?'list', + * data?: ?array, + * totalCount?: ?int, * pages?: ?CursorPages, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->data = $values['data']; - $this->totalCount = $values['totalCount']; + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; $this->pages = $values['pages'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; diff --git a/src/Types/ContactLocation.php b/src/Types/ContactLocation.php index f7ababe..d980da5 100644 --- a/src/Types/ContactLocation.php +++ b/src/Types/ContactLocation.php @@ -11,10 +11,10 @@ class ContactLocation extends JsonSerializableType { /** - * @var 'location' $type Always location + * @var ?string $type Always location */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** * @var ?string $country The country that the contact is located in @@ -36,33 +36,33 @@ class ContactLocation extends JsonSerializableType /** * @param array{ - * type: 'location', + * type?: ?string, * country?: ?string, * region?: ?string, * city?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; + $this->type = $values['type'] ?? null; $this->country = $values['country'] ?? null; $this->region = $values['region'] ?? null; $this->city = $values['city'] ?? null; } /** - * @return 'location' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'location' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; diff --git a/src/Types/ContactNotes.php b/src/Types/ContactNotes.php index 18fb28c..4f56017 100644 --- a/src/Types/ContactNotes.php +++ b/src/Types/ContactNotes.php @@ -12,109 +12,109 @@ class ContactNotes extends JsonSerializableType { /** - * @var array $data This object represents the notes attached to a contact. + * @var ?array $data This object represents the notes attached to a contact. */ #[JsonProperty('data'), ArrayType([AddressableList::class])] - private array $data; + private ?array $data; /** - * @var string $url Url to get more company resources for this contact + * @var ?string $url Url to get more company resources for this contact */ #[JsonProperty('url')] - private string $url; + private ?string $url; /** - * @var int $totalCount Int representing the total number of companyies attached to this contact + * @var ?int $totalCount Int representing the total number of companyies attached to this contact */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** - * @var bool $hasMore Whether there's more Addressable Objects to be viewed. If true, use the url to view all + * @var ?bool $hasMore Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ #[JsonProperty('has_more')] - private bool $hasMore; + private ?bool $hasMore; /** * @param array{ - * data: array, - * url: string, - * totalCount: int, - * hasMore: bool, + * data?: ?array, + * url?: ?string, + * totalCount?: ?int, + * hasMore?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->data = $values['data']; - $this->url = $values['url']; - $this->totalCount = $values['totalCount']; - $this->hasMore = $values['hasMore']; + $this->data = $values['data'] ?? null; + $this->url = $values['url'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->hasMore = $values['hasMore'] ?? null; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; } /** - * @return string + * @return ?string */ - public function getUrl(): string + public function getUrl(): ?string { return $this->url; } /** - * @param string $value + * @param ?string $value */ - public function setUrl(string $value): self + public function setUrl(?string $value = null): self { $this->url = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getHasMore(): bool + public function getHasMore(): ?bool { return $this->hasMore; } /** - * @param bool $value + * @param ?bool $value */ - public function setHasMore(bool $value): self + public function setHasMore(?bool $value = null): self { $this->hasMore = $value; return $this; diff --git a/src/Types/ContactReference.php b/src/Types/ContactReference.php index 2c40ec2..8cea288 100644 --- a/src/Types/ContactReference.php +++ b/src/Types/ContactReference.php @@ -11,16 +11,16 @@ class ContactReference extends JsonSerializableType { /** - * @var 'contact' $type always contact + * @var ?'contact' $type always contact */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The unique identifier for the contact which is given by Intercom. + * @var ?string $id The unique identifier for the contact which is given by Intercom. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** * @var ?string $externalId The unique identifier for the contact which is provided by the Client. @@ -30,48 +30,48 @@ class ContactReference extends JsonSerializableType /** * @param array{ - * type: 'contact', - * id: string, + * type?: ?'contact', + * id?: ?string, * externalId?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; $this->externalId = $values['externalId'] ?? null; } /** - * @return 'contact' + * @return ?'contact' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'contact' $value + * @param ?'contact' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; diff --git a/src/Types/ContactReplyBaseRequest.php b/src/Types/ContactReplyBaseRequest.php index f297810..c37b351 100644 --- a/src/Types/ContactReplyBaseRequest.php +++ b/src/Types/ContactReplyBaseRequest.php @@ -38,6 +38,12 @@ class ContactReplyBaseRequest extends JsonSerializableType #[JsonProperty('attachment_urls'), ArrayType(['string'])] private ?array $attachmentUrls; + /** + * @var ?array $replyOptions The quick reply selection the contact wishes to respond with. These map to buttons displayed in the Messenger UI if sent by a bot, or the reply options sent by an Admin via the API. + */ + #[JsonProperty('reply_options'), ArrayType([ContactReplyBaseRequestReplyOptionsItem::class])] + private ?array $replyOptions; + /** * @param array{ * messageType: 'comment', @@ -45,6 +51,7 @@ class ContactReplyBaseRequest extends JsonSerializableType * body: string, * createdAt?: ?int, * attachmentUrls?: ?array, + * replyOptions?: ?array, * } $values */ public function __construct( @@ -55,6 +62,7 @@ public function __construct( $this->body = $values['body']; $this->createdAt = $values['createdAt'] ?? null; $this->attachmentUrls = $values['attachmentUrls'] ?? null; + $this->replyOptions = $values['replyOptions'] ?? null; } /** @@ -142,6 +150,23 @@ public function setAttachmentUrls(?array $value = null): self return $this; } + /** + * @return ?array + */ + public function getReplyOptions(): ?array + { + return $this->replyOptions; + } + + /** + * @param ?array $value + */ + public function setReplyOptions(?array $value = null): self + { + $this->replyOptions = $value; + return $this; + } + /** * @return string */ diff --git a/src/Types/ContactReplyBaseRequestReplyOptionsItem.php b/src/Types/ContactReplyBaseRequestReplyOptionsItem.php new file mode 100644 index 0000000..50c1f58 --- /dev/null +++ b/src/Types/ContactReplyBaseRequestReplyOptionsItem.php @@ -0,0 +1,76 @@ +text = $values['text']; + $this->uuid = $values['uuid']; + } + + /** + * @return string + */ + public function getText(): string + { + return $this->text; + } + + /** + * @param string $value + */ + public function setText(string $value): self + { + $this->text = $value; + return $this; + } + + /** + * @return string + */ + public function getUuid(): string + { + return $this->uuid; + } + + /** + * @param string $value + */ + public function setUuid(string $value): self + { + $this->uuid = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ContactReplyEmailRequest.php b/src/Types/ContactReplyEmailRequest.php index c31921a..ab3d6fe 100644 --- a/src/Types/ContactReplyEmailRequest.php +++ b/src/Types/ContactReplyEmailRequest.php @@ -34,6 +34,7 @@ class ContactReplyEmailRequest extends JsonSerializableType * email: string, * createdAt?: ?int, * attachmentUrls?: ?array, + * replyOptions?: ?array, * attachmentFiles?: ?array, * } $values */ @@ -45,6 +46,7 @@ public function __construct( $this->body = $values['body']; $this->createdAt = $values['createdAt'] ?? null; $this->attachmentUrls = $values['attachmentUrls'] ?? null; + $this->replyOptions = $values['replyOptions'] ?? null; $this->email = $values['email']; $this->attachmentFiles = $values['attachmentFiles'] ?? null; } diff --git a/src/Types/ContactReplyIntercomUserIdRequest.php b/src/Types/ContactReplyIntercomUserIdRequest.php index fc1dc44..6045ad3 100644 --- a/src/Types/ContactReplyIntercomUserIdRequest.php +++ b/src/Types/ContactReplyIntercomUserIdRequest.php @@ -34,6 +34,7 @@ class ContactReplyIntercomUserIdRequest extends JsonSerializableType * intercomUserId: string, * createdAt?: ?int, * attachmentUrls?: ?array, + * replyOptions?: ?array, * attachmentFiles?: ?array, * } $values */ @@ -45,6 +46,7 @@ public function __construct( $this->body = $values['body']; $this->createdAt = $values['createdAt'] ?? null; $this->attachmentUrls = $values['attachmentUrls'] ?? null; + $this->replyOptions = $values['replyOptions'] ?? null; $this->intercomUserId = $values['intercomUserId']; $this->attachmentFiles = $values['attachmentFiles'] ?? null; } diff --git a/src/Types/ContactReplyTicketEmailRequest.php b/src/Types/ContactReplyTicketEmailRequest.php index b5769fa..eb1e682 100644 --- a/src/Types/ContactReplyTicketEmailRequest.php +++ b/src/Types/ContactReplyTicketEmailRequest.php @@ -27,6 +27,7 @@ class ContactReplyTicketEmailRequest extends JsonSerializableType * email: string, * createdAt?: ?int, * attachmentUrls?: ?array, + * replyOptions?: ?array, * } $values */ public function __construct( @@ -37,6 +38,7 @@ public function __construct( $this->body = $values['body']; $this->createdAt = $values['createdAt'] ?? null; $this->attachmentUrls = $values['attachmentUrls'] ?? null; + $this->replyOptions = $values['replyOptions'] ?? null; $this->email = $values['email']; } diff --git a/src/Types/ContactReplyTicketIntercomUserIdRequest.php b/src/Types/ContactReplyTicketIntercomUserIdRequest.php index 7e70b8c..10eb570 100644 --- a/src/Types/ContactReplyTicketIntercomUserIdRequest.php +++ b/src/Types/ContactReplyTicketIntercomUserIdRequest.php @@ -27,6 +27,7 @@ class ContactReplyTicketIntercomUserIdRequest extends JsonSerializableType * intercomUserId: string, * createdAt?: ?int, * attachmentUrls?: ?array, + * replyOptions?: ?array, * } $values */ public function __construct( @@ -37,6 +38,7 @@ public function __construct( $this->body = $values['body']; $this->createdAt = $values['createdAt'] ?? null; $this->attachmentUrls = $values['attachmentUrls'] ?? null; + $this->replyOptions = $values['replyOptions'] ?? null; $this->intercomUserId = $values['intercomUserId']; } diff --git a/src/Types/ContactReplyTicketUserIdRequest.php b/src/Types/ContactReplyTicketUserIdRequest.php index 0a3e7c5..d04729d 100644 --- a/src/Types/ContactReplyTicketUserIdRequest.php +++ b/src/Types/ContactReplyTicketUserIdRequest.php @@ -27,6 +27,7 @@ class ContactReplyTicketUserIdRequest extends JsonSerializableType * userId: string, * createdAt?: ?int, * attachmentUrls?: ?array, + * replyOptions?: ?array, * } $values */ public function __construct( @@ -37,6 +38,7 @@ public function __construct( $this->body = $values['body']; $this->createdAt = $values['createdAt'] ?? null; $this->attachmentUrls = $values['attachmentUrls'] ?? null; + $this->replyOptions = $values['replyOptions'] ?? null; $this->userId = $values['userId']; } diff --git a/src/Types/ContactReplyUserIdRequest.php b/src/Types/ContactReplyUserIdRequest.php index 8eef1da..d66f280 100644 --- a/src/Types/ContactReplyUserIdRequest.php +++ b/src/Types/ContactReplyUserIdRequest.php @@ -34,6 +34,7 @@ class ContactReplyUserIdRequest extends JsonSerializableType * userId: string, * createdAt?: ?int, * attachmentUrls?: ?array, + * replyOptions?: ?array, * attachmentFiles?: ?array, * } $values */ @@ -45,6 +46,7 @@ public function __construct( $this->body = $values['body']; $this->createdAt = $values['createdAt'] ?? null; $this->attachmentUrls = $values['attachmentUrls'] ?? null; + $this->replyOptions = $values['replyOptions'] ?? null; $this->userId = $values['userId']; $this->attachmentFiles = $values['attachmentFiles'] ?? null; } diff --git a/src/Types/ContactSegments.php b/src/Types/ContactSegments.php index 987ed4f..51d57d8 100644 --- a/src/Types/ContactSegments.php +++ b/src/Types/ContactSegments.php @@ -13,59 +13,59 @@ class ContactSegments extends JsonSerializableType { /** - * @var 'list' $type The type of the object + * @var ?'list' $type The type of the object */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $data Segment objects associated with the contact. + * @var ?array $data Segment objects associated with the contact. */ #[JsonProperty('data'), ArrayType([Segment::class])] - private array $data; + private ?array $data; /** * @param array{ - * type: 'list', - * data: array, + * type?: ?'list', + * data?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->data = $values['data']; + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; diff --git a/src/Types/ContactSocialProfiles.php b/src/Types/ContactSocialProfiles.php index 61645e0..593605b 100644 --- a/src/Types/ContactSocialProfiles.php +++ b/src/Types/ContactSocialProfiles.php @@ -12,34 +12,34 @@ class ContactSocialProfiles extends JsonSerializableType { /** - * @var array $data A list of social profiles objects associated with the contact. + * @var ?array $data A list of social profiles objects associated with the contact. */ #[JsonProperty('data'), ArrayType([SocialProfile::class])] - private array $data; + private ?array $data; /** * @param array{ - * data: array, + * data?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->data = $values['data']; + $this->data = $values['data'] ?? null; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; diff --git a/src/Types/ContactSubscriptionTypes.php b/src/Types/ContactSubscriptionTypes.php index 9458596..f95750f 100644 --- a/src/Types/ContactSubscriptionTypes.php +++ b/src/Types/ContactSubscriptionTypes.php @@ -12,109 +12,109 @@ class ContactSubscriptionTypes extends JsonSerializableType { /** - * @var array $data This object represents the subscriptions attached to a contact. + * @var ?array $data This object represents the subscriptions attached to a contact. */ #[JsonProperty('data'), ArrayType([AddressableList::class])] - private array $data; + private ?array $data; /** - * @var string $url Url to get more subscription type resources for this contact + * @var ?string $url Url to get more subscription type resources for this contact */ #[JsonProperty('url')] - private string $url; + private ?string $url; /** - * @var int $totalCount Int representing the total number of subscription types attached to this contact + * @var ?int $totalCount Int representing the total number of subscription types attached to this contact */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** - * @var bool $hasMore Whether there's more Addressable Objects to be viewed. If true, use the url to view all + * @var ?bool $hasMore Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ #[JsonProperty('has_more')] - private bool $hasMore; + private ?bool $hasMore; /** * @param array{ - * data: array, - * url: string, - * totalCount: int, - * hasMore: bool, + * data?: ?array, + * url?: ?string, + * totalCount?: ?int, + * hasMore?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->data = $values['data']; - $this->url = $values['url']; - $this->totalCount = $values['totalCount']; - $this->hasMore = $values['hasMore']; + $this->data = $values['data'] ?? null; + $this->url = $values['url'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->hasMore = $values['hasMore'] ?? null; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; } /** - * @return string + * @return ?string */ - public function getUrl(): string + public function getUrl(): ?string { return $this->url; } /** - * @param string $value + * @param ?string $value */ - public function setUrl(string $value): self + public function setUrl(?string $value = null): self { $this->url = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getHasMore(): bool + public function getHasMore(): ?bool { return $this->hasMore; } /** - * @param bool $value + * @param ?bool $value */ - public function setHasMore(bool $value): self + public function setHasMore(?bool $value = null): self { $this->hasMore = $value; return $this; diff --git a/src/Types/ContactTags.php b/src/Types/ContactTags.php index 4810b9b..8f26723 100644 --- a/src/Types/ContactTags.php +++ b/src/Types/ContactTags.php @@ -12,109 +12,109 @@ class ContactTags extends JsonSerializableType { /** - * @var array $data This object represents the tags attached to a contact. + * @var ?array $data This object represents the tags attached to a contact. */ #[JsonProperty('data'), ArrayType([AddressableList::class])] - private array $data; + private ?array $data; /** - * @var string $url url to get more tag resources for this contact + * @var ?string $url url to get more tag resources for this contact */ #[JsonProperty('url')] - private string $url; + private ?string $url; /** - * @var int $totalCount Int representing the total number of tags attached to this contact + * @var ?int $totalCount Int representing the total number of tags attached to this contact */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** - * @var bool $hasMore Whether there's more Addressable Objects to be viewed. If true, use the url to view all + * @var ?bool $hasMore Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ #[JsonProperty('has_more')] - private bool $hasMore; + private ?bool $hasMore; /** * @param array{ - * data: array, - * url: string, - * totalCount: int, - * hasMore: bool, + * data?: ?array, + * url?: ?string, + * totalCount?: ?int, + * hasMore?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->data = $values['data']; - $this->url = $values['url']; - $this->totalCount = $values['totalCount']; - $this->hasMore = $values['hasMore']; + $this->data = $values['data'] ?? null; + $this->url = $values['url'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->hasMore = $values['hasMore'] ?? null; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; } /** - * @return string + * @return ?string */ - public function getUrl(): string + public function getUrl(): ?string { return $this->url; } /** - * @param string $value + * @param ?string $value */ - public function setUrl(string $value): self + public function setUrl(?string $value = null): self { $this->url = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getHasMore(): bool + public function getHasMore(): ?bool { return $this->hasMore; } /** - * @param bool $value + * @param ?bool $value */ - public function setHasMore(bool $value): self + public function setHasMore(?bool $value = null): self { $this->hasMore = $value; return $this; diff --git a/src/Types/ContactUnarchived.php b/src/Types/ContactUnarchived.php index ff0df08..99b1f1a 100644 --- a/src/Types/ContactUnarchived.php +++ b/src/Types/ContactUnarchived.php @@ -3,6 +3,7 @@ namespace Intercom\Types; use Intercom\Core\Json\JsonSerializableType; +use Intercom\Traits\ContactReference; use Intercom\Core\Json\JsonProperty; /** @@ -10,110 +11,43 @@ */ class ContactUnarchived extends JsonSerializableType { - /** - * @var 'contact' $type always contact - */ - #[JsonProperty('type')] - private string $type; - - /** - * @var string $id The unique identifier for the contact which is given by Intercom. - */ - #[JsonProperty('id')] - private string $id; + use ContactReference; /** - * @var ?string $externalId The unique identifier for the contact which is provided by the Client. - */ - #[JsonProperty('external_id')] - private ?string $externalId; - - /** - * @var bool $archived Whether the contact is archived or not. + * @var ?bool $archived Whether the contact is archived or not. */ #[JsonProperty('archived')] - private bool $archived; + private ?bool $archived; /** * @param array{ - * type: 'contact', - * id: string, - * archived: bool, + * type?: ?'contact', + * id?: ?string, * externalId?: ?string, + * archived?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; $this->externalId = $values['externalId'] ?? null; - $this->archived = $values['archived']; - } - - /** - * @return 'contact' - */ - public function getType(): string - { - return $this->type; - } - - /** - * @param 'contact' $value - */ - public function setType(string $value): self - { - $this->type = $value; - return $this; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return ?string - */ - public function getExternalId(): ?string - { - return $this->externalId; - } - - /** - * @param ?string $value - */ - public function setExternalId(?string $value = null): self - { - $this->externalId = $value; - return $this; + $this->archived = $values['archived'] ?? null; } /** - * @return bool + * @return ?bool */ - public function getArchived(): bool + public function getArchived(): ?bool { return $this->archived; } /** - * @param bool $value + * @param ?bool $value */ - public function setArchived(bool $value): self + public function setArchived(?bool $value = null): self { $this->archived = $value; return $this; diff --git a/src/Types/ContentObject.php b/src/Types/ContentObject.php deleted file mode 100644 index 449307c..0000000 --- a/src/Types/ContentObject.php +++ /dev/null @@ -1,57 +0,0 @@ - $components The list of components to be rendered. - */ - #[JsonProperty('components'), ArrayType([Component::class])] - private array $components; - - /** - * @param array{ - * components: array, - * } $values - */ - public function __construct( - array $values, - ) { - $this->components = $values['components']; - } - - /** - * @return array - */ - public function getComponents(): array - { - return $this->components; - } - - /** - * @param array $value - */ - public function setComponents(array $value): self - { - $this->components = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/ContentSourcesList.php b/src/Types/ContentSourcesList.php index dd72fda..4932ae0 100644 --- a/src/Types/ContentSourcesList.php +++ b/src/Types/ContentSourcesList.php @@ -10,84 +10,84 @@ class ContentSourcesList extends JsonSerializableType { /** - * @var 'content_source.list' $type + * @var ?'content_source.list' $type */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var int $totalCount The total number of content sources used by AI Agent in the conversation. + * @var ?int $totalCount The total number of content sources used by AI Agent in the conversation. */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** - * @var array $contentSources The content sources used by AI Agent in the conversation. + * @var ?array $contentSources The content sources used by AI Agent in the conversation. */ #[JsonProperty('content_sources'), ArrayType([ContentSource::class])] - private array $contentSources; + private ?array $contentSources; /** * @param array{ - * type: 'content_source.list', - * totalCount: int, - * contentSources: array, + * type?: ?'content_source.list', + * totalCount?: ?int, + * contentSources?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->totalCount = $values['totalCount']; - $this->contentSources = $values['contentSources']; + $this->type = $values['type'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->contentSources = $values['contentSources'] ?? null; } /** - * @return 'content_source.list' + * @return ?'content_source.list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'content_source.list' $value + * @param ?'content_source.list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; } /** - * @return array + * @return ?array */ - public function getContentSources(): array + public function getContentSources(): ?array { return $this->contentSources; } /** - * @param array $value + * @param ?array $value */ - public function setContentSources(array $value): self + public function setContentSources(?array $value = null): self { $this->contentSources = $value; return $this; diff --git a/src/Types/Context.php b/src/Types/Context.php deleted file mode 100644 index 7b884aa..0000000 --- a/src/Types/Context.php +++ /dev/null @@ -1,181 +0,0 @@ - $location Where the app is added or the action took place. Can be either 'conversation', 'home', 'message', or 'operator'. - */ - #[JsonProperty('location')] - private ?string $location; - - /** - * @var ?string $locale The default end-user language of the Messenger. Use to localise Messenger App content. - */ - #[JsonProperty('locale')] - private ?string $locale; - - /** - * @var ?string $messengerActionColour The messengers action colour. Use in Sheets and Icons to make a Messenger App experience feel part of the host Messenger. - */ - #[JsonProperty('messenger_action_colour')] - private ?string $messengerActionColour; - - /** - * @var ?string $messengerBackgroundColour The messengers background colour. Use in Sheets and Icons to make a Messenger App experience feel part of the host Messenger. - */ - #[JsonProperty('messenger_background_colour')] - private ?string $messengerBackgroundColour; - - /** - * @var ?string $referrer The current page URL where the app is being used. - */ - #[JsonProperty('referrer')] - private ?string $referrer; - - /** - * @param array{ - * conversationId?: ?int, - * location?: ?value-of, - * locale?: ?string, - * messengerActionColour?: ?string, - * messengerBackgroundColour?: ?string, - * referrer?: ?string, - * } $values - */ - public function __construct( - array $values = [], - ) { - $this->conversationId = $values['conversationId'] ?? null; - $this->location = $values['location'] ?? null; - $this->locale = $values['locale'] ?? null; - $this->messengerActionColour = $values['messengerActionColour'] ?? null; - $this->messengerBackgroundColour = $values['messengerBackgroundColour'] ?? null; - $this->referrer = $values['referrer'] ?? null; - } - - /** - * @return ?int - */ - public function getConversationId(): ?int - { - return $this->conversationId; - } - - /** - * @param ?int $value - */ - public function setConversationId(?int $value = null): self - { - $this->conversationId = $value; - return $this; - } - - /** - * @return ?value-of - */ - public function getLocation(): ?string - { - return $this->location; - } - - /** - * @param ?value-of $value - */ - public function setLocation(?string $value = null): self - { - $this->location = $value; - return $this; - } - - /** - * @return ?string - */ - public function getLocale(): ?string - { - return $this->locale; - } - - /** - * @param ?string $value - */ - public function setLocale(?string $value = null): self - { - $this->locale = $value; - return $this; - } - - /** - * @return ?string - */ - public function getMessengerActionColour(): ?string - { - return $this->messengerActionColour; - } - - /** - * @param ?string $value - */ - public function setMessengerActionColour(?string $value = null): self - { - $this->messengerActionColour = $value; - return $this; - } - - /** - * @return ?string - */ - public function getMessengerBackgroundColour(): ?string - { - return $this->messengerBackgroundColour; - } - - /** - * @param ?string $value - */ - public function setMessengerBackgroundColour(?string $value = null): self - { - $this->messengerBackgroundColour = $value; - return $this; - } - - /** - * @return ?string - */ - public function getReferrer(): ?string - { - return $this->referrer; - } - - /** - * @param ?string $value - */ - public function setReferrer(?string $value = null): self - { - $this->referrer = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/ContextLocation.php b/src/Types/ContextLocation.php deleted file mode 100644 index f0aa92d..0000000 --- a/src/Types/ContextLocation.php +++ /dev/null @@ -1,11 +0,0 @@ -contentType = $values['contentType']; - $this->data = $values['data']; - $this->name = $values['name']; + $this->contentType = $values['contentType'] ?? null; + $this->data = $values['data'] ?? null; + $this->name = $values['name'] ?? null; } /** - * @return string + * @return ?string */ - public function getContentType(): string + public function getContentType(): ?string { return $this->contentType; } /** - * @param string $value + * @param ?string $value */ - public function setContentType(string $value): self + public function setContentType(?string $value = null): self { $this->contentType = $value; return $this; } /** - * @return string + * @return ?string */ - public function getData(): string + public function getData(): ?string { return $this->data; } /** - * @param string $value + * @param ?string $value */ - public function setData(string $value): self + public function setData(?string $value = null): self { $this->data = $value; return $this; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; diff --git a/src/Types/ConversationAttributeUpdatedByAdmin.php b/src/Types/ConversationAttributeUpdatedByAdmin.php new file mode 100644 index 0000000..d0036fa --- /dev/null +++ b/src/Types/ConversationAttributeUpdatedByAdmin.php @@ -0,0 +1,79 @@ +conversation_attribute_updated_by_admin. + */ +class ConversationAttributeUpdatedByAdmin extends JsonSerializableType +{ + /** + * @var ?ConversationAttributeUpdatedByAdminAttribute $attribute + */ + #[JsonProperty('attribute')] + private ?ConversationAttributeUpdatedByAdminAttribute $attribute; + + /** + * @var ?ConversationAttributeUpdatedByAdminValue $value + */ + #[JsonProperty('value')] + private ?ConversationAttributeUpdatedByAdminValue $value; + + /** + * @param array{ + * attribute?: ?ConversationAttributeUpdatedByAdminAttribute, + * value?: ?ConversationAttributeUpdatedByAdminValue, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->attribute = $values['attribute'] ?? null; + $this->value = $values['value'] ?? null; + } + + /** + * @return ?ConversationAttributeUpdatedByAdminAttribute + */ + public function getAttribute(): ?ConversationAttributeUpdatedByAdminAttribute + { + return $this->attribute; + } + + /** + * @param ?ConversationAttributeUpdatedByAdminAttribute $value + */ + public function setAttribute(?ConversationAttributeUpdatedByAdminAttribute $value = null): self + { + $this->attribute = $value; + return $this; + } + + /** + * @return ?ConversationAttributeUpdatedByAdminValue + */ + public function getValue(): ?ConversationAttributeUpdatedByAdminValue + { + return $this->value; + } + + /** + * @param ?ConversationAttributeUpdatedByAdminValue $value + */ + public function setValue(?ConversationAttributeUpdatedByAdminValue $value = null): self + { + $this->value = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ConversationAttributeUpdatedByAdminAttribute.php b/src/Types/ConversationAttributeUpdatedByAdminAttribute.php new file mode 100644 index 0000000..7c2cd2a --- /dev/null +++ b/src/Types/ConversationAttributeUpdatedByAdminAttribute.php @@ -0,0 +1,51 @@ +name = $values['name'] ?? null; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ConversationAttributeUpdatedByAdminValue.php b/src/Types/ConversationAttributeUpdatedByAdminValue.php new file mode 100644 index 0000000..28adf73 --- /dev/null +++ b/src/Types/ConversationAttributeUpdatedByAdminValue.php @@ -0,0 +1,51 @@ +name = $values['name'] ?? null; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ConversationAttributeUpdatedByWorkflow.php b/src/Types/ConversationAttributeUpdatedByWorkflow.php new file mode 100644 index 0000000..02582d5 --- /dev/null +++ b/src/Types/ConversationAttributeUpdatedByWorkflow.php @@ -0,0 +1,104 @@ +conversation_attribute_updated_by_workflow. + */ +class ConversationAttributeUpdatedByWorkflow extends JsonSerializableType +{ + /** + * @var ?ConversationAttributeUpdatedByWorkflowWorkflow $workflow + */ + #[JsonProperty('workflow')] + private ?ConversationAttributeUpdatedByWorkflowWorkflow $workflow; + + /** + * @var ?ConversationAttributeUpdatedByWorkflowAttribute $attribute + */ + #[JsonProperty('attribute')] + private ?ConversationAttributeUpdatedByWorkflowAttribute $attribute; + + /** + * @var ?ConversationAttributeUpdatedByWorkflowValue $value + */ + #[JsonProperty('value')] + private ?ConversationAttributeUpdatedByWorkflowValue $value; + + /** + * @param array{ + * workflow?: ?ConversationAttributeUpdatedByWorkflowWorkflow, + * attribute?: ?ConversationAttributeUpdatedByWorkflowAttribute, + * value?: ?ConversationAttributeUpdatedByWorkflowValue, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->workflow = $values['workflow'] ?? null; + $this->attribute = $values['attribute'] ?? null; + $this->value = $values['value'] ?? null; + } + + /** + * @return ?ConversationAttributeUpdatedByWorkflowWorkflow + */ + public function getWorkflow(): ?ConversationAttributeUpdatedByWorkflowWorkflow + { + return $this->workflow; + } + + /** + * @param ?ConversationAttributeUpdatedByWorkflowWorkflow $value + */ + public function setWorkflow(?ConversationAttributeUpdatedByWorkflowWorkflow $value = null): self + { + $this->workflow = $value; + return $this; + } + + /** + * @return ?ConversationAttributeUpdatedByWorkflowAttribute + */ + public function getAttribute(): ?ConversationAttributeUpdatedByWorkflowAttribute + { + return $this->attribute; + } + + /** + * @param ?ConversationAttributeUpdatedByWorkflowAttribute $value + */ + public function setAttribute(?ConversationAttributeUpdatedByWorkflowAttribute $value = null): self + { + $this->attribute = $value; + return $this; + } + + /** + * @return ?ConversationAttributeUpdatedByWorkflowValue + */ + public function getValue(): ?ConversationAttributeUpdatedByWorkflowValue + { + return $this->value; + } + + /** + * @param ?ConversationAttributeUpdatedByWorkflowValue $value + */ + public function setValue(?ConversationAttributeUpdatedByWorkflowValue $value = null): self + { + $this->value = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ConversationAttributeUpdatedByWorkflowAttribute.php b/src/Types/ConversationAttributeUpdatedByWorkflowAttribute.php new file mode 100644 index 0000000..307a4aa --- /dev/null +++ b/src/Types/ConversationAttributeUpdatedByWorkflowAttribute.php @@ -0,0 +1,51 @@ +name = $values['name'] ?? null; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ConversationAttributeUpdatedByWorkflowValue.php b/src/Types/ConversationAttributeUpdatedByWorkflowValue.php new file mode 100644 index 0000000..670b424 --- /dev/null +++ b/src/Types/ConversationAttributeUpdatedByWorkflowValue.php @@ -0,0 +1,51 @@ +name = $values['name'] ?? null; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ConversationAttributeUpdatedByWorkflowWorkflow.php b/src/Types/ConversationAttributeUpdatedByWorkflowWorkflow.php new file mode 100644 index 0000000..52e410e --- /dev/null +++ b/src/Types/ConversationAttributeUpdatedByWorkflowWorkflow.php @@ -0,0 +1,51 @@ +name = $values['name'] ?? null; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ConversationContacts.php b/src/Types/ConversationContacts.php index 8989ef9..881660e 100644 --- a/src/Types/ConversationContacts.php +++ b/src/Types/ConversationContacts.php @@ -12,59 +12,59 @@ class ConversationContacts extends JsonSerializableType { /** - * @var 'contact.list' $type + * @var ?'contact.list' $type */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $contacts The list of contacts (users or leads) involved in this conversation. This will only contain one customer unless more were added via the group conversation feature. + * @var ?array $contacts The list of contacts (users or leads) involved in this conversation. This will only contain one customer unless more were added via the group conversation feature. */ #[JsonProperty('contacts'), ArrayType([ContactReference::class])] - private array $contacts; + private ?array $contacts; /** * @param array{ - * type: 'contact.list', - * contacts: array, + * type?: ?'contact.list', + * contacts?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->contacts = $values['contacts']; + $this->type = $values['type'] ?? null; + $this->contacts = $values['contacts'] ?? null; } /** - * @return 'contact.list' + * @return ?'contact.list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'contact.list' $value + * @param ?'contact.list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getContacts(): array + public function getContacts(): ?array { return $this->contacts; } /** - * @param array $value + * @param ?array $value */ - public function setContacts(array $value): self + public function setContacts(?array $value = null): self { $this->contacts = $value; return $this; diff --git a/src/Types/ConversationDeleted.php b/src/Types/ConversationDeleted.php new file mode 100644 index 0000000..eb399ac --- /dev/null +++ b/src/Types/ConversationDeleted.php @@ -0,0 +1,104 @@ +id = $values['id'] ?? null; + $this->object = $values['object'] ?? null; + $this->deleted = $values['deleted'] ?? null; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?'conversation' + */ + public function getObject(): ?string + { + return $this->object; + } + + /** + * @param ?'conversation' $value + */ + public function setObject(?string $value = null): self + { + $this->object = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getDeleted(): ?bool + { + return $this->deleted; + } + + /** + * @param ?bool $value + */ + public function setDeleted(?bool $value = null): self + { + $this->deleted = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ConversationFirstContactReply.php b/src/Types/ConversationFirstContactReply.php index 247e44b..7309364 100644 --- a/src/Types/ConversationFirstContactReply.php +++ b/src/Types/ConversationFirstContactReply.php @@ -11,16 +11,16 @@ class ConversationFirstContactReply extends JsonSerializableType { /** - * @var int $createdAt + * @var ?int $createdAt */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** - * @var string $type + * @var ?string $type */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** * @var ?string $url @@ -30,48 +30,48 @@ class ConversationFirstContactReply extends JsonSerializableType /** * @param array{ - * createdAt: int, - * type: string, + * createdAt?: ?int, + * type?: ?string, * url?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->createdAt = $values['createdAt']; - $this->type = $values['type']; + $this->createdAt = $values['createdAt'] ?? null; + $this->type = $values['type'] ?? null; $this->url = $values['url'] ?? null; } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; } /** - * @return string + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param string $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; diff --git a/src/Types/PaginatedConversationResponse.php b/src/Types/ConversationList.php similarity index 59% rename from src/Types/PaginatedConversationResponse.php rename to src/Types/ConversationList.php index 1380250..fc879e2 100644 --- a/src/Types/PaginatedConversationResponse.php +++ b/src/Types/ConversationList.php @@ -10,25 +10,25 @@ /** * Conversations are how you can communicate with users in Intercom. They are created when a contact replies to an outbound message, or when one admin directly sends a message to a single contact. */ -class PaginatedConversationResponse extends JsonSerializableType +class ConversationList extends JsonSerializableType { /** - * @var 'conversation.list' $type Always conversation.list + * @var ?'conversation.list' $type Always conversation.list */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $conversations The list of conversation objects + * @var ?array $conversations The list of conversation objects */ #[JsonProperty('conversations'), ArrayType([Conversation::class])] - private array $conversations; + private ?array $conversations; /** - * @var int $totalCount A count of the total number of objects. + * @var ?int $totalCount A count of the total number of objects. */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** * @var ?CursorPages $pages @@ -38,67 +38,67 @@ class PaginatedConversationResponse extends JsonSerializableType /** * @param array{ - * type: 'conversation.list', - * conversations: array, - * totalCount: int, + * type?: ?'conversation.list', + * conversations?: ?array, + * totalCount?: ?int, * pages?: ?CursorPages, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->conversations = $values['conversations']; - $this->totalCount = $values['totalCount']; + $this->type = $values['type'] ?? null; + $this->conversations = $values['conversations'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; $this->pages = $values['pages'] ?? null; } /** - * @return 'conversation.list' + * @return ?'conversation.list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'conversation.list' $value + * @param ?'conversation.list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getConversations(): array + public function getConversations(): ?array { return $this->conversations; } /** - * @param array $value + * @param ?array $value */ - public function setConversations(array $value): self + public function setConversations(?array $value = null): self { $this->conversations = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; diff --git a/src/Types/ConversationPart.php b/src/Types/ConversationPart.php index 815e12f..9483e8b 100644 --- a/src/Types/ConversationPart.php +++ b/src/Types/ConversationPart.php @@ -5,6 +5,8 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; use Intercom\Core\Types\ArrayType; +use Intercom\Tags\Types\TagBasic; +use Intercom\Core\Types\Union; /** * A Conversation Part represents a message in the conversation. @@ -12,22 +14,22 @@ class ConversationPart extends JsonSerializableType { /** - * @var 'conversation_part' $type Always conversation_part + * @var ?string $type Always conversation_part */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The id representing the conversation part. + * @var ?string $id The id representing the conversation part. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $partType The type of conversation part. + * @var ?string $partType The type of conversation part. */ #[JsonProperty('part_type')] - private string $partType; + private ?string $partType; /** * @var ?string $body The message body, which may contain HTML. For Twitter, this will show a generic message regarding why the body is obscured. @@ -36,10 +38,10 @@ class ConversationPart extends JsonSerializableType private ?string $body; /** - * @var int $createdAt The time the conversation part was created. + * @var ?int $createdAt The time the conversation part was created. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** * @var ?int $updatedAt The last time the conversation part was updated. @@ -48,10 +50,10 @@ class ConversationPart extends JsonSerializableType private ?int $updatedAt; /** - * @var int $notifiedAt The time the user was notified with the conversation part. + * @var ?int $notifiedAt The time the user was notified with the conversation part. */ #[JsonProperty('notified_at')] - private int $notifiedAt; + private ?int $notifiedAt; /** * @var ?Reference $assignedTo The id of the admin that was assigned the conversation by this conversation_part (null if there has been no change in assignment.) @@ -60,10 +62,10 @@ class ConversationPart extends JsonSerializableType private ?Reference $assignedTo; /** - * @var ConversationPartAuthor $author + * @var ?ConversationPartAuthor $author */ #[JsonProperty('author')] - private ConversationPartAuthor $author; + private ?ConversationPartAuthor $author; /** * @var ?array $attachments A list of attachments for the part. @@ -78,90 +80,150 @@ class ConversationPart extends JsonSerializableType private ?string $externalId; /** - * @var bool $redacted Whether or not the conversation part has been redacted. + * @var ?bool $redacted Whether or not the conversation part has been redacted. */ #[JsonProperty('redacted')] - private bool $redacted; + private ?bool $redacted; + + /** + * @var ?EmailMessageMetadata $emailMessageMetadata + */ + #[JsonProperty('email_message_metadata')] + private ?EmailMessageMetadata $emailMessageMetadata; + + /** + * @var ?ConversationPartMetadata $metadata + */ + #[JsonProperty('metadata')] + private ?ConversationPartMetadata $metadata; + + /** + * @var ?value-of $state Indicates the current state of conversation when the conversation part was created. + */ + #[JsonProperty('state')] + private ?string $state; + + /** + * @var ?array $tags A list of tags objects associated with the conversation part. + */ + #[JsonProperty('tags'), ArrayType([TagBasic::class])] + private ?array $tags; + + /** + * @var ( + * ConversationAttributeUpdatedByWorkflow + * |ConversationAttributeUpdatedByAdmin + * |CustomActionStarted + * |CustomActionFinished + * |OperatorWorkflowEvent + * )|null $eventDetails + */ + #[JsonProperty('event_details'), Union(ConversationAttributeUpdatedByWorkflow::class, ConversationAttributeUpdatedByAdmin::class, CustomActionStarted::class, CustomActionFinished::class, OperatorWorkflowEvent::class, 'null')] + private ConversationAttributeUpdatedByWorkflow|ConversationAttributeUpdatedByAdmin|CustomActionStarted|CustomActionFinished|OperatorWorkflowEvent|null $eventDetails; + + /** + * @var ?string $appPackageCode The app package code if this part was created via API. null if the part was not created via API. + */ + #[JsonProperty('app_package_code')] + private ?string $appPackageCode; /** * @param array{ - * type: 'conversation_part', - * id: string, - * partType: string, - * createdAt: int, - * notifiedAt: int, - * author: ConversationPartAuthor, - * redacted: bool, + * type?: ?string, + * id?: ?string, + * partType?: ?string, * body?: ?string, + * createdAt?: ?int, * updatedAt?: ?int, + * notifiedAt?: ?int, * assignedTo?: ?Reference, + * author?: ?ConversationPartAuthor, * attachments?: ?array, * externalId?: ?string, + * redacted?: ?bool, + * emailMessageMetadata?: ?EmailMessageMetadata, + * metadata?: ?ConversationPartMetadata, + * state?: ?value-of, + * tags?: ?array, + * eventDetails?: ( + * ConversationAttributeUpdatedByWorkflow + * |ConversationAttributeUpdatedByAdmin + * |CustomActionStarted + * |CustomActionFinished + * |OperatorWorkflowEvent + * )|null, + * appPackageCode?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->partType = $values['partType']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->partType = $values['partType'] ?? null; $this->body = $values['body'] ?? null; - $this->createdAt = $values['createdAt']; + $this->createdAt = $values['createdAt'] ?? null; $this->updatedAt = $values['updatedAt'] ?? null; - $this->notifiedAt = $values['notifiedAt']; + $this->notifiedAt = $values['notifiedAt'] ?? null; $this->assignedTo = $values['assignedTo'] ?? null; - $this->author = $values['author']; + $this->author = $values['author'] ?? null; $this->attachments = $values['attachments'] ?? null; $this->externalId = $values['externalId'] ?? null; - $this->redacted = $values['redacted']; + $this->redacted = $values['redacted'] ?? null; + $this->emailMessageMetadata = $values['emailMessageMetadata'] ?? null; + $this->metadata = $values['metadata'] ?? null; + $this->state = $values['state'] ?? null; + $this->tags = $values['tags'] ?? null; + $this->eventDetails = $values['eventDetails'] ?? null; + $this->appPackageCode = $values['appPackageCode'] ?? null; } /** - * @return 'conversation_part' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'conversation_part' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getPartType(): string + public function getPartType(): ?string { return $this->partType; } /** - * @param string $value + * @param ?string $value */ - public function setPartType(string $value): self + public function setPartType(?string $value = null): self { $this->partType = $value; return $this; @@ -185,17 +247,17 @@ public function setBody(?string $value = null): self } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; @@ -219,17 +281,17 @@ public function setUpdatedAt(?int $value = null): self } /** - * @return int + * @return ?int */ - public function getNotifiedAt(): int + public function getNotifiedAt(): ?int { return $this->notifiedAt; } /** - * @param int $value + * @param ?int $value */ - public function setNotifiedAt(int $value): self + public function setNotifiedAt(?int $value = null): self { $this->notifiedAt = $value; return $this; @@ -253,17 +315,17 @@ public function setAssignedTo(?Reference $value = null): self } /** - * @return ConversationPartAuthor + * @return ?ConversationPartAuthor */ - public function getAuthor(): ConversationPartAuthor + public function getAuthor(): ?ConversationPartAuthor { return $this->author; } /** - * @param ConversationPartAuthor $value + * @param ?ConversationPartAuthor $value */ - public function setAuthor(ConversationPartAuthor $value): self + public function setAuthor(?ConversationPartAuthor $value = null): self { $this->author = $value; return $this; @@ -304,22 +366,136 @@ public function setExternalId(?string $value = null): self } /** - * @return bool + * @return ?bool */ - public function getRedacted(): bool + public function getRedacted(): ?bool { return $this->redacted; } /** - * @param bool $value + * @param ?bool $value */ - public function setRedacted(bool $value): self + public function setRedacted(?bool $value = null): self { $this->redacted = $value; return $this; } + /** + * @return ?EmailMessageMetadata + */ + public function getEmailMessageMetadata(): ?EmailMessageMetadata + { + return $this->emailMessageMetadata; + } + + /** + * @param ?EmailMessageMetadata $value + */ + public function setEmailMessageMetadata(?EmailMessageMetadata $value = null): self + { + $this->emailMessageMetadata = $value; + return $this; + } + + /** + * @return ?ConversationPartMetadata + */ + public function getMetadata(): ?ConversationPartMetadata + { + return $this->metadata; + } + + /** + * @param ?ConversationPartMetadata $value + */ + public function setMetadata(?ConversationPartMetadata $value = null): self + { + $this->metadata = $value; + return $this; + } + + /** + * @return ?value-of + */ + public function getState(): ?string + { + return $this->state; + } + + /** + * @param ?value-of $value + */ + public function setState(?string $value = null): self + { + $this->state = $value; + return $this; + } + + /** + * @return ?array + */ + public function getTags(): ?array + { + return $this->tags; + } + + /** + * @param ?array $value + */ + public function setTags(?array $value = null): self + { + $this->tags = $value; + return $this; + } + + /** + * @return ( + * ConversationAttributeUpdatedByWorkflow + * |ConversationAttributeUpdatedByAdmin + * |CustomActionStarted + * |CustomActionFinished + * |OperatorWorkflowEvent + * )|null + */ + public function getEventDetails(): ConversationAttributeUpdatedByWorkflow|ConversationAttributeUpdatedByAdmin|CustomActionStarted|CustomActionFinished|OperatorWorkflowEvent|null + { + return $this->eventDetails; + } + + /** + * @param ( + * ConversationAttributeUpdatedByWorkflow + * |ConversationAttributeUpdatedByAdmin + * |CustomActionStarted + * |CustomActionFinished + * |OperatorWorkflowEvent + * )|null $value + */ + public function setEventDetails(ConversationAttributeUpdatedByWorkflow|ConversationAttributeUpdatedByAdmin|CustomActionStarted|CustomActionFinished|OperatorWorkflowEvent|null $value = null): self + { + $this->eventDetails = $value; + return $this; + } + + /** + * @return ?string + */ + public function getAppPackageCode(): ?string + { + return $this->appPackageCode; + } + + /** + * @param ?string $value + */ + public function setAppPackageCode(?string $value = null): self + { + $this->appPackageCode = $value; + return $this; + } + /** * @return string */ diff --git a/src/Types/ConversationPartAuthor.php b/src/Types/ConversationPartAuthor.php index 8bb3fa9..74391d6 100644 --- a/src/Types/ConversationPartAuthor.php +++ b/src/Types/ConversationPartAuthor.php @@ -11,114 +11,164 @@ class ConversationPartAuthor extends JsonSerializableType { /** - * @var string $type The type of the author + * @var ?string $type The type of the author */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The id of the author + * @var ?string $id The id of the author */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $name The name of the author + * @var ?string $name The name of the author */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var string $email The email of the author + * @var ?string $email The email of the author */ #[JsonProperty('email')] - private string $email; + private ?string $email; + + /** + * @var ?bool $fromAiAgent If this conversation part was sent by the AI Agent + */ + #[JsonProperty('from_ai_agent')] + private ?bool $fromAiAgent; + + /** + * @var ?bool $isAiAnswer If this conversation part body was generated by the AI Agent + */ + #[JsonProperty('is_ai_answer')] + private ?bool $isAiAnswer; /** * @param array{ - * type: string, - * id: string, - * name: string, - * email: string, + * type?: ?string, + * id?: ?string, + * name?: ?string, + * email?: ?string, + * fromAiAgent?: ?bool, + * isAiAnswer?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->name = $values['name']; - $this->email = $values['email']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->name = $values['name'] ?? null; + $this->email = $values['email'] ?? null; + $this->fromAiAgent = $values['fromAiAgent'] ?? null; + $this->isAiAnswer = $values['isAiAnswer'] ?? null; } /** - * @return string + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param string $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return string + * @return ?string */ - public function getEmail(): string + public function getEmail(): ?string { return $this->email; } /** - * @param string $value + * @param ?string $value */ - public function setEmail(string $value): self + public function setEmail(?string $value = null): self { $this->email = $value; return $this; } + /** + * @return ?bool + */ + public function getFromAiAgent(): ?bool + { + return $this->fromAiAgent; + } + + /** + * @param ?bool $value + */ + public function setFromAiAgent(?bool $value = null): self + { + $this->fromAiAgent = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getIsAiAnswer(): ?bool + { + return $this->isAiAnswer; + } + + /** + * @param ?bool $value + */ + public function setIsAiAnswer(?bool $value = null): self + { + $this->isAiAnswer = $value; + return $this; + } + /** * @return string */ diff --git a/src/Types/ConversationPartMetadata.php b/src/Types/ConversationPartMetadata.php new file mode 100644 index 0000000..3b98dc0 --- /dev/null +++ b/src/Types/ConversationPartMetadata.php @@ -0,0 +1,80 @@ + $quickReplyOptions The quick reply options sent by the Admin or bot, presented in this conversation part. + */ + #[JsonProperty('quick_reply_options'), ArrayType([ConversationPartMetadataQuickReplyOptionsItem::class])] + private ?array $quickReplyOptions; + + /** + * @var ?string $quickReplyUuid The unique identifier for the quick reply option that was clicked by the end user. + */ + #[JsonProperty('quick_reply_uuid')] + private ?string $quickReplyUuid; + + /** + * @param array{ + * quickReplyOptions?: ?array, + * quickReplyUuid?: ?string, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->quickReplyOptions = $values['quickReplyOptions'] ?? null; + $this->quickReplyUuid = $values['quickReplyUuid'] ?? null; + } + + /** + * @return ?array + */ + public function getQuickReplyOptions(): ?array + { + return $this->quickReplyOptions; + } + + /** + * @param ?array $value + */ + public function setQuickReplyOptions(?array $value = null): self + { + $this->quickReplyOptions = $value; + return $this; + } + + /** + * @return ?string + */ + public function getQuickReplyUuid(): ?string + { + return $this->quickReplyUuid; + } + + /** + * @param ?string $value + */ + public function setQuickReplyUuid(?string $value = null): self + { + $this->quickReplyUuid = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ConversationPartMetadataQuickReplyOptionsItem.php b/src/Types/ConversationPartMetadataQuickReplyOptionsItem.php new file mode 100644 index 0000000..50580eb --- /dev/null +++ b/src/Types/ConversationPartMetadataQuickReplyOptionsItem.php @@ -0,0 +1,59 @@ + $translations The translations for the quick reply option. + */ + #[JsonProperty('translations'), ArrayType(['string' => 'mixed'])] + private ?array $translations; + + /** + * @param array{ + * text: string, + * uuid: string, + * translations?: ?array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->text = $values['text']; + $this->uuid = $values['uuid']; + $this->translations = $values['translations'] ?? null; + } + + /** + * @return ?array + */ + public function getTranslations(): ?array + { + return $this->translations; + } + + /** + * @param ?array $value + */ + public function setTranslations(?array $value = null): self + { + $this->translations = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ConversationPartState.php b/src/Types/ConversationPartState.php new file mode 100644 index 0000000..5c2a429 --- /dev/null +++ b/src/Types/ConversationPartState.php @@ -0,0 +1,10 @@ + $conversationParts A list of Conversation Part objects for each part message in the conversation. This is only returned when Retrieving a Conversation, and ignored when Listing all Conversations. There is a limit of 500 parts. + * @var ?array $conversationParts A list of Conversation Part objects for each part message in the conversation. This is only returned when Retrieving a Conversation, and ignored when Listing all Conversations. There is a limit of 500 parts. */ #[JsonProperty('conversation_parts'), ArrayType([ConversationPart::class])] - private array $conversationParts; + private ?array $conversationParts; /** - * @var int $totalCount + * @var ?int $totalCount */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** * @param array{ - * type: 'conversation_part.list', - * conversationParts: array, - * totalCount: int, + * type?: ?'conversation_part.list', + * conversationParts?: ?array, + * totalCount?: ?int, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->conversationParts = $values['conversationParts']; - $this->totalCount = $values['totalCount']; + $this->type = $values['type'] ?? null; + $this->conversationParts = $values['conversationParts'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; } /** - * @return 'conversation_part.list' + * @return ?'conversation_part.list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'conversation_part.list' $value + * @param ?'conversation_part.list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getConversationParts(): array + public function getConversationParts(): ?array { return $this->conversationParts; } /** - * @param array $value + * @param ?array $value */ - public function setConversationParts(array $value): self + public function setConversationParts(?array $value = null): self { $this->conversationParts = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; diff --git a/src/Types/ConversationRating.php b/src/Types/ConversationRating.php index 41619f8..21084bc 100644 --- a/src/Types/ConversationRating.php +++ b/src/Types/ConversationRating.php @@ -11,134 +11,159 @@ class ConversationRating extends JsonSerializableType { /** - * @var int $rating The rating, between 1 and 5, for the conversation. + * @var ?int $rating The rating, between 1 and 5, for the conversation. */ #[JsonProperty('rating')] - private int $rating; + private ?int $rating; /** - * @var string $remark An optional field to add a remark to correspond to the number rating + * @var ?string $remark An optional field to add a remark to correspond to the number rating */ #[JsonProperty('remark')] - private string $remark; + private ?string $remark; /** - * @var int $createdAt The time the rating was requested in the conversation being rated. + * @var ?int $createdAt The time the rating was requested in the conversation being rated. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** - * @var ContactReference $contact + * @var ?int $updatedAt The time the rating was last updated. + */ + #[JsonProperty('updated_at')] + private ?int $updatedAt; + + /** + * @var ?ContactReference $contact */ #[JsonProperty('contact')] - private ContactReference $contact; + private ?ContactReference $contact; /** - * @var Reference $teammate + * @var ?Reference $teammate */ #[JsonProperty('teammate')] - private Reference $teammate; + private ?Reference $teammate; /** * @param array{ - * rating: int, - * remark: string, - * createdAt: int, - * contact: ContactReference, - * teammate: Reference, + * rating?: ?int, + * remark?: ?string, + * createdAt?: ?int, + * updatedAt?: ?int, + * contact?: ?ContactReference, + * teammate?: ?Reference, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->rating = $values['rating']; - $this->remark = $values['remark']; - $this->createdAt = $values['createdAt']; - $this->contact = $values['contact']; - $this->teammate = $values['teammate']; + $this->rating = $values['rating'] ?? null; + $this->remark = $values['remark'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->contact = $values['contact'] ?? null; + $this->teammate = $values['teammate'] ?? null; } /** - * @return int + * @return ?int */ - public function getRating(): int + public function getRating(): ?int { return $this->rating; } /** - * @param int $value + * @param ?int $value */ - public function setRating(int $value): self + public function setRating(?int $value = null): self { $this->rating = $value; return $this; } /** - * @return string + * @return ?string */ - public function getRemark(): string + public function getRemark(): ?string { return $this->remark; } /** - * @param string $value + * @param ?string $value */ - public function setRemark(string $value): self + public function setRemark(?string $value = null): self { $this->remark = $value; return $this; } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; } /** - * @return ContactReference + * @return ?int + */ + public function getUpdatedAt(): ?int + { + return $this->updatedAt; + } + + /** + * @param ?int $value + */ + public function setUpdatedAt(?int $value = null): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return ?ContactReference */ - public function getContact(): ContactReference + public function getContact(): ?ContactReference { return $this->contact; } /** - * @param ContactReference $value + * @param ?ContactReference $value */ - public function setContact(ContactReference $value): self + public function setContact(?ContactReference $value = null): self { $this->contact = $value; return $this; } /** - * @return Reference + * @return ?Reference */ - public function getTeammate(): Reference + public function getTeammate(): ?Reference { return $this->teammate; } /** - * @param Reference $value + * @param ?Reference $value */ - public function setTeammate(Reference $value): self + public function setTeammate(?Reference $value = null): self { $this->teammate = $value; return $this; diff --git a/src/Types/ConversationResponseTime.php b/src/Types/ConversationResponseTime.php new file mode 100644 index 0000000..ee5a9a6 --- /dev/null +++ b/src/Types/ConversationResponseTime.php @@ -0,0 +1,104 @@ +teamId = $values['teamId'] ?? null; + $this->teamName = $values['teamName'] ?? null; + $this->responseTime = $values['responseTime'] ?? null; + } + + /** + * @return ?int + */ + public function getTeamId(): ?int + { + return $this->teamId; + } + + /** + * @param ?int $value + */ + public function setTeamId(?int $value = null): self + { + $this->teamId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getTeamName(): ?string + { + return $this->teamName; + } + + /** + * @param ?string $value + */ + public function setTeamName(?string $value = null): self + { + $this->teamName = $value; + return $this; + } + + /** + * @return ?int + */ + public function getResponseTime(): ?int + { + return $this->responseTime; + } + + /** + * @param ?int $value + */ + public function setResponseTime(?int $value = null): self + { + $this->responseTime = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ConversationSource.php b/src/Types/ConversationSource.php index a2506ee..9c82734 100644 --- a/src/Types/ConversationSource.php +++ b/src/Types/ConversationSource.php @@ -7,33 +7,33 @@ use Intercom\Core\Types\ArrayType; /** - * The Conversation Part that originated this conversation, which can be Contact, Admin, Campaign, Automated or Operator initiated. + * The type of the conversation part that started this conversation. Can be Contact, Admin, Campaign, Automated or Operator initiated. */ class ConversationSource extends JsonSerializableType { /** - * @var value-of $type This includes conversation, email, facebook, instagram, phone_call, phone_switch, push, sms, twitter and whatsapp. + * @var ?value-of $type This includes conversation, email, facebook, instagram, phone_call, phone_switch, push, sms, twitter and whatsapp. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The id representing the message. + * @var ?string $id The id representing the message. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $deliveredAs The conversation's initiation type. Possible values are customer_initiated, campaigns_initiated (legacy campaigns), operator_initiated (Custom bot), automated (Series and other outbounds with dynamic audience message) and admin_initiated (fixed audience message, ticket initiated by an admin, group email). + * @var ?string $deliveredAs The conversation's initiation type. Possible values are customer_initiated, campaigns_initiated (legacy campaigns), operator_initiated (Custom bot), automated (Series and other outbounds with dynamic audience message) and admin_initiated (fixed audience message, ticket initiated by an admin, group email). */ #[JsonProperty('delivered_as')] - private string $deliveredAs; + private ?string $deliveredAs; /** - * @var string $subject Optional. The message subject. For Twitter, this will show a generic message regarding why the subject is obscured. + * @var ?string $subject Optional. The message subject. For Twitter, this will show a generic message regarding why the subject is obscured. */ #[JsonProperty('subject')] - private string $subject; + private ?string $subject; /** * @var ?string $body The message body, which may contain HTML. For Twitter, this will show a generic message regarding why the body is obscured. @@ -42,10 +42,10 @@ class ConversationSource extends JsonSerializableType private ?string $body; /** - * @var ConversationPartAuthor $author + * @var ?ConversationPartAuthor $author */ #[JsonProperty('author')] - private ConversationPartAuthor $author; + private ?ConversationPartAuthor $author; /** * @var ?array $attachments A list of attachments for the part. @@ -60,101 +60,101 @@ class ConversationSource extends JsonSerializableType private ?string $url; /** - * @var bool $redacted Whether or not the source message has been redacted. Only applicable for contact initiated messages. + * @var ?bool $redacted Whether or not the source message has been redacted. Only applicable for contact initiated messages. */ #[JsonProperty('redacted')] - private bool $redacted; + private ?bool $redacted; /** * @param array{ - * type: value-of, - * id: string, - * deliveredAs: string, - * subject: string, - * author: ConversationPartAuthor, - * redacted: bool, + * type?: ?value-of, + * id?: ?string, + * deliveredAs?: ?string, + * subject?: ?string, * body?: ?string, + * author?: ?ConversationPartAuthor, * attachments?: ?array, * url?: ?string, + * redacted?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->deliveredAs = $values['deliveredAs']; - $this->subject = $values['subject']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->deliveredAs = $values['deliveredAs'] ?? null; + $this->subject = $values['subject'] ?? null; $this->body = $values['body'] ?? null; - $this->author = $values['author']; + $this->author = $values['author'] ?? null; $this->attachments = $values['attachments'] ?? null; $this->url = $values['url'] ?? null; - $this->redacted = $values['redacted']; + $this->redacted = $values['redacted'] ?? null; } /** - * @return value-of + * @return ?value-of */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getDeliveredAs(): string + public function getDeliveredAs(): ?string { return $this->deliveredAs; } /** - * @param string $value + * @param ?string $value */ - public function setDeliveredAs(string $value): self + public function setDeliveredAs(?string $value = null): self { $this->deliveredAs = $value; return $this; } /** - * @return string + * @return ?string */ - public function getSubject(): string + public function getSubject(): ?string { return $this->subject; } /** - * @param string $value + * @param ?string $value */ - public function setSubject(string $value): self + public function setSubject(?string $value = null): self { $this->subject = $value; return $this; @@ -178,17 +178,17 @@ public function setBody(?string $value = null): self } /** - * @return ConversationPartAuthor + * @return ?ConversationPartAuthor */ - public function getAuthor(): ConversationPartAuthor + public function getAuthor(): ?ConversationPartAuthor { return $this->author; } /** - * @param ConversationPartAuthor $value + * @param ?ConversationPartAuthor $value */ - public function setAuthor(ConversationPartAuthor $value): self + public function setAuthor(?ConversationPartAuthor $value = null): self { $this->author = $value; return $this; @@ -229,17 +229,17 @@ public function setUrl(?string $value = null): self } /** - * @return bool + * @return ?bool */ - public function getRedacted(): bool + public function getRedacted(): ?bool { return $this->redacted; } /** - * @param bool $value + * @param ?bool $value */ - public function setRedacted(bool $value): self + public function setRedacted(?bool $value = null): self { $this->redacted = $value; return $this; diff --git a/src/Types/ConversationStatistics.php b/src/Types/ConversationStatistics.php index d7b844e..8fdc18d 100644 --- a/src/Types/ConversationStatistics.php +++ b/src/Types/ConversationStatistics.php @@ -4,6 +4,7 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; +use Intercom\Core\Types\ArrayType; /** * A Statistics object containing all information required for reporting, with timestamps and calculated metrics. @@ -11,10 +12,10 @@ class ConversationStatistics extends JsonSerializableType { /** - * @var 'conversation_statistics' $type + * @var ?string $type */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** * @var ?int $timeToAssignment Duration until last assignment before first admin reply. In seconds. @@ -124,9 +125,27 @@ class ConversationStatistics extends JsonSerializableType #[JsonProperty('count_conversation_parts')] private ?int $countConversationParts; + /** + * @var ?array $assignedTeamFirstResponseTimeByTeam An array of conversation response time objects + */ + #[JsonProperty('assigned_team_first_response_time_by_team'), ArrayType([ConversationResponseTime::class])] + private ?array $assignedTeamFirstResponseTimeByTeam; + + /** + * @var ?array $assignedTeamFirstResponseTimeInOfficeHours An array of conversation response time objects within office hours + */ + #[JsonProperty('assigned_team_first_response_time_in_office_hours'), ArrayType([ConversationResponseTime::class])] + private ?array $assignedTeamFirstResponseTimeInOfficeHours; + + /** + * @var ?int $handlingTime Time from conversation assignment to conversation close in seconds. + */ + #[JsonProperty('handling_time')] + private ?int $handlingTime; + /** * @param array{ - * type: 'conversation_statistics', + * type?: ?string, * timeToAssignment?: ?int, * timeToAdminReply?: ?int, * timeToFirstClose?: ?int, @@ -145,12 +164,15 @@ class ConversationStatistics extends JsonSerializableType * countReopens?: ?int, * countAssignments?: ?int, * countConversationParts?: ?int, + * assignedTeamFirstResponseTimeByTeam?: ?array, + * assignedTeamFirstResponseTimeInOfficeHours?: ?array, + * handlingTime?: ?int, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; + $this->type = $values['type'] ?? null; $this->timeToAssignment = $values['timeToAssignment'] ?? null; $this->timeToAdminReply = $values['timeToAdminReply'] ?? null; $this->timeToFirstClose = $values['timeToFirstClose'] ?? null; @@ -169,20 +191,23 @@ public function __construct( $this->countReopens = $values['countReopens'] ?? null; $this->countAssignments = $values['countAssignments'] ?? null; $this->countConversationParts = $values['countConversationParts'] ?? null; + $this->assignedTeamFirstResponseTimeByTeam = $values['assignedTeamFirstResponseTimeByTeam'] ?? null; + $this->assignedTeamFirstResponseTimeInOfficeHours = $values['assignedTeamFirstResponseTimeInOfficeHours'] ?? null; + $this->handlingTime = $values['handlingTime'] ?? null; } /** - * @return 'conversation_statistics' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'conversation_statistics' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; @@ -494,6 +519,57 @@ public function setCountConversationParts(?int $value = null): self return $this; } + /** + * @return ?array + */ + public function getAssignedTeamFirstResponseTimeByTeam(): ?array + { + return $this->assignedTeamFirstResponseTimeByTeam; + } + + /** + * @param ?array $value + */ + public function setAssignedTeamFirstResponseTimeByTeam(?array $value = null): self + { + $this->assignedTeamFirstResponseTimeByTeam = $value; + return $this; + } + + /** + * @return ?array + */ + public function getAssignedTeamFirstResponseTimeInOfficeHours(): ?array + { + return $this->assignedTeamFirstResponseTimeInOfficeHours; + } + + /** + * @param ?array $value + */ + public function setAssignedTeamFirstResponseTimeInOfficeHours(?array $value = null): self + { + $this->assignedTeamFirstResponseTimeInOfficeHours = $value; + return $this; + } + + /** + * @return ?int + */ + public function getHandlingTime(): ?int + { + return $this->handlingTime; + } + + /** + * @param ?int $value + */ + public function setHandlingTime(?int $value = null): self + { + $this->handlingTime = $value; + return $this; + } + /** * @return string */ diff --git a/src/Articles/Requests/CreateArticleRequest.php b/src/Types/CreateArticleRequest.php similarity index 96% rename from src/Articles/Requests/CreateArticleRequest.php rename to src/Types/CreateArticleRequest.php index c38aee4..961087e 100644 --- a/src/Articles/Requests/CreateArticleRequest.php +++ b/src/Types/CreateArticleRequest.php @@ -1,13 +1,13 @@ translatedContent = $value; return $this; } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } } diff --git a/src/Articles/Types/CreateArticleRequestParentType.php b/src/Types/CreateArticleRequestParentType.php similarity index 77% rename from src/Articles/Types/CreateArticleRequestParentType.php rename to src/Types/CreateArticleRequestParentType.php index 55ae37f..8ed8dcf 100644 --- a/src/Articles/Types/CreateArticleRequestParentType.php +++ b/src/Types/CreateArticleRequestParentType.php @@ -1,6 +1,6 @@ $dataType + */ + #[JsonProperty('data_type')] + private ?string $dataType; + + /** + * @param array{ + * dataType?: ?value-of, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->dataType = $values['dataType'] ?? null; + } + + /** + * @return ?value-of + */ + public function getDataType(): ?string + { + return $this->dataType; + } + + /** + * @param ?value-of $value + */ + public function setDataType(?string $value = null): self + { + $this->dataType = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/DataAttributes/Types/CreateDataAttributeRequestDataType.php b/src/Types/CreateDataAttributeRequestOneDataType.php similarity index 67% rename from src/DataAttributes/Types/CreateDataAttributeRequestDataType.php rename to src/Types/CreateDataAttributeRequestOneDataType.php index ed7177c..af7f8ea 100644 --- a/src/DataAttributes/Types/CreateDataAttributeRequestDataType.php +++ b/src/Types/CreateDataAttributeRequestOneDataType.php @@ -1,8 +1,8 @@ $options Array of objects representing the options of the list, with `value` as the key and the option as the value. At least two options are required. + */ + #[JsonProperty('options'), ArrayType([CreateDataAttributeRequestOptionsOptionsItem::class])] + private array $options; + + /** + * @param array{ + * options: array, + * dataType?: ?'options', + * } $values + */ + public function __construct( + array $values, + ) { + $this->dataType = $values['dataType'] ?? null; + $this->options = $values['options']; + } + + /** + * @return ?'options' + */ + public function getDataType(): ?string + { + return $this->dataType; + } + + /** + * @param ?'options' $value + */ + public function setDataType(?string $value = null): self + { + $this->dataType = $value; + return $this; + } + + /** + * @return array + */ + public function getOptions(): array + { + return $this->options; + } + + /** + * @param array $value + */ + public function setOptions(array $value): self + { + $this->options = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/CreateDataAttributeRequestOptionsOptionsItem.php b/src/Types/CreateDataAttributeRequestOptionsOptionsItem.php new file mode 100644 index 0000000..3d04ffb --- /dev/null +++ b/src/Types/CreateDataAttributeRequestOptionsOptionsItem.php @@ -0,0 +1,51 @@ +value = $values['value'] ?? null; + } + + /** + * @return ?string + */ + public function getValue(): ?string + { + return $this->value; + } + + /** + * @param ?string $value + */ + public function setValue(?string $value = null): self + { + $this->value = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/CreateInternalArticleRequest.php b/src/Types/CreateInternalArticleRequest.php new file mode 100644 index 0000000..7bf82db --- /dev/null +++ b/src/Types/CreateInternalArticleRequest.php @@ -0,0 +1,129 @@ +title = $values['title']; + $this->body = $values['body'] ?? null; + $this->authorId = $values['authorId']; + $this->ownerId = $values['ownerId']; + } + + /** + * @return string + */ + public function getTitle(): string + { + return $this->title; + } + + /** + * @param string $value + */ + public function setTitle(string $value): self + { + $this->title = $value; + return $this; + } + + /** + * @return ?string + */ + public function getBody(): ?string + { + return $this->body; + } + + /** + * @param ?string $value + */ + public function setBody(?string $value = null): self + { + $this->body = $value; + return $this; + } + + /** + * @return int + */ + public function getAuthorId(): int + { + return $this->authorId; + } + + /** + * @param int $value + */ + public function setAuthorId(int $value): self + { + $this->authorId = $value; + return $this; + } + + /** + * @return int + */ + public function getOwnerId(): int + { + return $this->ownerId; + } + + /** + * @param int $value + */ + public function setOwnerId(int $value): self + { + $this->ownerId = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Companies/Requests/CreateOrUpdateCompanyRequest.php b/src/Types/CreateOrUpdateCompanyRequest.php similarity index 96% rename from src/Companies/Requests/CreateOrUpdateCompanyRequest.php rename to src/Types/CreateOrUpdateCompanyRequest.php index ad18998..c7674a1 100644 --- a/src/Companies/Requests/CreateOrUpdateCompanyRequest.php +++ b/src/Types/CreateOrUpdateCompanyRequest.php @@ -1,11 +1,14 @@ monthlySpend = $value; return $this; } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } } diff --git a/src/PhoneCallRedirects/Requests/CreatePhoneCallRedirectRequest.php b/src/Types/CreatePhoneSwitchRequest.php similarity index 58% rename from src/PhoneCallRedirects/Requests/CreatePhoneCallRedirectRequest.php rename to src/Types/CreatePhoneSwitchRequest.php index 2225282..7c09f24 100644 --- a/src/PhoneCallRedirects/Requests/CreatePhoneCallRedirectRequest.php +++ b/src/Types/CreatePhoneSwitchRequest.php @@ -1,12 +1,17 @@ $customAttributes + * @var ?array $customAttributes */ - #[JsonProperty('custom_attributes'), ArrayType(['string' => 'mixed'])] + #[JsonProperty('custom_attributes'), ArrayType(['string' => new Union('string', 'integer', 'datetime', CustomObjectInstanceList::class)])] private ?array $customAttributes; /** * @param array{ * phone: string, - * customAttributes?: ?array, + * customAttributes?: ?array, * } $values */ public function __construct( @@ -51,7 +66,12 @@ public function setPhone(string $value): self } /** - * @return ?array + * @return ?array */ public function getCustomAttributes(): ?array { @@ -59,11 +79,24 @@ public function getCustomAttributes(): ?array } /** - * @param ?array $value + * @param ?array $value */ public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; return $this; } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } } diff --git a/src/Types/CreateTicketRequestAssignment.php b/src/Types/CreateTicketRequestAssignment.php new file mode 100644 index 0000000..05ab972 --- /dev/null +++ b/src/Types/CreateTicketRequestAssignment.php @@ -0,0 +1,76 @@ +adminAssigneeId = $values['adminAssigneeId'] ?? null; + $this->teamAssigneeId = $values['teamAssigneeId'] ?? null; + } + + /** + * @return ?string + */ + public function getAdminAssigneeId(): ?string + { + return $this->adminAssigneeId; + } + + /** + * @param ?string $value + */ + public function setAdminAssigneeId(?string $value = null): self + { + $this->adminAssigneeId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getTeamAssigneeId(): ?string + { + return $this->teamAssigneeId; + } + + /** + * @param ?string $value + */ + public function setTeamAssigneeId(?string $value = null): self + { + $this->teamAssigneeId = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/CreateTicketRequest.php b/src/Types/CreateTicketRequestBody.php similarity index 68% rename from src/Types/CreateTicketRequest.php rename to src/Types/CreateTicketRequestBody.php index a0bb8d5..5096f35 100644 --- a/src/Types/CreateTicketRequest.php +++ b/src/Types/CreateTicketRequestBody.php @@ -10,7 +10,7 @@ /** * You can create a Ticket */ -class CreateTicketRequest extends JsonSerializableType +class CreateTicketRequestBody extends JsonSerializableType { /** * @var string $ticketTypeId The ID of the type of ticket you want to create @@ -29,7 +29,19 @@ class CreateTicketRequest extends JsonSerializableType private array $contacts; /** - * @var ?string $companyId The ID of the company that the ticket is associated with. The ID that you set upon company creation. + * The ID of the conversation you want to link to the ticket. Here are the valid ways of linking two tickets: + * - conversation | back-office ticket + * - customer tickets | non-shared back-office ticket + * - conversation | tracker ticket + * - customer ticket | tracker ticket + * + * @var ?string $conversationToLinkId + */ + #[JsonProperty('conversation_to_link_id')] + private ?string $conversationToLinkId; + + /** + * @var ?string $companyId The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom */ #[JsonProperty('company_id')] private ?string $companyId; @@ -41,10 +53,10 @@ class CreateTicketRequest extends JsonSerializableType private ?int $createdAt; /** - * @var ?array $ticketAttributes + * @var ?CreateTicketRequestAssignment $assignment */ - #[JsonProperty('ticket_attributes'), ArrayType(['string' => 'mixed'])] - private ?array $ticketAttributes; + #[JsonProperty('assignment')] + private ?CreateTicketRequestAssignment $assignment; /** * @param array{ @@ -54,9 +66,10 @@ class CreateTicketRequest extends JsonSerializableType * |CreateTicketRequestContactsItemExternalId * |CreateTicketRequestContactsItemEmail * )>, + * conversationToLinkId?: ?string, * companyId?: ?string, * createdAt?: ?int, - * ticketAttributes?: ?array, + * assignment?: ?CreateTicketRequestAssignment, * } $values */ public function __construct( @@ -64,9 +77,10 @@ public function __construct( ) { $this->ticketTypeId = $values['ticketTypeId']; $this->contacts = $values['contacts']; + $this->conversationToLinkId = $values['conversationToLinkId'] ?? null; $this->companyId = $values['companyId'] ?? null; $this->createdAt = $values['createdAt'] ?? null; - $this->ticketAttributes = $values['ticketAttributes'] ?? null; + $this->assignment = $values['assignment'] ?? null; } /** @@ -111,6 +125,23 @@ public function setContacts(array $value): self return $this; } + /** + * @return ?string + */ + public function getConversationToLinkId(): ?string + { + return $this->conversationToLinkId; + } + + /** + * @param ?string $value + */ + public function setConversationToLinkId(?string $value = null): self + { + $this->conversationToLinkId = $value; + return $this; + } + /** * @return ?string */ @@ -146,19 +177,19 @@ public function setCreatedAt(?int $value = null): self } /** - * @return ?array + * @return ?CreateTicketRequestAssignment */ - public function getTicketAttributes(): ?array + public function getAssignment(): ?CreateTicketRequestAssignment { - return $this->ticketAttributes; + return $this->assignment; } /** - * @param ?array $value + * @param ?CreateTicketRequestAssignment $value */ - public function setTicketAttributes(?array $value = null): self + public function setAssignment(?CreateTicketRequestAssignment $value = null): self { - $this->ticketAttributes = $value; + $this->assignment = $value; return $this; } diff --git a/src/TicketTypes/Requests/CreateTicketTypeRequest.php b/src/Types/CreateTicketTypeRequest.php similarity index 90% rename from src/TicketTypes/Requests/CreateTicketTypeRequest.php rename to src/Types/CreateTicketTypeRequest.php index 0c97806..361103d 100644 --- a/src/TicketTypes/Requests/CreateTicketTypeRequest.php +++ b/src/Types/CreateTicketTypeRequest.php @@ -1,11 +1,14 @@ isInternal = $value; return $this; } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } } diff --git a/src/TicketTypes/Types/CreateTicketTypeRequestCategory.php b/src/Types/CreateTicketTypeRequestCategory.php similarity index 80% rename from src/TicketTypes/Types/CreateTicketTypeRequestCategory.php rename to src/Types/CreateTicketTypeRequestCategory.php index d5c8159..42f026c 100644 --- a/src/TicketTypes/Types/CreateTicketTypeRequestCategory.php +++ b/src/Types/CreateTicketTypeRequestCategory.php @@ -1,6 +1,6 @@ currentCanvas = $values['currentCanvas']; - } - - /** - * @return CanvasObject - */ - public function getCurrentCanvas(): CanvasObject - { - return $this->currentCanvas; - } - - /** - * @param CanvasObject $value - */ - public function setCurrentCanvas(CanvasObject $value): self - { - $this->currentCanvas = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/CursorPages.php b/src/Types/CursorPages.php index eafc215..d045236 100644 --- a/src/Types/CursorPages.php +++ b/src/Types/CursorPages.php @@ -12,10 +12,10 @@ class CursorPages extends JsonSerializableType { /** - * @var 'pages' $type the type of object `pages`. + * @var ?'pages' $type the type of object `pages`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** * @var ?int $page The current page @@ -43,7 +43,7 @@ class CursorPages extends JsonSerializableType /** * @param array{ - * type: 'pages', + * type?: ?'pages', * page?: ?int, * next?: ?StartingAfterPaging, * perPage?: ?int, @@ -51,9 +51,9 @@ class CursorPages extends JsonSerializableType * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; + $this->type = $values['type'] ?? null; $this->page = $values['page'] ?? null; $this->next = $values['next'] ?? null; $this->perPage = $values['perPage'] ?? null; @@ -61,17 +61,17 @@ public function __construct( } /** - * @return 'pages' + * @return ?'pages' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'pages' $value + * @param ?'pages' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; diff --git a/src/Types/CustomActionFinished.php b/src/Types/CustomActionFinished.php new file mode 100644 index 0000000..ae6bb94 --- /dev/null +++ b/src/Types/CustomActionFinished.php @@ -0,0 +1,54 @@ +custom_action_finished. + */ +class CustomActionFinished extends JsonSerializableType +{ + /** + * @var ?CustomActionFinishedAction $action + */ + #[JsonProperty('action')] + private ?CustomActionFinishedAction $action; + + /** + * @param array{ + * action?: ?CustomActionFinishedAction, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->action = $values['action'] ?? null; + } + + /** + * @return ?CustomActionFinishedAction + */ + public function getAction(): ?CustomActionFinishedAction + { + return $this->action; + } + + /** + * @param ?CustomActionFinishedAction $value + */ + public function setAction(?CustomActionFinishedAction $value = null): self + { + $this->action = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/CustomActionFinishedAction.php b/src/Types/CustomActionFinishedAction.php new file mode 100644 index 0000000..ed04712 --- /dev/null +++ b/src/Types/CustomActionFinishedAction.php @@ -0,0 +1,76 @@ + $result Status of the action + */ + #[JsonProperty('result')] + private ?string $result; + + /** + * @param array{ + * name?: ?string, + * result?: ?value-of, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->name = $values['name'] ?? null; + $this->result = $values['result'] ?? null; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return ?value-of + */ + public function getResult(): ?string + { + return $this->result; + } + + /** + * @param ?value-of $value + */ + public function setResult(?string $value = null): self + { + $this->result = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/CustomActionFinishedActionResult.php b/src/Types/CustomActionFinishedActionResult.php new file mode 100644 index 0000000..ac6f488 --- /dev/null +++ b/src/Types/CustomActionFinishedActionResult.php @@ -0,0 +1,9 @@ +custom_action_started. + */ +class CustomActionStarted extends JsonSerializableType +{ + /** + * @var ?CustomActionStartedAction $action + */ + #[JsonProperty('action')] + private ?CustomActionStartedAction $action; + + /** + * @param array{ + * action?: ?CustomActionStartedAction, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->action = $values['action'] ?? null; + } + + /** + * @return ?CustomActionStartedAction + */ + public function getAction(): ?CustomActionStartedAction + { + return $this->action; + } + + /** + * @param ?CustomActionStartedAction $value + */ + public function setAction(?CustomActionStartedAction $value = null): self + { + $this->action = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/CustomActionStartedAction.php b/src/Types/CustomActionStartedAction.php new file mode 100644 index 0000000..024b4e0 --- /dev/null +++ b/src/Types/CustomActionStartedAction.php @@ -0,0 +1,51 @@ +name = $values['name'] ?? null; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/DataAttributes/Types/UpdateDataAttributeRequestOptionsItem.php b/src/Types/CustomChannelAttribute.php similarity index 55% rename from src/DataAttributes/Types/UpdateDataAttributeRequestOptionsItem.php rename to src/Types/CustomChannelAttribute.php index f37b59e..3376c63 100644 --- a/src/DataAttributes/Types/UpdateDataAttributeRequestOptionsItem.php +++ b/src/Types/CustomChannelAttribute.php @@ -1,29 +1,54 @@ id = $values['id']; $this->value = $values['value']; } + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $value + */ + public function setId(string $value): self + { + $this->id = $value; + return $this; + } + /** * @return string */ diff --git a/src/Types/CustomChannelBaseEvent.php b/src/Types/CustomChannelBaseEvent.php new file mode 100644 index 0000000..c1eed94 --- /dev/null +++ b/src/Types/CustomChannelBaseEvent.php @@ -0,0 +1,101 @@ +eventId = $values['eventId']; + $this->externalConversationId = $values['externalConversationId']; + $this->contact = $values['contact']; + } + + /** + * @return string + */ + public function getEventId(): string + { + return $this->eventId; + } + + /** + * @param string $value + */ + public function setEventId(string $value): self + { + $this->eventId = $value; + return $this; + } + + /** + * @return string + */ + public function getExternalConversationId(): string + { + return $this->externalConversationId; + } + + /** + * @param string $value + */ + public function setExternalConversationId(string $value): self + { + $this->externalConversationId = $value; + return $this; + } + + /** + * @return CustomChannelContact + */ + public function getContact(): CustomChannelContact + { + return $this->contact; + } + + /** + * @param CustomChannelContact $value + */ + public function setContact(CustomChannelContact $value): self + { + $this->contact = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/CustomChannelContact.php b/src/Types/CustomChannelContact.php new file mode 100644 index 0000000..35cc727 --- /dev/null +++ b/src/Types/CustomChannelContact.php @@ -0,0 +1,126 @@ + $type Type of contact, must be "user" or "lead". + */ + #[JsonProperty('type')] + private string $type; + + /** + * @var string $externalId External identifier for the contact. Intercom will take care of the mapping of your external_id with our internal ones so you don't have to worry about it. + */ + #[JsonProperty('external_id')] + private string $externalId; + + /** + * @var ?string $name Name of the contact. Required for user type. + */ + #[JsonProperty('name')] + private ?string $name; + + /** + * @var ?string $email Email address of the contact. Required for user type. + */ + #[JsonProperty('email')] + private ?string $email; + + /** + * @param array{ + * type: value-of, + * externalId: string, + * name?: ?string, + * email?: ?string, + * } $values + */ + public function __construct( + array $values, + ) { + $this->type = $values['type']; + $this->externalId = $values['externalId']; + $this->name = $values['name'] ?? null; + $this->email = $values['email'] ?? null; + } + + /** + * @return value-of + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param value-of $value + */ + public function setType(string $value): self + { + $this->type = $value; + return $this; + } + + /** + * @return string + */ + public function getExternalId(): string + { + return $this->externalId; + } + + /** + * @param string $value + */ + public function setExternalId(string $value): self + { + $this->externalId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return ?string + */ + public function getEmail(): ?string + { + return $this->email; + } + + /** + * @param ?string $value + */ + public function setEmail(?string $value = null): self + { + $this->email = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/CustomChannelContactType.php b/src/Types/CustomChannelContactType.php new file mode 100644 index 0000000..08876cb --- /dev/null +++ b/src/Types/CustomChannelContactType.php @@ -0,0 +1,9 @@ +externalConversationId = $values['externalConversationId']; + $this->conversationId = $values['conversationId']; + $this->externalContactId = $values['externalContactId']; + $this->contactId = $values['contactId']; + } + + /** + * @return string + */ + public function getExternalConversationId(): string + { + return $this->externalConversationId; + } + + /** + * @param string $value + */ + public function setExternalConversationId(string $value): self + { + $this->externalConversationId = $value; + return $this; + } + + /** + * @return string + */ + public function getConversationId(): string + { + return $this->conversationId; + } + + /** + * @param string $value + */ + public function setConversationId(string $value): self + { + $this->conversationId = $value; + return $this; + } + + /** + * @return string + */ + public function getExternalContactId(): string + { + return $this->externalContactId; + } + + /** + * @param string $value + */ + public function setExternalContactId(string $value): self + { + $this->externalContactId = $value; + return $this; + } + + /** + * @return string + */ + public function getContactId(): string + { + return $this->contactId; + } + + /** + * @param string $value + */ + public function setContactId(string $value): self + { + $this->contactId = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/CustomObjectInstanceDeleted.php b/src/Types/CustomObjectInstanceDeleted.php new file mode 100644 index 0000000..1554f21 --- /dev/null +++ b/src/Types/CustomObjectInstanceDeleted.php @@ -0,0 +1,104 @@ +object = $values['object'] ?? null; + $this->id = $values['id'] ?? null; + $this->deleted = $values['deleted'] ?? null; + } + + /** + * @return ?string + */ + public function getObject(): ?string + { + return $this->object; + } + + /** + * @param ?string $value + */ + public function setObject(?string $value = null): self + { + $this->object = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getDeleted(): ?bool + { + return $this->deleted; + } + + /** + * @param ?bool $value + */ + public function setDeleted(?bool $value = null): self + { + $this->deleted = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/CustomObjectInstanceList.php b/src/Types/CustomObjectInstanceList.php new file mode 100644 index 0000000..c4d6958 --- /dev/null +++ b/src/Types/CustomObjectInstanceList.php @@ -0,0 +1,82 @@ + $instances The list of associated custom object instances for a given reference attribute on the parent object. + */ + #[JsonProperty('instances'), ArrayType([new Union(CustomObjectInstance::class, 'null')])] + private ?array $instances; + + /** + * @param array{ + * type?: ?string, + * instances?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->instances = $values['instances'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?array + */ + public function getInstances(): ?array + { + return $this->instances; + } + + /** + * @param ?array $value + */ + public function setInstances(?array $value = null): self + { + $this->instances = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DataAttributeList.php b/src/Types/DataAttributeList.php index 47b9e8c..8169b21 100644 --- a/src/Types/DataAttributeList.php +++ b/src/Types/DataAttributeList.php @@ -13,59 +13,59 @@ class DataAttributeList extends JsonSerializableType { /** - * @var 'list' $type The type of the object + * @var ?'list' $type The type of the object */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $data A list of data attributes + * @var ?array $data A list of data attributes */ #[JsonProperty('data'), ArrayType([DataAttribute::class])] - private array $data; + private ?array $data; /** * @param array{ - * type: 'list', - * data: array, + * type?: ?'list', + * data?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->data = $values['data']; + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; diff --git a/src/Types/DataEventList.php b/src/Types/DataEventList.php index 47cbb0a..6e1202e 100644 --- a/src/Types/DataEventList.php +++ b/src/Types/DataEventList.php @@ -13,16 +13,16 @@ class DataEventList extends JsonSerializableType { /** - * @var 'event.list' $type The type of the object + * @var ?'event.list' $type The type of the object */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $events A list of data events + * @var ?array $events A list of data events */ #[JsonProperty('events'), ArrayType([DataEvent::class])] - private array $events; + private ?array $events; /** * @var ?DataEventListPages $pages Pagination @@ -32,48 +32,48 @@ class DataEventList extends JsonSerializableType /** * @param array{ - * type: 'event.list', - * events: array, + * type?: ?'event.list', + * events?: ?array, * pages?: ?DataEventListPages, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->events = $values['events']; + $this->type = $values['type'] ?? null; + $this->events = $values['events'] ?? null; $this->pages = $values['pages'] ?? null; } /** - * @return 'event.list' + * @return ?'event.list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'event.list' $value + * @param ?'event.list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getEvents(): array + public function getEvents(): ?array { return $this->events; } /** - * @param array $value + * @param ?array $value */ - public function setEvents(array $value): self + public function setEvents(?array $value = null): self { $this->events = $value; return $this; diff --git a/src/Types/DataEventSummary.php b/src/Types/DataEventSummary.php index 46cf0a3..9923e70 100644 --- a/src/Types/DataEventSummary.php +++ b/src/Types/DataEventSummary.php @@ -5,6 +5,7 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; use Intercom\Core\Types\ArrayType; +use Intercom\Core\Types\Union; /** * This will return a summary of data events for the App. @@ -36,14 +37,14 @@ class DataEventSummary extends JsonSerializableType private ?string $userId; /** - * @var array $events A summary of data events + * @var array $events A summary of data events */ - #[JsonProperty('events'), ArrayType([DataEventSummaryItem::class])] + #[JsonProperty('events'), ArrayType([new Union(DataEventSummaryItem::class, 'null')])] private array $events; /** * @param array{ - * events: array, + * events: array, * type?: ?'event.summary', * email?: ?string, * intercomUserId?: ?string, @@ -129,7 +130,7 @@ public function setUserId(?string $value = null): self } /** - * @return array + * @return array */ public function getEvents(): array { @@ -137,7 +138,7 @@ public function getEvents(): array } /** - * @param array $value + * @param array $value */ public function setEvents(array $value): self { diff --git a/src/Types/DataEventSummaryItem.php b/src/Types/DataEventSummaryItem.php index 472855c..6cc3ce2 100644 --- a/src/Types/DataEventSummaryItem.php +++ b/src/Types/DataEventSummaryItem.php @@ -11,28 +11,28 @@ class DataEventSummaryItem extends JsonSerializableType { /** - * @var string $name The name of the event + * @var ?string $name The name of the event */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var string $first The first time the event was sent + * @var ?string $first The first time the event was sent */ #[JsonProperty('first')] - private string $first; + private ?string $first; /** - * @var string $last The last time the event was sent + * @var ?string $last The last time the event was sent */ #[JsonProperty('last')] - private string $last; + private ?string $last; /** - * @var int $count The number of times the event was sent + * @var ?int $count The number of times the event was sent */ #[JsonProperty('count')] - private int $count; + private ?int $count; /** * @var ?string $description The description of the event @@ -42,86 +42,86 @@ class DataEventSummaryItem extends JsonSerializableType /** * @param array{ - * name: string, - * first: string, - * last: string, - * count: int, + * name?: ?string, + * first?: ?string, + * last?: ?string, + * count?: ?int, * description?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->name = $values['name']; - $this->first = $values['first']; - $this->last = $values['last']; - $this->count = $values['count']; + $this->name = $values['name'] ?? null; + $this->first = $values['first'] ?? null; + $this->last = $values['last'] ?? null; + $this->count = $values['count'] ?? null; $this->description = $values['description'] ?? null; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return string + * @return ?string */ - public function getFirst(): string + public function getFirst(): ?string { return $this->first; } /** - * @param string $value + * @param ?string $value */ - public function setFirst(string $value): self + public function setFirst(?string $value = null): self { $this->first = $value; return $this; } /** - * @return string + * @return ?string */ - public function getLast(): string + public function getLast(): ?string { return $this->last; } /** - * @param string $value + * @param ?string $value */ - public function setLast(string $value): self + public function setLast(?string $value = null): self { $this->last = $value; return $this; } /** - * @return int + * @return ?int */ - public function getCount(): int + public function getCount(): ?int { return $this->count; } /** - * @param int $value + * @param ?int $value */ - public function setCount(int $value): self + public function setCount(?int $value = null): self { $this->count = $value; return $this; diff --git a/src/Types/DataExportCsv.php b/src/Types/DataExportCsv.php index 8edf656..a424c1e 100644 --- a/src/Types/DataExportCsv.php +++ b/src/Types/DataExportCsv.php @@ -11,10 +11,10 @@ class DataExportCsv extends JsonSerializableType { /** - * @var string $userId The user_id of the user who was sent the message. + * @var ?string $userId The user_id of the user who was sent the message. */ #[JsonProperty('user_id')] - private string $userId; + private ?string $userId; /** * @var ?string $userExternalId The external_user_id of the user who was sent the message @@ -23,46 +23,46 @@ class DataExportCsv extends JsonSerializableType private ?string $userExternalId; /** - * @var string $companyId The company ID of the user in relation to the message that was sent. Will return -1 if no company is present. + * @var ?string $companyId The company ID of the user in relation to the message that was sent. Will return -1 if no company is present. */ #[JsonProperty('company_id')] - private string $companyId; + private ?string $companyId; /** - * @var string $email The users email who was sent the message. + * @var ?string $email The users email who was sent the message. */ #[JsonProperty('email')] - private string $email; + private ?string $email; /** - * @var string $name The full name of the user receiving the message + * @var ?string $name The full name of the user receiving the message */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var string $rulesetId The id of the message. + * @var ?string $rulesetId The id of the message. */ #[JsonProperty('ruleset_id')] - private string $rulesetId; + private ?string $rulesetId; /** - * @var string $contentId The specific content that was received. In an A/B test each version has its own Content ID. + * @var ?string $contentId The specific content that was received. In an A/B test each version has its own Content ID. */ #[JsonProperty('content_id')] - private string $contentId; + private ?string $contentId; /** - * @var string $contentType Email, Chat, Post etc. + * @var ?string $contentType Email, Chat, Post etc. */ #[JsonProperty('content_type')] - private string $contentType; + private ?string $contentType; /** - * @var string $contentTitle The title of the content you see in your Intercom workspace. + * @var ?string $contentTitle The title of the content you see in your Intercom workspace. */ #[JsonProperty('content_title')] - private string $contentTitle; + private ?string $contentTitle; /** * @var ?string $rulesetVersionId As you edit content we record new versions. This ID can help you determine which version of a piece of content that was received. @@ -168,15 +168,15 @@ class DataExportCsv extends JsonSerializableType /** * @param array{ - * userId: string, - * companyId: string, - * email: string, - * name: string, - * rulesetId: string, - * contentId: string, - * contentType: string, - * contentTitle: string, + * userId?: ?string, * userExternalId?: ?string, + * companyId?: ?string, + * email?: ?string, + * name?: ?string, + * rulesetId?: ?string, + * contentId?: ?string, + * contentType?: ?string, + * contentTitle?: ?string, * rulesetVersionId?: ?string, * receiptId?: ?string, * receivedAt?: ?int, @@ -197,17 +197,17 @@ class DataExportCsv extends JsonSerializableType * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->userId = $values['userId']; + $this->userId = $values['userId'] ?? null; $this->userExternalId = $values['userExternalId'] ?? null; - $this->companyId = $values['companyId']; - $this->email = $values['email']; - $this->name = $values['name']; - $this->rulesetId = $values['rulesetId']; - $this->contentId = $values['contentId']; - $this->contentType = $values['contentType']; - $this->contentTitle = $values['contentTitle']; + $this->companyId = $values['companyId'] ?? null; + $this->email = $values['email'] ?? null; + $this->name = $values['name'] ?? null; + $this->rulesetId = $values['rulesetId'] ?? null; + $this->contentId = $values['contentId'] ?? null; + $this->contentType = $values['contentType'] ?? null; + $this->contentTitle = $values['contentTitle'] ?? null; $this->rulesetVersionId = $values['rulesetVersionId'] ?? null; $this->receiptId = $values['receiptId'] ?? null; $this->receivedAt = $values['receivedAt'] ?? null; @@ -228,17 +228,17 @@ public function __construct( } /** - * @return string + * @return ?string */ - public function getUserId(): string + public function getUserId(): ?string { return $this->userId; } /** - * @param string $value + * @param ?string $value */ - public function setUserId(string $value): self + public function setUserId(?string $value = null): self { $this->userId = $value; return $this; @@ -262,119 +262,119 @@ public function setUserExternalId(?string $value = null): self } /** - * @return string + * @return ?string */ - public function getCompanyId(): string + public function getCompanyId(): ?string { return $this->companyId; } /** - * @param string $value + * @param ?string $value */ - public function setCompanyId(string $value): self + public function setCompanyId(?string $value = null): self { $this->companyId = $value; return $this; } /** - * @return string + * @return ?string */ - public function getEmail(): string + public function getEmail(): ?string { return $this->email; } /** - * @param string $value + * @param ?string $value */ - public function setEmail(string $value): self + public function setEmail(?string $value = null): self { $this->email = $value; return $this; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return string + * @return ?string */ - public function getRulesetId(): string + public function getRulesetId(): ?string { return $this->rulesetId; } /** - * @param string $value + * @param ?string $value */ - public function setRulesetId(string $value): self + public function setRulesetId(?string $value = null): self { $this->rulesetId = $value; return $this; } /** - * @return string + * @return ?string */ - public function getContentId(): string + public function getContentId(): ?string { return $this->contentId; } /** - * @param string $value + * @param ?string $value */ - public function setContentId(string $value): self + public function setContentId(?string $value = null): self { $this->contentId = $value; return $this; } /** - * @return string + * @return ?string */ - public function getContentType(): string + public function getContentType(): ?string { return $this->contentType; } /** - * @param string $value + * @param ?string $value */ - public function setContentType(string $value): self + public function setContentType(?string $value = null): self { $this->contentType = $value; return $this; } /** - * @return string + * @return ?string */ - public function getContentTitle(): string + public function getContentTitle(): ?string { return $this->contentTitle; } /** - * @param string $value + * @param ?string $value */ - public function setContentTitle(string $value): self + public function setContentTitle(?string $value = null): self { $this->contentTitle = $value; return $this; diff --git a/src/Types/DataTableComponent.php b/src/Types/DataTableComponent.php deleted file mode 100644 index 6fc1244..0000000 --- a/src/Types/DataTableComponent.php +++ /dev/null @@ -1,55 +0,0 @@ - $items The items that will be rendered in the data-table. - */ - #[JsonProperty('items'), ArrayType([DataTableItem::class])] - private array $items; - - /** - * @param array{ - * items: array, - * } $values - */ - public function __construct( - array $values, - ) { - $this->items = $values['items']; - } - - /** - * @return array - */ - public function getItems(): array - { - return $this->items; - } - - /** - * @param array $value - */ - public function setItems(array $value): self - { - $this->items = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/DataTableItem.php b/src/Types/DataTableItem.php deleted file mode 100644 index 1b5221c..0000000 --- a/src/Types/DataTableItem.php +++ /dev/null @@ -1,104 +0,0 @@ -type = $values['type']; - $this->field = $values['field']; - $this->value = $values['value']; - } - - /** - * @return 'field-value' - */ - public function getType(): string - { - return $this->type; - } - - /** - * @param 'field-value' $value - */ - public function setType(string $value): self - { - $this->type = $value; - return $this; - } - - /** - * @return string - */ - public function getField(): string - { - return $this->field; - } - - /** - * @param string $value - */ - public function setField(string $value): self - { - $this->field = $value; - return $this; - } - - /** - * @return string - */ - public function getValue(): string - { - return $this->value; - } - - /** - * @param string $value - */ - public function setValue(string $value): self - { - $this->value = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/DeletedArticleObject.php b/src/Types/DeletedArticleObject.php index c0e896d..e0eaac4 100644 --- a/src/Types/DeletedArticleObject.php +++ b/src/Types/DeletedArticleObject.php @@ -11,84 +11,84 @@ class DeletedArticleObject extends JsonSerializableType { /** - * @var string $id The unique identifier for the article which you provided in the URL. + * @var ?string $id The unique identifier for the article which you provided in the URL. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var 'article' $object The type of object which was deleted. - article + * @var ?'article' $object The type of object which was deleted. - article */ #[JsonProperty('object')] - private string $object; + private ?string $object; /** - * @var bool $deleted Whether the article was deleted successfully or not. + * @var ?bool $deleted Whether the article was deleted successfully or not. */ #[JsonProperty('deleted')] - private bool $deleted; + private ?bool $deleted; /** * @param array{ - * id: string, - * object: 'article', - * deleted: bool, + * id?: ?string, + * object?: ?'article', + * deleted?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->id = $values['id']; - $this->object = $values['object']; - $this->deleted = $values['deleted']; + $this->id = $values['id'] ?? null; + $this->object = $values['object'] ?? null; + $this->deleted = $values['deleted'] ?? null; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return 'article' + * @return ?'article' */ - public function getObject(): string + public function getObject(): ?string { return $this->object; } /** - * @param 'article' $value + * @param ?'article' $value */ - public function setObject(string $value): self + public function setObject(?string $value = null): self { $this->object = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getDeleted(): bool + public function getDeleted(): ?bool { return $this->deleted; } /** - * @param bool $value + * @param ?bool $value */ - public function setDeleted(bool $value): self + public function setDeleted(?bool $value = null): self { $this->deleted = $value; return $this; diff --git a/src/Types/DeletedCollectionObject.php b/src/Types/DeletedCollectionObject.php index 7dd2b84..2c538a7 100644 --- a/src/Types/DeletedCollectionObject.php +++ b/src/Types/DeletedCollectionObject.php @@ -11,84 +11,84 @@ class DeletedCollectionObject extends JsonSerializableType { /** - * @var string $id The unique identifier for the collection which you provided in the URL. + * @var ?string $id The unique identifier for the collection which you provided in the URL. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var 'collection' $object The type of object which was deleted. - `collection` + * @var ?'collection' $object The type of object which was deleted. - `collection` */ #[JsonProperty('object')] - private string $object; + private ?string $object; /** - * @var bool $deleted Whether the collection was deleted successfully or not. + * @var ?bool $deleted Whether the collection was deleted successfully or not. */ #[JsonProperty('deleted')] - private bool $deleted; + private ?bool $deleted; /** * @param array{ - * id: string, - * object: 'collection', - * deleted: bool, + * id?: ?string, + * object?: ?'collection', + * deleted?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->id = $values['id']; - $this->object = $values['object']; - $this->deleted = $values['deleted']; + $this->id = $values['id'] ?? null; + $this->object = $values['object'] ?? null; + $this->deleted = $values['deleted'] ?? null; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return 'collection' + * @return ?'collection' */ - public function getObject(): string + public function getObject(): ?string { return $this->object; } /** - * @param 'collection' $value + * @param ?'collection' $value */ - public function setObject(string $value): self + public function setObject(?string $value = null): self { $this->object = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getDeleted(): bool + public function getDeleted(): ?bool { return $this->deleted; } /** - * @param bool $value + * @param ?bool $value */ - public function setDeleted(bool $value): self + public function setDeleted(?bool $value = null): self { $this->deleted = $value; return $this; diff --git a/src/Types/DeletedCompanyObject.php b/src/Types/DeletedCompanyObject.php index b22524d..adfc262 100644 --- a/src/Types/DeletedCompanyObject.php +++ b/src/Types/DeletedCompanyObject.php @@ -11,84 +11,84 @@ class DeletedCompanyObject extends JsonSerializableType { /** - * @var string $id The unique identifier for the company which is given by Intercom. + * @var ?string $id The unique identifier for the company which is given by Intercom. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var 'company' $object The type of object which was deleted. - `company` + * @var ?'company' $object The type of object which was deleted. - `company` */ #[JsonProperty('object')] - private string $object; + private ?string $object; /** - * @var bool $deleted Whether the company was deleted successfully or not. + * @var ?bool $deleted Whether the company was deleted successfully or not. */ #[JsonProperty('deleted')] - private bool $deleted; + private ?bool $deleted; /** * @param array{ - * id: string, - * object: 'company', - * deleted: bool, + * id?: ?string, + * object?: ?'company', + * deleted?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->id = $values['id']; - $this->object = $values['object']; - $this->deleted = $values['deleted']; + $this->id = $values['id'] ?? null; + $this->object = $values['object'] ?? null; + $this->deleted = $values['deleted'] ?? null; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return 'company' + * @return ?'company' */ - public function getObject(): string + public function getObject(): ?string { return $this->object; } /** - * @param 'company' $value + * @param ?'company' $value */ - public function setObject(string $value): self + public function setObject(?string $value = null): self { $this->object = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getDeleted(): bool + public function getDeleted(): ?bool { return $this->deleted; } /** - * @param bool $value + * @param ?bool $value */ - public function setDeleted(bool $value): self + public function setDeleted(?bool $value = null): self { $this->deleted = $value; return $this; diff --git a/src/Types/DeletedInternalArticleObject.php b/src/Types/DeletedInternalArticleObject.php new file mode 100644 index 0000000..18e0cf2 --- /dev/null +++ b/src/Types/DeletedInternalArticleObject.php @@ -0,0 +1,104 @@ +id = $values['id'] ?? null; + $this->object = $values['object'] ?? null; + $this->deleted = $values['deleted'] ?? null; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?'internal_article' + */ + public function getObject(): ?string + { + return $this->object; + } + + /** + * @param ?'internal_article' $value + */ + public function setObject(?string $value = null): self + { + $this->object = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getDeleted(): ?bool + { + return $this->deleted; + } + + /** + * @param ?bool $value + */ + public function setDeleted(?bool $value = null): self + { + $this->deleted = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/DeletedObject.php b/src/Types/DeletedObject.php index 1faa504..7e69b70 100644 --- a/src/Types/DeletedObject.php +++ b/src/Types/DeletedObject.php @@ -11,84 +11,84 @@ class DeletedObject extends JsonSerializableType { /** - * @var string $id The unique identifier for the news item which you provided in the URL. + * @var ?string $id The unique identifier for the news item which you provided in the URL. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var 'news-item' $object The type of object which was deleted - news-item. + * @var ?'news-item' $object The type of object which was deleted - news-item. */ #[JsonProperty('object')] - private string $object; + private ?string $object; /** - * @var bool $deleted Whether the news item was deleted successfully or not. + * @var ?bool $deleted Whether the news item was deleted successfully or not. */ #[JsonProperty('deleted')] - private bool $deleted; + private ?bool $deleted; /** * @param array{ - * id: string, - * object: 'news-item', - * deleted: bool, + * id?: ?string, + * object?: ?'news-item', + * deleted?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->id = $values['id']; - $this->object = $values['object']; - $this->deleted = $values['deleted']; + $this->id = $values['id'] ?? null; + $this->object = $values['object'] ?? null; + $this->deleted = $values['deleted'] ?? null; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return 'news-item' + * @return ?'news-item' */ - public function getObject(): string + public function getObject(): ?string { return $this->object; } /** - * @param 'news-item' $value + * @param ?'news-item' $value */ - public function setObject(string $value): self + public function setObject(?string $value = null): self { $this->object = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getDeleted(): bool + public function getDeleted(): ?bool { return $this->deleted; } /** - * @param bool $value + * @param ?bool $value */ - public function setDeleted(bool $value): self + public function setDeleted(?bool $value = null): self { $this->deleted = $value; return $this; diff --git a/src/Types/DropdownComponent.php b/src/Types/DropdownComponent.php deleted file mode 100644 index 061c327..0000000 --- a/src/Types/DropdownComponent.php +++ /dev/null @@ -1,182 +0,0 @@ - $options The list of options. Can provide 2 to 10. - */ - #[JsonProperty('options'), ArrayType([DropdownOption::class])] - private array $options; - - /** - * @var ?string $label The text shown above the dropdown. - */ - #[JsonProperty('label')] - private ?string $label; - - /** - * @var ?string $value The option that is selected by default. - */ - #[JsonProperty('value')] - private ?string $value; - - /** - * @var ?value-of $saveState Styles all options and prevents the action. Default is `unsaved`. Will be overridden if `save_state` is `saved`. - */ - #[JsonProperty('save_state')] - private ?string $saveState; - - /** - * @var ?bool $disabled Styles all options and prevents the action. Default is false. Will be overridden if save_state is saved. - */ - #[JsonProperty('disabled')] - private ?bool $disabled; - - /** - * @param array{ - * id: string, - * options: array, - * label?: ?string, - * value?: ?string, - * saveState?: ?value-of, - * disabled?: ?bool, - * } $values - */ - public function __construct( - array $values, - ) { - $this->id = $values['id']; - $this->options = $values['options']; - $this->label = $values['label'] ?? null; - $this->value = $values['value'] ?? null; - $this->saveState = $values['saveState'] ?? null; - $this->disabled = $values['disabled'] ?? null; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return array - */ - public function getOptions(): array - { - return $this->options; - } - - /** - * @param array $value - */ - public function setOptions(array $value): self - { - $this->options = $value; - return $this; - } - - /** - * @return ?string - */ - public function getLabel(): ?string - { - return $this->label; - } - - /** - * @param ?string $value - */ - public function setLabel(?string $value = null): self - { - $this->label = $value; - return $this; - } - - /** - * @return ?string - */ - public function getValue(): ?string - { - return $this->value; - } - - /** - * @param ?string $value - */ - public function setValue(?string $value = null): self - { - $this->value = $value; - return $this; - } - - /** - * @return ?value-of - */ - public function getSaveState(): ?string - { - return $this->saveState; - } - - /** - * @param ?value-of $value - */ - public function setSaveState(?string $value = null): self - { - $this->saveState = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getDisabled(): ?bool - { - return $this->disabled; - } - - /** - * @param ?bool $value - */ - public function setDisabled(?bool $value = null): self - { - $this->disabled = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/DropdownComponentSaveState.php b/src/Types/DropdownComponentSaveState.php deleted file mode 100644 index 542de8d..0000000 --- a/src/Types/DropdownComponentSaveState.php +++ /dev/null @@ -1,10 +0,0 @@ -type = $values['type']; - $this->id = $values['id']; - $this->text = $values['text']; - $this->disabled = $values['disabled'] ?? null; - } - - /** - * @return 'option' - */ - public function getType(): string - { - return $this->type; - } - - /** - * @param 'option' $value - */ - public function setType(string $value): self - { - $this->type = $value; - return $this; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return string - */ - public function getText(): string - { - return $this->text; - } - - /** - * @param string $value - */ - public function setText(string $value): self - { - $this->text = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getDisabled(): ?bool - { - return $this->disabled; - } - - /** - * @param ?bool $value - */ - public function setDisabled(?bool $value = null): self - { - $this->disabled = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/EmailAddressHeader.php b/src/Types/EmailAddressHeader.php new file mode 100644 index 0000000..935375b --- /dev/null +++ b/src/Types/EmailAddressHeader.php @@ -0,0 +1,104 @@ +type = $values['type'] ?? null; + $this->emailAddress = $values['emailAddress'] ?? null; + $this->name = $values['name'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getEmailAddress(): ?string + { + return $this->emailAddress; + } + + /** + * @param ?string $value + */ + public function setEmailAddress(?string $value = null): self + { + $this->emailAddress = $value; + return $this; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/EmailMessageMetadata.php b/src/Types/EmailMessageMetadata.php new file mode 100644 index 0000000..3db79e5 --- /dev/null +++ b/src/Types/EmailMessageMetadata.php @@ -0,0 +1,80 @@ + $emailAddressHeaders A list of an email address headers. + */ + #[JsonProperty('email_address_headers'), ArrayType([EmailAddressHeader::class])] + private ?array $emailAddressHeaders; + + /** + * @param array{ + * subject?: ?string, + * emailAddressHeaders?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->subject = $values['subject'] ?? null; + $this->emailAddressHeaders = $values['emailAddressHeaders'] ?? null; + } + + /** + * @return ?string + */ + public function getSubject(): ?string + { + return $this->subject; + } + + /** + * @param ?string $value + */ + public function setSubject(?string $value = null): self + { + $this->subject = $value; + return $this; + } + + /** + * @return ?array + */ + public function getEmailAddressHeaders(): ?array + { + return $this->emailAddressHeaders; + } + + /** + * @param ?array $value + */ + public function setEmailAddressHeaders(?array $value = null): self + { + $this->emailAddressHeaders = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/Event.php b/src/Types/Event.php deleted file mode 100644 index e9b90fa..0000000 --- a/src/Types/Event.php +++ /dev/null @@ -1,54 +0,0 @@ -type = $values['type']; - } - - /** - * @return 'completed' - */ - public function getType(): string - { - return $this->type; - } - - /** - * @param 'completed' $value - */ - public function setType(string $value): self - { - $this->type = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/FileAttribute.php b/src/Types/FileAttribute.php index 60ed961..7886256 100644 --- a/src/Types/FileAttribute.php +++ b/src/Types/FileAttribute.php @@ -11,184 +11,184 @@ class FileAttribute extends JsonSerializableType { /** - * @var string $type + * @var ?string $type */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $name The name of the file + * @var ?string $name The name of the file */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var string $url The url of the file. This is a temporary URL and will expire after 30 minutes. + * @var ?string $url The url of the file. This is a temporary URL and will expire after 30 minutes. */ #[JsonProperty('url')] - private string $url; + private ?string $url; /** - * @var string $contentType The type of file + * @var ?string $contentType The type of file */ #[JsonProperty('content_type')] - private string $contentType; + private ?string $contentType; /** - * @var int $filesize The size of the file in bytes + * @var ?int $filesize The size of the file in bytes */ #[JsonProperty('filesize')] - private int $filesize; + private ?int $filesize; /** - * @var int $width The width of the file in pixels, if applicable + * @var ?int $width The width of the file in pixels, if applicable */ #[JsonProperty('width')] - private int $width; + private ?int $width; /** - * @var int $height The height of the file in pixels, if applicable + * @var ?int $height The height of the file in pixels, if applicable */ #[JsonProperty('height')] - private int $height; + private ?int $height; /** * @param array{ - * type: string, - * name: string, - * url: string, - * contentType: string, - * filesize: int, - * width: int, - * height: int, + * type?: ?string, + * name?: ?string, + * url?: ?string, + * contentType?: ?string, + * filesize?: ?int, + * width?: ?int, + * height?: ?int, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->name = $values['name']; - $this->url = $values['url']; - $this->contentType = $values['contentType']; - $this->filesize = $values['filesize']; - $this->width = $values['width']; - $this->height = $values['height']; + $this->type = $values['type'] ?? null; + $this->name = $values['name'] ?? null; + $this->url = $values['url'] ?? null; + $this->contentType = $values['contentType'] ?? null; + $this->filesize = $values['filesize'] ?? null; + $this->width = $values['width'] ?? null; + $this->height = $values['height'] ?? null; } /** - * @return string + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param string $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return string + * @return ?string */ - public function getUrl(): string + public function getUrl(): ?string { return $this->url; } /** - * @param string $value + * @param ?string $value */ - public function setUrl(string $value): self + public function setUrl(?string $value = null): self { $this->url = $value; return $this; } /** - * @return string + * @return ?string */ - public function getContentType(): string + public function getContentType(): ?string { return $this->contentType; } /** - * @param string $value + * @param ?string $value */ - public function setContentType(string $value): self + public function setContentType(?string $value = null): self { $this->contentType = $value; return $this; } /** - * @return int + * @return ?int */ - public function getFilesize(): int + public function getFilesize(): ?int { return $this->filesize; } /** - * @param int $value + * @param ?int $value */ - public function setFilesize(int $value): self + public function setFilesize(?int $value = null): self { $this->filesize = $value; return $this; } /** - * @return int + * @return ?int */ - public function getWidth(): int + public function getWidth(): ?int { return $this->width; } /** - * @param int $value + * @param ?int $value */ - public function setWidth(int $value): self + public function setWidth(?int $value = null): self { $this->width = $value; return $this; } /** - * @return int + * @return ?int */ - public function getHeight(): int + public function getHeight(): ?int { return $this->height; } /** - * @param int $value + * @param ?int $value */ - public function setHeight(int $value): self + public function setHeight(?int $value = null): self { $this->height = $value; return $this; diff --git a/src/Types/GroupContent.php b/src/Types/GroupContent.php index 52f43d6..813cd93 100644 --- a/src/Types/GroupContent.php +++ b/src/Types/GroupContent.php @@ -11,84 +11,84 @@ class GroupContent extends JsonSerializableType { /** - * @var 'group_content' $type The type of object - `group_content` . + * @var ?string $type The type of object - `group_content` . */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $name The name of the collection or section. + * @var ?string $name The name of the collection or section. */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var string $description The description of the collection. Only available for collections. + * @var ?string $description The description of the collection. Only available for collections. */ #[JsonProperty('description')] - private string $description; + private ?string $description; /** * @param array{ - * type: 'group_content', - * name: string, - * description: string, + * type?: ?string, + * name?: ?string, + * description?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->name = $values['name']; - $this->description = $values['description']; + $this->type = $values['type'] ?? null; + $this->name = $values['name'] ?? null; + $this->description = $values['description'] ?? null; } /** - * @return 'group_content' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'group_content' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return string + * @return ?string */ - public function getDescription(): string + public function getDescription(): ?string { return $this->description; } /** - * @param string $value + * @param ?string $value */ - public function setDescription(string $value): self + public function setDescription(?string $value = null): self { $this->description = $value; return $this; diff --git a/src/Types/GroupTranslatedContent.php b/src/Types/GroupTranslatedContent.php index 77b3be4..bb92109 100644 --- a/src/Types/GroupTranslatedContent.php +++ b/src/Types/GroupTranslatedContent.php @@ -11,10 +11,10 @@ class GroupTranslatedContent extends JsonSerializableType { /** - * @var 'group_translated_content' $type The type of object - group_translated_content. + * @var ?string $type The type of object - group_translated_content. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** * @var ?GroupContent $ar The content of the group in Arabic @@ -240,7 +240,7 @@ class GroupTranslatedContent extends JsonSerializableType /** * @param array{ - * type: 'group_translated_content', + * type?: ?string, * ar?: ?GroupContent, * bg?: ?GroupContent, * bs?: ?GroupContent, @@ -281,9 +281,9 @@ class GroupTranslatedContent extends JsonSerializableType * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; + $this->type = $values['type'] ?? null; $this->ar = $values['ar'] ?? null; $this->bg = $values['bg'] ?? null; $this->bs = $values['bs'] ?? null; @@ -324,17 +324,17 @@ public function __construct( } /** - * @return 'group_translated_content' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'group_translated_content' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; diff --git a/src/Types/ImageComponent.php b/src/Types/ImageComponent.php deleted file mode 100644 index 49b6470..0000000 --- a/src/Types/ImageComponent.php +++ /dev/null @@ -1,232 +0,0 @@ - $align Aligns the image inside the component. Default is `left`. - */ - #[JsonProperty('align')] - private ?string $align; - - /** - * @var int $width The exact width of the image in pixels. - */ - #[JsonProperty('width')] - private int $width; - - /** - * @var int $height The exact height of the image in pixels. - */ - #[JsonProperty('height')] - private int $height; - - /** - * @var ?bool $rounded Rounds the corners of the image. Default is `false`. - */ - #[JsonProperty('rounded')] - private ?bool $rounded; - - /** - * @var ?'none' $bottomMargin Disables a component's margin-bottom of 10px. - */ - #[JsonProperty('bottom_margin')] - private ?string $bottomMargin; - - /** - * @var ?UrlActionComponent $action This can be a URL Action only. - */ - #[JsonProperty('action')] - private ?UrlActionComponent $action; - - /** - * @param array{ - * url: string, - * width: int, - * height: int, - * id?: ?string, - * align?: ?value-of, - * rounded?: ?bool, - * bottomMargin?: ?'none', - * action?: ?UrlActionComponent, - * } $values - */ - public function __construct( - array $values, - ) { - $this->id = $values['id'] ?? null; - $this->url = $values['url']; - $this->align = $values['align'] ?? null; - $this->width = $values['width']; - $this->height = $values['height']; - $this->rounded = $values['rounded'] ?? null; - $this->bottomMargin = $values['bottomMargin'] ?? null; - $this->action = $values['action'] ?? null; - } - - /** - * @return ?string - */ - public function getId(): ?string - { - return $this->id; - } - - /** - * @param ?string $value - */ - public function setId(?string $value = null): self - { - $this->id = $value; - return $this; - } - - /** - * @return string - */ - public function getUrl(): string - { - return $this->url; - } - - /** - * @param string $value - */ - public function setUrl(string $value): self - { - $this->url = $value; - return $this; - } - - /** - * @return ?value-of - */ - public function getAlign(): ?string - { - return $this->align; - } - - /** - * @param ?value-of $value - */ - public function setAlign(?string $value = null): self - { - $this->align = $value; - return $this; - } - - /** - * @return int - */ - public function getWidth(): int - { - return $this->width; - } - - /** - * @param int $value - */ - public function setWidth(int $value): self - { - $this->width = $value; - return $this; - } - - /** - * @return int - */ - public function getHeight(): int - { - return $this->height; - } - - /** - * @param int $value - */ - public function setHeight(int $value): self - { - $this->height = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getRounded(): ?bool - { - return $this->rounded; - } - - /** - * @param ?bool $value - */ - public function setRounded(?bool $value = null): self - { - $this->rounded = $value; - return $this; - } - - /** - * @return ?'none' - */ - public function getBottomMargin(): ?string - { - return $this->bottomMargin; - } - - /** - * @param ?'none' $value - */ - public function setBottomMargin(?string $value = null): self - { - $this->bottomMargin = $value; - return $this; - } - - /** - * @return ?UrlActionComponent - */ - public function getAction(): ?UrlActionComponent - { - return $this->action; - } - - /** - * @param ?UrlActionComponent $value - */ - public function setAction(?UrlActionComponent $value = null): self - { - $this->action = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/ImageComponentAlign.php b/src/Types/ImageComponentAlign.php deleted file mode 100644 index 359ca12..0000000 --- a/src/Types/ImageComponentAlign.php +++ /dev/null @@ -1,11 +0,0 @@ - $cardCreationOptions Key-value pairs which were given as results in response to the Configure request. - */ - #[JsonProperty('card_creation_options'), ArrayType(['string' => 'mixed'])] - private array $cardCreationOptions; - - /** - * @var Context $context The context of where the app is added, where the user last visited, and information on the Messenger settings. - */ - #[JsonProperty('context')] - private Context $context; - - /** - * @var Conversation $conversation The conversation your app is being shown for. - */ - #[JsonProperty('conversation')] - private Conversation $conversation; - - /** - * @var Contact $contact The contact which is currently being viewed by the teammate in the conversation details panel. We send an individual initialize request for each customer when it's a group conversation. - */ - #[JsonProperty('contact')] - private Contact $contact; - - /** - * @param array{ - * workspaceId: string, - * workspaceRegion: string, - * admin: Admin, - * cardCreationOptions: array, - * context: Context, - * conversation: Conversation, - * contact: Contact, - * } $values - */ - public function __construct( - array $values, - ) { - $this->workspaceId = $values['workspaceId']; - $this->workspaceRegion = $values['workspaceRegion']; - $this->admin = $values['admin']; - $this->cardCreationOptions = $values['cardCreationOptions']; - $this->context = $values['context']; - $this->conversation = $values['conversation']; - $this->contact = $values['contact']; - } - - /** - * @return string - */ - public function getWorkspaceId(): string - { - return $this->workspaceId; - } - - /** - * @param string $value - */ - public function setWorkspaceId(string $value): self - { - $this->workspaceId = $value; - return $this; - } - - /** - * @return string - */ - public function getWorkspaceRegion(): string - { - return $this->workspaceRegion; - } - - /** - * @param string $value - */ - public function setWorkspaceRegion(string $value): self - { - $this->workspaceRegion = $value; - return $this; - } - - /** - * @return Admin - */ - public function getAdmin(): Admin - { - return $this->admin; - } - - /** - * @param Admin $value - */ - public function setAdmin(Admin $value): self - { - $this->admin = $value; - return $this; - } - - /** - * @return array - */ - public function getCardCreationOptions(): array - { - return $this->cardCreationOptions; - } - - /** - * @param array $value - */ - public function setCardCreationOptions(array $value): self - { - $this->cardCreationOptions = $value; - return $this; - } - - /** - * @return Context - */ - public function getContext(): Context - { - return $this->context; - } - - /** - * @param Context $value - */ - public function setContext(Context $value): self - { - $this->context = $value; - return $this; - } - - /** - * @return Conversation - */ - public function getConversation(): Conversation - { - return $this->conversation; - } - - /** - * @param Conversation $value - */ - public function setConversation(Conversation $value): self - { - $this->conversation = $value; - return $this; - } - - /** - * @return Contact - */ - public function getContact(): Contact - { - return $this->contact; - } - - /** - * @param Contact $value - */ - public function setContact(Contact $value): self - { - $this->contact = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/InitializeResponse.php b/src/Types/InitializeResponse.php deleted file mode 100644 index 51be89a..0000000 --- a/src/Types/InitializeResponse.php +++ /dev/null @@ -1,54 +0,0 @@ -canvas = $values['canvas']; - } - - /** - * @return CanvasObject - */ - public function getCanvas(): CanvasObject - { - return $this->canvas; - } - - /** - * @param CanvasObject $value - */ - public function setCanvas(CanvasObject $value): self - { - $this->canvas = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/InputComponent.php b/src/Types/InputComponent.php deleted file mode 100644 index 3559951..0000000 --- a/src/Types/InputComponent.php +++ /dev/null @@ -1,207 +0,0 @@ - $saveState Styles the input. Default is `unsaved`. Prevent action with `saved`. - */ - #[JsonProperty('save_state')] - private ?string $saveState; - - /** - * @var ?bool $disabled Styles the input and prevents the action. Default is false. Will be overridden if save_state is saved. - */ - #[JsonProperty('disabled')] - private ?bool $disabled; - - /** - * @param array{ - * id: string, - * label?: ?string, - * placeholder?: ?string, - * value?: ?string, - * action?: ?ActionComponent, - * saveState?: ?value-of, - * disabled?: ?bool, - * } $values - */ - public function __construct( - array $values, - ) { - $this->id = $values['id']; - $this->label = $values['label'] ?? null; - $this->placeholder = $values['placeholder'] ?? null; - $this->value = $values['value'] ?? null; - $this->action = $values['action'] ?? null; - $this->saveState = $values['saveState'] ?? null; - $this->disabled = $values['disabled'] ?? null; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return ?string - */ - public function getLabel(): ?string - { - return $this->label; - } - - /** - * @param ?string $value - */ - public function setLabel(?string $value = null): self - { - $this->label = $value; - return $this; - } - - /** - * @return ?string - */ - public function getPlaceholder(): ?string - { - return $this->placeholder; - } - - /** - * @param ?string $value - */ - public function setPlaceholder(?string $value = null): self - { - $this->placeholder = $value; - return $this; - } - - /** - * @return ?string - */ - public function getValue(): ?string - { - return $this->value; - } - - /** - * @param ?string $value - */ - public function setValue(?string $value = null): self - { - $this->value = $value; - return $this; - } - - /** - * @return ?ActionComponent - */ - public function getAction(): ?ActionComponent - { - return $this->action; - } - - /** - * @param ?ActionComponent $value - */ - public function setAction(?ActionComponent $value = null): self - { - $this->action = $value; - return $this; - } - - /** - * @return ?value-of - */ - public function getSaveState(): ?string - { - return $this->saveState; - } - - /** - * @param ?value-of $value - */ - public function setSaveState(?string $value = null): self - { - $this->saveState = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getDisabled(): ?bool - { - return $this->disabled; - } - - /** - * @param ?bool $value - */ - public function setDisabled(?bool $value = null): self - { - $this->disabled = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/InputComponentSaveState.php b/src/Types/InputComponentSaveState.php deleted file mode 100644 index c1075be..0000000 --- a/src/Types/InputComponentSaveState.php +++ /dev/null @@ -1,10 +0,0 @@ - $data An array of Internal Article objects + */ + #[JsonProperty('data'), ArrayType([InternalArticleListItem::class])] + private ?array $data; + + /** + * @param array{ + * type?: ?'list', + * pages?: ?CursorPages, + * totalCount?: ?int, + * data?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->pages = $values['pages'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return ?'list' + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?'list' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?CursorPages + */ + public function getPages(): ?CursorPages + { + return $this->pages; + } + + /** + * @param ?CursorPages $value + */ + public function setPages(?CursorPages $value = null): self + { + $this->pages = $value; + return $this; + } + + /** + * @return ?int + */ + public function getTotalCount(): ?int + { + return $this->totalCount; + } + + /** + * @param ?int $value + */ + public function setTotalCount(?int $value = null): self + { + $this->totalCount = $value; + return $this; + } + + /** + * @return ?array + */ + public function getData(): ?array + { + return $this->data; + } + + /** + * @param ?array $value + */ + public function setData(?array $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/LinkedObject.php b/src/Types/LinkedObject.php index 2d491f0..4fe6de8 100644 --- a/src/Types/LinkedObject.php +++ b/src/Types/LinkedObject.php @@ -11,16 +11,16 @@ class LinkedObject extends JsonSerializableType { /** - * @var value-of $type ticket or conversation + * @var ?value-of $type ticket or conversation */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The ID of the linked object + * @var ?string $id The ID of the linked object */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** * @var ?string $category Category of the Linked Ticket Object. @@ -30,48 +30,48 @@ class LinkedObject extends JsonSerializableType /** * @param array{ - * type: value-of, - * id: string, + * type?: ?value-of, + * id?: ?string, * category?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; $this->category = $values['category'] ?? null; } /** - * @return value-of + * @return ?value-of */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; diff --git a/src/Types/LinkedObjectList.php b/src/Types/LinkedObjectList.php index 3ccf6e8..4c7b668 100644 --- a/src/Types/LinkedObjectList.php +++ b/src/Types/LinkedObjectList.php @@ -12,109 +12,109 @@ class LinkedObjectList extends JsonSerializableType { /** - * @var 'list' $type Always list. + * @var ?'list' $type Always list. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var int $totalCount The total number of linked objects. + * @var ?int $totalCount The total number of linked objects. */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** - * @var bool $hasMore Whether or not there are more linked objects than returned. + * @var ?bool $hasMore Whether or not there are more linked objects than returned. */ #[JsonProperty('has_more')] - private bool $hasMore; + private ?bool $hasMore; /** - * @var array $data An array containing the linked conversations and linked tickets. + * @var ?array $data An array containing the linked conversations and linked tickets. */ #[JsonProperty('data'), ArrayType([LinkedObject::class])] - private array $data; + private ?array $data; /** * @param array{ - * type: 'list', - * totalCount: int, - * hasMore: bool, - * data: array, + * type?: ?'list', + * totalCount?: ?int, + * hasMore?: ?bool, + * data?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->totalCount = $values['totalCount']; - $this->hasMore = $values['hasMore']; - $this->data = $values['data']; + $this->type = $values['type'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->hasMore = $values['hasMore'] ?? null; + $this->data = $values['data'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getHasMore(): bool + public function getHasMore(): ?bool { return $this->hasMore; } /** - * @param bool $value + * @param ?bool $value */ - public function setHasMore(bool $value): self + public function setHasMore(?bool $value = null): self { $this->hasMore = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; diff --git a/src/Types/ListComponent.php b/src/Types/ListComponent.php deleted file mode 100644 index 66bb35d..0000000 --- a/src/Types/ListComponent.php +++ /dev/null @@ -1,97 +0,0 @@ - $items The items that will be rendered in the list. - */ - #[JsonProperty('items'), ArrayType([new Union(ListItemWithImage::class, ListItemWithoutImage::class)])] - private array $items; - - /** - * @var ?bool $disabled Styles all list items and prevents the action. Default is `false`. - */ - #[JsonProperty('disabled')] - private ?bool $disabled; - - /** - * @param array{ - * items: array<( - * ListItemWithImage - * |ListItemWithoutImage - * )>, - * disabled?: ?bool, - * } $values - */ - public function __construct( - array $values, - ) { - $this->items = $values['items']; - $this->disabled = $values['disabled'] ?? null; - } - - /** - * @return array<( - * ListItemWithImage - * |ListItemWithoutImage - * )> - */ - public function getItems(): array - { - return $this->items; - } - - /** - * @param array<( - * ListItemWithImage - * |ListItemWithoutImage - * )> $value - */ - public function setItems(array $value): self - { - $this->items = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getDisabled(): ?bool - { - return $this->disabled; - } - - /** - * @param ?bool $value - */ - public function setDisabled(?bool $value = null): self - { - $this->disabled = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/ListItem.php b/src/Types/ListItem.php deleted file mode 100644 index e3e9d8f..0000000 --- a/src/Types/ListItem.php +++ /dev/null @@ -1,229 +0,0 @@ -type = $values['type']; - $this->id = $values['id']; - $this->title = $values['title']; - $this->subtitle = $values['subtitle'] ?? null; - $this->tertiaryText = $values['tertiaryText'] ?? null; - $this->roundedImage = $values['roundedImage'] ?? null; - $this->disabled = $values['disabled'] ?? null; - $this->action = $values['action'] ?? null; - } - - /** - * @return 'item' - */ - public function getType(): string - { - return $this->type; - } - - /** - * @param 'item' $value - */ - public function setType(string $value): self - { - $this->type = $value; - return $this; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return string - */ - public function getTitle(): string - { - return $this->title; - } - - /** - * @param string $value - */ - public function setTitle(string $value): self - { - $this->title = $value; - return $this; - } - - /** - * @return ?string - */ - public function getSubtitle(): ?string - { - return $this->subtitle; - } - - /** - * @param ?string $value - */ - public function setSubtitle(?string $value = null): self - { - $this->subtitle = $value; - return $this; - } - - /** - * @return ?string - */ - public function getTertiaryText(): ?string - { - return $this->tertiaryText; - } - - /** - * @param ?string $value - */ - public function setTertiaryText(?string $value = null): self - { - $this->tertiaryText = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getRoundedImage(): ?bool - { - return $this->roundedImage; - } - - /** - * @param ?bool $value - */ - public function setRoundedImage(?bool $value = null): self - { - $this->roundedImage = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getDisabled(): ?bool - { - return $this->disabled; - } - - /** - * @param ?bool $value - */ - public function setDisabled(?bool $value = null): self - { - $this->disabled = $value; - return $this; - } - - /** - * @return ?ActionComponent - */ - public function getAction(): ?ActionComponent - { - return $this->action; - } - - /** - * @param ?ActionComponent $value - */ - public function setAction(?ActionComponent $value = null): self - { - $this->action = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/ListItemWithImage.php b/src/Types/ListItemWithImage.php deleted file mode 100644 index 09e4a26..0000000 --- a/src/Types/ListItemWithImage.php +++ /dev/null @@ -1,120 +0,0 @@ -type = $values['type']; - $this->id = $values['id']; - $this->title = $values['title']; - $this->subtitle = $values['subtitle'] ?? null; - $this->tertiaryText = $values['tertiaryText'] ?? null; - $this->roundedImage = $values['roundedImage'] ?? null; - $this->disabled = $values['disabled'] ?? null; - $this->action = $values['action'] ?? null; - $this->image = $values['image']; - $this->imageWidth = $values['imageWidth']; - $this->imageHeight = $values['imageHeight']; - } - - /** - * @return string - */ - public function getImage(): string - { - return $this->image; - } - - /** - * @param string $value - */ - public function setImage(string $value): self - { - $this->image = $value; - return $this; - } - - /** - * @return int - */ - public function getImageWidth(): int - { - return $this->imageWidth; - } - - /** - * @param int $value - */ - public function setImageWidth(int $value): self - { - $this->imageWidth = $value; - return $this; - } - - /** - * @return int - */ - public function getImageHeight(): int - { - return $this->imageHeight; - } - - /** - * @param int $value - */ - public function setImageHeight(int $value): self - { - $this->imageHeight = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/ListItemWithoutImage.php b/src/Types/ListItemWithoutImage.php deleted file mode 100644 index 5d65475..0000000 --- a/src/Types/ListItemWithoutImage.php +++ /dev/null @@ -1,120 +0,0 @@ -type = $values['type']; - $this->id = $values['id']; - $this->title = $values['title']; - $this->subtitle = $values['subtitle'] ?? null; - $this->tertiaryText = $values['tertiaryText'] ?? null; - $this->roundedImage = $values['roundedImage'] ?? null; - $this->disabled = $values['disabled'] ?? null; - $this->action = $values['action'] ?? null; - $this->image = $values['image'] ?? null; - $this->imageWidth = $values['imageWidth'] ?? null; - $this->imageHeight = $values['imageHeight'] ?? null; - } - - /** - * @return ?string - */ - public function getImage(): ?string - { - return $this->image; - } - - /** - * @param ?string $value - */ - public function setImage(?string $value = null): self - { - $this->image = $value; - return $this; - } - - /** - * @return ?int - */ - public function getImageWidth(): ?int - { - return $this->imageWidth; - } - - /** - * @param ?int $value - */ - public function setImageWidth(?int $value = null): self - { - $this->imageWidth = $value; - return $this; - } - - /** - * @return ?int - */ - public function getImageHeight(): ?int - { - return $this->imageHeight; - } - - /** - * @param ?int $value - */ - public function setImageHeight(?int $value = null): self - { - $this->imageHeight = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/LiveCanvasRequest.php b/src/Types/LiveCanvasRequest.php deleted file mode 100644 index 62b66ca..0000000 --- a/src/Types/LiveCanvasRequest.php +++ /dev/null @@ -1,157 +0,0 @@ -workspaceId = $values['workspaceId']; - $this->workspaceRegion = $values['workspaceRegion']; - $this->canvas = $values['canvas']; - $this->context = $values['context']; - $this->contact = $values['contact']; - } - - /** - * @return string - */ - public function getWorkspaceId(): string - { - return $this->workspaceId; - } - - /** - * @param string $value - */ - public function setWorkspaceId(string $value): self - { - $this->workspaceId = $value; - return $this; - } - - /** - * @return string - */ - public function getWorkspaceRegion(): string - { - return $this->workspaceRegion; - } - - /** - * @param string $value - */ - public function setWorkspaceRegion(string $value): self - { - $this->workspaceRegion = $value; - return $this; - } - - /** - * @return CanvasObject - */ - public function getCanvas(): CanvasObject - { - return $this->canvas; - } - - /** - * @param CanvasObject $value - */ - public function setCanvas(CanvasObject $value): self - { - $this->canvas = $value; - return $this; - } - - /** - * @return Context - */ - public function getContext(): Context - { - return $this->context; - } - - /** - * @param Context $value - */ - public function setContext(Context $value): self - { - $this->context = $value; - return $this; - } - - /** - * @return Contact - */ - public function getContact(): Contact - { - return $this->contact; - } - - /** - * @param Contact $value - */ - public function setContact(Contact $value): self - { - $this->contact = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/LiveCanvasResponse.php b/src/Types/LiveCanvasResponse.php deleted file mode 100644 index 8f4ed3c..0000000 --- a/src/Types/LiveCanvasResponse.php +++ /dev/null @@ -1,54 +0,0 @@ -content = $values['content']; - } - - /** - * @return ContentObject - */ - public function getContent(): ContentObject - { - return $this->content; - } - - /** - * @param ContentObject $value - */ - public function setContent(ContentObject $value): self - { - $this->content = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/MultipleFilterSearchRequest.php b/src/Types/MultipleFilterSearchRequest.php index 371a458..c215c38 100644 --- a/src/Types/MultipleFilterSearchRequest.php +++ b/src/Types/MultipleFilterSearchRequest.php @@ -4,7 +4,6 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; -use Intercom\Core\Types\ArrayType; use Intercom\Core\Types\Union; /** @@ -19,21 +18,21 @@ class MultipleFilterSearchRequest extends JsonSerializableType private ?string $operator; /** - * @var ?array<( - * MultipleFilterSearchRequest - * |SingleFilterSearchRequest - * )> $value + * @var ( + * array + * |array + * )|null $value */ - #[JsonProperty('value'), ArrayType([new Union(MultipleFilterSearchRequest::class, SingleFilterSearchRequest::class)])] - private ?array $value; + #[JsonProperty('value'), Union([MultipleFilterSearchRequest::class], [SingleFilterSearchRequest::class], 'null')] + private array|null $value; /** * @param array{ * operator?: ?value-of, - * value?: ?array<( - * MultipleFilterSearchRequest - * |SingleFilterSearchRequest - * )>, + * value?: ( + * array + * |array + * )|null, * } $values */ public function __construct( @@ -61,23 +60,23 @@ public function setOperator(?string $value = null): self } /** - * @return ?array<( - * MultipleFilterSearchRequest - * |SingleFilterSearchRequest - * )> + * @return ( + * array + * |array + * )|null */ - public function getValue(): ?array + public function getValue(): array|null { return $this->value; } /** - * @param ?array<( - * MultipleFilterSearchRequest - * |SingleFilterSearchRequest - * )> $value + * @param ( + * array + * |array + * )|null $value */ - public function setValue(?array $value = null): self + public function setValue(array|null $value = null): self { $this->value = $value; return $this; diff --git a/src/Types/NotFoundErrorBody.php b/src/Types/NotFoundErrorBody.php new file mode 100644 index 0000000..ebf251b --- /dev/null +++ b/src/Types/NotFoundErrorBody.php @@ -0,0 +1,102 @@ + $errors An array of one or more error objects + */ + #[JsonProperty('errors'), ArrayType([NotFoundErrorBodyErrorsItem::class])] + private array $errors; + + /** + * @param array{ + * type: string, + * errors: array, + * requestId?: ?string, + * } $values + */ + public function __construct( + array $values, + ) { + $this->type = $values['type']; + $this->requestId = $values['requestId'] ?? null; + $this->errors = $values['errors']; + } + + /** + * @return string + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param string $value + */ + public function setType(string $value): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getRequestId(): ?string + { + return $this->requestId; + } + + /** + * @param ?string $value + */ + public function setRequestId(?string $value = null): self + { + $this->requestId = $value; + return $this; + } + + /** + * @return array + */ + public function getErrors(): array + { + return $this->errors; + } + + /** + * @param array $value + */ + public function setErrors(array $value): self + { + $this->errors = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/NotFoundErrorBodyErrorsItem.php b/src/Types/NotFoundErrorBodyErrorsItem.php new file mode 100644 index 0000000..d5b0c5e --- /dev/null +++ b/src/Types/NotFoundErrorBodyErrorsItem.php @@ -0,0 +1,76 @@ +code = $values['code']; + $this->message = $values['message'] ?? null; + } + + /** + * @return string + */ + public function getCode(): string + { + return $this->code; + } + + /** + * @param string $value + */ + public function setCode(string $value): self + { + $this->code = $value; + return $this; + } + + /** + * @return ?string + */ + public function getMessage(): ?string + { + return $this->message; + } + + /** + * @param ?string $value + */ + public function setMessage(?string $value = null): self + { + $this->message = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/NoteList.php b/src/Types/NoteList.php index cd3456c..4f76b39 100644 --- a/src/Types/NoteList.php +++ b/src/Types/NoteList.php @@ -13,84 +13,84 @@ class NoteList extends JsonSerializableType { /** - * @var 'list' $type String representing the object's type. Always has the value `list`. + * @var ?string $type String representing the object's type. Always has the value `list`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $data An array of notes. + * @var ?array $data An array of notes. */ #[JsonProperty('data'), ArrayType([Note::class])] - private array $data; + private ?array $data; /** - * @var int $totalCount A count of the total number of notes. + * @var ?int $totalCount A count of the total number of notes. */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** * @param array{ - * type: 'list', - * data: array, - * totalCount: int, + * type?: ?string, + * data?: ?array, + * totalCount?: ?int, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->data = $values['data']; - $this->totalCount = $values['totalCount']; + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; } /** - * @return 'list' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; diff --git a/src/Types/OperatorWorkflowEvent.php b/src/Types/OperatorWorkflowEvent.php new file mode 100644 index 0000000..8590d2c --- /dev/null +++ b/src/Types/OperatorWorkflowEvent.php @@ -0,0 +1,79 @@ +operator_workflow_event. + */ +class OperatorWorkflowEvent extends JsonSerializableType +{ + /** + * @var ?OperatorWorkflowEventWorkflow $workflow + */ + #[JsonProperty('workflow')] + private ?OperatorWorkflowEventWorkflow $workflow; + + /** + * @var ?OperatorWorkflowEventEvent $event + */ + #[JsonProperty('event')] + private ?OperatorWorkflowEventEvent $event; + + /** + * @param array{ + * workflow?: ?OperatorWorkflowEventWorkflow, + * event?: ?OperatorWorkflowEventEvent, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->workflow = $values['workflow'] ?? null; + $this->event = $values['event'] ?? null; + } + + /** + * @return ?OperatorWorkflowEventWorkflow + */ + public function getWorkflow(): ?OperatorWorkflowEventWorkflow + { + return $this->workflow; + } + + /** + * @param ?OperatorWorkflowEventWorkflow $value + */ + public function setWorkflow(?OperatorWorkflowEventWorkflow $value = null): self + { + $this->workflow = $value; + return $this; + } + + /** + * @return ?OperatorWorkflowEventEvent + */ + public function getEvent(): ?OperatorWorkflowEventEvent + { + return $this->event; + } + + /** + * @param ?OperatorWorkflowEventEvent $value + */ + public function setEvent(?OperatorWorkflowEventEvent $value = null): self + { + $this->event = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/OperatorWorkflowEventEvent.php b/src/Types/OperatorWorkflowEventEvent.php new file mode 100644 index 0000000..4ebdfa2 --- /dev/null +++ b/src/Types/OperatorWorkflowEventEvent.php @@ -0,0 +1,76 @@ +type = $values['type'] ?? null; + $this->result = $values['result'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getResult(): ?string + { + return $this->result; + } + + /** + * @param ?string $value + */ + public function setResult(?string $value = null): self + { + $this->result = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/OperatorWorkflowEventWorkflow.php b/src/Types/OperatorWorkflowEventWorkflow.php new file mode 100644 index 0000000..080b2a2 --- /dev/null +++ b/src/Types/OperatorWorkflowEventWorkflow.php @@ -0,0 +1,51 @@ +name = $values['name'] ?? null; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/PagesLink.php b/src/Types/PagesLink.php index 8a5519c..e14e065 100644 --- a/src/Types/PagesLink.php +++ b/src/Types/PagesLink.php @@ -13,16 +13,16 @@ class PagesLink extends JsonSerializableType { /** - * @var 'pages' $type + * @var ?'pages' $type */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var int $page + * @var ?int $page */ #[JsonProperty('page')] - private int $page; + private ?int $page; /** * @var ?string $next A link to the next page of results. A response that does not contain a next link does not have further data to fetch. @@ -31,65 +31,65 @@ class PagesLink extends JsonSerializableType private ?string $next; /** - * @var int $perPage + * @var ?int $perPage */ #[JsonProperty('per_page')] - private int $perPage; + private ?int $perPage; /** - * @var int $totalPages + * @var ?int $totalPages */ #[JsonProperty('total_pages')] - private int $totalPages; + private ?int $totalPages; /** * @param array{ - * type: 'pages', - * page: int, - * perPage: int, - * totalPages: int, + * type?: ?'pages', + * page?: ?int, * next?: ?string, + * perPage?: ?int, + * totalPages?: ?int, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->page = $values['page']; + $this->type = $values['type'] ?? null; + $this->page = $values['page'] ?? null; $this->next = $values['next'] ?? null; - $this->perPage = $values['perPage']; - $this->totalPages = $values['totalPages']; + $this->perPage = $values['perPage'] ?? null; + $this->totalPages = $values['totalPages'] ?? null; } /** - * @return 'pages' + * @return ?'pages' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'pages' $value + * @param ?'pages' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return int + * @return ?int */ - public function getPage(): int + public function getPage(): ?int { return $this->page; } /** - * @param int $value + * @param ?int $value */ - public function setPage(int $value): self + public function setPage(?int $value = null): self { $this->page = $value; return $this; @@ -113,34 +113,34 @@ public function setNext(?string $value = null): self } /** - * @return int + * @return ?int */ - public function getPerPage(): int + public function getPerPage(): ?int { return $this->perPage; } /** - * @param int $value + * @param ?int $value */ - public function setPerPage(int $value): self + public function setPerPage(?int $value = null): self { $this->perPage = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalPages(): int + public function getTotalPages(): ?int { return $this->totalPages; } /** - * @param int $value + * @param ?int $value */ - public function setTotalPages(int $value): self + public function setTotalPages(?int $value = null): self { $this->totalPages = $value; return $this; diff --git a/src/Types/PaginatedResponse.php b/src/Types/PaginatedResponse.php new file mode 100644 index 0000000..35fe68a --- /dev/null +++ b/src/Types/PaginatedResponse.php @@ -0,0 +1,130 @@ + $type The type of object + */ + #[JsonProperty('type')] + private ?string $type; + + /** + * @var ?CursorPages $pages + */ + #[JsonProperty('pages')] + private ?CursorPages $pages; + + /** + * @var ?int $totalCount A count of the total number of objects. + */ + #[JsonProperty('total_count')] + private ?int $totalCount; + + /** + * @var ?array $data An array of Objects + */ + #[JsonProperty('data'), ArrayType([PaginatedResponseDataItem::class])] + private ?array $data; + + /** + * @param array{ + * type?: ?value-of, + * pages?: ?CursorPages, + * totalCount?: ?int, + * data?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->pages = $values['pages'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return ?value-of + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?value-of $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?CursorPages + */ + public function getPages(): ?CursorPages + { + return $this->pages; + } + + /** + * @param ?CursorPages $value + */ + public function setPages(?CursorPages $value = null): self + { + $this->pages = $value; + return $this; + } + + /** + * @return ?int + */ + public function getTotalCount(): ?int + { + return $this->totalCount; + } + + /** + * @param ?int $value + */ + public function setTotalCount(?int $value = null): self + { + $this->totalCount = $value; + return $this; + } + + /** + * @return ?array + */ + public function getData(): ?array + { + return $this->data; + } + + /** + * @param ?array $value + */ + public function setData(?array $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/ActionComponent.php b/src/Types/PaginatedResponseDataItem.php similarity index 52% rename from src/Types/ActionComponent.php rename to src/Types/PaginatedResponseDataItem.php index 9a587df..389a8a4 100644 --- a/src/Types/ActionComponent.php +++ b/src/Types/PaginatedResponseDataItem.php @@ -3,16 +3,17 @@ namespace Intercom\Types; use Intercom\Core\Json\JsonSerializableType; +use Intercom\News\Types\NewsItem; +use Intercom\News\Types\Newsfeed; use Exception; use Intercom\Core\Json\JsonDecoder; -class ActionComponent extends JsonSerializableType +class PaginatedResponseDataItem extends JsonSerializableType { /** * @var ( - * 'sheet' - * |'url' - * |'submit' + * 'news-item' + * |'newsfeed' * |'_unknown' * ) $type */ @@ -20,9 +21,8 @@ class ActionComponent extends JsonSerializableType /** * @var ( - * SheetActionComponent - * |UrlActionComponent - * |SubmitActionComponent + * NewsItem + * |Newsfeed * |mixed * ) $value */ @@ -31,15 +31,13 @@ class ActionComponent extends JsonSerializableType /** * @param array{ * type: ( - * 'sheet' - * |'url' - * |'submit' + * 'news-item' + * |'newsfeed' * |'_unknown' * ), * value: ( - * SheetActionComponent - * |UrlActionComponent - * |SubmitActionComponent + * NewsItem + * |Newsfeed * |mixed * ), * } $values @@ -53,9 +51,8 @@ private function __construct( /** * @return ( - * 'sheet' - * |'url' - * |'submit' + * 'news-item' + * |'newsfeed' * |'_unknown' * ) */ @@ -66,9 +63,8 @@ public function getType(): string /** * @return ( - * SheetActionComponent - * |UrlActionComponent - * |SubmitActionComponent + * NewsItem + * |Newsfeed * |mixed * ) */ @@ -78,57 +74,45 @@ public function getValue(): mixed } /** - * @param SheetActionComponent $sheet - * @return ActionComponent + * @param NewsItem $newsItem + * @return PaginatedResponseDataItem */ - public static function sheet(SheetActionComponent $sheet): ActionComponent + public static function newsItem(NewsItem $newsItem): PaginatedResponseDataItem { - return new ActionComponent([ - 'type' => 'sheet', - 'value' => $sheet, + return new PaginatedResponseDataItem([ + 'type' => 'news-item', + 'value' => $newsItem, ]); } /** - * @param UrlActionComponent $url - * @return ActionComponent + * @param Newsfeed $newsfeed + * @return PaginatedResponseDataItem */ - public static function url(UrlActionComponent $url): ActionComponent + public static function newsfeed(Newsfeed $newsfeed): PaginatedResponseDataItem { - return new ActionComponent([ - 'type' => 'url', - 'value' => $url, - ]); - } - - /** - * @param SubmitActionComponent $submit - * @return ActionComponent - */ - public static function submit(SubmitActionComponent $submit): ActionComponent - { - return new ActionComponent([ - 'type' => 'submit', - 'value' => $submit, + return new PaginatedResponseDataItem([ + 'type' => 'newsfeed', + 'value' => $newsfeed, ]); } /** * @return bool */ - public function isSheet(): bool + public function isNewsItem(): bool { - return $this->value instanceof SheetActionComponent && $this->type === 'sheet'; + return $this->value instanceof NewsItem && $this->type === 'news-item'; } /** - * @return SheetActionComponent + * @return NewsItem */ - public function asSheet(): SheetActionComponent + public function asNewsItem(): NewsItem { - if (!($this->value instanceof SheetActionComponent && $this->type === 'sheet')) { + if (!($this->value instanceof NewsItem && $this->type === 'news-item')) { throw new Exception( - "Expected sheet; got " . $this->type . " with value of type " . get_debug_type($this->value), + "Expected news-item; got " . $this->type . " with value of type " . get_debug_type($this->value), ); } @@ -138,41 +122,19 @@ public function asSheet(): SheetActionComponent /** * @return bool */ - public function isUrl(): bool + public function isNewsfeed(): bool { - return $this->value instanceof UrlActionComponent && $this->type === 'url'; + return $this->value instanceof Newsfeed && $this->type === 'newsfeed'; } /** - * @return UrlActionComponent + * @return Newsfeed */ - public function asUrl(): UrlActionComponent + public function asNewsfeed(): Newsfeed { - if (!($this->value instanceof UrlActionComponent && $this->type === 'url')) { + if (!($this->value instanceof Newsfeed && $this->type === 'newsfeed')) { throw new Exception( - "Expected url; got " . $this->type . " with value of type " . get_debug_type($this->value), - ); - } - - return $this->value; - } - - /** - * @return bool - */ - public function isSubmit(): bool - { - return $this->value instanceof SubmitActionComponent && $this->type === 'submit'; - } - - /** - * @return SubmitActionComponent - */ - public function asSubmit(): SubmitActionComponent - { - if (!($this->value instanceof SubmitActionComponent && $this->type === 'submit')) { - throw new Exception( - "Expected submit; got " . $this->type . " with value of type " . get_debug_type($this->value), + "Expected newsfeed; got " . $this->type . " with value of type " . get_debug_type($this->value), ); } @@ -199,16 +161,12 @@ public function jsonSerialize(): array $result = array_merge($base, $result); switch ($this->type) { - case 'sheet': - $value = $this->asSheet()->jsonSerialize(); + case 'news-item': + $value = $this->asNewsItem()->jsonSerialize(); $result = array_merge($value, $result); break; - case 'url': - $value = $this->asUrl()->jsonSerialize(); - $result = array_merge($value, $result); - break; - case 'submit': - $value = $this->asSubmit()->jsonSerialize(); + case 'newsfeed': + $value = $this->asNewsfeed()->jsonSerialize(); $result = array_merge($value, $result); break; case '_unknown': @@ -259,14 +217,11 @@ public static function jsonDeserialize(array $data): static $args['type'] = $type; switch ($type) { - case 'sheet': - $args['value'] = SheetActionComponent::jsonDeserialize($data); - break; - case 'url': - $args['value'] = UrlActionComponent::jsonDeserialize($data); + case 'news-item': + $args['value'] = NewsItem::jsonDeserialize($data); break; - case 'submit': - $args['value'] = SubmitActionComponent::jsonDeserialize($data); + case 'newsfeed': + $args['value'] = Newsfeed::jsonDeserialize($data); break; case '_unknown': default: diff --git a/src/Types/PaginatedResponseType.php b/src/Types/PaginatedResponseType.php new file mode 100644 index 0000000..fb2ef73 --- /dev/null +++ b/src/Types/PaginatedResponseType.php @@ -0,0 +1,9 @@ +type = $values['type']; - $this->name = $values['name']; - $this->url = $values['url']; - $this->contentType = $values['contentType']; - $this->filesize = $values['filesize']; - $this->width = $values['width']; - $this->height = $values['height']; + $this->type = $values['type'] ?? null; + $this->name = $values['name'] ?? null; + $this->url = $values['url'] ?? null; + $this->contentType = $values['contentType'] ?? null; + $this->filesize = $values['filesize'] ?? null; + $this->width = $values['width'] ?? null; + $this->height = $values['height'] ?? null; } /** - * @return string + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param string $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return string + * @return ?string */ - public function getUrl(): string + public function getUrl(): ?string { return $this->url; } /** - * @param string $value + * @param ?string $value */ - public function setUrl(string $value): self + public function setUrl(?string $value = null): self { $this->url = $value; return $this; } /** - * @return string + * @return ?string */ - public function getContentType(): string + public function getContentType(): ?string { return $this->contentType; } /** - * @param string $value + * @param ?string $value */ - public function setContentType(string $value): self + public function setContentType(?string $value = null): self { $this->contentType = $value; return $this; } /** - * @return int + * @return ?int */ - public function getFilesize(): int + public function getFilesize(): ?int { return $this->filesize; } /** - * @param int $value + * @param ?int $value */ - public function setFilesize(int $value): self + public function setFilesize(?int $value = null): self { $this->filesize = $value; return $this; } /** - * @return int + * @return ?int */ - public function getWidth(): int + public function getWidth(): ?int { return $this->width; } /** - * @param int $value + * @param ?int $value */ - public function setWidth(int $value): self + public function setWidth(?int $value = null): self { $this->width = $value; return $this; } /** - * @return int + * @return ?int */ - public function getHeight(): int + public function getHeight(): ?int { return $this->height; } /** - * @param int $value + * @param ?int $value */ - public function setHeight(int $value): self + public function setHeight(?int $value = null): self { $this->height = $value; return $this; diff --git a/src/Types/PhoneSwitch.php b/src/Types/PhoneSwitch.php index 62f991b..b0618cc 100644 --- a/src/Types/PhoneSwitch.php +++ b/src/Types/PhoneSwitch.php @@ -11,59 +11,59 @@ class PhoneSwitch extends JsonSerializableType { /** - * @var 'phone_call_redirect' $type + * @var ?'phone_call_redirect' $type */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $phone Phone number in E.164 format, that has received the SMS to continue the conversation in the Messenger. + * @var ?string $phone Phone number in E.164 format, that has received the SMS to continue the conversation in the Messenger. */ #[JsonProperty('phone')] - private string $phone; + private ?string $phone; /** * @param array{ - * type: 'phone_call_redirect', - * phone: string, + * type?: ?'phone_call_redirect', + * phone?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->phone = $values['phone']; + $this->type = $values['type'] ?? null; + $this->phone = $values['phone'] ?? null; } /** - * @return 'phone_call_redirect' + * @return ?'phone_call_redirect' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'phone_call_redirect' $value + * @param ?'phone_call_redirect' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getPhone(): string + public function getPhone(): ?string { return $this->phone; } /** - * @param string $value + * @param ?string $value */ - public function setPhone(string $value): self + public function setPhone(?string $value = null): self { $this->phone = $value; return $this; diff --git a/src/Types/QuickReplyOption.php b/src/Types/QuickReplyOption.php new file mode 100644 index 0000000..47d006a --- /dev/null +++ b/src/Types/QuickReplyOption.php @@ -0,0 +1,76 @@ +text = $values['text']; + $this->uuid = $values['uuid']; + } + + /** + * @return string + */ + public function getText(): string + { + return $this->text; + } + + /** + * @param string $value + */ + public function setText(string $value): self + { + $this->text = $value; + return $this; + } + + /** + * @return string + */ + public function getUuid(): string + { + return $this->uuid; + } + + /** + * @param string $value + */ + public function setUuid(string $value): self + { + $this->uuid = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/Recipient.php b/src/Types/Recipient.php new file mode 100644 index 0000000..275d596 --- /dev/null +++ b/src/Types/Recipient.php @@ -0,0 +1,79 @@ + $type The role associated to the contact - `user` or `lead`. + */ + #[JsonProperty('type')] + private string $type; + + /** + * @var string $id The identifier for the contact which is given by Intercom. + */ + #[JsonProperty('id')] + private string $id; + + /** + * @param array{ + * type: value-of, + * id: string, + * } $values + */ + public function __construct( + array $values, + ) { + $this->type = $values['type']; + $this->id = $values['id']; + } + + /** + * @return value-of + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param value-of $value + */ + public function setType(string $value): self + { + $this->type = $value; + return $this; + } + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $value + */ + public function setId(string $value): self + { + $this->id = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/RecipientType.php b/src/Types/RecipientType.php new file mode 100644 index 0000000..1a929da --- /dev/null +++ b/src/Types/RecipientType.php @@ -0,0 +1,9 @@ +type = $values['type']; + $this->type = $values['type'] ?? null; $this->id = $values['id'] ?? null; } /** - * @return string + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param string $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; diff --git a/src/Types/ResultsResponse.php b/src/Types/ResultsResponse.php deleted file mode 100644 index d0df17d..0000000 --- a/src/Types/ResultsResponse.php +++ /dev/null @@ -1,55 +0,0 @@ - $results Key-value pairs of data you want access to in the Initialize request - */ - #[JsonProperty('results'), ArrayType(['string' => 'mixed'])] - private array $results; - - /** - * @param array{ - * results: array, - * } $values - */ - public function __construct( - array $values, - ) { - $this->results = $values['results']; - } - - /** - * @return array - */ - public function getResults(): array - { - return $this->results; - } - - /** - * @param array $value - */ - public function setResults(array $value): self - { - $this->results = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/SegmentList.php b/src/Types/SegmentList.php index 52cbc4d..08ebfdc 100644 --- a/src/Types/SegmentList.php +++ b/src/Types/SegmentList.php @@ -13,16 +13,16 @@ class SegmentList extends JsonSerializableType { /** - * @var 'segment.list' $type The type of the object + * @var ?'segment.list' $type The type of the object */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $segments A list of Segment objects + * @var ?array $segments A list of Segment objects */ #[JsonProperty('segments'), ArrayType([Segment::class])] - private array $segments; + private ?array $segments; /** * @var ?array $pages A pagination object, which may be empty, indicating no further pages to fetch. @@ -32,48 +32,48 @@ class SegmentList extends JsonSerializableType /** * @param array{ - * type: 'segment.list', - * segments: array, + * type?: ?'segment.list', + * segments?: ?array, * pages?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->segments = $values['segments']; + $this->type = $values['type'] ?? null; + $this->segments = $values['segments'] ?? null; $this->pages = $values['pages'] ?? null; } /** - * @return 'segment.list' + * @return ?'segment.list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'segment.list' $value + * @param ?'segment.list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getSegments(): array + public function getSegments(): ?array { return $this->segments; } /** - * @param array $value + * @param ?array $value */ - public function setSegments(array $value): self + public function setSegments(?array $value = null): self { $this->segments = $value; return $this; diff --git a/src/Types/SheetActionComponent.php b/src/Types/SheetActionComponent.php deleted file mode 100644 index 5b4b0d7..0000000 --- a/src/Types/SheetActionComponent.php +++ /dev/null @@ -1,56 +0,0 @@ -url = $values['url']; - } - - /** - * @return string - */ - public function getUrl(): string - { - return $this->url; - } - - /** - * @param string $value - */ - public function setUrl(string $value): self - { - $this->url = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/SingleFilterSearchRequest.php b/src/Types/SingleFilterSearchRequest.php index e3f39d4..17f721e 100644 --- a/src/Types/SingleFilterSearchRequest.php +++ b/src/Types/SingleFilterSearchRequest.php @@ -27,11 +27,13 @@ class SingleFilterSearchRequest extends JsonSerializableType * @var ( * string * |int - * |array - * |array + * |array<( + * string + * |int + * )> * )|null $value The value that you want to search on. */ - #[JsonProperty('value'), Union('string', 'integer', ['string'], ['integer'], 'null')] + #[JsonProperty('value'), Union('string', 'integer', [new Union('string', 'integer')], 'null')] private string|int|array|null $value; /** @@ -41,8 +43,10 @@ class SingleFilterSearchRequest extends JsonSerializableType * value?: ( * string * |int - * |array - * |array + * |array<( + * string + * |int + * )> * )|null, * } $values */ @@ -92,8 +96,10 @@ public function setOperator(?string $value = null): self * @return ( * string * |int - * |array - * |array + * |array<( + * string + * |int + * )> * )|null */ public function getValue(): string|int|array|null @@ -105,8 +111,10 @@ public function getValue(): string|int|array|null * @param ( * string * |int - * |array - * |array + * |array<( + * string + * |int + * )> * )|null $value */ public function setValue(string|int|array|null $value = null): self diff --git a/src/Types/SingleSelectComponent.php b/src/Types/SingleSelectComponent.php deleted file mode 100644 index ee3fc45..0000000 --- a/src/Types/SingleSelectComponent.php +++ /dev/null @@ -1,210 +0,0 @@ - $options The list of options. Can provide 2 to 10. - */ - #[JsonProperty('options'), ArrayType([SingleSelectOption::class])] - private array $options; - - /** - * @var ?string $label The text shown above the options. - */ - #[JsonProperty('label')] - private ?string $label; - - /** - * @var ?string $value The option that is selected by default. - */ - #[JsonProperty('value')] - private ?string $value; - - /** - * @var ?value-of $saveState Styles the input. Default is `unsaved`. Prevent action with `saved`. - */ - #[JsonProperty('save_state')] - private ?string $saveState; - - /** - * @var ?bool $disabled Styles all options and prevents the action. Default is false. Will be overridden if save_state is saved. - */ - #[JsonProperty('disabled')] - private ?bool $disabled; - - /** - * @var ?ActionComponent $action This can be a Submit Action, URL Action, or Sheets Action. - */ - #[JsonProperty('action')] - private ?ActionComponent $action; - - /** - * @param array{ - * id: string, - * options: array, - * label?: ?string, - * value?: ?string, - * saveState?: ?value-of, - * disabled?: ?bool, - * action?: ?ActionComponent, - * } $values - */ - public function __construct( - array $values, - ) { - $this->id = $values['id']; - $this->options = $values['options']; - $this->label = $values['label'] ?? null; - $this->value = $values['value'] ?? null; - $this->saveState = $values['saveState'] ?? null; - $this->disabled = $values['disabled'] ?? null; - $this->action = $values['action'] ?? null; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return array - */ - public function getOptions(): array - { - return $this->options; - } - - /** - * @param array $value - */ - public function setOptions(array $value): self - { - $this->options = $value; - return $this; - } - - /** - * @return ?string - */ - public function getLabel(): ?string - { - return $this->label; - } - - /** - * @param ?string $value - */ - public function setLabel(?string $value = null): self - { - $this->label = $value; - return $this; - } - - /** - * @return ?string - */ - public function getValue(): ?string - { - return $this->value; - } - - /** - * @param ?string $value - */ - public function setValue(?string $value = null): self - { - $this->value = $value; - return $this; - } - - /** - * @return ?value-of - */ - public function getSaveState(): ?string - { - return $this->saveState; - } - - /** - * @param ?value-of $value - */ - public function setSaveState(?string $value = null): self - { - $this->saveState = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getDisabled(): ?bool - { - return $this->disabled; - } - - /** - * @param ?bool $value - */ - public function setDisabled(?bool $value = null): self - { - $this->disabled = $value; - return $this; - } - - /** - * @return ?ActionComponent - */ - public function getAction(): ?ActionComponent - { - return $this->action; - } - - /** - * @param ?ActionComponent $value - */ - public function setAction(?ActionComponent $value = null): self - { - $this->action = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/SingleSelectComponentSaveState.php b/src/Types/SingleSelectComponentSaveState.php deleted file mode 100644 index 3776c6a..0000000 --- a/src/Types/SingleSelectComponentSaveState.php +++ /dev/null @@ -1,10 +0,0 @@ -type = $values['type']; - $this->id = $values['id']; - $this->text = $values['text']; - $this->disabled = $values['disabled'] ?? null; - } - - /** - * @return 'option' - */ - public function getType(): string - { - return $this->type; - } - - /** - * @param 'option' $value - */ - public function setType(string $value): self - { - $this->type = $value; - return $this; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return string - */ - public function getText(): string - { - return $this->text; - } - - /** - * @param string $value - */ - public function setText(string $value): self - { - $this->text = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getDisabled(): ?bool - { - return $this->disabled; - } - - /** - * @param ?bool $value - */ - public function setDisabled(?bool $value = null): self - { - $this->disabled = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/SlaApplied.php b/src/Types/SlaApplied.php index 79ced80..6587038 100644 --- a/src/Types/SlaApplied.php +++ b/src/Types/SlaApplied.php @@ -12,16 +12,16 @@ class SlaApplied extends JsonSerializableType { /** - * @var string $type object type + * @var ?string $type object type */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $slaName The name of the SLA as given by the teammate when it was created. + * @var ?string $slaName The name of the SLA as given by the teammate when it was created. */ #[JsonProperty('sla_name')] - private string $slaName; + private ?string $slaName; /** * SLA statuses: @@ -29,72 +29,72 @@ class SlaApplied extends JsonSerializableType * - `missed`: If there are any missed sla_events for the conversation and no canceled events. If there’s even a single missed sla event, the status will always be missed. A missed status is not applied when the SLA expires, only the next time a teammate replies. * - `active`: An SLA has been applied to a conversation, but has not yet been fulfilled. SLA status is active only if there are no “hit, “missed”, or “canceled” events. * - * @var value-of $slaStatus + * @var ?value-of $slaStatus */ #[JsonProperty('sla_status')] - private string $slaStatus; + private ?string $slaStatus; /** * @param array{ - * type: string, - * slaName: string, - * slaStatus: value-of, + * type?: ?string, + * slaName?: ?string, + * slaStatus?: ?value-of, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->slaName = $values['slaName']; - $this->slaStatus = $values['slaStatus']; + $this->type = $values['type'] ?? null; + $this->slaName = $values['slaName'] ?? null; + $this->slaStatus = $values['slaStatus'] ?? null; } /** - * @return string + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param string $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getSlaName(): string + public function getSlaName(): ?string { return $this->slaName; } /** - * @param string $value + * @param ?string $value */ - public function setSlaName(string $value): self + public function setSlaName(?string $value = null): self { $this->slaName = $value; return $this; } /** - * @return value-of + * @return ?value-of */ - public function getSlaStatus(): string + public function getSlaStatus(): ?string { return $this->slaStatus; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setSlaStatus(string $value): self + public function setSlaStatus(?string $value = null): self { $this->slaStatus = $value; return $this; diff --git a/src/Types/SocialProfile.php b/src/Types/SocialProfile.php index ac99d03..0ae1f48 100644 --- a/src/Types/SocialProfile.php +++ b/src/Types/SocialProfile.php @@ -11,84 +11,84 @@ class SocialProfile extends JsonSerializableType { /** - * @var 'social_profile' $type value is "social_profile" + * @var ?'social_profile' $type value is "social_profile" */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $name The name of the Social media profile + * @var ?string $name The name of the Social media profile */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var string $url The name of the Social media profile + * @var ?string $url The name of the Social media profile */ #[JsonProperty('url')] - private string $url; + private ?string $url; /** * @param array{ - * type: 'social_profile', - * name: string, - * url: string, + * type?: ?'social_profile', + * name?: ?string, + * url?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->name = $values['name']; - $this->url = $values['url']; + $this->type = $values['type'] ?? null; + $this->name = $values['name'] ?? null; + $this->url = $values['url'] ?? null; } /** - * @return 'social_profile' + * @return ?'social_profile' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'social_profile' $value + * @param ?'social_profile' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return string + * @return ?string */ - public function getUrl(): string + public function getUrl(): ?string { return $this->url; } /** - * @param string $value + * @param ?string $value */ - public function setUrl(string $value): self + public function setUrl(?string $value = null): self { $this->url = $value; return $this; diff --git a/src/Types/SpacerComponent.php b/src/Types/SpacerComponent.php deleted file mode 100644 index cf7331f..0000000 --- a/src/Types/SpacerComponent.php +++ /dev/null @@ -1,79 +0,0 @@ - $size The amount of space between components. Default is `s`. - */ - #[JsonProperty('size')] - private ?string $size; - - /** - * @param array{ - * id?: ?string, - * size?: ?value-of, - * } $values - */ - public function __construct( - array $values = [], - ) { - $this->id = $values['id'] ?? null; - $this->size = $values['size'] ?? null; - } - - /** - * @return ?string - */ - public function getId(): ?string - { - return $this->id; - } - - /** - * @param ?string $value - */ - public function setId(?string $value = null): self - { - $this->id = $value; - return $this; - } - - /** - * @return ?value-of - */ - public function getSize(): ?string - { - return $this->size; - } - - /** - * @param ?value-of $value - */ - public function setSize(?string $value = null): self - { - $this->size = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/SpacerComponentSize.php b/src/Types/SpacerComponentSize.php deleted file mode 100644 index 57b3d99..0000000 --- a/src/Types/SpacerComponentSize.php +++ /dev/null @@ -1,12 +0,0 @@ -perPage = $values['perPage']; + $this->perPage = $values['perPage'] ?? null; $this->startingAfter = $values['startingAfter'] ?? null; } /** - * @return int + * @return ?int */ - public function getPerPage(): int + public function getPerPage(): ?int { return $this->perPage; } /** - * @param int $value + * @param ?int $value */ - public function setPerPage(int $value): self + public function setPerPage(?int $value = null): self { $this->perPage = $value; return $this; diff --git a/src/Types/SubmitActionComponent.php b/src/Types/SubmitActionComponent.php deleted file mode 100644 index 6b4d2c9..0000000 --- a/src/Types/SubmitActionComponent.php +++ /dev/null @@ -1,19 +0,0 @@ -toJson(); - } -} diff --git a/src/Types/SubmitRequest.php b/src/Types/SubmitRequest.php deleted file mode 100644 index f88fe7a..0000000 --- a/src/Types/SubmitRequest.php +++ /dev/null @@ -1,283 +0,0 @@ - $inputValues A list of key/value pairs of data, inputted by the teammate on the current canvas. - */ - #[JsonProperty('input_values'), ArrayType(['string' => 'mixed'])] - private array $inputValues; - - /** - * @var Contact $user The user who took the action. - */ - #[JsonProperty('user')] - private Contact $user; - - /** - * @param array{ - * workspaceId: string, - * workspaceRegion: string, - * admin: Admin, - * componentId: string, - * context: Context, - * conversation: Conversation, - * currentCanvas: CurrentCanvas, - * contact: Contact, - * inputValues: array, - * user: Contact, - * } $values - */ - public function __construct( - array $values, - ) { - $this->workspaceId = $values['workspaceId']; - $this->workspaceRegion = $values['workspaceRegion']; - $this->admin = $values['admin']; - $this->componentId = $values['componentId']; - $this->context = $values['context']; - $this->conversation = $values['conversation']; - $this->currentCanvas = $values['currentCanvas']; - $this->contact = $values['contact']; - $this->inputValues = $values['inputValues']; - $this->user = $values['user']; - } - - /** - * @return string - */ - public function getWorkspaceId(): string - { - return $this->workspaceId; - } - - /** - * @param string $value - */ - public function setWorkspaceId(string $value): self - { - $this->workspaceId = $value; - return $this; - } - - /** - * @return string - */ - public function getWorkspaceRegion(): string - { - return $this->workspaceRegion; - } - - /** - * @param string $value - */ - public function setWorkspaceRegion(string $value): self - { - $this->workspaceRegion = $value; - return $this; - } - - /** - * @return Admin - */ - public function getAdmin(): Admin - { - return $this->admin; - } - - /** - * @param Admin $value - */ - public function setAdmin(Admin $value): self - { - $this->admin = $value; - return $this; - } - - /** - * @return string - */ - public function getComponentId(): string - { - return $this->componentId; - } - - /** - * @param string $value - */ - public function setComponentId(string $value): self - { - $this->componentId = $value; - return $this; - } - - /** - * @return Context - */ - public function getContext(): Context - { - return $this->context; - } - - /** - * @param Context $value - */ - public function setContext(Context $value): self - { - $this->context = $value; - return $this; - } - - /** - * @return Conversation - */ - public function getConversation(): Conversation - { - return $this->conversation; - } - - /** - * @param Conversation $value - */ - public function setConversation(Conversation $value): self - { - $this->conversation = $value; - return $this; - } - - /** - * @return CurrentCanvas - */ - public function getCurrentCanvas(): CurrentCanvas - { - return $this->currentCanvas; - } - - /** - * @param CurrentCanvas $value - */ - public function setCurrentCanvas(CurrentCanvas $value): self - { - $this->currentCanvas = $value; - return $this; - } - - /** - * @return Contact - */ - public function getContact(): Contact - { - return $this->contact; - } - - /** - * @param Contact $value - */ - public function setContact(Contact $value): self - { - $this->contact = $value; - return $this; - } - - /** - * @return array - */ - public function getInputValues(): array - { - return $this->inputValues; - } - - /** - * @param array $value - */ - public function setInputValues(array $value): self - { - $this->inputValues = $value; - return $this; - } - - /** - * @return Contact - */ - public function getUser(): Contact - { - return $this->user; - } - - /** - * @param Contact $value - */ - public function setUser(Contact $value): self - { - $this->user = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/SubmitResponse.php b/src/Types/SubmitResponse.php deleted file mode 100644 index b4fb3a8..0000000 --- a/src/Types/SubmitResponse.php +++ /dev/null @@ -1,113 +0,0 @@ - $cardCreationOptions Optional. Key-value pairs that will be sent in the initialize request to insert an app into the conversation reply. - */ - #[JsonProperty('card_creation_options'), ArrayType(['string' => 'mixed'])] - private ?array $cardCreationOptions; - - /** - * @var ?Event $event Optional. Indicates if the app has completed its purpose. - */ - #[JsonProperty('event')] - private ?Event $event; - - /** - * @param array{ - * canvas: CanvasObject, - * cardCreationOptions?: ?array, - * event?: ?Event, - * } $values - */ - public function __construct( - array $values, - ) { - $this->canvas = $values['canvas']; - $this->cardCreationOptions = $values['cardCreationOptions'] ?? null; - $this->event = $values['event'] ?? null; - } - - /** - * @return CanvasObject - */ - public function getCanvas(): CanvasObject - { - return $this->canvas; - } - - /** - * @param CanvasObject $value - */ - public function setCanvas(CanvasObject $value): self - { - $this->canvas = $value; - return $this; - } - - /** - * @return ?array - */ - public function getCardCreationOptions(): ?array - { - return $this->cardCreationOptions; - } - - /** - * @param ?array $value - */ - public function setCardCreationOptions(?array $value = null): self - { - $this->cardCreationOptions = $value; - return $this; - } - - /** - * @return ?Event - */ - public function getEvent(): ?Event - { - return $this->event; - } - - /** - * @param ?Event $value - */ - public function setEvent(?Event $value = null): self - { - $this->event = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/SubscriptionTypeList.php b/src/Types/SubscriptionTypeList.php index 7c292dd..9526ff2 100644 --- a/src/Types/SubscriptionTypeList.php +++ b/src/Types/SubscriptionTypeList.php @@ -13,59 +13,59 @@ class SubscriptionTypeList extends JsonSerializableType { /** - * @var 'list' $type The type of the object + * @var ?'list' $type The type of the object */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $data A list of subscription type objects associated with the workspace . + * @var ?array $data A list of subscription type objects associated with the workspace . */ #[JsonProperty('data'), ArrayType([SubscriptionType::class])] - private array $data; + private ?array $data; /** * @param array{ - * type: 'list', - * data: array, + * type?: ?'list', + * data?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->data = $values['data']; + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; diff --git a/src/Types/TagList.php b/src/Types/TagList.php index c9a3e64..105a2c7 100644 --- a/src/Types/TagList.php +++ b/src/Types/TagList.php @@ -13,59 +13,59 @@ class TagList extends JsonSerializableType { /** - * @var 'list' $type The type of the object + * @var ?'list' $type The type of the object */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $data A list of tags objects associated with the workspace . + * @var ?array $data A list of tags objects associated with the workspace . */ #[JsonProperty('data'), ArrayType([Tag::class])] - private array $data; + private ?array $data; /** * @param array{ - * type: 'list', - * data: array, + * type?: ?'list', + * data?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->data = $values['data']; + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; } /** - * @return 'list' + * @return ?'list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?'list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getData(): array + public function getData(): ?array { return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setData(array $value): self + public function setData(?array $value = null): self { $this->data = $value; return $this; diff --git a/src/Types/Tags.php b/src/Types/Tags.php index 598c543..a09e730 100644 --- a/src/Types/Tags.php +++ b/src/Types/Tags.php @@ -13,59 +13,59 @@ class Tags extends JsonSerializableType { /** - * @var 'tag.list' $type The type of the object + * @var ?'tag.list' $type The type of the object */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $tags A list of tags objects associated with the conversation. + * @var ?array $tags A list of tags objects associated with the conversation. */ #[JsonProperty('tags'), ArrayType([Tag::class])] - private array $tags; + private ?array $tags; /** * @param array{ - * type: 'tag.list', - * tags: array, + * type?: ?'tag.list', + * tags?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->tags = $values['tags']; + $this->type = $values['type'] ?? null; + $this->tags = $values['tags'] ?? null; } /** - * @return 'tag.list' + * @return ?'tag.list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'tag.list' $value + * @param ?'tag.list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getTags(): array + public function getTags(): ?array { return $this->tags; } /** - * @param array $value + * @param ?array $value */ - public function setTags(array $value): self + public function setTags(?array $value = null): self { $this->tags = $value; return $this; diff --git a/src/Types/TeamList.php b/src/Types/TeamList.php index 8670875..a7912da 100644 --- a/src/Types/TeamList.php +++ b/src/Types/TeamList.php @@ -13,59 +13,59 @@ class TeamList extends JsonSerializableType { /** - * @var 'team.list' $type The type of the object + * @var ?'team.list' $type The type of the object */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $teams A list of team objects + * @var ?array $teams A list of team objects */ #[JsonProperty('teams'), ArrayType([Team::class])] - private array $teams; + private ?array $teams; /** * @param array{ - * type: 'team.list', - * teams: array, + * type?: ?'team.list', + * teams?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->teams = $values['teams']; + $this->type = $values['type'] ?? null; + $this->teams = $values['teams'] ?? null; } /** - * @return 'team.list' + * @return ?'team.list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'team.list' $value + * @param ?'team.list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getTeams(): array + public function getTeams(): ?array { return $this->teams; } /** - * @param array $value + * @param ?array $value */ - public function setTeams(array $value): self + public function setTeams(?array $value = null): self { $this->teams = $value; return $this; diff --git a/src/Types/TextAreaComponent.php b/src/Types/TextAreaComponent.php deleted file mode 100644 index 7d8ac7f..0000000 --- a/src/Types/TextAreaComponent.php +++ /dev/null @@ -1,181 +0,0 @@ -id = $values['id']; - $this->label = $values['label'] ?? null; - $this->placeholder = $values['placeholder'] ?? null; - $this->value = $values['value'] ?? null; - $this->error = $values['error'] ?? null; - $this->disabled = $values['disabled'] ?? null; - } - - /** - * @return string - */ - public function getId(): string - { - return $this->id; - } - - /** - * @param string $value - */ - public function setId(string $value): self - { - $this->id = $value; - return $this; - } - - /** - * @return ?string - */ - public function getLabel(): ?string - { - return $this->label; - } - - /** - * @param ?string $value - */ - public function setLabel(?string $value = null): self - { - $this->label = $value; - return $this; - } - - /** - * @return ?string - */ - public function getPlaceholder(): ?string - { - return $this->placeholder; - } - - /** - * @param ?string $value - */ - public function setPlaceholder(?string $value = null): self - { - $this->placeholder = $value; - return $this; - } - - /** - * @return ?string - */ - public function getValue(): ?string - { - return $this->value; - } - - /** - * @param ?string $value - */ - public function setValue(?string $value = null): self - { - $this->value = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getError(): ?bool - { - return $this->error; - } - - /** - * @param ?bool $value - */ - public function setError(?bool $value = null): self - { - $this->error = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getDisabled(): ?bool - { - return $this->disabled; - } - - /** - * @param ?bool $value - */ - public function setDisabled(?bool $value = null): self - { - $this->disabled = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/TextComponent.php b/src/Types/TextComponent.php deleted file mode 100644 index df32229..0000000 --- a/src/Types/TextComponent.php +++ /dev/null @@ -1,154 +0,0 @@ - $align Aligns the text. Default is `left`. - */ - #[JsonProperty('align')] - private ?string $align; - - /** - * @var ?value-of $style Styles the text. Default is `paragraph`. - */ - #[JsonProperty('style')] - private ?string $style; - - /** - * @var ?'none' $bottomMargin Disables a component's margin-bottom of 10px. - */ - #[JsonProperty('bottom_margin')] - private ?string $bottomMargin; - - /** - * @param array{ - * text: string, - * id?: ?string, - * align?: ?value-of, - * style?: ?value-of, - * bottomMargin?: ?'none', - * } $values - */ - public function __construct( - array $values, - ) { - $this->id = $values['id'] ?? null; - $this->text = $values['text']; - $this->align = $values['align'] ?? null; - $this->style = $values['style'] ?? null; - $this->bottomMargin = $values['bottomMargin'] ?? null; - } - - /** - * @return ?string - */ - public function getId(): ?string - { - return $this->id; - } - - /** - * @param ?string $value - */ - public function setId(?string $value = null): self - { - $this->id = $value; - return $this; - } - - /** - * @return string - */ - public function getText(): string - { - return $this->text; - } - - /** - * @param string $value - */ - public function setText(string $value): self - { - $this->text = $value; - return $this; - } - - /** - * @return ?value-of - */ - public function getAlign(): ?string - { - return $this->align; - } - - /** - * @param ?value-of $value - */ - public function setAlign(?string $value = null): self - { - $this->align = $value; - return $this; - } - - /** - * @return ?value-of - */ - public function getStyle(): ?string - { - return $this->style; - } - - /** - * @param ?value-of $value - */ - public function setStyle(?string $value = null): self - { - $this->style = $value; - return $this; - } - - /** - * @return ?'none' - */ - public function getBottomMargin(): ?string - { - return $this->bottomMargin; - } - - /** - * @param ?'none' $value - */ - public function setBottomMargin(?string $value = null): self - { - $this->bottomMargin = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/TextComponentAlign.php b/src/Types/TextComponentAlign.php deleted file mode 100644 index ab4576a..0000000 --- a/src/Types/TextComponentAlign.php +++ /dev/null @@ -1,10 +0,0 @@ - $tickets The list of ticket objects + * @var ?array $tickets The list of ticket objects */ - #[JsonProperty('tickets'), ArrayType([Ticket::class])] - private array $tickets; + #[JsonProperty('tickets'), ArrayType([new Union(Ticket::class, 'null')])] + private ?array $tickets; /** - * @var int $totalCount A count of the total number of objects. + * @var ?int $totalCount A count of the total number of objects. */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** * @var ?CursorPages $pages @@ -38,67 +39,67 @@ class TicketList extends JsonSerializableType /** * @param array{ - * type: 'ticket.list', - * tickets: array, - * totalCount: int, + * type?: ?'ticket.list', + * tickets?: ?array, + * totalCount?: ?int, * pages?: ?CursorPages, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->tickets = $values['tickets']; - $this->totalCount = $values['totalCount']; + $this->type = $values['type'] ?? null; + $this->tickets = $values['tickets'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; $this->pages = $values['pages'] ?? null; } /** - * @return 'ticket.list' + * @return ?'ticket.list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'ticket.list' $value + * @param ?'ticket.list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getTickets(): array + public function getTickets(): ?array { return $this->tickets; } /** - * @param array $value + * @param ?array $value */ - public function setTickets(array $value): self + public function setTickets(?array $value = null): self { $this->tickets = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; diff --git a/src/Types/TicketPartAuthor.php b/src/Types/TicketPartAuthor.php index 2f3e292..faadb61 100644 --- a/src/Types/TicketPartAuthor.php +++ b/src/Types/TicketPartAuthor.php @@ -11,16 +11,16 @@ class TicketPartAuthor extends JsonSerializableType { /** - * @var value-of $type The type of the author + * @var ?value-of $type The type of the author */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The id of the author + * @var ?string $id The id of the author */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** * @var ?string $name The name of the author @@ -29,57 +29,57 @@ class TicketPartAuthor extends JsonSerializableType private ?string $name; /** - * @var string $email The email of the author + * @var ?string $email The email of the author */ #[JsonProperty('email')] - private string $email; + private ?string $email; /** * @param array{ - * type: value-of, - * id: string, - * email: string, + * type?: ?value-of, + * id?: ?string, * name?: ?string, + * email?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; $this->name = $values['name'] ?? null; - $this->email = $values['email']; + $this->email = $values['email'] ?? null; } /** - * @return value-of + * @return ?value-of */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; @@ -103,17 +103,17 @@ public function setName(?string $value = null): self } /** - * @return string + * @return ?string */ - public function getEmail(): string + public function getEmail(): ?string { return $this->email; } /** - * @param string $value + * @param ?string $value */ - public function setEmail(string $value): self + public function setEmail(?string $value = null): self { $this->email = $value; return $this; diff --git a/src/Types/TicketParts.php b/src/Types/TicketParts.php index 7abbb00..2dea032 100644 --- a/src/Types/TicketParts.php +++ b/src/Types/TicketParts.php @@ -13,84 +13,84 @@ class TicketParts extends JsonSerializableType { /** - * @var 'ticket_part.list' $type + * @var ?'ticket_part.list' $type */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $ticketParts A list of Ticket Part objects for each ticket. There is a limit of 500 parts. + * @var ?array $ticketParts A list of Ticket Part objects for each ticket. There is a limit of 500 parts. */ #[JsonProperty('ticket_parts'), ArrayType([TicketPart::class])] - private array $ticketParts; + private ?array $ticketParts; /** - * @var int $totalCount + * @var ?int $totalCount */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** * @param array{ - * type: 'ticket_part.list', - * ticketParts: array, - * totalCount: int, + * type?: ?'ticket_part.list', + * ticketParts?: ?array, + * totalCount?: ?int, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->ticketParts = $values['ticketParts']; - $this->totalCount = $values['totalCount']; + $this->type = $values['type'] ?? null; + $this->ticketParts = $values['ticketParts'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; } /** - * @return 'ticket_part.list' + * @return ?'ticket_part.list' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'ticket_part.list' $value + * @param ?'ticket_part.list' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getTicketParts(): array + public function getTicketParts(): ?array { return $this->ticketParts; } /** - * @param array $value + * @param ?array $value */ - public function setTicketParts(array $value): self + public function setTicketParts(?array $value = null): self { $this->ticketParts = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; diff --git a/src/Types/TicketReply.php b/src/Types/TicketReply.php index c2439b7..96bc10e 100644 --- a/src/Types/TicketReply.php +++ b/src/Types/TicketReply.php @@ -12,22 +12,22 @@ class TicketReply extends JsonSerializableType { /** - * @var 'ticket_part' $type Always ticket_part + * @var ?'ticket_part' $type Always ticket_part */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The id representing the part. + * @var ?string $id The id representing the part. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var value-of $partType Type of the part + * @var ?value-of $partType Type of the part */ #[JsonProperty('part_type')] - private string $partType; + private ?string $partType; /** * @var ?string $body The message body, which may contain HTML. @@ -36,10 +36,10 @@ class TicketReply extends JsonSerializableType private ?string $body; /** - * @var int $createdAt The time the note was created. + * @var ?int $createdAt The time the note was created. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** * @var ?int $updatedAt The last time the note was updated. @@ -67,11 +67,11 @@ class TicketReply extends JsonSerializableType /** * @param array{ - * type: 'ticket_part', - * id: string, - * partType: value-of, - * createdAt: int, + * type?: ?'ticket_part', + * id?: ?string, + * partType?: ?value-of, * body?: ?string, + * createdAt?: ?int, * updatedAt?: ?int, * author?: ?TicketPartAuthor, * attachments?: ?array, @@ -79,13 +79,13 @@ class TicketReply extends JsonSerializableType * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->partType = $values['partType']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->partType = $values['partType'] ?? null; $this->body = $values['body'] ?? null; - $this->createdAt = $values['createdAt']; + $this->createdAt = $values['createdAt'] ?? null; $this->updatedAt = $values['updatedAt'] ?? null; $this->author = $values['author'] ?? null; $this->attachments = $values['attachments'] ?? null; @@ -93,51 +93,51 @@ public function __construct( } /** - * @return 'ticket_part' + * @return ?'ticket_part' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'ticket_part' $value + * @param ?'ticket_part' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return value-of + * @return ?value-of */ - public function getPartType(): string + public function getPartType(): ?string { return $this->partType; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setPartType(string $value): self + public function setPartType(?string $value = null): self { $this->partType = $value; return $this; @@ -161,17 +161,17 @@ public function setBody(?string $value = null): self } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; diff --git a/src/Types/TicketStateList.php b/src/Types/TicketStateList.php new file mode 100644 index 0000000..7e42c02 --- /dev/null +++ b/src/Types/TicketStateList.php @@ -0,0 +1,82 @@ + $data A list of ticket states associated with a given ticket type. + */ + #[JsonProperty('data'), ArrayType([new Union(TicketStateDetailed::class, 'null')])] + private ?array $data; + + /** + * @param array{ + * type?: ?string, + * data?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?array + */ + public function getData(): ?array + { + return $this->data; + } + + /** + * @param ?array $value + */ + public function setData(?array $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/TicketTypeAttribute.php b/src/Types/TicketTypeAttribute.php index 0920322..757aa5f 100644 --- a/src/Types/TicketTypeAttribute.php +++ b/src/Types/TicketTypeAttribute.php @@ -12,100 +12,100 @@ class TicketTypeAttribute extends JsonSerializableType { /** - * @var 'ticket_type_attribute' $type String representing the object's type. Always has the value `ticket_type_attribute`. + * @var ?string $type String representing the object's type. Always has the value `ticket_type_attribute`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The id representing the ticket type attribute. + * @var ?string $id The id representing the ticket type attribute. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $workspaceId The id of the workspace that the ticket type attribute belongs to. + * @var ?string $workspaceId The id of the workspace that the ticket type attribute belongs to. */ #[JsonProperty('workspace_id')] - private string $workspaceId; + private ?string $workspaceId; /** - * @var string $name The name of the ticket type attribute + * @var ?string $name The name of the ticket type attribute */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var string $description The description of the ticket type attribute + * @var ?string $description The description of the ticket type attribute */ #[JsonProperty('description')] - private string $description; + private ?string $description; /** - * @var value-of $dataType The type of the data attribute (allowed values: "string list integer decimal boolean datetime files") + * @var ?value-of $dataType The type of the data attribute (allowed values: "string list integer decimal boolean datetime files") */ #[JsonProperty('data_type')] - private string $dataType; + private ?string $dataType; /** - * @var array $inputOptions Input options for the attribute + * @var ?array $inputOptions Input options for the attribute */ #[JsonProperty('input_options'), ArrayType(['string' => 'mixed'])] - private array $inputOptions; + private ?array $inputOptions; /** - * @var int $order The order of the attribute against other attributes + * @var ?int $order The order of the attribute against other attributes */ #[JsonProperty('order')] - private int $order; + private ?int $order; /** - * @var bool $requiredToCreate Whether the attribute is required or not for teammates. + * @var ?bool $requiredToCreate Whether the attribute is required or not for teammates. */ #[JsonProperty('required_to_create')] - private bool $requiredToCreate; + private ?bool $requiredToCreate; /** - * @var bool $requiredToCreateForContacts Whether the attribute is required or not for contacts. + * @var ?bool $requiredToCreateForContacts Whether the attribute is required or not for contacts. */ #[JsonProperty('required_to_create_for_contacts')] - private bool $requiredToCreateForContacts; + private ?bool $requiredToCreateForContacts; /** - * @var bool $visibleOnCreate Whether the attribute is visible or not to teammates. + * @var ?bool $visibleOnCreate Whether the attribute is visible or not to teammates. */ #[JsonProperty('visible_on_create')] - private bool $visibleOnCreate; + private ?bool $visibleOnCreate; /** - * @var bool $visibleToContacts Whether the attribute is visible or not to contacts. + * @var ?bool $visibleToContacts Whether the attribute is visible or not to contacts. */ #[JsonProperty('visible_to_contacts')] - private bool $visibleToContacts; + private ?bool $visibleToContacts; /** - * @var bool $default Whether the attribute is built in or not. + * @var ?bool $default Whether the attribute is built in or not. */ #[JsonProperty('default')] - private bool $default; + private ?bool $default; /** - * @var int $ticketTypeId The id of the ticket type that the attribute belongs to. + * @var ?int $ticketTypeId The id of the ticket type that the attribute belongs to. */ #[JsonProperty('ticket_type_id')] - private int $ticketTypeId; + private ?int $ticketTypeId; /** - * @var bool $archived Whether the ticket type attribute is archived or not. + * @var ?bool $archived Whether the ticket type attribute is archived or not. */ #[JsonProperty('archived')] - private bool $archived; + private ?bool $archived; /** - * @var int $createdAt The date and time the ticket type attribute was created. + * @var ?int $createdAt The date and time the ticket type attribute was created. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** * @var ?int $updatedAt The date and time the ticket type attribute was last updated. @@ -115,314 +115,314 @@ class TicketTypeAttribute extends JsonSerializableType /** * @param array{ - * type: 'ticket_type_attribute', - * id: string, - * workspaceId: string, - * name: string, - * description: string, - * dataType: value-of, - * inputOptions: array, - * order: int, - * requiredToCreate: bool, - * requiredToCreateForContacts: bool, - * visibleOnCreate: bool, - * visibleToContacts: bool, - * default: bool, - * ticketTypeId: int, - * archived: bool, - * createdAt: int, + * type?: ?string, + * id?: ?string, + * workspaceId?: ?string, + * name?: ?string, + * description?: ?string, + * dataType?: ?value-of, + * inputOptions?: ?array, + * order?: ?int, + * requiredToCreate?: ?bool, + * requiredToCreateForContacts?: ?bool, + * visibleOnCreate?: ?bool, + * visibleToContacts?: ?bool, + * default?: ?bool, + * ticketTypeId?: ?int, + * archived?: ?bool, + * createdAt?: ?int, * updatedAt?: ?int, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->workspaceId = $values['workspaceId']; - $this->name = $values['name']; - $this->description = $values['description']; - $this->dataType = $values['dataType']; - $this->inputOptions = $values['inputOptions']; - $this->order = $values['order']; - $this->requiredToCreate = $values['requiredToCreate']; - $this->requiredToCreateForContacts = $values['requiredToCreateForContacts']; - $this->visibleOnCreate = $values['visibleOnCreate']; - $this->visibleToContacts = $values['visibleToContacts']; - $this->default = $values['default']; - $this->ticketTypeId = $values['ticketTypeId']; - $this->archived = $values['archived']; - $this->createdAt = $values['createdAt']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->workspaceId = $values['workspaceId'] ?? null; + $this->name = $values['name'] ?? null; + $this->description = $values['description'] ?? null; + $this->dataType = $values['dataType'] ?? null; + $this->inputOptions = $values['inputOptions'] ?? null; + $this->order = $values['order'] ?? null; + $this->requiredToCreate = $values['requiredToCreate'] ?? null; + $this->requiredToCreateForContacts = $values['requiredToCreateForContacts'] ?? null; + $this->visibleOnCreate = $values['visibleOnCreate'] ?? null; + $this->visibleToContacts = $values['visibleToContacts'] ?? null; + $this->default = $values['default'] ?? null; + $this->ticketTypeId = $values['ticketTypeId'] ?? null; + $this->archived = $values['archived'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; $this->updatedAt = $values['updatedAt'] ?? null; } /** - * @return 'ticket_type_attribute' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'ticket_type_attribute' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getWorkspaceId(): string + public function getWorkspaceId(): ?string { return $this->workspaceId; } /** - * @param string $value + * @param ?string $value */ - public function setWorkspaceId(string $value): self + public function setWorkspaceId(?string $value = null): self { $this->workspaceId = $value; return $this; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return string + * @return ?string */ - public function getDescription(): string + public function getDescription(): ?string { return $this->description; } /** - * @param string $value + * @param ?string $value */ - public function setDescription(string $value): self + public function setDescription(?string $value = null): self { $this->description = $value; return $this; } /** - * @return value-of + * @return ?value-of */ - public function getDataType(): string + public function getDataType(): ?string { return $this->dataType; } /** - * @param value-of $value + * @param ?value-of $value */ - public function setDataType(string $value): self + public function setDataType(?string $value = null): self { $this->dataType = $value; return $this; } /** - * @return array + * @return ?array */ - public function getInputOptions(): array + public function getInputOptions(): ?array { return $this->inputOptions; } /** - * @param array $value + * @param ?array $value */ - public function setInputOptions(array $value): self + public function setInputOptions(?array $value = null): self { $this->inputOptions = $value; return $this; } /** - * @return int + * @return ?int */ - public function getOrder(): int + public function getOrder(): ?int { return $this->order; } /** - * @param int $value + * @param ?int $value */ - public function setOrder(int $value): self + public function setOrder(?int $value = null): self { $this->order = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getRequiredToCreate(): bool + public function getRequiredToCreate(): ?bool { return $this->requiredToCreate; } /** - * @param bool $value + * @param ?bool $value */ - public function setRequiredToCreate(bool $value): self + public function setRequiredToCreate(?bool $value = null): self { $this->requiredToCreate = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getRequiredToCreateForContacts(): bool + public function getRequiredToCreateForContacts(): ?bool { return $this->requiredToCreateForContacts; } /** - * @param bool $value + * @param ?bool $value */ - public function setRequiredToCreateForContacts(bool $value): self + public function setRequiredToCreateForContacts(?bool $value = null): self { $this->requiredToCreateForContacts = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getVisibleOnCreate(): bool + public function getVisibleOnCreate(): ?bool { return $this->visibleOnCreate; } /** - * @param bool $value + * @param ?bool $value */ - public function setVisibleOnCreate(bool $value): self + public function setVisibleOnCreate(?bool $value = null): self { $this->visibleOnCreate = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getVisibleToContacts(): bool + public function getVisibleToContacts(): ?bool { return $this->visibleToContacts; } /** - * @param bool $value + * @param ?bool $value */ - public function setVisibleToContacts(bool $value): self + public function setVisibleToContacts(?bool $value = null): self { $this->visibleToContacts = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getDefault(): bool + public function getDefault(): ?bool { return $this->default; } /** - * @param bool $value + * @param ?bool $value */ - public function setDefault(bool $value): self + public function setDefault(?bool $value = null): self { $this->default = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTicketTypeId(): int + public function getTicketTypeId(): ?int { return $this->ticketTypeId; } /** - * @param int $value + * @param ?int $value */ - public function setTicketTypeId(int $value): self + public function setTicketTypeId(?int $value = null): self { $this->ticketTypeId = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getArchived(): bool + public function getArchived(): ?bool { return $this->archived; } /** - * @param bool $value + * @param ?bool $value */ - public function setArchived(bool $value): self + public function setArchived(?bool $value = null): self { $this->archived = $value; return $this; } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; diff --git a/src/Types/TicketTypeAttributeList.php b/src/Types/TicketTypeAttributeList.php index 7e23379..e153db8 100644 --- a/src/Types/TicketTypeAttributeList.php +++ b/src/Types/TicketTypeAttributeList.php @@ -5,6 +5,7 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; use Intercom\Core\Types\ArrayType; +use Intercom\Core\Types\Union; /** * A list of attributes associated with a given ticket type. @@ -12,59 +13,59 @@ class TicketTypeAttributeList extends JsonSerializableType { /** - * @var 'ticket_type_attributes.list' $type String representing the object's type. Always has the value `ticket_type_attributes.list`. + * @var ?string $type String representing the object's type. Always has the value `ticket_type_attributes.list`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $ticketTypeAttributes A list of ticket type attributes associated with a given ticket type. + * @var ?array $ticketTypeAttributes A list of ticket type attributes associated with a given ticket type. */ - #[JsonProperty('ticket_type_attributes'), ArrayType([TicketTypeAttribute::class])] - private array $ticketTypeAttributes; + #[JsonProperty('ticket_type_attributes'), ArrayType([new Union(TicketTypeAttribute::class, 'null')])] + private ?array $ticketTypeAttributes; /** * @param array{ - * type: 'ticket_type_attributes.list', - * ticketTypeAttributes: array, + * type?: ?string, + * ticketTypeAttributes?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->ticketTypeAttributes = $values['ticketTypeAttributes']; + $this->type = $values['type'] ?? null; + $this->ticketTypeAttributes = $values['ticketTypeAttributes'] ?? null; } /** - * @return 'ticket_type_attributes.list' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'ticket_type_attributes.list' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getTicketTypeAttributes(): array + public function getTicketTypeAttributes(): ?array { return $this->ticketTypeAttributes; } /** - * @param array $value + * @param ?array $value */ - public function setTicketTypeAttributes(array $value): self + public function setTicketTypeAttributes(?array $value = null): self { $this->ticketTypeAttributes = $value; return $this; diff --git a/src/Types/TicketTypeList.php b/src/Types/TicketTypeList.php index 53612bb..15f57f4 100644 --- a/src/Types/TicketTypeList.php +++ b/src/Types/TicketTypeList.php @@ -6,6 +6,7 @@ use Intercom\Core\Json\JsonProperty; use Intercom\Tickets\Types\TicketType; use Intercom\Core\Types\ArrayType; +use Intercom\Core\Types\Union; /** * A list of ticket types associated with a given workspace. @@ -13,61 +14,61 @@ class TicketTypeList extends JsonSerializableType { /** - * @var 'ticket_type_attributes.list' $type String representing the object's type. Always has the value `ticket_type.list`. + * @var ?string $type String representing the object's type. Always has the value `list`. */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var array $ticketTypes A list of ticket_types associated with a given workspace. + * @var ?array $data A list of ticket_types associated with a given workspace. */ - #[JsonProperty('ticket_types'), ArrayType([TicketType::class])] - private array $ticketTypes; + #[JsonProperty('data'), ArrayType([new Union(TicketType::class, 'null')])] + private ?array $data; /** * @param array{ - * type: 'ticket_type_attributes.list', - * ticketTypes: array, + * type?: ?string, + * data?: ?array, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->ticketTypes = $values['ticketTypes']; + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; } /** - * @return 'ticket_type_attributes.list' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'ticket_type_attributes.list' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return array + * @return ?array */ - public function getTicketTypes(): array + public function getData(): ?array { - return $this->ticketTypes; + return $this->data; } /** - * @param array $value + * @param ?array $value */ - public function setTicketTypes(array $value): self + public function setData(?array $value = null): self { - $this->ticketTypes = $value; + $this->data = $value; return $this; } diff --git a/src/Types/Translation.php b/src/Types/Translation.php index 8be582a..7b98448 100644 --- a/src/Types/Translation.php +++ b/src/Types/Translation.php @@ -11,84 +11,84 @@ class Translation extends JsonSerializableType { /** - * @var string $name The localised name of the subscription type. + * @var ?string $name The localised name of the subscription type. */ #[JsonProperty('name')] - private string $name; + private ?string $name; /** - * @var string $description The localised description of the subscription type. + * @var ?string $description The localised description of the subscription type. */ #[JsonProperty('description')] - private string $description; + private ?string $description; /** - * @var string $locale The two character identifier for the language of the translation object. + * @var ?string $locale The two character identifier for the language of the translation object. */ #[JsonProperty('locale')] - private string $locale; + private ?string $locale; /** * @param array{ - * name: string, - * description: string, - * locale: string, + * name?: ?string, + * description?: ?string, + * locale?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->name = $values['name']; - $this->description = $values['description']; - $this->locale = $values['locale']; + $this->name = $values['name'] ?? null; + $this->description = $values['description'] ?? null; + $this->locale = $values['locale'] ?? null; } /** - * @return string + * @return ?string */ - public function getName(): string + public function getName(): ?string { return $this->name; } /** - * @param string $value + * @param ?string $value */ - public function setName(string $value): self + public function setName(?string $value = null): self { $this->name = $value; return $this; } /** - * @return string + * @return ?string */ - public function getDescription(): string + public function getDescription(): ?string { return $this->description; } /** - * @param string $value + * @param ?string $value */ - public function setDescription(string $value): self + public function setDescription(?string $value = null): self { $this->description = $value; return $this; } /** - * @return string + * @return ?string */ - public function getLocale(): string + public function getLocale(): ?string { return $this->locale; } /** - * @param string $value + * @param ?string $value */ - public function setLocale(string $value): self + public function setLocale(?string $value = null): self { $this->locale = $value; return $this; diff --git a/src/Types/UntagCompanyRequestCompaniesItem.php b/src/Types/UntagCompanyRequestCompaniesItem.php index badf1b7..7f12d76 100644 --- a/src/Types/UntagCompanyRequestCompaniesItem.php +++ b/src/Types/UntagCompanyRequestCompaniesItem.php @@ -8,84 +8,84 @@ class UntagCompanyRequestCompaniesItem extends JsonSerializableType { /** - * @var string $id The Intercom defined id representing the company. + * @var ?string $id The Intercom defined id representing the company. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $companyId The company id you have defined for the company. + * @var ?string $companyId The company id you have defined for the company. */ #[JsonProperty('company_id')] - private string $companyId; + private ?string $companyId; /** - * @var true $untag Always set to true + * @var ?bool $untag Always set to true */ #[JsonProperty('untag')] - private bool $untag; + private ?bool $untag; /** * @param array{ - * id: string, - * companyId: string, - * untag: true, + * id?: ?string, + * companyId?: ?string, + * untag?: ?bool, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->id = $values['id']; - $this->companyId = $values['companyId']; - $this->untag = $values['untag']; + $this->id = $values['id'] ?? null; + $this->companyId = $values['companyId'] ?? null; + $this->untag = $values['untag'] ?? null; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getCompanyId(): string + public function getCompanyId(): ?string { return $this->companyId; } /** - * @param string $value + * @param ?string $value */ - public function setCompanyId(string $value): self + public function setCompanyId(?string $value = null): self { $this->companyId = $value; return $this; } /** - * @return true + * @return ?bool */ - public function getUntag(): bool + public function getUntag(): ?bool { return $this->untag; } /** - * @param true $value + * @param ?bool $value */ - public function setUntag(bool $value): self + public function setUntag(?bool $value = null): self { $this->untag = $value; return $this; diff --git a/src/Types/UpdateArticleRequestBody.php b/src/Types/UpdateArticleRequestBody.php new file mode 100644 index 0000000..f22bdf0 --- /dev/null +++ b/src/Types/UpdateArticleRequestBody.php @@ -0,0 +1,51 @@ + $parentType + */ + #[JsonProperty('parent_type')] + private ?string $parentType; + + /** + * @param array{ + * parentType?: ?value-of, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->parentType = $values['parentType'] ?? null; + } + + /** + * @return ?value-of + */ + public function getParentType(): ?string + { + return $this->parentType; + } + + /** + * @param ?value-of $value + */ + public function setParentType(?string $value = null): self + { + $this->parentType = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Articles/Types/UpdateArticleRequestBodyParentType.php b/src/Types/UpdateArticleRequestBodyParentType.php similarity index 78% rename from src/Articles/Types/UpdateArticleRequestBodyParentType.php rename to src/Types/UpdateArticleRequestBodyParentType.php index 374f62b..116289c 100644 --- a/src/Articles/Types/UpdateArticleRequestBodyParentType.php +++ b/src/Types/UpdateArticleRequestBodyParentType.php @@ -1,6 +1,6 @@ $options Array of objects representing the options of the list, with `value` as the key and the option as the value. At least two options are required. + */ + #[JsonProperty('options'), ArrayType([UpdateDataAttributeRequestOptionsOptionsItem::class])] + private array $options; + + /** + * @param array{ + * options: array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->options = $values['options']; + } + + /** + * @return array + */ + public function getOptions(): array + { + return $this->options; + } + + /** + * @param array $value + */ + public function setOptions(array $value): self + { + $this->options = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/UpdateDataAttributeRequestOptionsOptionsItem.php b/src/Types/UpdateDataAttributeRequestOptionsOptionsItem.php new file mode 100644 index 0000000..cd8485d --- /dev/null +++ b/src/Types/UpdateDataAttributeRequestOptionsOptionsItem.php @@ -0,0 +1,51 @@ +value = $values['value'] ?? null; + } + + /** + * @return ?string + */ + public function getValue(): ?string + { + return $this->value; + } + + /** + * @param ?string $value + */ + public function setValue(?string $value = null): self + { + $this->value = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/UrlActionComponent.php b/src/Types/UrlActionComponent.php deleted file mode 100644 index fcac878..0000000 --- a/src/Types/UrlActionComponent.php +++ /dev/null @@ -1,54 +0,0 @@ -url = $values['url']; - } - - /** - * @return string - */ - public function getUrl(): string - { - return $this->url; - } - - /** - * @param string $value - */ - public function setUrl(string $value): self - { - $this->url = $value; - return $this; - } - - /** - * @return string - */ - public function __toString(): string - { - return $this->toJson(); - } -} diff --git a/src/Types/Visitor.php b/src/Types/Visitor.php index 05a9dd9..8ebfa5a 100644 --- a/src/Types/Visitor.php +++ b/src/Types/Visitor.php @@ -12,34 +12,34 @@ class Visitor extends JsonSerializableType { /** - * @var 'visitor' $type Value is 'visitor' + * @var ?'visitor' $type Value is 'visitor' */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $id The Intercom defined id representing the Visitor. + * @var ?string $id The Intercom defined id representing the Visitor. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var string $userId Automatically generated identifier for the Visitor. + * @var ?string $userId Automatically generated identifier for the Visitor. */ #[JsonProperty('user_id')] - private string $userId; + private ?string $userId; /** - * @var bool $anonymous Identifies if this visitor is anonymous. + * @var ?bool $anonymous Identifies if this visitor is anonymous. */ #[JsonProperty('anonymous')] - private bool $anonymous; + private ?bool $anonymous; /** - * @var string $email The email of the visitor. + * @var ?string $email The email of the visitor. */ #[JsonProperty('email')] - private string $email; + private ?string $email; /** * @var ?string $phone The phone number of the visitor. @@ -66,10 +66,10 @@ class Visitor extends JsonSerializableType private ?VisitorAvatar $avatar; /** - * @var string $appId The id of the app the visitor is associated with. + * @var ?string $appId The id of the app the visitor is associated with. */ #[JsonProperty('app_id')] - private string $appId; + private ?string $appId; /** * @var ?VisitorCompanies $companies @@ -90,10 +90,10 @@ class Visitor extends JsonSerializableType private ?int $lasRequestAt; /** - * @var int $createdAt The time the Visitor was added to Intercom. + * @var ?int $createdAt The time the Visitor was added to Intercom. */ #[JsonProperty('created_at')] - private int $createdAt; + private ?int $createdAt; /** * @var ?int $remoteCreatedAt The time the Visitor was added to Intercom. @@ -102,10 +102,10 @@ class Visitor extends JsonSerializableType private ?int $remoteCreatedAt; /** - * @var int $signedUpAt The time the Visitor signed up for your product. + * @var ?int $signedUpAt The time the Visitor signed up for your product. */ #[JsonProperty('signed_up_at')] - private int $signedUpAt; + private ?int $signedUpAt; /** * @var ?int $updatedAt The last time the Visitor was updated. @@ -211,22 +211,22 @@ class Visitor extends JsonSerializableType /** * @param array{ - * type: 'visitor', - * id: string, - * userId: string, - * anonymous: bool, - * email: string, - * appId: string, - * createdAt: int, - * signedUpAt: int, + * type?: ?'visitor', + * id?: ?string, + * userId?: ?string, + * anonymous?: ?bool, + * email?: ?string, * phone?: ?string, * name?: ?string, * pseudonym?: ?string, * avatar?: ?VisitorAvatar, + * appId?: ?string, * companies?: ?VisitorCompanies, * locationData?: ?VisitorLocationData, * lasRequestAt?: ?int, + * createdAt?: ?int, * remoteCreatedAt?: ?int, + * signedUpAt?: ?int, * updatedAt?: ?int, * sessionCount?: ?int, * socialProfiles?: ?VisitorSocialProfiles, @@ -247,24 +247,24 @@ class Visitor extends JsonSerializableType * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; - $this->id = $values['id']; - $this->userId = $values['userId']; - $this->anonymous = $values['anonymous']; - $this->email = $values['email']; + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->userId = $values['userId'] ?? null; + $this->anonymous = $values['anonymous'] ?? null; + $this->email = $values['email'] ?? null; $this->phone = $values['phone'] ?? null; $this->name = $values['name'] ?? null; $this->pseudonym = $values['pseudonym'] ?? null; $this->avatar = $values['avatar'] ?? null; - $this->appId = $values['appId']; + $this->appId = $values['appId'] ?? null; $this->companies = $values['companies'] ?? null; $this->locationData = $values['locationData'] ?? null; $this->lasRequestAt = $values['lasRequestAt'] ?? null; - $this->createdAt = $values['createdAt']; + $this->createdAt = $values['createdAt'] ?? null; $this->remoteCreatedAt = $values['remoteCreatedAt'] ?? null; - $this->signedUpAt = $values['signedUpAt']; + $this->signedUpAt = $values['signedUpAt'] ?? null; $this->updatedAt = $values['updatedAt'] ?? null; $this->sessionCount = $values['sessionCount'] ?? null; $this->socialProfiles = $values['socialProfiles'] ?? null; @@ -285,85 +285,85 @@ public function __construct( } /** - * @return 'visitor' + * @return ?'visitor' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'visitor' $value + * @param ?'visitor' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return string + * @return ?string */ - public function getUserId(): string + public function getUserId(): ?string { return $this->userId; } /** - * @param string $value + * @param ?string $value */ - public function setUserId(string $value): self + public function setUserId(?string $value = null): self { $this->userId = $value; return $this; } /** - * @return bool + * @return ?bool */ - public function getAnonymous(): bool + public function getAnonymous(): ?bool { return $this->anonymous; } /** - * @param bool $value + * @param ?bool $value */ - public function setAnonymous(bool $value): self + public function setAnonymous(?bool $value = null): self { $this->anonymous = $value; return $this; } /** - * @return string + * @return ?string */ - public function getEmail(): string + public function getEmail(): ?string { return $this->email; } /** - * @param string $value + * @param ?string $value */ - public function setEmail(string $value): self + public function setEmail(?string $value = null): self { $this->email = $value; return $this; @@ -438,17 +438,17 @@ public function setAvatar(?VisitorAvatar $value = null): self } /** - * @return string + * @return ?string */ - public function getAppId(): string + public function getAppId(): ?string { return $this->appId; } /** - * @param string $value + * @param ?string $value */ - public function setAppId(string $value): self + public function setAppId(?string $value = null): self { $this->appId = $value; return $this; @@ -506,17 +506,17 @@ public function setLasRequestAt(?int $value = null): self } /** - * @return int + * @return ?int */ - public function getCreatedAt(): int + public function getCreatedAt(): ?int { return $this->createdAt; } /** - * @param int $value + * @param ?int $value */ - public function setCreatedAt(int $value): self + public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; return $this; @@ -540,17 +540,17 @@ public function setRemoteCreatedAt(?int $value = null): self } /** - * @return int + * @return ?int */ - public function getSignedUpAt(): int + public function getSignedUpAt(): ?int { return $this->signedUpAt; } /** - * @param int $value + * @param ?int $value */ - public function setSignedUpAt(int $value): self + public function setSignedUpAt(?int $value = null): self { $this->signedUpAt = $value; return $this; diff --git a/src/Types/VisitorDeletedObject.php b/src/Types/VisitorDeletedObject.php index 4b9d586..b90fc8f 100644 --- a/src/Types/VisitorDeletedObject.php +++ b/src/Types/VisitorDeletedObject.php @@ -11,84 +11,84 @@ class VisitorDeletedObject extends JsonSerializableType { /** - * @var string $id The unique identifier for the visitor which is given by Intercom. + * @var ?string $id The unique identifier for the visitor which is given by Intercom. */ #[JsonProperty('id')] - private string $id; + private ?string $id; /** - * @var 'visitor' $type The type of object which was deleted + * @var ?'visitor' $type The type of object which was deleted */ #[JsonProperty('type')] - private string $type; + private ?string $type; /** - * @var string $userId Automatically generated identifier for the Visitor. + * @var ?string $userId Automatically generated identifier for the Visitor. */ #[JsonProperty('user_id')] - private string $userId; + private ?string $userId; /** * @param array{ - * id: string, - * type: 'visitor', - * userId: string, + * id?: ?string, + * type?: ?'visitor', + * userId?: ?string, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->id = $values['id']; - $this->type = $values['type']; - $this->userId = $values['userId']; + $this->id = $values['id'] ?? null; + $this->type = $values['type'] ?? null; + $this->userId = $values['userId'] ?? null; } /** - * @return string + * @return ?string */ - public function getId(): string + public function getId(): ?string { return $this->id; } /** - * @param string $value + * @param ?string $value */ - public function setId(string $value): self + public function setId(?string $value = null): self { $this->id = $value; return $this; } /** - * @return 'visitor' + * @return ?'visitor' */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'visitor' $value + * @param ?'visitor' $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return string + * @return ?string */ - public function getUserId(): string + public function getUserId(): ?string { return $this->userId; } /** - * @param string $value + * @param ?string $value */ - public function setUserId(string $value): self + public function setUserId(?string $value = null): self { $this->userId = $value; return $this; diff --git a/src/Types/WhatsappMessageStatusList.php b/src/Types/WhatsappMessageStatusList.php new file mode 100644 index 0000000..8ff477a --- /dev/null +++ b/src/Types/WhatsappMessageStatusList.php @@ -0,0 +1,152 @@ + $events + */ + #[JsonProperty('events'), ArrayType([WhatsappMessageStatusListEventsItem::class])] + private array $events; + + /** + * @param array{ + * type: 'list', + * rulesetId: string, + * pages: WhatsappMessageStatusListPages, + * totalCount: int, + * events: array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->type = $values['type']; + $this->rulesetId = $values['rulesetId']; + $this->pages = $values['pages']; + $this->totalCount = $values['totalCount']; + $this->events = $values['events']; + } + + /** + * @return 'list' + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param 'list' $value + */ + public function setType(string $value): self + { + $this->type = $value; + return $this; + } + + /** + * @return string + */ + public function getRulesetId(): string + { + return $this->rulesetId; + } + + /** + * @param string $value + */ + public function setRulesetId(string $value): self + { + $this->rulesetId = $value; + return $this; + } + + /** + * @return WhatsappMessageStatusListPages + */ + public function getPages(): WhatsappMessageStatusListPages + { + return $this->pages; + } + + /** + * @param WhatsappMessageStatusListPages $value + */ + public function setPages(WhatsappMessageStatusListPages $value): self + { + $this->pages = $value; + return $this; + } + + /** + * @return int + */ + public function getTotalCount(): int + { + return $this->totalCount; + } + + /** + * @param int $value + */ + public function setTotalCount(int $value): self + { + $this->totalCount = $value; + return $this; + } + + /** + * @return array + */ + public function getEvents(): array + { + return $this->events; + } + + /** + * @param array $value + */ + public function setEvents(array $value): self + { + $this->events = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/WhatsappMessageStatusListEventsItem.php b/src/Types/WhatsappMessageStatusListEventsItem.php new file mode 100644 index 0000000..9eb3715 --- /dev/null +++ b/src/Types/WhatsappMessageStatusListEventsItem.php @@ -0,0 +1,226 @@ + $status Current status of the message + */ + #[JsonProperty('status')] + private string $status; + + /** + * @var 'broadcast_outbound' $type Event type + */ + #[JsonProperty('type')] + private string $type; + + /** + * @var int $createdAt Creation timestamp + */ + #[JsonProperty('created_at')] + private int $createdAt; + + /** + * @var int $updatedAt Last update timestamp + */ + #[JsonProperty('updated_at')] + private int $updatedAt; + + /** + * @var string $whatsappMessageId WhatsApp's message identifier + */ + #[JsonProperty('whatsapp_message_id')] + private string $whatsappMessageId; + + /** + * @var ?string $templateName Name of the WhatsApp template used + */ + #[JsonProperty('template_name')] + private ?string $templateName; + + /** + * @param array{ + * id: string, + * conversationId: string, + * status: value-of, + * type: 'broadcast_outbound', + * createdAt: int, + * updatedAt: int, + * whatsappMessageId: string, + * templateName?: ?string, + * } $values + */ + public function __construct( + array $values, + ) { + $this->id = $values['id']; + $this->conversationId = $values['conversationId']; + $this->status = $values['status']; + $this->type = $values['type']; + $this->createdAt = $values['createdAt']; + $this->updatedAt = $values['updatedAt']; + $this->whatsappMessageId = $values['whatsappMessageId']; + $this->templateName = $values['templateName'] ?? null; + } + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $value + */ + public function setId(string $value): self + { + $this->id = $value; + return $this; + } + + /** + * @return string + */ + public function getConversationId(): string + { + return $this->conversationId; + } + + /** + * @param string $value + */ + public function setConversationId(string $value): self + { + $this->conversationId = $value; + return $this; + } + + /** + * @return value-of + */ + public function getStatus(): string + { + return $this->status; + } + + /** + * @param value-of $value + */ + public function setStatus(string $value): self + { + $this->status = $value; + return $this; + } + + /** + * @return 'broadcast_outbound' + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param 'broadcast_outbound' $value + */ + public function setType(string $value): self + { + $this->type = $value; + return $this; + } + + /** + * @return int + */ + public function getCreatedAt(): int + { + return $this->createdAt; + } + + /** + * @param int $value + */ + public function setCreatedAt(int $value): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return int + */ + public function getUpdatedAt(): int + { + return $this->updatedAt; + } + + /** + * @param int $value + */ + public function setUpdatedAt(int $value): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return string + */ + public function getWhatsappMessageId(): string + { + return $this->whatsappMessageId; + } + + /** + * @param string $value + */ + public function setWhatsappMessageId(string $value): self + { + $this->whatsappMessageId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getTemplateName(): ?string + { + return $this->templateName; + } + + /** + * @param ?string $value + */ + public function setTemplateName(?string $value = null): self + { + $this->templateName = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/WhatsappMessageStatusListEventsItemStatus.php b/src/Types/WhatsappMessageStatusListEventsItemStatus.php new file mode 100644 index 0000000..d97b01e --- /dev/null +++ b/src/Types/WhatsappMessageStatusListEventsItemStatus.php @@ -0,0 +1,11 @@ +type = $values['type']; + $this->perPage = $values['perPage']; + $this->totalPages = $values['totalPages']; + $this->next = $values['next'] ?? null; + } + + /** + * @return 'pages' + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param 'pages' $value + */ + public function setType(string $value): self + { + $this->type = $value; + return $this; + } + + /** + * @return int + */ + public function getPerPage(): int + { + return $this->perPage; + } + + /** + * @param int $value + */ + public function setPerPage(int $value): self + { + $this->perPage = $value; + return $this; + } + + /** + * @return int + */ + public function getTotalPages(): int + { + return $this->totalPages; + } + + /** + * @param int $value + */ + public function setTotalPages(int $value): self + { + $this->totalPages = $value; + return $this; + } + + /** + * @return ?WhatsappMessageStatusListPagesNext + */ + public function getNext(): ?WhatsappMessageStatusListPagesNext + { + return $this->next; + } + + /** + * @param ?WhatsappMessageStatusListPagesNext $value + */ + public function setNext(?WhatsappMessageStatusListPagesNext $value = null): self + { + $this->next = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Types/WhatsappMessageStatusListPagesNext.php b/src/Types/WhatsappMessageStatusListPagesNext.php new file mode 100644 index 0000000..1b112f4 --- /dev/null +++ b/src/Types/WhatsappMessageStatusListPagesNext.php @@ -0,0 +1,54 @@ +startingAfter = $values['startingAfter'] ?? null; + } + + /** + * @return ?string + */ + public function getStartingAfter(): ?string + { + return $this->startingAfter; + } + + /** + * @param ?string $value + */ + public function setStartingAfter(?string $value = null): self + { + $this->startingAfter = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/AiAgent/Types/AiAgent.php b/src/Unstable/AiAgent/Types/AiAgent.php index d2a66c1..d055de8 100644 --- a/src/Unstable/AiAgent/Types/AiAgent.php +++ b/src/Unstable/AiAgent/Types/AiAgent.php @@ -47,6 +47,18 @@ class AiAgent extends JsonSerializableType #[JsonProperty('rating_remark')] private ?string $ratingRemark; + /** + * @var ?int $createdAt The time when the AI agent rating was created. + */ + #[JsonProperty('created_at')] + private ?int $createdAt; + + /** + * @var ?int $updatedAt The time when the AI agent rating was last updated. + */ + #[JsonProperty('updated_at')] + private ?int $updatedAt; + /** * @var ?ContentSourcesList $contentSources */ @@ -61,6 +73,8 @@ class AiAgent extends JsonSerializableType * resolutionState?: ?string, * rating?: ?int, * ratingRemark?: ?string, + * createdAt?: ?int, + * updatedAt?: ?int, * contentSources?: ?ContentSourcesList, * } $values */ @@ -73,6 +87,8 @@ public function __construct( $this->resolutionState = $values['resolutionState'] ?? null; $this->rating = $values['rating'] ?? null; $this->ratingRemark = $values['ratingRemark'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; $this->contentSources = $values['contentSources'] ?? null; } @@ -178,6 +194,40 @@ public function setRatingRemark(?string $value = null): self return $this; } + /** + * @return ?int + */ + public function getCreatedAt(): ?int + { + return $this->createdAt; + } + + /** + * @param ?int $value + */ + public function setCreatedAt(?int $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getUpdatedAt(): ?int + { + return $this->updatedAt; + } + + /** + * @param ?int $value + */ + public function setUpdatedAt(?int $value = null): self + { + $this->updatedAt = $value; + return $this; + } + /** * @return ?ContentSourcesList */ diff --git a/src/Unstable/Brands/BrandsClient.php b/src/Unstable/Brands/BrandsClient.php new file mode 100644 index 0000000..6fe54cc --- /dev/null +++ b/src/Unstable/Brands/BrandsClient.php @@ -0,0 +1,164 @@ +, + * } $options + */ + private array $options; + + /** + * @var RawClient $client + */ + private RawClient $client; + + /** + * @param RawClient $client + * @param ?array{ + * baseUrl?: string, + * client?: ClientInterface, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * } $options + */ + public function __construct( + RawClient $client, + ?array $options = null, + ) { + $this->client = $client; + $this->options = $options ?? []; + } + + /** + * Retrieves all brands for the workspace, including the default brand. + * The default brand id always matches the workspace + * + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return BrandList + * @throws IntercomException + * @throws IntercomApiException + */ + public function listBrands(?array $options = null): BrandList + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "brands", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return BrandList::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Fetches a specific brand by its unique identifier + * + * @param RetrieveBrandRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return Brand + * @throws IntercomException + * @throws IntercomApiException + */ + public function retrieveBrand(RetrieveBrandRequest $request, ?array $options = null): Brand + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "brands/{$request->getId()}", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return Brand::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } +} diff --git a/src/Unstable/Brands/Requests/RetrieveBrandRequest.php b/src/Unstable/Brands/Requests/RetrieveBrandRequest.php new file mode 100644 index 0000000..4341267 --- /dev/null +++ b/src/Unstable/Brands/Requests/RetrieveBrandRequest.php @@ -0,0 +1,41 @@ +id = $values['id']; + } + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $value + */ + public function setId(string $value): self + { + $this->id = $value; + return $this; + } +} diff --git a/src/Unstable/Brands/Types/Brand.php b/src/Unstable/Brands/Types/Brand.php new file mode 100644 index 0000000..e1206d2 --- /dev/null +++ b/src/Unstable/Brands/Types/Brand.php @@ -0,0 +1,229 @@ +type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->name = $values['name'] ?? null; + $this->isDefault = $values['isDefault'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->helpCenterId = $values['helpCenterId'] ?? null; + $this->defaultAddressSettingsId = $values['defaultAddressSettingsId'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getIsDefault(): ?bool + { + return $this->isDefault; + } + + /** + * @param ?bool $value + */ + public function setIsDefault(?bool $value = null): self + { + $this->isDefault = $value; + return $this; + } + + /** + * @return ?int + */ + public function getCreatedAt(): ?int + { + return $this->createdAt; + } + + /** + * @param ?int $value + */ + public function setCreatedAt(?int $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getUpdatedAt(): ?int + { + return $this->updatedAt; + } + + /** + * @param ?int $value + */ + public function setUpdatedAt(?int $value = null): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return ?string + */ + public function getHelpCenterId(): ?string + { + return $this->helpCenterId; + } + + /** + * @param ?string $value + */ + public function setHelpCenterId(?string $value = null): self + { + $this->helpCenterId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getDefaultAddressSettingsId(): ?string + { + return $this->defaultAddressSettingsId; + } + + /** + * @param ?string $value + */ + public function setDefaultAddressSettingsId(?string $value = null): self + { + $this->defaultAddressSettingsId = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Brands/Types/BrandList.php b/src/Unstable/Brands/Types/BrandList.php new file mode 100644 index 0000000..90cade1 --- /dev/null +++ b/src/Unstable/Brands/Types/BrandList.php @@ -0,0 +1,80 @@ + $data + */ + #[JsonProperty('data'), ArrayType([Brand::class])] + private ?array $data; + + /** + * @param array{ + * type?: ?string, + * data?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?array + */ + public function getData(): ?array + { + return $this->data; + } + + /** + * @param ?array $value + */ + public function setData(?array $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Calls/CallsClient.php b/src/Unstable/Calls/CallsClient.php new file mode 100644 index 0000000..c7a50b4 --- /dev/null +++ b/src/Unstable/Calls/CallsClient.php @@ -0,0 +1,337 @@ +, + * } $options + */ + private array $options; + + /** + * @var RawClient $client + */ + private RawClient $client; + + /** + * @param RawClient $client + * @param ?array{ + * baseUrl?: string, + * client?: ClientInterface, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * } $options + */ + public function __construct( + RawClient $client, + ?array $options = null, + ) { + $this->client = $client; + $this->options = $options ?? []; + } + + /** + * Retrieve a paginated list of calls. + * + * @param ListCallsRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return CallList + * @throws IntercomException + * @throws IntercomApiException + */ + public function listCalls(ListCallsRequest $request = new ListCallsRequest(), ?array $options = null): CallList + { + $options = array_merge($this->options, $options ?? []); + $query = []; + if ($request->getPage() != null) { + $query['page'] = $request->getPage(); + } + if ($request->getPerPage() != null) { + $query['per_page'] = $request->getPerPage(); + } + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "calls", + method: HttpMethod::GET, + query: $query, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return CallList::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Retrieve a single call by id. + * + * @param ShowCallRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return Call + * @throws IntercomException + * @throws IntercomApiException + */ + public function showCall(ShowCallRequest $request, ?array $options = null): Call + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "calls/{$request->getId()}", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return Call::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Redirects to a signed URL for the call's recording if it exists. + * + * @param ShowCallRecordingRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @throws IntercomException + * @throws IntercomApiException + */ + public function showCallRecording(ShowCallRecordingRequest $request, ?array $options = null): void + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "calls/{$request->getId()}/recording", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + return; + } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Returns the transcript for the specified call as a downloadable text file. + * + * @param ShowCallTranscriptRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return string + * @throws IntercomException + * @throws IntercomApiException + */ + public function showCallTranscript(ShowCallTranscriptRequest $request, ?array $options = null): string + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "calls/{$request->getId()}/transcript", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + return $response->getBody()->getContents(); + } + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Retrieve calls by a list of conversation ids and include transcripts when available. + * A maximum of 20 `conversation_ids` can be provided. If none are provided or more than 20 are provided, a 400 error is returned. + * + * @param ListCallsWithTranscriptsRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return ListCallsWithTranscriptsResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function listCallsWithTranscripts(ListCallsWithTranscriptsRequest $request, ?array $options = null): ListCallsWithTranscriptsResponse + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "calls/search", + method: HttpMethod::POST, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return ListCallsWithTranscriptsResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } +} diff --git a/src/Unstable/Calls/Requests/ListCallsRequest.php b/src/Unstable/Calls/Requests/ListCallsRequest.php new file mode 100644 index 0000000..69cf13c --- /dev/null +++ b/src/Unstable/Calls/Requests/ListCallsRequest.php @@ -0,0 +1,65 @@ +page = $values['page'] ?? null; + $this->perPage = $values['perPage'] ?? null; + } + + /** + * @return ?int + */ + public function getPage(): ?int + { + return $this->page; + } + + /** + * @param ?int $value + */ + public function setPage(?int $value = null): self + { + $this->page = $value; + return $this; + } + + /** + * @return ?int + */ + public function getPerPage(): ?int + { + return $this->perPage; + } + + /** + * @param ?int $value + */ + public function setPerPage(?int $value = null): self + { + $this->perPage = $value; + return $this; + } +} diff --git a/src/Unstable/Calls/Requests/ListCallsWithTranscriptsRequest.php b/src/Unstable/Calls/Requests/ListCallsWithTranscriptsRequest.php new file mode 100644 index 0000000..58d704a --- /dev/null +++ b/src/Unstable/Calls/Requests/ListCallsWithTranscriptsRequest.php @@ -0,0 +1,44 @@ + $conversationIds A list of conversation ids to fetch calls for. Maximum 20. + */ + #[JsonProperty('conversation_ids'), ArrayType(['string'])] + private array $conversationIds; + + /** + * @param array{ + * conversationIds: array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->conversationIds = $values['conversationIds']; + } + + /** + * @return array + */ + public function getConversationIds(): array + { + return $this->conversationIds; + } + + /** + * @param array $value + */ + public function setConversationIds(array $value): self + { + $this->conversationIds = $value; + return $this; + } +} diff --git a/src/Unstable/Calls/Requests/ShowCallRecordingRequest.php b/src/Unstable/Calls/Requests/ShowCallRecordingRequest.php new file mode 100644 index 0000000..71adbfe --- /dev/null +++ b/src/Unstable/Calls/Requests/ShowCallRecordingRequest.php @@ -0,0 +1,41 @@ +id = $values['id']; + } + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $value + */ + public function setId(string $value): self + { + $this->id = $value; + return $this; + } +} diff --git a/src/Unstable/Calls/Requests/ShowCallRequest.php b/src/Unstable/Calls/Requests/ShowCallRequest.php new file mode 100644 index 0000000..f571778 --- /dev/null +++ b/src/Unstable/Calls/Requests/ShowCallRequest.php @@ -0,0 +1,41 @@ +id = $values['id']; + } + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $value + */ + public function setId(string $value): self + { + $this->id = $value; + return $this; + } +} diff --git a/src/Unstable/Calls/Requests/ShowCallTranscriptRequest.php b/src/Unstable/Calls/Requests/ShowCallTranscriptRequest.php new file mode 100644 index 0000000..a5b7e88 --- /dev/null +++ b/src/Unstable/Calls/Requests/ShowCallTranscriptRequest.php @@ -0,0 +1,41 @@ +id = $values['id']; + } + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $value + */ + public function setId(string $value): self + { + $this->id = $value; + return $this; + } +} diff --git a/src/Unstable/Calls/Traits/Call.php b/src/Unstable/Calls/Traits/Call.php new file mode 100644 index 0000000..12c0927 --- /dev/null +++ b/src/Unstable/Calls/Traits/Call.php @@ -0,0 +1,506 @@ +type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getConversationId(): ?string + { + return $this->conversationId; + } + + /** + * @param ?string $value + */ + public function setConversationId(?string $value = null): self + { + $this->conversationId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getAdminId(): ?string + { + return $this->adminId; + } + + /** + * @param ?string $value + */ + public function setAdminId(?string $value = null): self + { + $this->adminId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getContactId(): ?string + { + return $this->contactId; + } + + /** + * @param ?string $value + */ + public function setContactId(?string $value = null): self + { + $this->contactId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getState(): ?string + { + return $this->state; + } + + /** + * @param ?string $value + */ + public function setState(?string $value = null): self + { + $this->state = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getInitiatedAt(): DateTime|int|null + { + return $this->initiatedAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setInitiatedAt(DateTime|int|null $value = null): self + { + $this->initiatedAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getAnsweredAt(): DateTime|int|null + { + return $this->answeredAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setAnsweredAt(DateTime|int|null $value = null): self + { + $this->answeredAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getEndedAt(): DateTime|int|null + { + return $this->endedAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setEndedAt(DateTime|int|null $value = null): self + { + $this->endedAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getCreatedAt(): DateTime|int|null + { + return $this->createdAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setCreatedAt(DateTime|int|null $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getUpdatedAt(): DateTime|int|null + { + return $this->updatedAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setUpdatedAt(DateTime|int|null $value = null): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return ?string + */ + public function getRecordingUrl(): ?string + { + return $this->recordingUrl; + } + + /** + * @param ?string $value + */ + public function setRecordingUrl(?string $value = null): self + { + $this->recordingUrl = $value; + return $this; + } + + /** + * @return ?string + */ + public function getCallType(): ?string + { + return $this->callType; + } + + /** + * @param ?string $value + */ + public function setCallType(?string $value = null): self + { + $this->callType = $value; + return $this; + } + + /** + * @return ?string + */ + public function getDirection(): ?string + { + return $this->direction; + } + + /** + * @param ?string $value + */ + public function setDirection(?string $value = null): self + { + $this->direction = $value; + return $this; + } + + /** + * @return ?string + */ + public function getEndedReason(): ?string + { + return $this->endedReason; + } + + /** + * @param ?string $value + */ + public function setEndedReason(?string $value = null): self + { + $this->endedReason = $value; + return $this; + } + + /** + * @return ?string + */ + public function getPhone(): ?string + { + return $this->phone; + } + + /** + * @param ?string $value + */ + public function setPhone(?string $value = null): self + { + $this->phone = $value; + return $this; + } + + /** + * @return ?string + */ + public function getFinRecordingUrl(): ?string + { + return $this->finRecordingUrl; + } + + /** + * @param ?string $value + */ + public function setFinRecordingUrl(?string $value = null): self + { + $this->finRecordingUrl = $value; + return $this; + } + + /** + * @return ?string + */ + public function getFinTranscriptionUrl(): ?string + { + return $this->finTranscriptionUrl; + } + + /** + * @param ?string $value + */ + public function setFinTranscriptionUrl(?string $value = null): self + { + $this->finTranscriptionUrl = $value; + return $this; + } +} diff --git a/src/Unstable/Calls/Types/Call.php b/src/Unstable/Calls/Types/Call.php new file mode 100644 index 0000000..f9158ba --- /dev/null +++ b/src/Unstable/Calls/Types/Call.php @@ -0,0 +1,541 @@ +type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->conversationId = $values['conversationId'] ?? null; + $this->adminId = $values['adminId'] ?? null; + $this->contactId = $values['contactId'] ?? null; + $this->state = $values['state'] ?? null; + $this->initiatedAt = $values['initiatedAt'] ?? null; + $this->answeredAt = $values['answeredAt'] ?? null; + $this->endedAt = $values['endedAt'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->recordingUrl = $values['recordingUrl'] ?? null; + $this->callType = $values['callType'] ?? null; + $this->direction = $values['direction'] ?? null; + $this->endedReason = $values['endedReason'] ?? null; + $this->phone = $values['phone'] ?? null; + $this->finRecordingUrl = $values['finRecordingUrl'] ?? null; + $this->finTranscriptionUrl = $values['finTranscriptionUrl'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getConversationId(): ?string + { + return $this->conversationId; + } + + /** + * @param ?string $value + */ + public function setConversationId(?string $value = null): self + { + $this->conversationId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getAdminId(): ?string + { + return $this->adminId; + } + + /** + * @param ?string $value + */ + public function setAdminId(?string $value = null): self + { + $this->adminId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getContactId(): ?string + { + return $this->contactId; + } + + /** + * @param ?string $value + */ + public function setContactId(?string $value = null): self + { + $this->contactId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getState(): ?string + { + return $this->state; + } + + /** + * @param ?string $value + */ + public function setState(?string $value = null): self + { + $this->state = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getInitiatedAt(): DateTime|int|null + { + return $this->initiatedAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setInitiatedAt(DateTime|int|null $value = null): self + { + $this->initiatedAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getAnsweredAt(): DateTime|int|null + { + return $this->answeredAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setAnsweredAt(DateTime|int|null $value = null): self + { + $this->answeredAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getEndedAt(): DateTime|int|null + { + return $this->endedAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setEndedAt(DateTime|int|null $value = null): self + { + $this->endedAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getCreatedAt(): DateTime|int|null + { + return $this->createdAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setCreatedAt(DateTime|int|null $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ( + * DateTime + * |int + * )|null + */ + public function getUpdatedAt(): DateTime|int|null + { + return $this->updatedAt; + } + + /** + * @param ( + * DateTime + * |int + * )|null $value + */ + public function setUpdatedAt(DateTime|int|null $value = null): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return ?string + */ + public function getRecordingUrl(): ?string + { + return $this->recordingUrl; + } + + /** + * @param ?string $value + */ + public function setRecordingUrl(?string $value = null): self + { + $this->recordingUrl = $value; + return $this; + } + + /** + * @return ?string + */ + public function getCallType(): ?string + { + return $this->callType; + } + + /** + * @param ?string $value + */ + public function setCallType(?string $value = null): self + { + $this->callType = $value; + return $this; + } + + /** + * @return ?string + */ + public function getDirection(): ?string + { + return $this->direction; + } + + /** + * @param ?string $value + */ + public function setDirection(?string $value = null): self + { + $this->direction = $value; + return $this; + } + + /** + * @return ?string + */ + public function getEndedReason(): ?string + { + return $this->endedReason; + } + + /** + * @param ?string $value + */ + public function setEndedReason(?string $value = null): self + { + $this->endedReason = $value; + return $this; + } + + /** + * @return ?string + */ + public function getPhone(): ?string + { + return $this->phone; + } + + /** + * @param ?string $value + */ + public function setPhone(?string $value = null): self + { + $this->phone = $value; + return $this; + } + + /** + * @return ?string + */ + public function getFinRecordingUrl(): ?string + { + return $this->finRecordingUrl; + } + + /** + * @param ?string $value + */ + public function setFinRecordingUrl(?string $value = null): self + { + $this->finRecordingUrl = $value; + return $this; + } + + /** + * @return ?string + */ + public function getFinTranscriptionUrl(): ?string + { + return $this->finTranscriptionUrl; + } + + /** + * @param ?string $value + */ + public function setFinTranscriptionUrl(?string $value = null): self + { + $this->finTranscriptionUrl = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Calls/Types/ListCallsWithTranscriptsResponse.php b/src/Unstable/Calls/Types/ListCallsWithTranscriptsResponse.php new file mode 100644 index 0000000..1852a5c --- /dev/null +++ b/src/Unstable/Calls/Types/ListCallsWithTranscriptsResponse.php @@ -0,0 +1,77 @@ + $data + */ + #[JsonProperty('data'), ArrayType([ListCallsWithTranscriptsResponseDataItem::class])] + private ?array $data; + + /** + * @param array{ + * type?: ?string, + * data?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?array + */ + public function getData(): ?array + { + return $this->data; + } + + /** + * @param ?array $value + */ + public function setData(?array $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Calls/Types/ListCallsWithTranscriptsResponseDataItem.php b/src/Unstable/Calls/Types/ListCallsWithTranscriptsResponseDataItem.php new file mode 100644 index 0000000..ce76008 --- /dev/null +++ b/src/Unstable/Calls/Types/ListCallsWithTranscriptsResponseDataItem.php @@ -0,0 +1,132 @@ +> $transcript The call transcript if available, otherwise an empty array. + */ + #[JsonProperty('transcript'), ArrayType([['string' => 'mixed']])] + private ?array $transcript; + + /** + * @var ?string $transcriptStatus The status of the transcript if available. + */ + #[JsonProperty('transcript_status')] + private ?string $transcriptStatus; + + /** + * @param array{ + * type?: ?string, + * id?: ?string, + * conversationId?: ?string, + * adminId?: ?string, + * contactId?: ?string, + * state?: ?string, + * initiatedAt?: ( + * DateTime + * |int + * )|null, + * answeredAt?: ( + * DateTime + * |int + * )|null, + * endedAt?: ( + * DateTime + * |int + * )|null, + * createdAt?: ( + * DateTime + * |int + * )|null, + * updatedAt?: ( + * DateTime + * |int + * )|null, + * recordingUrl?: ?string, + * callType?: ?string, + * direction?: ?string, + * endedReason?: ?string, + * phone?: ?string, + * finRecordingUrl?: ?string, + * finTranscriptionUrl?: ?string, + * transcript?: ?array>, + * transcriptStatus?: ?string, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->conversationId = $values['conversationId'] ?? null; + $this->adminId = $values['adminId'] ?? null; + $this->contactId = $values['contactId'] ?? null; + $this->state = $values['state'] ?? null; + $this->initiatedAt = $values['initiatedAt'] ?? null; + $this->answeredAt = $values['answeredAt'] ?? null; + $this->endedAt = $values['endedAt'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->recordingUrl = $values['recordingUrl'] ?? null; + $this->callType = $values['callType'] ?? null; + $this->direction = $values['direction'] ?? null; + $this->endedReason = $values['endedReason'] ?? null; + $this->phone = $values['phone'] ?? null; + $this->finRecordingUrl = $values['finRecordingUrl'] ?? null; + $this->finTranscriptionUrl = $values['finTranscriptionUrl'] ?? null; + $this->transcript = $values['transcript'] ?? null; + $this->transcriptStatus = $values['transcriptStatus'] ?? null; + } + + /** + * @return ?array> + */ + public function getTranscript(): ?array + { + return $this->transcript; + } + + /** + * @param ?array> $value + */ + public function setTranscript(?array $value = null): self + { + $this->transcript = $value; + return $this; + } + + /** + * @return ?string + */ + public function getTranscriptStatus(): ?string + { + return $this->transcriptStatus; + } + + /** + * @param ?string $value + */ + public function setTranscriptStatus(?string $value = null): self + { + $this->transcriptStatus = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Conversations/ConversationsClient.php b/src/Unstable/Conversations/ConversationsClient.php index 473ac82..65b8fd1 100644 --- a/src/Unstable/Conversations/ConversationsClient.php +++ b/src/Unstable/Conversations/ConversationsClient.php @@ -231,6 +231,9 @@ public function retrieveConversation(RetrieveConversationRequest $request, ?arra if ($request->getDisplayAs() != null) { $query['display_as'] = $request->getDisplayAs(); } + if ($request->getIncludeTranslations() != null) { + $query['include_translations'] = $request->getIncludeTranslations(); + } try { $response = $this->client->sendRequest( new JsonApiRequest( diff --git a/src/Unstable/Conversations/Requests/RetrieveConversationRequest.php b/src/Unstable/Conversations/Requests/RetrieveConversationRequest.php index b549593..b79db62 100644 --- a/src/Unstable/Conversations/Requests/RetrieveConversationRequest.php +++ b/src/Unstable/Conversations/Requests/RetrieveConversationRequest.php @@ -16,10 +16,16 @@ class RetrieveConversationRequest extends JsonSerializableType */ private ?string $displayAs; + /** + * @var ?bool $includeTranslations If set to true, conversation parts will be translated to the detected language of the conversation. + */ + private ?bool $includeTranslations; + /** * @param array{ * id: int, * displayAs?: ?string, + * includeTranslations?: ?bool, * } $values */ public function __construct( @@ -27,6 +33,7 @@ public function __construct( ) { $this->id = $values['id']; $this->displayAs = $values['displayAs'] ?? null; + $this->includeTranslations = $values['includeTranslations'] ?? null; } /** @@ -62,4 +69,21 @@ public function setDisplayAs(?string $value = null): self $this->displayAs = $value; return $this; } + + /** + * @return ?bool + */ + public function getIncludeTranslations(): ?bool + { + return $this->includeTranslations; + } + + /** + * @param ?bool $value + */ + public function setIncludeTranslations(?bool $value = null): self + { + $this->includeTranslations = $value; + return $this; + } } diff --git a/src/Unstable/DataAttributes/DataAttributesClient.php b/src/Unstable/DataAttributes/DataAttributesClient.php index 0a74aec..9d9d93c 100644 --- a/src/Unstable/DataAttributes/DataAttributesClient.php +++ b/src/Unstable/DataAttributes/DataAttributesClient.php @@ -14,7 +14,6 @@ use JsonException; use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; -use Intercom\Unstable\DataAttributes\Requests\CreateDataAttributeRequest; use Intercom\Unstable\DataAttributes\Types\DataAttribute; use Intercom\Unstable\DataAttributes\Requests\UpdateDataAttributeRequest; @@ -120,7 +119,7 @@ public function lisDataAttributes(LisDataAttributesRequest $request = new LisDat /** * You can create a data attributes for a `contact` or a `company`. * - * @param CreateDataAttributeRequest $request + * @param mixed $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -133,7 +132,7 @@ public function lisDataAttributes(LisDataAttributesRequest $request = new LisDat * @throws IntercomException * @throws IntercomApiException */ - public function createDataAttribute(CreateDataAttributeRequest $request, ?array $options = null): DataAttribute + public function createDataAttribute(mixed $request, ?array $options = null): DataAttribute { $options = array_merge($this->options, $options ?? []); try { @@ -203,7 +202,7 @@ public function updateDataAttribute(UpdateDataAttributeRequest $request, ?array baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, path: "data_attributes/{$request->getId()}", method: HttpMethod::PUT, - body: $request, + body: $request->getBody(), ), $options, ); diff --git a/src/Unstable/DataAttributes/Requests/CreateDataAttributeRequest.php b/src/Unstable/DataAttributes/Requests/CreateDataAttributeRequest.php deleted file mode 100644 index 06625dd..0000000 --- a/src/Unstable/DataAttributes/Requests/CreateDataAttributeRequest.php +++ /dev/null @@ -1,171 +0,0 @@ - $model The model that the data attribute belongs to. - */ - #[JsonProperty('model')] - private string $model; - - /** - * @var value-of $dataType The type of data stored for this attribute. - */ - #[JsonProperty('data_type')] - private string $dataType; - - /** - * @var ?string $description The readable description you see in the UI for the attribute. - */ - #[JsonProperty('description')] - private ?string $description; - - /** - * @var ?array $options To create list attributes. Provide a set of hashes with `value` as the key of the options you want to make. `data_type` must be `string`. - */ - #[JsonProperty('options'), ArrayType(['string'])] - private ?array $options; - - /** - * @var ?bool $messengerWritable Can this attribute be updated by the Messenger - */ - #[JsonProperty('messenger_writable')] - private ?bool $messengerWritable; - - /** - * @param array{ - * name: string, - * model: value-of, - * dataType: value-of, - * description?: ?string, - * options?: ?array, - * messengerWritable?: ?bool, - * } $values - */ - public function __construct( - array $values, - ) { - $this->name = $values['name']; - $this->model = $values['model']; - $this->dataType = $values['dataType']; - $this->description = $values['description'] ?? null; - $this->options = $values['options'] ?? null; - $this->messengerWritable = $values['messengerWritable'] ?? null; - } - - /** - * @return string - */ - public function getName(): string - { - return $this->name; - } - - /** - * @param string $value - */ - public function setName(string $value): self - { - $this->name = $value; - return $this; - } - - /** - * @return value-of - */ - public function getModel(): string - { - return $this->model; - } - - /** - * @param value-of $value - */ - public function setModel(string $value): self - { - $this->model = $value; - return $this; - } - - /** - * @return value-of - */ - public function getDataType(): string - { - return $this->dataType; - } - - /** - * @param value-of $value - */ - public function setDataType(string $value): self - { - $this->dataType = $value; - return $this; - } - - /** - * @return ?string - */ - public function getDescription(): ?string - { - return $this->description; - } - - /** - * @param ?string $value - */ - public function setDescription(?string $value = null): self - { - $this->description = $value; - return $this; - } - - /** - * @return ?array - */ - public function getOptions(): ?array - { - return $this->options; - } - - /** - * @param ?array $value - */ - public function setOptions(?array $value = null): self - { - $this->options = $value; - return $this; - } - - /** - * @return ?bool - */ - public function getMessengerWritable(): ?bool - { - return $this->messengerWritable; - } - - /** - * @param ?bool $value - */ - public function setMessengerWritable(?bool $value = null): self - { - $this->messengerWritable = $value; - return $this; - } -} diff --git a/src/Unstable/DataAttributes/Requests/UpdateDataAttributeRequest.php b/src/Unstable/DataAttributes/Requests/UpdateDataAttributeRequest.php index 5036ad4..f25e038 100644 --- a/src/Unstable/DataAttributes/Requests/UpdateDataAttributeRequest.php +++ b/src/Unstable/DataAttributes/Requests/UpdateDataAttributeRequest.php @@ -3,8 +3,6 @@ namespace Intercom\Unstable\DataAttributes\Requests; use Intercom\Core\Json\JsonSerializableType; -use Intercom\Core\Json\JsonProperty; -use Intercom\Core\Types\ArrayType; class UpdateDataAttributeRequest extends JsonSerializableType { @@ -14,46 +12,21 @@ class UpdateDataAttributeRequest extends JsonSerializableType private int $id; /** - * @var ?bool $archived Whether the attribute is to be archived or not. + * @var mixed $body */ - #[JsonProperty('archived')] - private ?bool $archived; - - /** - * @var ?string $description The readable description you see in the UI for the attribute. - */ - #[JsonProperty('description')] - private ?string $description; - - /** - * @var ?array $options To create list attributes. Provide a set of hashes with `value` as the key of the options you want to make. `data_type` must be `string`. - */ - #[JsonProperty('options'), ArrayType(['string'])] - private ?array $options; - - /** - * @var ?bool $messengerWritable Can this attribute be updated by the Messenger - */ - #[JsonProperty('messenger_writable')] - private ?bool $messengerWritable; + private mixed $body; /** * @param array{ * id: int, - * archived?: ?bool, - * description?: ?string, - * options?: ?array, - * messengerWritable?: ?bool, + * body: mixed, * } $values */ public function __construct( array $values, ) { $this->id = $values['id']; - $this->archived = $values['archived'] ?? null; - $this->description = $values['description'] ?? null; - $this->options = $values['options'] ?? null; - $this->messengerWritable = $values['messengerWritable'] ?? null; + $this->body = $values['body']; } /** @@ -74,70 +47,19 @@ public function setId(int $value): self } /** - * @return ?bool - */ - public function getArchived(): ?bool - { - return $this->archived; - } - - /** - * @param ?bool $value - */ - public function setArchived(?bool $value = null): self - { - $this->archived = $value; - return $this; - } - - /** - * @return ?string - */ - public function getDescription(): ?string - { - return $this->description; - } - - /** - * @param ?string $value - */ - public function setDescription(?string $value = null): self - { - $this->description = $value; - return $this; - } - - /** - * @return ?array - */ - public function getOptions(): ?array - { - return $this->options; - } - - /** - * @param ?array $value - */ - public function setOptions(?array $value = null): self - { - $this->options = $value; - return $this; - } - - /** - * @return ?bool + * @return mixed */ - public function getMessengerWritable(): ?bool + public function getBody(): mixed { - return $this->messengerWritable; + return $this->body; } /** - * @param ?bool $value + * @param mixed $value */ - public function setMessengerWritable(?bool $value = null): self + public function setBody(mixed $value): self { - $this->messengerWritable = $value; + $this->body = $value; return $this; } } diff --git a/src/Unstable/DataAttributes/Types/CreateDataAttributeRequestModel.php b/src/Unstable/DataAttributes/Types/CreateDataAttributeRequestModel.php deleted file mode 100644 index 414b329..0000000 --- a/src/Unstable/DataAttributes/Types/CreateDataAttributeRequestModel.php +++ /dev/null @@ -1,9 +0,0 @@ -, + * } $options + */ + private array $options; + + /** + * @var RawClient $client + */ + private RawClient $client; + + /** + * @param RawClient $client + * @param ?array{ + * baseUrl?: string, + * client?: ClientInterface, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * } $options + */ + public function __construct( + RawClient $client, + ?array $options = null, + ) { + $this->client = $client; + $this->options = $options ?? []; + } + + /** + * Lists all sender email address settings for the workspace + * + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return EmailList + * @throws IntercomException + * @throws IntercomApiException + */ + public function listEmails(?array $options = null): EmailList + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "emails", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return EmailList::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * Fetches a specific email setting by its unique identifier + * + * @param RetrieveEmailRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return EmailSetting + * @throws IntercomException + * @throws IntercomApiException + */ + public function retrieveEmail(RetrieveEmailRequest $request, ?array $options = null): EmailSetting + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "emails/{$request->getId()}", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return EmailSetting::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } +} diff --git a/src/Unstable/Emails/Requests/RetrieveEmailRequest.php b/src/Unstable/Emails/Requests/RetrieveEmailRequest.php new file mode 100644 index 0000000..467a677 --- /dev/null +++ b/src/Unstable/Emails/Requests/RetrieveEmailRequest.php @@ -0,0 +1,41 @@ +id = $values['id']; + } + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $value + */ + public function setId(string $value): self + { + $this->id = $value; + return $this; + } +} diff --git a/src/Unstable/Emails/Types/EmailList.php b/src/Unstable/Emails/Types/EmailList.php new file mode 100644 index 0000000..a9e4074 --- /dev/null +++ b/src/Unstable/Emails/Types/EmailList.php @@ -0,0 +1,80 @@ + $data + */ + #[JsonProperty('data'), ArrayType([EmailSetting::class])] + private ?array $data; + + /** + * @param array{ + * type?: ?string, + * data?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?array + */ + public function getData(): ?array + { + return $this->data; + } + + /** + * @param ?array $value + */ + public function setData(?array $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Emails/Types/EmailSetting.php b/src/Unstable/Emails/Types/EmailSetting.php new file mode 100644 index 0000000..d90b86b --- /dev/null +++ b/src/Unstable/Emails/Types/EmailSetting.php @@ -0,0 +1,279 @@ +type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->email = $values['email'] ?? null; + $this->verified = $values['verified'] ?? null; + $this->domain = $values['domain'] ?? null; + $this->brandId = $values['brandId'] ?? null; + $this->forwardingEnabled = $values['forwardingEnabled'] ?? null; + $this->forwardedEmailLastReceivedAt = $values['forwardedEmailLastReceivedAt'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + } + + /** + * @return ?string + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?string $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getEmail(): ?string + { + return $this->email; + } + + /** + * @param ?string $value + */ + public function setEmail(?string $value = null): self + { + $this->email = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getVerified(): ?bool + { + return $this->verified; + } + + /** + * @param ?bool $value + */ + public function setVerified(?bool $value = null): self + { + $this->verified = $value; + return $this; + } + + /** + * @return ?string + */ + public function getDomain(): ?string + { + return $this->domain; + } + + /** + * @param ?string $value + */ + public function setDomain(?string $value = null): self + { + $this->domain = $value; + return $this; + } + + /** + * @return ?string + */ + public function getBrandId(): ?string + { + return $this->brandId; + } + + /** + * @param ?string $value + */ + public function setBrandId(?string $value = null): self + { + $this->brandId = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getForwardingEnabled(): ?bool + { + return $this->forwardingEnabled; + } + + /** + * @param ?bool $value + */ + public function setForwardingEnabled(?bool $value = null): self + { + $this->forwardingEnabled = $value; + return $this; + } + + /** + * @return ?int + */ + public function getForwardedEmailLastReceivedAt(): ?int + { + return $this->forwardedEmailLastReceivedAt; + } + + /** + * @param ?int $value + */ + public function setForwardedEmailLastReceivedAt(?int $value = null): self + { + $this->forwardedEmailLastReceivedAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getCreatedAt(): ?int + { + return $this->createdAt; + } + + /** + * @param ?int $value + */ + public function setCreatedAt(?int $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getUpdatedAt(): ?int + { + return $this->updatedAt; + } + + /** + * @param ?int $value + */ + public function setUpdatedAt(?int $value = null): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/HelpCenter/Types/HelpCenter.php b/src/Unstable/HelpCenter/Types/HelpCenter.php index bafc7ab..2d33002 100644 --- a/src/Unstable/HelpCenter/Types/HelpCenter.php +++ b/src/Unstable/HelpCenter/Types/HelpCenter.php @@ -52,6 +52,18 @@ class HelpCenter extends JsonSerializableType #[JsonProperty('display_name')] private ?string $displayName; + /** + * @var ?string $url The URL for the help center, if you have a custom domain then this will show the URL using the custom domain. + */ + #[JsonProperty('url')] + private ?string $url; + + /** + * @var ?string $customDomain Custom domain configured for the help center + */ + #[JsonProperty('custom_domain')] + private ?string $customDomain; + /** * @param array{ * id?: ?string, @@ -61,6 +73,8 @@ class HelpCenter extends JsonSerializableType * identifier?: ?string, * websiteTurnedOn?: ?bool, * displayName?: ?string, + * url?: ?string, + * customDomain?: ?string, * } $values */ public function __construct( @@ -73,6 +87,8 @@ public function __construct( $this->identifier = $values['identifier'] ?? null; $this->websiteTurnedOn = $values['websiteTurnedOn'] ?? null; $this->displayName = $values['displayName'] ?? null; + $this->url = $values['url'] ?? null; + $this->customDomain = $values['customDomain'] ?? null; } /** @@ -194,6 +210,40 @@ public function setDisplayName(?string $value = null): self return $this; } + /** + * @return ?string + */ + public function getUrl(): ?string + { + return $this->url; + } + + /** + * @param ?string $value + */ + public function setUrl(?string $value = null): self + { + $this->url = $value; + return $this; + } + + /** + * @return ?string + */ + public function getCustomDomain(): ?string + { + return $this->customDomain; + } + + /** + * @param ?string $value + */ + public function setCustomDomain(?string $value = null): self + { + $this->customDomain = $value; + return $this; + } + /** * @return string */ diff --git a/src/Unstable/InternalArticles/InternalArticlesClient.php b/src/Unstable/InternalArticles/InternalArticlesClient.php new file mode 100644 index 0000000..1f4e277 --- /dev/null +++ b/src/Unstable/InternalArticles/InternalArticlesClient.php @@ -0,0 +1,396 @@ +, + * } $options + */ + private array $options; + + /** + * @var RawClient $client + */ + private RawClient $client; + + /** + * @param RawClient $client + * @param ?array{ + * baseUrl?: string, + * client?: ClientInterface, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * } $options + */ + public function __construct( + RawClient $client, + ?array $options = null, + ) { + $this->client = $client; + $this->options = $options ?? []; + } + + /** + * You can fetch a list of all internal articles by making a GET request to `https://api.intercom.io/internal_articles`. + * + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return InternalArticleList + * @throws IntercomException + * @throws IntercomApiException + */ + public function listInternalArticles(?array $options = null): InternalArticleList + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "internal_articles", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return InternalArticleList::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can create a new internal article by making a POST request to `https://api.intercom.io/internal_articles`. + * + * @param ?CreateInternalArticleRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return InternalArticleListItem + * @throws IntercomException + * @throws IntercomApiException + */ + public function createInternalArticle(?CreateInternalArticleRequest $request = null, ?array $options = null): InternalArticleListItem + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "internal_articles", + method: HttpMethod::POST, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return InternalArticleListItem::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can fetch the details of a single internal article by making a GET request to `https://api.intercom.io/internal_articles/`. + * + * @param RetrieveInternalArticleRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return InternalArticleListItem + * @throws IntercomException + * @throws IntercomApiException + */ + public function retrieveInternalArticle(RetrieveInternalArticleRequest $request, ?array $options = null): InternalArticleListItem + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "internal_articles/{$request->getId()}", + method: HttpMethod::GET, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return InternalArticleListItem::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can update the details of a single internal article by making a PUT request to `https://api.intercom.io/internal_articles/`. + * + * @param UpdateInternalArticleRequestBody $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return InternalArticleListItem + * @throws IntercomException + * @throws IntercomApiException + */ + public function updateInternalArticle(UpdateInternalArticleRequestBody $request, ?array $options = null): InternalArticleListItem + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "internal_articles/{$request->getId()}", + method: HttpMethod::PUT, + body: $request, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return InternalArticleListItem::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can delete a single internal article by making a DELETE request to `https://api.intercom.io/internal_articles/`. + * + * @param DeleteInternalArticleRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return DeletedInternalArticleObject + * @throws IntercomException + * @throws IntercomApiException + */ + public function deleteInternalArticle(DeleteInternalArticleRequest $request, ?array $options = null): DeletedInternalArticleObject + { + $options = array_merge($this->options, $options ?? []); + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "internal_articles/{$request->getId()}", + method: HttpMethod::DELETE, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return DeletedInternalArticleObject::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } + + /** + * You can search for internal articles by making a GET request to `https://api.intercom.io/internal_articles/search`. + * + * @param SearchInternalArticlesRequest $request + * @param ?array{ + * baseUrl?: string, + * maxRetries?: int, + * timeout?: float, + * headers?: array, + * queryParameters?: array, + * bodyProperties?: array, + * } $options + * @return InternalArticleSearchResponse + * @throws IntercomException + * @throws IntercomApiException + */ + public function searchInternalArticles(SearchInternalArticlesRequest $request = new SearchInternalArticlesRequest(), ?array $options = null): InternalArticleSearchResponse + { + $options = array_merge($this->options, $options ?? []); + $query = []; + if ($request->getFolderId() != null) { + $query['folder_id'] = $request->getFolderId(); + } + try { + $response = $this->client->sendRequest( + new JsonApiRequest( + baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, + path: "internal_articles/search", + method: HttpMethod::GET, + query: $query, + ), + $options, + ); + $statusCode = $response->getStatusCode(); + if ($statusCode >= 200 && $statusCode < 400) { + $json = $response->getBody()->getContents(); + return InternalArticleSearchResponse::fromJson($json); + } + } catch (JsonException $e) { + throw new IntercomException(message: "Failed to deserialize response: {$e->getMessage()}", previous: $e); + } catch (RequestException $e) { + $response = $e->getResponse(); + if ($response === null) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: "API request failed", + statusCode: $response->getStatusCode(), + body: $response->getBody()->getContents(), + ); + } catch (ClientExceptionInterface $e) { + throw new IntercomException(message: $e->getMessage(), previous: $e); + } + throw new IntercomApiException( + message: 'API request failed', + statusCode: $statusCode, + body: $response->getBody()->getContents(), + ); + } +} diff --git a/src/Unstable/InternalArticles/Requests/DeleteInternalArticleRequest.php b/src/Unstable/InternalArticles/Requests/DeleteInternalArticleRequest.php new file mode 100644 index 0000000..50e7744 --- /dev/null +++ b/src/Unstable/InternalArticles/Requests/DeleteInternalArticleRequest.php @@ -0,0 +1,41 @@ +id = $values['id']; + } + + /** + * @return int + */ + public function getId(): int + { + return $this->id; + } + + /** + * @param int $value + */ + public function setId(int $value): self + { + $this->id = $value; + return $this; + } +} diff --git a/src/Unstable/InternalArticles/Requests/RetrieveInternalArticleRequest.php b/src/Unstable/InternalArticles/Requests/RetrieveInternalArticleRequest.php new file mode 100644 index 0000000..e715963 --- /dev/null +++ b/src/Unstable/InternalArticles/Requests/RetrieveInternalArticleRequest.php @@ -0,0 +1,41 @@ +id = $values['id']; + } + + /** + * @return int + */ + public function getId(): int + { + return $this->id; + } + + /** + * @param int $value + */ + public function setId(int $value): self + { + $this->id = $value; + return $this; + } +} diff --git a/src/Unstable/InternalArticles/Requests/SearchInternalArticlesRequest.php b/src/Unstable/InternalArticles/Requests/SearchInternalArticlesRequest.php new file mode 100644 index 0000000..4c5ce06 --- /dev/null +++ b/src/Unstable/InternalArticles/Requests/SearchInternalArticlesRequest.php @@ -0,0 +1,41 @@ +folderId = $values['folderId'] ?? null; + } + + /** + * @return ?string + */ + public function getFolderId(): ?string + { + return $this->folderId; + } + + /** + * @param ?string $value + */ + public function setFolderId(?string $value = null): self + { + $this->folderId = $value; + return $this; + } +} diff --git a/src/Unstable/InternalArticles/Requests/UpdateInternalArticleRequestBody.php b/src/Unstable/InternalArticles/Requests/UpdateInternalArticleRequestBody.php new file mode 100644 index 0000000..76ce544 --- /dev/null +++ b/src/Unstable/InternalArticles/Requests/UpdateInternalArticleRequestBody.php @@ -0,0 +1,142 @@ +id = $values['id']; + $this->title = $values['title'] ?? null; + $this->body = $values['body'] ?? null; + $this->authorId = $values['authorId'] ?? null; + $this->ownerId = $values['ownerId'] ?? null; + } + + /** + * @return int + */ + public function getId(): int + { + return $this->id; + } + + /** + * @param int $value + */ + public function setId(int $value): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getTitle(): ?string + { + return $this->title; + } + + /** + * @param ?string $value + */ + public function setTitle(?string $value = null): self + { + $this->title = $value; + return $this; + } + + /** + * @return ?string + */ + public function getBody(): ?string + { + return $this->body; + } + + /** + * @param ?string $value + */ + public function setBody(?string $value = null): self + { + $this->body = $value; + return $this; + } + + /** + * @return ?int + */ + public function getAuthorId(): ?int + { + return $this->authorId; + } + + /** + * @param ?int $value + */ + public function setAuthorId(?int $value = null): self + { + $this->authorId = $value; + return $this; + } + + /** + * @return ?int + */ + public function getOwnerId(): ?int + { + return $this->ownerId; + } + + /** + * @param ?int $value + */ + public function setOwnerId(?int $value = null): self + { + $this->ownerId = $value; + return $this; + } +} diff --git a/src/Unstable/InternalArticles/Types/InternalArticleListItem.php b/src/Unstable/InternalArticles/Types/InternalArticleListItem.php new file mode 100644 index 0000000..4dff4e3 --- /dev/null +++ b/src/Unstable/InternalArticles/Types/InternalArticleListItem.php @@ -0,0 +1,254 @@ +type = $values['type'] ?? null; + $this->id = $values['id'] ?? null; + $this->title = $values['title'] ?? null; + $this->body = $values['body'] ?? null; + $this->ownerId = $values['ownerId'] ?? null; + $this->authorId = $values['authorId'] ?? null; + $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; + $this->locale = $values['locale'] ?? null; + } + + /** + * @return ?'internal_article' + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?'internal_article' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?string + */ + public function getTitle(): ?string + { + return $this->title; + } + + /** + * @param ?string $value + */ + public function setTitle(?string $value = null): self + { + $this->title = $value; + return $this; + } + + /** + * @return ?string + */ + public function getBody(): ?string + { + return $this->body; + } + + /** + * @param ?string $value + */ + public function setBody(?string $value = null): self + { + $this->body = $value; + return $this; + } + + /** + * @return ?int + */ + public function getOwnerId(): ?int + { + return $this->ownerId; + } + + /** + * @param ?int $value + */ + public function setOwnerId(?int $value = null): self + { + $this->ownerId = $value; + return $this; + } + + /** + * @return ?int + */ + public function getAuthorId(): ?int + { + return $this->authorId; + } + + /** + * @param ?int $value + */ + public function setAuthorId(?int $value = null): self + { + $this->authorId = $value; + return $this; + } + + /** + * @return ?int + */ + public function getCreatedAt(): ?int + { + return $this->createdAt; + } + + /** + * @param ?int $value + */ + public function setCreatedAt(?int $value = null): self + { + $this->createdAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getUpdatedAt(): ?int + { + return $this->updatedAt; + } + + /** + * @param ?int $value + */ + public function setUpdatedAt(?int $value = null): self + { + $this->updatedAt = $value; + return $this; + } + + /** + * @return ?string + */ + public function getLocale(): ?string + { + return $this->locale; + } + + /** + * @param ?string $value + */ + public function setLocale(?string $value = null): self + { + $this->locale = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/InternalArticles/Types/InternalArticleSearchResponse.php b/src/Unstable/InternalArticles/Types/InternalArticleSearchResponse.php new file mode 100644 index 0000000..2c61496 --- /dev/null +++ b/src/Unstable/InternalArticles/Types/InternalArticleSearchResponse.php @@ -0,0 +1,130 @@ +type = $values['type'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->data = $values['data'] ?? null; + $this->pages = $values['pages'] ?? null; + } + + /** + * @return ?'list' + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?'list' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?int + */ + public function getTotalCount(): ?int + { + return $this->totalCount; + } + + /** + * @param ?int $value + */ + public function setTotalCount(?int $value = null): self + { + $this->totalCount = $value; + return $this; + } + + /** + * @return ?InternalArticleSearchResponseData + */ + public function getData(): ?InternalArticleSearchResponseData + { + return $this->data; + } + + /** + * @param ?InternalArticleSearchResponseData $value + */ + public function setData(?InternalArticleSearchResponseData $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return ?CursorPages + */ + public function getPages(): ?CursorPages + { + return $this->pages; + } + + /** + * @param ?CursorPages $value + */ + public function setPages(?CursorPages $value = null): self + { + $this->pages = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/InternalArticles/Types/InternalArticleSearchResponseData.php b/src/Unstable/InternalArticles/Types/InternalArticleSearchResponseData.php new file mode 100644 index 0000000..f4dd5d2 --- /dev/null +++ b/src/Unstable/InternalArticles/Types/InternalArticleSearchResponseData.php @@ -0,0 +1,55 @@ + $internalArticles An array of Internal Article objects + */ + #[JsonProperty('internal_articles'), ArrayType([InternalArticleListItem::class])] + private ?array $internalArticles; + + /** + * @param array{ + * internalArticles?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->internalArticles = $values['internalArticles'] ?? null; + } + + /** + * @return ?array + */ + public function getInternalArticles(): ?array + { + return $this->internalArticles; + } + + /** + * @param ?array $value + */ + public function setInternalArticles(?array $value = null): self + { + $this->internalArticles = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Types/ActivityLogActivityType.php b/src/Unstable/Types/ActivityLogActivityType.php index f8cddd3..c82055a 100644 --- a/src/Unstable/Types/ActivityLogActivityType.php +++ b/src/Unstable/Types/ActivityLogActivityType.php @@ -4,7 +4,8 @@ enum ActivityLogActivityType: string { - case AdminAssignmentLimitChange = "admin_assignment_limit_change"; + case AdminConversationAssignmentLimitChange = "admin_conversation_assignment_limit_change"; + case AdminTicketAssignmentLimitChange = "admin_ticket_assignment_limit_change"; case AdminAwayModeChange = "admin_away_mode_change"; case AdminDeletion = "admin_deletion"; case AdminDeprovisioned = "admin_deprovisioned"; diff --git a/src/Unstable/Types/ActivityLogMetadata.php b/src/Unstable/Types/ActivityLogMetadata.php index c66967d..2d9c6c9 100644 --- a/src/Unstable/Types/ActivityLogMetadata.php +++ b/src/Unstable/Types/ActivityLogMetadata.php @@ -64,6 +64,18 @@ class ActivityLogMetadata extends JsonSerializableType #[JsonProperty('update_by_name')] private ?string $updateByName; + /** + * @var ?int $conversationAssignmentLimit The conversation assignment limit value for an admin. + */ + #[JsonProperty('conversation_assignment_limit')] + private ?int $conversationAssignmentLimit; + + /** + * @var ?int $ticketAssignmentLimit The ticket assignment limit value for an admin. + */ + #[JsonProperty('ticket_assignment_limit')] + private ?int $ticketAssignmentLimit; + /** * @param array{ * signInMethod?: ?string, @@ -75,6 +87,8 @@ class ActivityLogMetadata extends JsonSerializableType * autoChanged?: ?string, * updateBy?: ?int, * updateByName?: ?string, + * conversationAssignmentLimit?: ?int, + * ticketAssignmentLimit?: ?int, * } $values */ public function __construct( @@ -89,6 +103,8 @@ public function __construct( $this->autoChanged = $values['autoChanged'] ?? null; $this->updateBy = $values['updateBy'] ?? null; $this->updateByName = $values['updateByName'] ?? null; + $this->conversationAssignmentLimit = $values['conversationAssignmentLimit'] ?? null; + $this->ticketAssignmentLimit = $values['ticketAssignmentLimit'] ?? null; } /** @@ -244,6 +260,40 @@ public function setUpdateByName(?string $value = null): self return $this; } + /** + * @return ?int + */ + public function getConversationAssignmentLimit(): ?int + { + return $this->conversationAssignmentLimit; + } + + /** + * @param ?int $value + */ + public function setConversationAssignmentLimit(?int $value = null): self + { + $this->conversationAssignmentLimit = $value; + return $this; + } + + /** + * @return ?int + */ + public function getTicketAssignmentLimit(): ?int + { + return $this->ticketAssignmentLimit; + } + + /** + * @param ?int $value + */ + public function setTicketAssignmentLimit(?int $value = null): self + { + $this->ticketAssignmentLimit = $value; + return $this; + } + /** * @return string */ diff --git a/src/Types/PaginatedNewsfeedResponse.php b/src/Unstable/Types/CallList.php similarity index 53% rename from src/Types/PaginatedNewsfeedResponse.php rename to src/Unstable/Types/CallList.php index b5bfac7..943a7af 100644 --- a/src/Types/PaginatedNewsfeedResponse.php +++ b/src/Unstable/Types/CallList.php @@ -1,123 +1,123 @@ $data A list of calls. */ - #[JsonProperty('pages')] - private ?CursorPages $pages; + #[JsonProperty('data'), ArrayType([Call::class])] + private ?array $data; /** - * @var int $totalCount A count of the total number of Newsfeeds. + * @var ?int $totalCount Total number of items available. */ #[JsonProperty('total_count')] - private int $totalCount; + private ?int $totalCount; /** - * @var array $data An array of Newsfeeds + * @var ?CursorPages $pages */ - #[JsonProperty('data'), ArrayType([Newsfeed::class])] - private array $data; + #[JsonProperty('pages')] + private ?CursorPages $pages; /** * @param array{ - * type: 'list', - * totalCount: int, - * data: array, + * type?: ?string, + * data?: ?array, + * totalCount?: ?int, * pages?: ?CursorPages, * } $values */ public function __construct( - array $values, + array $values = [], ) { - $this->type = $values['type']; + $this->type = $values['type'] ?? null; + $this->data = $values['data'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; $this->pages = $values['pages'] ?? null; - $this->totalCount = $values['totalCount']; - $this->data = $values['data']; } /** - * @return 'list' + * @return ?string */ - public function getType(): string + public function getType(): ?string { return $this->type; } /** - * @param 'list' $value + * @param ?string $value */ - public function setType(string $value): self + public function setType(?string $value = null): self { $this->type = $value; return $this; } /** - * @return ?CursorPages + * @return ?array */ - public function getPages(): ?CursorPages + public function getData(): ?array { - return $this->pages; + return $this->data; } /** - * @param ?CursorPages $value + * @param ?array $value */ - public function setPages(?CursorPages $value = null): self + public function setData(?array $value = null): self { - $this->pages = $value; + $this->data = $value; return $this; } /** - * @return int + * @return ?int */ - public function getTotalCount(): int + public function getTotalCount(): ?int { return $this->totalCount; } /** - * @param int $value + * @param ?int $value */ - public function setTotalCount(int $value): self + public function setTotalCount(?int $value = null): self { $this->totalCount = $value; return $this; } /** - * @return array + * @return ?CursorPages */ - public function getData(): array + public function getPages(): ?CursorPages { - return $this->data; + return $this->pages; } /** - * @param array $value + * @param ?CursorPages $value */ - public function setData(array $value): self + public function setPages(?CursorPages $value = null): self { - $this->data = $value; + $this->pages = $value; return $this; } diff --git a/src/Unstable/Types/ConversationRating.php b/src/Unstable/Types/ConversationRating.php index 25352f3..7ad4553 100644 --- a/src/Unstable/Types/ConversationRating.php +++ b/src/Unstable/Types/ConversationRating.php @@ -28,6 +28,12 @@ class ConversationRating extends JsonSerializableType #[JsonProperty('created_at')] private ?int $createdAt; + /** + * @var ?int $updatedAt The time the rating was last updated. + */ + #[JsonProperty('updated_at')] + private ?int $updatedAt; + /** * @var ?ContactReference $contact */ @@ -45,6 +51,7 @@ class ConversationRating extends JsonSerializableType * rating?: ?int, * remark?: ?string, * createdAt?: ?int, + * updatedAt?: ?int, * contact?: ?ContactReference, * teammate?: ?Reference, * } $values @@ -55,6 +62,7 @@ public function __construct( $this->rating = $values['rating'] ?? null; $this->remark = $values['remark'] ?? null; $this->createdAt = $values['createdAt'] ?? null; + $this->updatedAt = $values['updatedAt'] ?? null; $this->contact = $values['contact'] ?? null; $this->teammate = $values['teammate'] ?? null; } @@ -110,6 +118,23 @@ public function setCreatedAt(?int $value = null): self return $this; } + /** + * @return ?int + */ + public function getUpdatedAt(): ?int + { + return $this->updatedAt; + } + + /** + * @param ?int $value + */ + public function setUpdatedAt(?int $value = null): self + { + $this->updatedAt = $value; + return $this; + } + /** * @return ?ContactReference */ diff --git a/src/Unstable/Types/UpdateArticleRequestBody.php b/src/Unstable/Types/CreateArticleRequest.php similarity index 73% rename from src/Unstable/Types/UpdateArticleRequestBody.php rename to src/Unstable/Types/CreateArticleRequest.php index 2616367..a14c324 100644 --- a/src/Unstable/Types/UpdateArticleRequestBody.php +++ b/src/Unstable/Types/CreateArticleRequest.php @@ -6,15 +6,15 @@ use Intercom\Core\Json\JsonProperty; /** - * You can Update an Article + * You can create an Article */ -class UpdateArticleRequestBody extends JsonSerializableType +class CreateArticleRequest extends JsonSerializableType { /** - * @var ?string $title The title of the article.For multilingual articles, this will be the title of the default language's content. + * @var string $title The title of the article.For multilingual articles, this will be the title of the default language's content. */ #[JsonProperty('title')] - private ?string $title; + private string $title; /** * @var ?string $description The description of the article. For multilingual articles, this will be the description of the default language's content. @@ -29,22 +29,22 @@ class UpdateArticleRequestBody extends JsonSerializableType private ?string $body; /** - * @var ?int $authorId The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace. + * @var int $authorId The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace. */ #[JsonProperty('author_id')] - private ?int $authorId; + private int $authorId; /** - * @var ?value-of $state Whether the article will be `published` or will be a `draft`. Defaults to draft. For multilingual articles, this will be the state of the default language's content. + * @var ?value-of $state Whether the article will be `published` or will be a `draft`. Defaults to draft. For multilingual articles, this will be the state of the default language's content. */ #[JsonProperty('state')] private ?string $state; /** - * @var ?string $parentId The id of the article's parent collection or section. An article without this field stands alone. + * @var ?int $parentId The id of the article's parent collection or section. An article without this field stands alone. */ #[JsonProperty('parent_id')] - private ?string $parentId; + private ?int $parentId; /** * @var ?string $parentType The type of parent, which can either be a `collection` or `section`. @@ -60,23 +60,23 @@ class UpdateArticleRequestBody extends JsonSerializableType /** * @param array{ - * title?: ?string, + * title: string, + * authorId: int, * description?: ?string, * body?: ?string, - * authorId?: ?int, - * state?: ?value-of, - * parentId?: ?string, + * state?: ?value-of, + * parentId?: ?int, * parentType?: ?string, * translatedContent?: ?ArticleTranslatedContent, * } $values */ public function __construct( - array $values = [], + array $values, ) { - $this->title = $values['title'] ?? null; + $this->title = $values['title']; $this->description = $values['description'] ?? null; $this->body = $values['body'] ?? null; - $this->authorId = $values['authorId'] ?? null; + $this->authorId = $values['authorId']; $this->state = $values['state'] ?? null; $this->parentId = $values['parentId'] ?? null; $this->parentType = $values['parentType'] ?? null; @@ -84,17 +84,17 @@ public function __construct( } /** - * @return ?string + * @return string */ - public function getTitle(): ?string + public function getTitle(): string { return $this->title; } /** - * @param ?string $value + * @param string $value */ - public function setTitle(?string $value = null): self + public function setTitle(string $value): self { $this->title = $value; return $this; @@ -135,24 +135,24 @@ public function setBody(?string $value = null): self } /** - * @return ?int + * @return int */ - public function getAuthorId(): ?int + public function getAuthorId(): int { return $this->authorId; } /** - * @param ?int $value + * @param int $value */ - public function setAuthorId(?int $value = null): self + public function setAuthorId(int $value): self { $this->authorId = $value; return $this; } /** - * @return ?value-of + * @return ?value-of */ public function getState(): ?string { @@ -160,7 +160,7 @@ public function getState(): ?string } /** - * @param ?value-of $value + * @param ?value-of $value */ public function setState(?string $value = null): self { @@ -169,17 +169,17 @@ public function setState(?string $value = null): self } /** - * @return ?string + * @return ?int */ - public function getParentId(): ?string + public function getParentId(): ?int { return $this->parentId; } /** - * @param ?string $value + * @param ?int $value */ - public function setParentId(?string $value = null): self + public function setParentId(?int $value = null): self { $this->parentId = $value; return $this; diff --git a/src/Unstable/Types/CreateArticleRequestState.php b/src/Unstable/Types/CreateArticleRequestState.php new file mode 100644 index 0000000..4e41f9f --- /dev/null +++ b/src/Unstable/Types/CreateArticleRequestState.php @@ -0,0 +1,9 @@ + $dataType + */ + #[JsonProperty('data_type')] + private ?string $dataType; + + /** + * @param array{ + * dataType?: ?value-of, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->dataType = $values['dataType'] ?? null; + } + + /** + * @return ?value-of + */ + public function getDataType(): ?string + { + return $this->dataType; + } + + /** + * @param ?value-of $value + */ + public function setDataType(?string $value = null): self + { + $this->dataType = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/DataAttributes/Types/CreateDataAttributeRequestDataType.php b/src/Unstable/Types/CreateDataAttributeRequestOneDataType.php similarity index 65% rename from src/Unstable/DataAttributes/Types/CreateDataAttributeRequestDataType.php rename to src/Unstable/Types/CreateDataAttributeRequestOneDataType.php index e31d259..b16abca 100644 --- a/src/Unstable/DataAttributes/Types/CreateDataAttributeRequestDataType.php +++ b/src/Unstable/Types/CreateDataAttributeRequestOneDataType.php @@ -1,8 +1,8 @@ $options Array of objects representing the options of the list, with `value` as the key and the option as the value. At least two options are required. + */ + #[JsonProperty('options'), ArrayType([CreateDataAttributeRequestOptionsOptionsItem::class])] + private array $options; + + /** + * @param array{ + * options: array, + * dataType?: ?'options', + * } $values + */ + public function __construct( + array $values, + ) { + $this->dataType = $values['dataType'] ?? null; + $this->options = $values['options']; + } + + /** + * @return ?'options' + */ + public function getDataType(): ?string + { + return $this->dataType; + } + + /** + * @param ?'options' $value + */ + public function setDataType(?string $value = null): self + { + $this->dataType = $value; + return $this; + } + + /** + * @return array + */ + public function getOptions(): array + { + return $this->options; + } + + /** + * @param array $value + */ + public function setOptions(array $value): self + { + $this->options = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Types/CreateDataAttributeRequestOptionsOptionsItem.php b/src/Unstable/Types/CreateDataAttributeRequestOptionsOptionsItem.php new file mode 100644 index 0000000..f4f33be --- /dev/null +++ b/src/Unstable/Types/CreateDataAttributeRequestOptionsOptionsItem.php @@ -0,0 +1,51 @@ +value = $values['value'] ?? null; + } + + /** + * @return ?string + */ + public function getValue(): ?string + { + return $this->value; + } + + /** + * @param ?string $value + */ + public function setValue(?string $value = null): self + { + $this->value = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Types/CreateInternalArticleRequest.php b/src/Unstable/Types/CreateInternalArticleRequest.php new file mode 100644 index 0000000..5239646 --- /dev/null +++ b/src/Unstable/Types/CreateInternalArticleRequest.php @@ -0,0 +1,129 @@ +title = $values['title']; + $this->body = $values['body'] ?? null; + $this->authorId = $values['authorId']; + $this->ownerId = $values['ownerId']; + } + + /** + * @return string + */ + public function getTitle(): string + { + return $this->title; + } + + /** + * @param string $value + */ + public function setTitle(string $value): self + { + $this->title = $value; + return $this; + } + + /** + * @return ?string + */ + public function getBody(): ?string + { + return $this->body; + } + + /** + * @param ?string $value + */ + public function setBody(?string $value = null): self + { + $this->body = $value; + return $this; + } + + /** + * @return int + */ + public function getAuthorId(): int + { + return $this->authorId; + } + + /** + * @param int $value + */ + public function setAuthorId(int $value): self + { + $this->authorId = $value; + return $this; + } + + /** + * @return int + */ + public function getOwnerId(): int + { + return $this->ownerId; + } + + /** + * @param int $value + */ + public function setOwnerId(int $value): self + { + $this->ownerId = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Types/CreateOrUpdateCompanyRequest.php b/src/Unstable/Types/CreateOrUpdateCompanyRequest.php new file mode 100644 index 0000000..614037c --- /dev/null +++ b/src/Unstable/Types/CreateOrUpdateCompanyRequest.php @@ -0,0 +1,255 @@ + $customAttributes A hash of key/value pairs containing any other data about the company you want Intercom to store. + */ + #[JsonProperty('custom_attributes'), ArrayType(['string' => 'string'])] + private ?array $customAttributes; + + /** + * @var ?int $remoteCreatedAt The time the company was created by you. + */ + #[JsonProperty('remote_created_at')] + private ?int $remoteCreatedAt; + + /** + * @var ?int $monthlySpend How much revenue the company generates for your business. Note that this will truncate floats. i.e. it only allow for whole integers, 155.98 will be truncated to 155. Note that this has an upper limit of 2**31-1 or 2147483647.. + */ + #[JsonProperty('monthly_spend')] + private ?int $monthlySpend; + + /** + * @param array{ + * name?: ?string, + * companyId?: ?string, + * plan?: ?string, + * size?: ?int, + * website?: ?string, + * industry?: ?string, + * customAttributes?: ?array, + * remoteCreatedAt?: ?int, + * monthlySpend?: ?int, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->name = $values['name'] ?? null; + $this->companyId = $values['companyId'] ?? null; + $this->plan = $values['plan'] ?? null; + $this->size = $values['size'] ?? null; + $this->website = $values['website'] ?? null; + $this->industry = $values['industry'] ?? null; + $this->customAttributes = $values['customAttributes'] ?? null; + $this->remoteCreatedAt = $values['remoteCreatedAt'] ?? null; + $this->monthlySpend = $values['monthlySpend'] ?? null; + } + + /** + * @return ?string + */ + public function getName(): ?string + { + return $this->name; + } + + /** + * @param ?string $value + */ + public function setName(?string $value = null): self + { + $this->name = $value; + return $this; + } + + /** + * @return ?string + */ + public function getCompanyId(): ?string + { + return $this->companyId; + } + + /** + * @param ?string $value + */ + public function setCompanyId(?string $value = null): self + { + $this->companyId = $value; + return $this; + } + + /** + * @return ?string + */ + public function getPlan(): ?string + { + return $this->plan; + } + + /** + * @param ?string $value + */ + public function setPlan(?string $value = null): self + { + $this->plan = $value; + return $this; + } + + /** + * @return ?int + */ + public function getSize(): ?int + { + return $this->size; + } + + /** + * @param ?int $value + */ + public function setSize(?int $value = null): self + { + $this->size = $value; + return $this; + } + + /** + * @return ?string + */ + public function getWebsite(): ?string + { + return $this->website; + } + + /** + * @param ?string $value + */ + public function setWebsite(?string $value = null): self + { + $this->website = $value; + return $this; + } + + /** + * @return ?string + */ + public function getIndustry(): ?string + { + return $this->industry; + } + + /** + * @param ?string $value + */ + public function setIndustry(?string $value = null): self + { + $this->industry = $value; + return $this; + } + + /** + * @return ?array + */ + public function getCustomAttributes(): ?array + { + return $this->customAttributes; + } + + /** + * @param ?array $value + */ + public function setCustomAttributes(?array $value = null): self + { + $this->customAttributes = $value; + return $this; + } + + /** + * @return ?int + */ + public function getRemoteCreatedAt(): ?int + { + return $this->remoteCreatedAt; + } + + /** + * @param ?int $value + */ + public function setRemoteCreatedAt(?int $value = null): self + { + $this->remoteCreatedAt = $value; + return $this; + } + + /** + * @return ?int + */ + public function getMonthlySpend(): ?int + { + return $this->monthlySpend; + } + + /** + * @param ?int $value + */ + public function setMonthlySpend(?int $value = null): self + { + $this->monthlySpend = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Types/CreatePhoneSwitchRequest.php b/src/Unstable/Types/CreatePhoneSwitchRequest.php new file mode 100644 index 0000000..645f03f --- /dev/null +++ b/src/Unstable/Types/CreatePhoneSwitchRequest.php @@ -0,0 +1,102 @@ + $customAttributes + */ + #[JsonProperty('custom_attributes'), ArrayType(['string' => new Union('string', 'integer', 'datetime', CustomObjectInstanceList::class)])] + private ?array $customAttributes; + + /** + * @param array{ + * phone: string, + * customAttributes?: ?array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->phone = $values['phone']; + $this->customAttributes = $values['customAttributes'] ?? null; + } + + /** + * @return string + */ + public function getPhone(): string + { + return $this->phone; + } + + /** + * @param string $value + */ + public function setPhone(string $value): self + { + $this->phone = $value; + return $this; + } + + /** + * @return ?array + */ + public function getCustomAttributes(): ?array + { + return $this->customAttributes; + } + + /** + * @param ?array $value + */ + public function setCustomAttributes(?array $value = null): self + { + $this->customAttributes = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Types/UpdateTicketTypeRequestBody.php b/src/Unstable/Types/CreateTicketTypeRequest.php similarity index 66% rename from src/Unstable/Types/UpdateTicketTypeRequestBody.php rename to src/Unstable/Types/CreateTicketTypeRequest.php index 9011776..03ffc1e 100644 --- a/src/Unstable/Types/UpdateTicketTypeRequestBody.php +++ b/src/Unstable/Types/CreateTicketTypeRequest.php @@ -6,16 +6,16 @@ use Intercom\Core\Json\JsonProperty; /** - * The request payload for updating a ticket type. - * You can copy the `icon` property for your ticket type from [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app/) + * The request payload for creating a ticket type. + * You can copy the `icon` property for your ticket type from [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app/) */ -class UpdateTicketTypeRequestBody extends JsonSerializableType +class CreateTicketTypeRequest extends JsonSerializableType { /** - * @var ?string $name The name of the ticket type. + * @var string $name The name of the ticket type. */ #[JsonProperty('name')] - private ?string $name; + private string $name; /** * @var ?string $description The description of the ticket type. @@ -24,7 +24,7 @@ class UpdateTicketTypeRequestBody extends JsonSerializableType private ?string $description; /** - * @var ?value-of $category Category of the Ticket Type. + * @var ?value-of $category Category of the Ticket Type. */ #[JsonProperty('category')] private ?string $category; @@ -35,12 +35,6 @@ class UpdateTicketTypeRequestBody extends JsonSerializableType #[JsonProperty('icon')] private ?string $icon; - /** - * @var ?bool $archived The archived status of the ticket type. - */ - #[JsonProperty('archived')] - private ?bool $archived; - /** * @var ?bool $isInternal Whether the tickets associated with this ticket type are intended for internal use only or will be shared with customers. This is currently a limited attribute. */ @@ -49,37 +43,35 @@ class UpdateTicketTypeRequestBody extends JsonSerializableType /** * @param array{ - * name?: ?string, + * name: string, * description?: ?string, - * category?: ?value-of, + * category?: ?value-of, * icon?: ?string, - * archived?: ?bool, * isInternal?: ?bool, * } $values */ public function __construct( - array $values = [], + array $values, ) { - $this->name = $values['name'] ?? null; + $this->name = $values['name']; $this->description = $values['description'] ?? null; $this->category = $values['category'] ?? null; $this->icon = $values['icon'] ?? null; - $this->archived = $values['archived'] ?? null; $this->isInternal = $values['isInternal'] ?? null; } /** - * @return ?string + * @return string */ - public function getName(): ?string + public function getName(): string { return $this->name; } /** - * @param ?string $value + * @param string $value */ - public function setName(?string $value = null): self + public function setName(string $value): self { $this->name = $value; return $this; @@ -103,7 +95,7 @@ public function setDescription(?string $value = null): self } /** - * @return ?value-of + * @return ?value-of */ public function getCategory(): ?string { @@ -111,7 +103,7 @@ public function getCategory(): ?string } /** - * @param ?value-of $value + * @param ?value-of $value */ public function setCategory(?string $value = null): self { @@ -136,23 +128,6 @@ public function setIcon(?string $value = null): self return $this; } - /** - * @return ?bool - */ - public function getArchived(): ?bool - { - return $this->archived; - } - - /** - * @param ?bool $value - */ - public function setArchived(?bool $value = null): self - { - $this->archived = $value; - return $this; - } - /** * @return ?bool */ diff --git a/src/TicketTypes/Types/UpdateTicketTypeRequestBodyCategory.php b/src/Unstable/Types/CreateTicketTypeRequestCategory.php similarity index 56% rename from src/TicketTypes/Types/UpdateTicketTypeRequestBodyCategory.php rename to src/Unstable/Types/CreateTicketTypeRequestCategory.php index 26981fb..bca229b 100644 --- a/src/TicketTypes/Types/UpdateTicketTypeRequestBodyCategory.php +++ b/src/Unstable/Types/CreateTicketTypeRequestCategory.php @@ -1,8 +1,8 @@ id = $values['id'] ?? null; + $this->object = $values['object'] ?? null; + $this->deleted = $values['deleted'] ?? null; + } + + /** + * @return ?string + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param ?string $value + */ + public function setId(?string $value = null): self + { + $this->id = $value; + return $this; + } + + /** + * @return ?'internal_article' + */ + public function getObject(): ?string + { + return $this->object; + } + + /** + * @param ?'internal_article' $value + */ + public function setObject(?string $value = null): self + { + $this->object = $value; + return $this; + } + + /** + * @return ?bool + */ + public function getDeleted(): ?bool + { + return $this->deleted; + } + + /** + * @param ?bool $value + */ + public function setDeleted(?bool $value = null): self + { + $this->deleted = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Types/IntercomVersion.php b/src/Unstable/Types/IntercomVersion.php index 77ad898..bcd9bbf 100644 --- a/src/Unstable/Types/IntercomVersion.php +++ b/src/Unstable/Types/IntercomVersion.php @@ -21,5 +21,8 @@ enum IntercomVersion: string case Two9 = "2.9"; case Two10 = "2.10"; case Two11 = "2.11"; + case Two12 = "2.12"; + case Two13 = "2.13"; + case Two14 = "2.14"; case Unstable = "Unstable"; } diff --git a/src/Unstable/Types/InternalArticleList.php b/src/Unstable/Types/InternalArticleList.php new file mode 100644 index 0000000..dcd59d8 --- /dev/null +++ b/src/Unstable/Types/InternalArticleList.php @@ -0,0 +1,131 @@ + $data An array of Internal Article objects + */ + #[JsonProperty('data'), ArrayType([InternalArticleListItem::class])] + private ?array $data; + + /** + * @param array{ + * type?: ?'list', + * pages?: ?CursorPages, + * totalCount?: ?int, + * data?: ?array, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->type = $values['type'] ?? null; + $this->pages = $values['pages'] ?? null; + $this->totalCount = $values['totalCount'] ?? null; + $this->data = $values['data'] ?? null; + } + + /** + * @return ?'list' + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param ?'list' $value + */ + public function setType(?string $value = null): self + { + $this->type = $value; + return $this; + } + + /** + * @return ?CursorPages + */ + public function getPages(): ?CursorPages + { + return $this->pages; + } + + /** + * @param ?CursorPages $value + */ + public function setPages(?CursorPages $value = null): self + { + $this->pages = $value; + return $this; + } + + /** + * @return ?int + */ + public function getTotalCount(): ?int + { + return $this->totalCount; + } + + /** + * @param ?int $value + */ + public function setTotalCount(?int $value = null): self + { + $this->totalCount = $value; + return $this; + } + + /** + * @return ?array + */ + public function getData(): ?array + { + return $this->data; + } + + /** + * @param ?array $value + */ + public function setData(?array $value = null): self + { + $this->data = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Types/UpdateDataAttributeRequestOptions.php b/src/Unstable/Types/UpdateDataAttributeRequestOptions.php new file mode 100644 index 0000000..9b1f82f --- /dev/null +++ b/src/Unstable/Types/UpdateDataAttributeRequestOptions.php @@ -0,0 +1,52 @@ + $options Array of objects representing the options of the list, with `value` as the key and the option as the value. At least two options are required. + */ + #[JsonProperty('options'), ArrayType([UpdateDataAttributeRequestOptionsOptionsItem::class])] + private array $options; + + /** + * @param array{ + * options: array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->options = $values['options']; + } + + /** + * @return array + */ + public function getOptions(): array + { + return $this->options; + } + + /** + * @param array $value + */ + public function setOptions(array $value): self + { + $this->options = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Types/UpdateDataAttributeRequestOptionsOptionsItem.php b/src/Unstable/Types/UpdateDataAttributeRequestOptionsOptionsItem.php new file mode 100644 index 0000000..24643a4 --- /dev/null +++ b/src/Unstable/Types/UpdateDataAttributeRequestOptionsOptionsItem.php @@ -0,0 +1,51 @@ +value = $values['value'] ?? null; + } + + /** + * @return ?string + */ + public function getValue(): ?string + { + return $this->value; + } + + /** + * @param ?string $value + */ + public function setValue(?string $value = null): self + { + $this->value = $value; + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/UnstableClient.php b/src/Unstable/UnstableClient.php index 7923ea8..9250bda 100644 --- a/src/Unstable/UnstableClient.php +++ b/src/Unstable/UnstableClient.php @@ -8,6 +8,7 @@ use Intercom\Unstable\AwayStatusReasons\AwayStatusReasonsClient; use Intercom\Unstable\Export\ExportClient; use Intercom\Unstable\HelpCenter\HelpCenterClient; +use Intercom\Unstable\InternalArticles\InternalArticlesClient; use Intercom\Unstable\Companies\CompaniesClient; use Intercom\Unstable\Contacts\ContactsClient; use Intercom\Unstable\Notes\NotesClient; @@ -25,12 +26,15 @@ use Intercom\Unstable\News\NewsClient; use Intercom\Unstable\Segments\SegmentsClient; use Intercom\Unstable\Switch_\SwitchClient; +use Intercom\Unstable\Calls\CallsClient; use Intercom\Unstable\Teams\TeamsClient; use Intercom\Unstable\TicketStates\TicketStatesClient; use Intercom\Unstable\TicketTypeAttributes\TicketTypeAttributesClient; use Intercom\Unstable\TicketTypes\TicketTypesClient; use Intercom\Unstable\Tickets\TicketsClient; use Intercom\Unstable\Visitors\VisitorsClient; +use Intercom\Unstable\Brands\BrandsClient; +use Intercom\Unstable\Emails\EmailsClient; use GuzzleHttp\ClientInterface; use Intercom\Core\Client\RawClient; @@ -66,6 +70,11 @@ class UnstableClient */ public HelpCenterClient $helpCenter; + /** + * @var InternalArticlesClient $internalArticles + */ + public InternalArticlesClient $internalArticles; + /** * @var CompaniesClient $companies */ @@ -151,6 +160,11 @@ class UnstableClient */ public SwitchClient $switch_; + /** + * @var CallsClient $calls + */ + public CallsClient $calls; + /** * @var TeamsClient $teams */ @@ -181,6 +195,16 @@ class UnstableClient */ public VisitorsClient $visitors; + /** + * @var BrandsClient $brands + */ + public BrandsClient $brands; + + /** + * @var EmailsClient $emails + */ + public EmailsClient $emails; + /** * @var array{ * baseUrl?: string, @@ -219,6 +243,7 @@ public function __construct( $this->awayStatusReasons = new AwayStatusReasonsClient($this->client, $this->options); $this->export = new ExportClient($this->client, $this->options); $this->helpCenter = new HelpCenterClient($this->client, $this->options); + $this->internalArticles = new InternalArticlesClient($this->client, $this->options); $this->companies = new CompaniesClient($this->client, $this->options); $this->contacts = new ContactsClient($this->client, $this->options); $this->notes = new NotesClient($this->client, $this->options); @@ -236,11 +261,14 @@ public function __construct( $this->news = new NewsClient($this->client, $this->options); $this->segments = new SegmentsClient($this->client, $this->options); $this->switch_ = new SwitchClient($this->client, $this->options); + $this->calls = new CallsClient($this->client, $this->options); $this->teams = new TeamsClient($this->client, $this->options); $this->ticketStates = new TicketStatesClient($this->client, $this->options); $this->ticketTypeAttributes = new TicketTypeAttributesClient($this->client, $this->options); $this->ticketTypes = new TicketTypesClient($this->client, $this->options); $this->tickets = new TicketsClient($this->client, $this->options); $this->visitors = new VisitorsClient($this->client, $this->options); + $this->brands = new BrandsClient($this->client, $this->options); + $this->emails = new EmailsClient($this->client, $this->options); } } diff --git a/src/Visitors/VisitorsClient.php b/src/Visitors/VisitorsClient.php index 8ec76f0..966a2e3 100644 --- a/src/Visitors/VisitorsClient.php +++ b/src/Visitors/VisitorsClient.php @@ -69,11 +69,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Visitor + * @return ?Visitor * @throws IntercomException * @throws IntercomApiException */ - public function find(FindVisitorRequest $request, ?array $options = null): Visitor + public function find(FindVisitorRequest $request, ?array $options = null): ?Visitor { $options = array_merge($this->options, $options ?? []); $query = []; @@ -91,6 +91,9 @@ public function find(FindVisitorRequest $request, ?array $options = null): Visit $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Visitor::fromJson($json); } } catch (JsonException $e) { @@ -134,11 +137,11 @@ public function find(FindVisitorRequest $request, ?array $options = null): Visit * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Visitor + * @return ?Visitor * @throws IntercomException * @throws IntercomApiException */ - public function update(UpdateVisitorRequestWithId|UpdateVisitorRequestWithUserId $request, ?array $options = null): Visitor + public function update(UpdateVisitorRequestWithId|UpdateVisitorRequestWithUserId $request, ?array $options = null): ?Visitor { $options = array_merge($this->options, $options ?? []); try { @@ -154,6 +157,9 @@ public function update(UpdateVisitorRequestWithId|UpdateVisitorRequestWithUserId $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Visitor::fromJson($json); } } catch (JsonException $e) {