diff --git a/.fern/metadata.json b/.fern/metadata.json index a9003b27..45a05288 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -1,13 +1,14 @@ { - "cliVersion": "3.0.2", + "cliVersion": "5.187.0", "generatorName": "fernapi/fern-php-sdk", - "generatorVersion": "1.25.0", + "generatorVersion": "2.30.12", "generatorConfig": { "namespace": "Intercom", "clientName": "IntercomClient", "packageName": "intercom/intercom-php", "propertyAccess": "private", "inlinePathParameters": true, + "encode-path-params": true, "composerJson": { "description": "Intercom API client.", "author": { @@ -17,4 +18,4 @@ "homepage": "https://developers.intercom.com/docs" } } -} \ No newline at end of file +} diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..0c772cdc --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,120 @@ +# Contributing + +Thanks for your interest in contributing to this SDK! This document provides guidelines for contributing to the project. + +## Getting Started + +### Prerequisites + +- PHP 8.1+ +- Composer + +### Installation + +Install the project dependencies: + +```bash +composer install +``` + +### Testing + +Run the test suite: + +```bash +composer test +``` + +Or run PHPUnit directly: + +```bash +./vendor/bin/phpunit +``` + +### Linting & Formatting + +Fix code style issues: + +```bash +./vendor/bin/php-cs-fixer fix +``` + +### Static Analysis + +Run static analysis: + +```bash +./vendor/bin/phpstan analyse +``` + +## About Generated Code + +**Important**: Most files in this SDK are automatically generated by [Fern](https://buildwithfern.com) from the API definition. Direct modifications to generated files will be overwritten the next time the SDK is generated. + +### Generated Files + +The following directories contain generated code: +- `src/` - API client classes and types +- Most PHP files in the project + +### How to Customize + +If you need to customize the SDK, you have two options: + +#### Option 1: Use `.fernignore` + +For custom code that should persist across SDK regenerations: + +1. Create a `.fernignore` file in the project root +2. Add file patterns for files you want to preserve (similar to `.gitignore` syntax) +3. Add your custom code to those files + +Files listed in `.fernignore` will not be overwritten when the SDK is regenerated. + +For more information, see the [Fern documentation on custom code](https://buildwithfern.com/learn/sdks/overview/custom-code). + +#### Option 2: Contribute to the Generator + +If you want to change how code is generated for all users of this SDK: + +1. The PHP SDK generator lives in the [Fern repository](https://github.com/fern-api/fern) +2. Generator code is located at `generators/php/` +3. Follow the [Fern contributing guidelines](https://github.com/fern-api/fern/blob/main/CONTRIBUTING.md) +4. Submit a pull request with your changes to the generator + +This approach is best for: +- Bug fixes in generated code +- New features that would benefit all users +- Improvements to code generation patterns + +## Making Changes + +### Workflow + +1. Create a new branch for your changes +2. Make your modifications +3. Run tests to ensure nothing breaks: `composer test` +4. Run formatting: `./vendor/bin/php-cs-fixer fix` +5. Run static analysis: `./vendor/bin/phpstan analyse` +6. Commit your changes with a clear commit message +7. Push your branch and create a pull request + +### Commit Messages + +Write clear, descriptive commit messages that explain what changed and why. + +### Code Style + +This project uses PHP CS Fixer for automated code formatting. Run `./vendor/bin/php-cs-fixer fix` before committing to ensure your code meets the project's style guidelines. + +## Questions or Issues? + +If you have questions or run into issues: + +1. Check the [Fern documentation](https://buildwithfern.com) +2. Search existing [GitHub issues](https://github.com/fern-api/fern/issues) +3. Open a new issue if your question hasn't been addressed + +## License + +By contributing to this project, you agree that your contributions will be licensed under the same license as the project. diff --git a/README.md b/README.md index 1db1a906..10b6d5a1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Intercom PHP Library -[![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) +[![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=Intercom%2FPHP) [![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 APIs from PHP. @@ -10,9 +10,9 @@ The Intercom PHP library provides convenient access to the Intercom APIs from PH - [Requirements](#requirements) - [Installation](#installation) - [Usage](#usage) +- [Environments](#environments) - [Exception Handling](#exception-handling) - [Pagination](#pagination) -- [Legacy Sdk](#legacy-sdk) - [Advanced](#advanced) - [Custom Client](#custom-client) - [Retries](#retries) @@ -53,6 +53,31 @@ $client->aiContent->createContentImportSource( ``` +## Environments + +This SDK allows you to configure different environments for API requests. + +```php +The SDK defaults to the `UsProduction` environment. To use a different environment, pass it to the client constructor: + +```php +use Intercom\IntercomClient; +use Intercom\Environments; + +$client = new IntercomClient( + token: '', + options: [ + 'baseUrl' => Environments::Staging->value + ] +); +``` + +Available environments: +- `Environments::UsProduction` +- `Environments::EuProduction` +- `Environments::AuProduction` +``` + ## Exception Handling When the API returns a non-success status code (4xx or 5xx response), an exception will be thrown. @@ -79,7 +104,7 @@ List endpoints return a `Pager` which lets you loop over all items and the SD use Intercom\IntercomClient; $client = new IntercomClient( - '', + '', ['baseUrl' => 'https://api.example.com'], ); @@ -100,58 +125,34 @@ foreach ($items->getPages() as $page) { ``` -## Legacy SDK - -While the new SDK has a lot of improvements, we at Intercom understand that it takes time to upgrade when there are breaking changes. -To make the migration easier, the new SDK also exports the legacy SDK as `Intercom\Legacy\...`. Here's an example of how you can use the -legacy SDK alongside the new SDK inside a single file: - -```php -use Intercom\IntercomClient; -use Intercom\Legacy\IntercomClient as LegacyIntercomClient; - -$intercom = new IntercomClient(); -$legacyClient = new LegacyIntercomClient(); -``` - -We recommend migrating to the new SDK using the following steps: - -1. Upgrade the package to `^5.1.0` -2. Search and replace all requires and imports from `Intercom\...` to `Intercom\Legacy\...` - -3. Gradually move over to use the new SDK by importing it from the `Intercom\...` import. - - ## Advanced ### Custom Client -This SDK is built to work with any HTTP client that implements Guzzle's `ClientInterface`. -By default, if no client is provided, the SDK will use Guzzle's default HTTP client. +This SDK is built to work with any HTTP client that implements the [PSR-18](https://www.php-fig.org/psr/psr-18/) `ClientInterface`. +By default, if no client is provided, the SDK will use `php-http/discovery` to find an installed HTTP client. However, you can pass your own client that adheres to `ClientInterface`: ```php use Intercom\IntercomClient; -// Create a custom Guzzle client with specific configuration. +// Pass any PSR-18 compatible HTTP client implementation. +// For example, using Guzzle: $customClient = new \GuzzleHttp\Client([ 'timeout' => 5.0, ]); -// Pass the custom client when creating an instance of the class. $client = new IntercomClient(options: [ 'client' => $customClient ]); -// You can also utilize the same technique to leverage advanced customizations to the client such as adding middleware -$handlerStack = \GuzzleHttp\HandlerStack::create(); -$handlerStack->push(MyCustomMiddleware::create()); -$customClient = new \GuzzleHttp\Client(['handler' => $handlerStack]); - -// Pass the custom client when creating an instance of the class. -$client = new IntercomClient(options: [ - 'client' => $customClient -]); +// Or using Symfony HttpClient: +// $customClient = (new \Symfony\Component\HttpClient\Psr18Client()) +// ->withOptions(['timeout' => 5.0]); +// +// $client = new IntercomClient(options: [ +// 'client' => $customClient +// ]); ``` ### Retries @@ -164,7 +165,12 @@ A request is deemed retryable when any of the following HTTP status codes is ret - [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout) - [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests) -- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors) +- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#server_error_responses) (Internal Server Error) + +The `retryStatusCodes` configuration controls which [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#server_error_responses) status codes are retried: + +- `legacy` (default): Retries `408`, `429`, and all `>= 500` +- `recommended`: Retries `408`, `429`, `502`, `503`, `504` only (excludes `500 Internal Server Error` to avoid retrying non-idempotent failures) Use the `maxRetries` request option to configure this behavior. @@ -185,7 +191,7 @@ The SDK defaults to a 30 second timeout. Use the `timeout` option to configure t $response = $client->aiContent->createContentImportSource( ..., options: [ - 'timeout' => 3.0 // Override timeout to 3 seconds + 'timeout' => 3.0 // Override timeout at the request level ] ); ``` @@ -198,4 +204,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! \ No newline at end of file +On the other hand, contributions to the README are always very welcome! diff --git a/composer.json b/composer.json index 14e29170..f9fc8a1f 100644 --- a/composer.json +++ b/composer.json @@ -14,13 +14,15 @@ "php-http/client-common": "^2.0", "php-http/discovery": "^1.0", "php-http/message": "^1.0", + "php-http/multipart-stream-builder": "^1.4", "psr/http-client": "^1.0", + "psr/http-factory": "^1.0", "psr/http-message": "^1.0 || ^2.0", "nyholm/psr7": "^1.0", "guzzlehttp/guzzle": "^7.4" }, "require-dev": { - "phpunit/phpunit": "^9.0", + "phpunit/phpunit": "^12.5", "friendsofphp/php-cs-fixer": "3.5.0", "phpstan/phpstan": "^1.12" }, diff --git a/reference.md b/reference.md index db106d5f..8a5f8732 100644 --- a/reference.md +++ b/reference.md @@ -129,7 +129,7 @@ $client->admins->away( -
$client->admins->listAllActivityLogs($request) -> ActivityLogList +
$client->admins->listAllActivityLogs($request) -> ?ActivityLogList
@@ -196,7 +196,7 @@ $client->admins->listAllActivityLogs(
-
$client->admins->list() -> AdminList +
$client->admins->list() -> ?AdminList
@@ -294,7 +294,7 @@ $client->admins->find(
## AI Content -
$client->aiContent->listContentImportSources() -> ContentImportSourcesList +
$client->aiContent->listContentImportSources() -> ?ContentImportSourcesList
@@ -333,7 +333,7 @@ $client->aiContent->listContentImportSources();
-
$client->aiContent->createContentImportSource($request) -> ContentImportSource +
$client->aiContent->createContentImportSource($request) -> ?ContentImportSource
@@ -408,7 +408,7 @@ $client->aiContent->createContentImportSource(
-
$client->aiContent->getContentImportSource($request) -> ContentImportSource +
$client->aiContent->getContentImportSource($request) -> ?ContentImportSource
@@ -452,7 +452,7 @@ $client->aiContent->getContentImportSource(
-
$client->aiContent->updateContentImportSource($request) -> ContentImportSource +
$client->aiContent->updateContentImportSource($request) -> ?ContentImportSource
@@ -594,7 +594,7 @@ $client->aiContent->deleteContentImportSource(
-
$client->aiContent->listExternalPages() -> ExternalPagesList +
$client->aiContent->listExternalPages() -> ?ExternalPagesList
@@ -633,7 +633,7 @@ $client->aiContent->listExternalPages();
-
$client->aiContent->createExternalPage($request) -> ExternalPage +
$client->aiContent->createExternalPage($request) -> ?ExternalPage
@@ -752,7 +752,7 @@ $client->aiContent->createExternalPage(
-
$client->aiContent->getExternalPage($request) -> ExternalPage +
$client->aiContent->getExternalPage($request) -> ?ExternalPage
@@ -810,7 +810,7 @@ $client->aiContent->getExternalPage(
-
$client->aiContent->updateExternalPage($request) -> ExternalPage +
$client->aiContent->updateExternalPage($request) -> ?ExternalPage
@@ -930,7 +930,7 @@ $client->aiContent->updateExternalPage(
-
$client->aiContent->deleteExternalPage($request) -> ExternalPage +
$client->aiContent->deleteExternalPage($request) -> ?ExternalPage
@@ -989,7 +989,7 @@ $client->aiContent->deleteExternalPage(
## Articles -
$client->articles->list($request) -> ArticleList +
$client->articles->list($request) -> ?ArticleList
@@ -1021,7 +1021,10 @@ You can fetch a list of all articles by making a GET request to `https://api.int ```php $client->articles->list( - new ListArticlesRequest([]), + new ListArticlesRequest([ + 'page' => 1, + 'perPage' => 1, + ]), ); ```
@@ -1057,7 +1060,7 @@ $client->articles->list(
-
$client->articles->create($request) -> Article +
$client->articles->create($request) -> ?Article
@@ -1130,7 +1133,7 @@ $client->articles->create(
-
$client->articles->find($request) -> Article +
$client->articles->find($request) -> ?Article
@@ -1188,7 +1191,7 @@ $client->articles->find(
-
$client->articles->update($request) -> Article +
$client->articles->update($request) -> ?Article
@@ -1312,7 +1315,7 @@ $client->articles->update(
-
$client->articles->delete($request) -> DeletedArticleObject +
$client->articles->delete($request) -> ?DeletedArticleObject
@@ -1370,7 +1373,7 @@ $client->articles->delete(
-
$client->articles->search($request) -> ArticleSearchResponse +
$client->articles->search($request) -> ?ArticleSearchResponse
@@ -1456,7 +1459,7 @@ $client->articles->search(
## Away Status Reasons -
$client->awayStatusReasons->listAwayStatusReasons() -> array +
$client->awayStatusReasons->listAwayStatusReasons() -> ?array
@@ -1496,7 +1499,7 @@ $client->awayStatusReasons->listAwayStatusReasons();
## Export -
$client->export->enqueueANewReportingDataExportJob($request) -> PostExportReportingDataEnqueueResponse +
$client->export->enqueueANewReportingDataExportJob($request) -> ?PostExportReportingDataEnqueueResponse
@@ -1570,7 +1573,7 @@ $client->export->enqueueANewReportingDataExportJob(
-
$client->export->listAvailableDatasetsAndAttributes() -> GetExportReportingDataGetDatasetsResponse +
$client->export->listAvailableDatasetsAndAttributes() -> ?GetExportReportingDataGetDatasetsResponse
@@ -1596,7 +1599,7 @@ $client->export->listAvailableDatasetsAndAttributes();
## Data Export -
$client->dataExport->exportReportingData($request) -> DataExportExportReportingDataResponse +
$client->dataExport->exportReportingData($request) -> ?DataExportExportReportingDataResponse
@@ -1611,9 +1614,10 @@ $client->export->listAvailableDatasetsAndAttributes(); ```php $client->dataExport->exportReportingData( new ExportReportingDataRequest([ - 'jobIdentifier' => 'job_identifier', + 'jobIdentifierPathParam' => 'job_identifier', 'appId' => 'app_id', 'clientId' => 'client_id', + 'jobIdentifier' => 'job_identifier', ]), ); ``` @@ -1630,7 +1634,7 @@ $client->dataExport->exportReportingData(
-**$jobIdentifier:** `string` — Unique identifier of the job. +**$jobIdentifierPathParam:** `string` — Unique identifier of the job.
@@ -1648,6 +1652,14 @@ $client->dataExport->exportReportingData( **$clientId:** `string` +
+
+ +
+
+ +**$jobIdentifier:** `string` — Unique identifier of the job. +
@@ -1691,8 +1703,9 @@ Download the data from a completed reporting data export job. ```php $client->dataExport->downloadReportingDataExport( new DownloadReportingDataExportRequest([ - 'jobIdentifier' => 'job_identifier', + 'jobIdentifierPathParam' => 'job_identifier', 'appId' => 'app_id', + 'jobIdentifier' => 'job_identifier', 'accept' => 'application/octet-stream', ]), ); @@ -1710,7 +1723,7 @@ $client->dataExport->downloadReportingDataExport(
-**$jobIdentifier:** `string` +**$jobIdentifierPathParam:** `string`
@@ -1726,6 +1739,14 @@ $client->dataExport->downloadReportingDataExport(
+**$jobIdentifier:** `string` + +
+
+ +
+
+ **$accept:** `string` — Required header for downloading the export file
@@ -1738,7 +1759,7 @@ $client->dataExport->downloadReportingDataExport(
-
$client->dataExport->create($request) -> DataExport +
$client->dataExport->create($request) -> ?DataExport
@@ -1819,7 +1840,7 @@ $client->dataExport->create(
-
$client->dataExport->find($request) -> DataExport +
$client->dataExport->find($request) -> ?DataExport
@@ -1881,7 +1902,7 @@ $client->dataExport->find(
-
$client->dataExport->cancel($request) -> DataExport +
$client->dataExport->cancel($request) -> ?DataExport
@@ -2004,7 +2025,7 @@ $client->dataExport->download(
## HelpCenters -
$client->helpCenters->find($request) -> HelpCenter +
$client->helpCenters->find($request) -> ?HelpCenter
@@ -2062,7 +2083,7 @@ $client->helpCenters->find(
-
$client->helpCenters->list($request) -> HelpCenterList +
$client->helpCenters->list($request) -> ?HelpCenterList
@@ -2090,7 +2111,10 @@ You can list all Help Centers by making a GET request to `https://api.intercom.i ```php $client->helpCenters->list( - new ListHelpCentersRequest([]), + new ListHelpCentersRequest([ + 'page' => 1, + 'perPage' => 1, + ]), ); ```
@@ -2127,7 +2151,7 @@ $client->helpCenters->list(
## Internal Articles -
$client->internalArticles->listInternalArticles() -> InternalArticleList +
$client->internalArticles->listInternalArticles() -> ?InternalArticleList
@@ -2166,7 +2190,7 @@ $client->internalArticles->listInternalArticles();
-
$client->internalArticles->createInternalArticle($request) -> InternalArticleListItem +
$client->internalArticles->createInternalArticle($request) -> ?InternalArticleListItem
@@ -2227,7 +2251,7 @@ $client->internalArticles->createInternalArticle(
-
$client->internalArticles->retrieveInternalArticle($request) -> InternalArticleListItem +
$client->internalArticles->retrieveInternalArticle($request) -> ?InternalArticleListItem
@@ -2285,7 +2309,7 @@ $client->internalArticles->retrieveInternalArticle(
-
$client->internalArticles->updateInternalArticle($request) -> InternalArticleListItem +
$client->internalArticles->updateInternalArticle($request) -> ?InternalArticleListItem
@@ -2377,7 +2401,7 @@ $client->internalArticles->updateInternalArticle(
-
$client->internalArticles->deleteInternalArticle($request) -> DeletedInternalArticleObject +
$client->internalArticles->deleteInternalArticle($request) -> ?DeletedInternalArticleObject
@@ -2435,7 +2459,7 @@ $client->internalArticles->deleteInternalArticle(
-
$client->internalArticles->searchInternalArticles($request) -> InternalArticleSearchResponse +
$client->internalArticles->searchInternalArticles($request) -> ?InternalArticleSearchResponse
@@ -2494,7 +2518,7 @@ $client->internalArticles->searchInternalArticles(
## IP Allowlist -
$client->ipAllowlist->getIpAllowlist() -> IpAllowlist +
$client->ipAllowlist->getIpAllowlist() -> ?IpAllowlist
@@ -2533,7 +2557,7 @@ $client->ipAllowlist->getIpAllowlist();
-
$client->ipAllowlist->updateIpAllowlist($request) -> IpAllowlist +
$client->ipAllowlist->updateIpAllowlist($request) -> ?IpAllowlist
@@ -2600,7 +2624,7 @@ $client->ipAllowlist->updateIpAllowlist(
## Companies -
$client->companies->retrieve($request) -> CompaniesRetrieveResponse +
$client->companies->retrieve($request) -> ?CompaniesRetrieveResponse
@@ -2713,7 +2737,7 @@ $client->companies->retrieve(
-
$client->companies->createOrUpdate($request) -> Company +
$client->companies->createOrUpdate($request) -> ?Company
@@ -2781,7 +2805,7 @@ $client->companies->createOrUpdate(
-
$client->companies->find($request) -> Company +
$client->companies->find($request) -> ?Company
@@ -2839,7 +2863,7 @@ $client->companies->find(
-
$client->companies->update($request) -> Company +
$client->companies->update($request) -> ?Company
@@ -2913,7 +2937,7 @@ $client->companies->update(
-
$client->companies->delete($request) -> DeletedCompanyObject +
$client->companies->delete($request) -> ?DeletedCompanyObject
@@ -2971,7 +2995,7 @@ $client->companies->delete(
-
$client->companies->listAttachedContacts($request) -> CompanyAttachedContacts +
$client->companies->listAttachedContacts($request) -> ?CompanyAttachedContacts
@@ -3029,7 +3053,7 @@ $client->companies->listAttachedContacts(
-
$client->companies->listAttachedSegments($request) -> CompanyAttachedSegments +
$client->companies->listAttachedSegments($request) -> ?CompanyAttachedSegments
@@ -3087,7 +3111,7 @@ $client->companies->listAttachedSegments(
-
$client->companies->list($request) -> CompanyList +
$client->companies->list($request) -> ?CompanyList
@@ -3243,7 +3267,7 @@ $client->companies->scroll(
-
$client->companies->attachContact($request) -> Company +
$client->companies->attachContact($request) -> ?Company
@@ -3310,7 +3334,7 @@ $client->companies->attachContact(
-
$client->companies->detachContact($request) -> Company +
$client->companies->detachContact($request) -> ?Company
@@ -3378,7 +3402,7 @@ $client->companies->detachContact(
## Contacts -
$client->contacts->listAttachedCompanies($request) -> ContactAttachedCompanies +
$client->contacts->listAttachedCompanies($request) -> ?ContactAttachedCompanies
@@ -3454,7 +3478,7 @@ $client->contacts->listAttachedCompanies(
-
$client->contacts->listAttachedSegments($request) -> ContactSegments +
$client->contacts->listAttachedSegments($request) -> ?ContactSegments
@@ -3512,7 +3536,7 @@ $client->contacts->listAttachedSegments(
-
$client->contacts->listAttachedSubscriptions($request) -> SubscriptionTypeList +
$client->contacts->listAttachedSubscriptions($request) -> ?SubscriptionTypeList
@@ -3576,7 +3600,7 @@ $client->contacts->listAttachedSubscriptions(
-
$client->contacts->attachSubscription($request) -> SubscriptionType +
$client->contacts->attachSubscription($request) -> ?SubscriptionType
@@ -3658,7 +3682,7 @@ $client->contacts->attachSubscription(
-
$client->contacts->detachSubscription($request) -> SubscriptionType +
$client->contacts->detachSubscription($request) -> ?SubscriptionType
@@ -3725,7 +3749,7 @@ $client->contacts->detachSubscription(
-
$client->contacts->listAttachedTags($request) -> TagList +
$client->contacts->listAttachedTags($request) -> ?TagList
@@ -3783,7 +3807,7 @@ $client->contacts->listAttachedTags(
-
$client->contacts->find($request) -> ContactsFindResponse +
$client->contacts->find($request) -> ?ContactsFindResponse
@@ -3841,7 +3865,7 @@ $client->contacts->find(
-
$client->contacts->update($request) -> ContactsUpdateResponse +
$client->contacts->update($request) -> ?ContactsUpdateResponse
@@ -3995,7 +4019,7 @@ $client->contacts->update(
-
$client->contacts->delete($request) -> ContactDeleted +
$client->contacts->delete($request) -> ?ContactDeleted
@@ -4053,7 +4077,7 @@ $client->contacts->delete(
-
$client->contacts->mergeLeadInUser($request) -> ContactsMergeLeadInUserResponse +
$client->contacts->mergeLeadInUser($request) -> ?ContactsMergeLeadInUserResponse
@@ -4120,7 +4144,7 @@ $client->contacts->mergeLeadInUser(
-
$client->contacts->search($request) -> ContactList +
$client->contacts->search($request) -> ?ContactList
@@ -4247,7 +4271,9 @@ The table below shows the operators you can use to define how you want to search ```php $client->unstable->contacts->searchContacts( new SearchRequest([ - 'query' => new SingleFilterSearchRequest([]), + 'query' => new SingleFilterSearchRequest([ + 'value' => [], + ]), 'pagination' => new StartingAfterPaging([ 'perPage' => 5, ]), @@ -4279,7 +4305,7 @@ $client->unstable->contacts->searchContacts(
-
$client->contacts->list($request) -> ContactList +
$client->contacts->list($request) -> ?ContactList
@@ -4311,7 +4337,11 @@ You can fetch a list of all contacts (ie. users or leads) in your workspace. ```php $client->contacts->list( - new ListContactsRequest([]), + new ListContactsRequest([ + 'page' => 1, + 'perPage' => 1, + 'startingAfter' => 'starting_after', + ]), ); ```
@@ -4355,7 +4385,7 @@ $client->contacts->list(
-
$client->contacts->create($request) -> ContactsCreateResponse +
$client->contacts->create($request) -> ?ContactsCreateResponse
@@ -4413,7 +4443,7 @@ $client->contacts->create(
-
$client->contacts->showContactByExternalId($request) -> ShowContactByExternalIdResponse +
$client->contacts->showContactByExternalId($request) -> ?ShowContactByExternalIdResponse
@@ -4471,7 +4501,7 @@ $client->contacts->showContactByExternalId(
-
$client->contacts->archive($request) -> ContactArchived +
$client->contacts->archive($request) -> ?ContactArchived
@@ -4529,7 +4559,7 @@ $client->contacts->archive(
-
$client->contacts->unarchive($request) -> ContactUnarchived +
$client->contacts->unarchive($request) -> ?ContactUnarchived
@@ -4587,7 +4617,7 @@ $client->contacts->unarchive(
-
$client->contacts->blockContact($request) -> ContactBlocked +
$client->contacts->blockContact($request) -> ?ContactBlocked
@@ -4646,7 +4676,7 @@ $client->contacts->blockContact(
## Notes -
$client->notes->list($request) -> NoteList +
$client->notes->list($request) -> ?NoteList
@@ -4676,6 +4706,8 @@ You can fetch a list of notes that are associated to a contact. $client->notes->list( new ListContactNotesRequest([ 'contactId' => 'contact_id', + 'page' => 1, + 'perPage' => 1, ]), ); ``` @@ -4720,7 +4752,7 @@ $client->notes->list(
-
$client->notes->create($request) -> Note +
$client->notes->create($request) -> ?Note
@@ -4796,7 +4828,7 @@ $client->notes->create(
-
$client->notes->find($request) -> Note +
$client->notes->find($request) -> ?Note
@@ -4855,7 +4887,7 @@ $client->notes->find(
## Tags -
$client->tags->tagContact($request) -> Tag +
$client->tags->tagContact($request) -> ?Tag
@@ -4922,7 +4954,7 @@ $client->tags->tagContact(
-
$client->tags->untagContact($request) -> Tag +
$client->tags->untagContact($request) -> ?Tag
@@ -4989,7 +5021,7 @@ $client->tags->untagContact(
-
$client->tags->tagConversation($request) -> Tag +
$client->tags->tagConversation($request) -> ?Tag
@@ -5065,7 +5097,7 @@ $client->tags->tagConversation(
-
$client->tags->untagConversation($request) -> Tag +
$client->tags->untagConversation($request) -> ?Tag
@@ -5141,7 +5173,7 @@ $client->tags->untagConversation(
-
$client->tags->list() -> TagList +
$client->tags->list() -> ?TagList
@@ -5181,7 +5213,7 @@ $client->tags->list();
-
$client->tags->create($request) -> Tag +
$client->tags->create($request) -> ?Tag
@@ -5251,7 +5283,7 @@ $client->tags->create(
-
$client->tags->find($request) -> Tag +
$client->tags->find($request) -> ?Tag
@@ -5368,7 +5400,7 @@ $client->tags->delete(
-
$client->tags->tagTicket($request) -> Tag +
$client->tags->tagTicket($request) -> ?Tag
@@ -5444,7 +5476,7 @@ $client->tags->tagTicket(
-
$client->tags->untagTicket($request) -> Tag +
$client->tags->untagTicket($request) -> ?Tag
@@ -5521,7 +5553,7 @@ $client->tags->untagTicket(
## Conversations -
$client->conversations->list($request) -> ConversationList +
$client->conversations->list($request) -> ?ConversationList
@@ -5594,7 +5626,7 @@ $client->conversations->list(
-
$client->conversations->create($request) -> Message +
$client->conversations->create($request) -> ?Message
@@ -5681,7 +5713,7 @@ $client->conversations->create(
-
$client->conversations->find($request) -> Conversation +
$client->conversations->find($request) -> ?Conversation
@@ -5766,7 +5798,7 @@ $client->conversations->find(
-
$client->conversations->update($request) -> Conversation +
$client->conversations->update($request) -> ?Conversation
@@ -5883,7 +5915,7 @@ $client->conversations->update(
-
$client->conversations->deleteConversation($request) -> ConversationDeleted +
$client->conversations->deleteConversation($request) -> ?ConversationDeleted
@@ -5941,7 +5973,7 @@ $client->conversations->deleteConversation(
-
$client->conversations->search($request) -> ConversationList +
$client->conversations->search($request) -> ?ConversationList
@@ -6068,7 +6100,9 @@ The table below shows the operators you can use to define how you want to search ```php $client->unstable->conversations->searchConversations( new SearchRequest([ - 'query' => new SingleFilterSearchRequest([]), + 'query' => new SingleFilterSearchRequest([ + 'value' => [], + ]), 'pagination' => new StartingAfterPaging([ 'perPage' => 5, ]), @@ -6100,7 +6134,7 @@ $client->unstable->conversations->searchConversations(
-
$client->conversations->reply($request) -> Conversation +
$client->conversations->reply($request) -> ?Conversation
@@ -6172,7 +6206,7 @@ $client->conversations->reply(
-
$client->conversations->manage($request) -> Conversation +
$client->conversations->manage($request) -> ?Conversation
@@ -6246,7 +6280,7 @@ $client->conversations->manage(
-
$client->conversations->attachContactAsAdmin($request) -> Conversation +
$client->conversations->attachContactAsAdmin($request) -> ?Conversation
@@ -6329,7 +6363,7 @@ $client->conversations->attachContactAsAdmin(
-
$client->conversations->detachContactAsAdmin($request) -> Conversation +
$client->conversations->detachContactAsAdmin($request) -> ?Conversation
@@ -6410,7 +6444,7 @@ $client->conversations->detachContactAsAdmin(
-
$client->conversations->redactConversationPart($request) -> Conversation +
$client->conversations->redactConversationPart($request) -> ?Conversation
@@ -6549,7 +6583,7 @@ $client->conversations->convertToTicket(
-
$client->conversations->runAssignmentRules($request) -> Conversation +
$client->conversations->runAssignmentRules($request) -> ?Conversation
@@ -6614,7 +6648,7 @@ $client->conversations->runAssignmentRules(
## Custom Channel Events -
$client->customChannelEvents->notifyNewConversation($request) -> CustomChannelNotificationResponse +
$client->customChannelEvents->notifyNewConversation($request) -> ?CustomChannelNotificationResponse
@@ -6649,6 +6683,8 @@ $client->customChannelEvents->notifyNewConversation( 'contact' => new CustomChannelContact([ 'type' => CustomChannelContactType::User->value, 'externalId' => 'external_id', + 'name' => 'name', + 'email' => 'email', ]), ]), ); @@ -6678,7 +6714,7 @@ $client->customChannelEvents->notifyNewConversation(
-
$client->customChannelEvents->notifyNewMessage($request) -> CustomChannelNotificationResponse +
$client->customChannelEvents->notifyNewMessage($request) -> ?CustomChannelNotificationResponse
@@ -6713,6 +6749,8 @@ $client->customChannelEvents->notifyNewMessage( 'contact' => new CustomChannelContact([ 'type' => CustomChannelContactType::User->value, 'externalId' => 'external_id', + 'name' => 'name', + 'email' => 'email', ]), 'body' => 'body', ]), @@ -6743,7 +6781,7 @@ $client->customChannelEvents->notifyNewMessage(
-
$client->customChannelEvents->notifyQuickReplySelected($request) -> CustomChannelNotificationResponse +
$client->customChannelEvents->notifyQuickReplySelected($request) -> ?CustomChannelNotificationResponse
@@ -6810,7 +6848,7 @@ $client->customChannelEvents->notifyQuickReplySelected(
-
$client->customChannelEvents->notifyAttributeCollected($request) -> CustomChannelNotificationResponse +
$client->customChannelEvents->notifyAttributeCollected($request) -> ?CustomChannelNotificationResponse
@@ -6845,6 +6883,8 @@ $client->customChannelEvents->notifyAttributeCollected( 'contact' => new CustomChannelContact([ 'type' => CustomChannelContactType::User->value, 'externalId' => 'external_id', + 'name' => 'name', + 'email' => 'email', ]), 'attribute' => new CustomChannelAttribute([ 'id' => 'id', @@ -6934,7 +6974,7 @@ $client->customObjectInstances->getCustomObjectInstancesByExternalId(
-**$externalId:** `string` +**$externalId:** `string` — The unique identifier for the instance in the external system it originated from.
@@ -7043,7 +7083,7 @@ $client->customObjectInstances->createCustomObjectInstances(
-
$client->customObjectInstances->deleteCustomObjectInstancesById($request) -> CustomObjectInstanceDeleted +
$client->customObjectInstances->deleteCustomObjectInstancesById($request) -> ?CustomObjectInstanceDeleted
@@ -7098,7 +7138,7 @@ $client->customObjectInstances->deleteCustomObjectInstancesById(
-**$externalId:** `string` +**$externalId:** `string` — The unique identifier for the instance in the external system it originated from.
@@ -7177,7 +7217,7 @@ $client->customObjectInstances->getCustomObjectInstancesById(
-
$client->customObjectInstances->deleteCustomObjectInstancesByExternalId($request) -> CustomObjectInstanceDeleted +
$client->customObjectInstances->deleteCustomObjectInstancesByExternalId($request) -> ?CustomObjectInstanceDeleted
@@ -7245,7 +7285,7 @@ $client->customObjectInstances->deleteCustomObjectInstancesByExternalId(
## Data Attributes -
$client->dataAttributes->list($request) -> DataAttributeList +
$client->dataAttributes->list($request) -> ?DataAttributeList
@@ -7312,7 +7352,7 @@ $client->dataAttributes->list(
-
$client->dataAttributes->create($request) -> DataAttribute +
$client->dataAttributes->create($request) -> ?DataAttribute
@@ -7342,6 +7382,9 @@ You can create a data attributes for a `contact` or a `company`. $client->dataAttributes->create( new CreateDataAttributeRequestOptions([ 'dataType' => 'string', + 'options' => [ + new CreateDataAttributeRequestOptionsOptionsItem([]), + ], ]), ); ``` @@ -7370,7 +7413,7 @@ $client->dataAttributes->create(
-
$client->dataAttributes->update($request) -> DataAttribute +
$client->dataAttributes->update($request) -> ?DataAttribute
@@ -7405,12 +7448,12 @@ You can update a data attribute. $client->dataAttributes->update( new UpdateDataAttributeRequest([ 'dataAttributeId' => 1, - 'body' => new UpdateDataAttributeRequestOptions([ + 'body' => new UpdateDataAttributeRequestBodyOptions([ 'options' => [ - new UpdateDataAttributeRequestOptionsOptionsItem([ + new UpdateDataAttributeRequestBodyOptionsOptionsItem([ 'value' => '1-10', ]), - new UpdateDataAttributeRequestOptionsOptionsItem([ + new UpdateDataAttributeRequestBodyOptionsOptionsItem([ 'value' => '11-20', ]), ], @@ -7452,7 +7495,7 @@ $client->dataAttributes->update(
## Events -
$client->events->list($request) -> DataEventSummary +
$client->events->list($request) -> ?DataEventSummary
@@ -7494,11 +7537,14 @@ You can optionally define the result page size as well with the `per_page` param ```php $client->events->list( new ListEventsRequest([ + 'filter' => new EventsListRequestFilterUserId([ + 'userId' => 'user_id', + ]), + 'type' => 'type', + 'summary' => true, 'userId' => 'user_id', 'intercomUserId' => 'intercom_user_id', 'email' => 'email', - 'type' => 'type', - 'summary' => true, 'perPage' => 1, ]), ); @@ -7516,7 +7562,7 @@ $client->events->list(
-**$userId:** `?string` — user_id query parameter +**$filter:** `EventsListRequestFilterUserId|EventsListRequestFilterIntercomUserId|EventsListRequestFilterEmail`
@@ -7524,7 +7570,7 @@ $client->events->list(
-**$intercomUserId:** `?string` — intercom_user_id query parameter +**$type:** `string` — The value must be user
@@ -7532,7 +7578,7 @@ $client->events->list(
-**$email:** `?string` — email query parameter +**$summary:** `?bool` — summary flag
@@ -7540,7 +7586,7 @@ $client->events->list(
-**$type:** `string` — The value must be user +**$userId:** `?string` — user_id query parameter
@@ -7548,7 +7594,15 @@ $client->events->list(
-**$summary:** `?bool` — summary flag +**$intercomUserId:** `?string` — intercom_user_id query parameter + +
+
+ +
+
+ +**$email:** `?string` — email query parameter
@@ -7735,7 +7789,7 @@ $client->events->summaries(
## Jobs -
$client->jobs->status($request) -> Jobs +
$client->jobs->status($request) -> ?Jobs
@@ -7794,7 +7848,7 @@ $client->jobs->status(
## Messages -
$client->messages->create($request) -> Message +
$client->messages->create($request) -> ?Message
@@ -7873,7 +7927,7 @@ $client->messages->create(
## Segments -
$client->segments->list($request) -> SegmentList +
$client->segments->list($request) -> ?SegmentList
@@ -7931,7 +7985,7 @@ $client->segments->list(
-
$client->segments->find($request) -> Segment +
$client->segments->find($request) -> ?Segment
@@ -7990,7 +8044,7 @@ $client->segments->find(
## Subscription Types -
$client->subscriptionTypes->list() -> SubscriptionTypeList +
$client->subscriptionTypes->list() -> ?SubscriptionTypeList
@@ -8096,7 +8150,7 @@ $client->phoneCallRedirects->create(
## Calls -
$client->calls->listCalls($request) -> CallList +
$client->calls->listCalls($request) -> ?CallList
@@ -8163,7 +8217,7 @@ $client->calls->listCalls(
-
$client->calls->showCall($request) -> Call +
$client->calls->showCall($request) -> ?Call
@@ -8337,7 +8391,7 @@ $client->calls->showCallTranscript(
-
$client->calls->listCallsWithTranscripts($request) -> ListCallsWithTranscriptsResponse +
$client->calls->listCallsWithTranscripts($request) -> ?ListCallsWithTranscriptsResponse
@@ -8400,7 +8454,7 @@ $client->calls->listCallsWithTranscripts(
## Teams -
$client->teams->list() -> TeamList +
$client->teams->list() -> ?TeamList
@@ -8439,7 +8493,7 @@ $client->teams->list();
-
$client->teams->find($request) -> Team +
$client->teams->find($request) -> ?Team
@@ -8498,7 +8552,7 @@ $client->teams->find(
## Ticket States -
$client->ticketStates->listTicketStates() -> TicketStateList +
$client->ticketStates->listTicketStates() -> ?TicketStateList
@@ -8538,7 +8592,7 @@ $client->ticketStates->listTicketStates();
## Ticket Types -
$client->ticketTypes->list() -> TicketTypeList +
$client->ticketTypes->list() -> ?TicketTypeList
@@ -8813,7 +8867,7 @@ $client->ticketTypes->update(
## Tickets -
$client->tickets->reply($request) -> TicketReply +
$client->tickets->reply($request) -> ?TicketReply
@@ -8865,7 +8919,7 @@ $client->tickets->reply(
-**$ticketId:** `string` +**$ticketId:** `string` — The id of the ticket to target.
@@ -8916,7 +8970,7 @@ $client->tickets->create( new CreateTicketRequest([ 'ticketTypeId' => '1234', 'contacts' => [ - new CreateTicketRequestContactsItemId([ + new CreateTicketRequestBodyContactsItemId([ 'id' => '6762f2d81bb69f9f2193bc54', ]), ], @@ -8948,7 +9002,7 @@ $client->tickets->create(
-
$client->tickets->enqueueCreateTicket($request) -> Jobs +
$client->tickets->enqueueCreateTicket($request) -> ?Jobs
@@ -8979,7 +9033,7 @@ $client->tickets->enqueueCreateTicket( new EnqueueCreateTicketRequest([ 'ticketTypeId' => '1234', 'contacts' => [ - new CreateTicketRequestContactsItemId([ + new CreateTicketRequestBodyContactsItemId([ 'id' => '6762f2d81bb69f9f2193bc54', ]), ], @@ -9200,7 +9254,7 @@ $client->tickets->update(
-
$client->tickets->deleteTicket($request) -> DeleteTicketResponse +
$client->tickets->deleteTicket($request) -> ?DeleteTicketResponse
@@ -9258,7 +9312,7 @@ $client->tickets->deleteTicket(
-
$client->tickets->search($request) -> TicketList +
$client->tickets->search($request) -> ?TicketList
@@ -9355,7 +9409,9 @@ The table below shows the operators you can use to define how you want to search ```php $client->unstable->tickets->searchTickets( new SearchRequest([ - 'query' => new SingleFilterSearchRequest([]), + 'query' => new SingleFilterSearchRequest([ + 'value' => [], + ]), 'pagination' => new StartingAfterPaging([ 'perPage' => 5, ]), @@ -9509,7 +9565,7 @@ $client->visitors->update(
-
$client->visitors->mergeToContact($request) -> Contact +
$client->visitors->mergeToContact($request) -> ?Contact
@@ -9595,7 +9651,7 @@ $client->unstable->visitors->convertVisitor(
## HelpCenters Collections -
$client->helpCenters->collections->list($request) -> CollectionList +
$client->helpCenters->collections->list($request) -> ?CollectionList
@@ -9625,7 +9681,10 @@ Collections will be returned in descending order on the `updated_at` attribute. ```php $client->helpCenters->collections->list( - new ListCollectionsRequest([]), + new ListCollectionsRequest([ + 'page' => 1, + 'perPage' => 1, + ]), ); ```
@@ -9661,7 +9720,7 @@ $client->helpCenters->collections->list(
-
$client->helpCenters->collections->create($request) -> Collection +
$client->helpCenters->collections->create($request) -> ?Collection
@@ -9751,7 +9810,7 @@ $client->helpCenters->collections->create(
-
$client->helpCenters->collections->find($request) -> Collection +
$client->helpCenters->collections->find($request) -> ?Collection
@@ -9809,7 +9868,7 @@ $client->helpCenters->collections->find(
-
$client->helpCenters->collections->update($request) -> Collection +
$client->helpCenters->collections->update($request) -> ?Collection
@@ -9900,7 +9959,7 @@ $client->helpCenters->collections->update(
-
$client->helpCenters->collections->delete($request) -> DeletedCollectionObject +
$client->helpCenters->collections->delete($request) -> ?DeletedCollectionObject
@@ -9959,7 +10018,7 @@ $client->helpCenters->collections->delete(
## News Items -
$client->news->items->list() -> PaginatedResponse +
$client->news->items->list() -> ?PaginatedResponse
@@ -9998,7 +10057,7 @@ $client->news->items->list();
-
$client->news->items->create($request) -> NewsItem +
$client->news->items->create($request) -> ?NewsItem
@@ -10075,7 +10134,7 @@ $client->news->items->create(
-
$client->news->items->find($request) -> NewsItem +
$client->news->items->find($request) -> ?NewsItem
@@ -10133,7 +10192,7 @@ $client->news->items->find(
-
$client->news->items->update($request) -> NewsItem +
$client->news->items->update($request) -> ?NewsItem
@@ -10194,7 +10253,7 @@ $client->news->items->update(
-
$client->news->items->delete($request) -> DeletedObject +
$client->news->items->delete($request) -> ?DeletedObject
@@ -10253,7 +10312,7 @@ $client->news->items->delete(
## News Feeds -
$client->news->feeds->listItems($request) -> PaginatedResponse +
$client->news->feeds->listItems($request) -> ?PaginatedResponse
@@ -10311,7 +10370,7 @@ $client->news->feeds->listItems(
-
$client->news->feeds->list() -> PaginatedResponse +
$client->news->feeds->list() -> ?PaginatedResponse
@@ -10350,7 +10409,7 @@ $client->news->feeds->list();
-
$client->news->feeds->find($request) -> Newsfeed +
$client->news->feeds->find($request) -> ?Newsfeed
@@ -10829,7 +10888,7 @@ $client->unstable->admins->setAwayAdmin(
-
$client->unstable->admins->listActivityLogs($request) -> ActivityLogList +
$client->unstable->admins->listActivityLogs($request) -> ?ActivityLogList
@@ -10896,7 +10955,7 @@ $client->admins->listAllActivityLogs(
-
$client->unstable->admins->listAdmins() -> AdminList +
$client->unstable->admins->listAdmins() -> ?AdminList
@@ -10994,7 +11053,7 @@ $client->unstable->admins->retrieveAdmin(
## AI Content -
$client->unstable->aiContent->listContentImportSources() -> ContentImportSourcesList +
$client->unstable->aiContent->listContentImportSources() -> ?ContentImportSourcesList
@@ -11033,7 +11092,7 @@ $client->aiContent->listContentImportSources();
-
$client->unstable->aiContent->createContentImportSource($request) -> ContentImportSource +
$client->unstable->aiContent->createContentImportSource($request) -> ?ContentImportSource
@@ -11108,7 +11167,7 @@ $client->aiContent->createContentImportSource(
-
$client->unstable->aiContent->getContentImportSource($request) -> ContentImportSource +
$client->unstable->aiContent->getContentImportSource($request) -> ?ContentImportSource
@@ -11152,7 +11211,7 @@ $client->unstable->aiContent->getContentImportSource(
-
$client->unstable->aiContent->updateContentImportSource($request) -> ContentImportSource +
$client->unstable->aiContent->updateContentImportSource($request) -> ?ContentImportSource
@@ -11294,7 +11353,7 @@ $client->unstable->aiContent->deleteContentImportSource(
-
$client->unstable->aiContent->listExternalPages() -> ExternalPagesList +
$client->unstable->aiContent->listExternalPages() -> ?ExternalPagesList
@@ -11333,7 +11392,7 @@ $client->aiContent->listExternalPages();
-
$client->unstable->aiContent->createExternalPage($request) -> ExternalPage +
$client->unstable->aiContent->createExternalPage($request) -> ?ExternalPage
@@ -11452,7 +11511,7 @@ $client->aiContent->createExternalPage(
-
$client->unstable->aiContent->getExternalPage($request) -> ExternalPage +
$client->unstable->aiContent->getExternalPage($request) -> ?ExternalPage
@@ -11510,7 +11569,7 @@ $client->unstable->aiContent->getExternalPage(
-
$client->unstable->aiContent->updateExternalPage($request) -> ExternalPage +
$client->unstable->aiContent->updateExternalPage($request) -> ?ExternalPage
@@ -11630,7 +11689,7 @@ $client->unstable->aiContent->updateExternalPage(
-
$client->unstable->aiContent->deleteExternalPage($request) -> ExternalPage +
$client->unstable->aiContent->deleteExternalPage($request) -> ?ExternalPage
@@ -11689,7 +11748,7 @@ $client->unstable->aiContent->deleteExternalPage(
## Articles -
$client->unstable->articles->listArticles() -> ArticleList +
$client->unstable->articles->listArticles() -> ?ArticleList
@@ -11734,7 +11793,7 @@ $client->articles->list(
-
$client->unstable->articles->createArticle($request) -> Article +
$client->unstable->articles->createArticle($request) -> ?Article
@@ -11792,7 +11851,7 @@ $client->unstable->articles->createArticle(
-
$client->unstable->articles->retrieveArticle($request) -> Article +
$client->unstable->articles->retrieveArticle($request) -> ?Article
@@ -11850,7 +11909,7 @@ $client->unstable->articles->retrieveArticle(
-
$client->unstable->articles->deleteArticle($request) -> DeletedArticleObject +
$client->unstable->articles->deleteArticle($request) -> ?DeletedArticleObject
@@ -11908,7 +11967,7 @@ $client->unstable->articles->deleteArticle(
-
$client->unstable->articles->searchArticles($request) -> ArticleSearchResponse +
$client->unstable->articles->searchArticles($request) -> ?ArticleSearchResponse
@@ -11994,7 +12053,7 @@ $client->articles->search(
## Away Status Reasons -
$client->unstable->awayStatusReasons->listAwayStatusReasons() -> array +
$client->unstable->awayStatusReasons->listAwayStatusReasons() -> ?array
@@ -12034,7 +12093,7 @@ $client->awayStatusReasons->listAwayStatusReasons();
## Unstable Export -
$client->unstable->export->enqueueANewReportingDataExportJob($request) -> PostExportReportingDataEnqueueResponse +
$client->unstable->export->enqueueANewReportingDataExportJob($request) -> ?PostExportReportingDataEnqueueResponse
@@ -12108,7 +12167,7 @@ $client->export->enqueueANewReportingDataExportJob(
-
$client->unstable->export->listAvailableDatasetsAndAttributes() -> GetExportReportingDataGetDatasetsResponse +
$client->unstable->export->listAvailableDatasetsAndAttributes() -> ?GetExportReportingDataGetDatasetsResponse
@@ -12134,7 +12193,7 @@ $client->export->listAvailableDatasetsAndAttributes();
## Help Center -
$client->unstable->helpCenter->listAllCollections() -> CollectionList +
$client->unstable->helpCenter->listAllCollections() -> ?CollectionList
@@ -12177,7 +12236,7 @@ $client->helpCenters->collections->list(
-
$client->unstable->helpCenter->createCollection($request) -> Collection +
$client->unstable->helpCenter->createCollection($request) -> ?Collection
@@ -12267,7 +12326,7 @@ $client->helpCenters->collections->create(
-
$client->unstable->helpCenter->retrieveCollection($request) -> Collection +
$client->unstable->helpCenter->retrieveCollection($request) -> ?Collection
@@ -12325,7 +12384,7 @@ $client->unstable->helpCenter->retrieveCollection(
-
$client->unstable->helpCenter->updateCollection($request) -> Collection +
$client->unstable->helpCenter->updateCollection($request) -> ?Collection
@@ -12416,7 +12475,7 @@ $client->unstable->helpCenter->updateCollection(
-
$client->unstable->helpCenter->deleteCollection($request) -> DeletedCollectionObject +
$client->unstable->helpCenter->deleteCollection($request) -> ?DeletedCollectionObject
@@ -12474,7 +12533,7 @@ $client->unstable->helpCenter->deleteCollection(
-
$client->unstable->helpCenter->retrieveHelpCenter($request) -> HelpCenter +
$client->unstable->helpCenter->retrieveHelpCenter($request) -> ?HelpCenter
@@ -12532,7 +12591,7 @@ $client->unstable->helpCenter->retrieveHelpCenter(
-
$client->unstable->helpCenter->listHelpCenters() -> HelpCenterList +
$client->unstable->helpCenter->listHelpCenters() -> ?HelpCenterList
@@ -12574,7 +12633,7 @@ $client->helpCenters->list(
## Internal Articles -
$client->unstable->internalArticles->listInternalArticles() -> InternalArticleList +
$client->unstable->internalArticles->listInternalArticles() -> ?InternalArticleList
@@ -12613,7 +12672,7 @@ $client->internalArticles->listInternalArticles();
-
$client->unstable->internalArticles->createInternalArticle($request) -> InternalArticleListItem +
$client->unstable->internalArticles->createInternalArticle($request) -> ?InternalArticleListItem
@@ -12674,7 +12733,7 @@ $client->internalArticles->createInternalArticle(
-
$client->unstable->internalArticles->retrieveInternalArticle($request) -> InternalArticleListItem +
$client->unstable->internalArticles->retrieveInternalArticle($request) -> ?InternalArticleListItem
@@ -12732,7 +12791,7 @@ $client->unstable->internalArticles->retrieveInternalArticle(
-
$client->unstable->internalArticles->updateInternalArticle($request) -> InternalArticleListItem +
$client->unstable->internalArticles->updateInternalArticle($request) -> ?InternalArticleListItem
@@ -12824,7 +12883,7 @@ $client->unstable->internalArticles->updateInternalArticle(
-
$client->unstable->internalArticles->deleteInternalArticle($request) -> DeletedInternalArticleObject +
$client->unstable->internalArticles->deleteInternalArticle($request) -> ?DeletedInternalArticleObject
@@ -12882,7 +12941,7 @@ $client->unstable->internalArticles->deleteInternalArticle(
-
$client->unstable->internalArticles->searchInternalArticles($request) -> InternalArticleSearchResponse +
$client->unstable->internalArticles->searchInternalArticles($request) -> ?InternalArticleSearchResponse
@@ -12941,7 +13000,7 @@ $client->internalArticles->searchInternalArticles(
## Companies -
$client->unstable->companies->retrieveCompany($request) -> CompanyList +
$client->unstable->companies->retrieveCompany($request) -> ?CompanyList
@@ -13054,7 +13113,7 @@ $client->companies->retrieve(
-
$client->unstable->companies->createOrUpdateCompany($request) -> Company +
$client->unstable->companies->createOrUpdateCompany($request) -> ?Company
@@ -13120,7 +13179,7 @@ $client->unstable->companies->createOrUpdateCompany(
-
$client->unstable->companies->retrieveACompanyById($request) -> Company +
$client->unstable->companies->retrieveACompanyById($request) -> ?Company
@@ -13178,7 +13237,7 @@ $client->unstable->companies->retrieveACompanyById(
-
$client->unstable->companies->updateCompany($request) -> Company +
$client->unstable->companies->updateCompany($request) -> ?Company
@@ -13240,7 +13299,7 @@ $client->unstable->companies->updateCompany(
-
$client->unstable->companies->deleteCompany($request) -> DeletedCompanyObject +
$client->unstable->companies->deleteCompany($request) -> ?DeletedCompanyObject
@@ -13298,7 +13357,7 @@ $client->unstable->companies->deleteCompany(
-
$client->unstable->companies->listAttachedContacts($request) -> CompanyAttachedContacts +
$client->unstable->companies->listAttachedContacts($request) -> ?CompanyAttachedContacts
@@ -13356,7 +13415,7 @@ $client->unstable->companies->listAttachedContacts(
-
$client->unstable->companies->listAttachedSegmentsForCompanies($request) -> CompanyAttachedSegments +
$client->unstable->companies->listAttachedSegmentsForCompanies($request) -> ?CompanyAttachedSegments
@@ -13414,7 +13473,7 @@ $client->unstable->companies->listAttachedSegmentsForCompanies(
-
$client->unstable->companies->listAllCompanies($request) -> CompanyList +
$client->unstable->companies->listAllCompanies($request) -> ?CompanyList
@@ -13570,7 +13629,7 @@ $client->companies->scroll(
-
$client->unstable->companies->attachContactToACompany($request) -> Company +
$client->unstable->companies->attachContactToACompany($request) -> ?Company
@@ -13637,7 +13696,7 @@ $client->unstable->companies->attachContactToACompany(
-
$client->unstable->companies->detachContactFromACompany($request) -> Company +
$client->unstable->companies->detachContactFromACompany($request) -> ?Company
@@ -13705,7 +13764,7 @@ $client->unstable->companies->detachContactFromACompany(
## Notes -
$client->unstable->notes->listCompanyNotes($request) -> NoteList +
$client->unstable->notes->listCompanyNotes($request) -> ?NoteList
@@ -13763,7 +13822,7 @@ $client->unstable->notes->listCompanyNotes(
-
$client->unstable->notes->listNotes($request) -> NoteList +
$client->unstable->notes->listNotes($request) -> ?NoteList
@@ -13821,7 +13880,7 @@ $client->unstable->notes->listNotes(
-
$client->unstable->notes->createNote($request) -> Note +
$client->unstable->notes->createNote($request) -> ?Note
@@ -13906,7 +13965,7 @@ $client->unstable->notes->createNote(
-
$client->unstable->notes->retrieveNote($request) -> Note +
$client->unstable->notes->retrieveNote($request) -> ?Note
@@ -13965,7 +14024,7 @@ $client->unstable->notes->retrieveNote(
## Contacts -
$client->unstable->contacts->listCompaniesForAContact($request) -> ContactAttachedCompanies +
$client->unstable->contacts->listCompaniesForAContact($request) -> ?ContactAttachedCompanies
@@ -14023,7 +14082,7 @@ $client->unstable->contacts->listCompaniesForAContact(
-
$client->unstable->contacts->listSegmentsForAContact($request) -> ContactSegments +
$client->unstable->contacts->listSegmentsForAContact($request) -> ?ContactSegments
@@ -14081,7 +14140,7 @@ $client->contacts->listAttachedSegments(
-
$client->unstable->contacts->listSubscriptionsForAContact($request) -> SubscriptionTypeList +
$client->unstable->contacts->listSubscriptionsForAContact($request) -> ?SubscriptionTypeList
@@ -14145,7 +14204,7 @@ $client->contacts->listAttachedSubscriptions(
-
$client->unstable->contacts->listTagsForAContact($request) -> TagList +
$client->unstable->contacts->listTagsForAContact($request) -> ?TagList
@@ -14203,7 +14262,7 @@ $client->contacts->listAttachedTags(
-
$client->unstable->contacts->showContact($request) -> ShowContactResponse +
$client->unstable->contacts->showContact($request) -> ?ShowContactResponse
@@ -14261,7 +14320,7 @@ $client->unstable->contacts->showContact(
-
$client->unstable->contacts->updateContact($request) -> UpdateContactResponse +
$client->unstable->contacts->updateContact($request) -> ?UpdateContactResponse
@@ -14423,7 +14482,7 @@ $client->unstable->contacts->updateContact(
-
$client->unstable->contacts->deleteContact($request) -> ContactDeleted +
$client->unstable->contacts->deleteContact($request) -> ?ContactDeleted
@@ -14481,7 +14540,7 @@ $client->unstable->contacts->deleteContact(
-
$client->unstable->contacts->mergeContact($request) -> MergeContactResponse +
$client->unstable->contacts->mergeContact($request) -> ?MergeContactResponse
@@ -14548,7 +14607,7 @@ $client->contacts->mergeLeadInUser(
-
$client->unstable->contacts->searchContacts($request) -> ContactList +
$client->unstable->contacts->searchContacts($request) -> ?ContactList
@@ -14676,7 +14735,9 @@ The table below shows the operators you can use to define how you want to search ```php $client->unstable->contacts->searchContacts( new SearchRequest([ - 'query' => new SingleFilterSearchRequest([]), + 'query' => new SingleFilterSearchRequest([ + 'value' => [], + ]), 'pagination' => new StartingAfterPaging([ 'perPage' => 5, ]), @@ -14708,7 +14769,7 @@ $client->unstable->contacts->searchContacts(
-
$client->unstable->contacts->listContacts() -> ContactList +
$client->unstable->contacts->listContacts() -> ?ContactList
@@ -14753,7 +14814,7 @@ $client->contacts->list(
-
$client->unstable->contacts->createContact($request) -> CreateContactResponse +
$client->unstable->contacts->createContact($request) -> ?CreateContactResponse
@@ -14811,7 +14872,7 @@ $client->contacts->create(
-
$client->unstable->contacts->showContactByExternalId($request) -> ShowContactByExternalIdResponse +
$client->unstable->contacts->showContactByExternalId($request) -> ?ShowContactByExternalIdResponse
@@ -14869,7 +14930,7 @@ $client->contacts->showContactByExternalId(
-
$client->unstable->contacts->archiveContact($request) -> ContactArchived +
$client->unstable->contacts->archiveContact($request) -> ?ContactArchived
@@ -14927,7 +14988,7 @@ $client->unstable->contacts->archiveContact(
-
$client->unstable->contacts->unarchiveContact($request) -> ContactUnarchived +
$client->unstable->contacts->unarchiveContact($request) -> ?ContactUnarchived
@@ -14985,7 +15046,7 @@ $client->unstable->contacts->unarchiveContact(
-
$client->unstable->contacts->blockContact($request) -> ContactBlocked +
$client->unstable->contacts->blockContact($request) -> ?ContactBlocked
@@ -15044,7 +15105,7 @@ $client->unstable->contacts->blockContact(
## Subscription Types -
$client->unstable->subscriptionTypes->attachSubscriptionTypeToContact($request) -> SubscriptionType +
$client->unstable->subscriptionTypes->attachSubscriptionTypeToContact($request) -> ?SubscriptionType
@@ -15126,7 +15187,7 @@ $client->contacts->attachSubscription(
-
$client->unstable->subscriptionTypes->detachSubscriptionTypeToContact($request) -> SubscriptionType +
$client->unstable->subscriptionTypes->detachSubscriptionTypeToContact($request) -> ?SubscriptionType
@@ -15193,7 +15254,7 @@ $client->unstable->subscriptionTypes->detachSubscriptionTypeToContact(
-
$client->unstable->subscriptionTypes->listSubscriptionTypes() -> SubscriptionTypeList +
$client->unstable->subscriptionTypes->listSubscriptionTypes() -> ?SubscriptionTypeList
@@ -15233,7 +15294,7 @@ $client->subscriptionTypes->list();
## Tags -
$client->unstable->tags->attachTagToContact($request) -> Tag +
$client->unstable->tags->attachTagToContact($request) -> ?Tag
@@ -15300,7 +15361,7 @@ $client->tags->tagContact(
-
$client->unstable->tags->detachTagFromContact($request) -> Tag +
$client->unstable->tags->detachTagFromContact($request) -> ?Tag
@@ -15367,7 +15428,7 @@ $client->unstable->tags->detachTagFromContact(
-
$client->unstable->tags->attachTagToConversation($request) -> Tag +
$client->unstable->tags->attachTagToConversation($request) -> ?Tag
@@ -15443,7 +15504,7 @@ $client->tags->tagConversation(
-
$client->unstable->tags->detachTagFromConversation($request) -> Tag +
$client->unstable->tags->detachTagFromConversation($request) -> ?Tag
@@ -15519,7 +15580,7 @@ $client->unstable->tags->detachTagFromConversation(
-
$client->unstable->tags->listTags() -> TagList +
$client->unstable->tags->listTags() -> ?TagList
@@ -15559,7 +15620,7 @@ $client->tags->list();
-
$client->unstable->tags->createTag($request) -> Tag +
$client->unstable->tags->createTag($request) -> ?Tag
@@ -15629,7 +15690,7 @@ $client->tags->create(
-
$client->unstable->tags->findTag($request) -> Tag +
$client->unstable->tags->findTag($request) -> ?Tag
@@ -15746,7 +15807,7 @@ $client->unstable->tags->deleteTag(
-
$client->unstable->tags->attachTagToTicket($request) -> Tag +
$client->unstable->tags->attachTagToTicket($request) -> ?Tag
@@ -15822,7 +15883,7 @@ $client->tags->tagTicket(
-
$client->unstable->tags->detachTagFromTicket($request) -> Tag +
$client->unstable->tags->detachTagFromTicket($request) -> ?Tag
@@ -15899,7 +15960,7 @@ $client->unstable->tags->detachTagFromTicket(
## Conversations -
$client->unstable->conversations->listConversations($request) -> ConversationList +
$client->unstable->conversations->listConversations($request) -> ?ConversationList
@@ -15972,7 +16033,7 @@ $client->conversations->list(
-
$client->unstable->conversations->createConversation($request) -> Message +
$client->unstable->conversations->createConversation($request) -> ?Message
@@ -16059,7 +16120,7 @@ $client->conversations->create(
-
$client->unstable->conversations->retrieveConversation($request) -> Conversation +
$client->unstable->conversations->retrieveConversation($request) -> ?Conversation
@@ -16144,7 +16205,7 @@ $client->unstable->conversations->retrieveConversation(
-
$client->unstable->conversations->updateConversation($request) -> Conversation +
$client->unstable->conversations->updateConversation($request) -> ?Conversation
@@ -16261,7 +16322,7 @@ $client->unstable->conversations->updateConversation(
-
$client->unstable->conversations->deleteConversation($request) -> ConversationDeleted +
$client->unstable->conversations->deleteConversation($request) -> ?ConversationDeleted
@@ -16319,7 +16380,7 @@ $client->unstable->conversations->deleteConversation(
-
$client->unstable->conversations->searchConversations($request) -> ConversationList +
$client->unstable->conversations->searchConversations($request) -> ?ConversationList
@@ -16446,7 +16507,9 @@ The table below shows the operators you can use to define how you want to search ```php $client->unstable->conversations->searchConversations( new SearchRequest([ - 'query' => new SingleFilterSearchRequest([]), + 'query' => new SingleFilterSearchRequest([ + 'value' => [], + ]), 'pagination' => new StartingAfterPaging([ 'perPage' => 5, ]), @@ -16478,7 +16541,7 @@ $client->unstable->conversations->searchConversations(
-
$client->unstable->conversations->replyConversation($request) -> Conversation +
$client->unstable->conversations->replyConversation($request) -> ?Conversation
@@ -16506,7 +16569,7 @@ You can reply to a conversation with a message from an admin or on behalf of a c ```php $client->unstable->conversations->replyConversation( - new ReplyConversationRequest([ + new ReplyConversationBody([ 'id' => '123 or "last"', 'body' => new ContactReplyIntercomUserIdRequest([ 'messageType' => 'comment', @@ -16550,7 +16613,7 @@ $client->unstable->conversations->replyConversation(
-
$client->unstable->conversations->manageConversation($request) -> Conversation +
$client->unstable->conversations->manageConversation($request) -> ?Conversation
@@ -16624,7 +16687,7 @@ $client->unstable->conversations->manageConversation(
-
$client->unstable->conversations->attachContactToConversation($request) -> Conversation +
$client->unstable->conversations->attachContactToConversation($request) -> ?Conversation
@@ -16707,7 +16770,7 @@ $client->unstable->conversations->attachContactToConversation(
-
$client->unstable->conversations->detachContactFromConversation($request) -> Conversation +
$client->unstable->conversations->detachContactFromConversation($request) -> ?Conversation
@@ -16788,7 +16851,7 @@ $client->conversations->detachContactAsAdmin(
-
$client->unstable->conversations->listHandlingEvents($request) -> HandlingEventList +
$client->unstable->conversations->listHandlingEvents($request) -> ?HandlingEventList
@@ -16848,7 +16911,7 @@ $client->unstable->conversations->listHandlingEvents(
-
$client->unstable->conversations->redactConversation($request) -> Conversation +
$client->unstable->conversations->redactConversation($request) -> ?Conversation
@@ -16988,7 +17051,7 @@ $client->unstable->conversations->convertConversationToTicket(
## Unstable CustomChannelEvents -
$client->unstable->customChannelEvents->notifyNewConversation($request) -> CustomChannelNotificationResponse +
$client->unstable->customChannelEvents->notifyNewConversation($request) -> ?CustomChannelNotificationResponse
@@ -17054,7 +17117,7 @@ $client->customChannelEvents->notifyNewConversation(
-
$client->unstable->customChannelEvents->notifyNewMessage($request) -> CustomChannelNotificationResponse +
$client->unstable->customChannelEvents->notifyNewMessage($request) -> ?CustomChannelNotificationResponse
@@ -17121,7 +17184,7 @@ $client->customChannelEvents->notifyNewMessage(
-
$client->unstable->customChannelEvents->notifyQuickReplySelected($request) -> CustomChannelNotificationResponse +
$client->unstable->customChannelEvents->notifyQuickReplySelected($request) -> ?CustomChannelNotificationResponse
@@ -17188,7 +17251,7 @@ $client->customChannelEvents->notifyQuickReplySelected(
-
$client->unstable->customChannelEvents->notifyAttributeCollected($request) -> CustomChannelNotificationResponse +
$client->unstable->customChannelEvents->notifyAttributeCollected($request) -> ?CustomChannelNotificationResponse
@@ -17314,7 +17377,7 @@ $client->customObjectInstances->getCustomObjectInstancesByExternalId(
-**$externalId:** `string` +**$externalId:** `string` — The unique identifier for the instance in the external system it originated from.
@@ -17423,7 +17486,7 @@ $client->customObjectInstances->createCustomObjectInstances(
-
$client->unstable->customObjectInstances->deleteCustomObjectInstancesById($request) -> CustomObjectInstanceDeleted +
$client->unstable->customObjectInstances->deleteCustomObjectInstancesById($request) -> ?CustomObjectInstanceDeleted
@@ -17478,7 +17541,7 @@ $client->customObjectInstances->deleteCustomObjectInstancesById(
-**$externalId:** `string` +**$externalId:** `string` — The unique identifier for the instance in the external system it originated from.
@@ -17557,7 +17620,7 @@ $client->unstable->customObjectInstances->getCustomObjectInstancesById(
-
$client->unstable->customObjectInstances->deleteCustomObjectInstancesByExternalId($request) -> CustomObjectInstanceDeleted +
$client->unstable->customObjectInstances->deleteCustomObjectInstancesByExternalId($request) -> ?CustomObjectInstanceDeleted
@@ -17625,7 +17688,7 @@ $client->unstable->customObjectInstances->deleteCustomObjectInstancesByExternalI
## Data Attributes -
$client->unstable->dataAttributes->lisDataAttributes($request) -> DataAttributeList +
$client->unstable->dataAttributes->lisDataAttributes($request) -> ?DataAttributeList
@@ -17692,7 +17755,7 @@ $client->dataAttributes->list(
-
$client->unstable->dataAttributes->createDataAttribute($request) -> DataAttribute +
$client->unstable->dataAttributes->createDataAttribute($request) -> ?DataAttribute
@@ -17750,7 +17813,7 @@ $client->unstable->dataAttributes->createDataAttribute(
-
$client->unstable->dataAttributes->updateDataAttribute($request) -> DataAttribute +
$client->unstable->dataAttributes->updateDataAttribute($request) -> ?DataAttribute
@@ -17783,7 +17846,7 @@ You can update a data attribute. ```php $client->unstable->dataAttributes->updateDataAttribute( - new UpdateDataAttributeRequest([ + new UpdateDataAttributeBody([ 'id' => 1, 'body' => [ 'key' => "value", @@ -17825,7 +17888,7 @@ $client->unstable->dataAttributes->updateDataAttribute(
## Data Events -
$client->unstable->dataEvents->lisDataEvents($request) -> DataEventSummary +
$client->unstable->dataEvents->lisDataEvents($request) -> ?DataEventSummary
@@ -17865,12 +17928,13 @@ You can optionally define the result page size as well with the `per_page` param
```php -$client->unstable->dataEvents->lisDataEvents( - new LisDataEventsRequest([ - 'filter' => new LisDataEventsRequestFilterUserId([ +$client->events->list( + new ListEventsRequest([ + 'filter' => new EventsListRequestFilterUserId([ 'userId' => 'user_id', ]), 'type' => 'type', + 'summary' => true, ]), ); ``` @@ -18080,7 +18144,7 @@ $client->events->summaries(
## Data Export -
$client->unstable->dataExport->createDataExport($request) -> DataExport +
$client->unstable->dataExport->createDataExport($request) -> ?DataExport
@@ -18161,7 +18225,7 @@ $client->dataExport->create(
-
$client->unstable->dataExport->getDataExport($request) -> DataExport +
$client->unstable->dataExport->getDataExport($request) -> ?DataExport
@@ -18223,7 +18287,7 @@ $client->dataExport->find(
-
$client->unstable->dataExport->cancelDataExport($request) -> DataExport +
$client->unstable->dataExport->cancelDataExport($request) -> ?DataExport
@@ -18346,7 +18410,7 @@ $client->dataExport->download(
## Workflows -
$client->unstable->workflows->exportWorkflow($request) -> WorkflowExport +
$client->unstable->workflows->exportWorkflow($request) -> ?WorkflowExport
@@ -18411,7 +18475,7 @@ $client->unstable->workflows->exportWorkflow(
## Jobs -
$client->unstable->jobs->status($request) -> Jobs +
$client->unstable->jobs->status($request) -> ?Jobs
@@ -18470,7 +18534,7 @@ $client->unstable->jobs->status(
## Macros -
$client->unstable->macros->listMacros($request) -> MacroList +
$client->unstable->macros->listMacros($request) -> ?MacroList
@@ -18633,7 +18697,7 @@ $client->unstable->macros->getMacro(
## Messages -
$client->unstable->messages->createMessage($request) -> Message +
$client->unstable->messages->createMessage($request) -> ?Message
@@ -18706,7 +18770,7 @@ $client->unstable->messages->createMessage(
-
$client->unstable->messages->getWhatsAppMessageStatus($request) -> WhatsappMessageStatusList +
$client->unstable->messages->getWhatsAppMessageStatus($request) -> ?WhatsappMessageStatusList
@@ -18787,7 +18851,7 @@ $client->unstable->messages->getWhatsAppMessageStatus(
## News -
$client->unstable->news->listNewsItems() -> PaginatedResponse +
$client->unstable->news->listNewsItems() -> ?PaginatedResponse
@@ -18826,7 +18890,7 @@ $client->news->items->list();
-
$client->unstable->news->createNewsItem($request) -> NewsItem +
$client->unstable->news->createNewsItem($request) -> ?NewsItem
@@ -18903,7 +18967,7 @@ $client->news->items->create(
-
$client->unstable->news->retrieveNewsItem($request) -> NewsItem +
$client->unstable->news->retrieveNewsItem($request) -> ?NewsItem
@@ -18961,7 +19025,7 @@ $client->unstable->news->retrieveNewsItem(
-
$client->unstable->news->updateNewsItem($request) -> NewsItem +
$client->unstable->news->updateNewsItem($request) -> ?NewsItem
@@ -19022,7 +19086,7 @@ $client->unstable->news->updateNewsItem(
-
$client->unstable->news->deleteNewsItem($request) -> DeletedObject +
$client->unstable->news->deleteNewsItem($request) -> ?DeletedObject
@@ -19080,7 +19144,7 @@ $client->unstable->news->deleteNewsItem(
-
$client->unstable->news->listLiveNewsfeedItems($request) -> PaginatedResponse +
$client->unstable->news->listLiveNewsfeedItems($request) -> ?PaginatedResponse
@@ -19138,7 +19202,7 @@ $client->unstable->news->listLiveNewsfeedItems(
-
$client->unstable->news->listNewsfeeds() -> PaginatedResponse +
$client->unstable->news->listNewsfeeds() -> ?PaginatedResponse
@@ -19177,7 +19241,7 @@ $client->news->feeds->list();
-
$client->unstable->news->retrieveNewsfeed($request) -> Newsfeed +
$client->unstable->news->retrieveNewsfeed($request) -> ?Newsfeed
@@ -19236,7 +19300,7 @@ $client->unstable->news->retrieveNewsfeed(
## Segments -
$client->unstable->segments->listSegments($request) -> SegmentList +
$client->unstable->segments->listSegments($request) -> ?SegmentList
@@ -19294,7 +19358,7 @@ $client->segments->list(
-
$client->unstable->segments->retrieveSegment($request) -> Segment +
$client->unstable->segments->retrieveSegment($request) -> ?Segment
@@ -19415,7 +19479,7 @@ $client->unstable->switch->createPhoneSwitch(
## Calls -
$client->unstable->calls->listCalls($request) -> CallList +
$client->unstable->calls->listCalls($request) -> ?CallList
@@ -19482,7 +19546,7 @@ $client->calls->listCalls(
-
$client->unstable->calls->showCall($request) -> Call +
$client->unstable->calls->showCall($request) -> ?Call
@@ -19656,7 +19720,7 @@ $client->unstable->calls->showCallTranscript(
-
$client->unstable->calls->listCallsWithTranscripts($request) -> ListCallsWithTranscriptsResponse +
$client->unstable->calls->listCallsWithTranscripts($request) -> ?ListCallsWithTranscriptsResponse
@@ -19718,7 +19782,7 @@ $client->calls->listCallsWithTranscripts(
-
$client->unstable->calls->registerFinVoiceCall($request) -> AiCallResponse +
$client->unstable->calls->registerFinVoiceCall($request) -> ?AiCallResponse
@@ -19783,7 +19847,7 @@ $client->unstable->calls->registerFinVoiceCall(
-
$client->unstable->calls->collectFinVoiceCallById($request) -> AiCallResponse +
$client->unstable->calls->collectFinVoiceCallById($request) -> ?AiCallResponse
@@ -19841,7 +19905,7 @@ $client->unstable->calls->collectFinVoiceCallById(
-
$client->unstable->calls->collectFinVoiceCallByExternalId($request) -> AiCallResponse +
$client->unstable->calls->collectFinVoiceCallByExternalId($request) -> ?AiCallResponse
@@ -19899,7 +19963,7 @@ $client->unstable->calls->collectFinVoiceCallByExternalId(
-
$client->unstable->calls->collectFinVoiceCallByPhoneNumber($request) -> Error +
$client->unstable->calls->collectFinVoiceCallByPhoneNumber($request) -> ?Error
@@ -19960,7 +20024,7 @@ $client->unstable->calls->collectFinVoiceCallByPhoneNumber(
## Teams -
$client->unstable->teams->listTeams() -> TeamList +
$client->unstable->teams->listTeams() -> ?TeamList
@@ -19999,7 +20063,7 @@ $client->teams->list();
-
$client->unstable->teams->retrieveTeam($request) -> Team +
$client->unstable->teams->retrieveTeam($request) -> ?Team
@@ -20058,7 +20122,7 @@ $client->unstable->teams->retrieveTeam(
## Ticket States -
$client->unstable->ticketStates->listTicketStates() -> TicketStateList +
$client->unstable->ticketStates->listTicketStates() -> ?TicketStateList
@@ -20389,7 +20453,7 @@ $client->unstable->ticketTypeAttributes->updateTicketTypeAttribute(
## Ticket Types -
$client->unstable->ticketTypes->listTicketTypes() -> TicketTypeList +
$client->unstable->ticketTypes->listTicketTypes() -> ?TicketTypeList
@@ -20549,7 +20613,7 @@ $client->unstable->ticketTypes->getTicketType(
## Tickets -
$client->unstable->tickets->replyTicket($request) -> TicketReply +
$client->unstable->tickets->replyTicket($request) -> ?TicketReply
@@ -20601,7 +20665,7 @@ $client->unstable->tickets->replyTicket(
-**$id:** `string` +**$id:** `string` — The id of the ticket to target.
@@ -20621,7 +20685,7 @@ $client->unstable->tickets->replyTicket(
-
$client->unstable->tickets->enqueueCreateTicket($request) -> Jobs +
$client->unstable->tickets->enqueueCreateTicket($request) -> ?Jobs
@@ -20652,7 +20716,7 @@ $client->tickets->enqueueCreateTicket( new EnqueueCreateTicketRequest([ 'ticketTypeId' => '1234', 'contacts' => [ - new CreateTicketRequestContactsItemId([ + new CreateTicketRequestBodyContactsItemId([ 'id' => '6762f2d81bb69f9f2193bc54', ]), ], @@ -20873,7 +20937,7 @@ $client->unstable->tickets->updateTicket(
-
$client->unstable->tickets->deleteTicket($request) -> DeleteTicketResponse +
$client->unstable->tickets->deleteTicket($request) -> ?DeleteTicketResponse
@@ -20931,7 +20995,7 @@ $client->unstable->tickets->deleteTicket(
-
$client->unstable->tickets->searchTickets($request) -> TicketList +
$client->unstable->tickets->searchTickets($request) -> ?TicketList
@@ -21028,7 +21092,9 @@ The table below shows the operators you can use to define how you want to search ```php $client->unstable->tickets->searchTickets( new SearchRequest([ - 'query' => new SingleFilterSearchRequest([]), + 'query' => new SingleFilterSearchRequest([ + 'value' => [], + ]), 'pagination' => new StartingAfterPaging([ 'perPage' => 5, ]), @@ -21182,7 +21248,7 @@ $client->visitors->update(
-
$client->unstable->visitors->convertVisitor($request) -> Contact +
$client->unstable->visitors->convertVisitor($request) -> ?Contact
@@ -21246,7 +21312,7 @@ $client->unstable->visitors->convertVisitor(
-**$user:** `mixed` +**$user:** `mixed` — The unique identifiers retained after converting or merging.
@@ -21254,7 +21320,7 @@ $client->unstable->visitors->convertVisitor(
-**$visitor:** `mixed` +**$visitor:** `mixed` — The unique identifiers to convert a single Visitor.
@@ -21267,7 +21333,7 @@ $client->unstable->visitors->convertVisitor(
## Brands -
$client->unstable->brands->listBrands() -> BrandList +
$client->unstable->brands->listBrands() -> ?BrandList
@@ -21307,7 +21373,7 @@ $client->unstable->brands->listBrands();
-
$client->unstable->brands->retrieveBrand($request) -> Brand +
$client->unstable->brands->retrieveBrand($request) -> ?Brand
@@ -21366,7 +21432,7 @@ $client->unstable->brands->retrieveBrand(
## Emails -
$client->unstable->emails->listEmails() -> EmailList +
$client->unstable->emails->listEmails() -> ?EmailList
@@ -21405,7 +21471,7 @@ $client->unstable->emails->listEmails();
-
$client->unstable->emails->retrieveEmail($request) -> EmailSetting +
$client->unstable->emails->retrieveEmail($request) -> ?EmailSetting
@@ -21462,3 +21528,4 @@ $client->unstable->emails->retrieveEmail(
+ diff --git a/src/Admins/AdminsClient.php b/src/Admins/AdminsClient.php index c5633256..919f0fb8 100644 --- a/src/Admins/AdminsClient.php +++ b/src/Admins/AdminsClient.php @@ -2,7 +2,7 @@ namespace Intercom\Admins; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Types\AdminWithApp; use Intercom\Exceptions\IntercomException; @@ -11,7 +11,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Admins\Requests\ConfigureAwayAdminRequest; use Intercom\Admins\Types\Admin; @@ -64,6 +63,11 @@ public function __construct( * > * > If you are building a custom "Log in with Intercom" flow for your site, and you call the `/me` endpoint to identify the logged-in user, you should not accept any sign-ins from users with unverified email addresses as it poses a potential impersonation security risk. * + * Example: + * ```php + * $client->admins->identify(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -98,16 +102,6 @@ public function identify(?array $options = null): ?AdminWithApp } } 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); } @@ -121,6 +115,18 @@ public function identify(?array $options = null): ?AdminWithApp /** * You can set an Admin as away for the Inbox. * + * Example: + * ```php + * $client->admins->away( + * new ConfigureAwayAdminRequest([ + * 'adminId' => 1, + * 'awayModeEnabled' => true, + * 'awayModeReassign' => true, + * 'awayStatusReasonId' => 12345, + * ]), + * ); + * ``` + * * @param ConfigureAwayAdminRequest $request * @param ?array{ * baseUrl?: string, @@ -141,7 +147,7 @@ public function away(ConfigureAwayAdminRequest $request, ?array $options = null) $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "admins/{$request->getAdminId()}/away", + path: "admins/" . RawClient::encodePathParam($request->getAdminId()) . "/away", method: HttpMethod::PUT, body: $request, ), @@ -157,16 +163,6 @@ public function away(ConfigureAwayAdminRequest $request, ?array $options = null) } } 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); } @@ -180,6 +176,16 @@ public function away(ConfigureAwayAdminRequest $request, ?array $options = null) /** * You can get a log of activities by all admins in an app. * + * Example: + * ```php + * $client->admins->listAllActivityLogs( + * new ListAllActivityLogsRequest([ + * 'createdAtAfter' => '1677253093', + * 'createdAtBefore' => '1677861493', + * ]), + * ); + * ``` + * * @param ListAllActivityLogsRequest $request * @param ?array{ * baseUrl?: string, @@ -189,11 +195,11 @@ public function away(ConfigureAwayAdminRequest $request, ?array $options = null) * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ActivityLogList + * @return ?ActivityLogList * @throws IntercomException * @throws IntercomApiException */ - public function listAllActivityLogs(ListAllActivityLogsRequest $request, ?array $options = null): ActivityLogList + public function listAllActivityLogs(ListAllActivityLogsRequest $request, ?array $options = null): ?ActivityLogList { $options = array_merge($this->options, $options ?? []); $query = []; @@ -214,20 +220,13 @@ public function listAllActivityLogs(ListAllActivityLogsRequest $request, ?array $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ActivityLogList::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); } @@ -241,6 +240,11 @@ public function listAllActivityLogs(ListAllActivityLogsRequest $request, ?array /** * You can fetch a list of admins for a given workspace. * + * Example: + * ```php + * $client->admins->list(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -249,11 +253,11 @@ public function listAllActivityLogs(ListAllActivityLogsRequest $request, ?array * queryParameters?: array, * bodyProperties?: array, * } $options - * @return AdminList + * @return ?AdminList * @throws IntercomException * @throws IntercomApiException */ - public function list(?array $options = null): AdminList + public function list(?array $options = null): ?AdminList { $options = array_merge($this->options, $options ?? []); try { @@ -268,20 +272,13 @@ public function list(?array $options = null): AdminList $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return AdminList::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); } @@ -295,6 +292,15 @@ public function list(?array $options = null): AdminList /** * You can retrieve the details of a single admin. * + * Example: + * ```php + * $client->admins->find( + * new FindAdminRequest([ + * 'adminId' => 1, + * ]), + * ); + * ``` + * * @param FindAdminRequest $request * @param ?array{ * baseUrl?: string, @@ -315,7 +321,7 @@ public function find(FindAdminRequest $request, ?array $options = null): ?Admin $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "admins/{$request->getAdminId()}", + path: "admins/" . RawClient::encodePathParam($request->getAdminId()), method: HttpMethod::GET, ), $options, @@ -330,16 +336,6 @@ public function find(FindAdminRequest $request, ?array $options = null): ?Admin } } 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); } diff --git a/src/Admins/Requests/ConfigureAwayAdminRequest.php b/src/Admins/Requests/ConfigureAwayAdminRequest.php index caf75c28..7631b5e1 100644 --- a/src/Admins/Requests/ConfigureAwayAdminRequest.php +++ b/src/Admins/Requests/ConfigureAwayAdminRequest.php @@ -61,6 +61,7 @@ public function getAdminId(): int public function setAdminId(int $value): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } @@ -78,6 +79,7 @@ public function getAwayModeEnabled(): bool public function setAwayModeEnabled(bool $value): self { $this->awayModeEnabled = $value; + $this->_setField('awayModeEnabled'); return $this; } @@ -95,6 +97,7 @@ public function getAwayModeReassign(): bool public function setAwayModeReassign(bool $value): self { $this->awayModeReassign = $value; + $this->_setField('awayModeReassign'); return $this; } @@ -112,6 +115,7 @@ public function getAwayStatusReasonId(): ?int public function setAwayStatusReasonId(?int $value = null): self { $this->awayStatusReasonId = $value; + $this->_setField('awayStatusReasonId'); return $this; } } diff --git a/src/Admins/Requests/FindAdminRequest.php b/src/Admins/Requests/FindAdminRequest.php index e21f2260..18773819 100644 --- a/src/Admins/Requests/FindAdminRequest.php +++ b/src/Admins/Requests/FindAdminRequest.php @@ -36,6 +36,7 @@ public function getAdminId(): int public function setAdminId(int $value): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } } diff --git a/src/Admins/Requests/ListAllActivityLogsRequest.php b/src/Admins/Requests/ListAllActivityLogsRequest.php index 969c2882..bf6aae0b 100644 --- a/src/Admins/Requests/ListAllActivityLogsRequest.php +++ b/src/Admins/Requests/ListAllActivityLogsRequest.php @@ -43,6 +43,7 @@ public function getCreatedAtAfter(): string public function setCreatedAtAfter(string $value): self { $this->createdAtAfter = $value; + $this->_setField('createdAtAfter'); return $this; } @@ -60,6 +61,7 @@ public function getCreatedAtBefore(): ?string public function setCreatedAtBefore(?string $value = null): self { $this->createdAtBefore = $value; + $this->_setField('createdAtBefore'); return $this; } } diff --git a/src/Admins/Types/Admin.php b/src/Admins/Types/Admin.php index 63f21ab8..78866d0d 100644 --- a/src/Admins/Types/Admin.php +++ b/src/Admins/Types/Admin.php @@ -131,6 +131,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -148,6 +149,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -165,6 +167,7 @@ public function getName(): string public function setName(string $value): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -182,6 +185,7 @@ public function getEmail(): string public function setEmail(string $value): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -199,6 +203,7 @@ public function getJobTitle(): ?string public function setJobTitle(?string $value = null): self { $this->jobTitle = $value; + $this->_setField('jobTitle'); return $this; } @@ -216,6 +221,7 @@ public function getAwayModeEnabled(): bool public function setAwayModeEnabled(bool $value): self { $this->awayModeEnabled = $value; + $this->_setField('awayModeEnabled'); return $this; } @@ -233,6 +239,7 @@ public function getAwayModeReassign(): bool public function setAwayModeReassign(bool $value): self { $this->awayModeReassign = $value; + $this->_setField('awayModeReassign'); return $this; } @@ -250,6 +257,7 @@ public function getAwayStatusReasonId(): ?int public function setAwayStatusReasonId(?int $value = null): self { $this->awayStatusReasonId = $value; + $this->_setField('awayStatusReasonId'); return $this; } @@ -267,6 +275,7 @@ public function getHasInboxSeat(): bool public function setHasInboxSeat(bool $value): self { $this->hasInboxSeat = $value; + $this->_setField('hasInboxSeat'); return $this; } @@ -284,6 +293,7 @@ public function getTeamIds(): array public function setTeamIds(array $value): self { $this->teamIds = $value; + $this->_setField('teamIds'); return $this; } @@ -301,6 +311,7 @@ public function getAvatar(): ?AdminAvatar public function setAvatar(?AdminAvatar $value = null): self { $this->avatar = $value; + $this->_setField('avatar'); return $this; } @@ -318,6 +329,7 @@ public function getTeamPriorityLevel(): ?TeamPriorityLevel public function setTeamPriorityLevel(?TeamPriorityLevel $value = null): self { $this->teamPriorityLevel = $value; + $this->_setField('teamPriorityLevel'); return $this; } diff --git a/src/Admins/Types/AdminAvatar.php b/src/Admins/Types/AdminAvatar.php index b0a255c0..08abebc3 100644 --- a/src/Admins/Types/AdminAvatar.php +++ b/src/Admins/Types/AdminAvatar.php @@ -41,6 +41,7 @@ public function getImageUrl(): string public function setImageUrl(string $value): self { $this->imageUrl = $value; + $this->_setField('imageUrl'); return $this; } diff --git a/src/AiAgent/Types/AiAgent.php b/src/AiAgent/Types/AiAgent.php index f940d426..f415f24b 100644 --- a/src/AiAgent/Types/AiAgent.php +++ b/src/AiAgent/Types/AiAgent.php @@ -106,6 +106,7 @@ public function getSourceType(): ?string public function setSourceType(?string $value = null): self { $this->sourceType = $value; + $this->_setField('sourceType'); return $this; } @@ -123,6 +124,7 @@ public function getSourceTitle(): ?string public function setSourceTitle(?string $value = null): self { $this->sourceTitle = $value; + $this->_setField('sourceTitle'); return $this; } @@ -140,6 +142,7 @@ public function getLastAnswerType(): ?string public function setLastAnswerType(?string $value = null): self { $this->lastAnswerType = $value; + $this->_setField('lastAnswerType'); return $this; } @@ -157,6 +160,7 @@ public function getResolutionState(): ?string public function setResolutionState(?string $value = null): self { $this->resolutionState = $value; + $this->_setField('resolutionState'); return $this; } @@ -174,6 +178,7 @@ public function getRating(): ?int public function setRating(?int $value = null): self { $this->rating = $value; + $this->_setField('rating'); return $this; } @@ -191,6 +196,7 @@ public function getRatingRemark(): ?string public function setRatingRemark(?string $value = null): self { $this->ratingRemark = $value; + $this->_setField('ratingRemark'); return $this; } @@ -208,6 +214,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -225,6 +232,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -242,6 +250,7 @@ public function getContentSources(): ?ContentSourcesList public function setContentSources(?ContentSourcesList $value = null): self { $this->contentSources = $value; + $this->_setField('contentSources'); return $this; } diff --git a/src/AiContent/AiContentClient.php b/src/AiContent/AiContentClient.php index 6f2f523d..33dfc773 100644 --- a/src/AiContent/AiContentClient.php +++ b/src/AiContent/AiContentClient.php @@ -2,7 +2,7 @@ namespace Intercom\AiContent; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\AiContent\Types\ContentImportSourcesList; use Intercom\Exceptions\IntercomException; @@ -11,7 +11,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\AiContent\Requests\CreateContentImportSourceRequest; use Intercom\AiContent\Types\ContentImportSource; @@ -64,6 +63,11 @@ public function __construct( /** * You can retrieve a list of all content import sources for a workspace. * + * Example: + * ```php + * $client->aiContent->listContentImportSources(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -72,11 +76,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContentImportSourcesList + * @return ?ContentImportSourcesList * @throws IntercomException * @throws IntercomApiException */ - public function listContentImportSources(?array $options = null): ContentImportSourcesList + public function listContentImportSources(?array $options = null): ?ContentImportSourcesList { $options = array_merge($this->options, $options ?? []); try { @@ -91,20 +95,13 @@ public function listContentImportSources(?array $options = null): ContentImportS $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -118,6 +115,16 @@ public function listContentImportSources(?array $options = null): ContentImportS /** * You can create a new content import source by sending a POST request to this endpoint. * + * Example: + * ```php + * $client->aiContent->createContentImportSource( + * new CreateContentImportSourceRequest([ + * 'syncBehavior' => 'api', + * 'url' => 'https://www.example.com', + * ]), + * ); + * ``` + * * @param CreateContentImportSourceRequest $request * @param ?array{ * baseUrl?: string, @@ -127,11 +134,11 @@ public function listContentImportSources(?array $options = null): ContentImportS * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContentImportSource + * @return ?ContentImportSource * @throws IntercomException * @throws IntercomApiException */ - public function createContentImportSource(CreateContentImportSourceRequest $request, ?array $options = null): ContentImportSource + public function createContentImportSource(CreateContentImportSourceRequest $request, ?array $options = null): ?ContentImportSource { $options = array_merge($this->options, $options ?? []); try { @@ -147,20 +154,13 @@ public function createContentImportSource(CreateContentImportSourceRequest $requ $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -172,6 +172,15 @@ public function createContentImportSource(CreateContentImportSourceRequest $requ } /** + * Example: + * ```php + * $client->aiContent->getContentImportSource( + * new GetContentImportSourceRequest([ + * 'sourceId' => 'source_id', + * ]), + * ); + * ``` + * * @param GetContentImportSourceRequest $request * @param ?array{ * baseUrl?: string, @@ -181,18 +190,18 @@ public function createContentImportSource(CreateContentImportSourceRequest $requ * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContentImportSource + * @return ?ContentImportSource * @throws IntercomException * @throws IntercomApiException */ - public function getContentImportSource(GetContentImportSourceRequest $request, ?array $options = null): ContentImportSource + 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()}", + path: "ai/content_import_sources/" . RawClient::encodePathParam($request->getSourceId()), method: HttpMethod::GET, ), $options, @@ -200,20 +209,13 @@ public function getContentImportSource(GetContentImportSourceRequest $request, ? $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -227,6 +229,17 @@ public function getContentImportSource(GetContentImportSourceRequest $request, ? /** * You can update an existing content import source. * + * Example: + * ```php + * $client->aiContent->updateContentImportSource( + * new UpdateContentImportSourceRequest([ + * 'sourceId' => 'source_id', + * 'syncBehavior' => UpdateContentImportSourceRequestSyncBehavior::Api->value, + * 'url' => 'https://www.example.com', + * ]), + * ); + * ``` + * * @param UpdateContentImportSourceRequest $request * @param ?array{ * baseUrl?: string, @@ -236,18 +249,18 @@ public function getContentImportSource(GetContentImportSourceRequest $request, ? * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContentImportSource + * @return ?ContentImportSource * @throws IntercomException * @throws IntercomApiException */ - public function updateContentImportSource(UpdateContentImportSourceRequest $request, ?array $options = null): ContentImportSource + 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()}", + path: "ai/content_import_sources/" . RawClient::encodePathParam($request->getSourceId()), method: HttpMethod::PUT, body: $request, ), @@ -256,20 +269,13 @@ public function updateContentImportSource(UpdateContentImportSourceRequest $requ $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -283,6 +289,15 @@ public function updateContentImportSource(UpdateContentImportSourceRequest $requ /** * 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. * + * Example: + * ```php + * $client->aiContent->deleteContentImportSource( + * new DeleteContentImportSourceRequest([ + * 'sourceId' => 'source_id', + * ]), + * ); + * ``` + * * @param DeleteContentImportSourceRequest $request * @param ?array{ * baseUrl?: string, @@ -302,7 +317,7 @@ public function deleteContentImportSource(DeleteContentImportSourceRequest $requ $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "ai/content_import_sources/{$request->getSourceId()}", + path: "ai/content_import_sources/" . RawClient::encodePathParam($request->getSourceId()), method: HttpMethod::DELETE, ), $options, @@ -311,16 +326,6 @@ public function deleteContentImportSource(DeleteContentImportSourceRequest $requ 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); } @@ -334,6 +339,11 @@ public function deleteContentImportSource(DeleteContentImportSourceRequest $requ /** * You can retrieve a list of all external pages for a workspace. * + * Example: + * ```php + * $client->aiContent->listExternalPages(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -342,11 +352,11 @@ public function deleteContentImportSource(DeleteContentImportSourceRequest $requ * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ExternalPagesList + * @return ?ExternalPagesList * @throws IntercomException * @throws IntercomApiException */ - public function listExternalPages(?array $options = null): ExternalPagesList + public function listExternalPages(?array $options = null): ?ExternalPagesList { $options = array_merge($this->options, $options ?? []); try { @@ -361,20 +371,13 @@ public function listExternalPages(?array $options = null): ExternalPagesList $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -388,6 +391,20 @@ public function listExternalPages(?array $options = null): ExternalPagesList /** * 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. * + * Example: + * ```php + * $client->aiContent->createExternalPage( + * new CreateExternalPageRequest([ + * 'title' => 'Test', + * 'html' => '

Test

', + * 'url' => 'https://www.example.com', + * 'locale' => 'en', + * 'sourceId' => 44, + * 'externalId' => 'abc1234', + * ]), + * ); + * ``` + * * @param CreateExternalPageRequest $request * @param ?array{ * baseUrl?: string, @@ -397,11 +414,11 @@ public function listExternalPages(?array $options = null): ExternalPagesList * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ExternalPage + * @return ?ExternalPage * @throws IntercomException * @throws IntercomApiException */ - public function createExternalPage(CreateExternalPageRequest $request, ?array $options = null): ExternalPage + public function createExternalPage(CreateExternalPageRequest $request, ?array $options = null): ?ExternalPage { $options = array_merge($this->options, $options ?? []); try { @@ -417,20 +434,13 @@ public function createExternalPage(CreateExternalPageRequest $request, ?array $o $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -444,6 +454,15 @@ public function createExternalPage(CreateExternalPageRequest $request, ?array $o /** * You can retrieve an external page. * + * Example: + * ```php + * $client->aiContent->getExternalPage( + * new GetExternalPageRequest([ + * 'pageId' => 'page_id', + * ]), + * ); + * ``` + * * @param GetExternalPageRequest $request * @param ?array{ * baseUrl?: string, @@ -453,18 +472,18 @@ public function createExternalPage(CreateExternalPageRequest $request, ?array $o * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ExternalPage + * @return ?ExternalPage * @throws IntercomException * @throws IntercomApiException */ - public function getExternalPage(GetExternalPageRequest $request, ?array $options = null): ExternalPage + 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()}", + path: "ai/external_pages/" . RawClient::encodePathParam($request->getPageId()), method: HttpMethod::GET, ), $options, @@ -472,20 +491,13 @@ public function getExternalPage(GetExternalPageRequest $request, ?array $options $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -499,6 +511,21 @@ public function getExternalPage(GetExternalPageRequest $request, ?array $options /** * You can update an existing external page (if it was created via the API). * + * Example: + * ```php + * $client->aiContent->updateExternalPage( + * new UpdateExternalPageRequest([ + * 'pageId' => 'page_id', + * 'title' => 'Test', + * 'html' => '

Test

', + * 'url' => 'https://www.example.com', + * 'locale' => 'en', + * 'sourceId' => 47, + * 'externalId' => '5678', + * ]), + * ); + * ``` + * * @param UpdateExternalPageRequest $request * @param ?array{ * baseUrl?: string, @@ -508,18 +535,18 @@ public function getExternalPage(GetExternalPageRequest $request, ?array $options * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ExternalPage + * @return ?ExternalPage * @throws IntercomException * @throws IntercomApiException */ - public function updateExternalPage(UpdateExternalPageRequest $request, ?array $options = null): ExternalPage + 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()}", + path: "ai/external_pages/" . RawClient::encodePathParam($request->getPageId()), method: HttpMethod::PUT, body: $request, ), @@ -528,20 +555,13 @@ public function updateExternalPage(UpdateExternalPageRequest $request, ?array $o $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -555,6 +575,15 @@ public function updateExternalPage(UpdateExternalPageRequest $request, ?array $o /** * Sending a DELETE request for an external page will remove it from the content library UI and from being used for AI answers. * + * Example: + * ```php + * $client->aiContent->deleteExternalPage( + * new DeleteExternalPageRequest([ + * 'pageId' => 'page_id', + * ]), + * ); + * ``` + * * @param DeleteExternalPageRequest $request * @param ?array{ * baseUrl?: string, @@ -564,18 +593,18 @@ public function updateExternalPage(UpdateExternalPageRequest $request, ?array $o * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ExternalPage + * @return ?ExternalPage * @throws IntercomException * @throws IntercomApiException */ - public function deleteExternalPage(DeleteExternalPageRequest $request, ?array $options = null): ExternalPage + 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()}", + path: "ai/external_pages/" . RawClient::encodePathParam($request->getPageId()), method: HttpMethod::DELETE, ), $options, @@ -583,20 +612,13 @@ public function deleteExternalPage(DeleteExternalPageRequest $request, ?array $o $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } diff --git a/src/AiContent/Requests/CreateContentImportSourceRequest.php b/src/AiContent/Requests/CreateContentImportSourceRequest.php index 123096cc..02ab2df5 100644 --- a/src/AiContent/Requests/CreateContentImportSourceRequest.php +++ b/src/AiContent/Requests/CreateContentImportSourceRequest.php @@ -55,6 +55,7 @@ public function getSyncBehavior(): string public function setSyncBehavior(string $value): self { $this->syncBehavior = $value; + $this->_setField('syncBehavior'); return $this; } @@ -72,6 +73,7 @@ public function getStatus(): ?string public function setStatus(?string $value = null): self { $this->status = $value; + $this->_setField('status'); return $this; } @@ -89,6 +91,7 @@ public function getUrl(): string public function setUrl(string $value): self { $this->url = $value; + $this->_setField('url'); return $this; } } diff --git a/src/AiContent/Requests/CreateExternalPageRequest.php b/src/AiContent/Requests/CreateExternalPageRequest.php index d4bc3233..527c5669 100644 --- a/src/AiContent/Requests/CreateExternalPageRequest.php +++ b/src/AiContent/Requests/CreateExternalPageRequest.php @@ -94,6 +94,7 @@ public function getTitle(): string public function setTitle(string $value): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -111,6 +112,7 @@ public function getHtml(): string public function setHtml(string $value): self { $this->html = $value; + $this->_setField('html'); return $this; } @@ -128,6 +130,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -145,6 +148,7 @@ public function getAiAgentAvailability(): ?bool public function setAiAgentAvailability(?bool $value = null): self { $this->aiAgentAvailability = $value; + $this->_setField('aiAgentAvailability'); return $this; } @@ -162,6 +166,7 @@ public function getAiCopilotAvailability(): ?bool public function setAiCopilotAvailability(?bool $value = null): self { $this->aiCopilotAvailability = $value; + $this->_setField('aiCopilotAvailability'); return $this; } @@ -179,6 +184,7 @@ public function getLocale(): string public function setLocale(string $value): self { $this->locale = $value; + $this->_setField('locale'); return $this; } @@ -196,6 +202,7 @@ public function getSourceId(): int public function setSourceId(int $value): self { $this->sourceId = $value; + $this->_setField('sourceId'); return $this; } @@ -213,6 +220,7 @@ public function getExternalId(): string public function setExternalId(string $value): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } } diff --git a/src/AiContent/Requests/DeleteContentImportSourceRequest.php b/src/AiContent/Requests/DeleteContentImportSourceRequest.php index ce218ec0..c6a8e7ca 100644 --- a/src/AiContent/Requests/DeleteContentImportSourceRequest.php +++ b/src/AiContent/Requests/DeleteContentImportSourceRequest.php @@ -36,6 +36,7 @@ public function getSourceId(): string public function setSourceId(string $value): self { $this->sourceId = $value; + $this->_setField('sourceId'); return $this; } } diff --git a/src/AiContent/Requests/DeleteExternalPageRequest.php b/src/AiContent/Requests/DeleteExternalPageRequest.php index 03748fc0..c9982ac7 100644 --- a/src/AiContent/Requests/DeleteExternalPageRequest.php +++ b/src/AiContent/Requests/DeleteExternalPageRequest.php @@ -36,6 +36,7 @@ public function getPageId(): string public function setPageId(string $value): self { $this->pageId = $value; + $this->_setField('pageId'); return $this; } } diff --git a/src/AiContent/Requests/GetContentImportSourceRequest.php b/src/AiContent/Requests/GetContentImportSourceRequest.php index 53bde83c..0ff35638 100644 --- a/src/AiContent/Requests/GetContentImportSourceRequest.php +++ b/src/AiContent/Requests/GetContentImportSourceRequest.php @@ -36,6 +36,7 @@ public function getSourceId(): string public function setSourceId(string $value): self { $this->sourceId = $value; + $this->_setField('sourceId'); return $this; } } diff --git a/src/AiContent/Requests/GetExternalPageRequest.php b/src/AiContent/Requests/GetExternalPageRequest.php index c6b10742..5251be13 100644 --- a/src/AiContent/Requests/GetExternalPageRequest.php +++ b/src/AiContent/Requests/GetExternalPageRequest.php @@ -36,6 +36,7 @@ public function getPageId(): string public function setPageId(string $value): self { $this->pageId = $value; + $this->_setField('pageId'); return $this; } } diff --git a/src/AiContent/Requests/UpdateContentImportSourceRequest.php b/src/AiContent/Requests/UpdateContentImportSourceRequest.php index c97d52ca..d3e2fb4f 100644 --- a/src/AiContent/Requests/UpdateContentImportSourceRequest.php +++ b/src/AiContent/Requests/UpdateContentImportSourceRequest.php @@ -63,6 +63,7 @@ public function getSourceId(): string public function setSourceId(string $value): self { $this->sourceId = $value; + $this->_setField('sourceId'); return $this; } @@ -80,6 +81,7 @@ public function getSyncBehavior(): string public function setSyncBehavior(string $value): self { $this->syncBehavior = $value; + $this->_setField('syncBehavior'); return $this; } @@ -97,6 +99,7 @@ public function getStatus(): ?string public function setStatus(?string $value = null): self { $this->status = $value; + $this->_setField('status'); return $this; } @@ -114,6 +117,7 @@ public function getUrl(): string public function setUrl(string $value): self { $this->url = $value; + $this->_setField('url'); return $this; } } diff --git a/src/AiContent/Requests/UpdateExternalPageRequest.php b/src/AiContent/Requests/UpdateExternalPageRequest.php index e77aa991..a7e0085d 100644 --- a/src/AiContent/Requests/UpdateExternalPageRequest.php +++ b/src/AiContent/Requests/UpdateExternalPageRequest.php @@ -93,6 +93,7 @@ public function getPageId(): string public function setPageId(string $value): self { $this->pageId = $value; + $this->_setField('pageId'); return $this; } @@ -110,6 +111,7 @@ public function getTitle(): string public function setTitle(string $value): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -127,6 +129,7 @@ public function getHtml(): string public function setHtml(string $value): self { $this->html = $value; + $this->_setField('html'); return $this; } @@ -144,6 +147,7 @@ public function getUrl(): string public function setUrl(string $value): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -161,6 +165,7 @@ public function getFinAvailability(): ?bool public function setFinAvailability(?bool $value = null): self { $this->finAvailability = $value; + $this->_setField('finAvailability'); return $this; } @@ -178,6 +183,7 @@ public function getLocale(): string public function setLocale(string $value): self { $this->locale = $value; + $this->_setField('locale'); return $this; } @@ -195,6 +201,7 @@ public function getSourceId(): int public function setSourceId(int $value): self { $this->sourceId = $value; + $this->_setField('sourceId'); return $this; } @@ -212,6 +219,7 @@ public function getExternalId(): ?string public function setExternalId(?string $value = null): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } } diff --git a/src/AiContent/Types/ContentImportSource.php b/src/AiContent/Types/ContentImportSource.php index f0ef072e..e29a80d5 100644 --- a/src/AiContent/Types/ContentImportSource.php +++ b/src/AiContent/Types/ContentImportSource.php @@ -97,6 +97,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -114,6 +115,7 @@ public function getId(): int public function setId(int $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -131,6 +133,7 @@ public function getLastSyncedAt(): int public function setLastSyncedAt(int $value): self { $this->lastSyncedAt = $value; + $this->_setField('lastSyncedAt'); return $this; } @@ -148,6 +151,7 @@ public function getSyncBehavior(): string public function setSyncBehavior(string $value): self { $this->syncBehavior = $value; + $this->_setField('syncBehavior'); return $this; } @@ -165,6 +169,7 @@ public function getStatus(): string public function setStatus(string $value): self { $this->status = $value; + $this->_setField('status'); return $this; } @@ -182,6 +187,7 @@ public function getUrl(): string public function setUrl(string $value): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -199,6 +205,7 @@ public function getCreatedAt(): int public function setCreatedAt(int $value): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -216,6 +223,7 @@ public function getUpdatedAt(): int public function setUpdatedAt(int $value): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } diff --git a/src/AiContent/Types/ContentImportSourcesList.php b/src/AiContent/Types/ContentImportSourcesList.php index 6a3b1f6c..6aff34c6 100644 --- a/src/AiContent/Types/ContentImportSourcesList.php +++ b/src/AiContent/Types/ContentImportSourcesList.php @@ -67,6 +67,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -84,6 +85,7 @@ public function getPages(): ?PagesLink public function setPages(?PagesLink $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } @@ -101,6 +103,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -118,6 +121,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/AiContent/Types/ExternalPage.php b/src/AiContent/Types/ExternalPage.php index 9e375617..074bc9f3 100644 --- a/src/AiContent/Types/ExternalPage.php +++ b/src/AiContent/Types/ExternalPage.php @@ -145,6 +145,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -162,6 +163,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -179,6 +181,7 @@ public function getTitle(): string public function setTitle(string $value): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -196,6 +199,7 @@ public function getHtml(): string public function setHtml(string $value): self { $this->html = $value; + $this->_setField('html'); return $this; } @@ -213,6 +217,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -230,6 +235,7 @@ public function getAiAgentAvailability(): bool public function setAiAgentAvailability(bool $value): self { $this->aiAgentAvailability = $value; + $this->_setField('aiAgentAvailability'); return $this; } @@ -247,6 +253,7 @@ public function getAiCopilotAvailability(): bool public function setAiCopilotAvailability(bool $value): self { $this->aiCopilotAvailability = $value; + $this->_setField('aiCopilotAvailability'); return $this; } @@ -264,6 +271,7 @@ public function getFinAvailability(): ?bool public function setFinAvailability(?bool $value = null): self { $this->finAvailability = $value; + $this->_setField('finAvailability'); return $this; } @@ -281,6 +289,7 @@ public function getLocale(): string public function setLocale(string $value): self { $this->locale = $value; + $this->_setField('locale'); return $this; } @@ -298,6 +307,7 @@ public function getSourceId(): int public function setSourceId(int $value): self { $this->sourceId = $value; + $this->_setField('sourceId'); return $this; } @@ -315,6 +325,7 @@ public function getExternalId(): string public function setExternalId(string $value): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } @@ -332,6 +343,7 @@ public function getCreatedAt(): int public function setCreatedAt(int $value): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -349,6 +361,7 @@ public function getUpdatedAt(): int public function setUpdatedAt(int $value): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -366,6 +379,7 @@ public function getLastIngestedAt(): int public function setLastIngestedAt(int $value): self { $this->lastIngestedAt = $value; + $this->_setField('lastIngestedAt'); return $this; } diff --git a/src/AiContent/Types/ExternalPagesList.php b/src/AiContent/Types/ExternalPagesList.php index edb5cbcd..05c518cc 100644 --- a/src/AiContent/Types/ExternalPagesList.php +++ b/src/AiContent/Types/ExternalPagesList.php @@ -67,6 +67,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -84,6 +85,7 @@ public function getPages(): ?PagesLink public function setPages(?PagesLink $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } @@ -101,6 +103,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -118,6 +121,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/AiContentSource/Types/ContentSource.php b/src/AiContentSource/Types/ContentSource.php index b5488877..c7b1c388 100644 --- a/src/AiContentSource/Types/ContentSource.php +++ b/src/AiContentSource/Types/ContentSource.php @@ -65,6 +65,7 @@ public function getContentType(): ?string public function setContentType(?string $value = null): self { $this->contentType = $value; + $this->_setField('contentType'); return $this; } @@ -82,6 +83,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -99,6 +101,7 @@ public function getTitle(): ?string public function setTitle(?string $value = null): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -116,6 +119,7 @@ public function getLocale(): ?string public function setLocale(?string $value = null): self { $this->locale = $value; + $this->_setField('locale'); return $this; } diff --git a/src/Articles/ArticlesClient.php b/src/Articles/ArticlesClient.php index d6c5f8ee..01874218 100644 --- a/src/Articles/ArticlesClient.php +++ b/src/Articles/ArticlesClient.php @@ -2,7 +2,7 @@ namespace Intercom\Articles; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Articles\Requests\ListArticlesRequest; use Intercom\Core\Pagination\Pager; @@ -17,7 +17,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Articles\Requests\FindArticleRequest; use Intercom\Articles\Requests\UpdateArticleRequest; @@ -69,6 +68,16 @@ public function __construct( * > * > Articles will be returned in descending order on the `updated_at` attribute. This means if you need to iterate through results then we'll show the most recently updated articles first. * + * Example: + * ```php + * $client->articles->list( + * new ListArticlesRequest([ + * 'page' => 1, + * 'perPage' => 1, + * ]), + * ); + * ``` + * * @param ListArticlesRequest $request * @param ?array{ * baseUrl?: string, @@ -92,7 +101,7 @@ public function list(ListArticlesRequest $request = new ListArticlesRequest(), ? }, getStep: null, /* @phpstan-ignore-next-line */ - getItems: fn (ArticleList $response) => $response?->getData() ?? [], + getItems: fn (?ArticleList $response) => $response?->getData() ?? [], /* @phpstan-ignore-next-line */ hasNextPage: null, ); @@ -101,6 +110,30 @@ public function list(ListArticlesRequest $request = new ListArticlesRequest(), ? /** * You can create a new article by making a POST request to `https://api.intercom.io/articles`. * + * Example: + * ```php + * $client->articles->create( + * new CreateArticleRequest([ + * 'title' => 'Thanks for everything', + * 'description' => 'Description of the Article', + * 'body' => 'Body of the Article', + * 'authorId' => 991267497, + * 'state' => CreateArticleRequestState::Published->value, + * 'parentId' => 145, + * 'parentType' => CreateArticleRequestParentType::Collection->value, + * 'translatedContent' => new ArticleTranslatedContent([ + * 'fr' => new ArticleContent([ + * 'title' => 'Merci pour tout', + * 'description' => "Description de l'article", + * 'body' => "Corps de l'article", + * 'authorId' => 991267497, + * 'state' => ArticleContentState::Published->value, + * ]), + * ]), + * ]), + * ); + * ``` + * * @param ?CreateArticleRequest $request * @param ?array{ * baseUrl?: string, @@ -110,11 +143,11 @@ public function list(ListArticlesRequest $request = new ListArticlesRequest(), ? * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Article + * @return ?Article * @throws IntercomException * @throws IntercomApiException */ - public function create(?CreateArticleRequest $request = null, ?array $options = null): Article + public function create(?CreateArticleRequest $request = null, ?array $options = null): ?Article { $options = array_merge($this->options, $options ?? []); try { @@ -130,20 +163,13 @@ public function create(?CreateArticleRequest $request = null, ?array $options = $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Article::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); } @@ -157,6 +183,15 @@ public function create(?CreateArticleRequest $request = null, ?array $options = /** * You can fetch the details of a single article by making a GET request to `https://api.intercom.io/articles/`. * + * Example: + * ```php + * $client->articles->find( + * new FindArticleRequest([ + * 'articleId' => 1, + * ]), + * ); + * ``` + * * @param FindArticleRequest $request * @param ?array{ * baseUrl?: string, @@ -166,18 +201,18 @@ public function create(?CreateArticleRequest $request = null, ?array $options = * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Article + * @return ?Article * @throws IntercomException * @throws IntercomApiException */ - public function find(FindArticleRequest $request, ?array $options = null): Article + public function find(FindArticleRequest $request, ?array $options = null): ?Article { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "articles/{$request->getArticleId()}", + path: "articles/" . RawClient::encodePathParam($request->getArticleId()), method: HttpMethod::GET, ), $options, @@ -185,20 +220,13 @@ public function find(FindArticleRequest $request, ?array $options = null): Artic $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Article::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); } @@ -212,6 +240,17 @@ public function find(FindArticleRequest $request, ?array $options = null): Artic /** * You can update the details of a single article by making a PUT request to `https://api.intercom.io/articles/`. * + * Example: + * ```php + * $client->articles->update( + * new UpdateArticleRequest([ + * 'articleId' => 1, + * 'title' => 'Christmas is here!', + * 'body' => '

New gifts in store for the jolly season

', + * ]), + * ); + * ``` + * * @param UpdateArticleRequest $request * @param ?array{ * baseUrl?: string, @@ -221,18 +260,18 @@ public function find(FindArticleRequest $request, ?array $options = null): Artic * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Article + * @return ?Article * @throws IntercomException * @throws IntercomApiException */ - public function update(UpdateArticleRequest $request, ?array $options = null): Article + public function update(UpdateArticleRequest $request, ?array $options = null): ?Article { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "articles/{$request->getArticleId()}", + path: "articles/" . RawClient::encodePathParam($request->getArticleId()), method: HttpMethod::PUT, body: $request, ), @@ -241,20 +280,13 @@ public function update(UpdateArticleRequest $request, ?array $options = null): A $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Article::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); } @@ -268,6 +300,15 @@ public function update(UpdateArticleRequest $request, ?array $options = null): A /** * You can delete a single article by making a DELETE request to `https://api.intercom.io/articles/`. * + * Example: + * ```php + * $client->articles->delete( + * new DeleteArticleRequest([ + * 'articleId' => 1, + * ]), + * ); + * ``` + * * @param DeleteArticleRequest $request * @param ?array{ * baseUrl?: string, @@ -277,18 +318,18 @@ public function update(UpdateArticleRequest $request, ?array $options = null): A * queryParameters?: array, * bodyProperties?: array, * } $options - * @return DeletedArticleObject + * @return ?DeletedArticleObject * @throws IntercomException * @throws IntercomApiException */ - public function delete(DeleteArticleRequest $request, ?array $options = null): DeletedArticleObject + public function delete(DeleteArticleRequest $request, ?array $options = null): ?DeletedArticleObject { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "articles/{$request->getArticleId()}", + path: "articles/" . RawClient::encodePathParam($request->getArticleId()), method: HttpMethod::DELETE, ), $options, @@ -296,20 +337,13 @@ public function delete(DeleteArticleRequest $request, ?array $options = null): D $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return DeletedArticleObject::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); } @@ -323,6 +357,18 @@ public function delete(DeleteArticleRequest $request, ?array $options = null): D /** * You can search for articles by making a GET request to `https://api.intercom.io/articles/search`. * + * Example: + * ```php + * $client->articles->search( + * new SearchArticlesRequest([ + * 'phrase' => 'Getting started', + * 'state' => 'published', + * 'helpCenterId' => 1, + * 'highlight' => true, + * ]), + * ); + * ``` + * * @param SearchArticlesRequest $request * @param ?array{ * baseUrl?: string, @@ -332,11 +378,11 @@ public function delete(DeleteArticleRequest $request, ?array $options = null): D * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ArticleSearchResponse + * @return ?ArticleSearchResponse * @throws IntercomException * @throws IntercomApiException */ - public function search(SearchArticlesRequest $request = new SearchArticlesRequest(), ?array $options = null): ArticleSearchResponse + public function search(SearchArticlesRequest $request = new SearchArticlesRequest(), ?array $options = null): ?ArticleSearchResponse { $options = array_merge($this->options, $options ?? []); $query = []; @@ -365,20 +411,13 @@ public function search(SearchArticlesRequest $request = new SearchArticlesReques $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ArticleSearchResponse::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); } @@ -405,11 +444,11 @@ public function search(SearchArticlesRequest $request = new SearchArticlesReques * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ArticleList + * @return ?ArticleList * @throws IntercomException * @throws IntercomApiException */ - private function _list(ListArticlesRequest $request = new ListArticlesRequest(), ?array $options = null): ArticleList + private function _list(ListArticlesRequest $request = new ListArticlesRequest(), ?array $options = null): ?ArticleList { $options = array_merge($this->options, $options ?? []); $query = []; @@ -432,20 +471,13 @@ private function _list(ListArticlesRequest $request = new ListArticlesRequest(), $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ArticleList::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); } diff --git a/src/Articles/Requests/DeleteArticleRequest.php b/src/Articles/Requests/DeleteArticleRequest.php index de8e346a..42a5e462 100644 --- a/src/Articles/Requests/DeleteArticleRequest.php +++ b/src/Articles/Requests/DeleteArticleRequest.php @@ -36,6 +36,7 @@ public function getArticleId(): int public function setArticleId(int $value): self { $this->articleId = $value; + $this->_setField('articleId'); return $this; } } diff --git a/src/Articles/Requests/FindArticleRequest.php b/src/Articles/Requests/FindArticleRequest.php index 999e9159..0f974247 100644 --- a/src/Articles/Requests/FindArticleRequest.php +++ b/src/Articles/Requests/FindArticleRequest.php @@ -36,6 +36,7 @@ public function getArticleId(): int public function setArticleId(int $value): self { $this->articleId = $value; + $this->_setField('articleId'); return $this; } } diff --git a/src/Articles/Requests/ListArticlesRequest.php b/src/Articles/Requests/ListArticlesRequest.php index 3feab27e..f02e64cb 100644 --- a/src/Articles/Requests/ListArticlesRequest.php +++ b/src/Articles/Requests/ListArticlesRequest.php @@ -43,6 +43,7 @@ public function getPage(): ?int public function setPage(?int $value = null): self { $this->page = $value; + $this->_setField('page'); return $this; } @@ -60,6 +61,7 @@ public function getPerPage(): ?int public function setPerPage(?int $value = null): self { $this->perPage = $value; + $this->_setField('perPage'); return $this; } } diff --git a/src/Articles/Requests/SearchArticlesRequest.php b/src/Articles/Requests/SearchArticlesRequest.php index f563cd11..0a7f8981 100644 --- a/src/Articles/Requests/SearchArticlesRequest.php +++ b/src/Articles/Requests/SearchArticlesRequest.php @@ -57,6 +57,7 @@ public function getPhrase(): ?string public function setPhrase(?string $value = null): self { $this->phrase = $value; + $this->_setField('phrase'); return $this; } @@ -74,6 +75,7 @@ public function getState(): ?string public function setState(?string $value = null): self { $this->state = $value; + $this->_setField('state'); return $this; } @@ -91,6 +93,7 @@ public function getHelpCenterId(): ?int public function setHelpCenterId(?int $value = null): self { $this->helpCenterId = $value; + $this->_setField('helpCenterId'); return $this; } @@ -108,6 +111,7 @@ public function getHighlight(): ?bool public function setHighlight(?bool $value = null): self { $this->highlight = $value; + $this->_setField('highlight'); return $this; } } diff --git a/src/Articles/Requests/UpdateArticleRequest.php b/src/Articles/Requests/UpdateArticleRequest.php index e29534ee..451973ad 100644 --- a/src/Articles/Requests/UpdateArticleRequest.php +++ b/src/Articles/Requests/UpdateArticleRequest.php @@ -4,7 +4,7 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; -use Intercom\Articles\Types\UpdateArticleRequestState; +use Intercom\Articles\Types\UpdateArticleRequestBodyState; use Intercom\Types\ArticleTranslatedContent; class UpdateArticleRequest extends JsonSerializableType @@ -39,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; @@ -69,7 +69,7 @@ class UpdateArticleRequest extends JsonSerializableType * description?: ?string, * body?: ?string, * authorId?: ?int, - * state?: ?value-of, + * state?: ?value-of, * parentId?: ?string, * parentType?: ?string, * translatedContent?: ?ArticleTranslatedContent, @@ -103,6 +103,7 @@ public function getArticleId(): int public function setArticleId(int $value): self { $this->articleId = $value; + $this->_setField('articleId'); return $this; } @@ -120,6 +121,7 @@ public function getTitle(): ?string public function setTitle(?string $value = null): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -137,6 +139,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -154,6 +157,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -171,11 +175,12 @@ public function getAuthorId(): ?int public function setAuthorId(?int $value = null): self { $this->authorId = $value; + $this->_setField('authorId'); return $this; } /** - * @return ?value-of + * @return ?value-of */ public function getState(): ?string { @@ -183,11 +188,12 @@ public function getState(): ?string } /** - * @param ?value-of $value + * @param ?value-of $value */ public function setState(?string $value = null): self { $this->state = $value; + $this->_setField('state'); return $this; } @@ -205,6 +211,7 @@ public function getParentId(): ?string public function setParentId(?string $value = null): self { $this->parentId = $value; + $this->_setField('parentId'); return $this; } @@ -222,6 +229,7 @@ public function getParentType(): ?string public function setParentType(?string $value = null): self { $this->parentType = $value; + $this->_setField('parentType'); return $this; } @@ -239,6 +247,7 @@ public function getTranslatedContent(): ?ArticleTranslatedContent public function setTranslatedContent(?ArticleTranslatedContent $value = null): self { $this->translatedContent = $value; + $this->_setField('translatedContent'); return $this; } } diff --git a/src/Articles/Traits/ArticleListItem.php b/src/Articles/Traits/ArticleListItem.php index d1747509..66ac41f0 100644 --- a/src/Articles/Traits/ArticleListItem.php +++ b/src/Articles/Traits/ArticleListItem.php @@ -139,6 +139,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -156,6 +157,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -173,6 +175,7 @@ public function getWorkspaceId(): string public function setWorkspaceId(string $value): self { $this->workspaceId = $value; + $this->_setField('workspaceId'); return $this; } @@ -190,6 +193,7 @@ public function getTitle(): string public function setTitle(string $value): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -207,6 +211,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -224,6 +229,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -241,6 +247,7 @@ public function getAuthorId(): int public function setAuthorId(int $value): self { $this->authorId = $value; + $this->_setField('authorId'); return $this; } @@ -258,6 +265,7 @@ public function getState(): string public function setState(string $value): self { $this->state = $value; + $this->_setField('state'); return $this; } @@ -275,6 +283,7 @@ public function getCreatedAt(): int public function setCreatedAt(int $value): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -292,6 +301,7 @@ public function getUpdatedAt(): int public function setUpdatedAt(int $value): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -309,6 +319,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -326,6 +337,7 @@ public function getParentId(): ?int public function setParentId(?int $value = null): self { $this->parentId = $value; + $this->_setField('parentId'); return $this; } @@ -343,6 +355,7 @@ public function getParentIds(): ?array public function setParentIds(?array $value = null): self { $this->parentIds = $value; + $this->_setField('parentIds'); return $this; } @@ -360,6 +373,7 @@ public function getParentType(): ?string public function setParentType(?string $value = null): self { $this->parentType = $value; + $this->_setField('parentType'); return $this; } @@ -377,6 +391,7 @@ public function getDefaultLocale(): ?string public function setDefaultLocale(?string $value = null): self { $this->defaultLocale = $value; + $this->_setField('defaultLocale'); return $this; } @@ -394,6 +409,7 @@ public function getTranslatedContent(): ?ArticleTranslatedContent public function setTranslatedContent(?ArticleTranslatedContent $value = null): self { $this->translatedContent = $value; + $this->_setField('translatedContent'); return $this; } } diff --git a/src/Articles/Types/Article.php b/src/Articles/Types/Article.php index 09b9a006..4c9ae3f7 100644 --- a/src/Articles/Types/Article.php +++ b/src/Articles/Types/Article.php @@ -78,6 +78,7 @@ public function getStatistics(): ?ArticleStatistics public function setStatistics(?ArticleStatistics $value = null): self { $this->statistics = $value; + $this->_setField('statistics'); return $this; } diff --git a/src/Articles/Types/ArticleListItem.php b/src/Articles/Types/ArticleListItem.php index 77521c87..8fdea17c 100644 --- a/src/Articles/Types/ArticleListItem.php +++ b/src/Articles/Types/ArticleListItem.php @@ -163,6 +163,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -180,6 +181,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -197,6 +199,7 @@ public function getWorkspaceId(): string public function setWorkspaceId(string $value): self { $this->workspaceId = $value; + $this->_setField('workspaceId'); return $this; } @@ -214,6 +217,7 @@ public function getTitle(): string public function setTitle(string $value): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -231,6 +235,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -248,6 +253,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -265,6 +271,7 @@ public function getAuthorId(): int public function setAuthorId(int $value): self { $this->authorId = $value; + $this->_setField('authorId'); return $this; } @@ -282,6 +289,7 @@ public function getState(): string public function setState(string $value): self { $this->state = $value; + $this->_setField('state'); return $this; } @@ -299,6 +307,7 @@ public function getCreatedAt(): int public function setCreatedAt(int $value): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -316,6 +325,7 @@ public function getUpdatedAt(): int public function setUpdatedAt(int $value): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -333,6 +343,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -350,6 +361,7 @@ public function getParentId(): ?int public function setParentId(?int $value = null): self { $this->parentId = $value; + $this->_setField('parentId'); return $this; } @@ -367,6 +379,7 @@ public function getParentIds(): ?array public function setParentIds(?array $value = null): self { $this->parentIds = $value; + $this->_setField('parentIds'); return $this; } @@ -384,6 +397,7 @@ public function getParentType(): ?string public function setParentType(?string $value = null): self { $this->parentType = $value; + $this->_setField('parentType'); return $this; } @@ -401,6 +415,7 @@ public function getDefaultLocale(): ?string public function setDefaultLocale(?string $value = null): self { $this->defaultLocale = $value; + $this->_setField('defaultLocale'); return $this; } @@ -418,6 +433,7 @@ public function getTranslatedContent(): ?ArticleTranslatedContent public function setTranslatedContent(?ArticleTranslatedContent $value = null): self { $this->translatedContent = $value; + $this->_setField('translatedContent'); return $this; } diff --git a/src/Articles/Types/ArticleSearchHighlights.php b/src/Articles/Types/ArticleSearchHighlights.php index 8cbd810d..dfe029b3 100644 --- a/src/Articles/Types/ArticleSearchHighlights.php +++ b/src/Articles/Types/ArticleSearchHighlights.php @@ -58,6 +58,7 @@ public function getArticleId(): ?string public function setArticleId(?string $value = null): self { $this->articleId = $value; + $this->_setField('articleId'); return $this; } @@ -75,6 +76,7 @@ public function getHighlightedTitle(): ?array public function setHighlightedTitle(?array $value = null): self { $this->highlightedTitle = $value; + $this->_setField('highlightedTitle'); return $this; } @@ -92,6 +94,7 @@ public function getHighlightedSummary(): ?array public function setHighlightedSummary(?array $value = null): self { $this->highlightedSummary = $value; + $this->_setField('highlightedSummary'); return $this; } diff --git a/src/Articles/Types/ArticleSearchHighlightsHighlightedSummaryItemItem.php b/src/Articles/Types/ArticleSearchHighlightsHighlightedSummaryItemItem.php index 5b0aadeb..d29f1c99 100644 --- a/src/Articles/Types/ArticleSearchHighlightsHighlightedSummaryItemItem.php +++ b/src/Articles/Types/ArticleSearchHighlightsHighlightedSummaryItemItem.php @@ -49,6 +49,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -66,6 +67,7 @@ public function getText(): ?string public function setText(?string $value = null): self { $this->text = $value; + $this->_setField('text'); return $this; } diff --git a/src/Articles/Types/ArticleSearchHighlightsHighlightedTitleItem.php b/src/Articles/Types/ArticleSearchHighlightsHighlightedTitleItem.php index 3fae7c03..2772eac9 100644 --- a/src/Articles/Types/ArticleSearchHighlightsHighlightedTitleItem.php +++ b/src/Articles/Types/ArticleSearchHighlightsHighlightedTitleItem.php @@ -49,6 +49,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -66,6 +67,7 @@ public function getText(): ?string public function setText(?string $value = null): self { $this->text = $value; + $this->_setField('text'); return $this; } diff --git a/src/Articles/Types/ArticleSearchResponse.php b/src/Articles/Types/ArticleSearchResponse.php index d4328631..578ccf71 100644 --- a/src/Articles/Types/ArticleSearchResponse.php +++ b/src/Articles/Types/ArticleSearchResponse.php @@ -66,6 +66,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -83,6 +84,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -100,6 +102,7 @@ public function getData(): ?ArticleSearchResponseData public function setData(?ArticleSearchResponseData $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } @@ -117,6 +120,7 @@ public function getPages(): ?CursorPages public function setPages(?CursorPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } diff --git a/src/Articles/Types/ArticleSearchResponseData.php b/src/Articles/Types/ArticleSearchResponseData.php index 56054d1c..70a6fabe 100644 --- a/src/Articles/Types/ArticleSearchResponseData.php +++ b/src/Articles/Types/ArticleSearchResponseData.php @@ -50,6 +50,7 @@ public function getArticles(): ?array public function setArticles(?array $value = null): self { $this->articles = $value; + $this->_setField('articles'); return $this; } @@ -67,6 +68,7 @@ public function getHighlights(): ?array public function setHighlights(?array $value = null): self { $this->highlights = $value; + $this->_setField('highlights'); return $this; } diff --git a/src/Articles/Types/UpdateArticleRequestState.php b/src/Articles/Types/UpdateArticleRequestBodyState.php similarity index 71% rename from src/Articles/Types/UpdateArticleRequestState.php rename to src/Articles/Types/UpdateArticleRequestBodyState.php index 9413b3fc..b803af94 100644 --- a/src/Articles/Types/UpdateArticleRequestState.php +++ b/src/Articles/Types/UpdateArticleRequestBodyState.php @@ -2,7 +2,7 @@ namespace Intercom\Articles\Types; -enum UpdateArticleRequestState: string +enum UpdateArticleRequestBodyState: string { case Published = "published"; case Draft = "draft"; diff --git a/src/AwayStatusReasons/AwayStatusReasonsClient.php b/src/AwayStatusReasons/AwayStatusReasonsClient.php index e27130f6..ad6eb5fc 100644 --- a/src/AwayStatusReasons/AwayStatusReasonsClient.php +++ b/src/AwayStatusReasons/AwayStatusReasonsClient.php @@ -2,7 +2,7 @@ namespace Intercom\AwayStatusReasons; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Types\AwayStatusReason; use Intercom\Exceptions\IntercomException; @@ -12,7 +12,6 @@ use Intercom\Core\Client\HttpMethod; use Intercom\Core\Json\JsonDecoder; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class AwayStatusReasonsClient @@ -54,6 +53,11 @@ public function __construct( /** * Returns a list of all away status reasons configured for the workspace, including deleted ones. * + * Example: + * ```php + * $client->awayStatusReasons->listAwayStatusReasons(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -62,11 +66,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return array + * @return ?array * @throws IntercomException * @throws IntercomApiException */ - public function listAwayStatusReasons(?array $options = null): array + public function listAwayStatusReasons(?array $options = null): ?array { $options = array_merge($this->options, $options ?? []); try { @@ -81,20 +85,13 @@ public function listAwayStatusReasons(?array $options = null): array $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } diff --git a/src/Calls/CallsClient.php b/src/Calls/CallsClient.php index 37ada085..0a648bbe 100644 --- a/src/Calls/CallsClient.php +++ b/src/Calls/CallsClient.php @@ -2,7 +2,7 @@ namespace Intercom\Calls; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Calls\Requests\ListCallsRequest; use Intercom\Types\CallList; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Calls\Requests\ShowCallRequest; use Intercom\Calls\Types\Call; @@ -60,6 +59,16 @@ public function __construct( /** * Retrieve a paginated list of calls. * + * Example: + * ```php + * $client->calls->listCalls( + * new ListCallsRequest([ + * 'page' => 1, + * 'perPage' => 1, + * ]), + * ); + * ``` + * * @param ListCallsRequest $request * @param ?array{ * baseUrl?: string, @@ -69,11 +78,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return CallList + * @return ?CallList * @throws IntercomException * @throws IntercomApiException */ - public function listCalls(ListCallsRequest $request = new ListCallsRequest(), ?array $options = null): CallList + public function listCalls(ListCallsRequest $request = new ListCallsRequest(), ?array $options = null): ?CallList { $options = array_merge($this->options, $options ?? []); $query = []; @@ -96,20 +105,13 @@ public function listCalls(ListCallsRequest $request = new ListCallsRequest(), ?a $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -123,6 +125,15 @@ public function listCalls(ListCallsRequest $request = new ListCallsRequest(), ?a /** * Retrieve a single call by id. * + * Example: + * ```php + * $client->calls->showCall( + * new ShowCallRequest([ + * 'callId' => 'call_id', + * ]), + * ); + * ``` + * * @param ShowCallRequest $request * @param ?array{ * baseUrl?: string, @@ -132,18 +143,18 @@ public function listCalls(ListCallsRequest $request = new ListCallsRequest(), ?a * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Call + * @return ?Call * @throws IntercomException * @throws IntercomApiException */ - public function showCall(ShowCallRequest $request, ?array $options = null): Call + 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()}", + path: "calls/" . RawClient::encodePathParam($request->getCallId()), method: HttpMethod::GET, ), $options, @@ -151,20 +162,13 @@ public function showCall(ShowCallRequest $request, ?array $options = null): Call $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -178,6 +182,15 @@ public function showCall(ShowCallRequest $request, ?array $options = null): Call /** * Redirects to a signed URL for the call's recording if it exists. * + * Example: + * ```php + * $client->calls->showCallRecording( + * new ShowCallRecordingRequest([ + * 'callId' => 'call_id', + * ]), + * ); + * ``` + * * @param ShowCallRecordingRequest $request * @param ?array{ * baseUrl?: string, @@ -197,7 +210,7 @@ public function showCallRecording(ShowCallRecordingRequest $request, ?array $opt $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "calls/{$request->getCallId()}/recording", + path: "calls/" . RawClient::encodePathParam($request->getCallId()) . "/recording", method: HttpMethod::GET, ), $options, @@ -206,16 +219,6 @@ public function showCallRecording(ShowCallRecordingRequest $request, ?array $opt 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); } @@ -229,6 +232,15 @@ public function showCallRecording(ShowCallRecordingRequest $request, ?array $opt /** * Returns the transcript for the specified call as a downloadable text file. * + * Example: + * ```php + * $client->calls->showCallTranscript( + * new ShowCallTranscriptRequest([ + * 'callId' => 'call_id', + * ]), + * ); + * ``` + * * @param ShowCallTranscriptRequest $request * @param ?array{ * baseUrl?: string, @@ -249,7 +261,7 @@ public function showCallTranscript(ShowCallTranscriptRequest $request, ?array $o $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "calls/{$request->getCallId()}/transcript", + path: "calls/" . RawClient::encodePathParam($request->getCallId()) . "/transcript", method: HttpMethod::GET, ), $options, @@ -258,16 +270,6 @@ public function showCallTranscript(ShowCallTranscriptRequest $request, ?array $o 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); } @@ -282,6 +284,18 @@ public function showCallTranscript(ShowCallTranscriptRequest $request, ?array $o * 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. * + * Example: + * ```php + * $client->calls->listCallsWithTranscripts( + * new ListCallsWithTranscriptsRequest([ + * 'conversationIds' => [ + * '64619700005694', + * '64619700005695', + * ], + * ]), + * ); + * ``` + * * @param ListCallsWithTranscriptsRequest $request * @param ?array{ * baseUrl?: string, @@ -291,11 +305,11 @@ public function showCallTranscript(ShowCallTranscriptRequest $request, ?array $o * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ListCallsWithTranscriptsResponse + * @return ?ListCallsWithTranscriptsResponse * @throws IntercomException * @throws IntercomApiException */ - public function listCallsWithTranscripts(ListCallsWithTranscriptsRequest $request, ?array $options = null): ListCallsWithTranscriptsResponse + public function listCallsWithTranscripts(ListCallsWithTranscriptsRequest $request, ?array $options = null): ?ListCallsWithTranscriptsResponse { $options = array_merge($this->options, $options ?? []); try { @@ -311,20 +325,13 @@ public function listCallsWithTranscripts(ListCallsWithTranscriptsRequest $reques $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } diff --git a/src/Calls/Requests/ListCallsRequest.php b/src/Calls/Requests/ListCallsRequest.php index cdfedbd3..8a1428be 100644 --- a/src/Calls/Requests/ListCallsRequest.php +++ b/src/Calls/Requests/ListCallsRequest.php @@ -43,6 +43,7 @@ public function getPage(): ?int public function setPage(?int $value = null): self { $this->page = $value; + $this->_setField('page'); return $this; } @@ -60,6 +61,7 @@ public function getPerPage(): ?int public function setPerPage(?int $value = null): self { $this->perPage = $value; + $this->_setField('perPage'); return $this; } } diff --git a/src/Calls/Requests/ListCallsWithTranscriptsRequest.php b/src/Calls/Requests/ListCallsWithTranscriptsRequest.php index b6b37865..fcbc5311 100644 --- a/src/Calls/Requests/ListCallsWithTranscriptsRequest.php +++ b/src/Calls/Requests/ListCallsWithTranscriptsRequest.php @@ -39,6 +39,7 @@ public function getConversationIds(): array public function setConversationIds(array $value): self { $this->conversationIds = $value; + $this->_setField('conversationIds'); return $this; } } diff --git a/src/Calls/Requests/ShowCallRecordingRequest.php b/src/Calls/Requests/ShowCallRecordingRequest.php index b4a66ba0..037ebc5b 100644 --- a/src/Calls/Requests/ShowCallRecordingRequest.php +++ b/src/Calls/Requests/ShowCallRecordingRequest.php @@ -36,6 +36,7 @@ public function getCallId(): string public function setCallId(string $value): self { $this->callId = $value; + $this->_setField('callId'); return $this; } } diff --git a/src/Calls/Requests/ShowCallRequest.php b/src/Calls/Requests/ShowCallRequest.php index 36756bd1..5d4f792d 100644 --- a/src/Calls/Requests/ShowCallRequest.php +++ b/src/Calls/Requests/ShowCallRequest.php @@ -36,6 +36,7 @@ public function getCallId(): string public function setCallId(string $value): self { $this->callId = $value; + $this->_setField('callId'); return $this; } } diff --git a/src/Calls/Requests/ShowCallTranscriptRequest.php b/src/Calls/Requests/ShowCallTranscriptRequest.php index 3d354459..72bab94e 100644 --- a/src/Calls/Requests/ShowCallTranscriptRequest.php +++ b/src/Calls/Requests/ShowCallTranscriptRequest.php @@ -36,6 +36,7 @@ public function getCallId(): string public function setCallId(string $value): self { $this->callId = $value; + $this->_setField('callId'); return $this; } } diff --git a/src/Calls/Traits/Call.php b/src/Calls/Traits/Call.php index 0d72c163..aad87b51 100644 --- a/src/Calls/Traits/Call.php +++ b/src/Calls/Traits/Call.php @@ -189,6 +189,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -206,6 +207,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -223,6 +225,7 @@ public function getConversationId(): ?string public function setConversationId(?string $value = null): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } @@ -240,6 +243,7 @@ public function getAdminId(): ?string public function setAdminId(?string $value = null): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } @@ -257,6 +261,7 @@ public function getContactId(): ?string public function setContactId(?string $value = null): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } @@ -274,6 +279,7 @@ public function getState(): ?string public function setState(?string $value = null): self { $this->state = $value; + $this->_setField('state'); return $this; } @@ -297,6 +303,7 @@ public function getInitiatedAt(): DateTime|int|null public function setInitiatedAt(DateTime|int|null $value = null): self { $this->initiatedAt = $value; + $this->_setField('initiatedAt'); return $this; } @@ -320,6 +327,7 @@ public function getAnsweredAt(): DateTime|int|null public function setAnsweredAt(DateTime|int|null $value = null): self { $this->answeredAt = $value; + $this->_setField('answeredAt'); return $this; } @@ -343,6 +351,7 @@ public function getEndedAt(): DateTime|int|null public function setEndedAt(DateTime|int|null $value = null): self { $this->endedAt = $value; + $this->_setField('endedAt'); return $this; } @@ -366,6 +375,7 @@ public function getCreatedAt(): DateTime|int|null public function setCreatedAt(DateTime|int|null $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -389,6 +399,7 @@ public function getUpdatedAt(): DateTime|int|null public function setUpdatedAt(DateTime|int|null $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -406,6 +417,7 @@ public function getRecordingUrl(): ?string public function setRecordingUrl(?string $value = null): self { $this->recordingUrl = $value; + $this->_setField('recordingUrl'); return $this; } @@ -423,6 +435,7 @@ public function getTranscriptionUrl(): ?string public function setTranscriptionUrl(?string $value = null): self { $this->transcriptionUrl = $value; + $this->_setField('transcriptionUrl'); return $this; } @@ -440,6 +453,7 @@ public function getCallType(): ?string public function setCallType(?string $value = null): self { $this->callType = $value; + $this->_setField('callType'); return $this; } @@ -457,6 +471,7 @@ public function getDirection(): ?string public function setDirection(?string $value = null): self { $this->direction = $value; + $this->_setField('direction'); return $this; } @@ -474,6 +489,7 @@ public function getEndedReason(): ?string public function setEndedReason(?string $value = null): self { $this->endedReason = $value; + $this->_setField('endedReason'); return $this; } @@ -491,6 +507,7 @@ public function getPhone(): ?string public function setPhone(?string $value = null): self { $this->phone = $value; + $this->_setField('phone'); return $this; } @@ -508,6 +525,7 @@ public function getFinRecordingUrl(): ?string public function setFinRecordingUrl(?string $value = null): self { $this->finRecordingUrl = $value; + $this->_setField('finRecordingUrl'); return $this; } @@ -525,6 +543,7 @@ public function getFinTranscriptionUrl(): ?string public function setFinTranscriptionUrl(?string $value = null): self { $this->finTranscriptionUrl = $value; + $this->_setField('finTranscriptionUrl'); return $this; } } diff --git a/src/Calls/Types/Call.php b/src/Calls/Types/Call.php index 28d5c00b..8acf24e3 100644 --- a/src/Calls/Types/Call.php +++ b/src/Calls/Types/Call.php @@ -217,6 +217,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -234,6 +235,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -251,6 +253,7 @@ public function getConversationId(): ?string public function setConversationId(?string $value = null): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } @@ -268,6 +271,7 @@ public function getAdminId(): ?string public function setAdminId(?string $value = null): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } @@ -285,6 +289,7 @@ public function getContactId(): ?string public function setContactId(?string $value = null): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } @@ -302,6 +307,7 @@ public function getState(): ?string public function setState(?string $value = null): self { $this->state = $value; + $this->_setField('state'); return $this; } @@ -325,6 +331,7 @@ public function getInitiatedAt(): DateTime|int|null public function setInitiatedAt(DateTime|int|null $value = null): self { $this->initiatedAt = $value; + $this->_setField('initiatedAt'); return $this; } @@ -348,6 +355,7 @@ public function getAnsweredAt(): DateTime|int|null public function setAnsweredAt(DateTime|int|null $value = null): self { $this->answeredAt = $value; + $this->_setField('answeredAt'); return $this; } @@ -371,6 +379,7 @@ public function getEndedAt(): DateTime|int|null public function setEndedAt(DateTime|int|null $value = null): self { $this->endedAt = $value; + $this->_setField('endedAt'); return $this; } @@ -394,6 +403,7 @@ public function getCreatedAt(): DateTime|int|null public function setCreatedAt(DateTime|int|null $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -417,6 +427,7 @@ public function getUpdatedAt(): DateTime|int|null public function setUpdatedAt(DateTime|int|null $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -434,6 +445,7 @@ public function getRecordingUrl(): ?string public function setRecordingUrl(?string $value = null): self { $this->recordingUrl = $value; + $this->_setField('recordingUrl'); return $this; } @@ -451,6 +463,7 @@ public function getTranscriptionUrl(): ?string public function setTranscriptionUrl(?string $value = null): self { $this->transcriptionUrl = $value; + $this->_setField('transcriptionUrl'); return $this; } @@ -468,6 +481,7 @@ public function getCallType(): ?string public function setCallType(?string $value = null): self { $this->callType = $value; + $this->_setField('callType'); return $this; } @@ -485,6 +499,7 @@ public function getDirection(): ?string public function setDirection(?string $value = null): self { $this->direction = $value; + $this->_setField('direction'); return $this; } @@ -502,6 +517,7 @@ public function getEndedReason(): ?string public function setEndedReason(?string $value = null): self { $this->endedReason = $value; + $this->_setField('endedReason'); return $this; } @@ -519,6 +535,7 @@ public function getPhone(): ?string public function setPhone(?string $value = null): self { $this->phone = $value; + $this->_setField('phone'); return $this; } @@ -536,6 +553,7 @@ public function getFinRecordingUrl(): ?string public function setFinRecordingUrl(?string $value = null): self { $this->finRecordingUrl = $value; + $this->_setField('finRecordingUrl'); return $this; } @@ -553,6 +571,7 @@ public function getFinTranscriptionUrl(): ?string public function setFinTranscriptionUrl(?string $value = null): self { $this->finTranscriptionUrl = $value; + $this->_setField('finTranscriptionUrl'); return $this; } diff --git a/src/Calls/Types/ListCallsWithTranscriptsResponse.php b/src/Calls/Types/ListCallsWithTranscriptsResponse.php index 811de6e0..bb2031cd 100644 --- a/src/Calls/Types/ListCallsWithTranscriptsResponse.php +++ b/src/Calls/Types/ListCallsWithTranscriptsResponse.php @@ -47,6 +47,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -64,6 +65,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Calls/Types/ListCallsWithTranscriptsResponseDataItem.php b/src/Calls/Types/ListCallsWithTranscriptsResponseDataItem.php index 9e0bd981..fee564d5 100644 --- a/src/Calls/Types/ListCallsWithTranscriptsResponseDataItem.php +++ b/src/Calls/Types/ListCallsWithTranscriptsResponseDataItem.php @@ -104,6 +104,7 @@ public function getTranscript(): ?array public function setTranscript(?array $value = null): self { $this->transcript = $value; + $this->_setField('transcript'); return $this; } @@ -121,6 +122,7 @@ public function getTranscriptStatus(): ?string public function setTranscriptStatus(?string $value = null): self { $this->transcriptStatus = $value; + $this->_setField('transcriptStatus'); return $this; } diff --git a/src/Companies/CompaniesClient.php b/src/Companies/CompaniesClient.php index cf702c95..a82f5f1a 100644 --- a/src/Companies/CompaniesClient.php +++ b/src/Companies/CompaniesClient.php @@ -2,7 +2,7 @@ namespace Intercom\Companies; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Companies\Requests\RetrieveCompanyRequest; use Intercom\Companies\Types\CompaniesRetrieveResponse; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Types\CreateOrUpdateCompanyRequest; use Intercom\Companies\Types\Company; @@ -83,6 +82,20 @@ public function __construct( * * `https://api.intercom.io/companies?segment_id={segment_id}` * + * Example: + * ```php + * $client->companies->retrieve( + * new RetrieveCompanyRequest([ + * 'name' => 'my company', + * 'companyId' => '12345', + * 'tagId' => '678910', + * 'segmentId' => '98765', + * 'page' => 1, + * 'perPage' => 1, + * ]), + * ); + * ``` + * * @param RetrieveCompanyRequest $request * @param ?array{ * baseUrl?: string, @@ -92,11 +105,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return CompaniesRetrieveResponse + * @return ?CompaniesRetrieveResponse * @throws IntercomException * @throws IntercomApiException */ - public function retrieve(RetrieveCompanyRequest $request = new RetrieveCompanyRequest(), ?array $options = null): CompaniesRetrieveResponse + public function retrieve(RetrieveCompanyRequest $request = new RetrieveCompanyRequest(), ?array $options = null): ?CompaniesRetrieveResponse { $options = array_merge($this->options, $options ?? []); $query = []; @@ -131,20 +144,13 @@ public function retrieve(RetrieveCompanyRequest $request = new RetrieveCompanyRe $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return CompaniesRetrieveResponse::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); } @@ -166,6 +172,17 @@ 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 %} * + * Example: + * ```php + * $client->companies->createOrUpdate( + * new CreateOrUpdateCompanyRequest([ + * 'name' => 'my company', + * 'companyId' => 'company_remote_id', + * 'remoteCreatedAt' => 1374138000, + * ]), + * ); + * ``` + * * @param ?CreateOrUpdateCompanyRequest $request * @param ?array{ * baseUrl?: string, @@ -175,11 +192,11 @@ public function retrieve(RetrieveCompanyRequest $request = new RetrieveCompanyRe * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Company + * @return ?Company * @throws IntercomException * @throws IntercomApiException */ - public function createOrUpdate(?CreateOrUpdateCompanyRequest $request = null, ?array $options = null): Company + public function createOrUpdate(?CreateOrUpdateCompanyRequest $request = null, ?array $options = null): ?Company { $options = array_merge($this->options, $options ?? []); try { @@ -195,20 +212,13 @@ public function createOrUpdate(?CreateOrUpdateCompanyRequest $request = null, ?a $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Company::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); } @@ -222,6 +232,15 @@ public function createOrUpdate(?CreateOrUpdateCompanyRequest $request = null, ?a /** * You can fetch a single company. * + * Example: + * ```php + * $client->companies->find( + * new FindCompanyRequest([ + * 'companyId' => '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', + * ]), + * ); + * ``` + * * @param FindCompanyRequest $request * @param ?array{ * baseUrl?: string, @@ -231,18 +250,18 @@ public function createOrUpdate(?CreateOrUpdateCompanyRequest $request = null, ?a * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Company + * @return ?Company * @throws IntercomException * @throws IntercomApiException */ - public function find(FindCompanyRequest $request, ?array $options = null): Company + public function find(FindCompanyRequest $request, ?array $options = null): ?Company { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "companies/{$request->getCompanyId()}", + path: "companies/" . RawClient::encodePathParam($request->getCompanyId()), method: HttpMethod::GET, ), $options, @@ -250,20 +269,13 @@ public function find(FindCompanyRequest $request, ?array $options = null): Compa $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Company::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); } @@ -281,6 +293,19 @@ public function find(FindCompanyRequest $request, ?array $options = null): Compa * When updating a company it is not possible to update `company_id`. This can only be set once upon creation of the company. * {% /admonition %} * + * Example: + * ```php + * $client->companies->update( + * new UpdateCompanyRequest([ + * 'companyId' => '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', + * 'body' => new UpdateCompanyRequestBody([ + * 'name' => 'my company', + * 'website' => 'http://www.mycompany.com/', + * ]), + * ]), + * ); + * ``` + * * @param UpdateCompanyRequest $request * @param ?array{ * baseUrl?: string, @@ -290,18 +315,18 @@ public function find(FindCompanyRequest $request, ?array $options = null): Compa * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Company + * @return ?Company * @throws IntercomException * @throws IntercomApiException */ - public function update(UpdateCompanyRequest $request, ?array $options = null): Company + public function update(UpdateCompanyRequest $request, ?array $options = null): ?Company { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "companies/{$request->getCompanyId()}", + path: "companies/" . RawClient::encodePathParam($request->getCompanyId()), method: HttpMethod::PUT, body: $request->getBody(), ), @@ -310,20 +335,13 @@ public function update(UpdateCompanyRequest $request, ?array $options = null): C $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Company::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); } @@ -337,6 +355,15 @@ public function update(UpdateCompanyRequest $request, ?array $options = null): C /** * You can delete a single company. * + * Example: + * ```php + * $client->companies->delete( + * new DeleteCompanyRequest([ + * 'companyId' => '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', + * ]), + * ); + * ``` + * * @param DeleteCompanyRequest $request * @param ?array{ * baseUrl?: string, @@ -346,18 +373,18 @@ public function update(UpdateCompanyRequest $request, ?array $options = null): C * queryParameters?: array, * bodyProperties?: array, * } $options - * @return DeletedCompanyObject + * @return ?DeletedCompanyObject * @throws IntercomException * @throws IntercomApiException */ - public function delete(DeleteCompanyRequest $request, ?array $options = null): DeletedCompanyObject + public function delete(DeleteCompanyRequest $request, ?array $options = null): ?DeletedCompanyObject { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "companies/{$request->getCompanyId()}", + path: "companies/" . RawClient::encodePathParam($request->getCompanyId()), method: HttpMethod::DELETE, ), $options, @@ -365,20 +392,13 @@ public function delete(DeleteCompanyRequest $request, ?array $options = null): D $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return DeletedCompanyObject::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); } @@ -392,6 +412,15 @@ public function delete(DeleteCompanyRequest $request, ?array $options = null): D /** * You can fetch a list of all contacts that belong to a company. * + * Example: + * ```php + * $client->companies->listAttachedContacts( + * new ListAttachedContactsRequest([ + * 'companyId' => '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', + * ]), + * ); + * ``` + * * @param ListAttachedContactsRequest $request * @param ?array{ * baseUrl?: string, @@ -401,18 +430,18 @@ public function delete(DeleteCompanyRequest $request, ?array $options = null): D * queryParameters?: array, * bodyProperties?: array, * } $options - * @return CompanyAttachedContacts + * @return ?CompanyAttachedContacts * @throws IntercomException * @throws IntercomApiException */ - public function listAttachedContacts(ListAttachedContactsRequest $request, ?array $options = null): CompanyAttachedContacts + public function listAttachedContacts(ListAttachedContactsRequest $request, ?array $options = null): ?CompanyAttachedContacts { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "companies/{$request->getCompanyId()}/contacts", + path: "companies/" . RawClient::encodePathParam($request->getCompanyId()) . "/contacts", method: HttpMethod::GET, ), $options, @@ -420,20 +449,13 @@ public function listAttachedContacts(ListAttachedContactsRequest $request, ?arra $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return CompanyAttachedContacts::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); } @@ -447,6 +469,15 @@ public function listAttachedContacts(ListAttachedContactsRequest $request, ?arra /** * You can fetch a list of all segments that belong to a company. * + * Example: + * ```php + * $client->companies->listAttachedSegments( + * new ListSegmentsAttachedToCompanyRequest([ + * 'companyId' => '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', + * ]), + * ); + * ``` + * * @param ListSegmentsAttachedToCompanyRequest $request * @param ?array{ * baseUrl?: string, @@ -456,18 +487,18 @@ public function listAttachedContacts(ListAttachedContactsRequest $request, ?arra * queryParameters?: array, * bodyProperties?: array, * } $options - * @return CompanyAttachedSegments + * @return ?CompanyAttachedSegments * @throws IntercomException * @throws IntercomApiException */ - public function listAttachedSegments(ListSegmentsAttachedToCompanyRequest $request, ?array $options = null): CompanyAttachedSegments + public function listAttachedSegments(ListSegmentsAttachedToCompanyRequest $request, ?array $options = null): ?CompanyAttachedSegments { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "companies/{$request->getCompanyId()}/segments", + path: "companies/" . RawClient::encodePathParam($request->getCompanyId()) . "/segments", method: HttpMethod::GET, ), $options, @@ -475,20 +506,13 @@ public function listAttachedSegments(ListSegmentsAttachedToCompanyRequest $reque $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return CompanyAttachedSegments::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); } @@ -510,6 +534,17 @@ public function listAttachedSegments(ListSegmentsAttachedToCompanyRequest $reque * See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. * {% /admonition %} * + * Example: + * ```php + * $client->companies->list( + * new ListCompaniesRequest([ + * 'page' => 1, + * 'perPage' => 1, + * 'order' => 'desc', + * ]), + * ); + * ``` + * * @param ListCompaniesRequest $request * @param ?array{ * baseUrl?: string, @@ -533,7 +568,7 @@ public function list(ListCompaniesRequest $request = new ListCompaniesRequest(), }, getStep: null, /* @phpstan-ignore-next-line */ - getItems: fn (CompanyList $response) => $response?->getData() ?? [], + getItems: fn (?CompanyList $response) => $response?->getData() ?? [], /* @phpstan-ignore-next-line */ hasNextPage: null, ); @@ -556,6 +591,15 @@ public function list(ListCompaniesRequest $request = new ListCompaniesRequest(), * If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll. * {% /admonition %} * + * Example: + * ```php + * $client->companies->scroll( + * new ScrollCompaniesRequest([ + * 'scrollParam' => 'scroll_param', + * ]), + * ); + * ``` + * * @param ScrollCompaniesRequest $request * @param ?array{ * baseUrl?: string, @@ -585,6 +629,16 @@ public function scroll(ScrollCompaniesRequest $request = new ScrollCompaniesRequ /** * You can attach a company to a single contact. * + * Example: + * ```php + * $client->companies->attachContact( + * new AttachContactToCompanyRequest([ + * 'contactId' => 'contact_id', + * 'companyId' => '6762f09a1bb69f9f2193bb34', + * ]), + * ); + * ``` + * * @param AttachContactToCompanyRequest $request * @param ?array{ * baseUrl?: string, @@ -594,18 +648,18 @@ public function scroll(ScrollCompaniesRequest $request = new ScrollCompaniesRequ * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Company + * @return ?Company * @throws IntercomException * @throws IntercomApiException */ - public function attachContact(AttachContactToCompanyRequest $request, ?array $options = null): Company + public function attachContact(AttachContactToCompanyRequest $request, ?array $options = null): ?Company { $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()}/companies", + path: "contacts/" . RawClient::encodePathParam($request->getContactId()) . "/companies", method: HttpMethod::POST, body: $request, ), @@ -614,20 +668,13 @@ public function attachContact(AttachContactToCompanyRequest $request, ?array $op $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Company::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); } @@ -641,6 +688,16 @@ public function attachContact(AttachContactToCompanyRequest $request, ?array $op /** * You can detach a company from a single contact. * + * Example: + * ```php + * $client->companies->detachContact( + * new DetachContactFromCompanyRequest([ + * 'contactId' => '58a430d35458202d41b1e65b', + * 'companyId' => '58a430d35458202d41b1e65b', + * ]), + * ); + * ``` + * * @param DetachContactFromCompanyRequest $request * @param ?array{ * baseUrl?: string, @@ -650,18 +707,18 @@ public function attachContact(AttachContactToCompanyRequest $request, ?array $op * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Company + * @return ?Company * @throws IntercomException * @throws IntercomApiException */ - public function detachContact(DetachContactFromCompanyRequest $request, ?array $options = null): Company + public function detachContact(DetachContactFromCompanyRequest $request, ?array $options = null): ?Company { $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()}/companies/{$request->getCompanyId()}", + path: "contacts/" . RawClient::encodePathParam($request->getContactId()) . "/companies/" . RawClient::encodePathParam($request->getCompanyId()), method: HttpMethod::DELETE, ), $options, @@ -669,20 +726,13 @@ public function detachContact(DetachContactFromCompanyRequest $request, ?array $ $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Company::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); } @@ -713,11 +763,11 @@ public function detachContact(DetachContactFromCompanyRequest $request, ?array $ * queryParameters?: array, * bodyProperties?: array, * } $options - * @return CompanyList + * @return ?CompanyList * @throws IntercomException * @throws IntercomApiException */ - private function _list(ListCompaniesRequest $request = new ListCompaniesRequest(), ?array $options = null): CompanyList + private function _list(ListCompaniesRequest $request = new ListCompaniesRequest(), ?array $options = null): ?CompanyList { $options = array_merge($this->options, $options ?? []); $query = []; @@ -743,20 +793,13 @@ private function _list(ListCompaniesRequest $request = new ListCompaniesRequest( $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return CompanyList::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); } @@ -824,16 +867,6 @@ private function _scroll(ScrollCompaniesRequest $request = new ScrollCompaniesRe } } 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); } diff --git a/src/Companies/Requests/AttachContactToCompanyRequest.php b/src/Companies/Requests/AttachContactToCompanyRequest.php index 974fb138..ac09a0a0 100644 --- a/src/Companies/Requests/AttachContactToCompanyRequest.php +++ b/src/Companies/Requests/AttachContactToCompanyRequest.php @@ -45,6 +45,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } @@ -62,6 +63,7 @@ public function getCompanyId(): string public function setCompanyId(string $value): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } } diff --git a/src/Companies/Requests/DeleteCompanyRequest.php b/src/Companies/Requests/DeleteCompanyRequest.php index 0d5ffc29..04c9a369 100644 --- a/src/Companies/Requests/DeleteCompanyRequest.php +++ b/src/Companies/Requests/DeleteCompanyRequest.php @@ -36,6 +36,7 @@ public function getCompanyId(): string public function setCompanyId(string $value): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } } diff --git a/src/Companies/Requests/DetachContactFromCompanyRequest.php b/src/Companies/Requests/DetachContactFromCompanyRequest.php index 540af626..b4cac876 100644 --- a/src/Companies/Requests/DetachContactFromCompanyRequest.php +++ b/src/Companies/Requests/DetachContactFromCompanyRequest.php @@ -43,6 +43,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } @@ -60,6 +61,7 @@ public function getCompanyId(): string public function setCompanyId(string $value): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } } diff --git a/src/Companies/Requests/FindCompanyRequest.php b/src/Companies/Requests/FindCompanyRequest.php index 6789872c..9f31bccf 100644 --- a/src/Companies/Requests/FindCompanyRequest.php +++ b/src/Companies/Requests/FindCompanyRequest.php @@ -36,6 +36,7 @@ public function getCompanyId(): string public function setCompanyId(string $value): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } } diff --git a/src/Companies/Requests/ListAttachedContactsRequest.php b/src/Companies/Requests/ListAttachedContactsRequest.php index c10f4d57..bdf340ba 100644 --- a/src/Companies/Requests/ListAttachedContactsRequest.php +++ b/src/Companies/Requests/ListAttachedContactsRequest.php @@ -36,6 +36,7 @@ public function getCompanyId(): string public function setCompanyId(string $value): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } } diff --git a/src/Companies/Requests/ListCompaniesRequest.php b/src/Companies/Requests/ListCompaniesRequest.php index 15149bd6..db631e48 100644 --- a/src/Companies/Requests/ListCompaniesRequest.php +++ b/src/Companies/Requests/ListCompaniesRequest.php @@ -50,6 +50,7 @@ public function getPage(): ?int public function setPage(?int $value = null): self { $this->page = $value; + $this->_setField('page'); return $this; } @@ -67,6 +68,7 @@ public function getPerPage(): ?int public function setPerPage(?int $value = null): self { $this->perPage = $value; + $this->_setField('perPage'); return $this; } @@ -84,6 +86,7 @@ public function getOrder(): ?string public function setOrder(?string $value = null): self { $this->order = $value; + $this->_setField('order'); return $this; } } diff --git a/src/Companies/Requests/ListSegmentsAttachedToCompanyRequest.php b/src/Companies/Requests/ListSegmentsAttachedToCompanyRequest.php index 2b0332c3..d7344b25 100644 --- a/src/Companies/Requests/ListSegmentsAttachedToCompanyRequest.php +++ b/src/Companies/Requests/ListSegmentsAttachedToCompanyRequest.php @@ -36,6 +36,7 @@ public function getCompanyId(): string public function setCompanyId(string $value): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } } diff --git a/src/Companies/Requests/RetrieveCompanyRequest.php b/src/Companies/Requests/RetrieveCompanyRequest.php index 5d7c5363..2116c8e9 100644 --- a/src/Companies/Requests/RetrieveCompanyRequest.php +++ b/src/Companies/Requests/RetrieveCompanyRequest.php @@ -71,6 +71,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -88,6 +89,7 @@ public function getCompanyId(): ?string public function setCompanyId(?string $value = null): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } @@ -105,6 +107,7 @@ public function getTagId(): ?string public function setTagId(?string $value = null): self { $this->tagId = $value; + $this->_setField('tagId'); return $this; } @@ -122,6 +125,7 @@ public function getSegmentId(): ?string public function setSegmentId(?string $value = null): self { $this->segmentId = $value; + $this->_setField('segmentId'); return $this; } @@ -139,6 +143,7 @@ public function getPage(): ?int public function setPage(?int $value = null): self { $this->page = $value; + $this->_setField('page'); return $this; } @@ -156,6 +161,7 @@ public function getPerPage(): ?int public function setPerPage(?int $value = null): self { $this->perPage = $value; + $this->_setField('perPage'); return $this; } } diff --git a/src/Companies/Requests/ScrollCompaniesRequest.php b/src/Companies/Requests/ScrollCompaniesRequest.php index 5191117a..be565f76 100644 --- a/src/Companies/Requests/ScrollCompaniesRequest.php +++ b/src/Companies/Requests/ScrollCompaniesRequest.php @@ -36,6 +36,7 @@ public function getScrollParam(): ?string public function setScrollParam(?string $value = null): self { $this->scrollParam = $value; + $this->_setField('scrollParam'); return $this; } } diff --git a/src/Companies/Requests/UpdateCompanyRequest.php b/src/Companies/Requests/UpdateCompanyRequest.php index 4f2f65aa..b04cc761 100644 --- a/src/Companies/Requests/UpdateCompanyRequest.php +++ b/src/Companies/Requests/UpdateCompanyRequest.php @@ -44,6 +44,7 @@ public function getCompanyId(): string public function setCompanyId(string $value): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } @@ -61,6 +62,7 @@ public function getBody(): ?UpdateCompanyRequestBody public function setBody(?UpdateCompanyRequestBody $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } } diff --git a/src/Companies/Types/CompaniesRetrieveResponse.php b/src/Companies/Types/CompaniesRetrieveResponse.php index 06d081ad..9e85b620 100644 --- a/src/Companies/Types/CompaniesRetrieveResponse.php +++ b/src/Companies/Types/CompaniesRetrieveResponse.php @@ -5,7 +5,6 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Types\CompanyList; use Exception; -use Intercom\Core\Json\JsonDecoder; class CompaniesRetrieveResponse extends JsonSerializableType { @@ -184,18 +183,6 @@ public function jsonSerialize(): array 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 */ diff --git a/src/Companies/Types/Company.php b/src/Companies/Types/Company.php index db5c5814..a05669f8 100644 --- a/src/Companies/Types/Company.php +++ b/src/Companies/Types/Company.php @@ -186,6 +186,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -203,6 +204,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -220,6 +222,7 @@ public function getName(): string public function setName(string $value): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -237,6 +240,7 @@ public function getAppId(): string public function setAppId(string $value): self { $this->appId = $value; + $this->_setField('appId'); return $this; } @@ -254,6 +258,7 @@ public function getPlan(): ?CompanyPlan public function setPlan(?CompanyPlan $value = null): self { $this->plan = $value; + $this->_setField('plan'); return $this; } @@ -271,6 +276,7 @@ public function getCompanyId(): string public function setCompanyId(string $value): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } @@ -288,6 +294,7 @@ public function getRemoteCreatedAt(): ?int public function setRemoteCreatedAt(?int $value = null): self { $this->remoteCreatedAt = $value; + $this->_setField('remoteCreatedAt'); return $this; } @@ -305,6 +312,7 @@ public function getCreatedAt(): int public function setCreatedAt(int $value): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -322,6 +330,7 @@ public function getUpdatedAt(): int public function setUpdatedAt(int $value): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -339,6 +348,7 @@ public function getLastRequestAt(): ?int public function setLastRequestAt(?int $value = null): self { $this->lastRequestAt = $value; + $this->_setField('lastRequestAt'); return $this; } @@ -356,6 +366,7 @@ public function getSize(): ?int public function setSize(?int $value = null): self { $this->size = $value; + $this->_setField('size'); return $this; } @@ -373,6 +384,7 @@ public function getWebsite(): ?string public function setWebsite(?string $value = null): self { $this->website = $value; + $this->_setField('website'); return $this; } @@ -390,6 +402,7 @@ public function getIndustry(): ?string public function setIndustry(?string $value = null): self { $this->industry = $value; + $this->_setField('industry'); return $this; } @@ -407,6 +420,7 @@ public function getMonthlySpend(): int public function setMonthlySpend(int $value): self { $this->monthlySpend = $value; + $this->_setField('monthlySpend'); return $this; } @@ -424,6 +438,7 @@ public function getSessionCount(): int public function setSessionCount(int $value): self { $this->sessionCount = $value; + $this->_setField('sessionCount'); return $this; } @@ -441,6 +456,7 @@ public function getUserCount(): int public function setUserCount(int $value): self { $this->userCount = $value; + $this->_setField('userCount'); return $this; } @@ -458,6 +474,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } @@ -475,6 +492,7 @@ public function getTags(): ?CompanyTags public function setTags(?CompanyTags $value = null): self { $this->tags = $value; + $this->_setField('tags'); return $this; } @@ -492,6 +510,7 @@ public function getSegments(): ?CompanySegments public function setSegments(?CompanySegments $value = null): self { $this->segments = $value; + $this->_setField('segments'); return $this; } diff --git a/src/Companies/Types/CompanyPlan.php b/src/Companies/Types/CompanyPlan.php index af273602..e74018da 100644 --- a/src/Companies/Types/CompanyPlan.php +++ b/src/Companies/Types/CompanyPlan.php @@ -54,6 +54,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -71,6 +72,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -88,6 +90,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } diff --git a/src/Companies/Types/CompanySegments.php b/src/Companies/Types/CompanySegments.php index 21df7441..d99b973d 100644 --- a/src/Companies/Types/CompanySegments.php +++ b/src/Companies/Types/CompanySegments.php @@ -51,6 +51,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -68,6 +69,7 @@ public function getSegments(): ?array public function setSegments(?array $value = null): self { $this->segments = $value; + $this->_setField('segments'); return $this; } diff --git a/src/Companies/Types/CompanyTags.php b/src/Companies/Types/CompanyTags.php index dccdaaf2..c6360107 100644 --- a/src/Companies/Types/CompanyTags.php +++ b/src/Companies/Types/CompanyTags.php @@ -50,6 +50,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -67,6 +68,7 @@ public function getTags(): ?array public function setTags(?array $value = null): self { $this->tags = $value; + $this->_setField('tags'); return $this; } diff --git a/src/Contacts/ContactsClient.php b/src/Contacts/ContactsClient.php index 969f9dfe..b2cbdbd1 100644 --- a/src/Contacts/ContactsClient.php +++ b/src/Contacts/ContactsClient.php @@ -2,7 +2,7 @@ namespace Intercom\Contacts; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Contacts\Requests\ListAttachedCompaniesRequest; use Intercom\Core\Pagination\Pager; @@ -17,7 +17,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Contacts\Requests\ListAttachedSubscriptionsRequest; use Intercom\Types\SubscriptionTypeList; @@ -94,6 +93,17 @@ public function __construct( /** * You can fetch a list of companies that are associated to a contact. * + * Example: + * ```php + * $client->contacts->listAttachedCompanies( + * new ListAttachedCompaniesRequest([ + * 'contactId' => '63a07ddf05a32042dffac965', + * 'page' => 1, + * 'perPage' => 1, + * ]), + * ); + * ``` + * * @param ListAttachedCompaniesRequest $request * @param ?array{ * baseUrl?: string, @@ -117,7 +127,7 @@ public function listAttachedCompanies(ListAttachedCompaniesRequest $request, ?ar }, getStep: null, /* @phpstan-ignore-next-line */ - getItems: fn (ContactAttachedCompanies $response) => $response?->getCompanies() ?? [], + getItems: fn (?ContactAttachedCompanies $response) => $response?->getCompanies() ?? [], /* @phpstan-ignore-next-line */ hasNextPage: null, ); @@ -126,6 +136,15 @@ public function listAttachedCompanies(ListAttachedCompaniesRequest $request, ?ar /** * You can fetch a list of segments that are associated to a contact. * + * Example: + * ```php + * $client->contacts->listAttachedSegments( + * new ListSegmentsAttachedToContactRequest([ + * 'contactId' => '63a07ddf05a32042dffac965', + * ]), + * ); + * ``` + * * @param ListSegmentsAttachedToContactRequest $request * @param ?array{ * baseUrl?: string, @@ -135,18 +154,18 @@ public function listAttachedCompanies(ListAttachedCompaniesRequest $request, ?ar * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContactSegments + * @return ?ContactSegments * @throws IntercomException * @throws IntercomApiException */ - public function listAttachedSegments(ListSegmentsAttachedToContactRequest $request, ?array $options = null): ContactSegments + public function listAttachedSegments(ListSegmentsAttachedToContactRequest $request, ?array $options = null): ?ContactSegments { $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()}/segments", + path: "contacts/" . RawClient::encodePathParam($request->getContactId()) . "/segments", method: HttpMethod::GET, ), $options, @@ -154,20 +173,13 @@ public function listAttachedSegments(ListSegmentsAttachedToContactRequest $reque $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ContactSegments::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); } @@ -187,6 +199,15 @@ public function listAttachedSegments(ListSegmentsAttachedToContactRequest $reque * 1.Opt-out subscription types that the user has opted-out from. * 2.Opt-in subscription types that the user has opted-in to receiving. * + * Example: + * ```php + * $client->contacts->listAttachedSubscriptions( + * new ListAttachedSubscriptionsRequest([ + * 'contactId' => '63a07ddf05a32042dffac965', + * ]), + * ); + * ``` + * * @param ListAttachedSubscriptionsRequest $request * @param ?array{ * baseUrl?: string, @@ -196,18 +217,18 @@ public function listAttachedSegments(ListSegmentsAttachedToContactRequest $reque * queryParameters?: array, * bodyProperties?: array, * } $options - * @return SubscriptionTypeList + * @return ?SubscriptionTypeList * @throws IntercomException * @throws IntercomApiException */ - public function listAttachedSubscriptions(ListAttachedSubscriptionsRequest $request, ?array $options = null): SubscriptionTypeList + public function listAttachedSubscriptions(ListAttachedSubscriptionsRequest $request, ?array $options = null): ?SubscriptionTypeList { $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()}/subscriptions", + path: "contacts/" . RawClient::encodePathParam($request->getContactId()) . "/subscriptions", method: HttpMethod::GET, ), $options, @@ -215,20 +236,13 @@ public function listAttachedSubscriptions(ListAttachedSubscriptionsRequest $requ $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return SubscriptionTypeList::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); } @@ -248,6 +262,17 @@ public function listAttachedSubscriptions(ListAttachedSubscriptionsRequest $requ * * This will return a subscription type model for the subscription type that was added to the contact. * + * Example: + * ```php + * $client->contacts->attachSubscription( + * new AttachSubscriptionToContactRequest([ + * 'contactId' => '63a07ddf05a32042dffac965', + * 'subscriptionId' => '37846', + * 'consentType' => 'opt_in', + * ]), + * ); + * ``` + * * @param AttachSubscriptionToContactRequest $request * @param ?array{ * baseUrl?: string, @@ -257,18 +282,18 @@ public function listAttachedSubscriptions(ListAttachedSubscriptionsRequest $requ * queryParameters?: array, * bodyProperties?: array, * } $options - * @return SubscriptionType + * @return ?SubscriptionType * @throws IntercomException * @throws IntercomApiException */ - public function attachSubscription(AttachSubscriptionToContactRequest $request, ?array $options = null): SubscriptionType + public function attachSubscription(AttachSubscriptionToContactRequest $request, ?array $options = null): ?SubscriptionType { $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()}/subscriptions", + path: "contacts/" . RawClient::encodePathParam($request->getContactId()) . "/subscriptions", method: HttpMethod::POST, body: $request, ), @@ -277,20 +302,13 @@ public function attachSubscription(AttachSubscriptionToContactRequest $request, $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return SubscriptionType::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); } @@ -304,6 +322,16 @@ public function attachSubscription(AttachSubscriptionToContactRequest $request, /** * You can remove a specific subscription from a contact. This will return a subscription type model for the subscription type that was removed from the contact. * + * Example: + * ```php + * $client->contacts->detachSubscription( + * new DetachSubscriptionFromContactRequest([ + * 'contactId' => '63a07ddf05a32042dffac965', + * 'subscriptionId' => '37846', + * ]), + * ); + * ``` + * * @param DetachSubscriptionFromContactRequest $request * @param ?array{ * baseUrl?: string, @@ -313,18 +341,18 @@ public function attachSubscription(AttachSubscriptionToContactRequest $request, * queryParameters?: array, * bodyProperties?: array, * } $options - * @return SubscriptionType + * @return ?SubscriptionType * @throws IntercomException * @throws IntercomApiException */ - public function detachSubscription(DetachSubscriptionFromContactRequest $request, ?array $options = null): SubscriptionType + public function detachSubscription(DetachSubscriptionFromContactRequest $request, ?array $options = null): ?SubscriptionType { $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()}/subscriptions/{$request->getSubscriptionId()}", + path: "contacts/" . RawClient::encodePathParam($request->getContactId()) . "/subscriptions/" . RawClient::encodePathParam($request->getSubscriptionId()), method: HttpMethod::DELETE, ), $options, @@ -332,20 +360,13 @@ public function detachSubscription(DetachSubscriptionFromContactRequest $request $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return SubscriptionType::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); } @@ -359,6 +380,15 @@ public function detachSubscription(DetachSubscriptionFromContactRequest $request /** * You can fetch a list of all tags that are attached to a specific contact. * + * Example: + * ```php + * $client->contacts->listAttachedTags( + * new ListTagsAttachedToContactRequest([ + * 'contactId' => '63a07ddf05a32042dffac965', + * ]), + * ); + * ``` + * * @param ListTagsAttachedToContactRequest $request * @param ?array{ * baseUrl?: string, @@ -368,18 +398,18 @@ public function detachSubscription(DetachSubscriptionFromContactRequest $request * queryParameters?: array, * bodyProperties?: array, * } $options - * @return TagList + * @return ?TagList * @throws IntercomException * @throws IntercomApiException */ - public function listAttachedTags(ListTagsAttachedToContactRequest $request, ?array $options = null): TagList + public function listAttachedTags(ListTagsAttachedToContactRequest $request, ?array $options = null): ?TagList { $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()}/tags", + path: "contacts/" . RawClient::encodePathParam($request->getContactId()) . "/tags", method: HttpMethod::GET, ), $options, @@ -387,20 +417,13 @@ public function listAttachedTags(ListTagsAttachedToContactRequest $request, ?arr $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return TagList::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); } @@ -414,6 +437,15 @@ public function listAttachedTags(ListTagsAttachedToContactRequest $request, ?arr /** * You can fetch the details of a single contact. * + * Example: + * ```php + * $client->contacts->find( + * new FindContactRequest([ + * 'contactId' => '63a07ddf05a32042dffac965', + * ]), + * ); + * ``` + * * @param FindContactRequest $request * @param ?array{ * baseUrl?: string, @@ -423,18 +455,18 @@ public function listAttachedTags(ListTagsAttachedToContactRequest $request, ?arr * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContactsFindResponse + * @return ?ContactsFindResponse * @throws IntercomException * @throws IntercomApiException */ - public function find(FindContactRequest $request, ?array $options = null): ContactsFindResponse + public function find(FindContactRequest $request, ?array $options = null): ?ContactsFindResponse { $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()}", + path: "contacts/" . RawClient::encodePathParam($request->getContactId()), method: HttpMethod::GET, ), $options, @@ -442,20 +474,13 @@ public function find(FindContactRequest $request, ?array $options = null): Conta $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ContactsFindResponse::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); } @@ -475,6 +500,17 @@ public function find(FindContactRequest $request, ?array $options = null): Conta * 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 %} * + * Example: + * ```php + * $client->contacts->update( + * new UpdateContactRequest([ + * 'contactId' => '63a07ddf05a32042dffac965', + * 'email' => 'joebloggs@intercom.io', + * 'name' => 'joe bloggs', + * ]), + * ); + * ``` + * * @param UpdateContactRequest $request * @param ?array{ * baseUrl?: string, @@ -484,18 +520,18 @@ public function find(FindContactRequest $request, ?array $options = null): Conta * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContactsUpdateResponse + * @return ?ContactsUpdateResponse * @throws IntercomException * @throws IntercomApiException */ - public function update(UpdateContactRequest $request, ?array $options = null): ContactsUpdateResponse + public function update(UpdateContactRequest $request, ?array $options = null): ?ContactsUpdateResponse { $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()}", + path: "contacts/" . RawClient::encodePathParam($request->getContactId()), method: HttpMethod::PUT, body: $request, ), @@ -504,20 +540,13 @@ public function update(UpdateContactRequest $request, ?array $options = null): C $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ContactsUpdateResponse::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); } @@ -531,6 +560,15 @@ public function update(UpdateContactRequest $request, ?array $options = null): C /** * You can delete a single contact. * + * Example: + * ```php + * $client->contacts->delete( + * new DeleteContactRequest([ + * 'contactId' => 'contact_id', + * ]), + * ); + * ``` + * * @param DeleteContactRequest $request * @param ?array{ * baseUrl?: string, @@ -540,18 +578,18 @@ public function update(UpdateContactRequest $request, ?array $options = null): C * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContactDeleted + * @return ?ContactDeleted * @throws IntercomException * @throws IntercomApiException */ - public function delete(DeleteContactRequest $request, ?array $options = null): ContactDeleted + public function delete(DeleteContactRequest $request, ?array $options = null): ?ContactDeleted { $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()}", + path: "contacts/" . RawClient::encodePathParam($request->getContactId()), method: HttpMethod::DELETE, ), $options, @@ -559,20 +597,13 @@ public function delete(DeleteContactRequest $request, ?array $options = null): C $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ContactDeleted::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); } @@ -586,6 +617,16 @@ public function delete(DeleteContactRequest $request, ?array $options = null): C /** * You can merge a contact with a `role` of `lead` into a contact with a `role` of `user`. * + * Example: + * ```php + * $client->contacts->mergeLeadInUser( + * new MergeContactsRequest([ + * 'leadId' => '6762f0d51bb69f9f2193bb7f', + * 'contactId' => '6762f0d51bb69f9f2193bb80', + * ]), + * ); + * ``` + * * @param MergeContactsRequest $request * @param ?array{ * baseUrl?: string, @@ -595,11 +636,11 @@ public function delete(DeleteContactRequest $request, ?array $options = null): C * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContactsMergeLeadInUserResponse + * @return ?ContactsMergeLeadInUserResponse * @throws IntercomException * @throws IntercomApiException */ - public function mergeLeadInUser(MergeContactsRequest $request = new MergeContactsRequest(), ?array $options = null): ContactsMergeLeadInUserResponse + public function mergeLeadInUser(MergeContactsRequest $request = new MergeContactsRequest(), ?array $options = null): ?ContactsMergeLeadInUserResponse { $options = array_merge($this->options, $options ?? []); try { @@ -615,20 +656,13 @@ public function mergeLeadInUser(MergeContactsRequest $request = new MergeContact $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ContactsMergeLeadInUserResponse::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); } @@ -740,6 +774,20 @@ public function mergeLeadInUser(MergeContactsRequest $request = new MergeContact * | ^ | String | Starts With | * | $ | String | Ends With | * + * Example: + * ```php + * $client->unstable->contacts->searchContacts( + * new SearchRequest([ + * 'query' => new SingleFilterSearchRequest([ + * 'value' => [], + * ]), + * 'pagination' => new StartingAfterPaging([ + * 'perPage' => 5, + * ]), + * ]), + * ); + * ``` + * * @param SearchRequest $request * @param ?array{ * baseUrl?: string, @@ -760,9 +808,9 @@ public function search(SearchRequest $request, ?array $options = null): Pager PaginationHelper::setDeep($request, ["pagination", "startingAfter"], $cursor); }, /* @phpstan-ignore-next-line */ - getNextCursor: fn (ContactList $response) => $response?->getPages()?->getNext()?->getStartingAfter() ?? null, + getNextCursor: fn (?ContactList $response) => $response?->getPages()?->getNext()?->getStartingAfter() ?? null, /* @phpstan-ignore-next-line */ - getItems: fn (ContactList $response) => $response?->getData() ?? [], + getItems: fn (?ContactList $response) => $response?->getData() ?? [], ); } @@ -773,6 +821,17 @@ public function search(SearchRequest $request, ?array $options = null): Pager * See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. * {% /admonition %} * + * Example: + * ```php + * $client->contacts->list( + * new ListContactsRequest([ + * 'page' => 1, + * 'perPage' => 1, + * 'startingAfter' => 'starting_after', + * ]), + * ); + * ``` + * * @param ListContactsRequest $request * @param ?array{ * baseUrl?: string, @@ -793,15 +852,24 @@ public function list(ListContactsRequest $request = new ListContactsRequest(), ? $request->setStartingAfter($cursor); }, /* @phpstan-ignore-next-line */ - getNextCursor: fn (ContactList $response) => $response?->getPages()?->getNext()?->getStartingAfter() ?? null, + getNextCursor: fn (?ContactList $response) => $response?->getPages()?->getNext()?->getStartingAfter() ?? null, /* @phpstan-ignore-next-line */ - getItems: fn (ContactList $response) => $response?->getData() ?? [], + getItems: fn (?ContactList $response) => $response?->getData() ?? [], ); } /** * You can create a new contact (ie. user or lead). * + * Example: + * ```php + * $client->contacts->create( + * new CreateContactRequestWithEmail([ + * 'email' => 'joebloggs@intercom.io', + * ]), + * ); + * ``` + * * @param ( * CreateContactRequestWithEmail * |CreateContactRequestWithExternalId @@ -815,11 +883,11 @@ public function list(ListContactsRequest $request = new ListContactsRequest(), ? * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContactsCreateResponse + * @return ?ContactsCreateResponse * @throws IntercomException * @throws IntercomApiException */ - public function create(CreateContactRequestWithEmail|CreateContactRequestWithExternalId|CreateContactRequestWithRole $request, ?array $options = null): ContactsCreateResponse + public function create(CreateContactRequestWithEmail|CreateContactRequestWithExternalId|CreateContactRequestWithRole $request, ?array $options = null): ?ContactsCreateResponse { $options = array_merge($this->options, $options ?? []); try { @@ -835,20 +903,13 @@ public function create(CreateContactRequestWithEmail|CreateContactRequestWithExt $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -862,6 +923,15 @@ public function create(CreateContactRequestWithEmail|CreateContactRequestWithExt /** * You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. * + * Example: + * ```php + * $client->contacts->showContactByExternalId( + * new ShowContactByExternalIdRequest([ + * 'externalId' => 'cdd29344-5e0c-4ef0-ac56-f9ba2979bc27', + * ]), + * ); + * ``` + * * @param ShowContactByExternalIdRequest $request * @param ?array{ * baseUrl?: string, @@ -871,18 +941,18 @@ public function create(CreateContactRequestWithEmail|CreateContactRequestWithExt * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ShowContactByExternalIdResponse + * @return ?ShowContactByExternalIdResponse * @throws IntercomException * @throws IntercomApiException */ - public function showContactByExternalId(ShowContactByExternalIdRequest $request, ?array $options = null): ShowContactByExternalIdResponse + 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()}", + path: "contacts/find_by_external_id/" . RawClient::encodePathParam($request->getExternalId()), method: HttpMethod::GET, ), $options, @@ -890,20 +960,13 @@ public function showContactByExternalId(ShowContactByExternalIdRequest $request, $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ShowContactByExternalIdResponse::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); } @@ -917,6 +980,15 @@ public function showContactByExternalId(ShowContactByExternalIdRequest $request, /** * You can archive a single contact. * + * Example: + * ```php + * $client->contacts->archive( + * new ArchiveContactRequest([ + * 'contactId' => '63a07ddf05a32042dffac965', + * ]), + * ); + * ``` + * * @param ArchiveContactRequest $request * @param ?array{ * baseUrl?: string, @@ -926,18 +998,18 @@ public function showContactByExternalId(ShowContactByExternalIdRequest $request, * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContactArchived + * @return ?ContactArchived * @throws IntercomException * @throws IntercomApiException */ - public function archive(ArchiveContactRequest $request, ?array $options = null): ContactArchived + public function archive(ArchiveContactRequest $request, ?array $options = null): ?ContactArchived { $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()}/archive", + path: "contacts/" . RawClient::encodePathParam($request->getContactId()) . "/archive", method: HttpMethod::POST, ), $options, @@ -945,20 +1017,13 @@ public function archive(ArchiveContactRequest $request, ?array $options = null): $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ContactArchived::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); } @@ -972,6 +1037,15 @@ public function archive(ArchiveContactRequest $request, ?array $options = null): /** * You can unarchive a single contact. * + * Example: + * ```php + * $client->contacts->unarchive( + * new UnarchiveContactRequest([ + * 'contactId' => '63a07ddf05a32042dffac965', + * ]), + * ); + * ``` + * * @param UnarchiveContactRequest $request * @param ?array{ * baseUrl?: string, @@ -981,18 +1055,18 @@ public function archive(ArchiveContactRequest $request, ?array $options = null): * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContactUnarchived + * @return ?ContactUnarchived * @throws IntercomException * @throws IntercomApiException */ - public function unarchive(UnarchiveContactRequest $request, ?array $options = null): ContactUnarchived + public function unarchive(UnarchiveContactRequest $request, ?array $options = null): ?ContactUnarchived { $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()}/unarchive", + path: "contacts/" . RawClient::encodePathParam($request->getContactId()) . "/unarchive", method: HttpMethod::POST, ), $options, @@ -1000,20 +1074,13 @@ public function unarchive(UnarchiveContactRequest $request, ?array $options = nu $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ContactUnarchived::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); } @@ -1027,6 +1094,15 @@ 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) * + * Example: + * ```php + * $client->contacts->blockContact( + * new BlockContactRequest([ + * 'contactId' => '63a07ddf05a32042dffac965', + * ]), + * ); + * ``` + * * @param BlockContactRequest $request * @param ?array{ * baseUrl?: string, @@ -1036,18 +1112,18 @@ public function unarchive(UnarchiveContactRequest $request, ?array $options = nu * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContactBlocked + * @return ?ContactBlocked * @throws IntercomException * @throws IntercomApiException */ - public function blockContact(BlockContactRequest $request, ?array $options = null): ContactBlocked + 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", + path: "contacts/" . RawClient::encodePathParam($request->getContactId()) . "/block", method: HttpMethod::POST, ), $options, @@ -1055,20 +1131,13 @@ public function blockContact(BlockContactRequest $request, ?array $options = nul $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -1091,11 +1160,11 @@ public function blockContact(BlockContactRequest $request, ?array $options = nul * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContactAttachedCompanies + * @return ?ContactAttachedCompanies * @throws IntercomException * @throws IntercomApiException */ - private function _listAttachedCompanies(ListAttachedCompaniesRequest $request, ?array $options = null): ContactAttachedCompanies + private function _listAttachedCompanies(ListAttachedCompaniesRequest $request, ?array $options = null): ?ContactAttachedCompanies { $options = array_merge($this->options, $options ?? []); $query = []; @@ -1109,7 +1178,7 @@ private function _listAttachedCompanies(ListAttachedCompaniesRequest $request, ? $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "contacts/{$request->getContactId()}/companies", + path: "contacts/" . RawClient::encodePathParam($request->getContactId()) . "/companies", method: HttpMethod::GET, query: $query, ), @@ -1118,20 +1187,13 @@ private function _listAttachedCompanies(ListAttachedCompaniesRequest $request, ? $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ContactAttachedCompanies::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); } @@ -1252,11 +1314,11 @@ private function _listAttachedCompanies(ListAttachedCompaniesRequest $request, ? * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContactList + * @return ?ContactList * @throws IntercomException * @throws IntercomApiException */ - private function _search(SearchRequest $request, ?array $options = null): ContactList + private function _search(SearchRequest $request, ?array $options = null): ?ContactList { $options = array_merge($this->options, $options ?? []); try { @@ -1272,20 +1334,13 @@ private function _search(SearchRequest $request, ?array $options = null): Contac $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ContactList::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); } @@ -1312,11 +1367,11 @@ private function _search(SearchRequest $request, ?array $options = null): Contac * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContactList + * @return ?ContactList * @throws IntercomException * @throws IntercomApiException */ - private function _list(ListContactsRequest $request = new ListContactsRequest(), ?array $options = null): ContactList + private function _list(ListContactsRequest $request = new ListContactsRequest(), ?array $options = null): ?ContactList { $options = array_merge($this->options, $options ?? []); $query = []; @@ -1342,20 +1397,13 @@ private function _list(ListContactsRequest $request = new ListContactsRequest(), $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ContactList::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); } diff --git a/src/Contacts/Requests/ArchiveContactRequest.php b/src/Contacts/Requests/ArchiveContactRequest.php index 33e0383f..c7e8549e 100644 --- a/src/Contacts/Requests/ArchiveContactRequest.php +++ b/src/Contacts/Requests/ArchiveContactRequest.php @@ -36,6 +36,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } } diff --git a/src/Contacts/Requests/AttachSubscriptionToContactRequest.php b/src/Contacts/Requests/AttachSubscriptionToContactRequest.php index 0198cca9..cb01913f 100644 --- a/src/Contacts/Requests/AttachSubscriptionToContactRequest.php +++ b/src/Contacts/Requests/AttachSubscriptionToContactRequest.php @@ -53,6 +53,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } @@ -70,6 +71,7 @@ public function getSubscriptionId(): string public function setSubscriptionId(string $value): self { $this->subscriptionId = $value; + $this->_setField('subscriptionId'); return $this; } @@ -87,6 +89,7 @@ public function getConsentType(): string public function setConsentType(string $value): self { $this->consentType = $value; + $this->_setField('consentType'); return $this; } } diff --git a/src/Contacts/Requests/BlockContactRequest.php b/src/Contacts/Requests/BlockContactRequest.php index 97efed0d..1fb2713b 100644 --- a/src/Contacts/Requests/BlockContactRequest.php +++ b/src/Contacts/Requests/BlockContactRequest.php @@ -36,6 +36,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } } diff --git a/src/Contacts/Requests/DeleteContactRequest.php b/src/Contacts/Requests/DeleteContactRequest.php index bd7f7ada..9299bc25 100644 --- a/src/Contacts/Requests/DeleteContactRequest.php +++ b/src/Contacts/Requests/DeleteContactRequest.php @@ -36,6 +36,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } } diff --git a/src/Contacts/Requests/DetachSubscriptionFromContactRequest.php b/src/Contacts/Requests/DetachSubscriptionFromContactRequest.php index 7eff9b9a..61d21677 100644 --- a/src/Contacts/Requests/DetachSubscriptionFromContactRequest.php +++ b/src/Contacts/Requests/DetachSubscriptionFromContactRequest.php @@ -43,6 +43,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } @@ -60,6 +61,7 @@ public function getSubscriptionId(): string public function setSubscriptionId(string $value): self { $this->subscriptionId = $value; + $this->_setField('subscriptionId'); return $this; } } diff --git a/src/Contacts/Requests/FindContactRequest.php b/src/Contacts/Requests/FindContactRequest.php index 59294ed0..e6cc6af5 100644 --- a/src/Contacts/Requests/FindContactRequest.php +++ b/src/Contacts/Requests/FindContactRequest.php @@ -36,6 +36,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } } diff --git a/src/Contacts/Requests/ListAttachedCompaniesRequest.php b/src/Contacts/Requests/ListAttachedCompaniesRequest.php index 2be08c95..a52d36cb 100644 --- a/src/Contacts/Requests/ListAttachedCompaniesRequest.php +++ b/src/Contacts/Requests/ListAttachedCompaniesRequest.php @@ -50,6 +50,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } @@ -67,6 +68,7 @@ public function getPage(): ?int public function setPage(?int $value = null): self { $this->page = $value; + $this->_setField('page'); return $this; } @@ -84,6 +86,7 @@ public function getPerPage(): ?int public function setPerPage(?int $value = null): self { $this->perPage = $value; + $this->_setField('perPage'); return $this; } } diff --git a/src/Contacts/Requests/ListAttachedSubscriptionsRequest.php b/src/Contacts/Requests/ListAttachedSubscriptionsRequest.php index fff1e4e8..2e9868a2 100644 --- a/src/Contacts/Requests/ListAttachedSubscriptionsRequest.php +++ b/src/Contacts/Requests/ListAttachedSubscriptionsRequest.php @@ -36,6 +36,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } } diff --git a/src/Contacts/Requests/ListContactsRequest.php b/src/Contacts/Requests/ListContactsRequest.php index 121eb476..fcaffd06 100644 --- a/src/Contacts/Requests/ListContactsRequest.php +++ b/src/Contacts/Requests/ListContactsRequest.php @@ -50,6 +50,7 @@ public function getPage(): ?int public function setPage(?int $value = null): self { $this->page = $value; + $this->_setField('page'); return $this; } @@ -67,6 +68,7 @@ public function getPerPage(): ?int public function setPerPage(?int $value = null): self { $this->perPage = $value; + $this->_setField('perPage'); return $this; } @@ -84,6 +86,7 @@ public function getStartingAfter(): ?string public function setStartingAfter(?string $value = null): self { $this->startingAfter = $value; + $this->_setField('startingAfter'); return $this; } } diff --git a/src/Contacts/Requests/ListSegmentsAttachedToContactRequest.php b/src/Contacts/Requests/ListSegmentsAttachedToContactRequest.php index 436a987f..fe7c62f5 100644 --- a/src/Contacts/Requests/ListSegmentsAttachedToContactRequest.php +++ b/src/Contacts/Requests/ListSegmentsAttachedToContactRequest.php @@ -36,6 +36,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } } diff --git a/src/Contacts/Requests/ListTagsAttachedToContactRequest.php b/src/Contacts/Requests/ListTagsAttachedToContactRequest.php index a2238e32..bf00c0ff 100644 --- a/src/Contacts/Requests/ListTagsAttachedToContactRequest.php +++ b/src/Contacts/Requests/ListTagsAttachedToContactRequest.php @@ -36,6 +36,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } } diff --git a/src/Contacts/Requests/MergeContactsRequest.php b/src/Contacts/Requests/MergeContactsRequest.php index 785c3f94..b02c58ae 100644 --- a/src/Contacts/Requests/MergeContactsRequest.php +++ b/src/Contacts/Requests/MergeContactsRequest.php @@ -46,6 +46,7 @@ public function getLeadId(): ?string public function setLeadId(?string $value = null): self { $this->leadId = $value; + $this->_setField('leadId'); return $this; } @@ -63,6 +64,7 @@ public function getContactId(): ?string public function setContactId(?string $value = null): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } } diff --git a/src/Contacts/Requests/ShowContactByExternalIdRequest.php b/src/Contacts/Requests/ShowContactByExternalIdRequest.php index 4a367e7e..d28d956a 100644 --- a/src/Contacts/Requests/ShowContactByExternalIdRequest.php +++ b/src/Contacts/Requests/ShowContactByExternalIdRequest.php @@ -36,6 +36,7 @@ public function getExternalId(): string public function setExternalId(string $value): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } } diff --git a/src/Contacts/Requests/UnarchiveContactRequest.php b/src/Contacts/Requests/UnarchiveContactRequest.php index aaf4f5eb..56336b06 100644 --- a/src/Contacts/Requests/UnarchiveContactRequest.php +++ b/src/Contacts/Requests/UnarchiveContactRequest.php @@ -36,6 +36,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } } diff --git a/src/Contacts/Requests/UpdateContactRequest.php b/src/Contacts/Requests/UpdateContactRequest.php index 2f6dc656..a55fbdf8 100644 --- a/src/Contacts/Requests/UpdateContactRequest.php +++ b/src/Contacts/Requests/UpdateContactRequest.php @@ -126,6 +126,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } @@ -143,6 +144,7 @@ public function getRole(): ?string public function setRole(?string $value = null): self { $this->role = $value; + $this->_setField('role'); return $this; } @@ -160,6 +162,7 @@ public function getExternalId(): ?string public function setExternalId(?string $value = null): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } @@ -177,6 +180,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -194,6 +198,7 @@ public function getPhone(): ?string public function setPhone(?string $value = null): self { $this->phone = $value; + $this->_setField('phone'); return $this; } @@ -211,6 +216,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -228,6 +234,7 @@ public function getAvatar(): ?string public function setAvatar(?string $value = null): self { $this->avatar = $value; + $this->_setField('avatar'); return $this; } @@ -245,6 +252,7 @@ public function getSignedUpAt(): ?int public function setSignedUpAt(?int $value = null): self { $this->signedUpAt = $value; + $this->_setField('signedUpAt'); return $this; } @@ -262,6 +270,7 @@ public function getLastSeenAt(): ?int public function setLastSeenAt(?int $value = null): self { $this->lastSeenAt = $value; + $this->_setField('lastSeenAt'); return $this; } @@ -279,6 +288,7 @@ public function getOwnerId(): ?int public function setOwnerId(?int $value = null): self { $this->ownerId = $value; + $this->_setField('ownerId'); return $this; } @@ -296,6 +306,7 @@ public function getUnsubscribedFromEmails(): ?bool public function setUnsubscribedFromEmails(?bool $value = null): self { $this->unsubscribedFromEmails = $value; + $this->_setField('unsubscribedFromEmails'); return $this; } @@ -313,6 +324,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } } diff --git a/src/Contacts/Traits/Contact.php b/src/Contacts/Traits/Contact.php index 068664e6..8f98aedc 100644 --- a/src/Contacts/Traits/Contact.php +++ b/src/Contacts/Traits/Contact.php @@ -345,6 +345,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -362,6 +363,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -379,6 +381,7 @@ public function getExternalId(): ?string public function setExternalId(?string $value = null): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } @@ -396,6 +399,7 @@ public function getWorkspaceId(): ?string public function setWorkspaceId(?string $value = null): self { $this->workspaceId = $value; + $this->_setField('workspaceId'); return $this; } @@ -413,6 +417,7 @@ public function getRole(): ?string public function setRole(?string $value = null): self { $this->role = $value; + $this->_setField('role'); return $this; } @@ -430,6 +435,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -447,6 +453,7 @@ public function getEmailDomain(): ?string public function setEmailDomain(?string $value = null): self { $this->emailDomain = $value; + $this->_setField('emailDomain'); return $this; } @@ -464,6 +471,7 @@ public function getPhone(): ?string public function setPhone(?string $value = null): self { $this->phone = $value; + $this->_setField('phone'); return $this; } @@ -481,6 +489,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -498,6 +507,7 @@ public function getOwnerId(): ?int public function setOwnerId(?int $value = null): self { $this->ownerId = $value; + $this->_setField('ownerId'); return $this; } @@ -515,6 +525,7 @@ public function getHasHardBounced(): ?bool public function setHasHardBounced(?bool $value = null): self { $this->hasHardBounced = $value; + $this->_setField('hasHardBounced'); return $this; } @@ -532,6 +543,7 @@ public function getMarkedEmailAsSpam(): ?bool public function setMarkedEmailAsSpam(?bool $value = null): self { $this->markedEmailAsSpam = $value; + $this->_setField('markedEmailAsSpam'); return $this; } @@ -549,6 +561,7 @@ public function getUnsubscribedFromEmails(): ?bool public function setUnsubscribedFromEmails(?bool $value = null): self { $this->unsubscribedFromEmails = $value; + $this->_setField('unsubscribedFromEmails'); return $this; } @@ -566,6 +579,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -583,6 +597,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -600,6 +615,7 @@ public function getSignedUpAt(): ?int public function setSignedUpAt(?int $value = null): self { $this->signedUpAt = $value; + $this->_setField('signedUpAt'); return $this; } @@ -617,6 +633,7 @@ public function getLastSeenAt(): ?int public function setLastSeenAt(?int $value = null): self { $this->lastSeenAt = $value; + $this->_setField('lastSeenAt'); return $this; } @@ -634,6 +651,7 @@ public function getLastRepliedAt(): ?int public function setLastRepliedAt(?int $value = null): self { $this->lastRepliedAt = $value; + $this->_setField('lastRepliedAt'); return $this; } @@ -651,6 +669,7 @@ public function getLastContactedAt(): ?int public function setLastContactedAt(?int $value = null): self { $this->lastContactedAt = $value; + $this->_setField('lastContactedAt'); return $this; } @@ -668,6 +687,7 @@ public function getLastEmailOpenedAt(): ?int public function setLastEmailOpenedAt(?int $value = null): self { $this->lastEmailOpenedAt = $value; + $this->_setField('lastEmailOpenedAt'); return $this; } @@ -685,6 +705,7 @@ public function getLastEmailClickedAt(): ?int public function setLastEmailClickedAt(?int $value = null): self { $this->lastEmailClickedAt = $value; + $this->_setField('lastEmailClickedAt'); return $this; } @@ -702,6 +723,7 @@ public function getLanguageOverride(): ?string public function setLanguageOverride(?string $value = null): self { $this->languageOverride = $value; + $this->_setField('languageOverride'); return $this; } @@ -719,6 +741,7 @@ public function getBrowser(): ?string public function setBrowser(?string $value = null): self { $this->browser = $value; + $this->_setField('browser'); return $this; } @@ -736,6 +759,7 @@ public function getBrowserVersion(): ?string public function setBrowserVersion(?string $value = null): self { $this->browserVersion = $value; + $this->_setField('browserVersion'); return $this; } @@ -753,6 +777,7 @@ public function getBrowserLanguage(): ?string public function setBrowserLanguage(?string $value = null): self { $this->browserLanguage = $value; + $this->_setField('browserLanguage'); return $this; } @@ -770,6 +795,7 @@ public function getOs(): ?string public function setOs(?string $value = null): self { $this->os = $value; + $this->_setField('os'); return $this; } @@ -787,6 +813,7 @@ public function getAndroidAppName(): ?string public function setAndroidAppName(?string $value = null): self { $this->androidAppName = $value; + $this->_setField('androidAppName'); return $this; } @@ -804,6 +831,7 @@ public function getAndroidAppVersion(): ?string public function setAndroidAppVersion(?string $value = null): self { $this->androidAppVersion = $value; + $this->_setField('androidAppVersion'); return $this; } @@ -821,6 +849,7 @@ public function getAndroidDevice(): ?string public function setAndroidDevice(?string $value = null): self { $this->androidDevice = $value; + $this->_setField('androidDevice'); return $this; } @@ -838,6 +867,7 @@ public function getAndroidOsVersion(): ?string public function setAndroidOsVersion(?string $value = null): self { $this->androidOsVersion = $value; + $this->_setField('androidOsVersion'); return $this; } @@ -855,6 +885,7 @@ public function getAndroidSdkVersion(): ?string public function setAndroidSdkVersion(?string $value = null): self { $this->androidSdkVersion = $value; + $this->_setField('androidSdkVersion'); return $this; } @@ -872,6 +903,7 @@ public function getAndroidLastSeenAt(): ?int public function setAndroidLastSeenAt(?int $value = null): self { $this->androidLastSeenAt = $value; + $this->_setField('androidLastSeenAt'); return $this; } @@ -889,6 +921,7 @@ public function getIosAppName(): ?string public function setIosAppName(?string $value = null): self { $this->iosAppName = $value; + $this->_setField('iosAppName'); return $this; } @@ -906,6 +939,7 @@ public function getIosAppVersion(): ?string public function setIosAppVersion(?string $value = null): self { $this->iosAppVersion = $value; + $this->_setField('iosAppVersion'); return $this; } @@ -923,6 +957,7 @@ public function getIosDevice(): ?string public function setIosDevice(?string $value = null): self { $this->iosDevice = $value; + $this->_setField('iosDevice'); return $this; } @@ -940,6 +975,7 @@ public function getIosOsVersion(): ?string public function setIosOsVersion(?string $value = null): self { $this->iosOsVersion = $value; + $this->_setField('iosOsVersion'); return $this; } @@ -957,6 +993,7 @@ public function getIosSdkVersion(): ?string public function setIosSdkVersion(?string $value = null): self { $this->iosSdkVersion = $value; + $this->_setField('iosSdkVersion'); return $this; } @@ -974,6 +1011,7 @@ public function getIosLastSeenAt(): ?int public function setIosLastSeenAt(?int $value = null): self { $this->iosLastSeenAt = $value; + $this->_setField('iosLastSeenAt'); return $this; } @@ -991,6 +1029,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } @@ -1008,6 +1047,7 @@ public function getAvatar(): ?string public function setAvatar(?string $value = null): self { $this->avatar = $value; + $this->_setField('avatar'); return $this; } @@ -1025,6 +1065,7 @@ public function getTags(): ?ContactTags public function setTags(?ContactTags $value = null): self { $this->tags = $value; + $this->_setField('tags'); return $this; } @@ -1042,6 +1083,7 @@ public function getNotes(): ?ContactNotes public function setNotes(?ContactNotes $value = null): self { $this->notes = $value; + $this->_setField('notes'); return $this; } @@ -1059,6 +1101,7 @@ public function getCompanies(): ?ContactCompanies public function setCompanies(?ContactCompanies $value = null): self { $this->companies = $value; + $this->_setField('companies'); return $this; } @@ -1076,6 +1119,7 @@ public function getLocation(): ?ContactLocation public function setLocation(?ContactLocation $value = null): self { $this->location = $value; + $this->_setField('location'); return $this; } @@ -1093,6 +1137,7 @@ public function getSocialProfiles(): ?ContactSocialProfiles public function setSocialProfiles(?ContactSocialProfiles $value = null): self { $this->socialProfiles = $value; + $this->_setField('socialProfiles'); return $this; } } diff --git a/src/Contacts/Types/Contact.php b/src/Contacts/Types/Contact.php index c16c44f3..548c19ae 100644 --- a/src/Contacts/Types/Contact.php +++ b/src/Contacts/Types/Contact.php @@ -399,6 +399,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -416,6 +417,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -433,6 +435,7 @@ public function getExternalId(): ?string public function setExternalId(?string $value = null): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } @@ -450,6 +453,7 @@ public function getWorkspaceId(): ?string public function setWorkspaceId(?string $value = null): self { $this->workspaceId = $value; + $this->_setField('workspaceId'); return $this; } @@ -467,6 +471,7 @@ public function getRole(): ?string public function setRole(?string $value = null): self { $this->role = $value; + $this->_setField('role'); return $this; } @@ -484,6 +489,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -501,6 +507,7 @@ public function getEmailDomain(): ?string public function setEmailDomain(?string $value = null): self { $this->emailDomain = $value; + $this->_setField('emailDomain'); return $this; } @@ -518,6 +525,7 @@ public function getPhone(): ?string public function setPhone(?string $value = null): self { $this->phone = $value; + $this->_setField('phone'); return $this; } @@ -535,6 +543,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -552,6 +561,7 @@ public function getOwnerId(): ?int public function setOwnerId(?int $value = null): self { $this->ownerId = $value; + $this->_setField('ownerId'); return $this; } @@ -569,6 +579,7 @@ public function getHasHardBounced(): ?bool public function setHasHardBounced(?bool $value = null): self { $this->hasHardBounced = $value; + $this->_setField('hasHardBounced'); return $this; } @@ -586,6 +597,7 @@ public function getMarkedEmailAsSpam(): ?bool public function setMarkedEmailAsSpam(?bool $value = null): self { $this->markedEmailAsSpam = $value; + $this->_setField('markedEmailAsSpam'); return $this; } @@ -603,6 +615,7 @@ public function getUnsubscribedFromEmails(): ?bool public function setUnsubscribedFromEmails(?bool $value = null): self { $this->unsubscribedFromEmails = $value; + $this->_setField('unsubscribedFromEmails'); return $this; } @@ -620,6 +633,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -637,6 +651,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -654,6 +669,7 @@ public function getSignedUpAt(): ?int public function setSignedUpAt(?int $value = null): self { $this->signedUpAt = $value; + $this->_setField('signedUpAt'); return $this; } @@ -671,6 +687,7 @@ public function getLastSeenAt(): ?int public function setLastSeenAt(?int $value = null): self { $this->lastSeenAt = $value; + $this->_setField('lastSeenAt'); return $this; } @@ -688,6 +705,7 @@ public function getLastRepliedAt(): ?int public function setLastRepliedAt(?int $value = null): self { $this->lastRepliedAt = $value; + $this->_setField('lastRepliedAt'); return $this; } @@ -705,6 +723,7 @@ public function getLastContactedAt(): ?int public function setLastContactedAt(?int $value = null): self { $this->lastContactedAt = $value; + $this->_setField('lastContactedAt'); return $this; } @@ -722,6 +741,7 @@ public function getLastEmailOpenedAt(): ?int public function setLastEmailOpenedAt(?int $value = null): self { $this->lastEmailOpenedAt = $value; + $this->_setField('lastEmailOpenedAt'); return $this; } @@ -739,6 +759,7 @@ public function getLastEmailClickedAt(): ?int public function setLastEmailClickedAt(?int $value = null): self { $this->lastEmailClickedAt = $value; + $this->_setField('lastEmailClickedAt'); return $this; } @@ -756,6 +777,7 @@ public function getLanguageOverride(): ?string public function setLanguageOverride(?string $value = null): self { $this->languageOverride = $value; + $this->_setField('languageOverride'); return $this; } @@ -773,6 +795,7 @@ public function getBrowser(): ?string public function setBrowser(?string $value = null): self { $this->browser = $value; + $this->_setField('browser'); return $this; } @@ -790,6 +813,7 @@ public function getBrowserVersion(): ?string public function setBrowserVersion(?string $value = null): self { $this->browserVersion = $value; + $this->_setField('browserVersion'); return $this; } @@ -807,6 +831,7 @@ public function getBrowserLanguage(): ?string public function setBrowserLanguage(?string $value = null): self { $this->browserLanguage = $value; + $this->_setField('browserLanguage'); return $this; } @@ -824,6 +849,7 @@ public function getOs(): ?string public function setOs(?string $value = null): self { $this->os = $value; + $this->_setField('os'); return $this; } @@ -841,6 +867,7 @@ public function getAndroidAppName(): ?string public function setAndroidAppName(?string $value = null): self { $this->androidAppName = $value; + $this->_setField('androidAppName'); return $this; } @@ -858,6 +885,7 @@ public function getAndroidAppVersion(): ?string public function setAndroidAppVersion(?string $value = null): self { $this->androidAppVersion = $value; + $this->_setField('androidAppVersion'); return $this; } @@ -875,6 +903,7 @@ public function getAndroidDevice(): ?string public function setAndroidDevice(?string $value = null): self { $this->androidDevice = $value; + $this->_setField('androidDevice'); return $this; } @@ -892,6 +921,7 @@ public function getAndroidOsVersion(): ?string public function setAndroidOsVersion(?string $value = null): self { $this->androidOsVersion = $value; + $this->_setField('androidOsVersion'); return $this; } @@ -909,6 +939,7 @@ public function getAndroidSdkVersion(): ?string public function setAndroidSdkVersion(?string $value = null): self { $this->androidSdkVersion = $value; + $this->_setField('androidSdkVersion'); return $this; } @@ -926,6 +957,7 @@ public function getAndroidLastSeenAt(): ?int public function setAndroidLastSeenAt(?int $value = null): self { $this->androidLastSeenAt = $value; + $this->_setField('androidLastSeenAt'); return $this; } @@ -943,6 +975,7 @@ public function getIosAppName(): ?string public function setIosAppName(?string $value = null): self { $this->iosAppName = $value; + $this->_setField('iosAppName'); return $this; } @@ -960,6 +993,7 @@ public function getIosAppVersion(): ?string public function setIosAppVersion(?string $value = null): self { $this->iosAppVersion = $value; + $this->_setField('iosAppVersion'); return $this; } @@ -977,6 +1011,7 @@ public function getIosDevice(): ?string public function setIosDevice(?string $value = null): self { $this->iosDevice = $value; + $this->_setField('iosDevice'); return $this; } @@ -994,6 +1029,7 @@ public function getIosOsVersion(): ?string public function setIosOsVersion(?string $value = null): self { $this->iosOsVersion = $value; + $this->_setField('iosOsVersion'); return $this; } @@ -1011,6 +1047,7 @@ public function getIosSdkVersion(): ?string public function setIosSdkVersion(?string $value = null): self { $this->iosSdkVersion = $value; + $this->_setField('iosSdkVersion'); return $this; } @@ -1028,6 +1065,7 @@ public function getIosLastSeenAt(): ?int public function setIosLastSeenAt(?int $value = null): self { $this->iosLastSeenAt = $value; + $this->_setField('iosLastSeenAt'); return $this; } @@ -1045,6 +1083,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } @@ -1062,6 +1101,7 @@ public function getAvatar(): ?string public function setAvatar(?string $value = null): self { $this->avatar = $value; + $this->_setField('avatar'); return $this; } @@ -1079,6 +1119,7 @@ public function getTags(): ?ContactTags public function setTags(?ContactTags $value = null): self { $this->tags = $value; + $this->_setField('tags'); return $this; } @@ -1096,6 +1137,7 @@ public function getNotes(): ?ContactNotes public function setNotes(?ContactNotes $value = null): self { $this->notes = $value; + $this->_setField('notes'); return $this; } @@ -1113,6 +1155,7 @@ public function getCompanies(): ?ContactCompanies public function setCompanies(?ContactCompanies $value = null): self { $this->companies = $value; + $this->_setField('companies'); return $this; } @@ -1130,6 +1173,7 @@ public function getLocation(): ?ContactLocation public function setLocation(?ContactLocation $value = null): self { $this->location = $value; + $this->_setField('location'); return $this; } @@ -1147,6 +1191,7 @@ public function getSocialProfiles(): ?ContactSocialProfiles public function setSocialProfiles(?ContactSocialProfiles $value = null): self { $this->socialProfiles = $value; + $this->_setField('socialProfiles'); return $this; } diff --git a/src/Contacts/Types/ContactsCreateResponse.php b/src/Contacts/Types/ContactsCreateResponse.php index c01ea0b4..9f05939e 100644 --- a/src/Contacts/Types/ContactsCreateResponse.php +++ b/src/Contacts/Types/ContactsCreateResponse.php @@ -136,6 +136,7 @@ public function getEnabledPushMessaging(): ?bool public function setEnabledPushMessaging(?bool $value = null): self { $this->enabledPushMessaging = $value; + $this->_setField('enabledPushMessaging'); return $this; } diff --git a/src/Contacts/Types/ContactsFindResponse.php b/src/Contacts/Types/ContactsFindResponse.php index c108e48e..2dc297b8 100644 --- a/src/Contacts/Types/ContactsFindResponse.php +++ b/src/Contacts/Types/ContactsFindResponse.php @@ -136,6 +136,7 @@ public function getEnabledPushMessaging(): ?bool public function setEnabledPushMessaging(?bool $value = null): self { $this->enabledPushMessaging = $value; + $this->_setField('enabledPushMessaging'); return $this; } diff --git a/src/Contacts/Types/ContactsMergeLeadInUserResponse.php b/src/Contacts/Types/ContactsMergeLeadInUserResponse.php index 5c689107..ad850af6 100644 --- a/src/Contacts/Types/ContactsMergeLeadInUserResponse.php +++ b/src/Contacts/Types/ContactsMergeLeadInUserResponse.php @@ -136,6 +136,7 @@ public function getEnabledPushMessaging(): ?bool public function setEnabledPushMessaging(?bool $value = null): self { $this->enabledPushMessaging = $value; + $this->_setField('enabledPushMessaging'); return $this; } diff --git a/src/Contacts/Types/ContactsUpdateResponse.php b/src/Contacts/Types/ContactsUpdateResponse.php index c4a2e146..aa708246 100644 --- a/src/Contacts/Types/ContactsUpdateResponse.php +++ b/src/Contacts/Types/ContactsUpdateResponse.php @@ -136,6 +136,7 @@ public function getEnabledPushMessaging(): ?bool public function setEnabledPushMessaging(?bool $value = null): self { $this->enabledPushMessaging = $value; + $this->_setField('enabledPushMessaging'); return $this; } diff --git a/src/Contacts/Types/ShowContactByExternalIdResponse.php b/src/Contacts/Types/ShowContactByExternalIdResponse.php index 14078506..8d95a8b4 100644 --- a/src/Contacts/Types/ShowContactByExternalIdResponse.php +++ b/src/Contacts/Types/ShowContactByExternalIdResponse.php @@ -136,6 +136,7 @@ public function getEnabledPushMessaging(): ?bool public function setEnabledPushMessaging(?bool $value = null): self { $this->enabledPushMessaging = $value; + $this->_setField('enabledPushMessaging'); return $this; } diff --git a/src/Conversations/ConversationsClient.php b/src/Conversations/ConversationsClient.php index f333ad12..29abbf3f 100644 --- a/src/Conversations/ConversationsClient.php +++ b/src/Conversations/ConversationsClient.php @@ -2,7 +2,7 @@ namespace Intercom\Conversations; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Conversations\Requests\ListConversationsRequest; use Intercom\Core\Pagination\Pager; @@ -17,7 +17,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Conversations\Requests\FindConversationRequest; use Intercom\Conversations\Requests\UpdateConversationRequest; @@ -79,6 +78,16 @@ public function __construct( * See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. * {% /admonition %} * + * Example: + * ```php + * $client->conversations->list( + * new ListConversationsRequest([ + * 'perPage' => 1, + * 'startingAfter' => 'starting_after', + * ]), + * ); + * ``` + * * @param ListConversationsRequest $request * @param ?array{ * baseUrl?: string, @@ -99,9 +108,9 @@ public function list(ListConversationsRequest $request = new ListConversationsRe $request->setStartingAfter($cursor); }, /* @phpstan-ignore-next-line */ - getNextCursor: fn (ConversationList $response) => $response?->getPages()?->getNext()?->getStartingAfter() ?? null, + getNextCursor: fn (?ConversationList $response) => $response?->getPages()?->getNext()?->getStartingAfter() ?? null, /* @phpstan-ignore-next-line */ - getItems: fn (ConversationList $response) => $response?->getConversations() ?? [], + getItems: fn (?ConversationList $response) => $response?->getConversations() ?? [], ); } @@ -117,6 +126,19 @@ public function list(ListConversationsRequest $request = new ListConversationsRe * This will return the Message model that has been created. * * + * Example: + * ```php + * $client->conversations->create( + * new CreateConversationRequest([ + * 'from' => new CreateConversationRequestFrom([ + * 'type' => CreateConversationRequestFromType::User->value, + * 'id' => '6762f11b1bb69f9f2193bba3', + * ]), + * 'body' => 'Hello there', + * ]), + * ); + * ``` + * * @param CreateConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -126,11 +148,11 @@ public function list(ListConversationsRequest $request = new ListConversationsRe * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Message + * @return ?Message * @throws IntercomException * @throws IntercomApiException */ - public function create(CreateConversationRequest $request, ?array $options = null): Message + public function create(CreateConversationRequest $request, ?array $options = null): ?Message { $options = array_merge($this->options, $options ?? []); try { @@ -146,20 +168,13 @@ public function create(CreateConversationRequest $request, ?array $options = nul $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Message::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); } @@ -182,6 +197,17 @@ public function create(CreateConversationRequest $request, ?array $options = nul * * For AI agent conversation metadata, please note that you need to have the agent enabled in your workspace, which is a [paid feature](https://www.intercom.com/help/en/articles/8205718-fin-resolutions#h_97f8c2e671). * + * Example: + * ```php + * $client->conversations->find( + * new FindConversationRequest([ + * 'conversationId' => '123', + * 'displayAs' => 'plaintext', + * 'includeTranslations' => true, + * ]), + * ); + * ``` + * * @param FindConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -191,11 +217,11 @@ public function create(CreateConversationRequest $request, ?array $options = nul * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Conversation + * @return ?Conversation * @throws IntercomException * @throws IntercomApiException */ - public function find(FindConversationRequest $request, ?array $options = null): Conversation + public function find(FindConversationRequest $request, ?array $options = null): ?Conversation { $options = array_merge($this->options, $options ?? []); $query = []; @@ -209,7 +235,7 @@ public function find(FindConversationRequest $request, ?array $options = null): $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "conversations/{$request->getConversationId()}", + path: "conversations/" . RawClient::encodePathParam($request->getConversationId()), method: HttpMethod::GET, query: $query, ), @@ -218,20 +244,13 @@ public function find(FindConversationRequest $request, ?array $options = null): $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Conversation::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); } @@ -257,6 +276,22 @@ public function find(FindConversationRequest $request, ?array $options = null): * {% /admonition %} * * + * Example: + * ```php + * $client->conversations->update( + * new UpdateConversationRequest([ + * 'conversationId' => 'conversation_id', + * 'displayAs' => 'plaintext', + * 'read' => true, + * 'title' => 'new conversation title', + * 'customAttributes' => [ + * 'issue_type' => 'Billing', + * 'priority' => 'High', + * ], + * ]), + * ); + * ``` + * * @param UpdateConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -266,11 +301,11 @@ public function find(FindConversationRequest $request, ?array $options = null): * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Conversation + * @return ?Conversation * @throws IntercomException * @throws IntercomApiException */ - public function update(UpdateConversationRequest $request, ?array $options = null): Conversation + public function update(UpdateConversationRequest $request, ?array $options = null): ?Conversation { $options = array_merge($this->options, $options ?? []); $query = []; @@ -281,7 +316,7 @@ public function update(UpdateConversationRequest $request, ?array $options = nul $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "conversations/{$request->getConversationId()}", + path: "conversations/" . RawClient::encodePathParam($request->getConversationId()), method: HttpMethod::PUT, query: $query, body: $request, @@ -291,20 +326,13 @@ public function update(UpdateConversationRequest $request, ?array $options = nul $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Conversation::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); } @@ -318,6 +346,15 @@ public function update(UpdateConversationRequest $request, ?array $options = nul /** * You can delete a single conversation. * + * Example: + * ```php + * $client->conversations->deleteConversation( + * new DeleteConversationRequest([ + * 'conversationId' => 1, + * ]), + * ); + * ``` + * * @param DeleteConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -327,18 +364,18 @@ public function update(UpdateConversationRequest $request, ?array $options = nul * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ConversationDeleted + * @return ?ConversationDeleted * @throws IntercomException * @throws IntercomApiException */ - public function deleteConversation(DeleteConversationRequest $request, ?array $options = null): ConversationDeleted + 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()}", + path: "conversations/" . RawClient::encodePathParam($request->getConversationId()), method: HttpMethod::DELETE, ), $options, @@ -346,20 +383,13 @@ public function deleteConversation(DeleteConversationRequest $request, ?array $o $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -471,6 +501,20 @@ public function deleteConversation(DeleteConversationRequest $request, ?array $o * | ^ | String | Starts With | * | $ | String | Ends With | * + * Example: + * ```php + * $client->unstable->conversations->searchConversations( + * new SearchRequest([ + * 'query' => new SingleFilterSearchRequest([ + * 'value' => [], + * ]), + * 'pagination' => new StartingAfterPaging([ + * 'perPage' => 5, + * ]), + * ]), + * ); + * ``` + * * @param SearchRequest $request * @param ?array{ * baseUrl?: string, @@ -491,15 +535,30 @@ public function search(SearchRequest $request, ?array $options = null): Pager PaginationHelper::setDeep($request, ["pagination", "startingAfter"], $cursor); }, /* @phpstan-ignore-next-line */ - getNextCursor: fn (ConversationList $response) => $response?->getPages()?->getNext()?->getStartingAfter() ?? null, + getNextCursor: fn (?ConversationList $response) => $response?->getPages()?->getNext()?->getStartingAfter() ?? null, /* @phpstan-ignore-next-line */ - getItems: fn (ConversationList $response) => $response?->getConversations() ?? [], + getItems: fn (?ConversationList $response) => $response?->getConversations() ?? [], ); } /** * You can reply to a conversation with a message from an admin or on behalf of a contact, or with a note for admins. * + * Example: + * ```php + * $client->conversations->reply( + * new ReplyToConversationRequest([ + * 'conversationId' => '123 or "last"', + * 'body' => new ContactReplyIntercomUserIdRequest([ + * 'messageType' => 'comment', + * 'type' => 'user', + * 'body' => 'Thanks again :)', + * 'intercomUserId' => '6762f1571bb69f9f2193bbbb', + * ]), + * ]), + * ); + * ``` + * * @param ReplyToConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -509,18 +568,18 @@ public function search(SearchRequest $request, ?array $options = null): Pager * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Conversation + * @return ?Conversation * @throws IntercomException * @throws IntercomApiException */ - public function reply(ReplyToConversationRequest $request, ?array $options = null): Conversation + public function reply(ReplyToConversationRequest $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()}/reply", + path: "conversations/" . RawClient::encodePathParam($request->getConversationId()) . "/reply", method: HttpMethod::POST, body: $request->getBody(), ), @@ -529,20 +588,13 @@ public function reply(ReplyToConversationRequest $request, ?array $options = nul $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Conversation::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); } @@ -560,6 +612,19 @@ public function reply(ReplyToConversationRequest $request, ?array $options = nul * - Open a conversation which is `snoozed` or `closed` * - Assign a conversation to an admin and/or team. * + * Example: + * ```php + * $client->conversations->manage( + * new ManageConversationPartsRequest([ + * 'conversationId' => '123', + * 'body' => ConversationsManageRequestBody::close(new CloseConversationRequest([ + * 'type' => 'admin', + * 'adminId' => '12345', + * ])), + * ]), + * ); + * ``` + * * @param ManageConversationPartsRequest $request * @param ?array{ * baseUrl?: string, @@ -569,18 +634,18 @@ public function reply(ReplyToConversationRequest $request, ?array $options = nul * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Conversation + * @return ?Conversation * @throws IntercomException * @throws IntercomApiException */ - public function manage(ManageConversationPartsRequest $request, ?array $options = null): Conversation + public function manage(ManageConversationPartsRequest $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()}/parts", + path: "conversations/" . RawClient::encodePathParam($request->getConversationId()) . "/parts", method: HttpMethod::POST, body: $request->getBody(), ), @@ -589,20 +654,13 @@ public function manage(ManageConversationPartsRequest $request, ?array $options $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Conversation::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); } @@ -621,6 +679,19 @@ public function manage(ManageConversationPartsRequest $request, ?array $options * {% /admonition %} * * + * Example: + * ```php + * $client->conversations->attachContactAsAdmin( + * new AttachContactToConversationRequest([ + * 'conversationId' => '123', + * 'adminId' => '12345', + * 'customer' => new AttachContactToConversationRequestCustomerIntercomUserId([ + * 'intercomUserId' => '6762f19b1bb69f9f2193bbd4', + * ]), + * ]), + * ); + * ``` + * * @param AttachContactToConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -630,18 +701,18 @@ public function manage(ManageConversationPartsRequest $request, ?array $options * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Conversation + * @return ?Conversation * @throws IntercomException * @throws IntercomApiException */ - public function attachContactAsAdmin(AttachContactToConversationRequest $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()}/customers", + path: "conversations/" . RawClient::encodePathParam($request->getConversationId()) . "/customers", method: HttpMethod::POST, body: $request, ), @@ -650,20 +721,13 @@ public function attachContactAsAdmin(AttachContactToConversationRequest $request $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Conversation::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); } @@ -682,6 +746,17 @@ public function attachContactAsAdmin(AttachContactToConversationRequest $request * {% /admonition %} * * + * Example: + * ```php + * $client->conversations->detachContactAsAdmin( + * new DetachContactFromConversationRequest([ + * 'conversationId' => '123', + * 'contactId' => '123', + * 'adminId' => '5017690', + * ]), + * ); + * ``` + * * @param DetachContactFromConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -691,18 +766,18 @@ public function attachContactAsAdmin(AttachContactToConversationRequest $request * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Conversation + * @return ?Conversation * @throws IntercomException * @throws IntercomApiException */ - public function detachContactAsAdmin(DetachContactFromConversationRequest $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/{$request->getContactId()}", + path: "conversations/" . RawClient::encodePathParam($request->getConversationId()) . "/customers/" . RawClient::encodePathParam($request->getContactId()), method: HttpMethod::DELETE, body: $request, ), @@ -711,20 +786,13 @@ public function detachContactAsAdmin(DetachContactFromConversationRequest $reque $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Conversation::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); } @@ -743,6 +811,16 @@ public function detachContactAsAdmin(DetachContactFromConversationRequest $reque * {% /admonition %} * * + * Example: + * ```php + * $client->conversations->redactConversationPart( + * RedactConversationRequest::conversationPart(new RedactConversationRequestConversationPart([ + * 'conversationId' => '19894788788', + * 'conversationPartId' => '19381789428', + * ])), + * ); + * ``` + * * @param RedactConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -752,11 +830,11 @@ public function detachContactAsAdmin(DetachContactFromConversationRequest $reque * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Conversation + * @return ?Conversation * @throws IntercomException * @throws IntercomApiException */ - public function redactConversationPart(RedactConversationRequest $request, ?array $options = null): Conversation + public function redactConversationPart(RedactConversationRequest $request, ?array $options = null): ?Conversation { $options = array_merge($this->options, $options ?? []); try { @@ -772,20 +850,13 @@ public function redactConversationPart(RedactConversationRequest $request, ?arra $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Conversation::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); } @@ -799,6 +870,16 @@ public function redactConversationPart(RedactConversationRequest $request, ?arra /** * You can convert a conversation to a ticket. * + * Example: + * ```php + * $client->conversations->convertToTicket( + * new ConvertConversationToTicketRequest([ + * 'conversationId' => 1, + * 'ticketTypeId' => '53', + * ]), + * ); + * ``` + * * @param ConvertConversationToTicketRequest $request * @param ?array{ * baseUrl?: string, @@ -819,7 +900,7 @@ public function convertToTicket(ConvertConversationToTicketRequest $request, ?ar $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "conversations/{$request->getConversationId()}/convert", + path: "conversations/" . RawClient::encodePathParam($request->getConversationId()) . "/convert", method: HttpMethod::POST, body: $request, ), @@ -835,16 +916,6 @@ public function convertToTicket(ConvertConversationToTicketRequest $request, ?ar } } 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); } @@ -864,6 +935,15 @@ public function convertToTicket(ConvertConversationToTicketRequest $request, ?ar * It is not possible to use this endpoint with Workflows. * {% /admonition %} * + * Example: + * ```php + * $client->conversations->runAssignmentRules( + * new AutoAssignConversationRequest([ + * 'conversationId' => '123', + * ]), + * ); + * ``` + * * @param AutoAssignConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -873,18 +953,18 @@ public function convertToTicket(ConvertConversationToTicketRequest $request, ?ar * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Conversation + * @return ?Conversation * @throws IntercomException * @throws IntercomApiException */ - public function runAssignmentRules(AutoAssignConversationRequest $request, ?array $options = null): Conversation + public function runAssignmentRules(AutoAssignConversationRequest $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/" . RawClient::encodePathParam($request->getConversationId()) . "/run_assignment_rules", method: HttpMethod::POST, ), $options, @@ -892,20 +972,13 @@ public function runAssignmentRules(AutoAssignConversationRequest $request, ?arra $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Conversation::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); } @@ -934,11 +1007,11 @@ public function runAssignmentRules(AutoAssignConversationRequest $request, ?arra * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ConversationList + * @return ?ConversationList * @throws IntercomException * @throws IntercomApiException */ - private function _list(ListConversationsRequest $request = new ListConversationsRequest(), ?array $options = null): ConversationList + private function _list(ListConversationsRequest $request = new ListConversationsRequest(), ?array $options = null): ?ConversationList { $options = array_merge($this->options, $options ?? []); $query = []; @@ -961,20 +1034,13 @@ private function _list(ListConversationsRequest $request = new ListConversations $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ConversationList::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); } @@ -1095,11 +1161,11 @@ private function _list(ListConversationsRequest $request = new ListConversations * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ConversationList + * @return ?ConversationList * @throws IntercomException * @throws IntercomApiException */ - private function _search(SearchRequest $request, ?array $options = null): ConversationList + private function _search(SearchRequest $request, ?array $options = null): ?ConversationList { $options = array_merge($this->options, $options ?? []); try { @@ -1115,20 +1181,13 @@ private function _search(SearchRequest $request, ?array $options = null): Conver $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ConversationList::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); } diff --git a/src/Conversations/Requests/AttachContactToConversationRequest.php b/src/Conversations/Requests/AttachContactToConversationRequest.php index 668b7930..27079c19 100644 --- a/src/Conversations/Requests/AttachContactToConversationRequest.php +++ b/src/Conversations/Requests/AttachContactToConversationRequest.php @@ -65,6 +65,7 @@ public function getConversationId(): string public function setConversationId(string $value): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } @@ -82,6 +83,7 @@ public function getAdminId(): ?string public function setAdminId(?string $value = null): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } @@ -107,6 +109,7 @@ public function getCustomer(): AttachContactToConversationRequestCustomerInterco public function setCustomer(AttachContactToConversationRequestCustomerIntercomUserId|AttachContactToConversationRequestCustomerUserId|AttachContactToConversationRequestCustomerCustomer|null $value = null): self { $this->customer = $value; + $this->_setField('customer'); return $this; } } diff --git a/src/Conversations/Requests/AutoAssignConversationRequest.php b/src/Conversations/Requests/AutoAssignConversationRequest.php index 0309f145..ece506ac 100644 --- a/src/Conversations/Requests/AutoAssignConversationRequest.php +++ b/src/Conversations/Requests/AutoAssignConversationRequest.php @@ -36,6 +36,7 @@ public function getConversationId(): string public function setConversationId(string $value): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } } diff --git a/src/Conversations/Requests/ConvertConversationToTicketRequest.php b/src/Conversations/Requests/ConvertConversationToTicketRequest.php index d206e5c3..a5f1559d 100644 --- a/src/Conversations/Requests/ConvertConversationToTicketRequest.php +++ b/src/Conversations/Requests/ConvertConversationToTicketRequest.php @@ -54,6 +54,7 @@ public function getConversationId(): int public function setConversationId(int $value): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } @@ -71,6 +72,7 @@ public function getTicketTypeId(): string public function setTicketTypeId(string $value): self { $this->ticketTypeId = $value; + $this->_setField('ticketTypeId'); return $this; } @@ -88,6 +90,7 @@ public function getAttributes(): ?array public function setAttributes(?array $value = null): self { $this->attributes = $value; + $this->_setField('attributes'); return $this; } } diff --git a/src/Conversations/Requests/CreateConversationRequest.php b/src/Conversations/Requests/CreateConversationRequest.php index 35ed68e1..865522b2 100644 --- a/src/Conversations/Requests/CreateConversationRequest.php +++ b/src/Conversations/Requests/CreateConversationRequest.php @@ -55,6 +55,7 @@ public function getFrom(): CreateConversationRequestFrom public function setFrom(CreateConversationRequestFrom $value): self { $this->from = $value; + $this->_setField('from'); return $this; } @@ -72,6 +73,7 @@ public function getBody(): string public function setBody(string $value): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -89,6 +91,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } } diff --git a/src/Conversations/Requests/DeleteConversationRequest.php b/src/Conversations/Requests/DeleteConversationRequest.php index 915714d5..67ee99a9 100644 --- a/src/Conversations/Requests/DeleteConversationRequest.php +++ b/src/Conversations/Requests/DeleteConversationRequest.php @@ -36,6 +36,7 @@ public function getConversationId(): int public function setConversationId(int $value): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } } diff --git a/src/Conversations/Requests/DetachContactFromConversationRequest.php b/src/Conversations/Requests/DetachContactFromConversationRequest.php index 200678e7..d7759de8 100644 --- a/src/Conversations/Requests/DetachContactFromConversationRequest.php +++ b/src/Conversations/Requests/DetachContactFromConversationRequest.php @@ -52,6 +52,7 @@ public function getConversationId(): string public function setConversationId(string $value): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } @@ -69,6 +70,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } @@ -86,6 +88,7 @@ public function getAdminId(): string public function setAdminId(string $value): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } } diff --git a/src/Conversations/Requests/FindConversationRequest.php b/src/Conversations/Requests/FindConversationRequest.php index 2d469410..37dbd9cc 100644 --- a/src/Conversations/Requests/FindConversationRequest.php +++ b/src/Conversations/Requests/FindConversationRequest.php @@ -50,6 +50,7 @@ public function getConversationId(): string public function setConversationId(string $value): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } @@ -67,6 +68,7 @@ public function getDisplayAs(): ?string public function setDisplayAs(?string $value = null): self { $this->displayAs = $value; + $this->_setField('displayAs'); return $this; } @@ -84,6 +86,7 @@ public function getIncludeTranslations(): ?bool public function setIncludeTranslations(?bool $value = null): self { $this->includeTranslations = $value; + $this->_setField('includeTranslations'); return $this; } } diff --git a/src/Conversations/Requests/ListConversationsRequest.php b/src/Conversations/Requests/ListConversationsRequest.php index b43587d2..bda4374a 100644 --- a/src/Conversations/Requests/ListConversationsRequest.php +++ b/src/Conversations/Requests/ListConversationsRequest.php @@ -43,6 +43,7 @@ public function getPerPage(): ?int public function setPerPage(?int $value = null): self { $this->perPage = $value; + $this->_setField('perPage'); return $this; } @@ -60,6 +61,7 @@ public function getStartingAfter(): ?string public function setStartingAfter(?string $value = null): self { $this->startingAfter = $value; + $this->_setField('startingAfter'); return $this; } } diff --git a/src/Conversations/Requests/ManageConversationPartsRequest.php b/src/Conversations/Requests/ManageConversationPartsRequest.php index 633d16d4..b6a197ce 100644 --- a/src/Conversations/Requests/ManageConversationPartsRequest.php +++ b/src/Conversations/Requests/ManageConversationPartsRequest.php @@ -44,6 +44,7 @@ public function getConversationId(): string public function setConversationId(string $value): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } @@ -61,6 +62,7 @@ public function getBody(): ConversationsManageRequestBody public function setBody(ConversationsManageRequestBody $value): self { $this->body = $value; + $this->_setField('body'); return $this; } } diff --git a/src/Conversations/Requests/ReplyToConversationRequest.php b/src/Conversations/Requests/ReplyToConversationRequest.php index fb978428..f7b68e0a 100644 --- a/src/Conversations/Requests/ReplyToConversationRequest.php +++ b/src/Conversations/Requests/ReplyToConversationRequest.php @@ -57,6 +57,7 @@ public function getConversationId(): string public function setConversationId(string $value): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } @@ -84,6 +85,7 @@ public function getBody(): ContactReplyIntercomUserIdRequest|ContactReplyEmailRe public function setBody(ContactReplyIntercomUserIdRequest|ContactReplyEmailRequest|ContactReplyUserIdRequest|AdminReplyConversationRequest $value): self { $this->body = $value; + $this->_setField('body'); return $this; } } diff --git a/src/Conversations/Requests/UpdateConversationRequest.php b/src/Conversations/Requests/UpdateConversationRequest.php index f099504f..9f3cf94a 100644 --- a/src/Conversations/Requests/UpdateConversationRequest.php +++ b/src/Conversations/Requests/UpdateConversationRequest.php @@ -90,6 +90,7 @@ public function getConversationId(): string public function setConversationId(string $value): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } @@ -107,6 +108,7 @@ public function getDisplayAs(): ?string public function setDisplayAs(?string $value = null): self { $this->displayAs = $value; + $this->_setField('displayAs'); return $this; } @@ -124,6 +126,7 @@ public function getRead(): ?bool public function setRead(?bool $value = null): self { $this->read = $value; + $this->_setField('read'); return $this; } @@ -141,6 +144,7 @@ public function getTitle(): ?string public function setTitle(?string $value = null): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -168,6 +172,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } @@ -185,6 +190,7 @@ public function getCompanyId(): ?string public function setCompanyId(?string $value = null): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } } diff --git a/src/Conversations/Types/AttachContactToConversationRequestCustomerCustomer.php b/src/Conversations/Types/AttachContactToConversationRequestCustomerCustomer.php index eb351497..5b10a089 100644 --- a/src/Conversations/Types/AttachContactToConversationRequestCustomerCustomer.php +++ b/src/Conversations/Types/AttachContactToConversationRequestCustomerCustomer.php @@ -58,6 +58,7 @@ public function getEmail(): string public function setEmail(string $value): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -83,6 +84,7 @@ public function getCustomer(): CustomerRequestIntercomUserId|CustomerRequestUser public function setCustomer(CustomerRequestIntercomUserId|CustomerRequestUserId|CustomerRequestEmail|null $value = null): self { $this->customer = $value; + $this->_setField('customer'); return $this; } diff --git a/src/Conversations/Types/AttachContactToConversationRequestCustomerIntercomUserId.php b/src/Conversations/Types/AttachContactToConversationRequestCustomerIntercomUserId.php index 08544b80..22d2393e 100644 --- a/src/Conversations/Types/AttachContactToConversationRequestCustomerIntercomUserId.php +++ b/src/Conversations/Types/AttachContactToConversationRequestCustomerIntercomUserId.php @@ -58,6 +58,7 @@ public function getIntercomUserId(): string public function setIntercomUserId(string $value): self { $this->intercomUserId = $value; + $this->_setField('intercomUserId'); return $this; } @@ -83,6 +84,7 @@ public function getCustomer(): CustomerRequestIntercomUserId|CustomerRequestUser public function setCustomer(CustomerRequestIntercomUserId|CustomerRequestUserId|CustomerRequestEmail|null $value = null): self { $this->customer = $value; + $this->_setField('customer'); return $this; } diff --git a/src/Conversations/Types/AttachContactToConversationRequestCustomerUserId.php b/src/Conversations/Types/AttachContactToConversationRequestCustomerUserId.php index 50fefe17..b247ee13 100644 --- a/src/Conversations/Types/AttachContactToConversationRequestCustomerUserId.php +++ b/src/Conversations/Types/AttachContactToConversationRequestCustomerUserId.php @@ -58,6 +58,7 @@ public function getUserId(): string public function setUserId(string $value): self { $this->userId = $value; + $this->_setField('userId'); return $this; } @@ -83,6 +84,7 @@ public function getCustomer(): CustomerRequestIntercomUserId|CustomerRequestUser public function setCustomer(CustomerRequestIntercomUserId|CustomerRequestUserId|CustomerRequestEmail|null $value = null): self { $this->customer = $value; + $this->_setField('customer'); return $this; } diff --git a/src/Conversations/Types/Conversation.php b/src/Conversations/Types/Conversation.php index 90fa29bd..4defc39b 100644 --- a/src/Conversations/Types/Conversation.php +++ b/src/Conversations/Types/Conversation.php @@ -274,6 +274,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -291,6 +292,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -308,6 +310,7 @@ public function getTitle(): ?string public function setTitle(?string $value = null): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -325,6 +328,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -342,6 +346,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -359,6 +364,7 @@ public function getWaitingSince(): ?int public function setWaitingSince(?int $value = null): self { $this->waitingSince = $value; + $this->_setField('waitingSince'); return $this; } @@ -376,6 +382,7 @@ public function getSnoozedUntil(): ?int public function setSnoozedUntil(?int $value = null): self { $this->snoozedUntil = $value; + $this->_setField('snoozedUntil'); return $this; } @@ -393,6 +400,7 @@ public function getOpen(): ?bool public function setOpen(?bool $value = null): self { $this->open = $value; + $this->_setField('open'); return $this; } @@ -410,6 +418,7 @@ public function getState(): ?string public function setState(?string $value = null): self { $this->state = $value; + $this->_setField('state'); return $this; } @@ -427,6 +436,7 @@ public function getRead(): ?bool public function setRead(?bool $value = null): self { $this->read = $value; + $this->_setField('read'); return $this; } @@ -444,6 +454,7 @@ public function getPriority(): ?string public function setPriority(?string $value = null): self { $this->priority = $value; + $this->_setField('priority'); return $this; } @@ -461,6 +472,7 @@ public function getAdminAssigneeId(): ?int public function setAdminAssigneeId(?int $value = null): self { $this->adminAssigneeId = $value; + $this->_setField('adminAssigneeId'); return $this; } @@ -478,6 +490,7 @@ public function getTeamAssigneeId(): ?string public function setTeamAssigneeId(?string $value = null): self { $this->teamAssigneeId = $value; + $this->_setField('teamAssigneeId'); return $this; } @@ -495,6 +508,7 @@ public function getCompanyId(): ?string public function setCompanyId(?string $value = null): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } @@ -512,6 +526,7 @@ public function getTags(): ?Tags public function setTags(?Tags $value = null): self { $this->tags = $value; + $this->_setField('tags'); return $this; } @@ -529,6 +544,7 @@ public function getConversationRating(): ?ConversationRating public function setConversationRating(?ConversationRating $value = null): self { $this->conversationRating = $value; + $this->_setField('conversationRating'); return $this; } @@ -546,6 +562,7 @@ public function getSource(): ?ConversationSource public function setSource(?ConversationSource $value = null): self { $this->source = $value; + $this->_setField('source'); return $this; } @@ -563,6 +580,7 @@ public function getContacts(): ?ConversationContacts public function setContacts(?ConversationContacts $value = null): self { $this->contacts = $value; + $this->_setField('contacts'); return $this; } @@ -580,6 +598,7 @@ public function getTeammates(): ?ConversationTeammates public function setTeammates(?ConversationTeammates $value = null): self { $this->teammates = $value; + $this->_setField('teammates'); return $this; } @@ -607,6 +626,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } @@ -624,6 +644,7 @@ public function getFirstContactReply(): ?ConversationFirstContactReply public function setFirstContactReply(?ConversationFirstContactReply $value = null): self { $this->firstContactReply = $value; + $this->_setField('firstContactReply'); return $this; } @@ -641,6 +662,7 @@ public function getSlaApplied(): ?SlaApplied public function setSlaApplied(?SlaApplied $value = null): self { $this->slaApplied = $value; + $this->_setField('slaApplied'); return $this; } @@ -658,6 +680,7 @@ public function getStatistics(): ?ConversationStatistics public function setStatistics(?ConversationStatistics $value = null): self { $this->statistics = $value; + $this->_setField('statistics'); return $this; } @@ -675,6 +698,7 @@ public function getConversationParts(): ?ConversationParts public function setConversationParts(?ConversationParts $value = null): self { $this->conversationParts = $value; + $this->_setField('conversationParts'); return $this; } @@ -692,6 +716,7 @@ public function getLinkedObjects(): ?LinkedObjectList public function setLinkedObjects(?LinkedObjectList $value = null): self { $this->linkedObjects = $value; + $this->_setField('linkedObjects'); return $this; } @@ -709,6 +734,7 @@ public function getAiAgentParticipated(): ?bool public function setAiAgentParticipated(?bool $value = null): self { $this->aiAgentParticipated = $value; + $this->_setField('aiAgentParticipated'); return $this; } @@ -726,6 +752,7 @@ public function getAiAgent(): ?AiAgent public function setAiAgent(?AiAgent $value = null): self { $this->aiAgent = $value; + $this->_setField('aiAgent'); return $this; } diff --git a/src/Conversations/Types/ConversationsManageRequestBody.php b/src/Conversations/Types/ConversationsManageRequestBody.php index bc3759dc..7d9def7d 100644 --- a/src/Conversations/Types/ConversationsManageRequestBody.php +++ b/src/Conversations/Types/ConversationsManageRequestBody.php @@ -8,7 +8,6 @@ use Intercom\Types\OpenConversationRequest; use Intercom\Types\AssignConversationRequest; use Exception; -use Intercom\Core\Json\JsonDecoder; class ConversationsManageRequestBody extends JsonSerializableType { @@ -275,18 +274,6 @@ public function jsonSerialize(): array 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 */ diff --git a/src/Conversations/Types/CreateConversationRequestFrom.php b/src/Conversations/Types/CreateConversationRequestFrom.php index b2b7f369..57a1ed20 100644 --- a/src/Conversations/Types/CreateConversationRequestFrom.php +++ b/src/Conversations/Types/CreateConversationRequestFrom.php @@ -46,6 +46,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -63,6 +64,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } diff --git a/src/Core/Client/HttpClientBuilder.php b/src/Core/Client/HttpClientBuilder.php new file mode 100644 index 00000000..c29d1a62 --- /dev/null +++ b/src/Core/Client/HttpClientBuilder.php @@ -0,0 +1,56 @@ + + */ + private array $responses = []; + + /** + * @var array + */ + private array $requests = []; + + /** + * @param ResponseInterface ...$responses + */ + public function append(ResponseInterface ...$responses): void + { + foreach ($responses as $response) { + $this->responses[] = $response; + } + } + + /** + * @param RequestInterface $request + * @return ResponseInterface + */ + public function sendRequest(RequestInterface $request): ResponseInterface + { + $this->requests[] = $request; + + if (empty($this->responses)) { + throw new RuntimeException('No more responses in the queue. Add responses using append().'); + } + + return array_shift($this->responses); + } + + /** + * @return ?RequestInterface + */ + public function getLastRequest(): ?RequestInterface + { + if (empty($this->requests)) { + return null; + } + return $this->requests[count($this->requests) - 1]; + } + + /** + * @return int + */ + public function getRequestCount(): int + { + return count($this->requests); + } + + /** + * Returns the number of remaining responses in the queue. + * + * @return int + */ + public function count(): int + { + return count($this->responses); + } +} diff --git a/src/Core/Client/RawClient.php b/src/Core/Client/RawClient.php index beb97921..6f989aec 100644 --- a/src/Core/Client/RawClient.php +++ b/src/Core/Client/RawClient.php @@ -3,54 +3,67 @@ namespace Intercom\Core\Client; use JsonSerializable; -use GuzzleHttp\Client; -use GuzzleHttp\ClientInterface; -use GuzzleHttp\HandlerStack; -use GuzzleHttp\Psr7\MultipartStream; -use GuzzleHttp\Psr7\Request; -use GuzzleHttp\Psr7\Utils; use InvalidArgumentException; use Psr\Http\Client\ClientExceptionInterface; +use Psr\Http\Client\ClientInterface; +use Psr\Http\Message\RequestFactoryInterface; +use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; +use Http\Message\MultipartStream\MultipartStreamBuilder; +use Psr\Http\Message\StreamFactoryInterface; use Psr\Http\Message\StreamInterface; use Intercom\Core\Json\JsonApiRequest; +use Intercom\Core\Json\JsonEncoder; use Intercom\Core\Multipart\MultipartApiRequest; class RawClient { /** - * @var ClientInterface $client + * @var RetryDecoratingClient $client */ - private ClientInterface $client; + private RetryDecoratingClient $client; + + /** + * @var RequestFactoryInterface $requestFactory + */ + private RequestFactoryInterface $requestFactory; + + /** + * @var StreamFactoryInterface $streamFactory + */ + private StreamFactoryInterface $streamFactory; /** * @var array $headers */ private array $headers; + /** + * @var ?(callable(): array) $getAuthHeaders + */ + private $getAuthHeaders; + /** * @param ?array{ * baseUrl?: string, * client?: ClientInterface, + * maxRetries?: int, + * timeout?: float, * headers?: array, + * getAuthHeaders?: callable(): array, * } $options */ public function __construct( public readonly ?array $options = null, ) { - $this->client = $this->options['client'] - ?? $this->createDefaultClient(); + $this->client = HttpClientBuilder::build( + $this->options['client'] ?? null, + $this->options['maxRetries'] ?? 2, + ); + $this->requestFactory = HttpClientBuilder::requestFactory(); + $this->streamFactory = HttpClientBuilder::streamFactory(); $this->headers = $this->options['headers'] ?? []; - } - - /** - * @return Client - */ - private function createDefaultClient(): Client - { - $handler = HandlerStack::create(); - $handler->push(RetryMiddleware::create()); - return new Client(['handler' => $handler]); + $this->getAuthHeaders = $this->options['getAuthHeaders'] ?? null; } /** @@ -71,26 +84,11 @@ public function sendRequest( ): ResponseInterface { $opts = $options ?? []; $httpRequest = $this->buildRequest($request, $opts); - return $this->client->send($httpRequest, $this->toGuzzleOptions($opts)); - } - /** - * @param array{ - * maxRetries?: int, - * timeout?: float, - * } $options - * @return array - */ - private function toGuzzleOptions(array $options): array - { - $guzzleOptions = []; - if (isset($options['maxRetries'])) { - $guzzleOptions['maxRetries'] = $options['maxRetries']; - } - if (isset($options['timeout'])) { - $guzzleOptions['timeout'] = $options['timeout']; - } - return $guzzleOptions; + $timeout = $opts['timeout'] ?? $this->options['timeout'] ?? null; + $maxRetries = $opts['maxRetries'] ?? null; + + return $this->client->send($httpRequest, $timeout, $maxRetries); } /** @@ -100,21 +98,38 @@ private function toGuzzleOptions(array $options): array * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Request + * @return RequestInterface */ private function buildRequest( BaseApiRequest $request, array $options - ): Request { + ): RequestInterface { $url = $this->buildUrl($request, $options); $headers = $this->encodeHeaders($request, $options); - $body = $this->encodeRequestBody($request, $options); - return new Request( + + $httpRequest = $this->requestFactory->createRequest( $request->method->name, $url, - $headers, - $body, ); + + // Encode body and, for multipart, capture the Content-Type with boundary. + if ($request instanceof MultipartApiRequest && $request->body !== null) { + $builder = new MultipartStreamBuilder($this->streamFactory); + $request->body->addToBuilder($builder); + $httpRequest = $httpRequest->withBody($builder->build()); + $headers['Content-Type'] = "multipart/form-data; boundary={$builder->getBoundary()}"; + } else { + $body = $this->encodeRequestBody($request, $options); + if ($body !== null) { + $httpRequest = $httpRequest->withBody($body); + } + } + + foreach ($headers as $name => $value) { + $httpRequest = $httpRequest->withHeader($name, $value); + } + + return $httpRequest; } /** @@ -128,6 +143,7 @@ private function encodeHeaders( BaseApiRequest $request, array $options, ): array { + $authHeaders = $this->getAuthHeaders !== null ? ($this->getAuthHeaders)() : []; return match (get_class($request)) { JsonApiRequest::class => array_merge( [ @@ -135,11 +151,23 @@ private function encodeHeaders( "Accept" => "*/*", ], $this->headers, + $authHeaders, + $request->headers, + $options['headers'] ?? [], + ), + UrlEncodedApiRequest::class => array_merge( + [ + "Content-Type" => "application/x-www-form-urlencoded", + "Accept" => "*/*", + ], + $this->headers, + $authHeaders, $request->headers, $options['headers'] ?? [], ), MultipartApiRequest::class => array_merge( $this->headers, + $authHeaders, $request->headers, $options['headers'] ?? [], ), @@ -158,18 +186,39 @@ private function encodeRequestBody( BaseApiRequest $request, array $options, ): ?StreamInterface { - return match (get_class($request)) { - JsonApiRequest::class => $request->body === null ? null : Utils::streamFor( - json_encode( + if ($request instanceof JsonApiRequest) { + return $request->body === null ? null : $this->streamFactory->createStream( + JsonEncoder::encode( $this->buildJsonBody( $request->body, $options, ), ) - ), - MultipartApiRequest::class => $request->body != null ? new MultipartStream($request->body->toArray()) : null, - default => throw new InvalidArgumentException('Unsupported request type: ' . get_class($request)), - }; + ); + } + + if ($request instanceof UrlEncodedApiRequest) { + if ($request->body === null) { + return null; + } + $body = $this->buildJsonBody($request->body, $options); + if ($body instanceof JsonSerializable) { + $body = $body->jsonSerialize(); + } + if (is_object($body)) { + $body = (array)$body; + } + if (!is_array($body)) { + throw new InvalidArgumentException('URL-encoded request bodies must serialize to an array.'); + } + return $this->streamFactory->createStream(http_build_query($body)); + } + + if ($request instanceof MultipartApiRequest) { + return null; + } + + throw new InvalidArgumentException('Unsupported request type: ' . get_class($request)); } /** @@ -204,6 +253,28 @@ private function buildJsonBody( return $result; } + /** + * Percent-encodes a value for use inside a single URL path segment. Encoding happens here, + * where the value is still separate from the path template, so that a value containing "/" + * or ".." cannot change which endpoint the request resolves to. + */ + public static function encodePathParam(mixed $value): string + { + if (is_bool($value)) { + return $value ? 'true' : 'false'; + } + if (is_null($value)) { + return ''; + } + if (is_scalar($value)) { + return rawurlencode((string)$value); + } + if (is_object($value) && method_exists($value, '__toString')) { + return rawurlencode((string)$value); + } + return rawurlencode(JsonEncoder::encode($value)); + } + /** * @param BaseApiRequest $request * @param array{ @@ -218,6 +289,7 @@ private function buildUrl( $baseUrl = $request->baseUrl; $trimmedBaseUrl = rtrim($baseUrl, '/'); $trimmedBasePath = ltrim($request->path, '/'); + self::assertNoDotSegments($trimmedBasePath); $url = "{$trimmedBaseUrl}/{$trimmedBasePath}"; $query = array_merge( $request->query, @@ -229,6 +301,25 @@ private function buildUrl( return $url; } + /** + * Rejects "." and ".." path segments, which HTTP clients and servers resolve + * and which would otherwise change the endpoint a request is sent to. + * + * @param string $path + * @throws InvalidArgumentException + */ + private static function assertNoDotSegments(string $path): void + { + foreach (explode('/', $path) as $segment) { + $decoded = rawurldecode($segment); + if ($decoded === '.' || $decoded === '..') { + throw new InvalidArgumentException( + "Invalid request path \"/{$path}\": \".\" and \"..\" path segments are not allowed." + ); + } + } + } + /** * @param array $query * @return string @@ -263,7 +354,7 @@ private function encodeQueryValue(mixed $value): string return 'null'; } // Unreachable, but included for a best effort. - return urlencode(strval(json_encode($value))); + return urlencode(JsonEncoder::encode($value)); } /** diff --git a/src/Core/Client/RetryDecoratingClient.php b/src/Core/Client/RetryDecoratingClient.php new file mode 100644 index 00000000..4e73eaed --- /dev/null +++ b/src/Core/Client/RetryDecoratingClient.php @@ -0,0 +1,241 @@ +client = $client; + $this->maxRetries = $maxRetries; + $this->baseDelay = $baseDelay; + $this->sleepFunction = $sleepFunction ?? 'usleep'; + } + + /** + * @param RequestInterface $request + * @return ResponseInterface + * @throws ClientExceptionInterface + */ + public function sendRequest(RequestInterface $request): ResponseInterface + { + return $this->send($request); + } + + /** + * Sends a request with optional per-request timeout and retry overrides. + * + * When a Guzzle or Symfony PSR-18 client is detected, the timeout is + * forwarded via the client's native API. For other PSR-18 clients the + * timeout value is silently ignored. + * + * @param RequestInterface $request + * @param ?float $timeout Timeout in seconds, or null to use the client default. + * @param ?int $maxRetries Maximum retry attempts, or null to use the client default. + * @return ResponseInterface + * @throws ClientExceptionInterface + */ + public function send( + RequestInterface $request, + ?float $timeout = null, + ?int $maxRetries = null, + ): ResponseInterface { + $maxRetries = $maxRetries ?? $this->maxRetries; + $retryAttempt = 0; + $lastResponse = null; + + while (true) { + try { + $lastResponse = $this->doSend($request, $timeout); + if (!$this->shouldRetry($retryAttempt, $maxRetries, $lastResponse)) { + return $lastResponse; + } + } catch (ClientExceptionInterface $e) { + if ($retryAttempt >= $maxRetries) { + throw $e; + } + } + + $retryAttempt++; + $delay = $this->getRetryDelay($retryAttempt, $lastResponse); + ($this->sleepFunction)($delay * 1000); // Convert milliseconds to microseconds + + // Rewind the request body so retries don't send an empty body. + $request->getBody()->rewind(); + } + } + + /** + * Dispatches the request to the underlying client, forwarding the timeout + * option to Guzzle or Symfony when available. + * + * @param RequestInterface $request + * @param ?float $timeout + * @return ResponseInterface + * @throws ClientExceptionInterface + */ + private function doSend(RequestInterface $request, ?float $timeout): ResponseInterface + { + static $warned = false; + + if ($timeout === null) { + return $this->client->sendRequest($request); + } + + if (interface_exists('GuzzleHttp\ClientInterface') + && $this->client instanceof \GuzzleHttp\ClientInterface + ) { + return $this->client->send($request, ['timeout' => $timeout]); + } + if (class_exists('Symfony\Component\HttpClient\Psr18Client') + && $this->client instanceof \Symfony\Component\HttpClient\Psr18Client + ) { + /** @var ClientInterface $clientWithTimeout */ + $clientWithTimeout = $this->client->withOptions(['timeout' => $timeout]); + return $clientWithTimeout->sendRequest($request); + } + + if ($warned) { + return $this->client->sendRequest($request); + } + $warned = true; + trigger_error( + 'Timeout option is not supported for the current PSR-18 client (' + . get_class($this->client) + . '). Use Guzzle or Symfony HttpClient for timeout support.', + E_USER_WARNING, + ); + return $this->client->sendRequest($request); + } + + /** + * @param int $retryAttempt + * @param int $maxRetries + * @param ?ResponseInterface $response + * @return bool + */ + private function shouldRetry( + int $retryAttempt, + int $maxRetries, + ?ResponseInterface $response = null, + ): bool { + if ($retryAttempt >= $maxRetries) { + return false; + } + + if ($response !== null) { + return $response->getStatusCode() >= 500 || + in_array($response->getStatusCode(), self::RETRY_STATUS_CODES); + } + + return false; + } + + /** + * Calculate the retry delay based on response headers or exponential backoff. + * + * @param int $retryAttempt + * @param ?ResponseInterface $response + * @return int milliseconds + */ + private function getRetryDelay(int $retryAttempt, ?ResponseInterface $response): int + { + if ($response !== null) { + // Check Retry-After header + $retryAfter = $response->getHeaderLine('Retry-After'); + if ($retryAfter !== '') { + // Try parsing as integer (seconds) + if (is_numeric($retryAfter)) { + $retryAfterSeconds = (int)$retryAfter; + if ($retryAfterSeconds > 0) { + return min($retryAfterSeconds * 1000, self::MAX_RETRY_DELAY); + } + } + + // Try parsing as HTTP date + $retryAfterDate = strtotime($retryAfter); + if ($retryAfterDate !== false) { + $delay = ($retryAfterDate - time()) * 1000; + if ($delay > 0) { + return min(max($delay, 0), self::MAX_RETRY_DELAY); + } + } + } + + // Check X-RateLimit-Reset header + $rateLimitReset = $response->getHeaderLine('X-RateLimit-Reset'); + if ($rateLimitReset !== '' && is_numeric($rateLimitReset)) { + $resetTime = (int)$rateLimitReset; + $delay = ($resetTime * 1000) - (int)(microtime(true) * 1000); + if ($delay > 0) { + return $this->addPositiveJitter(min($delay, self::MAX_RETRY_DELAY)); + } + } + } + + // Fall back to exponential backoff with symmetric jitter + return $this->addSymmetricJitter( + min($this->exponentialDelay($retryAttempt), self::MAX_RETRY_DELAY) + ); + } + + /** + * Add positive jitter (0% to +20%) to the delay. + * + * @param int $delay + * @return int + */ + private function addPositiveJitter(int $delay): int + { + $jitterMultiplier = 1 + (mt_rand() / mt_getrandmax()) * self::JITTER_FACTOR; + return (int)($delay * $jitterMultiplier); + } + + /** + * Add symmetric jitter (-10% to +10%) to the delay. + * + * @param int $delay + * @return int + */ + private function addSymmetricJitter(int $delay): int + { + $jitterMultiplier = 1 + ((mt_rand() / mt_getrandmax()) - 0.5) * self::JITTER_FACTOR; + return (int)($delay * $jitterMultiplier); + } + + /** + * Default exponential backoff delay function. + * + * @return int milliseconds. + */ + private function exponentialDelay(int $retryAttempt): int + { + return 2 ** ($retryAttempt - 1) * $this->baseDelay; + } +} diff --git a/src/Core/Client/RetryMiddleware.php b/src/Core/Client/RetryMiddleware.php deleted file mode 100644 index eb2682c8..00000000 --- a/src/Core/Client/RetryMiddleware.php +++ /dev/null @@ -1,266 +0,0 @@ - 2, - 'baseDelay' => 1000 - ]; - private const RETRY_STATUS_CODES = [408, 429]; - private const MAX_RETRY_DELAY = 60000; // 60 seconds in milliseconds - private const JITTER_FACTOR = 0.2; // 20% random jitter - - /** - * @var callable(RequestInterface, array): PromiseInterface - * @phpstan-ignore missingType.iterableValue - */ - private $nextHandler; - - /** - * @var array{ - * maxRetries: int, - * baseDelay: int, - * } - */ - private array $options; - - /** - * @param callable $nextHandler - * @param ?array{ - * maxRetries?: int, - * } $options - */ - public function __construct( - callable $nextHandler, - ?array $options = null, - ) { - $this->nextHandler = $nextHandler; - $this->options = array_merge(self::DEFAULT_RETRY_OPTIONS, $options ?? []); - } - - /** - * @param ?array{ - * maxRetries?: int, - * baseDelay?: int, - * } $options - * @return callable - */ - public static function create(?array $options = null): callable - { - return static function (callable $handler) use ($options): RetryMiddleware { - return new RetryMiddleware($handler, $options); - }; - } - - /** - * @param RequestInterface $request - * @param array{ - * retryAttempt?: int, - * delay: int, - * maxRetries?: int, - * } $options - * @return PromiseInterface - */ - public function __invoke(RequestInterface $request, array $options): PromiseInterface - { - $options = array_merge($this->options, $options); - if (!isset($options['retryAttempt'])) { - $options['retryAttempt'] = 0; - } - - $fn = $this->nextHandler; - - return $fn($request, $options) - ->then( - $this->onFulfilled($request, $options), - $this->onRejected($request, $options) - ); - } - - /** - * @param int $retryAttempt - * @param int $maxRetries - * @param ?ResponseInterface $response - * @param ?Throwable $exception - * @return bool - */ - private function shouldRetry( - int $retryAttempt, - int $maxRetries, - ?ResponseInterface $response = null, - ?Throwable $exception = null - ): bool { - if ($retryAttempt >= $maxRetries) { - return false; - } - - if ($exception instanceof ConnectException) { - return true; - } - - if ($response) { - return $response->getStatusCode() >= 500 || - in_array($response->getStatusCode(), self::RETRY_STATUS_CODES); - } - return false; - } - - /** - * Execute fulfilled closure - * @param array{ - * retryAttempt: int, - * delay: int, - * maxRetries: int, - * } $options - */ - private function onFulfilled(RequestInterface $request, array $options): callable - { - $retryAttempt = $options['retryAttempt']; - $maxRetries = $options['maxRetries']; - return function ($value) use ($request, $options, $retryAttempt, $maxRetries) { - if (!$this->shouldRetry( - $retryAttempt, - $maxRetries, - $value - )) { - return $value; - } - - return $this->doRetry($request, $options, $value); - }; - } - - /** - * Execute rejected closure - * @param RequestInterface $req - * @param array{ - * retryAttempt: int, - * delay: int, - * maxRetries: int, - * } $options - * @return callable - */ - private function onRejected(RequestInterface $req, array $options): callable - { - $retryAttempt = $options['retryAttempt']; - $maxRetries = $options['maxRetries']; - return function ($reason) use ($req, $options, $retryAttempt, $maxRetries) { - if (!$this->shouldRetry( - $retryAttempt, - $maxRetries, - null, - $reason - )) { - return P\Create::rejectionFor($reason); - } - - return $this->doRetry($req, $options); - }; - } - - /** - * @param RequestInterface $request - * @param array{ - * delay: int, - * retryAttempt: int, - * } $options - * @param ?ResponseInterface $response - * @return PromiseInterface - */ - private function doRetry(RequestInterface $request, array $options, ?ResponseInterface $response = null): PromiseInterface - { - $options['delay'] = $this->getRetryDelay(++$options['retryAttempt'], $response); - return $this($request, $options); - } - - /** - * Calculate the retry delay based on response headers or exponential backoff. - * - * @param int $retryAttempt - * @param ?ResponseInterface $response - * @return int milliseconds - */ - private function getRetryDelay(int $retryAttempt, ?ResponseInterface $response): int - { - if ($response !== null) { - // Check Retry-After header - $retryAfter = $response->getHeaderLine('Retry-After'); - if ($retryAfter !== '') { - // Try parsing as integer (seconds) - if (is_numeric($retryAfter)) { - $retryAfterSeconds = (int)$retryAfter; - if ($retryAfterSeconds > 0) { - return min($retryAfterSeconds * 1000, self::MAX_RETRY_DELAY); - } - } - - // Try parsing as HTTP date - $retryAfterDate = strtotime($retryAfter); - if ($retryAfterDate !== false) { - $delay = ($retryAfterDate - time()) * 1000; - if ($delay > 0) { - return min(max($delay, 0), self::MAX_RETRY_DELAY); - } - } - } - - // Check X-RateLimit-Reset header - $rateLimitReset = $response->getHeaderLine('X-RateLimit-Reset'); - if ($rateLimitReset !== '' && is_numeric($rateLimitReset)) { - $resetTime = (int)$rateLimitReset; - $delay = ($resetTime * 1000) - (int)(microtime(true) * 1000); - if ($delay > 0) { - return $this->addPositiveJitter(min($delay, self::MAX_RETRY_DELAY)); - } - } - } - - // Fall back to exponential backoff with symmetric jitter - return $this->addSymmetricJitter( - min($this->exponentialDelay($retryAttempt), self::MAX_RETRY_DELAY) - ); - } - - /** - * Add positive jitter (0% to +20%) to the delay. - * - * @param int $delay - * @return int - */ - private function addPositiveJitter(int $delay): int - { - $jitterMultiplier = 1 + (mt_rand() / mt_getrandmax()) * self::JITTER_FACTOR; - return (int)($delay * $jitterMultiplier); - } - - /** - * Add symmetric jitter (-10% to +10%) to the delay. - * - * @param int $delay - * @return int - */ - private function addSymmetricJitter(int $delay): int - { - $jitterMultiplier = 1 + ((mt_rand() / mt_getrandmax()) - 0.5) * self::JITTER_FACTOR; - return (int)($delay * $jitterMultiplier); - } - - /** - * Default exponential backoff delay function. - * - * @return int milliseconds. - */ - private function exponentialDelay(int $retryAttempt): int - { - return 2 ** ($retryAttempt - 1) * $this->options['baseDelay']; - } -} diff --git a/src/Core/Client/UrlEncodedApiRequest.php b/src/Core/Client/UrlEncodedApiRequest.php new file mode 100644 index 00000000..06949bfd --- /dev/null +++ b/src/Core/Client/UrlEncodedApiRequest.php @@ -0,0 +1,25 @@ + $headers Additional headers for the request (optional) + * @param array $query Query parameters for the request (optional) + * @param mixed|null $body The form-urlencoded request body (optional) + */ + public function __construct( + string $baseUrl, + string $path, + HttpMethod $method, + array $headers = [], + array $query = [], + public readonly mixed $body = null + ) { + parent::__construct($baseUrl, $path, $method, $headers, $query); + } +} diff --git a/src/Core/Json/JsonDecoder.php b/src/Core/Json/JsonDecoder.php index c2b51fc3..e6ebb3ae 100644 --- a/src/Core/Json/JsonDecoder.php +++ b/src/Core/Json/JsonDecoder.php @@ -20,7 +20,7 @@ public static function decodeString(string $json): string { $decoded = self::decode($json); if (!is_string($decoded)) { - throw new JsonException("Unexpected non-string json value: " . $json); + throw new JsonException("Unexpected non-string json value: $json"); } return $decoded; } @@ -36,7 +36,7 @@ public static function decodeBool(string $json): bool { $decoded = self::decode($json); if (!is_bool($decoded)) { - throw new JsonException("Unexpected non-boolean json value: " . $json); + throw new JsonException("Unexpected non-boolean json value: $json"); } return $decoded; } @@ -52,7 +52,7 @@ public static function decodeDateTime(string $json): DateTime { $decoded = self::decode($json); if (!is_string($decoded)) { - throw new JsonException("Unexpected non-string json value for datetime: " . $json); + throw new JsonException("Unexpected non-string json value for datetime: $json"); } return JsonDeserializer::deserializeDateTime($decoded); } @@ -68,7 +68,7 @@ public static function decodeDate(string $json): DateTime { $decoded = self::decode($json); if (!is_string($decoded)) { - throw new JsonException("Unexpected non-string json value for date: " . $json); + throw new JsonException("Unexpected non-string json value for date: $json"); } return JsonDeserializer::deserializeDate($decoded); } @@ -84,7 +84,7 @@ public static function decodeFloat(string $json): float { $decoded = self::decode($json); if (!is_float($decoded)) { - throw new JsonException("Unexpected non-float json value: " . $json); + throw new JsonException("Unexpected non-float json value: $json"); } return $decoded; } @@ -100,7 +100,7 @@ public static function decodeInt(string $json): int { $decoded = self::decode($json); if (!is_int($decoded)) { - throw new JsonException("Unexpected non-integer json value: " . $json); + throw new JsonException("Unexpected non-integer json value: $json"); } return $decoded; } @@ -117,7 +117,7 @@ public static function decodeArray(string $json, array $type): array { $decoded = self::decode($json); if (!is_array($decoded)) { - throw new JsonException("Unexpected non-array json value: " . $json); + throw new JsonException("Unexpected non-array json value: $json"); } return JsonDeserializer::deserializeArray($decoded, $type); } diff --git a/src/Core/Json/JsonDeserializer.php b/src/Core/Json/JsonDeserializer.php index 518daccf..b43b2c1e 100644 --- a/src/Core/Json/JsonDeserializer.php +++ b/src/Core/Json/JsonDeserializer.php @@ -45,9 +45,9 @@ public static function deserializeDate(string $date): DateTime /** * Deserializes an array based on type annotations (either a list or a map). * - * @param mixed[]|array $data The array to be deserialized. - * @param mixed[]|array $type The type definition from the annotation. - * @return mixed[]|array The deserialized array. + * @param array $data The array to be deserialized. + * @param array $type The type definition from the annotation. + * @return array The deserialized array. * @throws JsonException If deserialization fails. */ public static function deserializeArray(array $data, array $type): array @@ -75,7 +75,7 @@ private static function deserializeValue(mixed $data, mixed $type): mixed return self::deserializeArray((array)$data, $type); } - if (gettype($type) != "string") { + if (gettype($type) !== "string") { throw new JsonException("Unexpected non-string type."); } @@ -103,7 +103,7 @@ public static function deserializeUnion(mixed $data, Union $type): mixed } $readableType = Utils::getReadableType($data); throw new JsonException( - "Cannot deserialize value of type $readableType with any of the union types: " . $type + "Cannot deserialize value of type $readableType with any of the union types: $type" ); } @@ -134,6 +134,7 @@ private static function deserializeSingleValue(mixed $data, string $type): mixed } if (class_exists($type) && is_array($data)) { + /** @var array $data */ return self::deserializeObject($data, $type); } @@ -143,6 +144,11 @@ private static function deserializeSingleValue(mixed $data, string $type): mixed return (float) $data; } + // Handle bools as a special case since gettype($data) returns "boolean" for bool values in PHP. + if ($type === 'bool' && is_bool($data)) { + return $data; + } + if (gettype($data) === $type) { return $data; } @@ -171,19 +177,24 @@ public static function deserializeObject(array $data, string $type): object /** * Deserializes a map (associative array) with defined key and value types. * - * @param array $data The associative array to deserialize. - * @param array $type The type definition for the map. + * @param array $data The associative array to deserialize. + * @param array $type The type definition for the map. * @return array The deserialized map. * @throws JsonException If deserialization fails. */ private static function deserializeMap(array $data, array $type): array { $keyType = array_key_first($type); + if ($keyType === null) { + throw new JsonException("Unexpected no key in ArrayType."); + } + $keyType = (string) $keyType; $valueType = $type[$keyType]; + /** @var array $result */ $result = []; foreach ($data as $key => $item) { - $key = Utils::castKey($key, (string)$keyType); + $key = (string) Utils::castKey($key, $keyType); $result[$key] = self::deserializeValue($item, $valueType); } @@ -193,14 +204,15 @@ private static function deserializeMap(array $data, array $type): array /** * Deserializes a list (indexed array) with a defined value type. * - * @param array $data The list to deserialize. - * @param array $type The type definition for the list. + * @param array $data The list to deserialize. + * @param array $type The type definition for the list. * @return array The deserialized list. * @throws JsonException If deserialization fails. */ private static function deserializeList(array $data, array $type): array { $valueType = $type[0]; + /** @var array */ return array_map(fn ($item) => self::deserializeValue($item, $valueType), $data); } } diff --git a/src/Core/Json/JsonSerializableType.php b/src/Core/Json/JsonSerializableType.php index 8ae4a6f8..5df36f78 100644 --- a/src/Core/Json/JsonSerializableType.php +++ b/src/Core/Json/JsonSerializableType.php @@ -19,6 +19,9 @@ abstract class JsonSerializableType implements \JsonSerializable /** @var array Extra properties from JSON that don't map to class properties */ private array $__additionalProperties = []; + /** @var array Properties that have been explicitly set via setter methods */ + private array $__explicitlySetProperties = []; + /** * Serializes the object to a JSON string. * @@ -28,7 +31,7 @@ abstract class JsonSerializableType implements \JsonSerializable public function toJson(): string { $serializedObject = $this->jsonSerialize(); - $encoded = JsonEncoder::encode($serializedObject); + $encoded = JsonEncoder::encode(empty($serializedObject) ? new \stdClass() : $serializedObject); if (!$encoded) { throw new Exception("Could not encode type"); } @@ -47,7 +50,7 @@ public function jsonSerialize(): array $reflectionClass = new \ReflectionClass($this); foreach ($reflectionClass->getProperties() as $property) { $jsonKey = self::getJsonKey($property); - if ($jsonKey == null) { + if ($jsonKey === null) { continue; } $value = $property->getValue($this); @@ -75,12 +78,13 @@ public function jsonSerialize(): array $value = JsonSerializer::serializeArray($value, $arrayType); } - // Handle object - if (is_object($value)) { + // Handle object (skip stdClass since it's already serialized, e.g. from union processing) + if (is_object($value) && !($value instanceof \stdClass)) { $value = JsonSerializer::serializeObject($value); } - if ($value !== null) { + // Include the value if it's not null, OR if it was explicitly set (even to null) + if ($value !== null || array_key_exists($property->getName(), $this->__explicitlySetProperties)) { $result[$jsonKey] = $value; } } @@ -101,7 +105,9 @@ public static function fromJson(string $json): static if (!is_array($decodedJson)) { throw new JsonException("Unexpected non-array decoded type: " . gettype($decodedJson)); } - return self::jsonDeserialize($decodedJson); + /** @var array $decodedJson */ + // static:: (not self::) so subclasses' typed jsonDeserialize overrides are dispatched via late static binding. + return static::jsonDeserialize($decodedJson); } /** @@ -140,12 +146,14 @@ public static function jsonDeserialize(array $data): static $dateTypeAttr = $property->getAttributes(Date::class)[0] ?? null; if ($dateTypeAttr) { $dateType = $dateTypeAttr->newInstance()->type; - if (!is_string($value)) { - throw new JsonException("Unexpected non-string type for date."); + if ($value !== null) { + if (!is_string($value)) { + throw new JsonException("Unexpected non-string type for date."); + } + $value = ($dateType === Date::TYPE_DATE) + ? JsonDeserializer::deserializeDate($value) + : JsonDeserializer::deserializeDateTime($value); } - $value = ($dateType === Date::TYPE_DATE) - ? JsonDeserializer::deserializeDate($value) - : JsonDeserializer::deserializeDateTime($value); } // Handle Array annotation @@ -165,7 +173,9 @@ public static function jsonDeserialize(array $data): static // Handle object $type = $property->getType(); if (is_array($value) && $type instanceof ReflectionNamedType && !$type->isBuiltin()) { - $value = JsonDeserializer::deserializeObject($value, $type->getName()); + /** @var array $arrayValue */ + $arrayValue = $value; + $value = JsonDeserializer::deserializeObject($arrayValue, $type->getName()); } $args[$property->getName()] = $value; @@ -174,7 +184,7 @@ public static function jsonDeserialize(array $data): static // Fill in any missing properties with defaults foreach ($properties as $property) { if (!isset($args[$property->getName()])) { - $args[$property->getName()] = $property->getDefaultValue() ?? null; + $args[$property->getName()] = $property->hasDefaultValue() ? $property->getDefaultValue() : null; } } @@ -193,6 +203,17 @@ public function getAdditionalProperties(): array return $this->__additionalProperties; } + /** + * Mark a property as explicitly set. + * This ensures the property will be included in JSON serialization even if null. + * + * @param string $propertyName The name of the property to mark as explicitly set. + */ + protected function _setField(string $propertyName): void + { + $this->__explicitlySetProperties[$propertyName] = true; + } + /** * Retrieves the JSON key associated with a property. * diff --git a/src/Core/Json/JsonSerializer.php b/src/Core/Json/JsonSerializer.php index b7500d7e..c2063cb3 100644 --- a/src/Core/Json/JsonSerializer.php +++ b/src/Core/Json/JsonSerializer.php @@ -41,12 +41,12 @@ public static function serializeDateTime(DateTime $date): string /** * Serializes an array based on type annotations (either a list or map). * - * @param mixed[]|array $data The array to be serialized. - * @param mixed[]|array $type The type definition from the annotation. - * @return mixed[]|array The serialized array. + * @param array $data The array to be serialized. + * @param array $type The type definition from the annotation. + * @return array|\stdClass The serialized array, or stdClass if empty map. * @throws JsonException If serialization fails. */ - public static function serializeArray(array $data, array $type): array + public static function serializeArray(array $data, array $type): array|\stdClass { return Utils::isMapType($type) ? self::serializeMap($data, $type) @@ -71,7 +71,7 @@ private static function serializeValue(mixed $data, mixed $type): mixed return self::serializeArray((array)$data, $type); } - if (gettype($type) != "string") { + if (gettype($type) !== "string") { throw new JsonException("Unexpected non-string type."); } @@ -98,7 +98,7 @@ public static function serializeUnion(mixed $data, Union $unionType): mixed } $readableType = Utils::getReadableType($data); throw new JsonException( - "Cannot serialize value of type $readableType with any of the union types: " . $unionType + "Cannot serialize value of type $readableType with any of the union types: $unionType" ); } @@ -133,6 +133,11 @@ private static function serializeSingleValue(mixed $data, string $type): mixed return $data; } + // Handle bools as a special case since gettype($data) returns "boolean" for bool values in PHP. + if ($type === 'bool' && is_bool($data)) { + return $data; + } + if (gettype($data) === $type) { return $data; } @@ -153,28 +158,37 @@ public static function serializeObject(object $data): mixed $type = get_class($data); throw new JsonException("Class $type must implement JsonSerializable."); } - return $data->jsonSerialize(); + $result = $data->jsonSerialize(); + if (is_array($result) && empty($result)) { + return new \stdClass(); + } + return $result; } /** * Serializes a map (associative array) with defined key and value types. * - * @param array $data The associative array to serialize. - * @param array $type The type definition for the map. - * @return array The serialized map. + * @param array $data The associative array to serialize. + * @param array $type The type definition for the map. + * @return array|\stdClass The serialized map, or stdClass if empty. * @throws JsonException If serialization fails. */ - private static function serializeMap(array $data, array $type): array + private static function serializeMap(array $data, array $type): array|\stdClass { + if (empty($data)) { + return new \stdClass(); + } $keyType = array_key_first($type); if ($keyType === null) { throw new JsonException("Unexpected no key in ArrayType."); } + $keyType = (string) $keyType; $valueType = $type[$keyType]; + /** @var array $result */ $result = []; foreach ($data as $key => $item) { - $key = Utils::castKey($key, $keyType); + $key = (string) Utils::castKey($key, $keyType); $result[$key] = self::serializeValue($item, $valueType); } @@ -184,14 +198,15 @@ private static function serializeMap(array $data, array $type): array /** * Serializes a list (indexed array) where only the value type is defined. * - * @param array $data The list to serialize. - * @param array $type The type definition for the list. + * @param array $data The list to serialize. + * @param array $type The type definition for the list. * @return array The serialized list. * @throws JsonException If serialization fails. */ private static function serializeList(array $data, array $type): array { $valueType = $type[0]; + /** @var array */ return array_map(fn ($item) => self::serializeValue($item, $valueType), $data); } } diff --git a/src/Core/Json/Utils.php b/src/Core/Json/Utils.php index 515c1942..8145c3f8 100644 --- a/src/Core/Json/Utils.php +++ b/src/Core/Json/Utils.php @@ -11,7 +11,7 @@ class Utils /** * Determines if the given type represents a map. * - * @param mixed[]|array $type The type definition from the annotation. + * @param array $type The type definition from the annotation. * @return bool True if the type is a map, false if it's a list. */ public static function isMapType(array $type): bool @@ -24,19 +24,20 @@ public static function isMapType(array $type): bool * * @param mixed $key The key to be cast. * @param string $keyType The type to cast the key to ('string', 'integer', 'float'). - * @return mixed The casted key. + * @return int|string The casted key. * @throws JsonException */ - public static function castKey(mixed $key, string $keyType): mixed + public static function castKey(mixed $key, string $keyType): int|string { if (!is_scalar($key)) { throw new JsonException("Key must be a scalar type."); } return match ($keyType) { 'integer' => (int)$key, - 'float' => (float)$key, + // PHP arrays don't support float keys; truncate to int + 'float' => (int)$key, 'string' => (string)$key, - default => $key, + default => is_int($key) ? $key : (string)$key, }; } diff --git a/src/Core/Multipart/MultipartFormData.php b/src/Core/Multipart/MultipartFormData.php index 12165f9f..a05cc828 100644 --- a/src/Core/Multipart/MultipartFormData.php +++ b/src/Core/Multipart/MultipartFormData.php @@ -2,6 +2,7 @@ namespace Intercom\Core\Multipart; +use Http\Message\MultipartStream\MultipartStreamBuilder; use Psr\Http\Message\StreamInterface; class MultipartFormData @@ -23,8 +24,8 @@ public function add( string|int|bool|float|StreamInterface $value, ?string $contentType = null, ): void { - $headers = $contentType != null ? ['Content-Type' => $contentType] : null; - self::addPart( + $headers = $contentType !== null ? ['Content-Type' => $contentType] : null; + $this->addPart( new MultipartFormDataPart( name: $name, value: $value, @@ -44,18 +45,14 @@ public function addPart(MultipartFormDataPart $part): void } /** - * Converts the multipart form data into an array suitable - * for Guzzle's multipart form data. + * Adds all parts to a MultipartStreamBuilder. * - * @return array - * }> + * @param MultipartStreamBuilder $builder */ - public function toArray(): array + public function addToBuilder(MultipartStreamBuilder $builder): void { - return array_map(fn ($part) => $part->toArray(), $this->parts); + foreach ($this->parts as $part) { + $part->addToBuilder($builder); + } } } diff --git a/src/Core/Multipart/MultipartFormDataPart.php b/src/Core/Multipart/MultipartFormDataPart.php index 5e88f267..f5a8771a 100644 --- a/src/Core/Multipart/MultipartFormDataPart.php +++ b/src/Core/Multipart/MultipartFormDataPart.php @@ -2,7 +2,7 @@ namespace Intercom\Core\Multipart; -use GuzzleHttp\Psr7\Utils; +use Http\Message\MultipartStream\MultipartStreamBuilder; use Psr\Http\Message\StreamInterface; class MultipartFormDataPart @@ -13,9 +13,9 @@ class MultipartFormDataPart private string $name; /** - * @var StreamInterface + * @var StreamInterface|string */ - private StreamInterface $contents; + private StreamInterface|string $contents; /** * @var ?string @@ -40,37 +40,23 @@ public function __construct( ?array $headers = null ) { $this->name = $name; - $this->contents = Utils::streamFor($value); + $this->contents = $value instanceof StreamInterface ? $value : (string)$value; $this->filename = $filename; $this->headers = $headers; } /** - * Converts the multipart form data part into an array suitable - * for Guzzle's multipart form data. + * Adds this part to a MultipartStreamBuilder. * - * @return array{ - * name: string, - * contents: StreamInterface, - * filename?: string, - * headers?: array - * } + * @param MultipartStreamBuilder $builder */ - public function toArray(): array + public function addToBuilder(MultipartStreamBuilder $builder): void { - $formData = [ - 'name' => $this->name, - 'contents' => $this->contents, - ]; + $options = array_filter([ + 'filename' => $this->filename, + 'headers' => $this->headers, + ], fn ($value) => $value !== null); - if ($this->filename != null) { - $formData['filename'] = $this->filename; - } - - if ($this->headers != null) { - $formData['headers'] = $this->headers; - } - - return $formData; + $builder->addResource($this->name, $this->contents, $options); } } diff --git a/src/Core/Pagination/CursorPager.php b/src/Core/Pagination/CursorPager.php index 3b9b340d..601e0a23 100644 --- a/src/Core/Pagination/CursorPager.php +++ b/src/Core/Pagination/CursorPager.php @@ -5,7 +5,7 @@ use Generator; /** - * @template TRequest + * @template TRequest of object * @template TResponse * @template TItem * @template TCursor diff --git a/src/Core/Pagination/OffsetPager.php b/src/Core/Pagination/OffsetPager.php index e47d5b29..1543a1d0 100644 --- a/src/Core/Pagination/OffsetPager.php +++ b/src/Core/Pagination/OffsetPager.php @@ -5,7 +5,7 @@ use Generator; /** - * @template TRequest + * @template TRequest of object * @template TResponse * @template TItem * @extends Pager diff --git a/src/Core/Pagination/PaginationHelper.php b/src/Core/Pagination/PaginationHelper.php index 6e59a920..3ca9f8c2 100644 --- a/src/Core/Pagination/PaginationHelper.php +++ b/src/Core/Pagination/PaginationHelper.php @@ -59,7 +59,7 @@ public static function setDeep(mixed $object, array $propertyPath, mixed $value) if ($next === null) { $propertyType = $reflectionProperty->getType(); if ($propertyType === null) { - throw new RuntimeException("Property type is null for property '$part' in class '" . $reflectionClass->getName() . "'"); + throw new RuntimeException("Property type is null for property '$part' in class '{$reflectionClass->getName()}'"); } /** @var class-string $nextTypeName */ diff --git a/src/CustomChannelEvents/CustomChannelEventsClient.php b/src/CustomChannelEvents/CustomChannelEventsClient.php index 61b3dc15..a3b86b09 100644 --- a/src/CustomChannelEvents/CustomChannelEventsClient.php +++ b/src/CustomChannelEvents/CustomChannelEventsClient.php @@ -2,7 +2,7 @@ namespace Intercom\CustomChannelEvents; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Types\CustomChannelBaseEvent; use Intercom\Types\CustomChannelNotificationResponse; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\CustomChannelEvents\Requests\NotifyNewMessageRequest; use Intercom\CustomChannelEvents\Requests\NotifyQuickReplySelectedRequest; @@ -58,6 +57,22 @@ public function __construct( * 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. * + * Example: + * ```php + * $client->customChannelEvents->notifyNewConversation( + * new CustomChannelBaseEvent([ + * 'eventId' => 'event_id', + * 'externalConversationId' => 'external_conversation_id', + * 'contact' => new CustomChannelContact([ + * 'type' => CustomChannelContactType::User->value, + * 'externalId' => 'external_id', + * 'name' => 'name', + * 'email' => 'email', + * ]), + * ]), + * ); + * ``` + * * @param CustomChannelBaseEvent $request * @param ?array{ * baseUrl?: string, @@ -67,11 +82,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return CustomChannelNotificationResponse + * @return ?CustomChannelNotificationResponse * @throws IntercomException * @throws IntercomApiException */ - public function notifyNewConversation(CustomChannelBaseEvent $request, ?array $options = null): CustomChannelNotificationResponse + public function notifyNewConversation(CustomChannelBaseEvent $request, ?array $options = null): ?CustomChannelNotificationResponse { $options = array_merge($this->options, $options ?? []); try { @@ -87,20 +102,13 @@ public function notifyNewConversation(CustomChannelBaseEvent $request, ?array $o $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -115,6 +123,23 @@ public function notifyNewConversation(CustomChannelBaseEvent $request, ?array $o * 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. * + * Example: + * ```php + * $client->customChannelEvents->notifyNewMessage( + * new NotifyNewMessageRequest([ + * 'eventId' => 'event_id', + * 'externalConversationId' => 'external_conversation_id', + * 'contact' => new CustomChannelContact([ + * 'type' => CustomChannelContactType::User->value, + * 'externalId' => 'external_id', + * 'name' => 'name', + * 'email' => 'email', + * ]), + * 'body' => 'body', + * ]), + * ); + * ``` + * * @param NotifyNewMessageRequest $request * @param ?array{ * baseUrl?: string, @@ -124,11 +149,11 @@ public function notifyNewConversation(CustomChannelBaseEvent $request, ?array $o * queryParameters?: array, * bodyProperties?: array, * } $options - * @return CustomChannelNotificationResponse + * @return ?CustomChannelNotificationResponse * @throws IntercomException * @throws IntercomApiException */ - public function notifyNewMessage(NotifyNewMessageRequest $request, ?array $options = null): CustomChannelNotificationResponse + public function notifyNewMessage(NotifyNewMessageRequest $request, ?array $options = null): ?CustomChannelNotificationResponse { $options = array_merge($this->options, $options ?? []); try { @@ -144,20 +169,13 @@ public function notifyNewMessage(NotifyNewMessageRequest $request, ?array $optio $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -172,6 +190,23 @@ public function notifyNewMessage(NotifyNewMessageRequest $request, ?array $optio * 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. * + * Example: + * ```php + * $client->customChannelEvents->notifyQuickReplySelected( + * new NotifyQuickReplySelectedRequest([ + * 'eventId' => 'evt_67890', + * 'externalConversationId' => 'conv_13579', + * 'contact' => new CustomChannelContact([ + * 'type' => CustomChannelContactType::User->value, + * 'externalId' => 'user_003', + * 'name' => 'Alice Example', + * 'email' => 'alice@example.com', + * ]), + * 'quickReplyOptionId' => '1234', + * ]), + * ); + * ``` + * * @param NotifyQuickReplySelectedRequest $request * @param ?array{ * baseUrl?: string, @@ -181,11 +216,11 @@ public function notifyNewMessage(NotifyNewMessageRequest $request, ?array $optio * queryParameters?: array, * bodyProperties?: array, * } $options - * @return CustomChannelNotificationResponse + * @return ?CustomChannelNotificationResponse * @throws IntercomException * @throws IntercomApiException */ - public function notifyQuickReplySelected(NotifyQuickReplySelectedRequest $request, ?array $options = null): CustomChannelNotificationResponse + public function notifyQuickReplySelected(NotifyQuickReplySelectedRequest $request, ?array $options = null): ?CustomChannelNotificationResponse { $options = array_merge($this->options, $options ?? []); try { @@ -201,20 +236,13 @@ public function notifyQuickReplySelected(NotifyQuickReplySelectedRequest $reques $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -229,6 +257,26 @@ public function notifyQuickReplySelected(NotifyQuickReplySelectedRequest $reques * 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. * + * Example: + * ```php + * $client->customChannelEvents->notifyAttributeCollected( + * new NotifyAttributeCollectedRequest([ + * 'eventId' => 'event_id', + * 'externalConversationId' => 'external_conversation_id', + * 'contact' => new CustomChannelContact([ + * 'type' => CustomChannelContactType::User->value, + * 'externalId' => 'external_id', + * 'name' => 'name', + * 'email' => 'email', + * ]), + * 'attribute' => new CustomChannelAttribute([ + * 'id' => 'id', + * 'value' => 'value', + * ]), + * ]), + * ); + * ``` + * * @param NotifyAttributeCollectedRequest $request * @param ?array{ * baseUrl?: string, @@ -238,11 +286,11 @@ public function notifyQuickReplySelected(NotifyQuickReplySelectedRequest $reques * queryParameters?: array, * bodyProperties?: array, * } $options - * @return CustomChannelNotificationResponse + * @return ?CustomChannelNotificationResponse * @throws IntercomException * @throws IntercomApiException */ - public function notifyAttributeCollected(NotifyAttributeCollectedRequest $request, ?array $options = null): CustomChannelNotificationResponse + public function notifyAttributeCollected(NotifyAttributeCollectedRequest $request, ?array $options = null): ?CustomChannelNotificationResponse { $options = array_merge($this->options, $options ?? []); try { @@ -258,20 +306,13 @@ public function notifyAttributeCollected(NotifyAttributeCollectedRequest $reques $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } diff --git a/src/CustomChannelEvents/Requests/NotifyAttributeCollectedRequest.php b/src/CustomChannelEvents/Requests/NotifyAttributeCollectedRequest.php index e553b23c..23b6003d 100644 --- a/src/CustomChannelEvents/Requests/NotifyAttributeCollectedRequest.php +++ b/src/CustomChannelEvents/Requests/NotifyAttributeCollectedRequest.php @@ -49,6 +49,7 @@ public function getAttribute(): CustomChannelAttribute public function setAttribute(CustomChannelAttribute $value): self { $this->attribute = $value; + $this->_setField('attribute'); return $this; } } diff --git a/src/CustomChannelEvents/Requests/NotifyNewMessageRequest.php b/src/CustomChannelEvents/Requests/NotifyNewMessageRequest.php index c505f7f9..f21d33e6 100644 --- a/src/CustomChannelEvents/Requests/NotifyNewMessageRequest.php +++ b/src/CustomChannelEvents/Requests/NotifyNewMessageRequest.php @@ -48,6 +48,7 @@ public function getBody(): string public function setBody(string $value): self { $this->body = $value; + $this->_setField('body'); return $this; } } diff --git a/src/CustomChannelEvents/Requests/NotifyQuickReplySelectedRequest.php b/src/CustomChannelEvents/Requests/NotifyQuickReplySelectedRequest.php index 8c8ab64c..ffe4a443 100644 --- a/src/CustomChannelEvents/Requests/NotifyQuickReplySelectedRequest.php +++ b/src/CustomChannelEvents/Requests/NotifyQuickReplySelectedRequest.php @@ -48,6 +48,7 @@ public function getQuickReplyOptionId(): string public function setQuickReplyOptionId(string $value): self { $this->quickReplyOptionId = $value; + $this->_setField('quickReplyOptionId'); return $this; } } diff --git a/src/CustomObjectInstances/CustomObjectInstancesClient.php b/src/CustomObjectInstances/CustomObjectInstancesClient.php index 35109a42..48a2db99 100644 --- a/src/CustomObjectInstances/CustomObjectInstancesClient.php +++ b/src/CustomObjectInstances/CustomObjectInstancesClient.php @@ -2,7 +2,7 @@ namespace Intercom\CustomObjectInstances; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\CustomObjectInstances\Requests\GetCustomObjectInstancesByExternalIdRequest; use Intercom\CustomObjectInstances\Types\CustomObjectInstance; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\CustomObjectInstances\Requests\CreateOrUpdateCustomObjectInstanceRequest; use Intercom\CustomObjectInstances\Requests\DeleteCustomObjectInstancesByIdRequest; @@ -59,6 +58,16 @@ public function __construct( /** * Fetch a Custom Object Instance by external_id. * + * Example: + * ```php + * $client->customObjectInstances->getCustomObjectInstancesByExternalId( + * new GetCustomObjectInstancesByExternalIdRequest([ + * 'customObjectTypeIdentifier' => 'Order', + * 'externalId' => 'external_id', + * ]), + * ); + * ``` + * * @param GetCustomObjectInstancesByExternalIdRequest $request * @param ?array{ * baseUrl?: string, @@ -81,7 +90,7 @@ public function getCustomObjectInstancesByExternalId(GetCustomObjectInstancesByE $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "custom_object_instances/{$request->getCustomObjectTypeIdentifier()}", + path: "custom_object_instances/" . RawClient::encodePathParam($request->getCustomObjectTypeIdentifier()), method: HttpMethod::GET, query: $query, ), @@ -97,16 +106,6 @@ public function getCustomObjectInstancesByExternalId(GetCustomObjectInstancesByE } } 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); } @@ -120,6 +119,22 @@ public function getCustomObjectInstancesByExternalId(GetCustomObjectInstancesByE /** * Create or update a custom object instance * + * Example: + * ```php + * $client->customObjectInstances->createCustomObjectInstances( + * new CreateOrUpdateCustomObjectInstanceRequest([ + * 'customObjectTypeIdentifier' => 'Order', + * 'externalId' => '123', + * 'externalCreatedAt' => 1392036272, + * 'externalUpdatedAt' => 1392036272, + * 'customAttributes' => [ + * 'order_number' => 'ORDER-12345', + * 'total_amount' => 'custom_attributes', + * ], + * ]), + * ); + * ``` + * * @param CreateOrUpdateCustomObjectInstanceRequest $request * @param ?array{ * baseUrl?: string, @@ -140,7 +155,7 @@ public function createCustomObjectInstances(CreateOrUpdateCustomObjectInstanceRe $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "custom_object_instances/{$request->getCustomObjectTypeIdentifier()}", + path: "custom_object_instances/" . RawClient::encodePathParam($request->getCustomObjectTypeIdentifier()), method: HttpMethod::POST, body: $request, ), @@ -156,16 +171,6 @@ public function createCustomObjectInstances(CreateOrUpdateCustomObjectInstanceRe } } 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); } @@ -179,6 +184,16 @@ public function createCustomObjectInstances(CreateOrUpdateCustomObjectInstanceRe /** * Delete a single Custom Object instance by external_id. * + * Example: + * ```php + * $client->customObjectInstances->deleteCustomObjectInstancesById( + * new DeleteCustomObjectInstancesByIdRequest([ + * 'customObjectTypeIdentifier' => 'Order', + * 'externalId' => 'external_id', + * ]), + * ); + * ``` + * * @param DeleteCustomObjectInstancesByIdRequest $request * @param ?array{ * baseUrl?: string, @@ -188,11 +203,11 @@ public function createCustomObjectInstances(CreateOrUpdateCustomObjectInstanceRe * queryParameters?: array, * bodyProperties?: array, * } $options - * @return CustomObjectInstanceDeleted + * @return ?CustomObjectInstanceDeleted * @throws IntercomException * @throws IntercomApiException */ - public function deleteCustomObjectInstancesById(DeleteCustomObjectInstancesByIdRequest $request, ?array $options = null): CustomObjectInstanceDeleted + public function deleteCustomObjectInstancesById(DeleteCustomObjectInstancesByIdRequest $request, ?array $options = null): ?CustomObjectInstanceDeleted { $options = array_merge($this->options, $options ?? []); $query = []; @@ -201,7 +216,7 @@ public function deleteCustomObjectInstancesById(DeleteCustomObjectInstancesByIdR $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "custom_object_instances/{$request->getCustomObjectTypeIdentifier()}", + path: "custom_object_instances/" . RawClient::encodePathParam($request->getCustomObjectTypeIdentifier()), method: HttpMethod::DELETE, query: $query, ), @@ -210,20 +225,13 @@ public function deleteCustomObjectInstancesById(DeleteCustomObjectInstancesByIdR $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -237,6 +245,16 @@ public function deleteCustomObjectInstancesById(DeleteCustomObjectInstancesByIdR /** * Fetch a Custom Object Instance by id. * + * Example: + * ```php + * $client->customObjectInstances->getCustomObjectInstancesById( + * new GetCustomObjectInstancesByIdRequest([ + * 'customObjectTypeIdentifier' => 'Order', + * 'customObjectInstanceId' => 'custom_object_instance_id', + * ]), + * ); + * ``` + * * @param GetCustomObjectInstancesByIdRequest $request * @param ?array{ * baseUrl?: string, @@ -257,7 +275,7 @@ public function getCustomObjectInstancesById(GetCustomObjectInstancesByIdRequest $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "custom_object_instances/{$request->getCustomObjectTypeIdentifier()}/{$request->getCustomObjectInstanceId()}", + path: "custom_object_instances/" . RawClient::encodePathParam($request->getCustomObjectTypeIdentifier()) . "/" . RawClient::encodePathParam($request->getCustomObjectInstanceId()), method: HttpMethod::GET, ), $options, @@ -272,16 +290,6 @@ public function getCustomObjectInstancesById(GetCustomObjectInstancesByIdRequest } } 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); } @@ -295,6 +303,16 @@ public function getCustomObjectInstancesById(GetCustomObjectInstancesByIdRequest /** * Delete a single Custom Object instance using the Intercom defined id. * + * Example: + * ```php + * $client->customObjectInstances->deleteCustomObjectInstancesByExternalId( + * new DeleteCustomObjectInstancesByExternalIdRequest([ + * 'customObjectTypeIdentifier' => 'Order', + * 'customObjectInstanceId' => 'custom_object_instance_id', + * ]), + * ); + * ``` + * * @param DeleteCustomObjectInstancesByExternalIdRequest $request * @param ?array{ * baseUrl?: string, @@ -304,18 +322,18 @@ public function getCustomObjectInstancesById(GetCustomObjectInstancesByIdRequest * queryParameters?: array, * bodyProperties?: array, * } $options - * @return CustomObjectInstanceDeleted + * @return ?CustomObjectInstanceDeleted * @throws IntercomException * @throws IntercomApiException */ - public function deleteCustomObjectInstancesByExternalId(DeleteCustomObjectInstancesByExternalIdRequest $request, ?array $options = null): CustomObjectInstanceDeleted + 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()}", + path: "custom_object_instances/" . RawClient::encodePathParam($request->getCustomObjectTypeIdentifier()) . "/" . RawClient::encodePathParam($request->getCustomObjectInstanceId()), method: HttpMethod::DELETE, ), $options, @@ -323,20 +341,13 @@ public function deleteCustomObjectInstancesByExternalId(DeleteCustomObjectInstan $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } diff --git a/src/CustomObjectInstances/Requests/CreateOrUpdateCustomObjectInstanceRequest.php b/src/CustomObjectInstances/Requests/CreateOrUpdateCustomObjectInstanceRequest.php index 87d7f75a..2dbf8482 100644 --- a/src/CustomObjectInstances/Requests/CreateOrUpdateCustomObjectInstanceRequest.php +++ b/src/CustomObjectInstances/Requests/CreateOrUpdateCustomObjectInstanceRequest.php @@ -71,6 +71,7 @@ public function getCustomObjectTypeIdentifier(): string public function setCustomObjectTypeIdentifier(string $value): self { $this->customObjectTypeIdentifier = $value; + $this->_setField('customObjectTypeIdentifier'); return $this; } @@ -88,6 +89,7 @@ public function getExternalId(): ?string public function setExternalId(?string $value = null): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } @@ -105,6 +107,7 @@ public function getExternalCreatedAt(): ?int public function setExternalCreatedAt(?int $value = null): self { $this->externalCreatedAt = $value; + $this->_setField('externalCreatedAt'); return $this; } @@ -122,6 +125,7 @@ public function getExternalUpdatedAt(): ?int public function setExternalUpdatedAt(?int $value = null): self { $this->externalUpdatedAt = $value; + $this->_setField('externalUpdatedAt'); return $this; } @@ -139,6 +143,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } } diff --git a/src/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByExternalIdRequest.php b/src/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByExternalIdRequest.php index 23b3ac87..3d3510e2 100644 --- a/src/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByExternalIdRequest.php +++ b/src/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByExternalIdRequest.php @@ -43,6 +43,7 @@ public function getCustomObjectTypeIdentifier(): string public function setCustomObjectTypeIdentifier(string $value): self { $this->customObjectTypeIdentifier = $value; + $this->_setField('customObjectTypeIdentifier'); return $this; } @@ -60,6 +61,7 @@ public function getCustomObjectInstanceId(): string public function setCustomObjectInstanceId(string $value): self { $this->customObjectInstanceId = $value; + $this->_setField('customObjectInstanceId'); return $this; } } diff --git a/src/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByIdRequest.php b/src/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByIdRequest.php index ce7cd94c..47d7dc1f 100644 --- a/src/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByIdRequest.php +++ b/src/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByIdRequest.php @@ -12,7 +12,7 @@ class DeleteCustomObjectInstancesByIdRequest extends JsonSerializableType private string $customObjectTypeIdentifier; /** - * @var string $externalId + * @var string $externalId The unique identifier for the instance in the external system it originated from. */ private string $externalId; @@ -43,6 +43,7 @@ public function getCustomObjectTypeIdentifier(): string public function setCustomObjectTypeIdentifier(string $value): self { $this->customObjectTypeIdentifier = $value; + $this->_setField('customObjectTypeIdentifier'); return $this; } @@ -60,6 +61,7 @@ public function getExternalId(): string public function setExternalId(string $value): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } } diff --git a/src/CustomObjectInstances/Requests/GetCustomObjectInstancesByExternalIdRequest.php b/src/CustomObjectInstances/Requests/GetCustomObjectInstancesByExternalIdRequest.php index dd31e84b..7ebe1f55 100644 --- a/src/CustomObjectInstances/Requests/GetCustomObjectInstancesByExternalIdRequest.php +++ b/src/CustomObjectInstances/Requests/GetCustomObjectInstancesByExternalIdRequest.php @@ -12,7 +12,7 @@ class GetCustomObjectInstancesByExternalIdRequest extends JsonSerializableType private string $customObjectTypeIdentifier; /** - * @var string $externalId + * @var string $externalId The unique identifier for the instance in the external system it originated from. */ private string $externalId; @@ -43,6 +43,7 @@ public function getCustomObjectTypeIdentifier(): string public function setCustomObjectTypeIdentifier(string $value): self { $this->customObjectTypeIdentifier = $value; + $this->_setField('customObjectTypeIdentifier'); return $this; } @@ -60,6 +61,7 @@ public function getExternalId(): string public function setExternalId(string $value): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } } diff --git a/src/CustomObjectInstances/Requests/GetCustomObjectInstancesByIdRequest.php b/src/CustomObjectInstances/Requests/GetCustomObjectInstancesByIdRequest.php index 71cf8a5c..e2454939 100644 --- a/src/CustomObjectInstances/Requests/GetCustomObjectInstancesByIdRequest.php +++ b/src/CustomObjectInstances/Requests/GetCustomObjectInstancesByIdRequest.php @@ -43,6 +43,7 @@ public function getCustomObjectTypeIdentifier(): string public function setCustomObjectTypeIdentifier(string $value): self { $this->customObjectTypeIdentifier = $value; + $this->_setField('customObjectTypeIdentifier'); return $this; } @@ -60,6 +61,7 @@ public function getCustomObjectInstanceId(): string public function setCustomObjectInstanceId(string $value): self { $this->customObjectInstanceId = $value; + $this->_setField('customObjectInstanceId'); return $this; } } diff --git a/src/CustomObjectInstances/Types/CustomObjectInstance.php b/src/CustomObjectInstances/Types/CustomObjectInstance.php index 85cab79b..1cb80bc9 100644 --- a/src/CustomObjectInstances/Types/CustomObjectInstance.php +++ b/src/CustomObjectInstances/Types/CustomObjectInstance.php @@ -98,6 +98,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -115,6 +116,7 @@ public function getExternalId(): ?string public function setExternalId(?string $value = null): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } @@ -132,6 +134,7 @@ public function getExternalCreatedAt(): ?int public function setExternalCreatedAt(?int $value = null): self { $this->externalCreatedAt = $value; + $this->_setField('externalCreatedAt'); return $this; } @@ -149,6 +152,7 @@ public function getExternalUpdatedAt(): ?int public function setExternalUpdatedAt(?int $value = null): self { $this->externalUpdatedAt = $value; + $this->_setField('externalUpdatedAt'); return $this; } @@ -166,6 +170,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -183,6 +188,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -200,6 +206,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -217,6 +224,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } diff --git a/src/DataAttributes/DataAttributesClient.php b/src/DataAttributes/DataAttributesClient.php index a08503d1..3e4fb3d0 100644 --- a/src/DataAttributes/DataAttributesClient.php +++ b/src/DataAttributes/DataAttributesClient.php @@ -2,7 +2,7 @@ namespace Intercom\DataAttributes; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\DataAttributes\Requests\ListDataAttributesRequest; use Intercom\Types\DataAttributeList; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Types\CreateDataAttributeRequestOptions; use Intercom\Types\CreateDataAttributeRequestOne; @@ -60,6 +59,16 @@ public function __construct( /** * You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. * + * Example: + * ```php + * $client->dataAttributes->list( + * new ListDataAttributesRequest([ + * 'model' => DataAttributesListRequestModel::Contact->value, + * 'includeArchived' => true, + * ]), + * ); + * ``` + * * @param ListDataAttributesRequest $request * @param ?array{ * baseUrl?: string, @@ -69,11 +78,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return DataAttributeList + * @return ?DataAttributeList * @throws IntercomException * @throws IntercomApiException */ - public function list(ListDataAttributesRequest $request = new ListDataAttributesRequest(), ?array $options = null): DataAttributeList + public function list(ListDataAttributesRequest $request = new ListDataAttributesRequest(), ?array $options = null): ?DataAttributeList { $options = array_merge($this->options, $options ?? []); $query = []; @@ -96,20 +105,13 @@ public function list(ListDataAttributesRequest $request = new ListDataAttributes $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return DataAttributeList::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); } @@ -123,6 +125,18 @@ public function list(ListDataAttributesRequest $request = new ListDataAttributes /** * You can create a data attributes for a `contact` or a `company`. * + * Example: + * ```php + * $client->dataAttributes->create( + * new CreateDataAttributeRequestOptions([ + * 'dataType' => 'string', + * 'options' => [ + * new CreateDataAttributeRequestOptionsOptionsItem([]), + * ], + * ]), + * ); + * ``` + * * @param ( * CreateDataAttributeRequestOptions * |CreateDataAttributeRequestOne @@ -135,11 +149,11 @@ public function list(ListDataAttributesRequest $request = new ListDataAttributes * queryParameters?: array, * bodyProperties?: array, * } $options - * @return DataAttribute + * @return ?DataAttribute * @throws IntercomException * @throws IntercomApiException */ - public function create(CreateDataAttributeRequestOptions|CreateDataAttributeRequestOne $request, ?array $options = null): DataAttribute + public function create(CreateDataAttributeRequestOptions|CreateDataAttributeRequestOne $request, ?array $options = null): ?DataAttribute { $options = array_merge($this->options, $options ?? []); try { @@ -155,20 +169,13 @@ public function create(CreateDataAttributeRequestOptions|CreateDataAttributeRequ $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return DataAttribute::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); } @@ -187,6 +194,25 @@ public function create(CreateDataAttributeRequestOptions|CreateDataAttributeRequ * > * > It is currently a dangerous action to execute changing a data attribute's type via the API. You will need to update the type via the UI instead. * + * Example: + * ```php + * $client->dataAttributes->update( + * new UpdateDataAttributeRequest([ + * 'dataAttributeId' => 1, + * 'body' => new UpdateDataAttributeRequestBodyOptions([ + * 'options' => [ + * new UpdateDataAttributeRequestBodyOptionsOptionsItem([ + * 'value' => '1-10', + * ]), + * new UpdateDataAttributeRequestBodyOptionsOptionsItem([ + * 'value' => '11-20', + * ]), + * ], + * ]), + * ]), + * ); + * ``` + * * @param UpdateDataAttributeRequest $request * @param ?array{ * baseUrl?: string, @@ -196,18 +222,18 @@ public function create(CreateDataAttributeRequestOptions|CreateDataAttributeRequ * queryParameters?: array, * bodyProperties?: array, * } $options - * @return DataAttribute + * @return ?DataAttribute * @throws IntercomException * @throws IntercomApiException */ - public function update(UpdateDataAttributeRequest $request, ?array $options = null): DataAttribute + public function update(UpdateDataAttributeRequest $request, ?array $options = null): ?DataAttribute { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "data_attributes/{$request->getDataAttributeId()}", + path: "data_attributes/" . RawClient::encodePathParam($request->getDataAttributeId()), method: HttpMethod::PUT, body: $request->getBody(), ), @@ -216,20 +242,13 @@ public function update(UpdateDataAttributeRequest $request, ?array $options = nu $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return DataAttribute::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); } diff --git a/src/DataAttributes/Requests/ListDataAttributesRequest.php b/src/DataAttributes/Requests/ListDataAttributesRequest.php index 5562a636..9e2a6a23 100644 --- a/src/DataAttributes/Requests/ListDataAttributesRequest.php +++ b/src/DataAttributes/Requests/ListDataAttributesRequest.php @@ -44,6 +44,7 @@ public function getModel(): ?string public function setModel(?string $value = null): self { $this->model = $value; + $this->_setField('model'); return $this; } @@ -61,6 +62,7 @@ public function getIncludeArchived(): ?bool public function setIncludeArchived(?bool $value = null): self { $this->includeArchived = $value; + $this->_setField('includeArchived'); return $this; } } diff --git a/src/DataAttributes/Requests/UpdateDataAttributeRequest.php b/src/DataAttributes/Requests/UpdateDataAttributeRequest.php index b33619e7..01d45737 100644 --- a/src/DataAttributes/Requests/UpdateDataAttributeRequest.php +++ b/src/DataAttributes/Requests/UpdateDataAttributeRequest.php @@ -3,7 +3,7 @@ namespace Intercom\DataAttributes\Requests; use Intercom\Core\Json\JsonSerializableType; -use Intercom\Types\UpdateDataAttributeRequestOptions; +use Intercom\Types\UpdateDataAttributeRequestBodyOptions; class UpdateDataAttributeRequest extends JsonSerializableType { @@ -14,7 +14,7 @@ class UpdateDataAttributeRequest extends JsonSerializableType /** * @var ( - * UpdateDataAttributeRequestOptions + * UpdateDataAttributeRequestBodyOptions * |mixed * ) $body */ @@ -24,7 +24,7 @@ class UpdateDataAttributeRequest extends JsonSerializableType * @param array{ * dataAttributeId: int, * body: ( - * UpdateDataAttributeRequestOptions + * UpdateDataAttributeRequestBodyOptions * |mixed * ), * } $values @@ -50,12 +50,13 @@ public function getDataAttributeId(): int public function setDataAttributeId(int $value): self { $this->dataAttributeId = $value; + $this->_setField('dataAttributeId'); return $this; } /** * @return ( - * UpdateDataAttributeRequestOptions + * UpdateDataAttributeRequestBodyOptions * |mixed * ) */ @@ -66,13 +67,14 @@ public function getBody(): mixed /** * @param ( - * UpdateDataAttributeRequestOptions + * UpdateDataAttributeRequestBodyOptions * |mixed * ) $value */ public function setBody(mixed $value): self { $this->body = $value; + $this->_setField('body'); return $this; } } diff --git a/src/DataAttributes/Types/DataAttribute.php b/src/DataAttributes/Types/DataAttribute.php index 2525dd76..ee77baec 100644 --- a/src/DataAttributes/Types/DataAttribute.php +++ b/src/DataAttributes/Types/DataAttribute.php @@ -170,6 +170,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -187,6 +188,7 @@ public function getId(): ?int public function setId(?int $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -204,6 +206,7 @@ public function getModel(): ?string public function setModel(?string $value = null): self { $this->model = $value; + $this->_setField('model'); return $this; } @@ -221,6 +224,7 @@ public function getName(): string public function setName(string $value): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -238,6 +242,7 @@ public function getFullName(): string public function setFullName(string $value): self { $this->fullName = $value; + $this->_setField('fullName'); return $this; } @@ -255,6 +260,7 @@ public function getLabel(): string public function setLabel(string $value): self { $this->label = $value; + $this->_setField('label'); return $this; } @@ -272,6 +278,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -289,6 +296,7 @@ public function getDataType(): string public function setDataType(string $value): self { $this->dataType = $value; + $this->_setField('dataType'); return $this; } @@ -306,6 +314,7 @@ public function getOptions(): ?array public function setOptions(?array $value = null): self { $this->options = $value; + $this->_setField('options'); return $this; } @@ -323,6 +332,7 @@ public function getApiWritable(): ?bool public function setApiWritable(?bool $value = null): self { $this->apiWritable = $value; + $this->_setField('apiWritable'); return $this; } @@ -340,6 +350,7 @@ public function getMessengerWritable(): ?bool public function setMessengerWritable(?bool $value = null): self { $this->messengerWritable = $value; + $this->_setField('messengerWritable'); return $this; } @@ -357,6 +368,7 @@ public function getUiWritable(): ?bool public function setUiWritable(?bool $value = null): self { $this->uiWritable = $value; + $this->_setField('uiWritable'); return $this; } @@ -374,6 +386,7 @@ public function getCustom(): ?bool public function setCustom(?bool $value = null): self { $this->custom = $value; + $this->_setField('custom'); return $this; } @@ -391,6 +404,7 @@ public function getArchived(): ?bool public function setArchived(?bool $value = null): self { $this->archived = $value; + $this->_setField('archived'); return $this; } @@ -408,6 +422,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -425,6 +440,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -442,6 +458,7 @@ public function getAdminId(): ?string public function setAdminId(?string $value = null): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } diff --git a/src/DataEvents/Types/DataEvent.php b/src/DataEvents/Types/DataEvent.php index 394b2db3..8a9ea33e 100644 --- a/src/DataEvents/Types/DataEvent.php +++ b/src/DataEvents/Types/DataEvent.php @@ -98,6 +98,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -115,6 +116,7 @@ public function getEventName(): string public function setEventName(string $value): self { $this->eventName = $value; + $this->_setField('eventName'); return $this; } @@ -132,6 +134,7 @@ public function getCreatedAt(): int public function setCreatedAt(int $value): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -149,6 +152,7 @@ public function getUserId(): ?string public function setUserId(?string $value = null): self { $this->userId = $value; + $this->_setField('userId'); return $this; } @@ -166,6 +170,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -183,6 +188,7 @@ public function getIntercomUserId(): ?string public function setIntercomUserId(?string $value = null): self { $this->intercomUserId = $value; + $this->_setField('intercomUserId'); return $this; } @@ -200,6 +206,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -217,6 +224,7 @@ public function getMetadata(): ?array public function setMetadata(?array $value = null): self { $this->metadata = $value; + $this->_setField('metadata'); return $this; } diff --git a/src/DataExport/DataExportClient.php b/src/DataExport/DataExportClient.php index 1f3d8e19..6c1acaba 100644 --- a/src/DataExport/DataExportClient.php +++ b/src/DataExport/DataExportClient.php @@ -2,7 +2,7 @@ namespace Intercom\DataExport; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\DataExport\Requests\ExportReportingDataRequest; use Intercom\DataExport\Types\DataExportExportReportingDataResponse; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\DataExport\Requests\DownloadReportingDataExportRequest; use Intercom\DataExport\Requests\CreateDataExportRequest; @@ -58,6 +57,18 @@ public function __construct( } /** + * Example: + * ```php + * $client->dataExport->exportReportingData( + * new ExportReportingDataRequest([ + * 'jobIdentifierPathParam' => 'job_identifier', + * 'appId' => 'app_id', + * 'clientId' => 'client_id', + * 'jobIdentifier' => 'job_identifier', + * ]), + * ); + * ``` + * * @param ExportReportingDataRequest $request * @param ?array{ * baseUrl?: string, @@ -67,21 +78,22 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return DataExportExportReportingDataResponse + * @return ?DataExportExportReportingDataResponse * @throws IntercomException * @throws IntercomApiException */ - public function exportReportingData(ExportReportingDataRequest $request, ?array $options = null): DataExportExportReportingDataResponse + 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(); + $query['job_identifier'] = $request->getJobIdentifier(); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "export/reporting_data/{$request->getJobIdentifier()}", + path: "export/reporting_data/" . RawClient::encodePathParam($request->getJobIdentifierPathParam()), method: HttpMethod::GET, query: $query, ), @@ -90,20 +102,13 @@ public function exportReportingData(ExportReportingDataRequest $request, ?array $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -121,6 +126,18 @@ public function exportReportingData(ExportReportingDataRequest $request, ?array * > * > You will have to specify the header Accept: `application/octet-stream` when hitting this endpoint. * + * Example: + * ```php + * $client->dataExport->downloadReportingDataExport( + * new DownloadReportingDataExportRequest([ + * 'jobIdentifierPathParam' => 'job_identifier', + * 'appId' => 'app_id', + * 'jobIdentifier' => 'job_identifier', + * 'accept' => 'application/octet-stream', + * ]), + * ); + * ``` + * * @param DownloadReportingDataExportRequest $request * @param ?array{ * baseUrl?: string, @@ -138,13 +155,14 @@ public function downloadReportingDataExport(DownloadReportingDataExportRequest $ $options = array_merge($this->options, $options ?? []); $query = []; $query['app_id'] = $request->getAppId(); + $query['job_identifier'] = $request->getJobIdentifier(); $headers = []; $headers['Accept'] = 'application/octet-stream'; try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "download/reporting_data/{$request->getJobIdentifier()}", + path: "download/reporting_data/" . RawClient::encodePathParam($request->getJobIdentifierPathParam()), method: HttpMethod::GET, headers: $headers, query: $query, @@ -155,16 +173,6 @@ public function downloadReportingDataExport(DownloadReportingDataExportRequest $ 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); } @@ -192,6 +200,16 @@ public function downloadReportingDataExport(DownloadReportingDataExportRequest $ * > * > Requesting data for 2018-06-01 until 2018-06-30 will get all data for those days including those specified - e.g. 2018-06-01 00:00:00 until 2018-06-30 23:59:99. * + * Example: + * ```php + * $client->dataExport->create( + * new CreateDataExportRequest([ + * 'createdAtAfter' => 1734519776, + * 'createdAtBefore' => 1734537776, + * ]), + * ); + * ``` + * * @param CreateDataExportRequest $request * @param ?array{ * baseUrl?: string, @@ -201,11 +219,11 @@ public function downloadReportingDataExport(DownloadReportingDataExportRequest $ * queryParameters?: array, * bodyProperties?: array, * } $options - * @return DataExport + * @return ?DataExport * @throws IntercomException * @throws IntercomApiException */ - public function create(CreateDataExportRequest $request, ?array $options = null): DataExport + public function create(CreateDataExportRequest $request, ?array $options = null): ?DataExport { $options = array_merge($this->options, $options ?? []); try { @@ -221,20 +239,13 @@ public function create(CreateDataExportRequest $request, ?array $options = null) $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return DataExport::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); } @@ -252,6 +263,15 @@ public function create(CreateDataExportRequest $request, ?array $options = null) * > 🚧 Jobs expire after two days * > All jobs that have completed processing (and are thus available to download from the provided URL) will have an expiry limit of two days from when the export ob completed. After this, the data will no longer be available. * + * Example: + * ```php + * $client->dataExport->find( + * new FindDataExportRequest([ + * 'jobIdentifier' => 'job_identifier', + * ]), + * ); + * ``` + * * @param FindDataExportRequest $request * @param ?array{ * baseUrl?: string, @@ -261,18 +281,18 @@ public function create(CreateDataExportRequest $request, ?array $options = null) * queryParameters?: array, * bodyProperties?: array, * } $options - * @return DataExport + * @return ?DataExport * @throws IntercomException * @throws IntercomApiException */ - public function find(FindDataExportRequest $request, ?array $options = null): DataExport + public function find(FindDataExportRequest $request, ?array $options = null): ?DataExport { $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/content/data/{$request->getJobIdentifier()}", + path: "export/content/data/" . RawClient::encodePathParam($request->getJobIdentifier()), method: HttpMethod::GET, ), $options, @@ -280,20 +300,13 @@ public function find(FindDataExportRequest $request, ?array $options = null): Da $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return DataExport::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); } @@ -307,6 +320,15 @@ public function find(FindDataExportRequest $request, ?array $options = null): Da /** * You can cancel your job * + * Example: + * ```php + * $client->dataExport->cancel( + * new CancelDataExportRequest([ + * 'jobIdentifier' => 'job_identifier', + * ]), + * ); + * ``` + * * @param CancelDataExportRequest $request * @param ?array{ * baseUrl?: string, @@ -316,18 +338,18 @@ public function find(FindDataExportRequest $request, ?array $options = null): Da * queryParameters?: array, * bodyProperties?: array, * } $options - * @return DataExport + * @return ?DataExport * @throws IntercomException * @throws IntercomApiException */ - public function cancel(CancelDataExportRequest $request, ?array $options = null): DataExport + public function cancel(CancelDataExportRequest $request, ?array $options = null): ?DataExport { $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/cancel/{$request->getJobIdentifier()}", + path: "export/cancel/" . RawClient::encodePathParam($request->getJobIdentifier()), method: HttpMethod::POST, ), $options, @@ -335,20 +357,13 @@ public function cancel(CancelDataExportRequest $request, ?array $options = null) $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return DataExport::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); } @@ -368,6 +383,15 @@ public function cancel(CancelDataExportRequest $request, ?array $options = null) * > * > You will have to specify the header Accept: `application/octet-stream` when hitting this endpoint. * + * Example: + * ```php + * $client->dataExport->download( + * new DownloadDataExportRequest([ + * 'jobIdentifier' => 'job_identifier', + * ]), + * ); + * ``` + * * @param DownloadDataExportRequest $request * @param ?array{ * baseUrl?: string, @@ -387,7 +411,7 @@ public function download(DownloadDataExportRequest $request, ?array $options = n $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "download/content/data/{$request->getJobIdentifier()}", + path: "download/content/data/" . RawClient::encodePathParam($request->getJobIdentifier()), method: HttpMethod::GET, ), $options, @@ -396,16 +420,6 @@ public function download(DownloadDataExportRequest $request, ?array $options = n 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); } diff --git a/src/DataExport/Requests/CancelDataExportRequest.php b/src/DataExport/Requests/CancelDataExportRequest.php index f030c5ae..bfd84a31 100644 --- a/src/DataExport/Requests/CancelDataExportRequest.php +++ b/src/DataExport/Requests/CancelDataExportRequest.php @@ -36,6 +36,7 @@ public function getJobIdentifier(): string public function setJobIdentifier(string $value): self { $this->jobIdentifier = $value; + $this->_setField('jobIdentifier'); return $this; } } diff --git a/src/DataExport/Requests/CreateDataExportRequest.php b/src/DataExport/Requests/CreateDataExportRequest.php index f8ac8eff..4d7f9058 100644 --- a/src/DataExport/Requests/CreateDataExportRequest.php +++ b/src/DataExport/Requests/CreateDataExportRequest.php @@ -46,6 +46,7 @@ public function getCreatedAtAfter(): int public function setCreatedAtAfter(int $value): self { $this->createdAtAfter = $value; + $this->_setField('createdAtAfter'); return $this; } @@ -63,6 +64,7 @@ public function getCreatedAtBefore(): int public function setCreatedAtBefore(int $value): self { $this->createdAtBefore = $value; + $this->_setField('createdAtBefore'); return $this; } } diff --git a/src/DataExport/Requests/DownloadDataExportRequest.php b/src/DataExport/Requests/DownloadDataExportRequest.php index d2718ff3..89a492a3 100644 --- a/src/DataExport/Requests/DownloadDataExportRequest.php +++ b/src/DataExport/Requests/DownloadDataExportRequest.php @@ -36,6 +36,7 @@ public function getJobIdentifier(): string public function setJobIdentifier(string $value): self { $this->jobIdentifier = $value; + $this->_setField('jobIdentifier'); return $this; } } diff --git a/src/DataExport/Requests/DownloadReportingDataExportRequest.php b/src/DataExport/Requests/DownloadReportingDataExportRequest.php index 3842c838..00aaec30 100644 --- a/src/DataExport/Requests/DownloadReportingDataExportRequest.php +++ b/src/DataExport/Requests/DownloadReportingDataExportRequest.php @@ -7,15 +7,20 @@ class DownloadReportingDataExportRequest extends JsonSerializableType { /** - * @var string $jobIdentifier + * @var string $jobIdentifierPathParam */ - private string $jobIdentifier; + private string $jobIdentifierPathParam; /** * @var string $appId */ private string $appId; + /** + * @var string $jobIdentifier + */ + private string $jobIdentifier; + /** * @var 'application/octet-stream' $accept Required header for downloading the export file */ @@ -23,33 +28,36 @@ class DownloadReportingDataExportRequest extends JsonSerializableType /** * @param array{ - * jobIdentifier: string, + * jobIdentifierPathParam: string, * appId: string, + * jobIdentifier: string, * accept: 'application/octet-stream', * } $values */ public function __construct( array $values, ) { - $this->jobIdentifier = $values['jobIdentifier']; + $this->jobIdentifierPathParam = $values['jobIdentifierPathParam']; $this->appId = $values['appId']; + $this->jobIdentifier = $values['jobIdentifier']; $this->accept = $values['accept']; } /** * @return string */ - public function getJobIdentifier(): string + public function getJobIdentifierPathParam(): string { - return $this->jobIdentifier; + return $this->jobIdentifierPathParam; } /** * @param string $value */ - public function setJobIdentifier(string $value): self + public function setJobIdentifierPathParam(string $value): self { - $this->jobIdentifier = $value; + $this->jobIdentifierPathParam = $value; + $this->_setField('jobIdentifierPathParam'); return $this; } @@ -67,6 +75,25 @@ public function getAppId(): string public function setAppId(string $value): self { $this->appId = $value; + $this->_setField('appId'); + return $this; + } + + /** + * @return string + */ + public function getJobIdentifier(): string + { + return $this->jobIdentifier; + } + + /** + * @param string $value + */ + public function setJobIdentifier(string $value): self + { + $this->jobIdentifier = $value; + $this->_setField('jobIdentifier'); return $this; } @@ -84,6 +111,7 @@ public function getAccept(): string public function setAccept(string $value): self { $this->accept = $value; + $this->_setField('accept'); return $this; } } diff --git a/src/DataExport/Requests/ExportReportingDataRequest.php b/src/DataExport/Requests/ExportReportingDataRequest.php index 28ec1d23..c95552ab 100644 --- a/src/DataExport/Requests/ExportReportingDataRequest.php +++ b/src/DataExport/Requests/ExportReportingDataRequest.php @@ -7,9 +7,9 @@ class ExportReportingDataRequest extends JsonSerializableType { /** - * @var string $jobIdentifier Unique identifier of the job. + * @var string $jobIdentifierPathParam Unique identifier of the job. */ - private string $jobIdentifier; + private string $jobIdentifierPathParam; /** * @var string $appId The Intercom defined code of the workspace the company is associated to. @@ -21,35 +21,43 @@ class ExportReportingDataRequest extends JsonSerializableType */ private string $clientId; + /** + * @var string $jobIdentifier Unique identifier of the job. + */ + private string $jobIdentifier; + /** * @param array{ - * jobIdentifier: string, + * jobIdentifierPathParam: string, * appId: string, * clientId: string, + * jobIdentifier: string, * } $values */ public function __construct( array $values, ) { - $this->jobIdentifier = $values['jobIdentifier']; + $this->jobIdentifierPathParam = $values['jobIdentifierPathParam']; $this->appId = $values['appId']; $this->clientId = $values['clientId']; + $this->jobIdentifier = $values['jobIdentifier']; } /** * @return string */ - public function getJobIdentifier(): string + public function getJobIdentifierPathParam(): string { - return $this->jobIdentifier; + return $this->jobIdentifierPathParam; } /** * @param string $value */ - public function setJobIdentifier(string $value): self + public function setJobIdentifierPathParam(string $value): self { - $this->jobIdentifier = $value; + $this->jobIdentifierPathParam = $value; + $this->_setField('jobIdentifierPathParam'); return $this; } @@ -67,6 +75,7 @@ public function getAppId(): string public function setAppId(string $value): self { $this->appId = $value; + $this->_setField('appId'); return $this; } @@ -84,6 +93,25 @@ public function getClientId(): string public function setClientId(string $value): self { $this->clientId = $value; + $this->_setField('clientId'); + return $this; + } + + /** + * @return string + */ + public function getJobIdentifier(): string + { + return $this->jobIdentifier; + } + + /** + * @param string $value + */ + public function setJobIdentifier(string $value): self + { + $this->jobIdentifier = $value; + $this->_setField('jobIdentifier'); return $this; } } diff --git a/src/DataExport/Requests/FindDataExportRequest.php b/src/DataExport/Requests/FindDataExportRequest.php index ad016697..9533ff48 100644 --- a/src/DataExport/Requests/FindDataExportRequest.php +++ b/src/DataExport/Requests/FindDataExportRequest.php @@ -36,6 +36,7 @@ public function getJobIdentifier(): string public function setJobIdentifier(string $value): self { $this->jobIdentifier = $value; + $this->_setField('jobIdentifier'); return $this; } } diff --git a/src/DataExport/Types/DataExport.php b/src/DataExport/Types/DataExport.php index a8c5b4b9..b9e8ff89 100644 --- a/src/DataExport/Types/DataExport.php +++ b/src/DataExport/Types/DataExport.php @@ -65,6 +65,7 @@ public function getJobIdentifier(): ?string public function setJobIdentifier(?string $value = null): self { $this->jobIdentifier = $value; + $this->_setField('jobIdentifier'); return $this; } @@ -82,6 +83,7 @@ public function getStatus(): ?string public function setStatus(?string $value = null): self { $this->status = $value; + $this->_setField('status'); return $this; } @@ -99,6 +101,7 @@ public function getDownloadExpiresAt(): ?string public function setDownloadExpiresAt(?string $value = null): self { $this->downloadExpiresAt = $value; + $this->_setField('downloadExpiresAt'); return $this; } @@ -116,6 +119,7 @@ public function getDownloadUrl(): ?string public function setDownloadUrl(?string $value = null): self { $this->downloadUrl = $value; + $this->_setField('downloadUrl'); return $this; } diff --git a/src/DataExport/Types/DataExportExportReportingDataResponse.php b/src/DataExport/Types/DataExportExportReportingDataResponse.php index 2c7db6f8..eb304cb8 100644 --- a/src/DataExport/Types/DataExportExportReportingDataResponse.php +++ b/src/DataExport/Types/DataExportExportReportingDataResponse.php @@ -62,6 +62,7 @@ public function getJobIdentifier(): ?string public function setJobIdentifier(?string $value = null): self { $this->jobIdentifier = $value; + $this->_setField('jobIdentifier'); return $this; } @@ -79,6 +80,7 @@ public function getStatus(): ?string public function setStatus(?string $value = null): self { $this->status = $value; + $this->_setField('status'); return $this; } @@ -96,6 +98,7 @@ public function getDownloadUrl(): ?string public function setDownloadUrl(?string $value = null): self { $this->downloadUrl = $value; + $this->_setField('downloadUrl'); return $this; } @@ -113,6 +116,7 @@ public function getDownloadExpiresAt(): ?string public function setDownloadExpiresAt(?string $value = null): self { $this->downloadExpiresAt = $value; + $this->_setField('downloadExpiresAt'); return $this; } diff --git a/src/Events/EventsClient.php b/src/Events/EventsClient.php index 6856658d..ac7b2b3f 100644 --- a/src/Events/EventsClient.php +++ b/src/Events/EventsClient.php @@ -2,23 +2,25 @@ namespace Intercom\Events; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Events\Requests\ListEventsRequest; use Intercom\Types\DataEventSummary; use Intercom\Exceptions\IntercomException; use Intercom\Exceptions\IntercomApiException; +use Intercom\Core\Json\JsonSerializer; +use Intercom\Core\Types\Union; +use Intercom\Events\Types\EventsListRequestFilterUserId; +use Intercom\Events\Types\EventsListRequestFilterIntercomUserId; +use Intercom\Events\Types\EventsListRequestFilterEmail; use Intercom\Core\Json\JsonApiRequest; use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Types\CreateDataEventRequestWithId; use Intercom\Types\CreateDataEventRequestWithUserId; use Intercom\Types\CreateDataEventRequestWithEmail; -use Intercom\Core\Json\JsonSerializer; -use Intercom\Core\Types\Union; use Intercom\Events\Requests\ListEventSummariesRequest; class EventsClient @@ -73,6 +75,23 @@ public function __construct( * * You can optionally define the result page size as well with the `per_page` parameter. * + * Example: + * ```php + * $client->events->list( + * new ListEventsRequest([ + * 'filter' => new EventsListRequestFilterUserId([ + * 'userId' => 'user_id', + * ]), + * 'type' => 'type', + * 'summary' => true, + * 'userId' => 'user_id', + * 'intercomUserId' => 'intercom_user_id', + * 'email' => 'email', + * 'perPage' => 1, + * ]), + * ); + * ``` + * * @param ListEventsRequest $request * @param ?array{ * baseUrl?: string, @@ -82,15 +101,19 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return DataEventSummary + * @return ?DataEventSummary * @throws IntercomException * @throws IntercomApiException */ - public function list(ListEventsRequest $request, ?array $options = null): DataEventSummary + public function list(ListEventsRequest $request, ?array $options = null): ?DataEventSummary { $options = array_merge($this->options, $options ?? []); $query = []; + $query['filter'] = JsonSerializer::serializeUnion($request->getFilter(), new Union(EventsListRequestFilterUserId::class, EventsListRequestFilterIntercomUserId::class, EventsListRequestFilterEmail::class)); $query['type'] = $request->getType(); + if ($request->getSummary() != null) { + $query['summary'] = $request->getSummary(); + } if ($request->getUserId() != null) { $query['user_id'] = $request->getUserId(); } @@ -100,9 +123,6 @@ public function list(ListEventsRequest $request, ?array $options = null): DataEv if ($request->getEmail() != null) { $query['email'] = $request->getEmail(); } - if ($request->getSummary() != null) { - $query['summary'] = $request->getSummary(); - } if ($request->getPerPage() != null) { $query['per_page'] = $request->getPerPage(); } @@ -119,20 +139,13 @@ public function list(ListEventsRequest $request, ?array $options = null): DataEv $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return DataEventSummary::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); } @@ -187,6 +200,17 @@ public function list(ListEventsRequest $request, ?array $options = null): DataEv * - Server errors will return a `500` response code and may contain an error message in the body. * * + * Example: + * ```php + * $client->events->create( + * new CreateDataEventRequestWithId([ + * 'id' => '8a88a590-e1c3-41e2-a502-e0649dbf721c', + * 'eventName' => 'invited-friend', + * 'createdAt' => 1671028894, + * ]), + * ); + * ``` + * * @param ( * CreateDataEventRequestWithId * |CreateDataEventRequestWithUserId @@ -220,16 +244,6 @@ public function create(CreateDataEventRequestWithId|CreateDataEventRequestWithUs 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); } @@ -244,6 +258,13 @@ public function create(CreateDataEventRequestWithId|CreateDataEventRequestWithUs * Create event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred. * * + * Example: + * ```php + * $client->events->summaries( + * new ListEventSummariesRequest([]), + * ); + * ``` + * * @param ListEventSummariesRequest $request * @param ?array{ * baseUrl?: string, @@ -273,16 +294,6 @@ public function summaries(ListEventSummariesRequest $request = new ListEventSumm 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); } diff --git a/src/Events/Requests/ListEventSummariesRequest.php b/src/Events/Requests/ListEventSummariesRequest.php index 5c3999fb..9e551425 100644 --- a/src/Events/Requests/ListEventSummariesRequest.php +++ b/src/Events/Requests/ListEventSummariesRequest.php @@ -47,6 +47,7 @@ public function getUserId(): ?string public function setUserId(?string $value = null): self { $this->userId = $value; + $this->_setField('userId'); return $this; } @@ -64,6 +65,7 @@ public function getEventSummaries(): ?CreateDataEventSummariesRequestEventSummar public function setEventSummaries(?CreateDataEventSummariesRequestEventSummaries $value = null): self { $this->eventSummaries = $value; + $this->_setField('eventSummaries'); return $this; } } diff --git a/src/Events/Requests/ListEventsRequest.php b/src/Events/Requests/ListEventsRequest.php index 514efdd1..15f1aeca 100644 --- a/src/Events/Requests/ListEventsRequest.php +++ b/src/Events/Requests/ListEventsRequest.php @@ -3,33 +3,45 @@ namespace Intercom\Events\Requests; use Intercom\Core\Json\JsonSerializableType; +use Intercom\Events\Types\EventsListRequestFilterUserId; +use Intercom\Events\Types\EventsListRequestFilterIntercomUserId; +use Intercom\Events\Types\EventsListRequestFilterEmail; class ListEventsRequest extends JsonSerializableType { /** - * @var ?string $userId user_id query parameter + * @var ( + * EventsListRequestFilterUserId + * |EventsListRequestFilterIntercomUserId + * |EventsListRequestFilterEmail + * ) $filter */ - private ?string $userId; + private EventsListRequestFilterUserId|EventsListRequestFilterIntercomUserId|EventsListRequestFilterEmail $filter; /** - * @var ?string $intercomUserId intercom_user_id query parameter + * @var string $type The value must be user */ - private ?string $intercomUserId; + private string $type; /** - * @var ?string $email email query parameter + * @var ?bool $summary summary flag */ - private ?string $email; + private ?bool $summary; /** - * @var string $type The value must be user + * @var ?string $userId user_id query parameter */ - private string $type; + private ?string $userId; /** - * @var ?bool $summary summary flag + * @var ?string $intercomUserId intercom_user_id query parameter */ - private ?bool $summary; + private ?string $intercomUserId; + + /** + * @var ?string $email email query parameter + */ + private ?string $email; /** * @var ?int $perPage How many results to display per page. Defaults to 15 @@ -38,107 +50,144 @@ class ListEventsRequest extends JsonSerializableType /** * @param array{ + * filter: ( + * EventsListRequestFilterUserId + * |EventsListRequestFilterIntercomUserId + * |EventsListRequestFilterEmail + * ), * type: string, + * summary?: ?bool, * userId?: ?string, * intercomUserId?: ?string, * email?: ?string, - * summary?: ?bool, * perPage?: ?int, * } $values */ public function __construct( array $values, ) { + $this->filter = $values['filter']; + $this->type = $values['type']; + $this->summary = $values['summary'] ?? null; $this->userId = $values['userId'] ?? null; $this->intercomUserId = $values['intercomUserId'] ?? null; $this->email = $values['email'] ?? null; - $this->type = $values['type']; - $this->summary = $values['summary'] ?? null; $this->perPage = $values['perPage'] ?? null; } /** - * @return ?string + * @return ( + * EventsListRequestFilterUserId + * |EventsListRequestFilterIntercomUserId + * |EventsListRequestFilterEmail + * ) */ - public function getUserId(): ?string + public function getFilter(): EventsListRequestFilterUserId|EventsListRequestFilterIntercomUserId|EventsListRequestFilterEmail { - return $this->userId; + return $this->filter; } /** - * @param ?string $value + * @param ( + * EventsListRequestFilterUserId + * |EventsListRequestFilterIntercomUserId + * |EventsListRequestFilterEmail + * ) $value */ - public function setUserId(?string $value = null): self + public function setFilter(EventsListRequestFilterUserId|EventsListRequestFilterIntercomUserId|EventsListRequestFilterEmail $value): self { - $this->userId = $value; + $this->filter = $value; + $this->_setField('filter'); return $this; } /** - * @return ?string + * @return string */ - public function getIntercomUserId(): ?string + public function getType(): string { - return $this->intercomUserId; + return $this->type; } /** - * @param ?string $value + * @param string $value */ - public function setIntercomUserId(?string $value = null): self + public function setType(string $value): self { - $this->intercomUserId = $value; + $this->type = $value; + $this->_setField('type'); + return $this; + } + + /** + * @return ?bool + */ + public function getSummary(): ?bool + { + return $this->summary; + } + + /** + * @param ?bool $value + */ + public function setSummary(?bool $value = null): self + { + $this->summary = $value; + $this->_setField('summary'); return $this; } /** * @return ?string */ - public function getEmail(): ?string + public function getUserId(): ?string { - return $this->email; + return $this->userId; } /** * @param ?string $value */ - public function setEmail(?string $value = null): self + public function setUserId(?string $value = null): self { - $this->email = $value; + $this->userId = $value; + $this->_setField('userId'); return $this; } /** - * @return string + * @return ?string */ - public function getType(): string + public function getIntercomUserId(): ?string { - return $this->type; + return $this->intercomUserId; } /** - * @param string $value + * @param ?string $value */ - public function setType(string $value): self + public function setIntercomUserId(?string $value = null): self { - $this->type = $value; + $this->intercomUserId = $value; + $this->_setField('intercomUserId'); return $this; } /** - * @return ?bool + * @return ?string */ - public function getSummary(): ?bool + public function getEmail(): ?string { - return $this->summary; + return $this->email; } /** - * @param ?bool $value + * @param ?string $value */ - public function setSummary(?bool $value = null): self + public function setEmail(?string $value = null): self { - $this->summary = $value; + $this->email = $value; + $this->_setField('email'); return $this; } @@ -156,6 +205,7 @@ public function getPerPage(): ?int public function setPerPage(?int $value = null): self { $this->perPage = $value; + $this->_setField('perPage'); return $this; } } diff --git a/src/Events/Types/CreateDataEventSummariesRequestEventSummaries.php b/src/Events/Types/CreateDataEventSummariesRequestEventSummaries.php index dc4cdb05..bb270f5f 100644 --- a/src/Events/Types/CreateDataEventSummariesRequestEventSummaries.php +++ b/src/Events/Types/CreateDataEventSummariesRequestEventSummaries.php @@ -65,6 +65,7 @@ public function getEventName(): ?string public function setEventName(?string $value = null): self { $this->eventName = $value; + $this->_setField('eventName'); return $this; } @@ -82,6 +83,7 @@ public function getCount(): ?int public function setCount(?int $value = null): self { $this->count = $value; + $this->_setField('count'); return $this; } @@ -99,6 +101,7 @@ public function getFirst(): ?int public function setFirst(?int $value = null): self { $this->first = $value; + $this->_setField('first'); return $this; } @@ -116,6 +119,7 @@ public function getLast(): ?int public function setLast(?int $value = null): self { $this->last = $value; + $this->_setField('last'); return $this; } diff --git a/src/Events/Types/EventsListRequestFilterEmail.php b/src/Events/Types/EventsListRequestFilterEmail.php new file mode 100644 index 00000000..384e7a03 --- /dev/null +++ b/src/Events/Types/EventsListRequestFilterEmail.php @@ -0,0 +1,52 @@ +email = $values['email']; + } + + /** + * @return string + */ + public function getEmail(): string + { + return $this->email; + } + + /** + * @param string $value + */ + public function setEmail(string $value): self + { + $this->email = $value; + $this->_setField('email'); + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Events/Types/EventsListRequestFilterIntercomUserId.php b/src/Events/Types/EventsListRequestFilterIntercomUserId.php new file mode 100644 index 00000000..ea5775ee --- /dev/null +++ b/src/Events/Types/EventsListRequestFilterIntercomUserId.php @@ -0,0 +1,52 @@ +intercomUserId = $values['intercomUserId']; + } + + /** + * @return string + */ + public function getIntercomUserId(): string + { + return $this->intercomUserId; + } + + /** + * @param string $value + */ + public function setIntercomUserId(string $value): self + { + $this->intercomUserId = $value; + $this->_setField('intercomUserId'); + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Events/Types/EventsListRequestFilterUserId.php b/src/Events/Types/EventsListRequestFilterUserId.php new file mode 100644 index 00000000..d047f4c5 --- /dev/null +++ b/src/Events/Types/EventsListRequestFilterUserId.php @@ -0,0 +1,52 @@ +userId = $values['userId']; + } + + /** + * @return string + */ + public function getUserId(): string + { + return $this->userId; + } + + /** + * @param string $value + */ + public function setUserId(string $value): self + { + $this->userId = $value; + $this->_setField('userId'); + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Exceptions/IntercomApiException.php b/src/Exceptions/IntercomApiException.php index 703bece9..ef764f9c 100644 --- a/src/Exceptions/IntercomApiException.php +++ b/src/Exceptions/IntercomApiException.php @@ -46,8 +46,8 @@ public function getBody(): mixed public function __toString(): string { if (empty($this->body)) { - return "$this->message; Status Code: $this->code\n"; + return $this->message . '; Status Code: ' . $this->getCode() . "\n"; } - return "$this->message; Status Code: $this->code; Body: " . $this->body . "\n"; + return $this->message . '; Status Code: ' . $this->getCode() . '; Body: ' . print_r($this->body, true) . "\n"; } } diff --git a/src/Export/ExportClient.php b/src/Export/ExportClient.php index 544337fb..58ad461a 100644 --- a/src/Export/ExportClient.php +++ b/src/Export/ExportClient.php @@ -2,7 +2,7 @@ namespace Intercom\Export; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Export\Requests\PostExportReportingDataEnqueueRequest; use Intercom\Export\Types\PostExportReportingDataEnqueueResponse; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Export\Types\GetExportReportingDataGetDatasetsResponse; @@ -53,6 +52,21 @@ public function __construct( } /** + * Example: + * ```php + * $client->export->enqueueANewReportingDataExportJob( + * new PostExportReportingDataEnqueueRequest([ + * 'datasetId' => 'conversation', + * 'attributeIds' => [ + * 'conversation_id', + * 'conversation_started_at', + * ], + * 'startTime' => 1717490000, + * 'endTime' => 1717510000, + * ]), + * ); + * ``` + * * @param PostExportReportingDataEnqueueRequest $request * @param ?array{ * baseUrl?: string, @@ -62,11 +76,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return PostExportReportingDataEnqueueResponse + * @return ?PostExportReportingDataEnqueueResponse * @throws IntercomException * @throws IntercomApiException */ - public function enqueueANewReportingDataExportJob(PostExportReportingDataEnqueueRequest $request, ?array $options = null): PostExportReportingDataEnqueueResponse + public function enqueueANewReportingDataExportJob(PostExportReportingDataEnqueueRequest $request, ?array $options = null): ?PostExportReportingDataEnqueueResponse { $options = array_merge($this->options, $options ?? []); try { @@ -82,20 +96,13 @@ public function enqueueANewReportingDataExportJob(PostExportReportingDataEnqueue $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -107,6 +114,11 @@ public function enqueueANewReportingDataExportJob(PostExportReportingDataEnqueue } /** + * Example: + * ```php + * $client->export->listAvailableDatasetsAndAttributes(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -115,11 +127,11 @@ public function enqueueANewReportingDataExportJob(PostExportReportingDataEnqueue * queryParameters?: array, * bodyProperties?: array, * } $options - * @return GetExportReportingDataGetDatasetsResponse + * @return ?GetExportReportingDataGetDatasetsResponse * @throws IntercomException * @throws IntercomApiException */ - public function listAvailableDatasetsAndAttributes(?array $options = null): GetExportReportingDataGetDatasetsResponse + public function listAvailableDatasetsAndAttributes(?array $options = null): ?GetExportReportingDataGetDatasetsResponse { $options = array_merge($this->options, $options ?? []); try { @@ -134,20 +146,13 @@ public function listAvailableDatasetsAndAttributes(?array $options = null): GetE $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } diff --git a/src/Export/Requests/PostExportReportingDataEnqueueRequest.php b/src/Export/Requests/PostExportReportingDataEnqueueRequest.php index 7be7a767..9c26900b 100644 --- a/src/Export/Requests/PostExportReportingDataEnqueueRequest.php +++ b/src/Export/Requests/PostExportReportingDataEnqueueRequest.php @@ -63,6 +63,7 @@ public function getDatasetId(): string public function setDatasetId(string $value): self { $this->datasetId = $value; + $this->_setField('datasetId'); return $this; } @@ -80,6 +81,7 @@ public function getAttributeIds(): array public function setAttributeIds(array $value): self { $this->attributeIds = $value; + $this->_setField('attributeIds'); return $this; } @@ -97,6 +99,7 @@ public function getStartTime(): int public function setStartTime(int $value): self { $this->startTime = $value; + $this->_setField('startTime'); return $this; } @@ -114,6 +117,7 @@ public function getEndTime(): int public function setEndTime(int $value): self { $this->endTime = $value; + $this->_setField('endTime'); return $this; } } diff --git a/src/Export/Types/GetExportReportingDataGetDatasetsResponse.php b/src/Export/Types/GetExportReportingDataGetDatasetsResponse.php index 76383f15..3314731f 100644 --- a/src/Export/Types/GetExportReportingDataGetDatasetsResponse.php +++ b/src/Export/Types/GetExportReportingDataGetDatasetsResponse.php @@ -47,6 +47,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -64,6 +65,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Export/Types/GetExportReportingDataGetDatasetsResponseDataItem.php b/src/Export/Types/GetExportReportingDataGetDatasetsResponseDataItem.php index 6ee1feda..961ea5ec 100644 --- a/src/Export/Types/GetExportReportingDataGetDatasetsResponseDataItem.php +++ b/src/Export/Types/GetExportReportingDataGetDatasetsResponseDataItem.php @@ -71,6 +71,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -88,6 +89,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -105,6 +107,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -122,6 +125,7 @@ public function getDefaultTimeAttributeId(): ?string public function setDefaultTimeAttributeId(?string $value = null): self { $this->defaultTimeAttributeId = $value; + $this->_setField('defaultTimeAttributeId'); return $this; } @@ -139,6 +143,7 @@ public function getAttributes(): ?array public function setAttributes(?array $value = null): self { $this->attributes = $value; + $this->_setField('attributes'); return $this; } diff --git a/src/Export/Types/GetExportReportingDataGetDatasetsResponseDataItemAttributesItem.php b/src/Export/Types/GetExportReportingDataGetDatasetsResponseDataItemAttributesItem.php index 498da2ba..a3f30968 100644 --- a/src/Export/Types/GetExportReportingDataGetDatasetsResponseDataItemAttributesItem.php +++ b/src/Export/Types/GetExportReportingDataGetDatasetsResponseDataItemAttributesItem.php @@ -46,6 +46,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -63,6 +64,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } diff --git a/src/Export/Types/PostExportReportingDataEnqueueResponse.php b/src/Export/Types/PostExportReportingDataEnqueueResponse.php index 58a18077..45a2a0dd 100644 --- a/src/Export/Types/PostExportReportingDataEnqueueResponse.php +++ b/src/Export/Types/PostExportReportingDataEnqueueResponse.php @@ -62,6 +62,7 @@ public function getJobIdentifier(): ?string public function setJobIdentifier(?string $value = null): self { $this->jobIdentifier = $value; + $this->_setField('jobIdentifier'); return $this; } @@ -79,6 +80,7 @@ public function getStatus(): ?string public function setStatus(?string $value = null): self { $this->status = $value; + $this->_setField('status'); return $this; } @@ -96,6 +98,7 @@ public function getDownloadUrl(): ?string public function setDownloadUrl(?string $value = null): self { $this->downloadUrl = $value; + $this->_setField('downloadUrl'); return $this; } @@ -113,6 +116,7 @@ public function getDownloadExpiresAt(): ?string public function setDownloadExpiresAt(?string $value = null): self { $this->downloadExpiresAt = $value; + $this->_setField('downloadExpiresAt'); return $this; } diff --git a/src/HelpCenter/Types/Collection.php b/src/HelpCenter/Types/Collection.php index fa84f9e0..b6f2fd92 100644 --- a/src/HelpCenter/Types/Collection.php +++ b/src/HelpCenter/Types/Collection.php @@ -138,6 +138,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -155,6 +156,7 @@ public function getWorkspaceId(): string public function setWorkspaceId(string $value): self { $this->workspaceId = $value; + $this->_setField('workspaceId'); return $this; } @@ -172,6 +174,7 @@ public function getName(): string public function setName(string $value): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -189,6 +192,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -206,6 +210,7 @@ public function getCreatedAt(): int public function setCreatedAt(int $value): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -223,6 +228,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -240,6 +246,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -257,6 +264,7 @@ public function getIcon(): ?string public function setIcon(?string $value = null): self { $this->icon = $value; + $this->_setField('icon'); return $this; } @@ -274,6 +282,7 @@ public function getOrder(): int public function setOrder(int $value): self { $this->order = $value; + $this->_setField('order'); return $this; } @@ -291,6 +300,7 @@ public function getDefaultLocale(): ?string public function setDefaultLocale(?string $value = null): self { $this->defaultLocale = $value; + $this->_setField('defaultLocale'); return $this; } @@ -308,6 +318,7 @@ public function getTranslatedContent(): ?GroupTranslatedContent public function setTranslatedContent(?GroupTranslatedContent $value = null): self { $this->translatedContent = $value; + $this->_setField('translatedContent'); return $this; } @@ -325,6 +336,7 @@ public function getParentId(): ?string public function setParentId(?string $value = null): self { $this->parentId = $value; + $this->_setField('parentId'); return $this; } @@ -342,6 +354,7 @@ public function getHelpCenterId(): ?int public function setHelpCenterId(?int $value = null): self { $this->helpCenterId = $value; + $this->_setField('helpCenterId'); return $this; } diff --git a/src/HelpCenter/Types/HelpCenter.php b/src/HelpCenter/Types/HelpCenter.php index 228b4ded..40413acc 100644 --- a/src/HelpCenter/Types/HelpCenter.php +++ b/src/HelpCenter/Types/HelpCenter.php @@ -105,6 +105,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -122,6 +123,7 @@ public function getWorkspaceId(): ?string public function setWorkspaceId(?string $value = null): self { $this->workspaceId = $value; + $this->_setField('workspaceId'); return $this; } @@ -139,6 +141,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -156,6 +159,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -173,6 +177,7 @@ public function getIdentifier(): ?string public function setIdentifier(?string $value = null): self { $this->identifier = $value; + $this->_setField('identifier'); return $this; } @@ -190,6 +195,7 @@ public function getWebsiteTurnedOn(): ?bool public function setWebsiteTurnedOn(?bool $value = null): self { $this->websiteTurnedOn = $value; + $this->_setField('websiteTurnedOn'); return $this; } @@ -207,6 +213,7 @@ public function getDisplayName(): ?string public function setDisplayName(?string $value = null): self { $this->displayName = $value; + $this->_setField('displayName'); return $this; } @@ -224,6 +231,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -241,6 +249,7 @@ public function getCustomDomain(): ?string public function setCustomDomain(?string $value = null): self { $this->customDomain = $value; + $this->_setField('customDomain'); return $this; } diff --git a/src/HelpCenter/Types/HelpCenterList.php b/src/HelpCenter/Types/HelpCenterList.php index e9af781c..3a6ff52f 100644 --- a/src/HelpCenter/Types/HelpCenterList.php +++ b/src/HelpCenter/Types/HelpCenterList.php @@ -50,6 +50,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -67,6 +68,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/HelpCenters/Collections/CollectionsClient.php b/src/HelpCenters/Collections/CollectionsClient.php index f3c92a78..399594d3 100644 --- a/src/HelpCenters/Collections/CollectionsClient.php +++ b/src/HelpCenters/Collections/CollectionsClient.php @@ -2,7 +2,7 @@ namespace Intercom\HelpCenters\Collections; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\HelpCenters\Collections\Requests\ListCollectionsRequest; use Intercom\Core\Pagination\Pager; @@ -16,7 +16,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\HelpCenters\Collections\Requests\FindCollectionRequest; use Intercom\HelpCenters\Collections\Requests\UpdateCollectionRequest; @@ -64,6 +63,16 @@ public function __construct( * * Collections will be returned in descending order on the `updated_at` attribute. This means if you need to iterate through results then we'll show the most recently updated collections first. * + * Example: + * ```php + * $client->helpCenters->collections->list( + * new ListCollectionsRequest([ + * 'page' => 1, + * 'perPage' => 1, + * ]), + * ); + * ``` + * * @param ListCollectionsRequest $request * @param ?array{ * baseUrl?: string, @@ -87,7 +96,7 @@ public function list(ListCollectionsRequest $request = new ListCollectionsReques }, getStep: null, /* @phpstan-ignore-next-line */ - getItems: fn (CollectionList $response) => $response?->getData() ?? [], + getItems: fn (?CollectionList $response) => $response?->getData() ?? [], /* @phpstan-ignore-next-line */ hasNextPage: null, ); @@ -96,6 +105,15 @@ public function list(ListCollectionsRequest $request = new ListCollectionsReques /** * You can create a new collection by making a POST request to `https://api.intercom.io/help_center/collections.` * + * Example: + * ```php + * $client->helpCenters->collections->create( + * new CreateCollectionRequest([ + * 'name' => 'Thanks for everything', + * ]), + * ); + * ``` + * * @param CreateCollectionRequest $request * @param ?array{ * baseUrl?: string, @@ -105,11 +123,11 @@ public function list(ListCollectionsRequest $request = new ListCollectionsReques * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Collection + * @return ?Collection * @throws IntercomException * @throws IntercomApiException */ - public function create(CreateCollectionRequest $request, ?array $options = null): Collection + public function create(CreateCollectionRequest $request, ?array $options = null): ?Collection { $options = array_merge($this->options, $options ?? []); try { @@ -125,20 +143,13 @@ public function create(CreateCollectionRequest $request, ?array $options = null) $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Collection::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); } @@ -152,6 +163,15 @@ public function create(CreateCollectionRequest $request, ?array $options = null) /** * You can fetch the details of a single collection by making a GET request to `https://api.intercom.io/help_center/collections/`. * + * Example: + * ```php + * $client->helpCenters->collections->find( + * new FindCollectionRequest([ + * 'collectionId' => 1, + * ]), + * ); + * ``` + * * @param FindCollectionRequest $request * @param ?array{ * baseUrl?: string, @@ -161,18 +181,18 @@ public function create(CreateCollectionRequest $request, ?array $options = null) * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Collection + * @return ?Collection * @throws IntercomException * @throws IntercomApiException */ - public function find(FindCollectionRequest $request, ?array $options = null): Collection + public function find(FindCollectionRequest $request, ?array $options = null): ?Collection { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "help_center/collections/{$request->getCollectionId()}", + path: "help_center/collections/" . RawClient::encodePathParam($request->getCollectionId()), method: HttpMethod::GET, ), $options, @@ -180,20 +200,13 @@ public function find(FindCollectionRequest $request, ?array $options = null): Co $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Collection::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); } @@ -207,6 +220,16 @@ public function find(FindCollectionRequest $request, ?array $options = null): Co /** * You can update the details of a single collection by making a PUT request to `https://api.intercom.io/collections/`. * + * Example: + * ```php + * $client->helpCenters->collections->update( + * new UpdateCollectionRequest([ + * 'collectionId' => 1, + * 'name' => 'Update collection name', + * ]), + * ); + * ``` + * * @param UpdateCollectionRequest $request * @param ?array{ * baseUrl?: string, @@ -216,18 +239,18 @@ public function find(FindCollectionRequest $request, ?array $options = null): Co * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Collection + * @return ?Collection * @throws IntercomException * @throws IntercomApiException */ - public function update(UpdateCollectionRequest $request, ?array $options = null): Collection + public function update(UpdateCollectionRequest $request, ?array $options = null): ?Collection { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "help_center/collections/{$request->getCollectionId()}", + path: "help_center/collections/" . RawClient::encodePathParam($request->getCollectionId()), method: HttpMethod::PUT, body: $request, ), @@ -236,20 +259,13 @@ public function update(UpdateCollectionRequest $request, ?array $options = null) $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Collection::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); } @@ -263,6 +279,15 @@ public function update(UpdateCollectionRequest $request, ?array $options = null) /** * You can delete a single collection by making a DELETE request to `https://api.intercom.io/collections/`. * + * Example: + * ```php + * $client->helpCenters->collections->delete( + * new DeleteCollectionRequest([ + * 'collectionId' => 1, + * ]), + * ); + * ``` + * * @param DeleteCollectionRequest $request * @param ?array{ * baseUrl?: string, @@ -272,18 +297,18 @@ public function update(UpdateCollectionRequest $request, ?array $options = null) * queryParameters?: array, * bodyProperties?: array, * } $options - * @return DeletedCollectionObject + * @return ?DeletedCollectionObject * @throws IntercomException * @throws IntercomApiException */ - public function delete(DeleteCollectionRequest $request, ?array $options = null): DeletedCollectionObject + public function delete(DeleteCollectionRequest $request, ?array $options = null): ?DeletedCollectionObject { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "help_center/collections/{$request->getCollectionId()}", + path: "help_center/collections/" . RawClient::encodePathParam($request->getCollectionId()), method: HttpMethod::DELETE, ), $options, @@ -291,20 +316,13 @@ public function delete(DeleteCollectionRequest $request, ?array $options = null) $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return DeletedCollectionObject::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); } @@ -329,11 +347,11 @@ public function delete(DeleteCollectionRequest $request, ?array $options = null) * queryParameters?: array, * bodyProperties?: array, * } $options - * @return CollectionList + * @return ?CollectionList * @throws IntercomException * @throws IntercomApiException */ - private function _list(ListCollectionsRequest $request = new ListCollectionsRequest(), ?array $options = null): CollectionList + private function _list(ListCollectionsRequest $request = new ListCollectionsRequest(), ?array $options = null): ?CollectionList { $options = array_merge($this->options, $options ?? []); $query = []; @@ -356,20 +374,13 @@ private function _list(ListCollectionsRequest $request = new ListCollectionsRequ $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return CollectionList::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); } diff --git a/src/HelpCenters/Collections/Requests/CreateCollectionRequest.php b/src/HelpCenters/Collections/Requests/CreateCollectionRequest.php index 2421a01e..a9853f23 100644 --- a/src/HelpCenters/Collections/Requests/CreateCollectionRequest.php +++ b/src/HelpCenters/Collections/Requests/CreateCollectionRequest.php @@ -71,6 +71,7 @@ public function getName(): string public function setName(string $value): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -88,6 +89,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -105,6 +107,7 @@ public function getTranslatedContent(): ?GroupTranslatedContent public function setTranslatedContent(?GroupTranslatedContent $value = null): self { $this->translatedContent = $value; + $this->_setField('translatedContent'); return $this; } @@ -122,6 +125,7 @@ public function getParentId(): ?string public function setParentId(?string $value = null): self { $this->parentId = $value; + $this->_setField('parentId'); return $this; } @@ -139,6 +143,7 @@ public function getHelpCenterId(): ?int public function setHelpCenterId(?int $value = null): self { $this->helpCenterId = $value; + $this->_setField('helpCenterId'); return $this; } } diff --git a/src/HelpCenters/Collections/Requests/DeleteCollectionRequest.php b/src/HelpCenters/Collections/Requests/DeleteCollectionRequest.php index a1e9af19..e0819d25 100644 --- a/src/HelpCenters/Collections/Requests/DeleteCollectionRequest.php +++ b/src/HelpCenters/Collections/Requests/DeleteCollectionRequest.php @@ -36,6 +36,7 @@ public function getCollectionId(): int public function setCollectionId(int $value): self { $this->collectionId = $value; + $this->_setField('collectionId'); return $this; } } diff --git a/src/HelpCenters/Collections/Requests/FindCollectionRequest.php b/src/HelpCenters/Collections/Requests/FindCollectionRequest.php index 88e8f247..b20d261d 100644 --- a/src/HelpCenters/Collections/Requests/FindCollectionRequest.php +++ b/src/HelpCenters/Collections/Requests/FindCollectionRequest.php @@ -36,6 +36,7 @@ public function getCollectionId(): int public function setCollectionId(int $value): self { $this->collectionId = $value; + $this->_setField('collectionId'); return $this; } } diff --git a/src/HelpCenters/Collections/Requests/ListCollectionsRequest.php b/src/HelpCenters/Collections/Requests/ListCollectionsRequest.php index 83a55182..34e9b504 100644 --- a/src/HelpCenters/Collections/Requests/ListCollectionsRequest.php +++ b/src/HelpCenters/Collections/Requests/ListCollectionsRequest.php @@ -43,6 +43,7 @@ public function getPage(): ?int public function setPage(?int $value = null): self { $this->page = $value; + $this->_setField('page'); return $this; } @@ -60,6 +61,7 @@ public function getPerPage(): ?int public function setPerPage(?int $value = null): self { $this->perPage = $value; + $this->_setField('perPage'); return $this; } } diff --git a/src/HelpCenters/Collections/Requests/UpdateCollectionRequest.php b/src/HelpCenters/Collections/Requests/UpdateCollectionRequest.php index 77b90e82..f715a128 100644 --- a/src/HelpCenters/Collections/Requests/UpdateCollectionRequest.php +++ b/src/HelpCenters/Collections/Requests/UpdateCollectionRequest.php @@ -70,6 +70,7 @@ public function getCollectionId(): int public function setCollectionId(int $value): self { $this->collectionId = $value; + $this->_setField('collectionId'); return $this; } @@ -87,6 +88,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -104,6 +106,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -121,6 +124,7 @@ public function getTranslatedContent(): ?GroupTranslatedContent public function setTranslatedContent(?GroupTranslatedContent $value = null): self { $this->translatedContent = $value; + $this->_setField('translatedContent'); return $this; } @@ -138,6 +142,7 @@ public function getParentId(): ?string public function setParentId(?string $value = null): self { $this->parentId = $value; + $this->_setField('parentId'); return $this; } } diff --git a/src/HelpCenters/HelpCentersClient.php b/src/HelpCenters/HelpCentersClient.php index d5521246..c1e9fcdc 100644 --- a/src/HelpCenters/HelpCentersClient.php +++ b/src/HelpCenters/HelpCentersClient.php @@ -3,7 +3,7 @@ namespace Intercom\HelpCenters; use Intercom\HelpCenters\Collections\CollectionsClient; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\HelpCenters\Requests\FindHelpCenterRequest; use Intercom\HelpCenter\Types\HelpCenter; @@ -13,7 +13,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\HelpCenters\Requests\ListHelpCentersRequest; use Intercom\Core\Pagination\Pager; @@ -65,6 +64,15 @@ public function __construct( /** * You can fetch the details of a single Help Center by making a GET request to `https://api.intercom.io/help_center/help_center/`. * + * Example: + * ```php + * $client->helpCenters->find( + * new FindHelpCenterRequest([ + * 'helpCenterId' => 1, + * ]), + * ); + * ``` + * * @param FindHelpCenterRequest $request * @param ?array{ * baseUrl?: string, @@ -74,18 +82,18 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return HelpCenter + * @return ?HelpCenter * @throws IntercomException * @throws IntercomApiException */ - public function find(FindHelpCenterRequest $request, ?array $options = null): HelpCenter + public function find(FindHelpCenterRequest $request, ?array $options = null): ?HelpCenter { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "help_center/help_centers/{$request->getHelpCenterId()}", + path: "help_center/help_centers/" . RawClient::encodePathParam($request->getHelpCenterId()), method: HttpMethod::GET, ), $options, @@ -93,20 +101,13 @@ public function find(FindHelpCenterRequest $request, ?array $options = null): He $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return HelpCenter::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); } @@ -120,6 +121,16 @@ public function find(FindHelpCenterRequest $request, ?array $options = null): He /** * You can list all Help Centers by making a GET request to `https://api.intercom.io/help_center/help_centers`. * + * Example: + * ```php + * $client->helpCenters->list( + * new ListHelpCentersRequest([ + * 'page' => 1, + * 'perPage' => 1, + * ]), + * ); + * ``` + * * @param ListHelpCentersRequest $request * @param ?array{ * baseUrl?: string, @@ -143,7 +154,7 @@ public function list(ListHelpCentersRequest $request = new ListHelpCentersReques }, getStep: null, /* @phpstan-ignore-next-line */ - getItems: fn (HelpCenterList $response) => $response?->getData() ?? [], + getItems: fn (?HelpCenterList $response) => $response?->getData() ?? [], /* @phpstan-ignore-next-line */ hasNextPage: null, ); @@ -161,11 +172,11 @@ public function list(ListHelpCentersRequest $request = new ListHelpCentersReques * queryParameters?: array, * bodyProperties?: array, * } $options - * @return HelpCenterList + * @return ?HelpCenterList * @throws IntercomException * @throws IntercomApiException */ - private function _list(ListHelpCentersRequest $request = new ListHelpCentersRequest(), ?array $options = null): HelpCenterList + private function _list(ListHelpCentersRequest $request = new ListHelpCentersRequest(), ?array $options = null): ?HelpCenterList { $options = array_merge($this->options, $options ?? []); $query = []; @@ -188,20 +199,13 @@ private function _list(ListHelpCentersRequest $request = new ListHelpCentersRequ $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return HelpCenterList::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); } diff --git a/src/HelpCenters/Requests/FindHelpCenterRequest.php b/src/HelpCenters/Requests/FindHelpCenterRequest.php index 081e65b4..245e22c9 100644 --- a/src/HelpCenters/Requests/FindHelpCenterRequest.php +++ b/src/HelpCenters/Requests/FindHelpCenterRequest.php @@ -36,6 +36,7 @@ public function getHelpCenterId(): int public function setHelpCenterId(int $value): self { $this->helpCenterId = $value; + $this->_setField('helpCenterId'); return $this; } } diff --git a/src/HelpCenters/Requests/ListHelpCentersRequest.php b/src/HelpCenters/Requests/ListHelpCentersRequest.php index 7241adec..8a5586ec 100644 --- a/src/HelpCenters/Requests/ListHelpCentersRequest.php +++ b/src/HelpCenters/Requests/ListHelpCentersRequest.php @@ -43,6 +43,7 @@ public function getPage(): ?int public function setPage(?int $value = null): self { $this->page = $value; + $this->_setField('page'); return $this; } @@ -60,6 +61,7 @@ public function getPerPage(): ?int public function setPerPage(?int $value = null): self { $this->perPage = $value; + $this->_setField('perPage'); return $this; } } diff --git a/src/IntercomClient.php b/src/IntercomClient.php index 238dd851..129237cf 100644 --- a/src/IntercomClient.php +++ b/src/IntercomClient.php @@ -33,7 +33,7 @@ use Intercom\Visitors\VisitorsClient; use Intercom\News\NewsClient; use Intercom\Unstable\UnstableClient; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Exception; @@ -229,8 +229,8 @@ public function __construct( 'Authorization' => "Bearer $token", 'X-Fern-Language' => 'PHP', 'X-Fern-SDK-Name' => 'Intercom', - 'X-Fern-SDK-Version' => '5.0.2', - 'User-Agent' => 'intercom/intercom-php/5.0.2', + 'X-Fern-SDK-Version' => '6.0.0', + 'User-Agent' => 'intercom/intercom-php/6.0.0', 'Intercom-Version' => '2.14', ]; diff --git a/src/InternalArticles/InternalArticlesClient.php b/src/InternalArticles/InternalArticlesClient.php index 2e8ade2d..ec2a338e 100644 --- a/src/InternalArticles/InternalArticlesClient.php +++ b/src/InternalArticles/InternalArticlesClient.php @@ -2,7 +2,7 @@ namespace Intercom\InternalArticles; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Types\InternalArticleList; use Intercom\Exceptions\IntercomException; @@ -11,7 +11,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Types\CreateInternalArticleRequest; use Intercom\InternalArticles\Types\InternalArticleListItem; @@ -61,6 +60,11 @@ public function __construct( /** * You can fetch a list of all internal articles by making a GET request to `https://api.intercom.io/internal_articles`. * + * Example: + * ```php + * $client->internalArticles->listInternalArticles(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -69,11 +73,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return InternalArticleList + * @return ?InternalArticleList * @throws IntercomException * @throws IntercomApiException */ - public function listInternalArticles(?array $options = null): InternalArticleList + public function listInternalArticles(?array $options = null): ?InternalArticleList { $options = array_merge($this->options, $options ?? []); try { @@ -88,20 +92,13 @@ public function listInternalArticles(?array $options = null): InternalArticleLis $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -115,6 +112,18 @@ public function listInternalArticles(?array $options = null): InternalArticleLis /** * You can create a new internal article by making a POST request to `https://api.intercom.io/internal_articles`. * + * Example: + * ```php + * $client->internalArticles->createInternalArticle( + * new CreateInternalArticleRequest([ + * 'title' => 'Thanks for everything', + * 'body' => 'Body of the Article', + * 'authorId' => 991266252, + * 'ownerId' => 991266252, + * ]), + * ); + * ``` + * * @param ?CreateInternalArticleRequest $request * @param ?array{ * baseUrl?: string, @@ -124,11 +133,11 @@ public function listInternalArticles(?array $options = null): InternalArticleLis * queryParameters?: array, * bodyProperties?: array, * } $options - * @return InternalArticleListItem + * @return ?InternalArticleListItem * @throws IntercomException * @throws IntercomApiException */ - public function createInternalArticle(?CreateInternalArticleRequest $request = null, ?array $options = null): InternalArticleListItem + public function createInternalArticle(?CreateInternalArticleRequest $request = null, ?array $options = null): ?InternalArticleListItem { $options = array_merge($this->options, $options ?? []); try { @@ -144,20 +153,13 @@ public function createInternalArticle(?CreateInternalArticleRequest $request = n $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -171,6 +173,15 @@ public function createInternalArticle(?CreateInternalArticleRequest $request = n /** * You can fetch the details of a single internal article by making a GET request to `https://api.intercom.io/internal_articles/`. * + * Example: + * ```php + * $client->internalArticles->retrieveInternalArticle( + * new RetrieveInternalArticleRequest([ + * 'internalArticleId' => 1, + * ]), + * ); + * ``` + * * @param RetrieveInternalArticleRequest $request * @param ?array{ * baseUrl?: string, @@ -180,18 +191,18 @@ public function createInternalArticle(?CreateInternalArticleRequest $request = n * queryParameters?: array, * bodyProperties?: array, * } $options - * @return InternalArticleListItem + * @return ?InternalArticleListItem * @throws IntercomException * @throws IntercomApiException */ - public function retrieveInternalArticle(RetrieveInternalArticleRequest $request, ?array $options = null): InternalArticleListItem + 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()}", + path: "internal_articles/" . RawClient::encodePathParam($request->getInternalArticleId()), method: HttpMethod::GET, ), $options, @@ -199,20 +210,13 @@ public function retrieveInternalArticle(RetrieveInternalArticleRequest $request, $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -226,6 +230,17 @@ public function retrieveInternalArticle(RetrieveInternalArticleRequest $request, /** * You can update the details of a single internal article by making a PUT request to `https://api.intercom.io/internal_articles/`. * + * Example: + * ```php + * $client->internalArticles->updateInternalArticle( + * new UpdateInternalArticleRequestBody([ + * 'internalArticleId' => 1, + * 'title' => 'Christmas is here!', + * 'body' => '

New gifts in store for the jolly season

', + * ]), + * ); + * ``` + * * @param UpdateInternalArticleRequestBody $request * @param ?array{ * baseUrl?: string, @@ -235,18 +250,18 @@ public function retrieveInternalArticle(RetrieveInternalArticleRequest $request, * queryParameters?: array, * bodyProperties?: array, * } $options - * @return InternalArticleListItem + * @return ?InternalArticleListItem * @throws IntercomException * @throws IntercomApiException */ - public function updateInternalArticle(UpdateInternalArticleRequestBody $request, ?array $options = null): InternalArticleListItem + 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()}", + path: "internal_articles/" . RawClient::encodePathParam($request->getInternalArticleId()), method: HttpMethod::PUT, body: $request, ), @@ -255,20 +270,13 @@ public function updateInternalArticle(UpdateInternalArticleRequestBody $request, $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -282,6 +290,15 @@ public function updateInternalArticle(UpdateInternalArticleRequestBody $request, /** * You can delete a single internal article by making a DELETE request to `https://api.intercom.io/internal_articles/`. * + * Example: + * ```php + * $client->internalArticles->deleteInternalArticle( + * new DeleteInternalArticleRequest([ + * 'internalArticleId' => 1, + * ]), + * ); + * ``` + * * @param DeleteInternalArticleRequest $request * @param ?array{ * baseUrl?: string, @@ -291,18 +308,18 @@ public function updateInternalArticle(UpdateInternalArticleRequestBody $request, * queryParameters?: array, * bodyProperties?: array, * } $options - * @return DeletedInternalArticleObject + * @return ?DeletedInternalArticleObject * @throws IntercomException * @throws IntercomApiException */ - public function deleteInternalArticle(DeleteInternalArticleRequest $request, ?array $options = null): DeletedInternalArticleObject + 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()}", + path: "internal_articles/" . RawClient::encodePathParam($request->getInternalArticleId()), method: HttpMethod::DELETE, ), $options, @@ -310,20 +327,13 @@ public function deleteInternalArticle(DeleteInternalArticleRequest $request, ?ar $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -337,6 +347,15 @@ public function deleteInternalArticle(DeleteInternalArticleRequest $request, ?ar /** * You can search for internal articles by making a GET request to `https://api.intercom.io/internal_articles/search`. * + * Example: + * ```php + * $client->internalArticles->searchInternalArticles( + * new SearchInternalArticlesRequest([ + * 'folderId' => 'folder_id', + * ]), + * ); + * ``` + * * @param SearchInternalArticlesRequest $request * @param ?array{ * baseUrl?: string, @@ -346,11 +365,11 @@ public function deleteInternalArticle(DeleteInternalArticleRequest $request, ?ar * queryParameters?: array, * bodyProperties?: array, * } $options - * @return InternalArticleSearchResponse + * @return ?InternalArticleSearchResponse * @throws IntercomException * @throws IntercomApiException */ - public function searchInternalArticles(SearchInternalArticlesRequest $request = new SearchInternalArticlesRequest(), ?array $options = null): InternalArticleSearchResponse + public function searchInternalArticles(SearchInternalArticlesRequest $request = new SearchInternalArticlesRequest(), ?array $options = null): ?InternalArticleSearchResponse { $options = array_merge($this->options, $options ?? []); $query = []; @@ -370,20 +389,13 @@ public function searchInternalArticles(SearchInternalArticlesRequest $request = $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } diff --git a/src/InternalArticles/Requests/DeleteInternalArticleRequest.php b/src/InternalArticles/Requests/DeleteInternalArticleRequest.php index 2bdeb18d..245b5083 100644 --- a/src/InternalArticles/Requests/DeleteInternalArticleRequest.php +++ b/src/InternalArticles/Requests/DeleteInternalArticleRequest.php @@ -36,6 +36,7 @@ public function getInternalArticleId(): int public function setInternalArticleId(int $value): self { $this->internalArticleId = $value; + $this->_setField('internalArticleId'); return $this; } } diff --git a/src/InternalArticles/Requests/RetrieveInternalArticleRequest.php b/src/InternalArticles/Requests/RetrieveInternalArticleRequest.php index cf95e1cd..f669ca69 100644 --- a/src/InternalArticles/Requests/RetrieveInternalArticleRequest.php +++ b/src/InternalArticles/Requests/RetrieveInternalArticleRequest.php @@ -36,6 +36,7 @@ public function getInternalArticleId(): int public function setInternalArticleId(int $value): self { $this->internalArticleId = $value; + $this->_setField('internalArticleId'); return $this; } } diff --git a/src/InternalArticles/Requests/SearchInternalArticlesRequest.php b/src/InternalArticles/Requests/SearchInternalArticlesRequest.php index 1e6e267a..a0c63d6c 100644 --- a/src/InternalArticles/Requests/SearchInternalArticlesRequest.php +++ b/src/InternalArticles/Requests/SearchInternalArticlesRequest.php @@ -36,6 +36,7 @@ public function getFolderId(): ?string public function setFolderId(?string $value = null): self { $this->folderId = $value; + $this->_setField('folderId'); return $this; } } diff --git a/src/InternalArticles/Requests/UpdateInternalArticleRequestBody.php b/src/InternalArticles/Requests/UpdateInternalArticleRequestBody.php index f947e155..6e8bda6d 100644 --- a/src/InternalArticles/Requests/UpdateInternalArticleRequestBody.php +++ b/src/InternalArticles/Requests/UpdateInternalArticleRequestBody.php @@ -69,6 +69,7 @@ public function getInternalArticleId(): int public function setInternalArticleId(int $value): self { $this->internalArticleId = $value; + $this->_setField('internalArticleId'); return $this; } @@ -86,6 +87,7 @@ public function getTitle(): ?string public function setTitle(?string $value = null): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -103,6 +105,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -120,6 +123,7 @@ public function getAuthorId(): ?int public function setAuthorId(?int $value = null): self { $this->authorId = $value; + $this->_setField('authorId'); return $this; } @@ -137,6 +141,7 @@ public function getOwnerId(): ?int public function setOwnerId(?int $value = null): self { $this->ownerId = $value; + $this->_setField('ownerId'); return $this; } } diff --git a/src/InternalArticles/Types/InternalArticleListItem.php b/src/InternalArticles/Types/InternalArticleListItem.php index b5484355..6f055813 100644 --- a/src/InternalArticles/Types/InternalArticleListItem.php +++ b/src/InternalArticles/Types/InternalArticleListItem.php @@ -105,6 +105,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -122,6 +123,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -139,6 +141,7 @@ public function getTitle(): ?string public function setTitle(?string $value = null): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -156,6 +159,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -173,6 +177,7 @@ public function getOwnerId(): ?int public function setOwnerId(?int $value = null): self { $this->ownerId = $value; + $this->_setField('ownerId'); return $this; } @@ -190,6 +195,7 @@ public function getAuthorId(): ?int public function setAuthorId(?int $value = null): self { $this->authorId = $value; + $this->_setField('authorId'); return $this; } @@ -207,6 +213,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -224,6 +231,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -241,6 +249,7 @@ public function getLocale(): ?string public function setLocale(?string $value = null): self { $this->locale = $value; + $this->_setField('locale'); return $this; } diff --git a/src/InternalArticles/Types/InternalArticleSearchResponse.php b/src/InternalArticles/Types/InternalArticleSearchResponse.php index bd420ad0..583e56fa 100644 --- a/src/InternalArticles/Types/InternalArticleSearchResponse.php +++ b/src/InternalArticles/Types/InternalArticleSearchResponse.php @@ -66,6 +66,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -83,6 +84,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -100,6 +102,7 @@ public function getData(): ?InternalArticleSearchResponseData public function setData(?InternalArticleSearchResponseData $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } @@ -117,6 +120,7 @@ public function getPages(): ?CursorPages public function setPages(?CursorPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } diff --git a/src/InternalArticles/Types/InternalArticleSearchResponseData.php b/src/InternalArticles/Types/InternalArticleSearchResponseData.php index 7dbcedd6..8469bcea 100644 --- a/src/InternalArticles/Types/InternalArticleSearchResponseData.php +++ b/src/InternalArticles/Types/InternalArticleSearchResponseData.php @@ -42,6 +42,7 @@ public function getInternalArticles(): ?array public function setInternalArticles(?array $value = null): self { $this->internalArticles = $value; + $this->_setField('internalArticles'); return $this; } diff --git a/src/IpAllowlist/IpAllowlistClient.php b/src/IpAllowlist/IpAllowlistClient.php index ae549afc..a7809155 100644 --- a/src/IpAllowlist/IpAllowlistClient.php +++ b/src/IpAllowlist/IpAllowlistClient.php @@ -2,7 +2,7 @@ namespace Intercom\IpAllowlist; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Types\IpAllowlist; use Intercom\Exceptions\IntercomException; @@ -11,7 +11,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class IpAllowlistClient @@ -53,6 +52,11 @@ public function __construct( /** * Retrieve the current IP allowlist configuration for the workspace. * + * Example: + * ```php + * $client->ipAllowlist->getIpAllowlist(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -61,11 +65,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return IpAllowlist + * @return ?IpAllowlist * @throws IntercomException * @throws IntercomApiException */ - public function getIpAllowlist(?array $options = null): IpAllowlist + public function getIpAllowlist(?array $options = null): ?IpAllowlist { $options = array_merge($this->options, $options ?? []); try { @@ -80,20 +84,13 @@ public function getIpAllowlist(?array $options = null): IpAllowlist $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return IpAllowlist::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); } @@ -111,6 +108,19 @@ public function getIpAllowlist(?array $options = null): IpAllowlist * The API will reject updates that would lock out the caller's IP address. Ensure your current IP is included in the allowlist when enabling the feature. * {% /admonition %} * + * Example: + * ```php + * $client->ipAllowlist->updateIpAllowlist( + * new IpAllowlist([ + * 'enabled' => true, + * 'ipAllowlist' => [ + * '192.168.1.0/24', + * '10.0.0.1', + * ], + * ]), + * ); + * ``` + * * @param IpAllowlist $request * @param ?array{ * baseUrl?: string, @@ -120,11 +130,11 @@ public function getIpAllowlist(?array $options = null): IpAllowlist * queryParameters?: array, * bodyProperties?: array, * } $options - * @return IpAllowlist + * @return ?IpAllowlist * @throws IntercomException * @throws IntercomApiException */ - public function updateIpAllowlist(IpAllowlist $request, ?array $options = null): IpAllowlist + public function updateIpAllowlist(IpAllowlist $request, ?array $options = null): ?IpAllowlist { $options = array_merge($this->options, $options ?? []); try { @@ -140,20 +150,13 @@ public function updateIpAllowlist(IpAllowlist $request, ?array $options = null): $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return IpAllowlist::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); } diff --git a/src/Jobs/JobsClient.php b/src/Jobs/JobsClient.php index ccef60e1..cdbf19ac 100644 --- a/src/Jobs/JobsClient.php +++ b/src/Jobs/JobsClient.php @@ -2,7 +2,7 @@ namespace Intercom\Jobs; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Jobs\Requests\JobsStatusRequest; use Intercom\Jobs\Types\Jobs; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class JobsClient @@ -54,6 +53,15 @@ public function __construct( /** * Retrieve the status of job execution. * + * Example: + * ```php + * $client->jobs->status( + * new JobsStatusRequest([ + * 'jobId' => 'job_id', + * ]), + * ); + * ``` + * * @param JobsStatusRequest $request * @param ?array{ * baseUrl?: string, @@ -63,18 +71,18 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Jobs + * @return ?Jobs * @throws IntercomException * @throws IntercomApiException */ - public function status(JobsStatusRequest $request, ?array $options = null): Jobs + 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()}", + path: "jobs/status/" . RawClient::encodePathParam($request->getJobId()), method: HttpMethod::GET, ), $options, @@ -82,20 +90,13 @@ public function status(JobsStatusRequest $request, ?array $options = null): Jobs $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } diff --git a/src/Jobs/Requests/JobsStatusRequest.php b/src/Jobs/Requests/JobsStatusRequest.php index e5ee7be3..1776cac2 100644 --- a/src/Jobs/Requests/JobsStatusRequest.php +++ b/src/Jobs/Requests/JobsStatusRequest.php @@ -36,6 +36,7 @@ public function getJobId(): string public function setJobId(string $value): self { $this->jobId = $value; + $this->_setField('jobId'); return $this; } } diff --git a/src/Jobs/Types/Jobs.php b/src/Jobs/Types/Jobs.php index 6a096ea6..eda2a37c 100644 --- a/src/Jobs/Types/Jobs.php +++ b/src/Jobs/Types/Jobs.php @@ -89,6 +89,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -106,6 +107,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -123,6 +125,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -140,6 +143,7 @@ public function getStatus(): ?string public function setStatus(?string $value = null): self { $this->status = $value; + $this->_setField('status'); return $this; } @@ -157,6 +161,7 @@ public function getResourceType(): ?string public function setResourceType(?string $value = null): self { $this->resourceType = $value; + $this->_setField('resourceType'); return $this; } @@ -174,6 +179,7 @@ public function getResourceId(): ?string public function setResourceId(?string $value = null): self { $this->resourceId = $value; + $this->_setField('resourceId'); return $this; } @@ -191,6 +197,7 @@ public function getResourceUrl(): ?string public function setResourceUrl(?string $value = null): self { $this->resourceUrl = $value; + $this->_setField('resourceUrl'); return $this; } diff --git a/src/Messages/MessagesClient.php b/src/Messages/MessagesClient.php index ab347828..4ced40dd 100644 --- a/src/Messages/MessagesClient.php +++ b/src/Messages/MessagesClient.php @@ -2,7 +2,7 @@ namespace Intercom\Messages; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Types\CreateMessageRequest; use Intercom\Messages\Types\Message; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class MessagesClient @@ -64,6 +63,25 @@ public function __construct( * > * > 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. * + * Example: + * ```php + * $client->messages->create( + * CreateMessageRequest::email(new CreateMessageRequestWithEmail([ + * 'subject' => 'Thanks for everything', + * 'body' => 'Hello there', + * 'template' => 'plain', + * 'from' => new CreateMessageRequestFrom([ + * 'type' => 'admin', + * 'id' => 394051, + * ]), + * 'to' => new CreateMessageRequestTo([ + * 'type' => CreateMessageRequestType::User->value, + * 'id' => '536e564f316c83104c000020', + * ]), + * ])), + * ); + * ``` + * * @param ?CreateMessageRequest $request * @param ?array{ * baseUrl?: string, @@ -73,11 +91,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Message + * @return ?Message * @throws IntercomException * @throws IntercomApiException */ - public function create(?CreateMessageRequest $request = null, ?array $options = null): Message + public function create(?CreateMessageRequest $request = null, ?array $options = null): ?Message { $options = array_merge($this->options, $options ?? []); try { @@ -93,20 +111,13 @@ public function create(?CreateMessageRequest $request = null, ?array $options = $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Message::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); } diff --git a/src/Messages/Types/Message.php b/src/Messages/Types/Message.php index 18bc4600..97c0365b 100644 --- a/src/Messages/Types/Message.php +++ b/src/Messages/Types/Message.php @@ -89,6 +89,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -106,6 +107,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -123,6 +125,7 @@ public function getCreatedAt(): int public function setCreatedAt(int $value): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -140,6 +143,7 @@ public function getSubject(): ?string public function setSubject(?string $value = null): self { $this->subject = $value; + $this->_setField('subject'); return $this; } @@ -157,6 +161,7 @@ public function getBody(): string public function setBody(string $value): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -174,6 +179,7 @@ public function getMessageType(): string public function setMessageType(string $value): self { $this->messageType = $value; + $this->_setField('messageType'); return $this; } @@ -191,6 +197,7 @@ public function getConversationId(): ?string public function setConversationId(?string $value = null): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } diff --git a/src/News/Feeds/FeedsClient.php b/src/News/Feeds/FeedsClient.php index 97e255bf..7d57a467 100644 --- a/src/News/Feeds/FeedsClient.php +++ b/src/News/Feeds/FeedsClient.php @@ -2,7 +2,7 @@ namespace Intercom\News\Feeds; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\News\Feeds\Requests\ListNewsFeedItemsRequest; use Intercom\Types\PaginatedResponse; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\News\Feeds\Requests\FindNewsFeedRequest; use Intercom\News\Types\Newsfeed; @@ -56,6 +55,15 @@ public function __construct( /** * You can fetch a list of all news items that are live on a given newsfeed * + * Example: + * ```php + * $client->news->feeds->listItems( + * new ListNewsFeedItemsRequest([ + * 'newsfeedId' => '123', + * ]), + * ); + * ``` + * * @param ListNewsFeedItemsRequest $request * @param ?array{ * baseUrl?: string, @@ -65,18 +73,18 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return PaginatedResponse + * @return ?PaginatedResponse * @throws IntercomException * @throws IntercomApiException */ - public function listItems(ListNewsFeedItemsRequest $request, ?array $options = null): PaginatedResponse + public function listItems(ListNewsFeedItemsRequest $request, ?array $options = null): ?PaginatedResponse { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "news/newsfeeds/{$request->getNewsfeedId()}/items", + path: "news/newsfeeds/" . RawClient::encodePathParam($request->getNewsfeedId()) . "/items", method: HttpMethod::GET, ), $options, @@ -84,20 +92,13 @@ public function listItems(ListNewsFeedItemsRequest $request, ?array $options = n $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return PaginatedResponse::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); } @@ -111,6 +112,11 @@ public function listItems(ListNewsFeedItemsRequest $request, ?array $options = n /** * You can fetch a list of all newsfeeds * + * Example: + * ```php + * $client->news->feeds->list(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -119,11 +125,11 @@ public function listItems(ListNewsFeedItemsRequest $request, ?array $options = n * queryParameters?: array, * bodyProperties?: array, * } $options - * @return PaginatedResponse + * @return ?PaginatedResponse * @throws IntercomException * @throws IntercomApiException */ - public function list(?array $options = null): PaginatedResponse + public function list(?array $options = null): ?PaginatedResponse { $options = array_merge($this->options, $options ?? []); try { @@ -138,20 +144,13 @@ public function list(?array $options = null): PaginatedResponse $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return PaginatedResponse::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); } @@ -165,6 +164,15 @@ public function list(?array $options = null): PaginatedResponse /** * You can fetch the details of a single newsfeed * + * Example: + * ```php + * $client->news->feeds->find( + * new FindNewsFeedRequest([ + * 'newsfeedId' => '123', + * ]), + * ); + * ``` + * * @param FindNewsFeedRequest $request * @param ?array{ * baseUrl?: string, @@ -174,18 +182,18 @@ public function list(?array $options = null): PaginatedResponse * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Newsfeed + * @return ?Newsfeed * @throws IntercomException * @throws IntercomApiException */ - public function find(FindNewsFeedRequest $request, ?array $options = null): Newsfeed + public function find(FindNewsFeedRequest $request, ?array $options = null): ?Newsfeed { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "news/newsfeeds/{$request->getNewsfeedId()}", + path: "news/newsfeeds/" . RawClient::encodePathParam($request->getNewsfeedId()), method: HttpMethod::GET, ), $options, @@ -193,20 +201,13 @@ public function find(FindNewsFeedRequest $request, ?array $options = null): News $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Newsfeed::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); } diff --git a/src/News/Feeds/Requests/FindNewsFeedRequest.php b/src/News/Feeds/Requests/FindNewsFeedRequest.php index 2f38b123..8a9df213 100644 --- a/src/News/Feeds/Requests/FindNewsFeedRequest.php +++ b/src/News/Feeds/Requests/FindNewsFeedRequest.php @@ -36,6 +36,7 @@ public function getNewsfeedId(): string public function setNewsfeedId(string $value): self { $this->newsfeedId = $value; + $this->_setField('newsfeedId'); return $this; } } diff --git a/src/News/Feeds/Requests/ListNewsFeedItemsRequest.php b/src/News/Feeds/Requests/ListNewsFeedItemsRequest.php index 16234900..baa050ee 100644 --- a/src/News/Feeds/Requests/ListNewsFeedItemsRequest.php +++ b/src/News/Feeds/Requests/ListNewsFeedItemsRequest.php @@ -36,6 +36,7 @@ public function getNewsfeedId(): string public function setNewsfeedId(string $value): self { $this->newsfeedId = $value; + $this->_setField('newsfeedId'); return $this; } } diff --git a/src/News/Items/ItemsClient.php b/src/News/Items/ItemsClient.php index f536ae36..219f1e7a 100644 --- a/src/News/Items/ItemsClient.php +++ b/src/News/Items/ItemsClient.php @@ -2,7 +2,7 @@ namespace Intercom\News\Items; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Types\PaginatedResponse; use Intercom\Exceptions\IntercomException; @@ -11,7 +11,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Types\NewsItemRequest; use Intercom\News\Types\NewsItem; @@ -59,6 +58,11 @@ public function __construct( /** * You can fetch a list of all news items * + * Example: + * ```php + * $client->news->items->list(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -67,11 +71,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return PaginatedResponse + * @return ?PaginatedResponse * @throws IntercomException * @throws IntercomApiException */ - public function list(?array $options = null): PaginatedResponse + public function list(?array $options = null): ?PaginatedResponse { $options = array_merge($this->options, $options ?? []); try { @@ -86,20 +90,13 @@ public function list(?array $options = null): PaginatedResponse $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return PaginatedResponse::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); } @@ -113,6 +110,34 @@ public function list(?array $options = null): PaginatedResponse /** * You can create a news item * + * Example: + * ```php + * $client->news->items->create( + * new NewsItemRequest([ + * 'title' => 'Halloween is here!', + * 'body' => '

New costumes in store for this spooky season

', + * 'senderId' => 991267834, + * 'state' => NewsItemRequestState::Live->value, + * 'deliverSilently' => true, + * 'labels' => [ + * 'Product', + * 'Update', + * 'New', + * ], + * 'reactions' => [ + * '😆', + * '😅', + * ], + * 'newsfeedAssignments' => [ + * new NewsfeedAssignment([ + * 'newsfeedId' => 53, + * 'publishedAt' => 1664638214, + * ]), + * ], + * ]), + * ); + * ``` + * * @param NewsItemRequest $request * @param ?array{ * baseUrl?: string, @@ -122,11 +147,11 @@ public function list(?array $options = null): PaginatedResponse * queryParameters?: array, * bodyProperties?: array, * } $options - * @return NewsItem + * @return ?NewsItem * @throws IntercomException * @throws IntercomApiException */ - public function create(NewsItemRequest $request, ?array $options = null): NewsItem + public function create(NewsItemRequest $request, ?array $options = null): ?NewsItem { $options = array_merge($this->options, $options ?? []); try { @@ -142,20 +167,13 @@ public function create(NewsItemRequest $request, ?array $options = null): NewsIt $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return NewsItem::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); } @@ -169,6 +187,15 @@ public function create(NewsItemRequest $request, ?array $options = null): NewsIt /** * You can fetch the details of a single news item. * + * Example: + * ```php + * $client->news->items->find( + * new FindNewsItemRequest([ + * 'newsItemId' => 1, + * ]), + * ); + * ``` + * * @param FindNewsItemRequest $request * @param ?array{ * baseUrl?: string, @@ -178,18 +205,18 @@ public function create(NewsItemRequest $request, ?array $options = null): NewsIt * queryParameters?: array, * bodyProperties?: array, * } $options - * @return NewsItem + * @return ?NewsItem * @throws IntercomException * @throws IntercomApiException */ - public function find(FindNewsItemRequest $request, ?array $options = null): NewsItem + public function find(FindNewsItemRequest $request, ?array $options = null): ?NewsItem { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "news/news_items/{$request->getNewsItemId()}", + path: "news/news_items/" . RawClient::encodePathParam($request->getNewsItemId()), method: HttpMethod::GET, ), $options, @@ -197,20 +224,13 @@ public function find(FindNewsItemRequest $request, ?array $options = null): News $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return NewsItem::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); } @@ -222,6 +242,24 @@ public function find(FindNewsItemRequest $request, ?array $options = null): News } /** + * Example: + * ```php + * $client->news->items->update( + * new UpdateNewsItemRequest([ + * 'newsItemId' => 1, + * 'body' => new NewsItemRequest([ + * 'title' => 'Christmas is here!', + * 'body' => '

New gifts in store for the jolly season

', + * 'senderId' => 991267845, + * 'reactions' => [ + * '😝', + * '😂', + * ], + * ]), + * ]), + * ); + * ``` + * * @param UpdateNewsItemRequest $request * @param ?array{ * baseUrl?: string, @@ -231,18 +269,18 @@ public function find(FindNewsItemRequest $request, ?array $options = null): News * queryParameters?: array, * bodyProperties?: array, * } $options - * @return NewsItem + * @return ?NewsItem * @throws IntercomException * @throws IntercomApiException */ - public function update(UpdateNewsItemRequest $request, ?array $options = null): NewsItem + public function update(UpdateNewsItemRequest $request, ?array $options = null): ?NewsItem { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "news/news_items/{$request->getNewsItemId()}", + path: "news/news_items/" . RawClient::encodePathParam($request->getNewsItemId()), method: HttpMethod::PUT, body: $request->getBody(), ), @@ -251,20 +289,13 @@ public function update(UpdateNewsItemRequest $request, ?array $options = null): $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return NewsItem::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); } @@ -278,6 +309,15 @@ public function update(UpdateNewsItemRequest $request, ?array $options = null): /** * You can delete a single news item. * + * Example: + * ```php + * $client->news->items->delete( + * new DeleteNewsItemRequest([ + * 'newsItemId' => 1, + * ]), + * ); + * ``` + * * @param DeleteNewsItemRequest $request * @param ?array{ * baseUrl?: string, @@ -287,18 +327,18 @@ public function update(UpdateNewsItemRequest $request, ?array $options = null): * queryParameters?: array, * bodyProperties?: array, * } $options - * @return DeletedObject + * @return ?DeletedObject * @throws IntercomException * @throws IntercomApiException */ - public function delete(DeleteNewsItemRequest $request, ?array $options = null): DeletedObject + public function delete(DeleteNewsItemRequest $request, ?array $options = null): ?DeletedObject { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "news/news_items/{$request->getNewsItemId()}", + path: "news/news_items/" . RawClient::encodePathParam($request->getNewsItemId()), method: HttpMethod::DELETE, ), $options, @@ -306,20 +346,13 @@ public function delete(DeleteNewsItemRequest $request, ?array $options = null): $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return DeletedObject::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); } diff --git a/src/News/Items/Requests/DeleteNewsItemRequest.php b/src/News/Items/Requests/DeleteNewsItemRequest.php index ffaeaaaf..562e2a49 100644 --- a/src/News/Items/Requests/DeleteNewsItemRequest.php +++ b/src/News/Items/Requests/DeleteNewsItemRequest.php @@ -36,6 +36,7 @@ public function getNewsItemId(): int public function setNewsItemId(int $value): self { $this->newsItemId = $value; + $this->_setField('newsItemId'); return $this; } } diff --git a/src/News/Items/Requests/FindNewsItemRequest.php b/src/News/Items/Requests/FindNewsItemRequest.php index 9d019d4c..05b4b554 100644 --- a/src/News/Items/Requests/FindNewsItemRequest.php +++ b/src/News/Items/Requests/FindNewsItemRequest.php @@ -36,6 +36,7 @@ public function getNewsItemId(): int public function setNewsItemId(int $value): self { $this->newsItemId = $value; + $this->_setField('newsItemId'); return $this; } } diff --git a/src/News/Items/Requests/UpdateNewsItemRequest.php b/src/News/Items/Requests/UpdateNewsItemRequest.php index 79d0c2c1..0d7528af 100644 --- a/src/News/Items/Requests/UpdateNewsItemRequest.php +++ b/src/News/Items/Requests/UpdateNewsItemRequest.php @@ -44,6 +44,7 @@ public function getNewsItemId(): int public function setNewsItemId(int $value): self { $this->newsItemId = $value; + $this->_setField('newsItemId'); return $this; } @@ -61,6 +62,7 @@ public function getBody(): NewsItemRequest public function setBody(NewsItemRequest $value): self { $this->body = $value; + $this->_setField('body'); return $this; } } diff --git a/src/News/NewsClient.php b/src/News/NewsClient.php index 43dee006..3cb7d4ff 100644 --- a/src/News/NewsClient.php +++ b/src/News/NewsClient.php @@ -4,7 +4,7 @@ use Intercom\News\Items\ItemsClient; use Intercom\News\Feeds\FeedsClient; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; class NewsClient diff --git a/src/News/Types/NewsItem.php b/src/News/Types/NewsItem.php index 39403f52..f95d1830 100644 --- a/src/News/Types/NewsItem.php +++ b/src/News/Types/NewsItem.php @@ -147,6 +147,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -164,6 +165,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -181,6 +183,7 @@ public function getWorkspaceId(): ?string public function setWorkspaceId(?string $value = null): self { $this->workspaceId = $value; + $this->_setField('workspaceId'); return $this; } @@ -198,6 +201,7 @@ public function getTitle(): ?string public function setTitle(?string $value = null): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -215,6 +219,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -232,6 +237,7 @@ public function getSenderId(): ?int public function setSenderId(?int $value = null): self { $this->senderId = $value; + $this->_setField('senderId'); return $this; } @@ -249,6 +255,7 @@ public function getState(): ?string public function setState(?string $value = null): self { $this->state = $value; + $this->_setField('state'); return $this; } @@ -266,6 +273,7 @@ public function getNewsfeedAssignments(): ?array public function setNewsfeedAssignments(?array $value = null): self { $this->newsfeedAssignments = $value; + $this->_setField('newsfeedAssignments'); return $this; } @@ -283,6 +291,7 @@ public function getLabels(): ?array public function setLabels(?array $value = null): self { $this->labels = $value; + $this->_setField('labels'); return $this; } @@ -300,6 +309,7 @@ public function getCoverImageUrl(): ?string public function setCoverImageUrl(?string $value = null): self { $this->coverImageUrl = $value; + $this->_setField('coverImageUrl'); return $this; } @@ -317,6 +327,7 @@ public function getReactions(): ?array public function setReactions(?array $value = null): self { $this->reactions = $value; + $this->_setField('reactions'); return $this; } @@ -334,6 +345,7 @@ public function getDeliverSilently(): ?bool public function setDeliverSilently(?bool $value = null): self { $this->deliverSilently = $value; + $this->_setField('deliverSilently'); return $this; } @@ -351,6 +363,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -368,6 +381,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } diff --git a/src/News/Types/Newsfeed.php b/src/News/Types/Newsfeed.php index 406564ed..c9cac049 100644 --- a/src/News/Types/Newsfeed.php +++ b/src/News/Types/Newsfeed.php @@ -75,6 +75,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -92,6 +93,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -109,6 +111,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -126,6 +129,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -143,6 +147,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } diff --git a/src/News/Types/NewsfeedAssignment.php b/src/News/Types/NewsfeedAssignment.php index 58995f6e..130c0f0f 100644 --- a/src/News/Types/NewsfeedAssignment.php +++ b/src/News/Types/NewsfeedAssignment.php @@ -49,6 +49,7 @@ public function getNewsfeedId(): ?int public function setNewsfeedId(?int $value = null): self { $this->newsfeedId = $value; + $this->_setField('newsfeedId'); return $this; } @@ -66,6 +67,7 @@ public function getPublishedAt(): ?int public function setPublishedAt(?int $value = null): self { $this->publishedAt = $value; + $this->_setField('publishedAt'); return $this; } diff --git a/src/Notes/NotesClient.php b/src/Notes/NotesClient.php index 4e36c938..fdf8fe74 100644 --- a/src/Notes/NotesClient.php +++ b/src/Notes/NotesClient.php @@ -2,7 +2,7 @@ namespace Intercom\Notes; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Notes\Requests\ListContactNotesRequest; use Intercom\Core\Pagination\Pager; @@ -16,7 +16,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Notes\Requests\FindNoteRequest; @@ -59,6 +58,17 @@ public function __construct( /** * You can fetch a list of notes that are associated to a contact. * + * Example: + * ```php + * $client->notes->list( + * new ListContactNotesRequest([ + * 'contactId' => 'contact_id', + * 'page' => 1, + * 'perPage' => 1, + * ]), + * ); + * ``` + * * @param ListContactNotesRequest $request * @param ?array{ * baseUrl?: string, @@ -82,7 +92,7 @@ public function list(ListContactNotesRequest $request, ?array $options = null): }, getStep: null, /* @phpstan-ignore-next-line */ - getItems: fn (NoteList $response) => $response?->getData() ?? [], + getItems: fn (?NoteList $response) => $response?->getData() ?? [], /* @phpstan-ignore-next-line */ hasNextPage: null, ); @@ -91,6 +101,17 @@ public function list(ListContactNotesRequest $request, ?array $options = null): /** * You can add a note to a single contact. * + * Example: + * ```php + * $client->notes->create( + * new CreateContactNoteRequest([ + * 'contactId' => '123', + * 'body' => 'Hello', + * 'adminId' => '123', + * ]), + * ); + * ``` + * * @param CreateContactNoteRequest $request * @param ?array{ * baseUrl?: string, @@ -100,18 +121,18 @@ public function list(ListContactNotesRequest $request, ?array $options = null): * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Note + * @return ?Note * @throws IntercomException * @throws IntercomApiException */ - public function create(CreateContactNoteRequest $request, ?array $options = null): Note + public function create(CreateContactNoteRequest $request, ?array $options = null): ?Note { $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()}/notes", + path: "contacts/" . RawClient::encodePathParam($request->getContactId()) . "/notes", method: HttpMethod::POST, body: $request, ), @@ -120,20 +141,13 @@ public function create(CreateContactNoteRequest $request, ?array $options = null $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Note::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); } @@ -147,6 +161,15 @@ public function create(CreateContactNoteRequest $request, ?array $options = null /** * You can fetch the details of a single note. * + * Example: + * ```php + * $client->notes->find( + * new FindNoteRequest([ + * 'noteId' => 1, + * ]), + * ); + * ``` + * * @param FindNoteRequest $request * @param ?array{ * baseUrl?: string, @@ -156,18 +179,18 @@ public function create(CreateContactNoteRequest $request, ?array $options = null * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Note + * @return ?Note * @throws IntercomException * @throws IntercomApiException */ - public function find(FindNoteRequest $request, ?array $options = null): Note + public function find(FindNoteRequest $request, ?array $options = null): ?Note { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "notes/{$request->getNoteId()}", + path: "notes/" . RawClient::encodePathParam($request->getNoteId()), method: HttpMethod::GET, ), $options, @@ -175,20 +198,13 @@ public function find(FindNoteRequest $request, ?array $options = null): Note $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Note::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); } @@ -211,11 +227,11 @@ public function find(FindNoteRequest $request, ?array $options = null): Note * queryParameters?: array, * bodyProperties?: array, * } $options - * @return NoteList + * @return ?NoteList * @throws IntercomException * @throws IntercomApiException */ - private function _list(ListContactNotesRequest $request, ?array $options = null): NoteList + private function _list(ListContactNotesRequest $request, ?array $options = null): ?NoteList { $options = array_merge($this->options, $options ?? []); $query = []; @@ -229,7 +245,7 @@ private function _list(ListContactNotesRequest $request, ?array $options = null) $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "contacts/{$request->getContactId()}/notes", + path: "contacts/" . RawClient::encodePathParam($request->getContactId()) . "/notes", method: HttpMethod::GET, query: $query, ), @@ -238,20 +254,13 @@ private function _list(ListContactNotesRequest $request, ?array $options = null) $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return NoteList::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); } diff --git a/src/Notes/Requests/CreateContactNoteRequest.php b/src/Notes/Requests/CreateContactNoteRequest.php index 7d3ab6e0..398f8baf 100644 --- a/src/Notes/Requests/CreateContactNoteRequest.php +++ b/src/Notes/Requests/CreateContactNoteRequest.php @@ -53,6 +53,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } @@ -70,6 +71,7 @@ public function getBody(): string public function setBody(string $value): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -87,6 +89,7 @@ public function getAdminId(): ?string public function setAdminId(?string $value = null): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } } diff --git a/src/Notes/Requests/FindNoteRequest.php b/src/Notes/Requests/FindNoteRequest.php index 7142d979..eefbfa16 100644 --- a/src/Notes/Requests/FindNoteRequest.php +++ b/src/Notes/Requests/FindNoteRequest.php @@ -36,6 +36,7 @@ public function getNoteId(): int public function setNoteId(int $value): self { $this->noteId = $value; + $this->_setField('noteId'); return $this; } } diff --git a/src/Notes/Requests/ListContactNotesRequest.php b/src/Notes/Requests/ListContactNotesRequest.php index 76f7ecdb..10317ef3 100644 --- a/src/Notes/Requests/ListContactNotesRequest.php +++ b/src/Notes/Requests/ListContactNotesRequest.php @@ -50,6 +50,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } @@ -67,6 +68,7 @@ public function getPage(): ?int public function setPage(?int $value = null): self { $this->page = $value; + $this->_setField('page'); return $this; } @@ -84,6 +86,7 @@ public function getPerPage(): ?int public function setPerPage(?int $value = null): self { $this->perPage = $value; + $this->_setField('perPage'); return $this; } } diff --git a/src/Notes/Types/Note.php b/src/Notes/Types/Note.php index 5e47daa6..0057f7da 100644 --- a/src/Notes/Types/Note.php +++ b/src/Notes/Types/Note.php @@ -82,6 +82,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -99,6 +100,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -116,6 +118,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -133,6 +136,7 @@ public function getContact(): ?NoteContact public function setContact(?NoteContact $value = null): self { $this->contact = $value; + $this->_setField('contact'); return $this; } @@ -150,6 +154,7 @@ public function getAuthor(): ?Admin public function setAuthor(?Admin $value = null): self { $this->author = $value; + $this->_setField('author'); return $this; } @@ -167,6 +172,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } diff --git a/src/Notes/Types/NoteContact.php b/src/Notes/Types/NoteContact.php index d6b0fc19..984e29c3 100644 --- a/src/Notes/Types/NoteContact.php +++ b/src/Notes/Types/NoteContact.php @@ -49,6 +49,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -66,6 +67,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } diff --git a/src/PhoneCallRedirects/PhoneCallRedirectsClient.php b/src/PhoneCallRedirects/PhoneCallRedirectsClient.php index 194ef68e..4f64eefa 100644 --- a/src/PhoneCallRedirects/PhoneCallRedirectsClient.php +++ b/src/PhoneCallRedirects/PhoneCallRedirectsClient.php @@ -2,7 +2,7 @@ namespace Intercom\PhoneCallRedirects; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Types\CreatePhoneSwitchRequest; use Intercom\Types\PhoneSwitch; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class PhoneCallRedirectsClient @@ -57,6 +56,19 @@ public function __construct( * * If custom attributes are specified, they will be added to the user or lead's custom data attributes. * + * Example: + * ```php + * $client->phoneCallRedirects->create( + * new CreatePhoneSwitchRequest([ + * 'phone' => '+353832345678', + * 'customAttributes' => [ + * 'issue_type' => 'Billing', + * 'priority' => 'High', + * ], + * ]), + * ); + * ``` + * * @param ?CreatePhoneSwitchRequest $request * @param ?array{ * baseUrl?: string, @@ -93,16 +105,6 @@ public function create(?CreatePhoneSwitchRequest $request = null, ?array $option } } 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); } diff --git a/src/Segments/Requests/FindSegmentRequest.php b/src/Segments/Requests/FindSegmentRequest.php index ceade37a..8d2b1244 100644 --- a/src/Segments/Requests/FindSegmentRequest.php +++ b/src/Segments/Requests/FindSegmentRequest.php @@ -36,6 +36,7 @@ public function getSegmentId(): string public function setSegmentId(string $value): self { $this->segmentId = $value; + $this->_setField('segmentId'); return $this; } } diff --git a/src/Segments/Requests/ListSegmentsRequest.php b/src/Segments/Requests/ListSegmentsRequest.php index 98fb040d..381a4c9d 100644 --- a/src/Segments/Requests/ListSegmentsRequest.php +++ b/src/Segments/Requests/ListSegmentsRequest.php @@ -36,6 +36,7 @@ public function getIncludeCount(): ?bool public function setIncludeCount(?bool $value = null): self { $this->includeCount = $value; + $this->_setField('includeCount'); return $this; } } diff --git a/src/Segments/SegmentsClient.php b/src/Segments/SegmentsClient.php index 0d883fbe..3d68bdfd 100644 --- a/src/Segments/SegmentsClient.php +++ b/src/Segments/SegmentsClient.php @@ -2,7 +2,7 @@ namespace Intercom\Segments; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Segments\Requests\ListSegmentsRequest; use Intercom\Types\SegmentList; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Segments\Requests\FindSegmentRequest; use Intercom\Segments\Types\Segment; @@ -56,6 +55,15 @@ public function __construct( /** * You can fetch a list of all segments. * + * Example: + * ```php + * $client->segments->list( + * new ListSegmentsRequest([ + * 'includeCount' => true, + * ]), + * ); + * ``` + * * @param ListSegmentsRequest $request * @param ?array{ * baseUrl?: string, @@ -65,11 +73,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return SegmentList + * @return ?SegmentList * @throws IntercomException * @throws IntercomApiException */ - public function list(ListSegmentsRequest $request = new ListSegmentsRequest(), ?array $options = null): SegmentList + public function list(ListSegmentsRequest $request = new ListSegmentsRequest(), ?array $options = null): ?SegmentList { $options = array_merge($this->options, $options ?? []); $query = []; @@ -89,20 +97,13 @@ public function list(ListSegmentsRequest $request = new ListSegmentsRequest(), ? $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return SegmentList::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); } @@ -116,6 +117,15 @@ public function list(ListSegmentsRequest $request = new ListSegmentsRequest(), ? /** * You can fetch the details of a single segment. * + * Example: + * ```php + * $client->segments->find( + * new FindSegmentRequest([ + * 'segmentId' => '123', + * ]), + * ); + * ``` + * * @param FindSegmentRequest $request * @param ?array{ * baseUrl?: string, @@ -125,18 +135,18 @@ public function list(ListSegmentsRequest $request = new ListSegmentsRequest(), ? * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Segment + * @return ?Segment * @throws IntercomException * @throws IntercomApiException */ - public function find(FindSegmentRequest $request, ?array $options = null): Segment + public function find(FindSegmentRequest $request, ?array $options = null): ?Segment { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "segments/{$request->getSegmentId()}", + path: "segments/" . RawClient::encodePathParam($request->getSegmentId()), method: HttpMethod::GET, ), $options, @@ -144,20 +154,13 @@ public function find(FindSegmentRequest $request, ?array $options = null): Segme $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Segment::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); } diff --git a/src/Segments/Types/Segment.php b/src/Segments/Types/Segment.php index 5dac3f5b..dfc567c3 100644 --- a/src/Segments/Types/Segment.php +++ b/src/Segments/Types/Segment.php @@ -89,6 +89,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -106,6 +107,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -123,6 +125,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -140,6 +143,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -157,6 +161,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -174,6 +179,7 @@ public function getPersonType(): ?string public function setPersonType(?string $value = null): self { $this->personType = $value; + $this->_setField('personType'); return $this; } @@ -191,6 +197,7 @@ public function getCount(): ?int public function setCount(?int $value = null): self { $this->count = $value; + $this->_setField('count'); return $this; } diff --git a/src/SubscriptionTypes/SubscriptionTypesClient.php b/src/SubscriptionTypes/SubscriptionTypesClient.php index a1eb02df..e7348343 100644 --- a/src/SubscriptionTypes/SubscriptionTypesClient.php +++ b/src/SubscriptionTypes/SubscriptionTypesClient.php @@ -2,7 +2,7 @@ namespace Intercom\SubscriptionTypes; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Types\SubscriptionTypeList; use Intercom\Exceptions\IntercomException; @@ -11,7 +11,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class SubscriptionTypesClient @@ -53,6 +52,11 @@ public function __construct( /** * You can list all subscription types. A list of subscription type objects will be returned. * + * Example: + * ```php + * $client->subscriptionTypes->list(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -61,11 +65,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return SubscriptionTypeList + * @return ?SubscriptionTypeList * @throws IntercomException * @throws IntercomApiException */ - public function list(?array $options = null): SubscriptionTypeList + public function list(?array $options = null): ?SubscriptionTypeList { $options = array_merge($this->options, $options ?? []); try { @@ -80,20 +84,13 @@ public function list(?array $options = null): SubscriptionTypeList $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return SubscriptionTypeList::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); } diff --git a/src/SubscriptionTypes/Types/SubscriptionType.php b/src/SubscriptionTypes/Types/SubscriptionType.php index 78c12fd2..2e6f2a05 100644 --- a/src/SubscriptionTypes/Types/SubscriptionType.php +++ b/src/SubscriptionTypes/Types/SubscriptionType.php @@ -91,6 +91,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -108,6 +109,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -125,6 +127,7 @@ public function getState(): ?string public function setState(?string $value = null): self { $this->state = $value; + $this->_setField('state'); return $this; } @@ -142,6 +145,7 @@ public function getDefaultTranslation(): ?Translation public function setDefaultTranslation(?Translation $value = null): self { $this->defaultTranslation = $value; + $this->_setField('defaultTranslation'); return $this; } @@ -159,6 +163,7 @@ public function getTranslations(): ?array public function setTranslations(?array $value = null): self { $this->translations = $value; + $this->_setField('translations'); return $this; } @@ -176,6 +181,7 @@ public function getConsentType(): ?string public function setConsentType(?string $value = null): self { $this->consentType = $value; + $this->_setField('consentType'); return $this; } @@ -193,6 +199,7 @@ public function getContentTypes(): ?array public function setContentTypes(?array $value = null): self { $this->contentTypes = $value; + $this->_setField('contentTypes'); return $this; } diff --git a/src/Tags/Requests/DeleteTagRequest.php b/src/Tags/Requests/DeleteTagRequest.php index 7dfe1dcb..cbb3b87c 100644 --- a/src/Tags/Requests/DeleteTagRequest.php +++ b/src/Tags/Requests/DeleteTagRequest.php @@ -36,6 +36,7 @@ public function getTagId(): string public function setTagId(string $value): self { $this->tagId = $value; + $this->_setField('tagId'); return $this; } } diff --git a/src/Tags/Requests/FindTagRequest.php b/src/Tags/Requests/FindTagRequest.php index af911b84..16ae290e 100644 --- a/src/Tags/Requests/FindTagRequest.php +++ b/src/Tags/Requests/FindTagRequest.php @@ -36,6 +36,7 @@ public function getTagId(): string public function setTagId(string $value): self { $this->tagId = $value; + $this->_setField('tagId'); return $this; } } diff --git a/src/Tags/Requests/TagContactRequest.php b/src/Tags/Requests/TagContactRequest.php index bb695ce8..d3504e4b 100644 --- a/src/Tags/Requests/TagContactRequest.php +++ b/src/Tags/Requests/TagContactRequest.php @@ -45,6 +45,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } @@ -62,6 +63,7 @@ public function getTagId(): string public function setTagId(string $value): self { $this->tagId = $value; + $this->_setField('tagId'); return $this; } } diff --git a/src/Tags/Requests/TagConversationRequest.php b/src/Tags/Requests/TagConversationRequest.php index 6165c2f5..cefd0aa9 100644 --- a/src/Tags/Requests/TagConversationRequest.php +++ b/src/Tags/Requests/TagConversationRequest.php @@ -53,6 +53,7 @@ public function getConversationId(): string public function setConversationId(string $value): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } @@ -70,6 +71,7 @@ public function getTagId(): string public function setTagId(string $value): self { $this->tagId = $value; + $this->_setField('tagId'); return $this; } @@ -87,6 +89,7 @@ public function getAdminId(): string public function setAdminId(string $value): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } } diff --git a/src/Tags/Requests/TagTicketRequest.php b/src/Tags/Requests/TagTicketRequest.php index c0615820..5ae62ec3 100644 --- a/src/Tags/Requests/TagTicketRequest.php +++ b/src/Tags/Requests/TagTicketRequest.php @@ -53,6 +53,7 @@ public function getTicketId(): string public function setTicketId(string $value): self { $this->ticketId = $value; + $this->_setField('ticketId'); return $this; } @@ -70,6 +71,7 @@ public function getTagId(): string public function setTagId(string $value): self { $this->tagId = $value; + $this->_setField('tagId'); return $this; } @@ -87,6 +89,7 @@ public function getAdminId(): string public function setAdminId(string $value): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } } diff --git a/src/Tags/Requests/UntagContactRequest.php b/src/Tags/Requests/UntagContactRequest.php index 6b8f9e5f..333fb74e 100644 --- a/src/Tags/Requests/UntagContactRequest.php +++ b/src/Tags/Requests/UntagContactRequest.php @@ -43,6 +43,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } @@ -60,6 +61,7 @@ public function getTagId(): string public function setTagId(string $value): self { $this->tagId = $value; + $this->_setField('tagId'); return $this; } } diff --git a/src/Tags/Requests/UntagConversationRequest.php b/src/Tags/Requests/UntagConversationRequest.php index 5ea02a20..e9854e41 100644 --- a/src/Tags/Requests/UntagConversationRequest.php +++ b/src/Tags/Requests/UntagConversationRequest.php @@ -52,6 +52,7 @@ public function getConversationId(): string public function setConversationId(string $value): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } @@ -69,6 +70,7 @@ public function getTagId(): string public function setTagId(string $value): self { $this->tagId = $value; + $this->_setField('tagId'); return $this; } @@ -86,6 +88,7 @@ public function getAdminId(): string public function setAdminId(string $value): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } } diff --git a/src/Tags/Requests/UntagTicketRequest.php b/src/Tags/Requests/UntagTicketRequest.php index c408b89b..db1dbad5 100644 --- a/src/Tags/Requests/UntagTicketRequest.php +++ b/src/Tags/Requests/UntagTicketRequest.php @@ -52,6 +52,7 @@ public function getTicketId(): string public function setTicketId(string $value): self { $this->ticketId = $value; + $this->_setField('ticketId'); return $this; } @@ -69,6 +70,7 @@ public function getTagId(): string public function setTagId(string $value): self { $this->tagId = $value; + $this->_setField('tagId'); return $this; } @@ -86,6 +88,7 @@ public function getAdminId(): string public function setAdminId(string $value): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } } diff --git a/src/Tags/TagsClient.php b/src/Tags/TagsClient.php index 75230270..8f9a6fff 100644 --- a/src/Tags/TagsClient.php +++ b/src/Tags/TagsClient.php @@ -2,7 +2,7 @@ namespace Intercom\Tags; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Tags\Requests\TagContactRequest; use Intercom\Tags\Types\Tag; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Tags\Requests\UntagContactRequest; use Intercom\Tags\Requests\TagConversationRequest; @@ -68,6 +67,16 @@ public function __construct( /** * You can tag a specific contact. This will return a tag object for the tag that was added to the contact. * + * Example: + * ```php + * $client->tags->tagContact( + * new TagContactRequest([ + * 'contactId' => '63a07ddf05a32042dffac965', + * 'tagId' => '7522907', + * ]), + * ); + * ``` + * * @param TagContactRequest $request * @param ?array{ * baseUrl?: string, @@ -77,18 +86,18 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Tag + * @return ?Tag * @throws IntercomException * @throws IntercomApiException */ - public function tagContact(TagContactRequest $request, ?array $options = null): Tag + public function tagContact(TagContactRequest $request, ?array $options = null): ?Tag { $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()}/tags", + path: "contacts/" . RawClient::encodePathParam($request->getContactId()) . "/tags", method: HttpMethod::POST, body: $request, ), @@ -97,20 +106,13 @@ public function tagContact(TagContactRequest $request, ?array $options = null): $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Tag::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); } @@ -124,6 +126,16 @@ public function tagContact(TagContactRequest $request, ?array $options = null): /** * You can remove tag from a specific contact. This will return a tag object for the tag that was removed from the contact. * + * Example: + * ```php + * $client->tags->untagContact( + * new UntagContactRequest([ + * 'contactId' => '63a07ddf05a32042dffac965', + * 'tagId' => '7522907', + * ]), + * ); + * ``` + * * @param UntagContactRequest $request * @param ?array{ * baseUrl?: string, @@ -133,18 +145,18 @@ public function tagContact(TagContactRequest $request, ?array $options = null): * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Tag + * @return ?Tag * @throws IntercomException * @throws IntercomApiException */ - public function untagContact(UntagContactRequest $request, ?array $options = null): Tag + public function untagContact(UntagContactRequest $request, ?array $options = null): ?Tag { $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()}/tags/{$request->getTagId()}", + path: "contacts/" . RawClient::encodePathParam($request->getContactId()) . "/tags/" . RawClient::encodePathParam($request->getTagId()), method: HttpMethod::DELETE, ), $options, @@ -152,20 +164,13 @@ public function untagContact(UntagContactRequest $request, ?array $options = nul $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Tag::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); } @@ -179,6 +184,17 @@ public function untagContact(UntagContactRequest $request, ?array $options = nul /** * You can tag a specific conversation. This will return a tag object for the tag that was added to the conversation. * + * Example: + * ```php + * $client->tags->tagConversation( + * new TagConversationRequest([ + * 'conversationId' => '64619700005694', + * 'tagId' => '7522907', + * 'adminId' => '780', + * ]), + * ); + * ``` + * * @param TagConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -188,18 +204,18 @@ public function untagContact(UntagContactRequest $request, ?array $options = nul * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Tag + * @return ?Tag * @throws IntercomException * @throws IntercomApiException */ - public function tagConversation(TagConversationRequest $request, ?array $options = null): Tag + public function tagConversation(TagConversationRequest $request, ?array $options = null): ?Tag { $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()}/tags", + path: "conversations/" . RawClient::encodePathParam($request->getConversationId()) . "/tags", method: HttpMethod::POST, body: $request, ), @@ -208,20 +224,13 @@ public function tagConversation(TagConversationRequest $request, ?array $options $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Tag::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); } @@ -235,6 +244,17 @@ public function tagConversation(TagConversationRequest $request, ?array $options /** * You can remove tag from a specific conversation. This will return a tag object for the tag that was removed from the conversation. * + * Example: + * ```php + * $client->tags->untagConversation( + * new UntagConversationRequest([ + * 'conversationId' => '64619700005694', + * 'tagId' => '7522907', + * 'adminId' => '123', + * ]), + * ); + * ``` + * * @param UntagConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -244,18 +264,18 @@ public function tagConversation(TagConversationRequest $request, ?array $options * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Tag + * @return ?Tag * @throws IntercomException * @throws IntercomApiException */ - public function untagConversation(UntagConversationRequest $request, ?array $options = null): Tag + public function untagConversation(UntagConversationRequest $request, ?array $options = null): ?Tag { $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()}/tags/{$request->getTagId()}", + path: "conversations/" . RawClient::encodePathParam($request->getConversationId()) . "/tags/" . RawClient::encodePathParam($request->getTagId()), method: HttpMethod::DELETE, body: $request, ), @@ -264,20 +284,13 @@ public function untagConversation(UntagConversationRequest $request, ?array $opt $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Tag::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); } @@ -292,6 +305,11 @@ public function untagConversation(UntagConversationRequest $request, ?array $opt * You can fetch a list of all tags for a given workspace. * * + * Example: + * ```php + * $client->tags->list(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -300,11 +318,11 @@ public function untagConversation(UntagConversationRequest $request, ?array $opt * queryParameters?: array, * bodyProperties?: array, * } $options - * @return TagList + * @return ?TagList * @throws IntercomException * @throws IntercomApiException */ - public function list(?array $options = null): TagList + public function list(?array $options = null): ?TagList { $options = array_merge($this->options, $options ?? []); try { @@ -319,20 +337,13 @@ public function list(?array $options = null): TagList $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return TagList::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); } @@ -358,6 +369,15 @@ public function list(?array $options = null): TagList * * Each operation will return a tag object. * + * Example: + * ```php + * $client->tags->create( + * new CreateOrUpdateTagRequest([ + * 'name' => 'test', + * ]), + * ); + * ``` + * * @param ( * CreateOrUpdateTagRequest * |TagCompanyRequest @@ -372,11 +392,11 @@ public function list(?array $options = null): TagList * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Tag + * @return ?Tag * @throws IntercomException * @throws IntercomApiException */ - public function create(CreateOrUpdateTagRequest|TagCompanyRequest|UntagCompanyRequest|TagMultipleUsersRequest $request, ?array $options = null): Tag + public function create(CreateOrUpdateTagRequest|TagCompanyRequest|UntagCompanyRequest|TagMultipleUsersRequest $request, ?array $options = null): ?Tag { $options = array_merge($this->options, $options ?? []); try { @@ -392,20 +412,13 @@ public function create(CreateOrUpdateTagRequest|TagCompanyRequest|UntagCompanyRe $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Tag::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); } @@ -420,6 +433,15 @@ public function create(CreateOrUpdateTagRequest|TagCompanyRequest|UntagCompanyRe * You can fetch the details of tags that are on the workspace by their id. * This will return a tag object. * + * Example: + * ```php + * $client->tags->find( + * new FindTagRequest([ + * 'tagId' => '123', + * ]), + * ); + * ``` + * * @param FindTagRequest $request * @param ?array{ * baseUrl?: string, @@ -429,18 +451,18 @@ public function create(CreateOrUpdateTagRequest|TagCompanyRequest|UntagCompanyRe * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Tag + * @return ?Tag * @throws IntercomException * @throws IntercomApiException */ - public function find(FindTagRequest $request, ?array $options = null): Tag + public function find(FindTagRequest $request, ?array $options = null): ?Tag { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "tags/{$request->getTagId()}", + path: "tags/" . RawClient::encodePathParam($request->getTagId()), method: HttpMethod::GET, ), $options, @@ -448,20 +470,13 @@ public function find(FindTagRequest $request, ?array $options = null): Tag $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Tag::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); } @@ -475,6 +490,15 @@ public function find(FindTagRequest $request, ?array $options = null): Tag /** * You can delete the details of tags that are on the workspace by passing in the id. * + * Example: + * ```php + * $client->tags->delete( + * new DeleteTagRequest([ + * 'tagId' => '123', + * ]), + * ); + * ``` + * * @param DeleteTagRequest $request * @param ?array{ * baseUrl?: string, @@ -494,7 +518,7 @@ public function delete(DeleteTagRequest $request, ?array $options = null): void $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "tags/{$request->getTagId()}", + path: "tags/" . RawClient::encodePathParam($request->getTagId()), method: HttpMethod::DELETE, ), $options, @@ -503,16 +527,6 @@ public function delete(DeleteTagRequest $request, ?array $options = null): void 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); } @@ -526,6 +540,17 @@ public function delete(DeleteTagRequest $request, ?array $options = null): void /** * You can tag a specific ticket. This will return a tag object for the tag that was added to the ticket. * + * Example: + * ```php + * $client->tags->tagTicket( + * new TagTicketRequest([ + * 'ticketId' => '64619700005694', + * 'tagId' => '7522907', + * 'adminId' => '780', + * ]), + * ); + * ``` + * * @param TagTicketRequest $request * @param ?array{ * baseUrl?: string, @@ -535,18 +560,18 @@ public function delete(DeleteTagRequest $request, ?array $options = null): void * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Tag + * @return ?Tag * @throws IntercomException * @throws IntercomApiException */ - public function tagTicket(TagTicketRequest $request, ?array $options = null): Tag + public function tagTicket(TagTicketRequest $request, ?array $options = null): ?Tag { $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()}/tags", + path: "tickets/" . RawClient::encodePathParam($request->getTicketId()) . "/tags", method: HttpMethod::POST, body: $request, ), @@ -555,20 +580,13 @@ public function tagTicket(TagTicketRequest $request, ?array $options = null): Ta $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Tag::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); } @@ -582,6 +600,17 @@ public function tagTicket(TagTicketRequest $request, ?array $options = null): Ta /** * You can remove tag from a specific ticket. This will return a tag object for the tag that was removed from the ticket. * + * Example: + * ```php + * $client->tags->untagTicket( + * new UntagTicketRequest([ + * 'ticketId' => '64619700005694', + * 'tagId' => '7522907', + * 'adminId' => '123', + * ]), + * ); + * ``` + * * @param UntagTicketRequest $request * @param ?array{ * baseUrl?: string, @@ -591,18 +620,18 @@ public function tagTicket(TagTicketRequest $request, ?array $options = null): Ta * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Tag + * @return ?Tag * @throws IntercomException * @throws IntercomApiException */ - public function untagTicket(UntagTicketRequest $request, ?array $options = null): Tag + public function untagTicket(UntagTicketRequest $request, ?array $options = null): ?Tag { $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()}/tags/{$request->getTagId()}", + path: "tickets/" . RawClient::encodePathParam($request->getTicketId()) . "/tags/" . RawClient::encodePathParam($request->getTagId()), method: HttpMethod::DELETE, body: $request, ), @@ -611,20 +640,13 @@ public function untagTicket(UntagTicketRequest $request, ?array $options = null) $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Tag::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); } diff --git a/src/Tags/Types/Tag.php b/src/Tags/Types/Tag.php index f85996a0..d1824207 100644 --- a/src/Tags/Types/Tag.php +++ b/src/Tags/Types/Tag.php @@ -74,6 +74,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -91,6 +92,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -108,6 +110,7 @@ public function getName(): string public function setName(string $value): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -125,6 +128,7 @@ public function getAppliedAt(): ?int public function setAppliedAt(?int $value = null): self { $this->appliedAt = $value; + $this->_setField('appliedAt'); return $this; } @@ -142,6 +146,7 @@ public function getAppliedBy(): ?Reference public function setAppliedBy(?Reference $value = null): self { $this->appliedBy = $value; + $this->_setField('appliedBy'); return $this; } diff --git a/src/Tags/Types/TagBasic.php b/src/Tags/Types/TagBasic.php index db26e454..a95e9fd1 100644 --- a/src/Tags/Types/TagBasic.php +++ b/src/Tags/Types/TagBasic.php @@ -57,6 +57,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -74,6 +75,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -91,6 +93,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } diff --git a/src/Teams/Requests/FindTeamRequest.php b/src/Teams/Requests/FindTeamRequest.php index 98e8e142..4ab8327d 100644 --- a/src/Teams/Requests/FindTeamRequest.php +++ b/src/Teams/Requests/FindTeamRequest.php @@ -36,6 +36,7 @@ public function getTeamId(): string public function setTeamId(string $value): self { $this->teamId = $value; + $this->_setField('teamId'); return $this; } } diff --git a/src/Teams/TeamsClient.php b/src/Teams/TeamsClient.php index 2e1d01e6..a688ad5c 100644 --- a/src/Teams/TeamsClient.php +++ b/src/Teams/TeamsClient.php @@ -2,7 +2,7 @@ namespace Intercom\Teams; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Types\TeamList; use Intercom\Exceptions\IntercomException; @@ -11,7 +11,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Teams\Requests\FindTeamRequest; use Intercom\Teams\Types\Team; @@ -55,6 +54,11 @@ public function __construct( /** * This will return a list of team objects for the App. * + * Example: + * ```php + * $client->teams->list(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -63,11 +67,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return TeamList + * @return ?TeamList * @throws IntercomException * @throws IntercomApiException */ - public function list(?array $options = null): TeamList + public function list(?array $options = null): ?TeamList { $options = array_merge($this->options, $options ?? []); try { @@ -82,20 +86,13 @@ public function list(?array $options = null): TeamList $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return TeamList::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); } @@ -109,6 +106,15 @@ public function list(?array $options = null): TeamList /** * You can fetch the details of a single team, containing an array of admins that belong to this team. * + * Example: + * ```php + * $client->teams->find( + * new FindTeamRequest([ + * 'teamId' => '123', + * ]), + * ); + * ``` + * * @param FindTeamRequest $request * @param ?array{ * baseUrl?: string, @@ -118,18 +124,18 @@ public function list(?array $options = null): TeamList * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Team + * @return ?Team * @throws IntercomException * @throws IntercomApiException */ - public function find(FindTeamRequest $request, ?array $options = null): Team + public function find(FindTeamRequest $request, ?array $options = null): ?Team { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "teams/{$request->getTeamId()}", + path: "teams/" . RawClient::encodePathParam($request->getTeamId()), method: HttpMethod::GET, ), $options, @@ -137,20 +143,13 @@ public function find(FindTeamRequest $request, ?array $options = null): Team $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Team::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); } diff --git a/src/Teams/Types/Team.php b/src/Teams/Types/Team.php index 5d01501c..6e5ecbb7 100644 --- a/src/Teams/Types/Team.php +++ b/src/Teams/Types/Team.php @@ -91,6 +91,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -108,6 +109,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -125,6 +127,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -142,6 +145,7 @@ public function getAdminIds(): ?array public function setAdminIds(?array $value = null): self { $this->adminIds = $value; + $this->_setField('adminIds'); return $this; } @@ -159,6 +163,7 @@ public function getAdminPriorityLevel(): ?AdminPriorityLevel public function setAdminPriorityLevel(?AdminPriorityLevel $value = null): self { $this->adminPriorityLevel = $value; + $this->_setField('adminPriorityLevel'); return $this; } @@ -176,6 +181,7 @@ public function getAssignmentLimit(): ?int public function setAssignmentLimit(?int $value = null): self { $this->assignmentLimit = $value; + $this->_setField('assignmentLimit'); return $this; } @@ -193,6 +199,7 @@ public function getDistributionMethod(): ?string public function setDistributionMethod(?string $value = null): self { $this->distributionMethod = $value; + $this->_setField('distributionMethod'); return $this; } diff --git a/src/TicketStates/TicketStatesClient.php b/src/TicketStates/TicketStatesClient.php index 0b77d620..9b94f002 100644 --- a/src/TicketStates/TicketStatesClient.php +++ b/src/TicketStates/TicketStatesClient.php @@ -2,7 +2,7 @@ namespace Intercom\TicketStates; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Types\TicketStateList; use Intercom\Exceptions\IntercomException; @@ -11,7 +11,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class TicketStatesClient @@ -53,6 +52,11 @@ public function __construct( /** * You can get a list of all ticket states for a workspace. * + * Example: + * ```php + * $client->ticketStates->listTicketStates(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -61,11 +65,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return TicketStateList + * @return ?TicketStateList * @throws IntercomException * @throws IntercomApiException */ - public function listTicketStates(?array $options = null): TicketStateList + public function listTicketStates(?array $options = null): ?TicketStateList { $options = array_merge($this->options, $options ?? []); try { @@ -80,20 +84,13 @@ public function listTicketStates(?array $options = null): TicketStateList $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } diff --git a/src/TicketTypes/Attributes/AttributesClient.php b/src/TicketTypes/Attributes/AttributesClient.php index 1708e58b..cde40321 100644 --- a/src/TicketTypes/Attributes/AttributesClient.php +++ b/src/TicketTypes/Attributes/AttributesClient.php @@ -2,7 +2,7 @@ namespace Intercom\TicketTypes\Attributes; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\TicketTypes\Attributes\Requests\CreateTicketTypeAttributeRequest; use Intercom\Types\TicketTypeAttribute; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\TicketTypes\Attributes\Requests\UpdateTicketTypeAttributeRequest; @@ -55,6 +54,19 @@ public function __construct( /** * You can create a new attribute for a ticket type. * + * Example: + * ```php + * $client->ticketTypes->attributes->create( + * new CreateTicketTypeAttributeRequest([ + * 'ticketTypeId' => 'ticket_type_id', + * 'name' => 'Attribute Title', + * 'description' => 'Attribute Description', + * 'dataType' => CreateTicketTypeAttributeRequestDataType::String->value, + * 'requiredToCreate' => false, + * ]), + * ); + * ``` + * * @param CreateTicketTypeAttributeRequest $request * @param ?array{ * baseUrl?: string, @@ -75,7 +87,7 @@ public function create(CreateTicketTypeAttributeRequest $request, ?array $option $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "ticket_types/{$request->getTicketTypeId()}/attributes", + path: "ticket_types/" . RawClient::encodePathParam($request->getTicketTypeId()) . "/attributes", method: HttpMethod::POST, body: $request, ), @@ -91,16 +103,6 @@ public function create(CreateTicketTypeAttributeRequest $request, ?array $option } } 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); } @@ -114,6 +116,17 @@ public function create(CreateTicketTypeAttributeRequest $request, ?array $option /** * You can update an existing attribute for a ticket type. * + * Example: + * ```php + * $client->ticketTypes->attributes->update( + * new UpdateTicketTypeAttributeRequest([ + * 'ticketTypeId' => 'ticket_type_id', + * 'attributeId' => 'attribute_id', + * 'description' => 'New Attribute Description', + * ]), + * ); + * ``` + * * @param UpdateTicketTypeAttributeRequest $request * @param ?array{ * baseUrl?: string, @@ -134,7 +147,7 @@ public function update(UpdateTicketTypeAttributeRequest $request, ?array $option $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "ticket_types/{$request->getTicketTypeId()}/attributes/{$request->getAttributeId()}", + path: "ticket_types/" . RawClient::encodePathParam($request->getTicketTypeId()) . "/attributes/" . RawClient::encodePathParam($request->getAttributeId()), method: HttpMethod::PUT, body: $request, ), @@ -150,16 +163,6 @@ public function update(UpdateTicketTypeAttributeRequest $request, ?array $option } } 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); } diff --git a/src/TicketTypes/Attributes/Requests/CreateTicketTypeAttributeRequest.php b/src/TicketTypes/Attributes/Requests/CreateTicketTypeAttributeRequest.php index fb99a5d4..bb0dddce 100644 --- a/src/TicketTypes/Attributes/Requests/CreateTicketTypeAttributeRequest.php +++ b/src/TicketTypes/Attributes/Requests/CreateTicketTypeAttributeRequest.php @@ -118,6 +118,7 @@ public function getTicketTypeId(): string public function setTicketTypeId(string $value): self { $this->ticketTypeId = $value; + $this->_setField('ticketTypeId'); return $this; } @@ -135,6 +136,7 @@ public function getName(): string public function setName(string $value): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -152,6 +154,7 @@ public function getDescription(): string public function setDescription(string $value): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -169,6 +172,7 @@ public function getDataType(): string public function setDataType(string $value): self { $this->dataType = $value; + $this->_setField('dataType'); return $this; } @@ -186,6 +190,7 @@ public function getRequiredToCreate(): ?bool public function setRequiredToCreate(?bool $value = null): self { $this->requiredToCreate = $value; + $this->_setField('requiredToCreate'); return $this; } @@ -203,6 +208,7 @@ public function getRequiredToCreateForContacts(): ?bool public function setRequiredToCreateForContacts(?bool $value = null): self { $this->requiredToCreateForContacts = $value; + $this->_setField('requiredToCreateForContacts'); return $this; } @@ -220,6 +226,7 @@ public function getVisibleOnCreate(): ?bool public function setVisibleOnCreate(?bool $value = null): self { $this->visibleOnCreate = $value; + $this->_setField('visibleOnCreate'); return $this; } @@ -237,6 +244,7 @@ public function getVisibleToContacts(): ?bool public function setVisibleToContacts(?bool $value = null): self { $this->visibleToContacts = $value; + $this->_setField('visibleToContacts'); return $this; } @@ -254,6 +262,7 @@ public function getMultiline(): ?bool public function setMultiline(?bool $value = null): self { $this->multiline = $value; + $this->_setField('multiline'); return $this; } @@ -271,6 +280,7 @@ public function getListItems(): ?string public function setListItems(?string $value = null): self { $this->listItems = $value; + $this->_setField('listItems'); return $this; } @@ -288,6 +298,7 @@ public function getAllowMultipleValues(): ?bool public function setAllowMultipleValues(?bool $value = null): self { $this->allowMultipleValues = $value; + $this->_setField('allowMultipleValues'); return $this; } } diff --git a/src/TicketTypes/Attributes/Requests/UpdateTicketTypeAttributeRequest.php b/src/TicketTypes/Attributes/Requests/UpdateTicketTypeAttributeRequest.php index d4741e5a..d8e5b180 100644 --- a/src/TicketTypes/Attributes/Requests/UpdateTicketTypeAttributeRequest.php +++ b/src/TicketTypes/Attributes/Requests/UpdateTicketTypeAttributeRequest.php @@ -124,6 +124,7 @@ public function getTicketTypeId(): string public function setTicketTypeId(string $value): self { $this->ticketTypeId = $value; + $this->_setField('ticketTypeId'); return $this; } @@ -141,6 +142,7 @@ public function getAttributeId(): string public function setAttributeId(string $value): self { $this->attributeId = $value; + $this->_setField('attributeId'); return $this; } @@ -158,6 +160,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -175,6 +178,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -192,6 +196,7 @@ public function getRequiredToCreate(): ?bool public function setRequiredToCreate(?bool $value = null): self { $this->requiredToCreate = $value; + $this->_setField('requiredToCreate'); return $this; } @@ -209,6 +214,7 @@ public function getRequiredToCreateForContacts(): ?bool public function setRequiredToCreateForContacts(?bool $value = null): self { $this->requiredToCreateForContacts = $value; + $this->_setField('requiredToCreateForContacts'); return $this; } @@ -226,6 +232,7 @@ public function getVisibleOnCreate(): ?bool public function setVisibleOnCreate(?bool $value = null): self { $this->visibleOnCreate = $value; + $this->_setField('visibleOnCreate'); return $this; } @@ -243,6 +250,7 @@ public function getVisibleToContacts(): ?bool public function setVisibleToContacts(?bool $value = null): self { $this->visibleToContacts = $value; + $this->_setField('visibleToContacts'); return $this; } @@ -260,6 +268,7 @@ public function getMultiline(): ?bool public function setMultiline(?bool $value = null): self { $this->multiline = $value; + $this->_setField('multiline'); return $this; } @@ -277,6 +286,7 @@ public function getListItems(): ?string public function setListItems(?string $value = null): self { $this->listItems = $value; + $this->_setField('listItems'); return $this; } @@ -294,6 +304,7 @@ public function getAllowMultipleValues(): ?bool public function setAllowMultipleValues(?bool $value = null): self { $this->allowMultipleValues = $value; + $this->_setField('allowMultipleValues'); return $this; } @@ -311,6 +322,7 @@ public function getArchived(): ?bool public function setArchived(?bool $value = null): self { $this->archived = $value; + $this->_setField('archived'); return $this; } } diff --git a/src/TicketTypes/Requests/FindTicketTypeRequest.php b/src/TicketTypes/Requests/FindTicketTypeRequest.php index 003ab1d0..cf1bdd56 100644 --- a/src/TicketTypes/Requests/FindTicketTypeRequest.php +++ b/src/TicketTypes/Requests/FindTicketTypeRequest.php @@ -36,6 +36,7 @@ public function getTicketTypeId(): string public function setTicketTypeId(string $value): self { $this->ticketTypeId = $value; + $this->_setField('ticketTypeId'); return $this; } } diff --git a/src/TicketTypes/Requests/UpdateTicketTypeRequest.php b/src/TicketTypes/Requests/UpdateTicketTypeRequest.php index b3b7a629..97196a40 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\UpdateTicketTypeRequestCategory; +use Intercom\TicketTypes\Types\UpdateTicketTypeRequestBodyCategory; 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, @@ -86,6 +86,7 @@ public function getTicketTypeId(): string public function setTicketTypeId(string $value): self { $this->ticketTypeId = $value; + $this->_setField('ticketTypeId'); return $this; } @@ -103,6 +104,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -120,11 +122,12 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } /** - * @return ?value-of + * @return ?value-of */ public function getCategory(): ?string { @@ -132,11 +135,12 @@ public function getCategory(): ?string } /** - * @param ?value-of $value + * @param ?value-of $value */ public function setCategory(?string $value = null): self { $this->category = $value; + $this->_setField('category'); return $this; } @@ -154,6 +158,7 @@ public function getIcon(): ?string public function setIcon(?string $value = null): self { $this->icon = $value; + $this->_setField('icon'); return $this; } @@ -171,6 +176,7 @@ public function getArchived(): ?bool public function setArchived(?bool $value = null): self { $this->archived = $value; + $this->_setField('archived'); return $this; } @@ -188,6 +194,7 @@ public function getIsInternal(): ?bool public function setIsInternal(?bool $value = null): self { $this->isInternal = $value; + $this->_setField('isInternal'); return $this; } } diff --git a/src/TicketTypes/TicketTypesClient.php b/src/TicketTypes/TicketTypesClient.php index ede3f0e1..066f6e91 100644 --- a/src/TicketTypes/TicketTypesClient.php +++ b/src/TicketTypes/TicketTypesClient.php @@ -3,7 +3,7 @@ namespace Intercom\TicketTypes; use Intercom\TicketTypes\Attributes\AttributesClient; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Types\TicketTypeList; use Intercom\Exceptions\IntercomException; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Types\CreateTicketTypeRequest; use Intercom\Tickets\Types\TicketType; @@ -64,6 +63,11 @@ public function __construct( /** * You can get a list of all ticket types for a workspace. * + * Example: + * ```php + * $client->ticketTypes->list(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -72,11 +76,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return TicketTypeList + * @return ?TicketTypeList * @throws IntercomException * @throws IntercomApiException */ - public function list(?array $options = null): TicketTypeList + public function list(?array $options = null): ?TicketTypeList { $options = array_merge($this->options, $options ?? []); try { @@ -91,20 +95,13 @@ public function list(?array $options = null): TicketTypeList $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return TicketTypeList::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); } @@ -122,6 +119,18 @@ 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/) * + * Example: + * ```php + * $client->ticketTypes->create( + * new CreateTicketTypeRequest([ + * 'name' => 'Customer Issue', + * 'description' => 'Customer Report Template', + * 'category' => CreateTicketTypeRequestCategory::Customer->value, + * 'icon' => '🎟️', + * ]), + * ); + * ``` + * * @param ?CreateTicketTypeRequest $request * @param ?array{ * baseUrl?: string, @@ -158,16 +167,6 @@ public function create(?CreateTicketTypeRequest $request = null, ?array $options } } 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); } @@ -181,6 +180,15 @@ public function create(?CreateTicketTypeRequest $request = null, ?array $options /** * You can fetch the details of a single ticket type. * + * Example: + * ```php + * $client->ticketTypes->get( + * new FindTicketTypeRequest([ + * 'ticketTypeId' => 'ticket_type_id', + * ]), + * ); + * ``` + * * @param FindTicketTypeRequest $request * @param ?array{ * baseUrl?: string, @@ -201,7 +209,7 @@ public function get(FindTicketTypeRequest $request, ?array $options = null): ?Ti $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "ticket_types/{$request->getTicketTypeId()}", + path: "ticket_types/" . RawClient::encodePathParam($request->getTicketTypeId()), method: HttpMethod::GET, ), $options, @@ -216,16 +224,6 @@ public function get(FindTicketTypeRequest $request, ?array $options = null): ?Ti } } 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); } @@ -244,6 +242,16 @@ public function get(FindTicketTypeRequest $request, ?array $options = null): ?Ti * > * > For the `icon` propery, use an emoji from [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app/) * + * Example: + * ```php + * $client->ticketTypes->update( + * new UpdateTicketTypeRequest([ + * 'ticketTypeId' => 'ticket_type_id', + * 'name' => 'Bug Report 2', + * ]), + * ); + * ``` + * * @param UpdateTicketTypeRequest $request * @param ?array{ * baseUrl?: string, @@ -264,7 +272,7 @@ public function update(UpdateTicketTypeRequest $request, ?array $options = null) $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "ticket_types/{$request->getTicketTypeId()}", + path: "ticket_types/" . RawClient::encodePathParam($request->getTicketTypeId()), method: HttpMethod::PUT, body: $request, ), @@ -280,16 +288,6 @@ public function update(UpdateTicketTypeRequest $request, ?array $options = null) } } 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); } diff --git a/src/TicketTypes/Types/UpdateTicketTypeRequestCategory.php b/src/TicketTypes/Types/UpdateTicketTypeRequestBodyCategory.php similarity index 75% rename from src/TicketTypes/Types/UpdateTicketTypeRequestCategory.php rename to src/TicketTypes/Types/UpdateTicketTypeRequestBodyCategory.php index 8cbdebca..26981fbc 100644 --- a/src/TicketTypes/Types/UpdateTicketTypeRequestCategory.php +++ b/src/TicketTypes/Types/UpdateTicketTypeRequestBodyCategory.php @@ -2,7 +2,7 @@ namespace Intercom\TicketTypes\Types; -enum UpdateTicketTypeRequestCategory: string +enum UpdateTicketTypeRequestBodyCategory: string { case Customer = "Customer"; case BackOffice = "Back-office"; diff --git a/src/Tickets/Requests/CreateTicketRequest.php b/src/Tickets/Requests/CreateTicketRequest.php index a941b797..f79f3c86 100644 --- a/src/Tickets/Requests/CreateTicketRequest.php +++ b/src/Tickets/Requests/CreateTicketRequest.php @@ -5,10 +5,10 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Traits\CreateTicketRequestBody; use Intercom\Core\Json\JsonProperty; -use Intercom\Types\CreateTicketRequestContactsItemId; -use Intercom\Types\CreateTicketRequestContactsItemExternalId; -use Intercom\Types\CreateTicketRequestContactsItemEmail; -use Intercom\Types\CreateTicketRequestAssignment; +use Intercom\Types\CreateTicketRequestBodyContactsItemId; +use Intercom\Types\CreateTicketRequestBodyContactsItemExternalId; +use Intercom\Types\CreateTicketRequestBodyContactsItemEmail; +use Intercom\Types\CreateTicketRequestBodyAssignment; class CreateTicketRequest extends JsonSerializableType { @@ -24,15 +24,15 @@ class CreateTicketRequest extends JsonSerializableType * @param array{ * ticketTypeId: string, * contacts: array<( - * CreateTicketRequestContactsItemId - * |CreateTicketRequestContactsItemExternalId - * |CreateTicketRequestContactsItemEmail + * CreateTicketRequestBodyContactsItemId + * |CreateTicketRequestBodyContactsItemExternalId + * |CreateTicketRequestBodyContactsItemEmail * )>, * skipNotifications?: ?bool, * conversationToLinkId?: ?string, * companyId?: ?string, * createdAt?: ?int, - * assignment?: ?CreateTicketRequestAssignment, + * assignment?: ?CreateTicketRequestBodyAssignment, * } $values */ public function __construct( @@ -61,6 +61,7 @@ public function getSkipNotifications(): ?bool public function setSkipNotifications(?bool $value = null): self { $this->skipNotifications = $value; + $this->_setField('skipNotifications'); return $this; } } diff --git a/src/Tickets/Requests/DeleteTicketRequest.php b/src/Tickets/Requests/DeleteTicketRequest.php index baaf0c8a..5f03ae46 100644 --- a/src/Tickets/Requests/DeleteTicketRequest.php +++ b/src/Tickets/Requests/DeleteTicketRequest.php @@ -36,6 +36,7 @@ public function getTicketId(): string public function setTicketId(string $value): self { $this->ticketId = $value; + $this->_setField('ticketId'); return $this; } } diff --git a/src/Tickets/Requests/EnqueueCreateTicketRequest.php b/src/Tickets/Requests/EnqueueCreateTicketRequest.php index ae051308..fd66f391 100644 --- a/src/Tickets/Requests/EnqueueCreateTicketRequest.php +++ b/src/Tickets/Requests/EnqueueCreateTicketRequest.php @@ -5,10 +5,10 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Traits\CreateTicketRequestBody; use Intercom\Core\Json\JsonProperty; -use Intercom\Types\CreateTicketRequestContactsItemId; -use Intercom\Types\CreateTicketRequestContactsItemExternalId; -use Intercom\Types\CreateTicketRequestContactsItemEmail; -use Intercom\Types\CreateTicketRequestAssignment; +use Intercom\Types\CreateTicketRequestBodyContactsItemId; +use Intercom\Types\CreateTicketRequestBodyContactsItemExternalId; +use Intercom\Types\CreateTicketRequestBodyContactsItemEmail; +use Intercom\Types\CreateTicketRequestBodyAssignment; class EnqueueCreateTicketRequest extends JsonSerializableType { @@ -24,15 +24,15 @@ class EnqueueCreateTicketRequest extends JsonSerializableType * @param array{ * ticketTypeId: string, * contacts: array<( - * CreateTicketRequestContactsItemId - * |CreateTicketRequestContactsItemExternalId - * |CreateTicketRequestContactsItemEmail + * CreateTicketRequestBodyContactsItemId + * |CreateTicketRequestBodyContactsItemExternalId + * |CreateTicketRequestBodyContactsItemEmail * )>, * skipNotifications?: ?bool, * conversationToLinkId?: ?string, * companyId?: ?string, * createdAt?: ?int, - * assignment?: ?CreateTicketRequestAssignment, + * assignment?: ?CreateTicketRequestBodyAssignment, * } $values */ public function __construct( @@ -61,6 +61,7 @@ public function getSkipNotifications(): ?bool public function setSkipNotifications(?bool $value = null): self { $this->skipNotifications = $value; + $this->_setField('skipNotifications'); return $this; } } diff --git a/src/Tickets/Requests/FindTicketRequest.php b/src/Tickets/Requests/FindTicketRequest.php index abed860a..a5667c7d 100644 --- a/src/Tickets/Requests/FindTicketRequest.php +++ b/src/Tickets/Requests/FindTicketRequest.php @@ -36,6 +36,7 @@ public function getTicketId(): string public function setTicketId(string $value): self { $this->ticketId = $value; + $this->_setField('ticketId'); return $this; } } diff --git a/src/Tickets/Requests/ReplyToTicketRequest.php b/src/Tickets/Requests/ReplyToTicketRequest.php index c001a6ef..d8677f81 100644 --- a/src/Tickets/Requests/ReplyToTicketRequest.php +++ b/src/Tickets/Requests/ReplyToTicketRequest.php @@ -11,7 +11,7 @@ class ReplyToTicketRequest extends JsonSerializableType { /** - * @var string $ticketId + * @var string $ticketId The id of the ticket to target. */ private string $ticketId; @@ -57,6 +57,7 @@ public function getTicketId(): string public function setTicketId(string $value): self { $this->ticketId = $value; + $this->_setField('ticketId'); return $this; } @@ -84,6 +85,7 @@ public function getBody(): ContactReplyTicketIntercomUserIdRequest|ContactReplyT public function setBody(ContactReplyTicketIntercomUserIdRequest|ContactReplyTicketUserIdRequest|ContactReplyTicketEmailRequest|AdminReplyTicketRequest $value): self { $this->body = $value; + $this->_setField('body'); return $this; } } diff --git a/src/Tickets/Requests/UpdateTicketRequest.php b/src/Tickets/Requests/UpdateTicketRequest.php index 97dc6cdf..02edc2b9 100644 --- a/src/Tickets/Requests/UpdateTicketRequest.php +++ b/src/Tickets/Requests/UpdateTicketRequest.php @@ -102,6 +102,7 @@ public function getTicketId(): string public function setTicketId(string $value): self { $this->ticketId = $value; + $this->_setField('ticketId'); return $this; } @@ -119,6 +120,7 @@ public function getTicketAttributes(): ?array public function setTicketAttributes(?array $value = null): self { $this->ticketAttributes = $value; + $this->_setField('ticketAttributes'); return $this; } @@ -136,6 +138,7 @@ public function getTicketStateId(): ?string public function setTicketStateId(?string $value = null): self { $this->ticketStateId = $value; + $this->_setField('ticketStateId'); return $this; } @@ -153,6 +156,7 @@ public function getCompanyId(): ?string public function setCompanyId(?string $value = null): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } @@ -170,6 +174,7 @@ public function getOpen(): ?bool public function setOpen(?bool $value = null): self { $this->open = $value; + $this->_setField('open'); return $this; } @@ -187,6 +192,7 @@ public function getIsShared(): ?bool public function setIsShared(?bool $value = null): self { $this->isShared = $value; + $this->_setField('isShared'); return $this; } @@ -204,6 +210,7 @@ public function getSnoozedUntil(): ?int public function setSnoozedUntil(?int $value = null): self { $this->snoozedUntil = $value; + $this->_setField('snoozedUntil'); return $this; } @@ -221,6 +228,7 @@ public function getAdminId(): ?int public function setAdminId(?int $value = null): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } @@ -238,6 +246,7 @@ public function getAssigneeId(): ?string public function setAssigneeId(?string $value = null): self { $this->assigneeId = $value; + $this->_setField('assigneeId'); return $this; } } diff --git a/src/Tickets/TicketsClient.php b/src/Tickets/TicketsClient.php index 0ce8fb80..1ef6c587 100644 --- a/src/Tickets/TicketsClient.php +++ b/src/Tickets/TicketsClient.php @@ -2,7 +2,7 @@ namespace Intercom\Tickets; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Tickets\Requests\ReplyToTicketRequest; use Intercom\Types\TicketReply; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Tickets\Requests\CreateTicketRequest; use Intercom\Tickets\Types\Ticket; @@ -67,6 +66,21 @@ public function __construct( /** * You can reply to a ticket with a message from an admin or on behalf of a contact, or with a note for admins. * + * Example: + * ```php + * $client->tickets->reply( + * new ReplyToTicketRequest([ + * 'ticketId' => '123', + * 'body' => new ContactReplyTicketIntercomUserIdRequest([ + * 'messageType' => 'comment', + * 'type' => 'user', + * 'body' => 'Thanks again :)', + * 'intercomUserId' => '6762f2971bb69f9f2193bc49', + * ]), + * ]), + * ); + * ``` + * * @param ReplyToTicketRequest $request * @param ?array{ * baseUrl?: string, @@ -76,18 +90,18 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return TicketReply + * @return ?TicketReply * @throws IntercomException * @throws IntercomApiException */ - public function reply(ReplyToTicketRequest $request, ?array $options = null): TicketReply + public function reply(ReplyToTicketRequest $request, ?array $options = null): ?TicketReply { $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()}/reply", + path: "tickets/" . RawClient::encodePathParam($request->getTicketId()) . "/reply", method: HttpMethod::POST, body: $request->getBody(), ), @@ -96,20 +110,13 @@ public function reply(ReplyToTicketRequest $request, ?array $options = null): Ti $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return TicketReply::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); } @@ -123,6 +130,20 @@ public function reply(ReplyToTicketRequest $request, ?array $options = null): Ti /** * You can create a new ticket. * + * Example: + * ```php + * $client->tickets->create( + * new CreateTicketRequest([ + * 'ticketTypeId' => '1234', + * 'contacts' => [ + * new CreateTicketRequestBodyContactsItemId([ + * 'id' => '6762f2d81bb69f9f2193bc54', + * ]), + * ], + * ]), + * ); + * ``` + * * @param CreateTicketRequest $request * @param ?array{ * baseUrl?: string, @@ -159,16 +180,6 @@ public function create(CreateTicketRequest $request, ?array $options = null): ?T } } 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); } @@ -182,6 +193,20 @@ public function create(CreateTicketRequest $request, ?array $options = null): ?T /** * 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. * + * Example: + * ```php + * $client->tickets->enqueueCreateTicket( + * new EnqueueCreateTicketRequest([ + * 'ticketTypeId' => '1234', + * 'contacts' => [ + * new CreateTicketRequestBodyContactsItemId([ + * 'id' => '6762f2d81bb69f9f2193bc54', + * ]), + * ], + * ]), + * ); + * ``` + * * @param EnqueueCreateTicketRequest $request * @param ?array{ * baseUrl?: string, @@ -191,11 +216,11 @@ public function create(CreateTicketRequest $request, ?array $options = null): ?T * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Jobs + * @return ?Jobs * @throws IntercomException * @throws IntercomApiException */ - public function enqueueCreateTicket(EnqueueCreateTicketRequest $request, ?array $options = null): Jobs + public function enqueueCreateTicket(EnqueueCreateTicketRequest $request, ?array $options = null): ?Jobs { $options = array_merge($this->options, $options ?? []); try { @@ -211,20 +236,13 @@ public function enqueueCreateTicket(EnqueueCreateTicketRequest $request, ?array $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -238,6 +256,15 @@ public function enqueueCreateTicket(EnqueueCreateTicketRequest $request, ?array /** * You can fetch the details of a single ticket. * + * Example: + * ```php + * $client->tickets->get( + * new FindTicketRequest([ + * 'ticketId' => 'ticket_id', + * ]), + * ); + * ``` + * * @param FindTicketRequest $request * @param ?array{ * baseUrl?: string, @@ -258,7 +285,7 @@ public function get(FindTicketRequest $request, ?array $options = null): ?Ticket $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "tickets/{$request->getTicketId()}", + path: "tickets/" . RawClient::encodePathParam($request->getTicketId()), method: HttpMethod::GET, ), $options, @@ -273,16 +300,6 @@ public function get(FindTicketRequest $request, ?array $options = null): ?Ticket } } 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); } @@ -296,6 +313,24 @@ public function get(FindTicketRequest $request, ?array $options = null): ?Ticket /** * You can update a ticket. * + * Example: + * ```php + * $client->tickets->update( + * new UpdateTicketRequest([ + * 'ticketId' => 'ticket_id', + * 'ticketAttributes' => [ + * '_default_title_' => "example", + * '_default_description_' => "there is a problem", + * ], + * 'ticketStateId' => '123', + * 'open' => true, + * 'snoozedUntil' => 1673609604, + * 'adminId' => 991268011, + * 'assigneeId' => '123', + * ]), + * ); + * ``` + * * @param UpdateTicketRequest $request * @param ?array{ * baseUrl?: string, @@ -316,7 +351,7 @@ public function update(UpdateTicketRequest $request, ?array $options = null): ?T $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "tickets/{$request->getTicketId()}", + path: "tickets/" . RawClient::encodePathParam($request->getTicketId()), method: HttpMethod::PUT, body: $request, ), @@ -332,16 +367,6 @@ public function update(UpdateTicketRequest $request, ?array $options = null): ?T } } 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); } @@ -355,6 +380,15 @@ public function update(UpdateTicketRequest $request, ?array $options = null): ?T /** * You can delete a ticket using the Intercom provided ID. * + * Example: + * ```php + * $client->tickets->deleteTicket( + * new DeleteTicketRequest([ + * 'ticketId' => 'ticket_id', + * ]), + * ); + * ``` + * * @param DeleteTicketRequest $request * @param ?array{ * baseUrl?: string, @@ -364,18 +398,18 @@ public function update(UpdateTicketRequest $request, ?array $options = null): ?T * queryParameters?: array, * bodyProperties?: array, * } $options - * @return DeleteTicketResponse + * @return ?DeleteTicketResponse * @throws IntercomException * @throws IntercomApiException */ - public function deleteTicket(DeleteTicketRequest $request, ?array $options = null): DeleteTicketResponse + 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()}", + path: "tickets/" . RawClient::encodePathParam($request->getTicketId()), method: HttpMethod::DELETE, ), $options, @@ -383,20 +417,13 @@ public function deleteTicket(DeleteTicketRequest $request, ?array $options = nul $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -478,6 +505,20 @@ public function deleteTicket(DeleteTicketRequest $request, ?array $options = nul * | ^ | String | Starts With | * | $ | String | Ends With | * + * Example: + * ```php + * $client->unstable->tickets->searchTickets( + * new SearchRequest([ + * 'query' => new SingleFilterSearchRequest([ + * 'value' => [], + * ]), + * 'pagination' => new StartingAfterPaging([ + * 'perPage' => 5, + * ]), + * ]), + * ); + * ``` + * * @param SearchRequest $request * @param ?array{ * baseUrl?: string, @@ -498,9 +539,9 @@ public function search(SearchRequest $request, ?array $options = null): Pager PaginationHelper::setDeep($request, ["pagination", "startingAfter"], $cursor); }, /* @phpstan-ignore-next-line */ - getNextCursor: fn (TicketList $response) => $response?->getPages()?->getNext()?->getStartingAfter() ?? null, + getNextCursor: fn (?TicketList $response) => $response?->getPages()?->getNext()?->getStartingAfter() ?? null, /* @phpstan-ignore-next-line */ - getItems: fn (TicketList $response) => $response?->getTickets() ?? [], + getItems: fn (?TicketList $response) => $response?->getTickets() ?? [], ); } @@ -584,11 +625,11 @@ public function search(SearchRequest $request, ?array $options = null): Pager * queryParameters?: array, * bodyProperties?: array, * } $options - * @return TicketList + * @return ?TicketList * @throws IntercomException * @throws IntercomApiException */ - private function _search(SearchRequest $request, ?array $options = null): TicketList + private function _search(SearchRequest $request, ?array $options = null): ?TicketList { $options = array_merge($this->options, $options ?? []); try { @@ -604,20 +645,13 @@ private function _search(SearchRequest $request, ?array $options = null): Ticket $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return TicketList::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); } diff --git a/src/Tickets/Types/DeleteTicketResponse.php b/src/Tickets/Types/DeleteTicketResponse.php index 8bd5bc3e..38b5aad8 100644 --- a/src/Tickets/Types/DeleteTicketResponse.php +++ b/src/Tickets/Types/DeleteTicketResponse.php @@ -57,6 +57,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -74,6 +75,7 @@ public function getObject(): ?string public function setObject(?string $value = null): self { $this->object = $value; + $this->_setField('object'); return $this; } @@ -91,6 +93,7 @@ public function getDeleted(): ?bool public function setDeleted(?bool $value = null): self { $this->deleted = $value; + $this->_setField('deleted'); return $this; } diff --git a/src/Tickets/Types/Ticket.php b/src/Tickets/Types/Ticket.php index 55be236e..0bbca858 100644 --- a/src/Tickets/Types/Ticket.php +++ b/src/Tickets/Types/Ticket.php @@ -172,6 +172,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -189,6 +190,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -206,6 +208,7 @@ public function getTicketId(): ?string public function setTicketId(?string $value = null): self { $this->ticketId = $value; + $this->_setField('ticketId'); return $this; } @@ -223,6 +226,7 @@ public function getCategory(): ?string public function setCategory(?string $value = null): self { $this->category = $value; + $this->_setField('category'); return $this; } @@ -240,6 +244,7 @@ public function getTicketAttributes(): ?array public function setTicketAttributes(?array $value = null): self { $this->ticketAttributes = $value; + $this->_setField('ticketAttributes'); return $this; } @@ -257,6 +262,7 @@ public function getTicketState(): ?TicketState public function setTicketState(?TicketState $value = null): self { $this->ticketState = $value; + $this->_setField('ticketState'); return $this; } @@ -274,6 +280,7 @@ public function getTicketType(): ?TicketType public function setTicketType(?TicketType $value = null): self { $this->ticketType = $value; + $this->_setField('ticketType'); return $this; } @@ -291,6 +298,7 @@ public function getContacts(): ?TicketContacts public function setContacts(?TicketContacts $value = null): self { $this->contacts = $value; + $this->_setField('contacts'); return $this; } @@ -308,6 +316,7 @@ public function getAdminAssigneeId(): ?string public function setAdminAssigneeId(?string $value = null): self { $this->adminAssigneeId = $value; + $this->_setField('adminAssigneeId'); return $this; } @@ -325,6 +334,7 @@ public function getTeamAssigneeId(): ?string public function setTeamAssigneeId(?string $value = null): self { $this->teamAssigneeId = $value; + $this->_setField('teamAssigneeId'); return $this; } @@ -342,6 +352,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -359,6 +370,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -376,6 +388,7 @@ public function getOpen(): ?bool public function setOpen(?bool $value = null): self { $this->open = $value; + $this->_setField('open'); return $this; } @@ -393,6 +406,7 @@ public function getSnoozedUntil(): ?int public function setSnoozedUntil(?int $value = null): self { $this->snoozedUntil = $value; + $this->_setField('snoozedUntil'); return $this; } @@ -410,6 +424,7 @@ public function getLinkedObjects(): ?LinkedObjectList public function setLinkedObjects(?LinkedObjectList $value = null): self { $this->linkedObjects = $value; + $this->_setField('linkedObjects'); return $this; } @@ -427,6 +442,7 @@ public function getTicketParts(): ?TicketParts public function setTicketParts(?TicketParts $value = null): self { $this->ticketParts = $value; + $this->_setField('ticketParts'); return $this; } @@ -444,6 +460,7 @@ public function getIsShared(): ?bool public function setIsShared(?bool $value = null): self { $this->isShared = $value; + $this->_setField('isShared'); return $this; } diff --git a/src/Tickets/Types/TicketContacts.php b/src/Tickets/Types/TicketContacts.php index 34c40e13..c69b6814 100644 --- a/src/Tickets/Types/TicketContacts.php +++ b/src/Tickets/Types/TicketContacts.php @@ -51,6 +51,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -68,6 +69,7 @@ public function getContacts(): ?array public function setContacts(?array $value = null): self { $this->contacts = $value; + $this->_setField('contacts'); return $this; } diff --git a/src/Tickets/Types/TicketPart.php b/src/Tickets/Types/TicketPart.php index d522f6d9..40782319 100644 --- a/src/Tickets/Types/TicketPart.php +++ b/src/Tickets/Types/TicketPart.php @@ -157,6 +157,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -174,6 +175,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -191,6 +193,7 @@ public function getPartType(): ?string public function setPartType(?string $value = null): self { $this->partType = $value; + $this->_setField('partType'); return $this; } @@ -208,6 +211,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -225,6 +229,7 @@ public function getPreviousTicketState(): ?string public function setPreviousTicketState(?string $value = null): self { $this->previousTicketState = $value; + $this->_setField('previousTicketState'); return $this; } @@ -242,6 +247,7 @@ public function getTicketState(): ?string public function setTicketState(?string $value = null): self { $this->ticketState = $value; + $this->_setField('ticketState'); return $this; } @@ -259,6 +265,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -276,6 +283,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -293,6 +301,7 @@ public function getAssignedTo(): ?Reference public function setAssignedTo(?Reference $value = null): self { $this->assignedTo = $value; + $this->_setField('assignedTo'); return $this; } @@ -310,6 +319,7 @@ public function getAuthor(): ?TicketPartAuthor public function setAuthor(?TicketPartAuthor $value = null): self { $this->author = $value; + $this->_setField('author'); return $this; } @@ -327,6 +337,7 @@ public function getAttachments(): ?array public function setAttachments(?array $value = null): self { $this->attachments = $value; + $this->_setField('attachments'); return $this; } @@ -344,6 +355,7 @@ public function getExternalId(): ?string public function setExternalId(?string $value = null): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } @@ -361,6 +373,7 @@ public function getRedacted(): ?bool public function setRedacted(?bool $value = null): self { $this->redacted = $value; + $this->_setField('redacted'); return $this; } @@ -378,6 +391,7 @@ public function getAppPackageCode(): ?string public function setAppPackageCode(?string $value = null): self { $this->appPackageCode = $value; + $this->_setField('appPackageCode'); return $this; } @@ -395,6 +409,7 @@ public function getUpdatedAttributeData(): ?TicketPartUpdatedAttributeData public function setUpdatedAttributeData(?TicketPartUpdatedAttributeData $value = null): self { $this->updatedAttributeData = $value; + $this->_setField('updatedAttributeData'); return $this; } diff --git a/src/Tickets/Types/TicketPartUpdatedAttributeData.php b/src/Tickets/Types/TicketPartUpdatedAttributeData.php index 76864701..120ed21e 100644 --- a/src/Tickets/Types/TicketPartUpdatedAttributeData.php +++ b/src/Tickets/Types/TicketPartUpdatedAttributeData.php @@ -49,6 +49,7 @@ public function getAttribute(): TicketPartUpdatedAttributeDataAttribute public function setAttribute(TicketPartUpdatedAttributeDataAttribute $value): self { $this->attribute = $value; + $this->_setField('attribute'); return $this; } @@ -66,6 +67,7 @@ public function getValue(): TicketPartUpdatedAttributeDataValue public function setValue(TicketPartUpdatedAttributeDataValue $value): self { $this->value = $value; + $this->_setField('value'); return $this; } diff --git a/src/Tickets/Types/TicketPartUpdatedAttributeDataAttribute.php b/src/Tickets/Types/TicketPartUpdatedAttributeDataAttribute.php index 7acf082f..f248cb71 100644 --- a/src/Tickets/Types/TicketPartUpdatedAttributeDataAttribute.php +++ b/src/Tickets/Types/TicketPartUpdatedAttributeDataAttribute.php @@ -57,6 +57,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -74,6 +75,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -91,6 +93,7 @@ public function getLabel(): string public function setLabel(string $value): self { $this->label = $value; + $this->_setField('label'); return $this; } diff --git a/src/Tickets/Types/TicketPartUpdatedAttributeDataValue.php b/src/Tickets/Types/TicketPartUpdatedAttributeDataValue.php index 771084e1..cb684059 100644 --- a/src/Tickets/Types/TicketPartUpdatedAttributeDataValue.php +++ b/src/Tickets/Types/TicketPartUpdatedAttributeDataValue.php @@ -72,6 +72,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -97,6 +98,7 @@ public function getId(): string|array|null public function setId(string|array|null $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -120,6 +122,7 @@ public function getLabel(): string|array public function setLabel(string|array $value): self { $this->label = $value; + $this->_setField('label'); return $this; } diff --git a/src/Tickets/Types/TicketState.php b/src/Tickets/Types/TicketState.php index 5a2a5d99..0491f030 100644 --- a/src/Tickets/Types/TicketState.php +++ b/src/Tickets/Types/TicketState.php @@ -73,6 +73,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -90,6 +91,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -107,6 +109,7 @@ public function getCategory(): ?string public function setCategory(?string $value = null): self { $this->category = $value; + $this->_setField('category'); return $this; } @@ -124,6 +127,7 @@ public function getInternalLabel(): ?string public function setInternalLabel(?string $value = null): self { $this->internalLabel = $value; + $this->_setField('internalLabel'); return $this; } @@ -141,6 +145,7 @@ public function getExternalLabel(): ?string public function setExternalLabel(?string $value = null): self { $this->externalLabel = $value; + $this->_setField('externalLabel'); return $this; } diff --git a/src/Tickets/Types/TicketStateDetailed.php b/src/Tickets/Types/TicketStateDetailed.php index 26803e23..86aac716 100644 --- a/src/Tickets/Types/TicketStateDetailed.php +++ b/src/Tickets/Types/TicketStateDetailed.php @@ -89,6 +89,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -106,6 +107,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -123,6 +125,7 @@ public function getCategory(): ?string public function setCategory(?string $value = null): self { $this->category = $value; + $this->_setField('category'); return $this; } @@ -140,6 +143,7 @@ public function getInternalLabel(): ?string public function setInternalLabel(?string $value = null): self { $this->internalLabel = $value; + $this->_setField('internalLabel'); return $this; } @@ -157,6 +161,7 @@ public function getExternalLabel(): ?string public function setExternalLabel(?string $value = null): self { $this->externalLabel = $value; + $this->_setField('externalLabel'); return $this; } @@ -174,6 +179,7 @@ public function getArchived(): ?bool public function setArchived(?bool $value = null): self { $this->archived = $value; + $this->_setField('archived'); return $this; } @@ -191,6 +197,7 @@ public function getTicketTypes(): ?TicketStateDetailedTicketTypes public function setTicketTypes(?TicketStateDetailedTicketTypes $value = null): self { $this->ticketTypes = $value; + $this->_setField('ticketTypes'); return $this; } diff --git a/src/Tickets/Types/TicketStateDetailedTicketTypes.php b/src/Tickets/Types/TicketStateDetailedTicketTypes.php index cee96e10..f28518e4 100644 --- a/src/Tickets/Types/TicketStateDetailedTicketTypes.php +++ b/src/Tickets/Types/TicketStateDetailedTicketTypes.php @@ -51,6 +51,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -68,6 +69,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Tickets/Types/TicketType.php b/src/Tickets/Types/TicketType.php index 5e1bcd31..a58e5676 100644 --- a/src/Tickets/Types/TicketType.php +++ b/src/Tickets/Types/TicketType.php @@ -130,6 +130,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -147,6 +148,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -164,6 +166,7 @@ public function getCategory(): ?string public function setCategory(?string $value = null): self { $this->category = $value; + $this->_setField('category'); return $this; } @@ -181,6 +184,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -198,6 +202,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -215,6 +220,7 @@ public function getIcon(): ?string public function setIcon(?string $value = null): self { $this->icon = $value; + $this->_setField('icon'); return $this; } @@ -232,6 +238,7 @@ public function getWorkspaceId(): ?string public function setWorkspaceId(?string $value = null): self { $this->workspaceId = $value; + $this->_setField('workspaceId'); return $this; } @@ -249,6 +256,7 @@ public function getTicketTypeAttributes(): ?TicketTypeAttributeList public function setTicketTypeAttributes(?TicketTypeAttributeList $value = null): self { $this->ticketTypeAttributes = $value; + $this->_setField('ticketTypeAttributes'); return $this; } @@ -266,6 +274,7 @@ public function getTicketStates(): ?TicketTypeTicketStates public function setTicketStates(?TicketTypeTicketStates $value = null): self { $this->ticketStates = $value; + $this->_setField('ticketStates'); return $this; } @@ -283,6 +292,7 @@ public function getArchived(): ?bool public function setArchived(?bool $value = null): self { $this->archived = $value; + $this->_setField('archived'); return $this; } @@ -300,6 +310,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -317,6 +328,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } diff --git a/src/Tickets/Types/TicketTypeTicketStates.php b/src/Tickets/Types/TicketTypeTicketStates.php index 8217a6b8..7c4541dc 100644 --- a/src/Tickets/Types/TicketTypeTicketStates.php +++ b/src/Tickets/Types/TicketTypeTicketStates.php @@ -51,6 +51,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -68,6 +69,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Traits/ContactReference.php b/src/Traits/ContactReference.php index 93d488a5..9f4ef232 100644 --- a/src/Traits/ContactReference.php +++ b/src/Traits/ContactReference.php @@ -45,6 +45,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -62,6 +63,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -79,6 +81,7 @@ public function getExternalId(): ?string public function setExternalId(?string $value = null): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } } diff --git a/src/Traits/ContactReplyBaseRequest.php b/src/Traits/ContactReplyBaseRequest.php index 55b0e56e..05693cc8 100644 --- a/src/Traits/ContactReplyBaseRequest.php +++ b/src/Traits/ContactReplyBaseRequest.php @@ -66,6 +66,7 @@ public function getMessageType(): string public function setMessageType(string $value): self { $this->messageType = $value; + $this->_setField('messageType'); return $this; } @@ -83,6 +84,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -100,6 +102,7 @@ public function getBody(): string public function setBody(string $value): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -117,6 +120,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -134,6 +138,7 @@ public function getAttachmentUrls(): ?array public function setAttachmentUrls(?array $value = null): self { $this->attachmentUrls = $value; + $this->_setField('attachmentUrls'); return $this; } @@ -151,6 +156,7 @@ public function getReplyOptions(): ?array public function setReplyOptions(?array $value = null): self { $this->replyOptions = $value; + $this->_setField('replyOptions'); return $this; } } diff --git a/src/Traits/CreateTicketRequestBody.php b/src/Traits/CreateTicketRequestBody.php index d4f36a90..f970cf1a 100644 --- a/src/Traits/CreateTicketRequestBody.php +++ b/src/Traits/CreateTicketRequestBody.php @@ -2,10 +2,10 @@ namespace Intercom\Traits; -use Intercom\Types\CreateTicketRequestContactsItemId; -use Intercom\Types\CreateTicketRequestContactsItemExternalId; -use Intercom\Types\CreateTicketRequestContactsItemEmail; -use Intercom\Types\CreateTicketRequestAssignment; +use Intercom\Types\CreateTicketRequestBodyContactsItemId; +use Intercom\Types\CreateTicketRequestBodyContactsItemExternalId; +use Intercom\Types\CreateTicketRequestBodyContactsItemEmail; +use Intercom\Types\CreateTicketRequestBodyAssignment; use Intercom\Core\Json\JsonProperty; use Intercom\Core\Types\ArrayType; use Intercom\Core\Types\Union; @@ -15,14 +15,14 @@ * * @property string $ticketTypeId * @property array<( - * CreateTicketRequestContactsItemId - * |CreateTicketRequestContactsItemExternalId - * |CreateTicketRequestContactsItemEmail + * CreateTicketRequestBodyContactsItemId + * |CreateTicketRequestBodyContactsItemExternalId + * |CreateTicketRequestBodyContactsItemEmail * )> $contacts * @property ?string $conversationToLinkId * @property ?string $companyId * @property ?int $createdAt - * @property ?CreateTicketRequestAssignment $assignment + * @property ?CreateTicketRequestBodyAssignment $assignment */ trait CreateTicketRequestBody { @@ -34,12 +34,12 @@ trait CreateTicketRequestBody /** * @var array<( - * CreateTicketRequestContactsItemId - * |CreateTicketRequestContactsItemExternalId - * |CreateTicketRequestContactsItemEmail + * CreateTicketRequestBodyContactsItemId + * |CreateTicketRequestBodyContactsItemExternalId + * |CreateTicketRequestBodyContactsItemEmail * )> $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)])] + #[JsonProperty('contacts'), ArrayType([new Union(CreateTicketRequestBodyContactsItemId::class, CreateTicketRequestBodyContactsItemExternalId::class, CreateTicketRequestBodyContactsItemEmail::class)])] private array $contacts; /** @@ -67,10 +67,10 @@ trait CreateTicketRequestBody private ?int $createdAt; /** - * @var ?CreateTicketRequestAssignment $assignment + * @var ?CreateTicketRequestBodyAssignment $assignment */ #[JsonProperty('assignment')] - private ?CreateTicketRequestAssignment $assignment; + private ?CreateTicketRequestBodyAssignment $assignment; /** * @return string @@ -86,14 +86,15 @@ public function getTicketTypeId(): string public function setTicketTypeId(string $value): self { $this->ticketTypeId = $value; + $this->_setField('ticketTypeId'); return $this; } /** * @return array<( - * CreateTicketRequestContactsItemId - * |CreateTicketRequestContactsItemExternalId - * |CreateTicketRequestContactsItemEmail + * CreateTicketRequestBodyContactsItemId + * |CreateTicketRequestBodyContactsItemExternalId + * |CreateTicketRequestBodyContactsItemEmail * )> */ public function getContacts(): array @@ -103,14 +104,15 @@ public function getContacts(): array /** * @param array<( - * CreateTicketRequestContactsItemId - * |CreateTicketRequestContactsItemExternalId - * |CreateTicketRequestContactsItemEmail + * CreateTicketRequestBodyContactsItemId + * |CreateTicketRequestBodyContactsItemExternalId + * |CreateTicketRequestBodyContactsItemEmail * )> $value */ public function setContacts(array $value): self { $this->contacts = $value; + $this->_setField('contacts'); return $this; } @@ -128,6 +130,7 @@ public function getConversationToLinkId(): ?string public function setConversationToLinkId(?string $value = null): self { $this->conversationToLinkId = $value; + $this->_setField('conversationToLinkId'); return $this; } @@ -145,6 +148,7 @@ public function getCompanyId(): ?string public function setCompanyId(?string $value = null): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } @@ -162,23 +166,25 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } /** - * @return ?CreateTicketRequestAssignment + * @return ?CreateTicketRequestBodyAssignment */ - public function getAssignment(): ?CreateTicketRequestAssignment + public function getAssignment(): ?CreateTicketRequestBodyAssignment { return $this->assignment; } /** - * @param ?CreateTicketRequestAssignment $value + * @param ?CreateTicketRequestBodyAssignment $value */ - public function setAssignment(?CreateTicketRequestAssignment $value = null): self + public function setAssignment(?CreateTicketRequestBodyAssignment $value = null): self { $this->assignment = $value; + $this->_setField('assignment'); return $this; } } diff --git a/src/Traits/CustomChannelBaseEvent.php b/src/Traits/CustomChannelBaseEvent.php index 6e4cbaed..bdf16c7f 100644 --- a/src/Traits/CustomChannelBaseEvent.php +++ b/src/Traits/CustomChannelBaseEvent.php @@ -44,6 +44,7 @@ public function getEventId(): string public function setEventId(string $value): self { $this->eventId = $value; + $this->_setField('eventId'); return $this; } @@ -61,6 +62,7 @@ public function getExternalConversationId(): string public function setExternalConversationId(string $value): self { $this->externalConversationId = $value; + $this->_setField('externalConversationId'); return $this; } @@ -78,6 +80,7 @@ public function getContact(): CustomChannelContact public function setContact(CustomChannelContact $value): self { $this->contact = $value; + $this->_setField('contact'); return $this; } } diff --git a/src/Traits/QuickReplyOption.php b/src/Traits/QuickReplyOption.php index 077aee82..3c2a342c 100644 --- a/src/Traits/QuickReplyOption.php +++ b/src/Traits/QuickReplyOption.php @@ -36,6 +36,7 @@ public function getText(): string public function setText(string $value): self { $this->text = $value; + $this->_setField('text'); return $this; } @@ -53,6 +54,7 @@ public function getUuid(): string public function setUuid(string $value): self { $this->uuid = $value; + $this->_setField('uuid'); return $this; } } diff --git a/src/Types/ActivityLog.php b/src/Types/ActivityLog.php index c0c7f228..57c8ad68 100644 --- a/src/Types/ActivityLog.php +++ b/src/Types/ActivityLog.php @@ -81,6 +81,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -98,6 +99,7 @@ public function getPerformedBy(): ?ActivityLogPerformedBy public function setPerformedBy(?ActivityLogPerformedBy $value = null): self { $this->performedBy = $value; + $this->_setField('performedBy'); return $this; } @@ -115,6 +117,7 @@ public function getMetadata(): ?ActivityLogMetadata public function setMetadata(?ActivityLogMetadata $value = null): self { $this->metadata = $value; + $this->_setField('metadata'); return $this; } @@ -132,6 +135,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -149,6 +153,7 @@ public function getActivityType(): ?string public function setActivityType(?string $value = null): self { $this->activityType = $value; + $this->_setField('activityType'); return $this; } @@ -166,6 +171,7 @@ public function getActivityDescription(): ?string public function setActivityDescription(?string $value = null): self { $this->activityDescription = $value; + $this->_setField('activityDescription'); return $this; } diff --git a/src/Types/ActivityLogList.php b/src/Types/ActivityLogList.php index 1f7695be..b2f7ffd2 100644 --- a/src/Types/ActivityLogList.php +++ b/src/Types/ActivityLogList.php @@ -59,6 +59,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -76,6 +77,7 @@ public function getPages(): ?CursorPages public function setPages(?CursorPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } @@ -93,6 +95,7 @@ public function getActivityLogs(): ?array public function setActivityLogs(?array $value = null): self { $this->activityLogs = $value; + $this->_setField('activityLogs'); return $this; } diff --git a/src/Types/ActivityLogMetadata.php b/src/Types/ActivityLogMetadata.php index c2303673..bd5ddaff 100644 --- a/src/Types/ActivityLogMetadata.php +++ b/src/Types/ActivityLogMetadata.php @@ -180,6 +180,7 @@ public function getSignInMethod(): ?string public function setSignInMethod(?string $value = null): self { $this->signInMethod = $value; + $this->_setField('signInMethod'); return $this; } @@ -197,6 +198,7 @@ public function getExternalId(): ?string public function setExternalId(?string $value = null): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } @@ -214,6 +216,7 @@ public function getAwayMode(): ?bool public function setAwayMode(?bool $value = null): self { $this->awayMode = $value; + $this->_setField('awayMode'); return $this; } @@ -231,6 +234,7 @@ public function getAwayStatusReason(): ?string public function setAwayStatusReason(?string $value = null): self { $this->awayStatusReason = $value; + $this->_setField('awayStatusReason'); return $this; } @@ -248,6 +252,7 @@ public function getReassignConversations(): ?bool public function setReassignConversations(?bool $value = null): self { $this->reassignConversations = $value; + $this->_setField('reassignConversations'); return $this; } @@ -265,6 +270,7 @@ public function getSource(): ?string public function setSource(?string $value = null): self { $this->source = $value; + $this->_setField('source'); return $this; } @@ -282,6 +288,7 @@ public function getAutoChanged(): ?string public function setAutoChanged(?string $value = null): self { $this->autoChanged = $value; + $this->_setField('autoChanged'); return $this; } @@ -299,6 +306,7 @@ public function getUpdateBy(): ?int public function setUpdateBy(?int $value = null): self { $this->updateBy = $value; + $this->_setField('updateBy'); return $this; } @@ -316,6 +324,7 @@ public function getUpdateByName(): ?string public function setUpdateByName(?string $value = null): self { $this->updateByName = $value; + $this->_setField('updateByName'); return $this; } @@ -333,6 +342,7 @@ public function getConversationAssignmentLimit(): ?int public function setConversationAssignmentLimit(?int $value = null): self { $this->conversationAssignmentLimit = $value; + $this->_setField('conversationAssignmentLimit'); return $this; } @@ -350,6 +360,7 @@ public function getTicketAssignmentLimit(): ?int public function setTicketAssignmentLimit(?int $value = null): self { $this->ticketAssignmentLimit = $value; + $this->_setField('ticketAssignmentLimit'); return $this; } @@ -367,6 +378,7 @@ public function getTeam(): ?ActivityLogMetadataTeam public function setTeam(?ActivityLogMetadataTeam $value = null): self { $this->team = $value; + $this->_setField('team'); return $this; } @@ -384,6 +396,7 @@ public function getTeamAssignmentLimit(): ?int public function setTeamAssignmentLimit(?int $value = null): self { $this->teamAssignmentLimit = $value; + $this->_setField('teamAssignmentLimit'); return $this; } @@ -401,6 +414,7 @@ public function getEnabled(): ?bool public function setEnabled(?bool $value = null): self { $this->enabled = $value; + $this->_setField('enabled'); return $this; } @@ -418,6 +432,7 @@ public function getConsentId(): ?int public function setConsentId(?int $value = null): self { $this->consentId = $value; + $this->_setField('consentId'); return $this; } @@ -435,6 +450,7 @@ public function getExpiredAt(): ?DateTime public function setExpiredAt(?DateTime $value = null): self { $this->expiredAt = $value; + $this->_setField('expiredAt'); return $this; } @@ -452,6 +468,7 @@ public function getBefore(): ?array public function setBefore(?array $value = null): self { $this->before = $value; + $this->_setField('before'); return $this; } @@ -469,6 +486,7 @@ public function getAfter(): ?array public function setAfter(?array $value = null): self { $this->after = $value; + $this->_setField('after'); return $this; } diff --git a/src/Types/ActivityLogMetadataTeam.php b/src/Types/ActivityLogMetadataTeam.php index f535b0d4..781d336b 100644 --- a/src/Types/ActivityLogMetadataTeam.php +++ b/src/Types/ActivityLogMetadataTeam.php @@ -49,6 +49,7 @@ public function getId(): ?int public function setId(?int $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -66,6 +67,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } diff --git a/src/Types/ActivityLogPerformedBy.php b/src/Types/ActivityLogPerformedBy.php index 6abcfbd3..1db5386e 100644 --- a/src/Types/ActivityLogPerformedBy.php +++ b/src/Types/ActivityLogPerformedBy.php @@ -65,6 +65,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -82,6 +83,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -99,6 +101,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -116,6 +119,7 @@ public function getIp(): ?string public function setIp(?string $value = null): self { $this->ip = $value; + $this->_setField('ip'); return $this; } diff --git a/src/Types/AddressableList.php b/src/Types/AddressableList.php index b19309c6..10c1e524 100644 --- a/src/Types/AddressableList.php +++ b/src/Types/AddressableList.php @@ -57,6 +57,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -74,6 +75,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -91,6 +93,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } diff --git a/src/Types/AdminList.php b/src/Types/AdminList.php index 780b63b8..f90d9a27 100644 --- a/src/Types/AdminList.php +++ b/src/Types/AdminList.php @@ -52,6 +52,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -69,6 +70,7 @@ public function getAdmins(): ?array public function setAdmins(?array $value = null): self { $this->admins = $value; + $this->_setField('admins'); return $this; } diff --git a/src/Types/AdminPriorityLevel.php b/src/Types/AdminPriorityLevel.php index 7463aabf..8518fee0 100644 --- a/src/Types/AdminPriorityLevel.php +++ b/src/Types/AdminPriorityLevel.php @@ -50,6 +50,7 @@ public function getPrimaryAdminIds(): ?array public function setPrimaryAdminIds(?array $value = null): self { $this->primaryAdminIds = $value; + $this->_setField('primaryAdminIds'); return $this; } @@ -67,6 +68,7 @@ public function getSecondaryAdminIds(): ?array public function setSecondaryAdminIds(?array $value = null): self { $this->secondaryAdminIds = $value; + $this->_setField('secondaryAdminIds'); return $this; } diff --git a/src/Types/AdminReplyConversationRequest.php b/src/Types/AdminReplyConversationRequest.php index dbdabde1..c64a3ebc 100644 --- a/src/Types/AdminReplyConversationRequest.php +++ b/src/Types/AdminReplyConversationRequest.php @@ -98,6 +98,7 @@ public function getMessageType(): string public function setMessageType(string $value): self { $this->messageType = $value; + $this->_setField('messageType'); return $this; } @@ -115,6 +116,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -132,6 +134,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -149,6 +152,7 @@ public function getAdminId(): string public function setAdminId(string $value): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } @@ -166,6 +170,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -183,6 +188,7 @@ public function getReplyOptions(): ?array public function setReplyOptions(?array $value = null): self { $this->replyOptions = $value; + $this->_setField('replyOptions'); return $this; } @@ -200,6 +206,7 @@ public function getAttachmentUrls(): ?array public function setAttachmentUrls(?array $value = null): self { $this->attachmentUrls = $value; + $this->_setField('attachmentUrls'); return $this; } @@ -217,6 +224,7 @@ public function getAttachmentFiles(): ?array public function setAttachmentFiles(?array $value = null): self { $this->attachmentFiles = $value; + $this->_setField('attachmentFiles'); return $this; } diff --git a/src/Types/AdminReplyTicketRequest.php b/src/Types/AdminReplyTicketRequest.php index 2378ec0d..3b8592b2 100644 --- a/src/Types/AdminReplyTicketRequest.php +++ b/src/Types/AdminReplyTicketRequest.php @@ -90,6 +90,7 @@ public function getMessageType(): string public function setMessageType(string $value): self { $this->messageType = $value; + $this->_setField('messageType'); return $this; } @@ -107,6 +108,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -124,6 +126,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -141,6 +144,7 @@ public function getAdminId(): string public function setAdminId(string $value): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } @@ -158,6 +162,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -175,6 +180,7 @@ public function getReplyOptions(): ?array public function setReplyOptions(?array $value = null): self { $this->replyOptions = $value; + $this->_setField('replyOptions'); return $this; } @@ -192,6 +198,7 @@ public function getAttachmentUrls(): ?array public function setAttachmentUrls(?array $value = null): self { $this->attachmentUrls = $value; + $this->_setField('attachmentUrls'); return $this; } diff --git a/src/Types/AdminReplyTicketRequestReplyOptionsItem.php b/src/Types/AdminReplyTicketRequestReplyOptionsItem.php index 7ace4d09..2d2ba1f2 100644 --- a/src/Types/AdminReplyTicketRequestReplyOptionsItem.php +++ b/src/Types/AdminReplyTicketRequestReplyOptionsItem.php @@ -46,6 +46,7 @@ public function getText(): string public function setText(string $value): self { $this->text = $value; + $this->_setField('text'); return $this; } @@ -63,6 +64,7 @@ public function getUuid(): string public function setUuid(string $value): self { $this->uuid = $value; + $this->_setField('uuid'); return $this; } diff --git a/src/Types/AdminWithApp.php b/src/Types/AdminWithApp.php index 0e37f309..85503353 100644 --- a/src/Types/AdminWithApp.php +++ b/src/Types/AdminWithApp.php @@ -130,6 +130,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -147,6 +148,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -164,6 +166,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -181,6 +184,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -198,6 +202,7 @@ public function getJobTitle(): ?string public function setJobTitle(?string $value = null): self { $this->jobTitle = $value; + $this->_setField('jobTitle'); return $this; } @@ -215,6 +220,7 @@ public function getAwayModeEnabled(): ?bool public function setAwayModeEnabled(?bool $value = null): self { $this->awayModeEnabled = $value; + $this->_setField('awayModeEnabled'); return $this; } @@ -232,6 +238,7 @@ public function getAwayModeReassign(): ?bool public function setAwayModeReassign(?bool $value = null): self { $this->awayModeReassign = $value; + $this->_setField('awayModeReassign'); return $this; } @@ -249,6 +256,7 @@ public function getHasInboxSeat(): ?bool public function setHasInboxSeat(?bool $value = null): self { $this->hasInboxSeat = $value; + $this->_setField('hasInboxSeat'); return $this; } @@ -266,6 +274,7 @@ public function getTeamIds(): ?array public function setTeamIds(?array $value = null): self { $this->teamIds = $value; + $this->_setField('teamIds'); return $this; } @@ -283,6 +292,7 @@ public function getAvatar(): ?AdminWithAppAvatar public function setAvatar(?AdminWithAppAvatar $value = null): self { $this->avatar = $value; + $this->_setField('avatar'); return $this; } @@ -300,6 +310,7 @@ public function getEmailVerified(): ?bool public function setEmailVerified(?bool $value = null): self { $this->emailVerified = $value; + $this->_setField('emailVerified'); return $this; } @@ -317,6 +328,7 @@ public function getApp(): ?App public function setApp(?App $value = null): self { $this->app = $value; + $this->_setField('app'); return $this; } diff --git a/src/Types/AdminWithAppAvatar.php b/src/Types/AdminWithAppAvatar.php index 41f290ca..8a9ec1fe 100644 --- a/src/Types/AdminWithAppAvatar.php +++ b/src/Types/AdminWithAppAvatar.php @@ -49,6 +49,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -66,6 +67,7 @@ public function getImageUrl(): ?string public function setImageUrl(?string $value = null): self { $this->imageUrl = $value; + $this->_setField('imageUrl'); return $this; } diff --git a/src/Types/App.php b/src/Types/App.php index 8d24f8a6..19fcf913 100644 --- a/src/Types/App.php +++ b/src/Types/App.php @@ -89,6 +89,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -106,6 +107,7 @@ public function getIdCode(): ?string public function setIdCode(?string $value = null): self { $this->idCode = $value; + $this->_setField('idCode'); return $this; } @@ -123,6 +125,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -140,6 +143,7 @@ public function getRegion(): ?string public function setRegion(?string $value = null): self { $this->region = $value; + $this->_setField('region'); return $this; } @@ -157,6 +161,7 @@ public function getTimezone(): ?string public function setTimezone(?string $value = null): self { $this->timezone = $value; + $this->_setField('timezone'); return $this; } @@ -174,6 +179,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -191,6 +197,7 @@ public function getIdentityVerification(): ?bool public function setIdentityVerification(?bool $value = null): self { $this->identityVerification = $value; + $this->_setField('identityVerification'); return $this; } diff --git a/src/Types/ArticleContent.php b/src/Types/ArticleContent.php index 6e4f6c1a..927620a6 100644 --- a/src/Types/ArticleContent.php +++ b/src/Types/ArticleContent.php @@ -105,6 +105,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -122,6 +123,7 @@ public function getTitle(): ?string public function setTitle(?string $value = null): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -139,6 +141,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -156,6 +159,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -173,6 +177,7 @@ public function getAuthorId(): ?int public function setAuthorId(?int $value = null): self { $this->authorId = $value; + $this->_setField('authorId'); return $this; } @@ -190,6 +195,7 @@ public function getState(): ?string public function setState(?string $value = null): self { $this->state = $value; + $this->_setField('state'); return $this; } @@ -207,6 +213,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -224,6 +231,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -241,6 +249,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } diff --git a/src/Types/ArticleList.php b/src/Types/ArticleList.php index f3600c26..a2f76aa8 100644 --- a/src/Types/ArticleList.php +++ b/src/Types/ArticleList.php @@ -67,6 +67,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -84,6 +85,7 @@ public function getPages(): mixed public function setPages(mixed $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } @@ -101,6 +103,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -118,6 +121,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Types/ArticleStatistics.php b/src/Types/ArticleStatistics.php index 8628724e..2248a261 100644 --- a/src/Types/ArticleStatistics.php +++ b/src/Types/ArticleStatistics.php @@ -89,6 +89,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -106,6 +107,7 @@ public function getViews(): int public function setViews(int $value): self { $this->views = $value; + $this->_setField('views'); return $this; } @@ -123,6 +125,7 @@ public function getConversions(): ?int public function setConversions(?int $value = null): self { $this->conversions = $value; + $this->_setField('conversions'); return $this; } @@ -140,6 +143,7 @@ public function getReactions(): int public function setReactions(int $value): self { $this->reactions = $value; + $this->_setField('reactions'); return $this; } @@ -157,6 +161,7 @@ public function getHappyReactionPercentage(): float public function setHappyReactionPercentage(float $value): self { $this->happyReactionPercentage = $value; + $this->_setField('happyReactionPercentage'); return $this; } @@ -174,6 +179,7 @@ public function getNeutralReactionPercentage(): float public function setNeutralReactionPercentage(float $value): self { $this->neutralReactionPercentage = $value; + $this->_setField('neutralReactionPercentage'); return $this; } @@ -191,6 +197,7 @@ public function getSadReactionPercentage(): float public function setSadReactionPercentage(float $value): self { $this->sadReactionPercentage = $value; + $this->_setField('sadReactionPercentage'); return $this; } diff --git a/src/Types/ArticleTranslatedContent.php b/src/Types/ArticleTranslatedContent.php index c1e9df14..743b46f0 100644 --- a/src/Types/ArticleTranslatedContent.php +++ b/src/Types/ArticleTranslatedContent.php @@ -337,6 +337,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -354,6 +355,7 @@ public function getAr(): ?ArticleContent public function setAr(?ArticleContent $value = null): self { $this->ar = $value; + $this->_setField('ar'); return $this; } @@ -371,6 +373,7 @@ public function getBg(): ?ArticleContent public function setBg(?ArticleContent $value = null): self { $this->bg = $value; + $this->_setField('bg'); return $this; } @@ -388,6 +391,7 @@ public function getBs(): ?ArticleContent public function setBs(?ArticleContent $value = null): self { $this->bs = $value; + $this->_setField('bs'); return $this; } @@ -405,6 +409,7 @@ public function getCa(): ?ArticleContent public function setCa(?ArticleContent $value = null): self { $this->ca = $value; + $this->_setField('ca'); return $this; } @@ -422,6 +427,7 @@ public function getCs(): ?ArticleContent public function setCs(?ArticleContent $value = null): self { $this->cs = $value; + $this->_setField('cs'); return $this; } @@ -439,6 +445,7 @@ public function getDa(): ?ArticleContent public function setDa(?ArticleContent $value = null): self { $this->da = $value; + $this->_setField('da'); return $this; } @@ -456,6 +463,7 @@ public function getDe(): ?ArticleContent public function setDe(?ArticleContent $value = null): self { $this->de = $value; + $this->_setField('de'); return $this; } @@ -473,6 +481,7 @@ public function getEl(): ?ArticleContent public function setEl(?ArticleContent $value = null): self { $this->el = $value; + $this->_setField('el'); return $this; } @@ -490,6 +499,7 @@ public function getEn(): ?ArticleContent public function setEn(?ArticleContent $value = null): self { $this->en = $value; + $this->_setField('en'); return $this; } @@ -507,6 +517,7 @@ public function getEs(): ?ArticleContent public function setEs(?ArticleContent $value = null): self { $this->es = $value; + $this->_setField('es'); return $this; } @@ -524,6 +535,7 @@ public function getEt(): ?ArticleContent public function setEt(?ArticleContent $value = null): self { $this->et = $value; + $this->_setField('et'); return $this; } @@ -541,6 +553,7 @@ public function getFi(): ?ArticleContent public function setFi(?ArticleContent $value = null): self { $this->fi = $value; + $this->_setField('fi'); return $this; } @@ -558,6 +571,7 @@ public function getFr(): ?ArticleContent public function setFr(?ArticleContent $value = null): self { $this->fr = $value; + $this->_setField('fr'); return $this; } @@ -575,6 +589,7 @@ public function getHe(): ?ArticleContent public function setHe(?ArticleContent $value = null): self { $this->he = $value; + $this->_setField('he'); return $this; } @@ -592,6 +607,7 @@ public function getHr(): ?ArticleContent public function setHr(?ArticleContent $value = null): self { $this->hr = $value; + $this->_setField('hr'); return $this; } @@ -609,6 +625,7 @@ public function getHu(): ?ArticleContent public function setHu(?ArticleContent $value = null): self { $this->hu = $value; + $this->_setField('hu'); return $this; } @@ -626,6 +643,7 @@ public function getId(): ?ArticleContent public function setId(?ArticleContent $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -643,6 +661,7 @@ public function getIt(): ?ArticleContent public function setIt(?ArticleContent $value = null): self { $this->it = $value; + $this->_setField('it'); return $this; } @@ -660,6 +679,7 @@ public function getJa(): ?ArticleContent public function setJa(?ArticleContent $value = null): self { $this->ja = $value; + $this->_setField('ja'); return $this; } @@ -677,6 +697,7 @@ public function getKo(): ?ArticleContent public function setKo(?ArticleContent $value = null): self { $this->ko = $value; + $this->_setField('ko'); return $this; } @@ -694,6 +715,7 @@ public function getLt(): ?ArticleContent public function setLt(?ArticleContent $value = null): self { $this->lt = $value; + $this->_setField('lt'); return $this; } @@ -711,6 +733,7 @@ public function getLv(): ?ArticleContent public function setLv(?ArticleContent $value = null): self { $this->lv = $value; + $this->_setField('lv'); return $this; } @@ -728,6 +751,7 @@ public function getMn(): ?ArticleContent public function setMn(?ArticleContent $value = null): self { $this->mn = $value; + $this->_setField('mn'); return $this; } @@ -745,6 +769,7 @@ public function getNb(): ?ArticleContent public function setNb(?ArticleContent $value = null): self { $this->nb = $value; + $this->_setField('nb'); return $this; } @@ -762,6 +787,7 @@ public function getNl(): ?ArticleContent public function setNl(?ArticleContent $value = null): self { $this->nl = $value; + $this->_setField('nl'); return $this; } @@ -779,6 +805,7 @@ public function getPl(): ?ArticleContent public function setPl(?ArticleContent $value = null): self { $this->pl = $value; + $this->_setField('pl'); return $this; } @@ -796,6 +823,7 @@ public function getPt(): ?ArticleContent public function setPt(?ArticleContent $value = null): self { $this->pt = $value; + $this->_setField('pt'); return $this; } @@ -813,6 +841,7 @@ public function getRo(): ?ArticleContent public function setRo(?ArticleContent $value = null): self { $this->ro = $value; + $this->_setField('ro'); return $this; } @@ -830,6 +859,7 @@ public function getRu(): ?ArticleContent public function setRu(?ArticleContent $value = null): self { $this->ru = $value; + $this->_setField('ru'); return $this; } @@ -847,6 +877,7 @@ public function getSl(): ?ArticleContent public function setSl(?ArticleContent $value = null): self { $this->sl = $value; + $this->_setField('sl'); return $this; } @@ -864,6 +895,7 @@ public function getSr(): ?ArticleContent public function setSr(?ArticleContent $value = null): self { $this->sr = $value; + $this->_setField('sr'); return $this; } @@ -881,6 +913,7 @@ public function getSv(): ?ArticleContent public function setSv(?ArticleContent $value = null): self { $this->sv = $value; + $this->_setField('sv'); return $this; } @@ -898,6 +931,7 @@ public function getTr(): ?ArticleContent public function setTr(?ArticleContent $value = null): self { $this->tr = $value; + $this->_setField('tr'); return $this; } @@ -915,6 +949,7 @@ public function getVi(): ?ArticleContent public function setVi(?ArticleContent $value = null): self { $this->vi = $value; + $this->_setField('vi'); return $this; } @@ -932,6 +967,7 @@ public function getPtBr(): ?ArticleContent public function setPtBr(?ArticleContent $value = null): self { $this->ptBr = $value; + $this->_setField('ptBr'); return $this; } @@ -949,6 +985,7 @@ public function getZhCn(): ?ArticleContent public function setZhCn(?ArticleContent $value = null): self { $this->zhCn = $value; + $this->_setField('zhCn'); return $this; } @@ -966,6 +1003,7 @@ public function getZhTw(): ?ArticleContent public function setZhTw(?ArticleContent $value = null): self { $this->zhTw = $value; + $this->_setField('zhTw'); return $this; } diff --git a/src/Types/AssignConversationRequest.php b/src/Types/AssignConversationRequest.php index e083b474..f75f66bc 100644 --- a/src/Types/AssignConversationRequest.php +++ b/src/Types/AssignConversationRequest.php @@ -65,6 +65,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -82,6 +83,7 @@ public function getAdminId(): string public function setAdminId(string $value): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } @@ -99,6 +101,7 @@ public function getAssigneeId(): string public function setAssigneeId(string $value): self { $this->assigneeId = $value; + $this->_setField('assigneeId'); return $this; } @@ -116,6 +119,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } diff --git a/src/Types/AwayStatusReason.php b/src/Types/AwayStatusReason.php index 47e4886c..37ee20d4 100644 --- a/src/Types/AwayStatusReason.php +++ b/src/Types/AwayStatusReason.php @@ -94,6 +94,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -111,6 +112,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -128,6 +130,7 @@ public function getLabel(): ?string public function setLabel(?string $value = null): self { $this->label = $value; + $this->_setField('label'); return $this; } @@ -145,6 +148,7 @@ public function getEmoji(): ?string public function setEmoji(?string $value = null): self { $this->emoji = $value; + $this->_setField('emoji'); return $this; } @@ -162,6 +166,7 @@ public function getOrder(): ?int public function setOrder(?int $value = null): self { $this->order = $value; + $this->_setField('order'); return $this; } @@ -179,6 +184,7 @@ public function getDeleted(): ?bool public function setDeleted(?bool $value = null): self { $this->deleted = $value; + $this->_setField('deleted'); return $this; } @@ -196,6 +202,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -213,6 +220,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } diff --git a/src/Types/CallList.php b/src/Types/CallList.php index 3ed1058f..ad2fe73d 100644 --- a/src/Types/CallList.php +++ b/src/Types/CallList.php @@ -67,6 +67,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -84,6 +85,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } @@ -101,6 +103,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -118,6 +121,7 @@ public function getPages(): ?CursorPages public function setPages(?CursorPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } diff --git a/src/Types/CloseConversationRequest.php b/src/Types/CloseConversationRequest.php index ee8344f2..3d8a77cc 100644 --- a/src/Types/CloseConversationRequest.php +++ b/src/Types/CloseConversationRequest.php @@ -57,6 +57,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -74,6 +75,7 @@ public function getAdminId(): string public function setAdminId(string $value): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } @@ -91,6 +93,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } diff --git a/src/Types/CollectionList.php b/src/Types/CollectionList.php index 42714b47..65a6f3b5 100644 --- a/src/Types/CollectionList.php +++ b/src/Types/CollectionList.php @@ -67,6 +67,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -84,6 +85,7 @@ public function getPages(): ?OffsetPages public function setPages(?OffsetPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } @@ -101,6 +103,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -118,6 +121,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Types/CompanyAttachedContacts.php b/src/Types/CompanyAttachedContacts.php index 58daef16..04920bec 100644 --- a/src/Types/CompanyAttachedContacts.php +++ b/src/Types/CompanyAttachedContacts.php @@ -67,6 +67,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -84,6 +85,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } @@ -101,6 +103,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -118,6 +121,7 @@ public function getPages(): ?CursorPages public function setPages(?CursorPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } diff --git a/src/Types/CompanyAttachedSegments.php b/src/Types/CompanyAttachedSegments.php index 4fd56eb7..99f4fb11 100644 --- a/src/Types/CompanyAttachedSegments.php +++ b/src/Types/CompanyAttachedSegments.php @@ -51,6 +51,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -68,6 +69,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Types/CompanyData.php b/src/Types/CompanyData.php index 11bef28a..477519fa 100644 --- a/src/Types/CompanyData.php +++ b/src/Types/CompanyData.php @@ -57,6 +57,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -74,6 +75,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -91,6 +93,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } diff --git a/src/Types/CompanyList.php b/src/Types/CompanyList.php index 45fab892..c5fc7470 100644 --- a/src/Types/CompanyList.php +++ b/src/Types/CompanyList.php @@ -67,6 +67,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -84,6 +85,7 @@ public function getPages(): ?OffsetPages public function setPages(?OffsetPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } @@ -101,6 +103,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -118,6 +121,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Types/CompanyScroll.php b/src/Types/CompanyScroll.php index 88c37743..36cf5dfc 100644 --- a/src/Types/CompanyScroll.php +++ b/src/Types/CompanyScroll.php @@ -75,6 +75,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -92,6 +93,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } @@ -109,6 +111,7 @@ public function getPages(): ?CursorPages public function setPages(?CursorPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } @@ -126,6 +129,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -143,6 +147,7 @@ public function getScrollParam(): ?string public function setScrollParam(?string $value = null): self { $this->scrollParam = $value; + $this->_setField('scrollParam'); return $this; } diff --git a/src/Types/ContactArchived.php b/src/Types/ContactArchived.php index 7e22c6c9..f3a2d9cc 100644 --- a/src/Types/ContactArchived.php +++ b/src/Types/ContactArchived.php @@ -50,6 +50,7 @@ public function getArchived(): ?bool public function setArchived(?bool $value = null): self { $this->archived = $value; + $this->_setField('archived'); return $this; } diff --git a/src/Types/ContactAttachedCompanies.php b/src/Types/ContactAttachedCompanies.php index 913eb5a0..4425df24 100644 --- a/src/Types/ContactAttachedCompanies.php +++ b/src/Types/ContactAttachedCompanies.php @@ -67,6 +67,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -84,6 +85,7 @@ public function getCompanies(): ?array public function setCompanies(?array $value = null): self { $this->companies = $value; + $this->_setField('companies'); return $this; } @@ -101,6 +103,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -118,6 +121,7 @@ public function getPages(): ?PagesLink public function setPages(?PagesLink $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } diff --git a/src/Types/ContactBlocked.php b/src/Types/ContactBlocked.php index f3621705..e716f307 100644 --- a/src/Types/ContactBlocked.php +++ b/src/Types/ContactBlocked.php @@ -50,6 +50,7 @@ public function getBlocked(): ?bool public function setBlocked(?bool $value = null): self { $this->blocked = $value; + $this->_setField('blocked'); return $this; } diff --git a/src/Types/ContactCompanies.php b/src/Types/ContactCompanies.php index 683bb06c..f6ca82c0 100644 --- a/src/Types/ContactCompanies.php +++ b/src/Types/ContactCompanies.php @@ -66,6 +66,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } @@ -83,6 +84,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -100,6 +102,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -117,6 +120,7 @@ public function getHasMore(): ?bool public function setHasMore(?bool $value = null): self { $this->hasMore = $value; + $this->_setField('hasMore'); return $this; } diff --git a/src/Types/ContactDeleted.php b/src/Types/ContactDeleted.php index d87c3de5..c66f6a4a 100644 --- a/src/Types/ContactDeleted.php +++ b/src/Types/ContactDeleted.php @@ -50,6 +50,7 @@ public function getDeleted(): ?bool public function setDeleted(?bool $value = null): self { $this->deleted = $value; + $this->_setField('deleted'); return $this; } diff --git a/src/Types/ContactList.php b/src/Types/ContactList.php index 4e70fc7e..336ac888 100644 --- a/src/Types/ContactList.php +++ b/src/Types/ContactList.php @@ -67,6 +67,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -84,6 +85,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } @@ -101,6 +103,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -118,6 +121,7 @@ public function getPages(): ?CursorPages public function setPages(?CursorPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } diff --git a/src/Types/ContactLocation.php b/src/Types/ContactLocation.php index d980da5b..abe18a22 100644 --- a/src/Types/ContactLocation.php +++ b/src/Types/ContactLocation.php @@ -65,6 +65,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -82,6 +83,7 @@ public function getCountry(): ?string public function setCountry(?string $value = null): self { $this->country = $value; + $this->_setField('country'); return $this; } @@ -99,6 +101,7 @@ public function getRegion(): ?string public function setRegion(?string $value = null): self { $this->region = $value; + $this->_setField('region'); return $this; } @@ -116,6 +119,7 @@ public function getCity(): ?string public function setCity(?string $value = null): self { $this->city = $value; + $this->_setField('city'); return $this; } diff --git a/src/Types/ContactNotes.php b/src/Types/ContactNotes.php index 4f560174..14c8b019 100644 --- a/src/Types/ContactNotes.php +++ b/src/Types/ContactNotes.php @@ -66,6 +66,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } @@ -83,6 +84,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -100,6 +102,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -117,6 +120,7 @@ public function getHasMore(): ?bool public function setHasMore(?bool $value = null): self { $this->hasMore = $value; + $this->_setField('hasMore'); return $this; } diff --git a/src/Types/ContactReference.php b/src/Types/ContactReference.php index 8cea2885..27ac527f 100644 --- a/src/Types/ContactReference.php +++ b/src/Types/ContactReference.php @@ -57,6 +57,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -74,6 +75,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -91,6 +93,7 @@ public function getExternalId(): ?string public function setExternalId(?string $value = null): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } diff --git a/src/Types/ContactReplyBaseRequest.php b/src/Types/ContactReplyBaseRequest.php index c37b3517..3f641f75 100644 --- a/src/Types/ContactReplyBaseRequest.php +++ b/src/Types/ContactReplyBaseRequest.php @@ -79,6 +79,7 @@ public function getMessageType(): string public function setMessageType(string $value): self { $this->messageType = $value; + $this->_setField('messageType'); return $this; } @@ -96,6 +97,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -113,6 +115,7 @@ public function getBody(): string public function setBody(string $value): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -130,6 +133,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -147,6 +151,7 @@ public function getAttachmentUrls(): ?array public function setAttachmentUrls(?array $value = null): self { $this->attachmentUrls = $value; + $this->_setField('attachmentUrls'); return $this; } @@ -164,6 +169,7 @@ public function getReplyOptions(): ?array public function setReplyOptions(?array $value = null): self { $this->replyOptions = $value; + $this->_setField('replyOptions'); return $this; } diff --git a/src/Types/ContactReplyBaseRequestReplyOptionsItem.php b/src/Types/ContactReplyBaseRequestReplyOptionsItem.php index 50c1f58d..73d67ba9 100644 --- a/src/Types/ContactReplyBaseRequestReplyOptionsItem.php +++ b/src/Types/ContactReplyBaseRequestReplyOptionsItem.php @@ -46,6 +46,7 @@ public function getText(): string public function setText(string $value): self { $this->text = $value; + $this->_setField('text'); return $this; } @@ -63,6 +64,7 @@ public function getUuid(): string public function setUuid(string $value): self { $this->uuid = $value; + $this->_setField('uuid'); return $this; } diff --git a/src/Types/ContactReplyEmailRequest.php b/src/Types/ContactReplyEmailRequest.php index ab3d6fea..e8655276 100644 --- a/src/Types/ContactReplyEmailRequest.php +++ b/src/Types/ContactReplyEmailRequest.php @@ -65,6 +65,7 @@ public function getEmail(): string public function setEmail(string $value): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -82,6 +83,7 @@ public function getAttachmentFiles(): ?array public function setAttachmentFiles(?array $value = null): self { $this->attachmentFiles = $value; + $this->_setField('attachmentFiles'); return $this; } diff --git a/src/Types/ContactReplyIntercomUserIdRequest.php b/src/Types/ContactReplyIntercomUserIdRequest.php index 6045ad35..5803ddad 100644 --- a/src/Types/ContactReplyIntercomUserIdRequest.php +++ b/src/Types/ContactReplyIntercomUserIdRequest.php @@ -65,6 +65,7 @@ public function getIntercomUserId(): string public function setIntercomUserId(string $value): self { $this->intercomUserId = $value; + $this->_setField('intercomUserId'); return $this; } @@ -82,6 +83,7 @@ public function getAttachmentFiles(): ?array public function setAttachmentFiles(?array $value = null): self { $this->attachmentFiles = $value; + $this->_setField('attachmentFiles'); return $this; } diff --git a/src/Types/ContactReplyTicketEmailRequest.php b/src/Types/ContactReplyTicketEmailRequest.php index eb1e6822..e85bf53b 100644 --- a/src/Types/ContactReplyTicketEmailRequest.php +++ b/src/Types/ContactReplyTicketEmailRequest.php @@ -56,6 +56,7 @@ public function getEmail(): string public function setEmail(string $value): self { $this->email = $value; + $this->_setField('email'); return $this; } diff --git a/src/Types/ContactReplyTicketIntercomUserIdRequest.php b/src/Types/ContactReplyTicketIntercomUserIdRequest.php index 10eb5705..db717be7 100644 --- a/src/Types/ContactReplyTicketIntercomUserIdRequest.php +++ b/src/Types/ContactReplyTicketIntercomUserIdRequest.php @@ -56,6 +56,7 @@ public function getIntercomUserId(): string public function setIntercomUserId(string $value): self { $this->intercomUserId = $value; + $this->_setField('intercomUserId'); return $this; } diff --git a/src/Types/ContactReplyTicketUserIdRequest.php b/src/Types/ContactReplyTicketUserIdRequest.php index d04729df..ccf8d31c 100644 --- a/src/Types/ContactReplyTicketUserIdRequest.php +++ b/src/Types/ContactReplyTicketUserIdRequest.php @@ -56,6 +56,7 @@ public function getUserId(): string public function setUserId(string $value): self { $this->userId = $value; + $this->_setField('userId'); return $this; } diff --git a/src/Types/ContactReplyUserIdRequest.php b/src/Types/ContactReplyUserIdRequest.php index d66f280d..e70e075b 100644 --- a/src/Types/ContactReplyUserIdRequest.php +++ b/src/Types/ContactReplyUserIdRequest.php @@ -65,6 +65,7 @@ public function getUserId(): string public function setUserId(string $value): self { $this->userId = $value; + $this->_setField('userId'); return $this; } @@ -82,6 +83,7 @@ public function getAttachmentFiles(): ?array public function setAttachmentFiles(?array $value = null): self { $this->attachmentFiles = $value; + $this->_setField('attachmentFiles'); return $this; } diff --git a/src/Types/ContactSegments.php b/src/Types/ContactSegments.php index 51d57d88..5f49a466 100644 --- a/src/Types/ContactSegments.php +++ b/src/Types/ContactSegments.php @@ -51,6 +51,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -68,6 +69,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Types/ContactSocialProfiles.php b/src/Types/ContactSocialProfiles.php index 593605be..c45a0165 100644 --- a/src/Types/ContactSocialProfiles.php +++ b/src/Types/ContactSocialProfiles.php @@ -42,6 +42,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Types/ContactSubscriptionTypes.php b/src/Types/ContactSubscriptionTypes.php index f95750f9..23291b28 100644 --- a/src/Types/ContactSubscriptionTypes.php +++ b/src/Types/ContactSubscriptionTypes.php @@ -66,6 +66,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } @@ -83,6 +84,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -100,6 +102,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -117,6 +120,7 @@ public function getHasMore(): ?bool public function setHasMore(?bool $value = null): self { $this->hasMore = $value; + $this->_setField('hasMore'); return $this; } diff --git a/src/Types/ContactTags.php b/src/Types/ContactTags.php index 8f267234..f3a6cf79 100644 --- a/src/Types/ContactTags.php +++ b/src/Types/ContactTags.php @@ -66,6 +66,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } @@ -83,6 +84,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -100,6 +102,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -117,6 +120,7 @@ public function getHasMore(): ?bool public function setHasMore(?bool $value = null): self { $this->hasMore = $value; + $this->_setField('hasMore'); return $this; } diff --git a/src/Types/ContactUnarchived.php b/src/Types/ContactUnarchived.php index 99b1f1a9..9b8a728e 100644 --- a/src/Types/ContactUnarchived.php +++ b/src/Types/ContactUnarchived.php @@ -50,6 +50,7 @@ public function getArchived(): ?bool public function setArchived(?bool $value = null): self { $this->archived = $value; + $this->_setField('archived'); return $this; } diff --git a/src/Types/ContentSourcesList.php b/src/Types/ContentSourcesList.php index 4932ae0f..f8a2ce02 100644 --- a/src/Types/ContentSourcesList.php +++ b/src/Types/ContentSourcesList.php @@ -56,6 +56,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -73,6 +74,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -90,6 +92,7 @@ public function getContentSources(): ?array public function setContentSources(?array $value = null): self { $this->contentSources = $value; + $this->_setField('contentSources'); return $this; } diff --git a/src/Types/ConversationAttachmentFiles.php b/src/Types/ConversationAttachmentFiles.php index 4e99e1a8..167500a2 100644 --- a/src/Types/ConversationAttachmentFiles.php +++ b/src/Types/ConversationAttachmentFiles.php @@ -57,6 +57,7 @@ public function getContentType(): ?string public function setContentType(?string $value = null): self { $this->contentType = $value; + $this->_setField('contentType'); return $this; } @@ -74,6 +75,7 @@ public function getData(): ?string public function setData(?string $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } @@ -91,6 +93,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } diff --git a/src/Types/ConversationAttributeUpdatedByAdmin.php b/src/Types/ConversationAttributeUpdatedByAdmin.php index d0036fa6..521b9f58 100644 --- a/src/Types/ConversationAttributeUpdatedByAdmin.php +++ b/src/Types/ConversationAttributeUpdatedByAdmin.php @@ -49,6 +49,7 @@ public function getAttribute(): ?ConversationAttributeUpdatedByAdminAttribute public function setAttribute(?ConversationAttributeUpdatedByAdminAttribute $value = null): self { $this->attribute = $value; + $this->_setField('attribute'); return $this; } @@ -66,6 +67,7 @@ public function getValue(): ?ConversationAttributeUpdatedByAdminValue public function setValue(?ConversationAttributeUpdatedByAdminValue $value = null): self { $this->value = $value; + $this->_setField('value'); return $this; } diff --git a/src/Types/ConversationAttributeUpdatedByAdminAttribute.php b/src/Types/ConversationAttributeUpdatedByAdminAttribute.php index 7c2cd2a8..a433554f 100644 --- a/src/Types/ConversationAttributeUpdatedByAdminAttribute.php +++ b/src/Types/ConversationAttributeUpdatedByAdminAttribute.php @@ -38,6 +38,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } diff --git a/src/Types/ConversationAttributeUpdatedByAdminValue.php b/src/Types/ConversationAttributeUpdatedByAdminValue.php index 28adf733..d874a48f 100644 --- a/src/Types/ConversationAttributeUpdatedByAdminValue.php +++ b/src/Types/ConversationAttributeUpdatedByAdminValue.php @@ -38,6 +38,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } diff --git a/src/Types/ConversationAttributeUpdatedByWorkflow.php b/src/Types/ConversationAttributeUpdatedByWorkflow.php index 02582d50..0d618f20 100644 --- a/src/Types/ConversationAttributeUpdatedByWorkflow.php +++ b/src/Types/ConversationAttributeUpdatedByWorkflow.php @@ -57,6 +57,7 @@ public function getWorkflow(): ?ConversationAttributeUpdatedByWorkflowWorkflow public function setWorkflow(?ConversationAttributeUpdatedByWorkflowWorkflow $value = null): self { $this->workflow = $value; + $this->_setField('workflow'); return $this; } @@ -74,6 +75,7 @@ public function getAttribute(): ?ConversationAttributeUpdatedByWorkflowAttribute public function setAttribute(?ConversationAttributeUpdatedByWorkflowAttribute $value = null): self { $this->attribute = $value; + $this->_setField('attribute'); return $this; } @@ -91,6 +93,7 @@ public function getValue(): ?ConversationAttributeUpdatedByWorkflowValue public function setValue(?ConversationAttributeUpdatedByWorkflowValue $value = null): self { $this->value = $value; + $this->_setField('value'); return $this; } diff --git a/src/Types/ConversationAttributeUpdatedByWorkflowAttribute.php b/src/Types/ConversationAttributeUpdatedByWorkflowAttribute.php index 307a4aaa..763eaffb 100644 --- a/src/Types/ConversationAttributeUpdatedByWorkflowAttribute.php +++ b/src/Types/ConversationAttributeUpdatedByWorkflowAttribute.php @@ -38,6 +38,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } diff --git a/src/Types/ConversationAttributeUpdatedByWorkflowValue.php b/src/Types/ConversationAttributeUpdatedByWorkflowValue.php index 670b424c..9dca7721 100644 --- a/src/Types/ConversationAttributeUpdatedByWorkflowValue.php +++ b/src/Types/ConversationAttributeUpdatedByWorkflowValue.php @@ -38,6 +38,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } diff --git a/src/Types/ConversationAttributeUpdatedByWorkflowWorkflow.php b/src/Types/ConversationAttributeUpdatedByWorkflowWorkflow.php index 52e410e9..71cdf41b 100644 --- a/src/Types/ConversationAttributeUpdatedByWorkflowWorkflow.php +++ b/src/Types/ConversationAttributeUpdatedByWorkflowWorkflow.php @@ -38,6 +38,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } diff --git a/src/Types/ConversationContacts.php b/src/Types/ConversationContacts.php index 881660e0..63e599d4 100644 --- a/src/Types/ConversationContacts.php +++ b/src/Types/ConversationContacts.php @@ -50,6 +50,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -67,6 +68,7 @@ public function getContacts(): ?array public function setContacts(?array $value = null): self { $this->contacts = $value; + $this->_setField('contacts'); return $this; } diff --git a/src/Types/ConversationDeleted.php b/src/Types/ConversationDeleted.php index eb399ac2..aa780255 100644 --- a/src/Types/ConversationDeleted.php +++ b/src/Types/ConversationDeleted.php @@ -57,6 +57,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -74,6 +75,7 @@ public function getObject(): ?string public function setObject(?string $value = null): self { $this->object = $value; + $this->_setField('object'); return $this; } @@ -91,6 +93,7 @@ public function getDeleted(): ?bool public function setDeleted(?bool $value = null): self { $this->deleted = $value; + $this->_setField('deleted'); return $this; } diff --git a/src/Types/ConversationFirstContactReply.php b/src/Types/ConversationFirstContactReply.php index 73093648..16959922 100644 --- a/src/Types/ConversationFirstContactReply.php +++ b/src/Types/ConversationFirstContactReply.php @@ -57,6 +57,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -74,6 +75,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -91,6 +93,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } diff --git a/src/Types/ConversationList.php b/src/Types/ConversationList.php index fc879e20..d882e4e6 100644 --- a/src/Types/ConversationList.php +++ b/src/Types/ConversationList.php @@ -67,6 +67,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -84,6 +85,7 @@ public function getConversations(): ?array public function setConversations(?array $value = null): self { $this->conversations = $value; + $this->_setField('conversations'); return $this; } @@ -101,6 +103,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -118,6 +121,7 @@ public function getPages(): ?CursorPages public function setPages(?CursorPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } diff --git a/src/Types/ConversationPart.php b/src/Types/ConversationPart.php index 9483e8bc..8700b989 100644 --- a/src/Types/ConversationPart.php +++ b/src/Types/ConversationPart.php @@ -192,6 +192,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -209,6 +210,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -226,6 +228,7 @@ public function getPartType(): ?string public function setPartType(?string $value = null): self { $this->partType = $value; + $this->_setField('partType'); return $this; } @@ -243,6 +246,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -260,6 +264,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -277,6 +282,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -294,6 +300,7 @@ public function getNotifiedAt(): ?int public function setNotifiedAt(?int $value = null): self { $this->notifiedAt = $value; + $this->_setField('notifiedAt'); return $this; } @@ -311,6 +318,7 @@ public function getAssignedTo(): ?Reference public function setAssignedTo(?Reference $value = null): self { $this->assignedTo = $value; + $this->_setField('assignedTo'); return $this; } @@ -328,6 +336,7 @@ public function getAuthor(): ?ConversationPartAuthor public function setAuthor(?ConversationPartAuthor $value = null): self { $this->author = $value; + $this->_setField('author'); return $this; } @@ -345,6 +354,7 @@ public function getAttachments(): ?array public function setAttachments(?array $value = null): self { $this->attachments = $value; + $this->_setField('attachments'); return $this; } @@ -362,6 +372,7 @@ public function getExternalId(): ?string public function setExternalId(?string $value = null): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } @@ -379,6 +390,7 @@ public function getRedacted(): ?bool public function setRedacted(?bool $value = null): self { $this->redacted = $value; + $this->_setField('redacted'); return $this; } @@ -396,6 +408,7 @@ public function getEmailMessageMetadata(): ?EmailMessageMetadata public function setEmailMessageMetadata(?EmailMessageMetadata $value = null): self { $this->emailMessageMetadata = $value; + $this->_setField('emailMessageMetadata'); return $this; } @@ -413,6 +426,7 @@ public function getMetadata(): ?ConversationPartMetadata public function setMetadata(?ConversationPartMetadata $value = null): self { $this->metadata = $value; + $this->_setField('metadata'); return $this; } @@ -430,6 +444,7 @@ public function getState(): ?string public function setState(?string $value = null): self { $this->state = $value; + $this->_setField('state'); return $this; } @@ -447,6 +462,7 @@ public function getTags(): ?array public function setTags(?array $value = null): self { $this->tags = $value; + $this->_setField('tags'); return $this; } @@ -476,6 +492,7 @@ public function getEventDetails(): ConversationAttributeUpdatedByWorkflow|Conver public function setEventDetails(ConversationAttributeUpdatedByWorkflow|ConversationAttributeUpdatedByAdmin|CustomActionStarted|CustomActionFinished|OperatorWorkflowEvent|null $value = null): self { $this->eventDetails = $value; + $this->_setField('eventDetails'); return $this; } @@ -493,6 +510,7 @@ public function getAppPackageCode(): ?string public function setAppPackageCode(?string $value = null): self { $this->appPackageCode = $value; + $this->_setField('appPackageCode'); return $this; } diff --git a/src/Types/ConversationPartAuthor.php b/src/Types/ConversationPartAuthor.php index 74391d6f..73c17c63 100644 --- a/src/Types/ConversationPartAuthor.php +++ b/src/Types/ConversationPartAuthor.php @@ -81,6 +81,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -98,6 +99,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -115,6 +117,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -132,6 +135,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -149,6 +153,7 @@ public function getFromAiAgent(): ?bool public function setFromAiAgent(?bool $value = null): self { $this->fromAiAgent = $value; + $this->_setField('fromAiAgent'); return $this; } @@ -166,6 +171,7 @@ public function getIsAiAnswer(): ?bool public function setIsAiAnswer(?bool $value = null): self { $this->isAiAnswer = $value; + $this->_setField('isAiAnswer'); return $this; } diff --git a/src/Types/ConversationPartMetadata.php b/src/Types/ConversationPartMetadata.php index 3b98dc0d..e13add9f 100644 --- a/src/Types/ConversationPartMetadata.php +++ b/src/Types/ConversationPartMetadata.php @@ -50,6 +50,7 @@ public function getQuickReplyOptions(): ?array public function setQuickReplyOptions(?array $value = null): self { $this->quickReplyOptions = $value; + $this->_setField('quickReplyOptions'); return $this; } @@ -67,6 +68,7 @@ public function getQuickReplyUuid(): ?string public function setQuickReplyUuid(?string $value = null): self { $this->quickReplyUuid = $value; + $this->_setField('quickReplyUuid'); return $this; } diff --git a/src/Types/ConversationPartMetadataQuickReplyOptionsItem.php b/src/Types/ConversationPartMetadataQuickReplyOptionsItem.php index 50580eb1..af9b7220 100644 --- a/src/Types/ConversationPartMetadataQuickReplyOptionsItem.php +++ b/src/Types/ConversationPartMetadataQuickReplyOptionsItem.php @@ -46,6 +46,7 @@ public function getTranslations(): ?array public function setTranslations(?array $value = null): self { $this->translations = $value; + $this->_setField('translations'); return $this; } diff --git a/src/Types/ConversationParts.php b/src/Types/ConversationParts.php index 1728712d..1855175c 100644 --- a/src/Types/ConversationParts.php +++ b/src/Types/ConversationParts.php @@ -58,6 +58,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -75,6 +76,7 @@ public function getConversationParts(): ?array public function setConversationParts(?array $value = null): self { $this->conversationParts = $value; + $this->_setField('conversationParts'); return $this; } @@ -92,6 +94,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } diff --git a/src/Types/ConversationRating.php b/src/Types/ConversationRating.php index 21084bcb..ace4381e 100644 --- a/src/Types/ConversationRating.php +++ b/src/Types/ConversationRating.php @@ -81,6 +81,7 @@ public function getRating(): ?int public function setRating(?int $value = null): self { $this->rating = $value; + $this->_setField('rating'); return $this; } @@ -98,6 +99,7 @@ public function getRemark(): ?string public function setRemark(?string $value = null): self { $this->remark = $value; + $this->_setField('remark'); return $this; } @@ -115,6 +117,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -132,6 +135,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -149,6 +153,7 @@ public function getContact(): ?ContactReference public function setContact(?ContactReference $value = null): self { $this->contact = $value; + $this->_setField('contact'); return $this; } @@ -166,6 +171,7 @@ public function getTeammate(): ?Reference public function setTeammate(?Reference $value = null): self { $this->teammate = $value; + $this->_setField('teammate'); return $this; } diff --git a/src/Types/ConversationResponseTime.php b/src/Types/ConversationResponseTime.php index ee5a9a64..c993d210 100644 --- a/src/Types/ConversationResponseTime.php +++ b/src/Types/ConversationResponseTime.php @@ -57,6 +57,7 @@ public function getTeamId(): ?int public function setTeamId(?int $value = null): self { $this->teamId = $value; + $this->_setField('teamId'); return $this; } @@ -74,6 +75,7 @@ public function getTeamName(): ?string public function setTeamName(?string $value = null): self { $this->teamName = $value; + $this->_setField('teamName'); return $this; } @@ -91,6 +93,7 @@ public function getResponseTime(): ?int public function setResponseTime(?int $value = null): self { $this->responseTime = $value; + $this->_setField('responseTime'); return $this; } diff --git a/src/Types/ConversationSource.php b/src/Types/ConversationSource.php index 9c82734d..52e0cab3 100644 --- a/src/Types/ConversationSource.php +++ b/src/Types/ConversationSource.php @@ -106,6 +106,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -123,6 +124,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -140,6 +142,7 @@ public function getDeliveredAs(): ?string public function setDeliveredAs(?string $value = null): self { $this->deliveredAs = $value; + $this->_setField('deliveredAs'); return $this; } @@ -157,6 +160,7 @@ public function getSubject(): ?string public function setSubject(?string $value = null): self { $this->subject = $value; + $this->_setField('subject'); return $this; } @@ -174,6 +178,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -191,6 +196,7 @@ public function getAuthor(): ?ConversationPartAuthor public function setAuthor(?ConversationPartAuthor $value = null): self { $this->author = $value; + $this->_setField('author'); return $this; } @@ -208,6 +214,7 @@ public function getAttachments(): ?array public function setAttachments(?array $value = null): self { $this->attachments = $value; + $this->_setField('attachments'); return $this; } @@ -225,6 +232,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -242,6 +250,7 @@ public function getRedacted(): ?bool public function setRedacted(?bool $value = null): self { $this->redacted = $value; + $this->_setField('redacted'); return $this; } diff --git a/src/Types/ConversationStatistics.php b/src/Types/ConversationStatistics.php index 7b381555..d3be2155 100644 --- a/src/Types/ConversationStatistics.php +++ b/src/Types/ConversationStatistics.php @@ -218,6 +218,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -235,6 +236,7 @@ public function getTimeToAssignment(): ?int public function setTimeToAssignment(?int $value = null): self { $this->timeToAssignment = $value; + $this->_setField('timeToAssignment'); return $this; } @@ -252,6 +254,7 @@ public function getTimeToAdminReply(): ?int public function setTimeToAdminReply(?int $value = null): self { $this->timeToAdminReply = $value; + $this->_setField('timeToAdminReply'); return $this; } @@ -269,6 +272,7 @@ public function getTimeToFirstClose(): ?int public function setTimeToFirstClose(?int $value = null): self { $this->timeToFirstClose = $value; + $this->_setField('timeToFirstClose'); return $this; } @@ -286,6 +290,7 @@ public function getTimeToLastClose(): ?int public function setTimeToLastClose(?int $value = null): self { $this->timeToLastClose = $value; + $this->_setField('timeToLastClose'); return $this; } @@ -303,6 +308,7 @@ public function getMedianTimeToReply(): ?int public function setMedianTimeToReply(?int $value = null): self { $this->medianTimeToReply = $value; + $this->_setField('medianTimeToReply'); return $this; } @@ -320,6 +326,7 @@ public function getFirstContactReplyAt(): ?int public function setFirstContactReplyAt(?int $value = null): self { $this->firstContactReplyAt = $value; + $this->_setField('firstContactReplyAt'); return $this; } @@ -337,6 +344,7 @@ public function getFirstAssignmentAt(): ?int public function setFirstAssignmentAt(?int $value = null): self { $this->firstAssignmentAt = $value; + $this->_setField('firstAssignmentAt'); return $this; } @@ -354,6 +362,7 @@ public function getFirstAdminReplyAt(): ?int public function setFirstAdminReplyAt(?int $value = null): self { $this->firstAdminReplyAt = $value; + $this->_setField('firstAdminReplyAt'); return $this; } @@ -371,6 +380,7 @@ public function getFirstCloseAt(): ?int public function setFirstCloseAt(?int $value = null): self { $this->firstCloseAt = $value; + $this->_setField('firstCloseAt'); return $this; } @@ -388,6 +398,7 @@ public function getLastAssignmentAt(): ?int public function setLastAssignmentAt(?int $value = null): self { $this->lastAssignmentAt = $value; + $this->_setField('lastAssignmentAt'); return $this; } @@ -405,6 +416,7 @@ public function getLastAssignmentAdminReplyAt(): ?int public function setLastAssignmentAdminReplyAt(?int $value = null): self { $this->lastAssignmentAdminReplyAt = $value; + $this->_setField('lastAssignmentAdminReplyAt'); return $this; } @@ -422,6 +434,7 @@ public function getLastContactReplyAt(): ?int public function setLastContactReplyAt(?int $value = null): self { $this->lastContactReplyAt = $value; + $this->_setField('lastContactReplyAt'); return $this; } @@ -439,6 +452,7 @@ public function getLastAdminReplyAt(): ?int public function setLastAdminReplyAt(?int $value = null): self { $this->lastAdminReplyAt = $value; + $this->_setField('lastAdminReplyAt'); return $this; } @@ -456,6 +470,7 @@ public function getLastCloseAt(): ?int public function setLastCloseAt(?int $value = null): self { $this->lastCloseAt = $value; + $this->_setField('lastCloseAt'); return $this; } @@ -473,6 +488,7 @@ public function getLastClosedById(): ?string public function setLastClosedById(?string $value = null): self { $this->lastClosedById = $value; + $this->_setField('lastClosedById'); return $this; } @@ -490,6 +506,7 @@ public function getCountReopens(): ?int public function setCountReopens(?int $value = null): self { $this->countReopens = $value; + $this->_setField('countReopens'); return $this; } @@ -507,6 +524,7 @@ public function getCountAssignments(): ?int public function setCountAssignments(?int $value = null): self { $this->countAssignments = $value; + $this->_setField('countAssignments'); return $this; } @@ -524,6 +542,7 @@ public function getCountConversationParts(): ?int public function setCountConversationParts(?int $value = null): self { $this->countConversationParts = $value; + $this->_setField('countConversationParts'); return $this; } @@ -541,6 +560,7 @@ public function getAssignedTeamFirstResponseTimeByTeam(): ?array public function setAssignedTeamFirstResponseTimeByTeam(?array $value = null): self { $this->assignedTeamFirstResponseTimeByTeam = $value; + $this->_setField('assignedTeamFirstResponseTimeByTeam'); return $this; } @@ -558,6 +578,7 @@ public function getAssignedTeamFirstResponseTimeInOfficeHours(): ?array public function setAssignedTeamFirstResponseTimeInOfficeHours(?array $value = null): self { $this->assignedTeamFirstResponseTimeInOfficeHours = $value; + $this->_setField('assignedTeamFirstResponseTimeInOfficeHours'); return $this; } @@ -575,6 +596,7 @@ public function getHandlingTime(): ?int public function setHandlingTime(?int $value = null): self { $this->handlingTime = $value; + $this->_setField('handlingTime'); return $this; } @@ -592,6 +614,7 @@ public function getAdjustedHandlingTime(): ?int public function setAdjustedHandlingTime(?int $value = null): self { $this->adjustedHandlingTime = $value; + $this->_setField('adjustedHandlingTime'); return $this; } diff --git a/src/Types/ConversationTeammates.php b/src/Types/ConversationTeammates.php index b32bab6b..c1bf7381 100644 --- a/src/Types/ConversationTeammates.php +++ b/src/Types/ConversationTeammates.php @@ -50,6 +50,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -67,6 +68,7 @@ public function getAdmins(): array public function setAdmins(array $value): self { $this->admins = $value; + $this->_setField('admins'); return $this; } diff --git a/src/Types/CreateArticleRequest.php b/src/Types/CreateArticleRequest.php index 961087ed..04d03124 100644 --- a/src/Types/CreateArticleRequest.php +++ b/src/Types/CreateArticleRequest.php @@ -97,6 +97,7 @@ public function getTitle(): string public function setTitle(string $value): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -114,6 +115,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -131,6 +133,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -148,6 +151,7 @@ public function getAuthorId(): int public function setAuthorId(int $value): self { $this->authorId = $value; + $this->_setField('authorId'); return $this; } @@ -165,6 +169,7 @@ public function getState(): ?string public function setState(?string $value = null): self { $this->state = $value; + $this->_setField('state'); return $this; } @@ -182,6 +187,7 @@ public function getParentId(): ?int public function setParentId(?int $value = null): self { $this->parentId = $value; + $this->_setField('parentId'); return $this; } @@ -199,6 +205,7 @@ public function getParentType(): ?string public function setParentType(?string $value = null): self { $this->parentType = $value; + $this->_setField('parentType'); return $this; } @@ -216,6 +223,7 @@ public function getTranslatedContent(): ?ArticleTranslatedContent public function setTranslatedContent(?ArticleTranslatedContent $value = null): self { $this->translatedContent = $value; + $this->_setField('translatedContent'); return $this; } diff --git a/src/Types/CreateContactRequestWithEmail.php b/src/Types/CreateContactRequestWithEmail.php index b571d6f1..55e882d0 100644 --- a/src/Types/CreateContactRequestWithEmail.php +++ b/src/Types/CreateContactRequestWithEmail.php @@ -103,6 +103,7 @@ public function getEmail(): string public function setEmail(string $value): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -120,6 +121,7 @@ public function getPhone(): ?string public function setPhone(?string $value = null): self { $this->phone = $value; + $this->_setField('phone'); return $this; } @@ -137,6 +139,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -154,6 +157,7 @@ public function getAvatar(): ?string public function setAvatar(?string $value = null): self { $this->avatar = $value; + $this->_setField('avatar'); return $this; } @@ -171,6 +175,7 @@ public function getSignedUpAt(): ?int public function setSignedUpAt(?int $value = null): self { $this->signedUpAt = $value; + $this->_setField('signedUpAt'); return $this; } @@ -188,6 +193,7 @@ public function getLastSeenAt(): ?int public function setLastSeenAt(?int $value = null): self { $this->lastSeenAt = $value; + $this->_setField('lastSeenAt'); return $this; } @@ -205,6 +211,7 @@ public function getOwnerId(): ?int public function setOwnerId(?int $value = null): self { $this->ownerId = $value; + $this->_setField('ownerId'); return $this; } @@ -222,6 +229,7 @@ public function getUnsubscribedFromEmails(): ?bool public function setUnsubscribedFromEmails(?bool $value = null): self { $this->unsubscribedFromEmails = $value; + $this->_setField('unsubscribedFromEmails'); return $this; } @@ -239,6 +247,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } diff --git a/src/Types/CreateContactRequestWithExternalId.php b/src/Types/CreateContactRequestWithExternalId.php index a57ef29a..34dee324 100644 --- a/src/Types/CreateContactRequestWithExternalId.php +++ b/src/Types/CreateContactRequestWithExternalId.php @@ -103,6 +103,7 @@ public function getExternalId(): string public function setExternalId(string $value): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } @@ -120,6 +121,7 @@ public function getPhone(): ?string public function setPhone(?string $value = null): self { $this->phone = $value; + $this->_setField('phone'); return $this; } @@ -137,6 +139,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -154,6 +157,7 @@ public function getAvatar(): ?string public function setAvatar(?string $value = null): self { $this->avatar = $value; + $this->_setField('avatar'); return $this; } @@ -171,6 +175,7 @@ public function getSignedUpAt(): ?int public function setSignedUpAt(?int $value = null): self { $this->signedUpAt = $value; + $this->_setField('signedUpAt'); return $this; } @@ -188,6 +193,7 @@ public function getLastSeenAt(): ?int public function setLastSeenAt(?int $value = null): self { $this->lastSeenAt = $value; + $this->_setField('lastSeenAt'); return $this; } @@ -205,6 +211,7 @@ public function getOwnerId(): ?int public function setOwnerId(?int $value = null): self { $this->ownerId = $value; + $this->_setField('ownerId'); return $this; } @@ -222,6 +229,7 @@ public function getUnsubscribedFromEmails(): ?bool public function setUnsubscribedFromEmails(?bool $value = null): self { $this->unsubscribedFromEmails = $value; + $this->_setField('unsubscribedFromEmails'); return $this; } @@ -239,6 +247,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } diff --git a/src/Types/CreateContactRequestWithRole.php b/src/Types/CreateContactRequestWithRole.php index 5d7c6e52..99308f35 100644 --- a/src/Types/CreateContactRequestWithRole.php +++ b/src/Types/CreateContactRequestWithRole.php @@ -103,6 +103,7 @@ public function getRole(): string public function setRole(string $value): self { $this->role = $value; + $this->_setField('role'); return $this; } @@ -120,6 +121,7 @@ public function getPhone(): ?string public function setPhone(?string $value = null): self { $this->phone = $value; + $this->_setField('phone'); return $this; } @@ -137,6 +139,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -154,6 +157,7 @@ public function getAvatar(): ?string public function setAvatar(?string $value = null): self { $this->avatar = $value; + $this->_setField('avatar'); return $this; } @@ -171,6 +175,7 @@ public function getSignedUpAt(): ?int public function setSignedUpAt(?int $value = null): self { $this->signedUpAt = $value; + $this->_setField('signedUpAt'); return $this; } @@ -188,6 +193,7 @@ public function getLastSeenAt(): ?int public function setLastSeenAt(?int $value = null): self { $this->lastSeenAt = $value; + $this->_setField('lastSeenAt'); return $this; } @@ -205,6 +211,7 @@ public function getOwnerId(): ?int public function setOwnerId(?int $value = null): self { $this->ownerId = $value; + $this->_setField('ownerId'); return $this; } @@ -222,6 +229,7 @@ public function getUnsubscribedFromEmails(): ?bool public function setUnsubscribedFromEmails(?bool $value = null): self { $this->unsubscribedFromEmails = $value; + $this->_setField('unsubscribedFromEmails'); return $this; } @@ -239,6 +247,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } diff --git a/src/Types/CreateDataAttributeRequestModel.php b/src/Types/CreateDataAttributeRequestModel.php new file mode 100644 index 00000000..6bbcae5a --- /dev/null +++ b/src/Types/CreateDataAttributeRequestModel.php @@ -0,0 +1,9 @@ +dataType = $value; + $this->_setField('dataType'); return $this; } diff --git a/src/Types/CreateDataAttributeRequestOptions.php b/src/Types/CreateDataAttributeRequestOptions.php index d0e9e1c4..ea6479c9 100644 --- a/src/Types/CreateDataAttributeRequestOptions.php +++ b/src/Types/CreateDataAttributeRequestOptions.php @@ -47,6 +47,7 @@ public function getDataType(): ?string public function setDataType(?string $value = null): self { $this->dataType = $value; + $this->_setField('dataType'); return $this; } @@ -64,6 +65,7 @@ public function getOptions(): array public function setOptions(array $value): self { $this->options = $value; + $this->_setField('options'); return $this; } diff --git a/src/Types/CreateDataAttributeRequestOptionsOptionsItem.php b/src/Types/CreateDataAttributeRequestOptionsOptionsItem.php index 3d04ffbb..46ac3c51 100644 --- a/src/Types/CreateDataAttributeRequestOptionsOptionsItem.php +++ b/src/Types/CreateDataAttributeRequestOptionsOptionsItem.php @@ -38,6 +38,7 @@ public function getValue(): ?string public function setValue(?string $value = null): self { $this->value = $value; + $this->_setField('value'); return $this; } diff --git a/src/Types/CreateDataEventRequestWithEmail.php b/src/Types/CreateDataEventRequestWithEmail.php index 6036c4ce..80754350 100644 --- a/src/Types/CreateDataEventRequestWithEmail.php +++ b/src/Types/CreateDataEventRequestWithEmail.php @@ -63,6 +63,7 @@ public function getEmail(): string public function setEmail(string $value): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -80,6 +81,7 @@ public function getEventName(): string public function setEventName(string $value): self { $this->eventName = $value; + $this->_setField('eventName'); return $this; } @@ -97,6 +99,7 @@ public function getCreatedAt(): int public function setCreatedAt(int $value): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -114,6 +117,7 @@ public function getMetadata(): ?array public function setMetadata(?array $value = null): self { $this->metadata = $value; + $this->_setField('metadata'); return $this; } diff --git a/src/Types/CreateDataEventRequestWithId.php b/src/Types/CreateDataEventRequestWithId.php index 413a048f..acb8652b 100644 --- a/src/Types/CreateDataEventRequestWithId.php +++ b/src/Types/CreateDataEventRequestWithId.php @@ -63,6 +63,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -80,6 +81,7 @@ public function getEventName(): string public function setEventName(string $value): self { $this->eventName = $value; + $this->_setField('eventName'); return $this; } @@ -97,6 +99,7 @@ public function getCreatedAt(): int public function setCreatedAt(int $value): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -114,6 +117,7 @@ public function getMetadata(): ?array public function setMetadata(?array $value = null): self { $this->metadata = $value; + $this->_setField('metadata'); return $this; } diff --git a/src/Types/CreateDataEventRequestWithUserId.php b/src/Types/CreateDataEventRequestWithUserId.php index 291442ef..39ea44aa 100644 --- a/src/Types/CreateDataEventRequestWithUserId.php +++ b/src/Types/CreateDataEventRequestWithUserId.php @@ -63,6 +63,7 @@ public function getUserId(): string public function setUserId(string $value): self { $this->userId = $value; + $this->_setField('userId'); return $this; } @@ -80,6 +81,7 @@ public function getEventName(): string public function setEventName(string $value): self { $this->eventName = $value; + $this->_setField('eventName'); return $this; } @@ -97,6 +99,7 @@ public function getCreatedAt(): int public function setCreatedAt(int $value): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -114,6 +117,7 @@ public function getMetadata(): ?array public function setMetadata(?array $value = null): self { $this->metadata = $value; + $this->_setField('metadata'); return $this; } diff --git a/src/Types/CreateInternalArticleRequest.php b/src/Types/CreateInternalArticleRequest.php index 7bf82db7..de2cb28b 100644 --- a/src/Types/CreateInternalArticleRequest.php +++ b/src/Types/CreateInternalArticleRequest.php @@ -65,6 +65,7 @@ public function getTitle(): string public function setTitle(string $value): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -82,6 +83,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -99,6 +101,7 @@ public function getAuthorId(): int public function setAuthorId(int $value): self { $this->authorId = $value; + $this->_setField('authorId'); return $this; } @@ -116,6 +119,7 @@ public function getOwnerId(): int public function setOwnerId(int $value): self { $this->ownerId = $value; + $this->_setField('ownerId'); return $this; } diff --git a/src/Types/CreateMessageRequest.php b/src/Types/CreateMessageRequest.php index 7bc95ec3..0df827a7 100644 --- a/src/Types/CreateMessageRequest.php +++ b/src/Types/CreateMessageRequest.php @@ -4,7 +4,6 @@ use Intercom\Core\Json\JsonSerializableType; use Exception; -use Intercom\Core\Json\JsonDecoder; /** * You can create a message @@ -186,18 +185,6 @@ public function jsonSerialize(): array 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 */ diff --git a/src/Types/CreateMessageRequestFrom.php b/src/Types/CreateMessageRequestFrom.php index 05c1c1da..356833c0 100644 --- a/src/Types/CreateMessageRequestFrom.php +++ b/src/Types/CreateMessageRequestFrom.php @@ -49,6 +49,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -66,6 +67,7 @@ public function getId(): int public function setId(int $value): self { $this->id = $value; + $this->_setField('id'); return $this; } diff --git a/src/Types/CreateMessageRequestTo.php b/src/Types/CreateMessageRequestTo.php index 9bf4146d..2d6e9cde 100644 --- a/src/Types/CreateMessageRequestTo.php +++ b/src/Types/CreateMessageRequestTo.php @@ -49,6 +49,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -66,6 +67,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } diff --git a/src/Types/CreateMessageRequestWithEmail.php b/src/Types/CreateMessageRequestWithEmail.php index d2ece0df..c516f2a1 100644 --- a/src/Types/CreateMessageRequestWithEmail.php +++ b/src/Types/CreateMessageRequestWithEmail.php @@ -86,6 +86,7 @@ public function getSubject(): string public function setSubject(string $value): self { $this->subject = $value; + $this->_setField('subject'); return $this; } @@ -103,6 +104,7 @@ public function getBody(): string public function setBody(string $value): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -120,6 +122,7 @@ public function getTemplate(): string public function setTemplate(string $value): self { $this->template = $value; + $this->_setField('template'); return $this; } @@ -137,6 +140,7 @@ public function getFrom(): CreateMessageRequestFrom public function setFrom(CreateMessageRequestFrom $value): self { $this->from = $value; + $this->_setField('from'); return $this; } @@ -154,6 +158,7 @@ public function getTo(): CreateMessageRequestTo public function setTo(CreateMessageRequestTo $value): self { $this->to = $value; + $this->_setField('to'); return $this; } @@ -171,6 +176,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -188,6 +194,7 @@ public function getCreateConversationWithoutContactReply(): ?bool public function setCreateConversationWithoutContactReply(?bool $value = null): self { $this->createConversationWithoutContactReply = $value; + $this->_setField('createConversationWithoutContactReply'); return $this; } diff --git a/src/Types/CreateMessageRequestWithInapp.php b/src/Types/CreateMessageRequestWithInapp.php index 23a0dcc4..b3f34ff4 100644 --- a/src/Types/CreateMessageRequestWithInapp.php +++ b/src/Types/CreateMessageRequestWithInapp.php @@ -86,6 +86,7 @@ public function getSubject(): ?string public function setSubject(?string $value = null): self { $this->subject = $value; + $this->_setField('subject'); return $this; } @@ -103,6 +104,7 @@ public function getBody(): string public function setBody(string $value): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -120,6 +122,7 @@ public function getTemplate(): ?string public function setTemplate(?string $value = null): self { $this->template = $value; + $this->_setField('template'); return $this; } @@ -137,6 +140,7 @@ public function getFrom(): CreateMessageRequestFrom public function setFrom(CreateMessageRequestFrom $value): self { $this->from = $value; + $this->_setField('from'); return $this; } @@ -154,6 +158,7 @@ public function getTo(): CreateMessageRequestTo public function setTo(CreateMessageRequestTo $value): self { $this->to = $value; + $this->_setField('to'); return $this; } @@ -171,6 +176,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -188,6 +194,7 @@ public function getCreateConversationWithoutContactReply(): ?bool public function setCreateConversationWithoutContactReply(?bool $value = null): self { $this->createConversationWithoutContactReply = $value; + $this->_setField('createConversationWithoutContactReply'); return $this; } diff --git a/src/Types/CreateOrUpdateCompanyRequest.php b/src/Types/CreateOrUpdateCompanyRequest.php index c7674a12..11087385 100644 --- a/src/Types/CreateOrUpdateCompanyRequest.php +++ b/src/Types/CreateOrUpdateCompanyRequest.php @@ -106,6 +106,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -123,6 +124,7 @@ public function getCompanyId(): ?string public function setCompanyId(?string $value = null): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } @@ -140,6 +142,7 @@ public function getPlan(): ?string public function setPlan(?string $value = null): self { $this->plan = $value; + $this->_setField('plan'); return $this; } @@ -157,6 +160,7 @@ public function getSize(): ?int public function setSize(?int $value = null): self { $this->size = $value; + $this->_setField('size'); return $this; } @@ -174,6 +178,7 @@ public function getWebsite(): ?string public function setWebsite(?string $value = null): self { $this->website = $value; + $this->_setField('website'); return $this; } @@ -191,6 +196,7 @@ public function getIndustry(): ?string public function setIndustry(?string $value = null): self { $this->industry = $value; + $this->_setField('industry'); return $this; } @@ -208,6 +214,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } @@ -225,6 +232,7 @@ public function getRemoteCreatedAt(): ?int public function setRemoteCreatedAt(?int $value = null): self { $this->remoteCreatedAt = $value; + $this->_setField('remoteCreatedAt'); return $this; } @@ -242,6 +250,7 @@ public function getMonthlySpend(): ?int public function setMonthlySpend(?int $value = null): self { $this->monthlySpend = $value; + $this->_setField('monthlySpend'); return $this; } diff --git a/src/Types/CreateOrUpdateTagRequest.php b/src/Types/CreateOrUpdateTagRequest.php index 72556e8e..45a00b6d 100644 --- a/src/Types/CreateOrUpdateTagRequest.php +++ b/src/Types/CreateOrUpdateTagRequest.php @@ -49,6 +49,7 @@ public function getName(): string public function setName(string $value): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -66,6 +67,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } diff --git a/src/Types/CreatePhoneSwitchRequest.php b/src/Types/CreatePhoneSwitchRequest.php index 7c09f24b..e5504e5e 100644 --- a/src/Types/CreatePhoneSwitchRequest.php +++ b/src/Types/CreatePhoneSwitchRequest.php @@ -62,6 +62,7 @@ public function getPhone(): string public function setPhone(string $value): self { $this->phone = $value; + $this->_setField('phone'); return $this; } @@ -89,6 +90,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } diff --git a/src/Types/CreateTicketRequestBody.php b/src/Types/CreateTicketRequestBody.php index 5096f35d..b2648071 100644 --- a/src/Types/CreateTicketRequestBody.php +++ b/src/Types/CreateTicketRequestBody.php @@ -20,12 +20,12 @@ class CreateTicketRequestBody extends JsonSerializableType /** * @var array<( - * CreateTicketRequestContactsItemId - * |CreateTicketRequestContactsItemExternalId - * |CreateTicketRequestContactsItemEmail + * CreateTicketRequestBodyContactsItemId + * |CreateTicketRequestBodyContactsItemExternalId + * |CreateTicketRequestBodyContactsItemEmail * )> $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)])] + #[JsonProperty('contacts'), ArrayType([new Union(CreateTicketRequestBodyContactsItemId::class, CreateTicketRequestBodyContactsItemExternalId::class, CreateTicketRequestBodyContactsItemEmail::class)])] private array $contacts; /** @@ -53,23 +53,23 @@ class CreateTicketRequestBody extends JsonSerializableType private ?int $createdAt; /** - * @var ?CreateTicketRequestAssignment $assignment + * @var ?CreateTicketRequestBodyAssignment $assignment */ #[JsonProperty('assignment')] - private ?CreateTicketRequestAssignment $assignment; + private ?CreateTicketRequestBodyAssignment $assignment; /** * @param array{ * ticketTypeId: string, * contacts: array<( - * CreateTicketRequestContactsItemId - * |CreateTicketRequestContactsItemExternalId - * |CreateTicketRequestContactsItemEmail + * CreateTicketRequestBodyContactsItemId + * |CreateTicketRequestBodyContactsItemExternalId + * |CreateTicketRequestBodyContactsItemEmail * )>, * conversationToLinkId?: ?string, * companyId?: ?string, * createdAt?: ?int, - * assignment?: ?CreateTicketRequestAssignment, + * assignment?: ?CreateTicketRequestBodyAssignment, * } $values */ public function __construct( @@ -97,14 +97,15 @@ public function getTicketTypeId(): string public function setTicketTypeId(string $value): self { $this->ticketTypeId = $value; + $this->_setField('ticketTypeId'); return $this; } /** * @return array<( - * CreateTicketRequestContactsItemId - * |CreateTicketRequestContactsItemExternalId - * |CreateTicketRequestContactsItemEmail + * CreateTicketRequestBodyContactsItemId + * |CreateTicketRequestBodyContactsItemExternalId + * |CreateTicketRequestBodyContactsItemEmail * )> */ public function getContacts(): array @@ -114,14 +115,15 @@ public function getContacts(): array /** * @param array<( - * CreateTicketRequestContactsItemId - * |CreateTicketRequestContactsItemExternalId - * |CreateTicketRequestContactsItemEmail + * CreateTicketRequestBodyContactsItemId + * |CreateTicketRequestBodyContactsItemExternalId + * |CreateTicketRequestBodyContactsItemEmail * )> $value */ public function setContacts(array $value): self { $this->contacts = $value; + $this->_setField('contacts'); return $this; } @@ -139,6 +141,7 @@ public function getConversationToLinkId(): ?string public function setConversationToLinkId(?string $value = null): self { $this->conversationToLinkId = $value; + $this->_setField('conversationToLinkId'); return $this; } @@ -156,6 +159,7 @@ public function getCompanyId(): ?string public function setCompanyId(?string $value = null): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } @@ -173,23 +177,25 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } /** - * @return ?CreateTicketRequestAssignment + * @return ?CreateTicketRequestBodyAssignment */ - public function getAssignment(): ?CreateTicketRequestAssignment + public function getAssignment(): ?CreateTicketRequestBodyAssignment { return $this->assignment; } /** - * @param ?CreateTicketRequestAssignment $value + * @param ?CreateTicketRequestBodyAssignment $value */ - public function setAssignment(?CreateTicketRequestAssignment $value = null): self + public function setAssignment(?CreateTicketRequestBodyAssignment $value = null): self { $this->assignment = $value; + $this->_setField('assignment'); return $this; } diff --git a/src/Types/CreateTicketRequestAssignment.php b/src/Types/CreateTicketRequestBodyAssignment.php similarity index 91% rename from src/Types/CreateTicketRequestAssignment.php rename to src/Types/CreateTicketRequestBodyAssignment.php index 05ab9729..0a5f4adc 100644 --- a/src/Types/CreateTicketRequestAssignment.php +++ b/src/Types/CreateTicketRequestBodyAssignment.php @@ -5,7 +5,7 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; -class CreateTicketRequestAssignment extends JsonSerializableType +class CreateTicketRequestBodyAssignment extends JsonSerializableType { /** * @var ?string $adminAssigneeId The ID of the admin to which the ticket is assigned. If not provided, the ticket will be unassigned. @@ -46,6 +46,7 @@ public function getAdminAssigneeId(): ?string public function setAdminAssigneeId(?string $value = null): self { $this->adminAssigneeId = $value; + $this->_setField('adminAssigneeId'); return $this; } @@ -63,6 +64,7 @@ public function getTeamAssigneeId(): ?string public function setTeamAssigneeId(?string $value = null): self { $this->teamAssigneeId = $value; + $this->_setField('teamAssigneeId'); return $this; } diff --git a/src/Types/CreateTicketRequestContactsItemEmail.php b/src/Types/CreateTicketRequestBodyContactsItemEmail.php similarity index 89% rename from src/Types/CreateTicketRequestContactsItemEmail.php rename to src/Types/CreateTicketRequestBodyContactsItemEmail.php index 7e6774aa..bf5155f2 100644 --- a/src/Types/CreateTicketRequestContactsItemEmail.php +++ b/src/Types/CreateTicketRequestBodyContactsItemEmail.php @@ -5,7 +5,7 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; -class CreateTicketRequestContactsItemEmail extends JsonSerializableType +class CreateTicketRequestBodyContactsItemEmail extends JsonSerializableType { /** * @var string $email The email you have defined for the contact who is being added as a participant. If a contact with this email does not exist, one will be created. @@ -38,6 +38,7 @@ public function getEmail(): string public function setEmail(string $value): self { $this->email = $value; + $this->_setField('email'); return $this; } diff --git a/src/Types/CreateTicketRequestContactsItemExternalId.php b/src/Types/CreateTicketRequestBodyContactsItemExternalId.php similarity index 88% rename from src/Types/CreateTicketRequestContactsItemExternalId.php rename to src/Types/CreateTicketRequestBodyContactsItemExternalId.php index 159807f5..b822490c 100644 --- a/src/Types/CreateTicketRequestContactsItemExternalId.php +++ b/src/Types/CreateTicketRequestBodyContactsItemExternalId.php @@ -5,7 +5,7 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; -class CreateTicketRequestContactsItemExternalId extends JsonSerializableType +class CreateTicketRequestBodyContactsItemExternalId extends JsonSerializableType { /** * @var string $externalId The external_id you have defined for the contact who is being added as a participant. @@ -38,6 +38,7 @@ public function getExternalId(): string public function setExternalId(string $value): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } diff --git a/src/Types/CreateTicketRequestContactsItemId.php b/src/Types/CreateTicketRequestBodyContactsItemId.php similarity index 88% rename from src/Types/CreateTicketRequestContactsItemId.php rename to src/Types/CreateTicketRequestBodyContactsItemId.php index d205be5e..68397710 100644 --- a/src/Types/CreateTicketRequestContactsItemId.php +++ b/src/Types/CreateTicketRequestBodyContactsItemId.php @@ -5,7 +5,7 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; -class CreateTicketRequestContactsItemId extends JsonSerializableType +class CreateTicketRequestBodyContactsItemId extends JsonSerializableType { /** * @var string $id The identifier for the contact as given by Intercom. @@ -38,6 +38,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } diff --git a/src/Types/CreateTicketTypeRequest.php b/src/Types/CreateTicketTypeRequest.php index 361103d8..c880e53d 100644 --- a/src/Types/CreateTicketTypeRequest.php +++ b/src/Types/CreateTicketTypeRequest.php @@ -74,6 +74,7 @@ public function getName(): string public function setName(string $value): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -91,6 +92,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -108,6 +110,7 @@ public function getCategory(): ?string public function setCategory(?string $value = null): self { $this->category = $value; + $this->_setField('category'); return $this; } @@ -125,6 +128,7 @@ public function getIcon(): ?string public function setIcon(?string $value = null): self { $this->icon = $value; + $this->_setField('icon'); return $this; } @@ -142,6 +146,7 @@ public function getIsInternal(): ?bool public function setIsInternal(?bool $value = null): self { $this->isInternal = $value; + $this->_setField('isInternal'); return $this; } diff --git a/src/Types/CursorPages.php b/src/Types/CursorPages.php index d045236f..fd84432a 100644 --- a/src/Types/CursorPages.php +++ b/src/Types/CursorPages.php @@ -74,6 +74,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -91,6 +92,7 @@ public function getPage(): ?int public function setPage(?int $value = null): self { $this->page = $value; + $this->_setField('page'); return $this; } @@ -108,6 +110,7 @@ public function getNext(): ?StartingAfterPaging public function setNext(?StartingAfterPaging $value = null): self { $this->next = $value; + $this->_setField('next'); return $this; } @@ -125,6 +128,7 @@ public function getPerPage(): ?int public function setPerPage(?int $value = null): self { $this->perPage = $value; + $this->_setField('perPage'); return $this; } @@ -142,6 +146,7 @@ public function getTotalPages(): ?int public function setTotalPages(?int $value = null): self { $this->totalPages = $value; + $this->_setField('totalPages'); return $this; } diff --git a/src/Types/CustomActionFinished.php b/src/Types/CustomActionFinished.php index ae6bb947..049339cb 100644 --- a/src/Types/CustomActionFinished.php +++ b/src/Types/CustomActionFinished.php @@ -41,6 +41,7 @@ public function getAction(): ?CustomActionFinishedAction public function setAction(?CustomActionFinishedAction $value = null): self { $this->action = $value; + $this->_setField('action'); return $this; } diff --git a/src/Types/CustomActionFinishedAction.php b/src/Types/CustomActionFinishedAction.php index ed047125..33f5b4b0 100644 --- a/src/Types/CustomActionFinishedAction.php +++ b/src/Types/CustomActionFinishedAction.php @@ -46,6 +46,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -63,6 +64,7 @@ public function getResult(): ?string public function setResult(?string $value = null): self { $this->result = $value; + $this->_setField('result'); return $this; } diff --git a/src/Types/CustomActionStarted.php b/src/Types/CustomActionStarted.php index 993127cc..e29f8fff 100644 --- a/src/Types/CustomActionStarted.php +++ b/src/Types/CustomActionStarted.php @@ -41,6 +41,7 @@ public function getAction(): ?CustomActionStartedAction public function setAction(?CustomActionStartedAction $value = null): self { $this->action = $value; + $this->_setField('action'); return $this; } diff --git a/src/Types/CustomActionStartedAction.php b/src/Types/CustomActionStartedAction.php index 024b4e0f..9a38b279 100644 --- a/src/Types/CustomActionStartedAction.php +++ b/src/Types/CustomActionStartedAction.php @@ -38,6 +38,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } diff --git a/src/Types/CustomChannelAttribute.php b/src/Types/CustomChannelAttribute.php index 3376c63c..07489373 100644 --- a/src/Types/CustomChannelAttribute.php +++ b/src/Types/CustomChannelAttribute.php @@ -46,6 +46,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -63,6 +64,7 @@ public function getValue(): string public function setValue(string $value): self { $this->value = $value; + $this->_setField('value'); return $this; } diff --git a/src/Types/CustomChannelBaseEvent.php b/src/Types/CustomChannelBaseEvent.php index c1eed943..8005fa36 100644 --- a/src/Types/CustomChannelBaseEvent.php +++ b/src/Types/CustomChannelBaseEvent.php @@ -54,6 +54,7 @@ public function getEventId(): string public function setEventId(string $value): self { $this->eventId = $value; + $this->_setField('eventId'); return $this; } @@ -71,6 +72,7 @@ public function getExternalConversationId(): string public function setExternalConversationId(string $value): self { $this->externalConversationId = $value; + $this->_setField('externalConversationId'); return $this; } @@ -88,6 +90,7 @@ public function getContact(): CustomChannelContact public function setContact(CustomChannelContact $value): self { $this->contact = $value; + $this->_setField('contact'); return $this; } diff --git a/src/Types/CustomChannelContact.php b/src/Types/CustomChannelContact.php index 35cc7274..5fecafba 100644 --- a/src/Types/CustomChannelContact.php +++ b/src/Types/CustomChannelContact.php @@ -62,6 +62,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -79,6 +80,7 @@ public function getExternalId(): string public function setExternalId(string $value): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } @@ -96,6 +98,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -113,6 +116,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } diff --git a/src/Types/CustomChannelNotificationResponse.php b/src/Types/CustomChannelNotificationResponse.php index 96b9fde9..5dd67ae6 100644 --- a/src/Types/CustomChannelNotificationResponse.php +++ b/src/Types/CustomChannelNotificationResponse.php @@ -62,6 +62,7 @@ public function getExternalConversationId(): string public function setExternalConversationId(string $value): self { $this->externalConversationId = $value; + $this->_setField('externalConversationId'); return $this; } @@ -79,6 +80,7 @@ public function getConversationId(): string public function setConversationId(string $value): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } @@ -96,6 +98,7 @@ public function getExternalContactId(): string public function setExternalContactId(string $value): self { $this->externalContactId = $value; + $this->_setField('externalContactId'); return $this; } @@ -113,6 +116,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } diff --git a/src/Types/CustomObjectInstanceDeleted.php b/src/Types/CustomObjectInstanceDeleted.php index 1554f219..c8f1b194 100644 --- a/src/Types/CustomObjectInstanceDeleted.php +++ b/src/Types/CustomObjectInstanceDeleted.php @@ -57,6 +57,7 @@ public function getObject(): ?string public function setObject(?string $value = null): self { $this->object = $value; + $this->_setField('object'); return $this; } @@ -74,6 +75,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -91,6 +93,7 @@ public function getDeleted(): ?bool public function setDeleted(?bool $value = null): self { $this->deleted = $value; + $this->_setField('deleted'); return $this; } diff --git a/src/Types/CustomObjectInstanceList.php b/src/Types/CustomObjectInstanceList.php index c4d69582..b6c5652b 100644 --- a/src/Types/CustomObjectInstanceList.php +++ b/src/Types/CustomObjectInstanceList.php @@ -52,6 +52,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -69,6 +70,7 @@ public function getInstances(): ?array public function setInstances(?array $value = null): self { $this->instances = $value; + $this->_setField('instances'); return $this; } diff --git a/src/Types/CustomerRequestEmail.php b/src/Types/CustomerRequestEmail.php index e40b94f4..cdc29ecb 100644 --- a/src/Types/CustomerRequestEmail.php +++ b/src/Types/CustomerRequestEmail.php @@ -38,6 +38,7 @@ public function getEmail(): string public function setEmail(string $value): self { $this->email = $value; + $this->_setField('email'); return $this; } diff --git a/src/Types/CustomerRequestIntercomUserId.php b/src/Types/CustomerRequestIntercomUserId.php index 96867408..5b6f027c 100644 --- a/src/Types/CustomerRequestIntercomUserId.php +++ b/src/Types/CustomerRequestIntercomUserId.php @@ -38,6 +38,7 @@ public function getIntercomUserId(): string public function setIntercomUserId(string $value): self { $this->intercomUserId = $value; + $this->_setField('intercomUserId'); return $this; } diff --git a/src/Types/CustomerRequestUserId.php b/src/Types/CustomerRequestUserId.php index 79f3bfe5..927c28c6 100644 --- a/src/Types/CustomerRequestUserId.php +++ b/src/Types/CustomerRequestUserId.php @@ -38,6 +38,7 @@ public function getUserId(): string public function setUserId(string $value): self { $this->userId = $value; + $this->_setField('userId'); return $this; } diff --git a/src/Types/DataAttributeList.php b/src/Types/DataAttributeList.php index 8169b217..baa19c5a 100644 --- a/src/Types/DataAttributeList.php +++ b/src/Types/DataAttributeList.php @@ -51,6 +51,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -68,6 +69,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Types/DataEventList.php b/src/Types/DataEventList.php index 6e1202e0..ac7f5455 100644 --- a/src/Types/DataEventList.php +++ b/src/Types/DataEventList.php @@ -59,6 +59,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -76,6 +77,7 @@ public function getEvents(): ?array public function setEvents(?array $value = null): self { $this->events = $value; + $this->_setField('events'); return $this; } @@ -93,6 +95,7 @@ public function getPages(): ?DataEventListPages public function setPages(?DataEventListPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } diff --git a/src/Types/DataEventListPages.php b/src/Types/DataEventListPages.php index b4df1f94..97b1976a 100644 --- a/src/Types/DataEventListPages.php +++ b/src/Types/DataEventListPages.php @@ -49,6 +49,7 @@ public function getNext(): ?string public function setNext(?string $value = null): self { $this->next = $value; + $this->_setField('next'); return $this; } @@ -66,6 +67,7 @@ public function getSince(): ?string public function setSince(?string $value = null): self { $this->since = $value; + $this->_setField('since'); return $this; } diff --git a/src/Types/DataEventSummary.php b/src/Types/DataEventSummary.php index 9923e70e..143a49d5 100644 --- a/src/Types/DataEventSummary.php +++ b/src/Types/DataEventSummary.php @@ -75,6 +75,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -92,6 +93,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -109,6 +111,7 @@ public function getIntercomUserId(): ?string public function setIntercomUserId(?string $value = null): self { $this->intercomUserId = $value; + $this->_setField('intercomUserId'); return $this; } @@ -126,6 +129,7 @@ public function getUserId(): ?string public function setUserId(?string $value = null): self { $this->userId = $value; + $this->_setField('userId'); return $this; } @@ -143,6 +147,7 @@ public function getEvents(): array public function setEvents(array $value): self { $this->events = $value; + $this->_setField('events'); return $this; } diff --git a/src/Types/DataEventSummaryItem.php b/src/Types/DataEventSummaryItem.php index 6cc3ce29..cb80086e 100644 --- a/src/Types/DataEventSummaryItem.php +++ b/src/Types/DataEventSummaryItem.php @@ -73,6 +73,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -90,6 +91,7 @@ public function getFirst(): ?string public function setFirst(?string $value = null): self { $this->first = $value; + $this->_setField('first'); return $this; } @@ -107,6 +109,7 @@ public function getLast(): ?string public function setLast(?string $value = null): self { $this->last = $value; + $this->_setField('last'); return $this; } @@ -124,6 +127,7 @@ public function getCount(): ?int public function setCount(?int $value = null): self { $this->count = $value; + $this->_setField('count'); return $this; } @@ -141,6 +145,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } diff --git a/src/Types/DataExportCsv.php b/src/Types/DataExportCsv.php index a424c1e1..600a9b59 100644 --- a/src/Types/DataExportCsv.php +++ b/src/Types/DataExportCsv.php @@ -241,6 +241,7 @@ public function getUserId(): ?string public function setUserId(?string $value = null): self { $this->userId = $value; + $this->_setField('userId'); return $this; } @@ -258,6 +259,7 @@ public function getUserExternalId(): ?string public function setUserExternalId(?string $value = null): self { $this->userExternalId = $value; + $this->_setField('userExternalId'); return $this; } @@ -275,6 +277,7 @@ public function getCompanyId(): ?string public function setCompanyId(?string $value = null): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } @@ -292,6 +295,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -309,6 +313,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -326,6 +331,7 @@ public function getRulesetId(): ?string public function setRulesetId(?string $value = null): self { $this->rulesetId = $value; + $this->_setField('rulesetId'); return $this; } @@ -343,6 +349,7 @@ public function getContentId(): ?string public function setContentId(?string $value = null): self { $this->contentId = $value; + $this->_setField('contentId'); return $this; } @@ -360,6 +367,7 @@ public function getContentType(): ?string public function setContentType(?string $value = null): self { $this->contentType = $value; + $this->_setField('contentType'); return $this; } @@ -377,6 +385,7 @@ public function getContentTitle(): ?string public function setContentTitle(?string $value = null): self { $this->contentTitle = $value; + $this->_setField('contentTitle'); return $this; } @@ -394,6 +403,7 @@ public function getRulesetVersionId(): ?string public function setRulesetVersionId(?string $value = null): self { $this->rulesetVersionId = $value; + $this->_setField('rulesetVersionId'); return $this; } @@ -411,6 +421,7 @@ public function getReceiptId(): ?string public function setReceiptId(?string $value = null): self { $this->receiptId = $value; + $this->_setField('receiptId'); return $this; } @@ -428,6 +439,7 @@ public function getReceivedAt(): ?int public function setReceivedAt(?int $value = null): self { $this->receivedAt = $value; + $this->_setField('receivedAt'); return $this; } @@ -445,6 +457,7 @@ public function getSeriesId(): ?string public function setSeriesId(?string $value = null): self { $this->seriesId = $value; + $this->_setField('seriesId'); return $this; } @@ -462,6 +475,7 @@ public function getSeriesTitle(): ?string public function setSeriesTitle(?string $value = null): self { $this->seriesTitle = $value; + $this->_setField('seriesTitle'); return $this; } @@ -479,6 +493,7 @@ public function getNodeId(): ?string public function setNodeId(?string $value = null): self { $this->nodeId = $value; + $this->_setField('nodeId'); return $this; } @@ -496,6 +511,7 @@ public function getFirstReply(): ?int public function setFirstReply(?int $value = null): self { $this->firstReply = $value; + $this->_setField('firstReply'); return $this; } @@ -513,6 +529,7 @@ public function getFirstCompletion(): ?int public function setFirstCompletion(?int $value = null): self { $this->firstCompletion = $value; + $this->_setField('firstCompletion'); return $this; } @@ -530,6 +547,7 @@ public function getFirstSeriesCompletion(): ?int public function setFirstSeriesCompletion(?int $value = null): self { $this->firstSeriesCompletion = $value; + $this->_setField('firstSeriesCompletion'); return $this; } @@ -547,6 +565,7 @@ public function getFirstSeriesDisengagement(): ?int public function setFirstSeriesDisengagement(?int $value = null): self { $this->firstSeriesDisengagement = $value; + $this->_setField('firstSeriesDisengagement'); return $this; } @@ -564,6 +583,7 @@ public function getFirstSeriesExit(): ?int public function setFirstSeriesExit(?int $value = null): self { $this->firstSeriesExit = $value; + $this->_setField('firstSeriesExit'); return $this; } @@ -581,6 +601,7 @@ public function getFirstGoalSuccess(): ?int public function setFirstGoalSuccess(?int $value = null): self { $this->firstGoalSuccess = $value; + $this->_setField('firstGoalSuccess'); return $this; } @@ -598,6 +619,7 @@ public function getFirstOpen(): ?int public function setFirstOpen(?int $value = null): self { $this->firstOpen = $value; + $this->_setField('firstOpen'); return $this; } @@ -615,6 +637,7 @@ public function getFirstClick(): ?int public function setFirstClick(?int $value = null): self { $this->firstClick = $value; + $this->_setField('firstClick'); return $this; } @@ -632,6 +655,7 @@ public function getFirstDismisall(): ?int public function setFirstDismisall(?int $value = null): self { $this->firstDismisall = $value; + $this->_setField('firstDismisall'); return $this; } @@ -649,6 +673,7 @@ public function getFirstUnsubscribe(): ?int public function setFirstUnsubscribe(?int $value = null): self { $this->firstUnsubscribe = $value; + $this->_setField('firstUnsubscribe'); return $this; } @@ -666,6 +691,7 @@ public function getFirstHardBounce(): ?int public function setFirstHardBounce(?int $value = null): self { $this->firstHardBounce = $value; + $this->_setField('firstHardBounce'); return $this; } diff --git a/src/Types/DeletedArticleObject.php b/src/Types/DeletedArticleObject.php index e0eaac4c..682e9638 100644 --- a/src/Types/DeletedArticleObject.php +++ b/src/Types/DeletedArticleObject.php @@ -57,6 +57,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -74,6 +75,7 @@ public function getObject(): ?string public function setObject(?string $value = null): self { $this->object = $value; + $this->_setField('object'); return $this; } @@ -91,6 +93,7 @@ public function getDeleted(): ?bool public function setDeleted(?bool $value = null): self { $this->deleted = $value; + $this->_setField('deleted'); return $this; } diff --git a/src/Types/DeletedCollectionObject.php b/src/Types/DeletedCollectionObject.php index 2c538a78..09be7aca 100644 --- a/src/Types/DeletedCollectionObject.php +++ b/src/Types/DeletedCollectionObject.php @@ -57,6 +57,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -74,6 +75,7 @@ public function getObject(): ?string public function setObject(?string $value = null): self { $this->object = $value; + $this->_setField('object'); return $this; } @@ -91,6 +93,7 @@ public function getDeleted(): ?bool public function setDeleted(?bool $value = null): self { $this->deleted = $value; + $this->_setField('deleted'); return $this; } diff --git a/src/Types/DeletedCompanyObject.php b/src/Types/DeletedCompanyObject.php index adfc2623..d9258ba0 100644 --- a/src/Types/DeletedCompanyObject.php +++ b/src/Types/DeletedCompanyObject.php @@ -57,6 +57,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -74,6 +75,7 @@ public function getObject(): ?string public function setObject(?string $value = null): self { $this->object = $value; + $this->_setField('object'); return $this; } @@ -91,6 +93,7 @@ public function getDeleted(): ?bool public function setDeleted(?bool $value = null): self { $this->deleted = $value; + $this->_setField('deleted'); return $this; } diff --git a/src/Types/DeletedInternalArticleObject.php b/src/Types/DeletedInternalArticleObject.php index 18e0cf2b..6bc72d3c 100644 --- a/src/Types/DeletedInternalArticleObject.php +++ b/src/Types/DeletedInternalArticleObject.php @@ -57,6 +57,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -74,6 +75,7 @@ public function getObject(): ?string public function setObject(?string $value = null): self { $this->object = $value; + $this->_setField('object'); return $this; } @@ -91,6 +93,7 @@ public function getDeleted(): ?bool public function setDeleted(?bool $value = null): self { $this->deleted = $value; + $this->_setField('deleted'); return $this; } diff --git a/src/Types/DeletedObject.php b/src/Types/DeletedObject.php index 7e69b702..df95c908 100644 --- a/src/Types/DeletedObject.php +++ b/src/Types/DeletedObject.php @@ -57,6 +57,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -74,6 +75,7 @@ public function getObject(): ?string public function setObject(?string $value = null): self { $this->object = $value; + $this->_setField('object'); return $this; } @@ -91,6 +93,7 @@ public function getDeleted(): ?bool public function setDeleted(?bool $value = null): self { $this->deleted = $value; + $this->_setField('deleted'); return $this; } diff --git a/src/Types/EmailAddressHeader.php b/src/Types/EmailAddressHeader.php index 935375b0..836abdac 100644 --- a/src/Types/EmailAddressHeader.php +++ b/src/Types/EmailAddressHeader.php @@ -57,6 +57,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -74,6 +75,7 @@ public function getEmailAddress(): ?string public function setEmailAddress(?string $value = null): self { $this->emailAddress = $value; + $this->_setField('emailAddress'); return $this; } @@ -91,6 +93,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } diff --git a/src/Types/EmailMessageMetadata.php b/src/Types/EmailMessageMetadata.php index 3db79e51..64c8d757 100644 --- a/src/Types/EmailMessageMetadata.php +++ b/src/Types/EmailMessageMetadata.php @@ -50,6 +50,7 @@ public function getSubject(): ?string public function setSubject(?string $value = null): self { $this->subject = $value; + $this->_setField('subject'); return $this; } @@ -67,6 +68,7 @@ public function getEmailAddressHeaders(): ?array public function setEmailAddressHeaders(?array $value = null): self { $this->emailAddressHeaders = $value; + $this->_setField('emailAddressHeaders'); return $this; } diff --git a/src/Types/Error.php b/src/Types/Error.php index dcbfe99b..f0f08003 100644 --- a/src/Types/Error.php +++ b/src/Types/Error.php @@ -58,6 +58,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -75,6 +76,7 @@ public function getRequestId(): ?string public function setRequestId(?string $value = null): self { $this->requestId = $value; + $this->_setField('requestId'); return $this; } @@ -92,6 +94,7 @@ public function getErrors(): array public function setErrors(array $value): self { $this->errors = $value; + $this->_setField('errors'); return $this; } diff --git a/src/Types/ErrorErrorsItem.php b/src/Types/ErrorErrorsItem.php index 98d57e1e..2508fbe5 100644 --- a/src/Types/ErrorErrorsItem.php +++ b/src/Types/ErrorErrorsItem.php @@ -54,6 +54,7 @@ public function getCode(): string public function setCode(string $value): self { $this->code = $value; + $this->_setField('code'); return $this; } @@ -71,6 +72,7 @@ public function getMessage(): ?string public function setMessage(?string $value = null): self { $this->message = $value; + $this->_setField('message'); return $this; } @@ -88,6 +90,7 @@ public function getField(): ?string public function setField(?string $value = null): self { $this->field = $value; + $this->_setField('field'); return $this; } diff --git a/src/Types/FileAttribute.php b/src/Types/FileAttribute.php index 78862567..84825d9e 100644 --- a/src/Types/FileAttribute.php +++ b/src/Types/FileAttribute.php @@ -89,6 +89,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -106,6 +107,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -123,6 +125,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -140,6 +143,7 @@ public function getContentType(): ?string public function setContentType(?string $value = null): self { $this->contentType = $value; + $this->_setField('contentType'); return $this; } @@ -157,6 +161,7 @@ public function getFilesize(): ?int public function setFilesize(?int $value = null): self { $this->filesize = $value; + $this->_setField('filesize'); return $this; } @@ -174,6 +179,7 @@ public function getWidth(): ?int public function setWidth(?int $value = null): self { $this->width = $value; + $this->_setField('width'); return $this; } @@ -191,6 +197,7 @@ public function getHeight(): ?int public function setHeight(?int $value = null): self { $this->height = $value; + $this->_setField('height'); return $this; } diff --git a/src/Types/GroupContent.php b/src/Types/GroupContent.php index 9e3bcc48..71aa08c1 100644 --- a/src/Types/GroupContent.php +++ b/src/Types/GroupContent.php @@ -57,6 +57,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -74,6 +75,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -91,6 +93,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } diff --git a/src/Types/GroupTranslatedContent.php b/src/Types/GroupTranslatedContent.php index 7e212a44..c15c199e 100644 --- a/src/Types/GroupTranslatedContent.php +++ b/src/Types/GroupTranslatedContent.php @@ -337,6 +337,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -354,6 +355,7 @@ public function getAr(): ?GroupContent public function setAr(?GroupContent $value = null): self { $this->ar = $value; + $this->_setField('ar'); return $this; } @@ -371,6 +373,7 @@ public function getBg(): ?GroupContent public function setBg(?GroupContent $value = null): self { $this->bg = $value; + $this->_setField('bg'); return $this; } @@ -388,6 +391,7 @@ public function getBs(): ?GroupContent public function setBs(?GroupContent $value = null): self { $this->bs = $value; + $this->_setField('bs'); return $this; } @@ -405,6 +409,7 @@ public function getCa(): ?GroupContent public function setCa(?GroupContent $value = null): self { $this->ca = $value; + $this->_setField('ca'); return $this; } @@ -422,6 +427,7 @@ public function getCs(): ?GroupContent public function setCs(?GroupContent $value = null): self { $this->cs = $value; + $this->_setField('cs'); return $this; } @@ -439,6 +445,7 @@ public function getDa(): ?GroupContent public function setDa(?GroupContent $value = null): self { $this->da = $value; + $this->_setField('da'); return $this; } @@ -456,6 +463,7 @@ public function getDe(): ?GroupContent public function setDe(?GroupContent $value = null): self { $this->de = $value; + $this->_setField('de'); return $this; } @@ -473,6 +481,7 @@ public function getEl(): ?GroupContent public function setEl(?GroupContent $value = null): self { $this->el = $value; + $this->_setField('el'); return $this; } @@ -490,6 +499,7 @@ public function getEn(): ?GroupContent public function setEn(?GroupContent $value = null): self { $this->en = $value; + $this->_setField('en'); return $this; } @@ -507,6 +517,7 @@ public function getEs(): ?GroupContent public function setEs(?GroupContent $value = null): self { $this->es = $value; + $this->_setField('es'); return $this; } @@ -524,6 +535,7 @@ public function getEt(): ?GroupContent public function setEt(?GroupContent $value = null): self { $this->et = $value; + $this->_setField('et'); return $this; } @@ -541,6 +553,7 @@ public function getFi(): ?GroupContent public function setFi(?GroupContent $value = null): self { $this->fi = $value; + $this->_setField('fi'); return $this; } @@ -558,6 +571,7 @@ public function getFr(): ?GroupContent public function setFr(?GroupContent $value = null): self { $this->fr = $value; + $this->_setField('fr'); return $this; } @@ -575,6 +589,7 @@ public function getHe(): ?GroupContent public function setHe(?GroupContent $value = null): self { $this->he = $value; + $this->_setField('he'); return $this; } @@ -592,6 +607,7 @@ public function getHr(): ?GroupContent public function setHr(?GroupContent $value = null): self { $this->hr = $value; + $this->_setField('hr'); return $this; } @@ -609,6 +625,7 @@ public function getHu(): ?GroupContent public function setHu(?GroupContent $value = null): self { $this->hu = $value; + $this->_setField('hu'); return $this; } @@ -626,6 +643,7 @@ public function getId(): ?GroupContent public function setId(?GroupContent $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -643,6 +661,7 @@ public function getIt(): ?GroupContent public function setIt(?GroupContent $value = null): self { $this->it = $value; + $this->_setField('it'); return $this; } @@ -660,6 +679,7 @@ public function getJa(): ?GroupContent public function setJa(?GroupContent $value = null): self { $this->ja = $value; + $this->_setField('ja'); return $this; } @@ -677,6 +697,7 @@ public function getKo(): ?GroupContent public function setKo(?GroupContent $value = null): self { $this->ko = $value; + $this->_setField('ko'); return $this; } @@ -694,6 +715,7 @@ public function getLt(): ?GroupContent public function setLt(?GroupContent $value = null): self { $this->lt = $value; + $this->_setField('lt'); return $this; } @@ -711,6 +733,7 @@ public function getLv(): ?GroupContent public function setLv(?GroupContent $value = null): self { $this->lv = $value; + $this->_setField('lv'); return $this; } @@ -728,6 +751,7 @@ public function getMn(): ?GroupContent public function setMn(?GroupContent $value = null): self { $this->mn = $value; + $this->_setField('mn'); return $this; } @@ -745,6 +769,7 @@ public function getNb(): ?GroupContent public function setNb(?GroupContent $value = null): self { $this->nb = $value; + $this->_setField('nb'); return $this; } @@ -762,6 +787,7 @@ public function getNl(): ?GroupContent public function setNl(?GroupContent $value = null): self { $this->nl = $value; + $this->_setField('nl'); return $this; } @@ -779,6 +805,7 @@ public function getPl(): ?GroupContent public function setPl(?GroupContent $value = null): self { $this->pl = $value; + $this->_setField('pl'); return $this; } @@ -796,6 +823,7 @@ public function getPt(): ?GroupContent public function setPt(?GroupContent $value = null): self { $this->pt = $value; + $this->_setField('pt'); return $this; } @@ -813,6 +841,7 @@ public function getRo(): ?GroupContent public function setRo(?GroupContent $value = null): self { $this->ro = $value; + $this->_setField('ro'); return $this; } @@ -830,6 +859,7 @@ public function getRu(): ?GroupContent public function setRu(?GroupContent $value = null): self { $this->ru = $value; + $this->_setField('ru'); return $this; } @@ -847,6 +877,7 @@ public function getSl(): ?GroupContent public function setSl(?GroupContent $value = null): self { $this->sl = $value; + $this->_setField('sl'); return $this; } @@ -864,6 +895,7 @@ public function getSr(): ?GroupContent public function setSr(?GroupContent $value = null): self { $this->sr = $value; + $this->_setField('sr'); return $this; } @@ -881,6 +913,7 @@ public function getSv(): ?GroupContent public function setSv(?GroupContent $value = null): self { $this->sv = $value; + $this->_setField('sv'); return $this; } @@ -898,6 +931,7 @@ public function getTr(): ?GroupContent public function setTr(?GroupContent $value = null): self { $this->tr = $value; + $this->_setField('tr'); return $this; } @@ -915,6 +949,7 @@ public function getVi(): ?GroupContent public function setVi(?GroupContent $value = null): self { $this->vi = $value; + $this->_setField('vi'); return $this; } @@ -932,6 +967,7 @@ public function getPtBr(): ?GroupContent public function setPtBr(?GroupContent $value = null): self { $this->ptBr = $value; + $this->_setField('ptBr'); return $this; } @@ -949,6 +985,7 @@ public function getZhCn(): ?GroupContent public function setZhCn(?GroupContent $value = null): self { $this->zhCn = $value; + $this->_setField('zhCn'); return $this; } @@ -966,6 +1003,7 @@ public function getZhTw(): ?GroupContent public function setZhTw(?GroupContent $value = null): self { $this->zhTw = $value; + $this->_setField('zhTw'); return $this; } diff --git a/src/Types/InternalArticleList.php b/src/Types/InternalArticleList.php index 5ba6998b..41ee3120 100644 --- a/src/Types/InternalArticleList.php +++ b/src/Types/InternalArticleList.php @@ -67,6 +67,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -84,6 +85,7 @@ public function getPages(): ?CursorPages public function setPages(?CursorPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } @@ -101,6 +103,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -118,6 +121,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Types/IpAllowlist.php b/src/Types/IpAllowlist.php index 9a3e4795..0d57106c 100644 --- a/src/Types/IpAllowlist.php +++ b/src/Types/IpAllowlist.php @@ -63,6 +63,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -80,6 +81,7 @@ public function getEnabled(): ?bool public function setEnabled(?bool $value = null): self { $this->enabled = $value; + $this->_setField('enabled'); return $this; } @@ -97,6 +99,7 @@ public function getIpAllowlist(): ?array public function setIpAllowlist(?array $value = null): self { $this->ipAllowlist = $value; + $this->_setField('ipAllowlist'); return $this; } diff --git a/src/Types/LinkedObject.php b/src/Types/LinkedObject.php index 07b06f73..c6a94cb8 100644 --- a/src/Types/LinkedObject.php +++ b/src/Types/LinkedObject.php @@ -57,6 +57,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -74,6 +75,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -91,6 +93,7 @@ public function getCategory(): ?string public function setCategory(?string $value = null): self { $this->category = $value; + $this->_setField('category'); return $this; } diff --git a/src/Types/LinkedObjectList.php b/src/Types/LinkedObjectList.php index 4c7b668f..aed08a47 100644 --- a/src/Types/LinkedObjectList.php +++ b/src/Types/LinkedObjectList.php @@ -66,6 +66,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -83,6 +84,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -100,6 +102,7 @@ public function getHasMore(): ?bool public function setHasMore(?bool $value = null): self { $this->hasMore = $value; + $this->_setField('hasMore'); return $this; } @@ -117,6 +120,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Types/MultipleFilterSearchRequest.php b/src/Types/MultipleFilterSearchRequest.php index c215c380..6843808a 100644 --- a/src/Types/MultipleFilterSearchRequest.php +++ b/src/Types/MultipleFilterSearchRequest.php @@ -56,6 +56,7 @@ public function getOperator(): ?string public function setOperator(?string $value = null): self { $this->operator = $value; + $this->_setField('operator'); return $this; } @@ -79,6 +80,7 @@ public function getValue(): array|null public function setValue(array|null $value = null): self { $this->value = $value; + $this->_setField('value'); return $this; } diff --git a/src/Types/NewsItemRequest.php b/src/Types/NewsItemRequest.php index 0ebc2f87..908523e3 100644 --- a/src/Types/NewsItemRequest.php +++ b/src/Types/NewsItemRequest.php @@ -100,6 +100,7 @@ public function getTitle(): string public function setTitle(string $value): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -117,6 +118,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -134,6 +136,7 @@ public function getSenderId(): int public function setSenderId(int $value): self { $this->senderId = $value; + $this->_setField('senderId'); return $this; } @@ -151,6 +154,7 @@ public function getState(): ?string public function setState(?string $value = null): self { $this->state = $value; + $this->_setField('state'); return $this; } @@ -168,6 +172,7 @@ public function getDeliverSilently(): ?bool public function setDeliverSilently(?bool $value = null): self { $this->deliverSilently = $value; + $this->_setField('deliverSilently'); return $this; } @@ -185,6 +190,7 @@ public function getLabels(): ?array public function setLabels(?array $value = null): self { $this->labels = $value; + $this->_setField('labels'); return $this; } @@ -202,6 +208,7 @@ public function getReactions(): ?array public function setReactions(?array $value = null): self { $this->reactions = $value; + $this->_setField('reactions'); return $this; } @@ -219,6 +226,7 @@ public function getNewsfeedAssignments(): ?array public function setNewsfeedAssignments(?array $value = null): self { $this->newsfeedAssignments = $value; + $this->_setField('newsfeedAssignments'); return $this; } diff --git a/src/Types/NotFoundErrorBody.php b/src/Types/NotFoundErrorBody.php index ebf251bf..4b6bc809 100644 --- a/src/Types/NotFoundErrorBody.php +++ b/src/Types/NotFoundErrorBody.php @@ -55,6 +55,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -72,6 +73,7 @@ public function getRequestId(): ?string public function setRequestId(?string $value = null): self { $this->requestId = $value; + $this->_setField('requestId'); return $this; } @@ -89,6 +91,7 @@ public function getErrors(): array public function setErrors(array $value): self { $this->errors = $value; + $this->_setField('errors'); return $this; } diff --git a/src/Types/NotFoundErrorBodyErrorsItem.php b/src/Types/NotFoundErrorBodyErrorsItem.php index d5b0c5ef..84021124 100644 --- a/src/Types/NotFoundErrorBodyErrorsItem.php +++ b/src/Types/NotFoundErrorBodyErrorsItem.php @@ -46,6 +46,7 @@ public function getCode(): string public function setCode(string $value): self { $this->code = $value; + $this->_setField('code'); return $this; } @@ -63,6 +64,7 @@ public function getMessage(): ?string public function setMessage(?string $value = null): self { $this->message = $value; + $this->_setField('message'); return $this; } diff --git a/src/Types/NoteList.php b/src/Types/NoteList.php index 4f76b398..a2ae50a0 100644 --- a/src/Types/NoteList.php +++ b/src/Types/NoteList.php @@ -59,6 +59,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -76,6 +77,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } @@ -93,6 +95,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } diff --git a/src/Types/OffsetPages.php b/src/Types/OffsetPages.php index e0af2699..99934483 100644 --- a/src/Types/OffsetPages.php +++ b/src/Types/OffsetPages.php @@ -70,6 +70,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -87,6 +88,7 @@ public function getPage(): ?int public function setPage(?int $value = null): self { $this->page = $value; + $this->_setField('page'); return $this; } @@ -104,6 +106,7 @@ public function getNext(): ?string public function setNext(?string $value = null): self { $this->next = $value; + $this->_setField('next'); return $this; } @@ -121,6 +124,7 @@ public function getPerPage(): ?int public function setPerPage(?int $value = null): self { $this->perPage = $value; + $this->_setField('perPage'); return $this; } @@ -138,6 +142,7 @@ public function getTotalPages(): ?int public function setTotalPages(?int $value = null): self { $this->totalPages = $value; + $this->_setField('totalPages'); return $this; } diff --git a/src/Types/OpenConversationRequest.php b/src/Types/OpenConversationRequest.php index f121aa16..4cd34bba 100644 --- a/src/Types/OpenConversationRequest.php +++ b/src/Types/OpenConversationRequest.php @@ -41,6 +41,7 @@ public function getAdminId(): string public function setAdminId(string $value): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } diff --git a/src/Types/OperatorWorkflowEvent.php b/src/Types/OperatorWorkflowEvent.php index 8590d2c7..c4b0b91a 100644 --- a/src/Types/OperatorWorkflowEvent.php +++ b/src/Types/OperatorWorkflowEvent.php @@ -49,6 +49,7 @@ public function getWorkflow(): ?OperatorWorkflowEventWorkflow public function setWorkflow(?OperatorWorkflowEventWorkflow $value = null): self { $this->workflow = $value; + $this->_setField('workflow'); return $this; } @@ -66,6 +67,7 @@ public function getEvent(): ?OperatorWorkflowEventEvent public function setEvent(?OperatorWorkflowEventEvent $value = null): self { $this->event = $value; + $this->_setField('event'); return $this; } diff --git a/src/Types/OperatorWorkflowEventEvent.php b/src/Types/OperatorWorkflowEventEvent.php index 4ebdfa27..b405f1a5 100644 --- a/src/Types/OperatorWorkflowEventEvent.php +++ b/src/Types/OperatorWorkflowEventEvent.php @@ -46,6 +46,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -63,6 +64,7 @@ public function getResult(): ?string public function setResult(?string $value = null): self { $this->result = $value; + $this->_setField('result'); return $this; } diff --git a/src/Types/OperatorWorkflowEventWorkflow.php b/src/Types/OperatorWorkflowEventWorkflow.php index 080b2a2c..ee5f94d3 100644 --- a/src/Types/OperatorWorkflowEventWorkflow.php +++ b/src/Types/OperatorWorkflowEventWorkflow.php @@ -38,6 +38,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } diff --git a/src/Types/PagesLink.php b/src/Types/PagesLink.php index e14e0652..2d6ccee6 100644 --- a/src/Types/PagesLink.php +++ b/src/Types/PagesLink.php @@ -75,6 +75,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -92,6 +93,7 @@ public function getPage(): ?int public function setPage(?int $value = null): self { $this->page = $value; + $this->_setField('page'); return $this; } @@ -109,6 +111,7 @@ public function getNext(): ?string public function setNext(?string $value = null): self { $this->next = $value; + $this->_setField('next'); return $this; } @@ -126,6 +129,7 @@ public function getPerPage(): ?int public function setPerPage(?int $value = null): self { $this->perPage = $value; + $this->_setField('perPage'); return $this; } @@ -143,6 +147,7 @@ public function getTotalPages(): ?int public function setTotalPages(?int $value = null): self { $this->totalPages = $value; + $this->_setField('totalPages'); return $this; } diff --git a/src/Types/PaginatedResponse.php b/src/Types/PaginatedResponse.php index 35fe68a7..c490fc0c 100644 --- a/src/Types/PaginatedResponse.php +++ b/src/Types/PaginatedResponse.php @@ -66,6 +66,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -83,6 +84,7 @@ public function getPages(): ?CursorPages public function setPages(?CursorPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } @@ -100,6 +102,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -117,6 +120,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Types/PaginatedResponseDataItem.php b/src/Types/PaginatedResponseDataItem.php index 389a8a47..043b40a1 100644 --- a/src/Types/PaginatedResponseDataItem.php +++ b/src/Types/PaginatedResponseDataItem.php @@ -6,7 +6,6 @@ use Intercom\News\Types\NewsItem; use Intercom\News\Types\Newsfeed; use Exception; -use Intercom\Core\Json\JsonDecoder; class PaginatedResponseDataItem extends JsonSerializableType { @@ -185,18 +184,6 @@ public function jsonSerialize(): array 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 */ diff --git a/src/Types/PartAttachment.php b/src/Types/PartAttachment.php index 3f6f7d0a..ca3cff74 100644 --- a/src/Types/PartAttachment.php +++ b/src/Types/PartAttachment.php @@ -89,6 +89,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -106,6 +107,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -123,6 +125,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -140,6 +143,7 @@ public function getContentType(): ?string public function setContentType(?string $value = null): self { $this->contentType = $value; + $this->_setField('contentType'); return $this; } @@ -157,6 +161,7 @@ public function getFilesize(): ?int public function setFilesize(?int $value = null): self { $this->filesize = $value; + $this->_setField('filesize'); return $this; } @@ -174,6 +179,7 @@ public function getWidth(): ?int public function setWidth(?int $value = null): self { $this->width = $value; + $this->_setField('width'); return $this; } @@ -191,6 +197,7 @@ public function getHeight(): ?int public function setHeight(?int $value = null): self { $this->height = $value; + $this->_setField('height'); return $this; } diff --git a/src/Types/PhoneSwitch.php b/src/Types/PhoneSwitch.php index b0618ccf..f6442b56 100644 --- a/src/Types/PhoneSwitch.php +++ b/src/Types/PhoneSwitch.php @@ -49,6 +49,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -66,6 +67,7 @@ public function getPhone(): ?string public function setPhone(?string $value = null): self { $this->phone = $value; + $this->_setField('phone'); return $this; } diff --git a/src/Types/QuickReplyOption.php b/src/Types/QuickReplyOption.php index 47d006a9..c3f59ea8 100644 --- a/src/Types/QuickReplyOption.php +++ b/src/Types/QuickReplyOption.php @@ -46,6 +46,7 @@ public function getText(): string public function setText(string $value): self { $this->text = $value; + $this->_setField('text'); return $this; } @@ -63,6 +64,7 @@ public function getUuid(): string public function setUuid(string $value): self { $this->uuid = $value; + $this->_setField('uuid'); return $this; } diff --git a/src/Types/Recipient.php b/src/Types/Recipient.php index 275d596f..b450edd3 100644 --- a/src/Types/Recipient.php +++ b/src/Types/Recipient.php @@ -49,6 +49,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -66,6 +67,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } diff --git a/src/Types/RedactConversationRequest.php b/src/Types/RedactConversationRequest.php index 8e103c7d..6805a9d8 100644 --- a/src/Types/RedactConversationRequest.php +++ b/src/Types/RedactConversationRequest.php @@ -4,7 +4,6 @@ use Intercom\Core\Json\JsonSerializableType; use Exception; -use Intercom\Core\Json\JsonDecoder; class RedactConversationRequest extends JsonSerializableType { @@ -183,18 +182,6 @@ public function jsonSerialize(): array 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 */ diff --git a/src/Types/RedactConversationRequestConversationPart.php b/src/Types/RedactConversationRequestConversationPart.php index e62f1aa0..219e03ab 100644 --- a/src/Types/RedactConversationRequestConversationPart.php +++ b/src/Types/RedactConversationRequestConversationPart.php @@ -49,6 +49,7 @@ public function getConversationId(): string public function setConversationId(string $value): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } @@ -66,6 +67,7 @@ public function getConversationPartId(): string public function setConversationPartId(string $value): self { $this->conversationPartId = $value; + $this->_setField('conversationPartId'); return $this; } diff --git a/src/Types/RedactConversationRequestSource.php b/src/Types/RedactConversationRequestSource.php index dcc63940..deb70864 100644 --- a/src/Types/RedactConversationRequestSource.php +++ b/src/Types/RedactConversationRequestSource.php @@ -49,6 +49,7 @@ public function getConversationId(): string public function setConversationId(string $value): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } @@ -66,6 +67,7 @@ public function getSourceId(): string public function setSourceId(string $value): self { $this->sourceId = $value; + $this->_setField('sourceId'); return $this; } diff --git a/src/Types/Reference.php b/src/Types/Reference.php index 8edd40c3..f5dad8f0 100644 --- a/src/Types/Reference.php +++ b/src/Types/Reference.php @@ -49,6 +49,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -66,6 +67,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } diff --git a/src/Types/SearchRequest.php b/src/Types/SearchRequest.php index c064c389..b9d23156 100644 --- a/src/Types/SearchRequest.php +++ b/src/Types/SearchRequest.php @@ -62,6 +62,7 @@ public function getQuery(): SingleFilterSearchRequest|MultipleFilterSearchReques public function setQuery(SingleFilterSearchRequest|MultipleFilterSearchRequest $value): self { $this->query = $value; + $this->_setField('query'); return $this; } @@ -79,6 +80,7 @@ public function getPagination(): ?StartingAfterPaging public function setPagination(?StartingAfterPaging $value = null): self { $this->pagination = $value; + $this->_setField('pagination'); return $this; } diff --git a/src/Types/SegmentList.php b/src/Types/SegmentList.php index 08ebfdcb..f0cf1812 100644 --- a/src/Types/SegmentList.php +++ b/src/Types/SegmentList.php @@ -59,6 +59,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -76,6 +77,7 @@ public function getSegments(): ?array public function setSegments(?array $value = null): self { $this->segments = $value; + $this->_setField('segments'); return $this; } @@ -93,6 +95,7 @@ public function getPages(): ?array public function setPages(?array $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } diff --git a/src/Types/SingleFilterSearchRequest.php b/src/Types/SingleFilterSearchRequest.php index 17f721eb..92fac926 100644 --- a/src/Types/SingleFilterSearchRequest.php +++ b/src/Types/SingleFilterSearchRequest.php @@ -72,6 +72,7 @@ public function getField(): ?string public function setField(?string $value = null): self { $this->field = $value; + $this->_setField('field'); return $this; } @@ -89,6 +90,7 @@ public function getOperator(): ?string public function setOperator(?string $value = null): self { $this->operator = $value; + $this->_setField('operator'); return $this; } @@ -120,6 +122,7 @@ public function getValue(): string|int|array|null public function setValue(string|int|array|null $value = null): self { $this->value = $value; + $this->_setField('value'); return $this; } diff --git a/src/Types/SlaApplied.php b/src/Types/SlaApplied.php index 6587038d..0d34c37f 100644 --- a/src/Types/SlaApplied.php +++ b/src/Types/SlaApplied.php @@ -63,6 +63,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -80,6 +81,7 @@ public function getSlaName(): ?string public function setSlaName(?string $value = null): self { $this->slaName = $value; + $this->_setField('slaName'); return $this; } @@ -97,6 +99,7 @@ public function getSlaStatus(): ?string public function setSlaStatus(?string $value = null): self { $this->slaStatus = $value; + $this->_setField('slaStatus'); return $this; } diff --git a/src/Types/SnoozeConversationRequest.php b/src/Types/SnoozeConversationRequest.php index 7ec7727f..500680c9 100644 --- a/src/Types/SnoozeConversationRequest.php +++ b/src/Types/SnoozeConversationRequest.php @@ -49,6 +49,7 @@ public function getAdminId(): string public function setAdminId(string $value): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } @@ -66,6 +67,7 @@ public function getSnoozedUntil(): int public function setSnoozedUntil(int $value): self { $this->snoozedUntil = $value; + $this->_setField('snoozedUntil'); return $this; } diff --git a/src/Types/SocialProfile.php b/src/Types/SocialProfile.php index 0ae1f48b..d369fff6 100644 --- a/src/Types/SocialProfile.php +++ b/src/Types/SocialProfile.php @@ -57,6 +57,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -74,6 +75,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -91,6 +93,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } diff --git a/src/Types/StartingAfterPaging.php b/src/Types/StartingAfterPaging.php index 39967d94..555316a5 100644 --- a/src/Types/StartingAfterPaging.php +++ b/src/Types/StartingAfterPaging.php @@ -46,6 +46,7 @@ public function getPerPage(): ?int public function setPerPage(?int $value = null): self { $this->perPage = $value; + $this->_setField('perPage'); return $this; } @@ -63,6 +64,7 @@ public function getStartingAfter(): ?string public function setStartingAfter(?string $value = null): self { $this->startingAfter = $value; + $this->_setField('startingAfter'); return $this; } diff --git a/src/Types/SubscriptionTypeList.php b/src/Types/SubscriptionTypeList.php index 9526ff20..dcff0477 100644 --- a/src/Types/SubscriptionTypeList.php +++ b/src/Types/SubscriptionTypeList.php @@ -51,6 +51,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -68,6 +69,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Types/TagCompanyRequest.php b/src/Types/TagCompanyRequest.php index 65c4d1a1..aa247637 100644 --- a/src/Types/TagCompanyRequest.php +++ b/src/Types/TagCompanyRequest.php @@ -50,6 +50,7 @@ public function getName(): string public function setName(string $value): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -67,6 +68,7 @@ public function getCompanies(): array public function setCompanies(array $value): self { $this->companies = $value; + $this->_setField('companies'); return $this; } diff --git a/src/Types/TagCompanyRequestCompaniesItem.php b/src/Types/TagCompanyRequestCompaniesItem.php index 9bb79a9e..969c6222 100644 --- a/src/Types/TagCompanyRequestCompaniesItem.php +++ b/src/Types/TagCompanyRequestCompaniesItem.php @@ -46,6 +46,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -63,6 +64,7 @@ public function getCompanyId(): ?string public function setCompanyId(?string $value = null): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } diff --git a/src/Types/TagList.php b/src/Types/TagList.php index 105a2c77..a2552d1e 100644 --- a/src/Types/TagList.php +++ b/src/Types/TagList.php @@ -51,6 +51,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -68,6 +69,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Types/TagMultipleUsersRequest.php b/src/Types/TagMultipleUsersRequest.php index 390e3c33..ac2d02ad 100644 --- a/src/Types/TagMultipleUsersRequest.php +++ b/src/Types/TagMultipleUsersRequest.php @@ -50,6 +50,7 @@ public function getName(): string public function setName(string $value): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -67,6 +68,7 @@ public function getUsers(): array public function setUsers(array $value): self { $this->users = $value; + $this->_setField('users'); return $this; } diff --git a/src/Types/TagMultipleUsersRequestUsersItem.php b/src/Types/TagMultipleUsersRequestUsersItem.php index ca6c9a66..75b1fe68 100644 --- a/src/Types/TagMultipleUsersRequestUsersItem.php +++ b/src/Types/TagMultipleUsersRequestUsersItem.php @@ -38,6 +38,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } diff --git a/src/Types/Tags.php b/src/Types/Tags.php index a09e730b..f07e4c84 100644 --- a/src/Types/Tags.php +++ b/src/Types/Tags.php @@ -51,6 +51,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -68,6 +69,7 @@ public function getTags(): ?array public function setTags(?array $value = null): self { $this->tags = $value; + $this->_setField('tags'); return $this; } diff --git a/src/Types/TeamList.php b/src/Types/TeamList.php index a7912da9..c9c23f69 100644 --- a/src/Types/TeamList.php +++ b/src/Types/TeamList.php @@ -51,6 +51,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -68,6 +69,7 @@ public function getTeams(): ?array public function setTeams(?array $value = null): self { $this->teams = $value; + $this->_setField('teams'); return $this; } diff --git a/src/Types/TeamPriorityLevel.php b/src/Types/TeamPriorityLevel.php index 4cd0f2e5..715e023b 100644 --- a/src/Types/TeamPriorityLevel.php +++ b/src/Types/TeamPriorityLevel.php @@ -50,6 +50,7 @@ public function getPrimaryTeamIds(): ?array public function setPrimaryTeamIds(?array $value = null): self { $this->primaryTeamIds = $value; + $this->_setField('primaryTeamIds'); return $this; } @@ -67,6 +68,7 @@ public function getSecondaryTeamIds(): ?array public function setSecondaryTeamIds(?array $value = null): self { $this->secondaryTeamIds = $value; + $this->_setField('secondaryTeamIds'); return $this; } diff --git a/src/Types/TicketList.php b/src/Types/TicketList.php index 2d7adea5..f85fa7a0 100644 --- a/src/Types/TicketList.php +++ b/src/Types/TicketList.php @@ -68,6 +68,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -85,6 +86,7 @@ public function getTickets(): ?array public function setTickets(?array $value = null): self { $this->tickets = $value; + $this->_setField('tickets'); return $this; } @@ -102,6 +104,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -119,6 +122,7 @@ public function getPages(): ?CursorPages public function setPages(?CursorPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } diff --git a/src/Types/TicketPartAuthor.php b/src/Types/TicketPartAuthor.php index faadb611..bf1fa150 100644 --- a/src/Types/TicketPartAuthor.php +++ b/src/Types/TicketPartAuthor.php @@ -65,6 +65,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -82,6 +83,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -99,6 +101,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -116,6 +119,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } diff --git a/src/Types/TicketParts.php b/src/Types/TicketParts.php index 2dea032b..f0289ad1 100644 --- a/src/Types/TicketParts.php +++ b/src/Types/TicketParts.php @@ -59,6 +59,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -76,6 +77,7 @@ public function getTicketParts(): ?array public function setTicketParts(?array $value = null): self { $this->ticketParts = $value; + $this->_setField('ticketParts'); return $this; } @@ -93,6 +95,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } diff --git a/src/Types/TicketReply.php b/src/Types/TicketReply.php index 96bc10e9..97392880 100644 --- a/src/Types/TicketReply.php +++ b/src/Types/TicketReply.php @@ -106,6 +106,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -123,6 +124,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -140,6 +142,7 @@ public function getPartType(): ?string public function setPartType(?string $value = null): self { $this->partType = $value; + $this->_setField('partType'); return $this; } @@ -157,6 +160,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -174,6 +178,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -191,6 +196,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -208,6 +214,7 @@ public function getAuthor(): ?TicketPartAuthor public function setAuthor(?TicketPartAuthor $value = null): self { $this->author = $value; + $this->_setField('author'); return $this; } @@ -225,6 +232,7 @@ public function getAttachments(): ?array public function setAttachments(?array $value = null): self { $this->attachments = $value; + $this->_setField('attachments'); return $this; } @@ -242,6 +250,7 @@ public function getRedacted(): ?bool public function setRedacted(?bool $value = null): self { $this->redacted = $value; + $this->_setField('redacted'); return $this; } diff --git a/src/Types/TicketStateList.php b/src/Types/TicketStateList.php index 7e42c02b..58bab82e 100644 --- a/src/Types/TicketStateList.php +++ b/src/Types/TicketStateList.php @@ -52,6 +52,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -69,6 +70,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Types/TicketTypeAttribute.php b/src/Types/TicketTypeAttribute.php index 757aa5f1..58074ed7 100644 --- a/src/Types/TicketTypeAttribute.php +++ b/src/Types/TicketTypeAttribute.php @@ -170,6 +170,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -187,6 +188,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -204,6 +206,7 @@ public function getWorkspaceId(): ?string public function setWorkspaceId(?string $value = null): self { $this->workspaceId = $value; + $this->_setField('workspaceId'); return $this; } @@ -221,6 +224,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -238,6 +242,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -255,6 +260,7 @@ public function getDataType(): ?string public function setDataType(?string $value = null): self { $this->dataType = $value; + $this->_setField('dataType'); return $this; } @@ -272,6 +278,7 @@ public function getInputOptions(): ?array public function setInputOptions(?array $value = null): self { $this->inputOptions = $value; + $this->_setField('inputOptions'); return $this; } @@ -289,6 +296,7 @@ public function getOrder(): ?int public function setOrder(?int $value = null): self { $this->order = $value; + $this->_setField('order'); return $this; } @@ -306,6 +314,7 @@ public function getRequiredToCreate(): ?bool public function setRequiredToCreate(?bool $value = null): self { $this->requiredToCreate = $value; + $this->_setField('requiredToCreate'); return $this; } @@ -323,6 +332,7 @@ public function getRequiredToCreateForContacts(): ?bool public function setRequiredToCreateForContacts(?bool $value = null): self { $this->requiredToCreateForContacts = $value; + $this->_setField('requiredToCreateForContacts'); return $this; } @@ -340,6 +350,7 @@ public function getVisibleOnCreate(): ?bool public function setVisibleOnCreate(?bool $value = null): self { $this->visibleOnCreate = $value; + $this->_setField('visibleOnCreate'); return $this; } @@ -357,6 +368,7 @@ public function getVisibleToContacts(): ?bool public function setVisibleToContacts(?bool $value = null): self { $this->visibleToContacts = $value; + $this->_setField('visibleToContacts'); return $this; } @@ -374,6 +386,7 @@ public function getDefault(): ?bool public function setDefault(?bool $value = null): self { $this->default = $value; + $this->_setField('default'); return $this; } @@ -391,6 +404,7 @@ public function getTicketTypeId(): ?int public function setTicketTypeId(?int $value = null): self { $this->ticketTypeId = $value; + $this->_setField('ticketTypeId'); return $this; } @@ -408,6 +422,7 @@ public function getArchived(): ?bool public function setArchived(?bool $value = null): self { $this->archived = $value; + $this->_setField('archived'); return $this; } @@ -425,6 +440,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -442,6 +458,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } diff --git a/src/Types/TicketTypeAttributeList.php b/src/Types/TicketTypeAttributeList.php index e153db8e..21041d8a 100644 --- a/src/Types/TicketTypeAttributeList.php +++ b/src/Types/TicketTypeAttributeList.php @@ -51,6 +51,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -68,6 +69,7 @@ public function getTicketTypeAttributes(): ?array public function setTicketTypeAttributes(?array $value = null): self { $this->ticketTypeAttributes = $value; + $this->_setField('ticketTypeAttributes'); return $this; } diff --git a/src/Types/TicketTypeList.php b/src/Types/TicketTypeList.php index 15f57f4c..cc4d23ae 100644 --- a/src/Types/TicketTypeList.php +++ b/src/Types/TicketTypeList.php @@ -52,6 +52,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -69,6 +70,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Types/Translation.php b/src/Types/Translation.php index 7b98448d..56fbf891 100644 --- a/src/Types/Translation.php +++ b/src/Types/Translation.php @@ -57,6 +57,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -74,6 +75,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -91,6 +93,7 @@ public function getLocale(): ?string public function setLocale(?string $value = null): self { $this->locale = $value; + $this->_setField('locale'); return $this; } diff --git a/src/Types/UntagCompanyRequest.php b/src/Types/UntagCompanyRequest.php index 85219f5f..3649579c 100644 --- a/src/Types/UntagCompanyRequest.php +++ b/src/Types/UntagCompanyRequest.php @@ -50,6 +50,7 @@ public function getName(): string public function setName(string $value): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -67,6 +68,7 @@ public function getCompanies(): array public function setCompanies(array $value): self { $this->companies = $value; + $this->_setField('companies'); return $this; } diff --git a/src/Types/UntagCompanyRequestCompaniesItem.php b/src/Types/UntagCompanyRequestCompaniesItem.php index 7f12d763..13fb63b2 100644 --- a/src/Types/UntagCompanyRequestCompaniesItem.php +++ b/src/Types/UntagCompanyRequestCompaniesItem.php @@ -54,6 +54,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -71,6 +72,7 @@ public function getCompanyId(): ?string public function setCompanyId(?string $value = null): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } @@ -88,6 +90,7 @@ public function getUntag(): ?bool public function setUntag(?bool $value = null): self { $this->untag = $value; + $this->_setField('untag'); return $this; } diff --git a/src/Types/UpdateArticleRequestBody.php b/src/Types/UpdateArticleRequestBody.php index f22bdf07..56482000 100644 --- a/src/Types/UpdateArticleRequestBody.php +++ b/src/Types/UpdateArticleRequestBody.php @@ -38,6 +38,7 @@ public function getParentType(): ?string public function setParentType(?string $value = null): self { $this->parentType = $value; + $this->_setField('parentType'); return $this; } diff --git a/src/Types/UpdateCompanyRequestBody.php b/src/Types/UpdateCompanyRequestBody.php index cef55175..e97ffc4d 100644 --- a/src/Types/UpdateCompanyRequestBody.php +++ b/src/Types/UpdateCompanyRequestBody.php @@ -90,6 +90,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -107,6 +108,7 @@ public function getPlan(): ?string public function setPlan(?string $value = null): self { $this->plan = $value; + $this->_setField('plan'); return $this; } @@ -124,6 +126,7 @@ public function getSize(): ?int public function setSize(?int $value = null): self { $this->size = $value; + $this->_setField('size'); return $this; } @@ -141,6 +144,7 @@ public function getWebsite(): ?string public function setWebsite(?string $value = null): self { $this->website = $value; + $this->_setField('website'); return $this; } @@ -158,6 +162,7 @@ public function getIndustry(): ?string public function setIndustry(?string $value = null): self { $this->industry = $value; + $this->_setField('industry'); return $this; } @@ -175,6 +180,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } @@ -192,6 +198,7 @@ public function getMonthlySpend(): ?int public function setMonthlySpend(?int $value = null): self { $this->monthlySpend = $value; + $this->_setField('monthlySpend'); return $this; } diff --git a/src/Types/UpdateDataAttributeRequestOptions.php b/src/Types/UpdateDataAttributeRequestBodyOptions.php similarity index 57% rename from src/Types/UpdateDataAttributeRequestOptions.php rename to src/Types/UpdateDataAttributeRequestBodyOptions.php index fa5e0b20..b51cb53e 100644 --- a/src/Types/UpdateDataAttributeRequestOptions.php +++ b/src/Types/UpdateDataAttributeRequestBodyOptions.php @@ -6,17 +6,17 @@ use Intercom\Core\Json\JsonProperty; use Intercom\Core\Types\ArrayType; -class UpdateDataAttributeRequestOptions extends JsonSerializableType +class UpdateDataAttributeRequestBodyOptions extends JsonSerializableType { /** - * @var array $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. + * @var array $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])] + #[JsonProperty('options'), ArrayType([UpdateDataAttributeRequestBodyOptionsOptionsItem::class])] private array $options; /** * @param array{ - * options: array, + * options: array, * } $values */ public function __construct( @@ -26,7 +26,7 @@ public function __construct( } /** - * @return array + * @return array */ public function getOptions(): array { @@ -34,11 +34,12 @@ public function getOptions(): array } /** - * @param array $value + * @param array $value */ public function setOptions(array $value): self { $this->options = $value; + $this->_setField('options'); return $this; } diff --git a/src/Types/UpdateDataAttributeRequestOptionsOptionsItem.php b/src/Types/UpdateDataAttributeRequestBodyOptionsOptionsItem.php similarity index 87% rename from src/Types/UpdateDataAttributeRequestOptionsOptionsItem.php rename to src/Types/UpdateDataAttributeRequestBodyOptionsOptionsItem.php index cd8485db..94622e36 100644 --- a/src/Types/UpdateDataAttributeRequestOptionsOptionsItem.php +++ b/src/Types/UpdateDataAttributeRequestBodyOptionsOptionsItem.php @@ -5,7 +5,7 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; -class UpdateDataAttributeRequestOptionsOptionsItem extends JsonSerializableType +class UpdateDataAttributeRequestBodyOptionsOptionsItem extends JsonSerializableType { /** * @var ?string $value @@ -38,6 +38,7 @@ public function getValue(): ?string public function setValue(?string $value = null): self { $this->value = $value; + $this->_setField('value'); return $this; } diff --git a/src/Types/UpdateVisitorRequestWithId.php b/src/Types/UpdateVisitorRequestWithId.php index f4483ee4..bdb1f7f8 100644 --- a/src/Types/UpdateVisitorRequestWithId.php +++ b/src/Types/UpdateVisitorRequestWithId.php @@ -55,6 +55,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -72,6 +73,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -89,6 +91,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } diff --git a/src/Types/UpdateVisitorRequestWithUserId.php b/src/Types/UpdateVisitorRequestWithUserId.php index 157691c5..3dd25acb 100644 --- a/src/Types/UpdateVisitorRequestWithUserId.php +++ b/src/Types/UpdateVisitorRequestWithUserId.php @@ -55,6 +55,7 @@ public function getUserId(): string public function setUserId(string $value): self { $this->userId = $value; + $this->_setField('userId'); return $this; } @@ -72,6 +73,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -89,6 +91,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } diff --git a/src/Types/Visitor.php b/src/Types/Visitor.php index 8ebfa5ac..d43a498a 100644 --- a/src/Types/Visitor.php +++ b/src/Types/Visitor.php @@ -298,6 +298,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -315,6 +316,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -332,6 +334,7 @@ public function getUserId(): ?string public function setUserId(?string $value = null): self { $this->userId = $value; + $this->_setField('userId'); return $this; } @@ -349,6 +352,7 @@ public function getAnonymous(): ?bool public function setAnonymous(?bool $value = null): self { $this->anonymous = $value; + $this->_setField('anonymous'); return $this; } @@ -366,6 +370,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -383,6 +388,7 @@ public function getPhone(): ?string public function setPhone(?string $value = null): self { $this->phone = $value; + $this->_setField('phone'); return $this; } @@ -400,6 +406,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -417,6 +424,7 @@ public function getPseudonym(): ?string public function setPseudonym(?string $value = null): self { $this->pseudonym = $value; + $this->_setField('pseudonym'); return $this; } @@ -434,6 +442,7 @@ public function getAvatar(): ?VisitorAvatar public function setAvatar(?VisitorAvatar $value = null): self { $this->avatar = $value; + $this->_setField('avatar'); return $this; } @@ -451,6 +460,7 @@ public function getAppId(): ?string public function setAppId(?string $value = null): self { $this->appId = $value; + $this->_setField('appId'); return $this; } @@ -468,6 +478,7 @@ public function getCompanies(): ?VisitorCompanies public function setCompanies(?VisitorCompanies $value = null): self { $this->companies = $value; + $this->_setField('companies'); return $this; } @@ -485,6 +496,7 @@ public function getLocationData(): ?VisitorLocationData public function setLocationData(?VisitorLocationData $value = null): self { $this->locationData = $value; + $this->_setField('locationData'); return $this; } @@ -502,6 +514,7 @@ public function getLasRequestAt(): ?int public function setLasRequestAt(?int $value = null): self { $this->lasRequestAt = $value; + $this->_setField('lasRequestAt'); return $this; } @@ -519,6 +532,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -536,6 +550,7 @@ public function getRemoteCreatedAt(): ?int public function setRemoteCreatedAt(?int $value = null): self { $this->remoteCreatedAt = $value; + $this->_setField('remoteCreatedAt'); return $this; } @@ -553,6 +568,7 @@ public function getSignedUpAt(): ?int public function setSignedUpAt(?int $value = null): self { $this->signedUpAt = $value; + $this->_setField('signedUpAt'); return $this; } @@ -570,6 +586,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -587,6 +604,7 @@ public function getSessionCount(): ?int public function setSessionCount(?int $value = null): self { $this->sessionCount = $value; + $this->_setField('sessionCount'); return $this; } @@ -604,6 +622,7 @@ public function getSocialProfiles(): ?VisitorSocialProfiles public function setSocialProfiles(?VisitorSocialProfiles $value = null): self { $this->socialProfiles = $value; + $this->_setField('socialProfiles'); return $this; } @@ -621,6 +640,7 @@ public function getOwnerId(): ?string public function setOwnerId(?string $value = null): self { $this->ownerId = $value; + $this->_setField('ownerId'); return $this; } @@ -638,6 +658,7 @@ public function getUnsubscribedFromEmails(): ?bool public function setUnsubscribedFromEmails(?bool $value = null): self { $this->unsubscribedFromEmails = $value; + $this->_setField('unsubscribedFromEmails'); return $this; } @@ -655,6 +676,7 @@ public function getMarkedEmailAsSpam(): ?bool public function setMarkedEmailAsSpam(?bool $value = null): self { $this->markedEmailAsSpam = $value; + $this->_setField('markedEmailAsSpam'); return $this; } @@ -672,6 +694,7 @@ public function getHasHardBounced(): ?bool public function setHasHardBounced(?bool $value = null): self { $this->hasHardBounced = $value; + $this->_setField('hasHardBounced'); return $this; } @@ -689,6 +712,7 @@ public function getTags(): ?VisitorTags public function setTags(?VisitorTags $value = null): self { $this->tags = $value; + $this->_setField('tags'); return $this; } @@ -706,6 +730,7 @@ public function getSegments(): ?VisitorSegments public function setSegments(?VisitorSegments $value = null): self { $this->segments = $value; + $this->_setField('segments'); return $this; } @@ -723,6 +748,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } @@ -740,6 +766,7 @@ public function getReferrer(): ?string public function setReferrer(?string $value = null): self { $this->referrer = $value; + $this->_setField('referrer'); return $this; } @@ -757,6 +784,7 @@ public function getUtmCampaign(): ?string public function setUtmCampaign(?string $value = null): self { $this->utmCampaign = $value; + $this->_setField('utmCampaign'); return $this; } @@ -774,6 +802,7 @@ public function getUtmContent(): ?string public function setUtmContent(?string $value = null): self { $this->utmContent = $value; + $this->_setField('utmContent'); return $this; } @@ -791,6 +820,7 @@ public function getUtmMedium(): ?string public function setUtmMedium(?string $value = null): self { $this->utmMedium = $value; + $this->_setField('utmMedium'); return $this; } @@ -808,6 +838,7 @@ public function getUtmSource(): ?string public function setUtmSource(?string $value = null): self { $this->utmSource = $value; + $this->_setField('utmSource'); return $this; } @@ -825,6 +856,7 @@ public function getUtmTerm(): ?string public function setUtmTerm(?string $value = null): self { $this->utmTerm = $value; + $this->_setField('utmTerm'); return $this; } @@ -842,6 +874,7 @@ public function getDoNotTrack(): ?bool public function setDoNotTrack(?bool $value = null): self { $this->doNotTrack = $value; + $this->_setField('doNotTrack'); return $this; } diff --git a/src/Types/VisitorAvatar.php b/src/Types/VisitorAvatar.php index 151d8adf..5c761eea 100644 --- a/src/Types/VisitorAvatar.php +++ b/src/Types/VisitorAvatar.php @@ -46,6 +46,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -63,6 +64,7 @@ public function getImageUrl(): ?string public function setImageUrl(?string $value = null): self { $this->imageUrl = $value; + $this->_setField('imageUrl'); return $this; } diff --git a/src/Types/VisitorCompanies.php b/src/Types/VisitorCompanies.php index d0f9e7df..862afda9 100644 --- a/src/Types/VisitorCompanies.php +++ b/src/Types/VisitorCompanies.php @@ -48,6 +48,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -65,6 +66,7 @@ public function getCompanies(): ?array public function setCompanies(?array $value = null): self { $this->companies = $value; + $this->_setField('companies'); return $this; } diff --git a/src/Types/VisitorDeletedObject.php b/src/Types/VisitorDeletedObject.php index b90fc8f4..a45a28b6 100644 --- a/src/Types/VisitorDeletedObject.php +++ b/src/Types/VisitorDeletedObject.php @@ -57,6 +57,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -74,6 +75,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -91,6 +93,7 @@ public function getUserId(): ?string public function setUserId(?string $value = null): self { $this->userId = $value; + $this->_setField('userId'); return $this; } diff --git a/src/Types/VisitorLocationData.php b/src/Types/VisitorLocationData.php index 528ef5ca..a1f513d9 100644 --- a/src/Types/VisitorLocationData.php +++ b/src/Types/VisitorLocationData.php @@ -94,6 +94,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -111,6 +112,7 @@ public function getCityName(): ?string public function setCityName(?string $value = null): self { $this->cityName = $value; + $this->_setField('cityName'); return $this; } @@ -128,6 +130,7 @@ public function getContinentCode(): ?string public function setContinentCode(?string $value = null): self { $this->continentCode = $value; + $this->_setField('continentCode'); return $this; } @@ -145,6 +148,7 @@ public function getCountryCode(): ?string public function setCountryCode(?string $value = null): self { $this->countryCode = $value; + $this->_setField('countryCode'); return $this; } @@ -162,6 +166,7 @@ public function getCountryName(): ?string public function setCountryName(?string $value = null): self { $this->countryName = $value; + $this->_setField('countryName'); return $this; } @@ -179,6 +184,7 @@ public function getPostalCode(): ?string public function setPostalCode(?string $value = null): self { $this->postalCode = $value; + $this->_setField('postalCode'); return $this; } @@ -196,6 +202,7 @@ public function getRegionName(): ?string public function setRegionName(?string $value = null): self { $this->regionName = $value; + $this->_setField('regionName'); return $this; } @@ -213,6 +220,7 @@ public function getTimezone(): ?string public function setTimezone(?string $value = null): self { $this->timezone = $value; + $this->_setField('timezone'); return $this; } diff --git a/src/Types/VisitorSegments.php b/src/Types/VisitorSegments.php index 6ebc2eda..70722319 100644 --- a/src/Types/VisitorSegments.php +++ b/src/Types/VisitorSegments.php @@ -47,6 +47,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -64,6 +65,7 @@ public function getSegments(): ?array public function setSegments(?array $value = null): self { $this->segments = $value; + $this->_setField('segments'); return $this; } diff --git a/src/Types/VisitorSocialProfiles.php b/src/Types/VisitorSocialProfiles.php index e8b49954..4e7c837b 100644 --- a/src/Types/VisitorSocialProfiles.php +++ b/src/Types/VisitorSocialProfiles.php @@ -47,6 +47,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -64,6 +65,7 @@ public function getSocialProfiles(): ?array public function setSocialProfiles(?array $value = null): self { $this->socialProfiles = $value; + $this->_setField('socialProfiles'); return $this; } diff --git a/src/Types/VisitorTags.php b/src/Types/VisitorTags.php index b37d17ec..7999ec13 100644 --- a/src/Types/VisitorTags.php +++ b/src/Types/VisitorTags.php @@ -47,6 +47,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -64,6 +65,7 @@ public function getTags(): ?array public function setTags(?array $value = null): self { $this->tags = $value; + $this->_setField('tags'); return $this; } diff --git a/src/Types/VisitorTagsTagsItem.php b/src/Types/VisitorTagsTagsItem.php index 6061f6c4..48b3d30b 100644 --- a/src/Types/VisitorTagsTagsItem.php +++ b/src/Types/VisitorTagsTagsItem.php @@ -54,6 +54,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -71,6 +72,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -88,6 +90,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } diff --git a/src/Types/WhatsappMessageStatusList.php b/src/Types/WhatsappMessageStatusList.php index 8ff477a4..ebdc879c 100644 --- a/src/Types/WhatsappMessageStatusList.php +++ b/src/Types/WhatsappMessageStatusList.php @@ -71,6 +71,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -88,6 +89,7 @@ public function getRulesetId(): string public function setRulesetId(string $value): self { $this->rulesetId = $value; + $this->_setField('rulesetId'); return $this; } @@ -105,6 +107,7 @@ public function getPages(): WhatsappMessageStatusListPages public function setPages(WhatsappMessageStatusListPages $value): self { $this->pages = $value; + $this->_setField('pages'); return $this; } @@ -122,6 +125,7 @@ public function getTotalCount(): int public function setTotalCount(int $value): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -139,6 +143,7 @@ public function getEvents(): array public function setEvents(array $value): self { $this->events = $value; + $this->_setField('events'); return $this; } diff --git a/src/Types/WhatsappMessageStatusListEventsItem.php b/src/Types/WhatsappMessageStatusListEventsItem.php index 9eb3715e..58bbf204 100644 --- a/src/Types/WhatsappMessageStatusListEventsItem.php +++ b/src/Types/WhatsappMessageStatusListEventsItem.php @@ -94,6 +94,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -111,6 +112,7 @@ public function getConversationId(): string public function setConversationId(string $value): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } @@ -128,6 +130,7 @@ public function getStatus(): string public function setStatus(string $value): self { $this->status = $value; + $this->_setField('status'); return $this; } @@ -145,6 +148,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -162,6 +166,7 @@ public function getCreatedAt(): int public function setCreatedAt(int $value): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -179,6 +184,7 @@ public function getUpdatedAt(): int public function setUpdatedAt(int $value): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -196,6 +202,7 @@ public function getWhatsappMessageId(): string public function setWhatsappMessageId(string $value): self { $this->whatsappMessageId = $value; + $this->_setField('whatsappMessageId'); return $this; } @@ -213,6 +220,7 @@ public function getTemplateName(): ?string public function setTemplateName(?string $value = null): self { $this->templateName = $value; + $this->_setField('templateName'); return $this; } diff --git a/src/Types/WhatsappMessageStatusListPages.php b/src/Types/WhatsappMessageStatusListPages.php index da8fecf4..eb4f1c82 100644 --- a/src/Types/WhatsappMessageStatusListPages.php +++ b/src/Types/WhatsappMessageStatusListPages.php @@ -62,6 +62,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -79,6 +80,7 @@ public function getPerPage(): int public function setPerPage(int $value): self { $this->perPage = $value; + $this->_setField('perPage'); return $this; } @@ -96,6 +98,7 @@ public function getTotalPages(): int public function setTotalPages(int $value): self { $this->totalPages = $value; + $this->_setField('totalPages'); return $this; } @@ -113,6 +116,7 @@ public function getNext(): ?WhatsappMessageStatusListPagesNext public function setNext(?WhatsappMessageStatusListPagesNext $value = null): self { $this->next = $value; + $this->_setField('next'); return $this; } diff --git a/src/Types/WhatsappMessageStatusListPagesNext.php b/src/Types/WhatsappMessageStatusListPagesNext.php index 1b112f43..db2bc7ca 100644 --- a/src/Types/WhatsappMessageStatusListPagesNext.php +++ b/src/Types/WhatsappMessageStatusListPagesNext.php @@ -41,6 +41,7 @@ public function getStartingAfter(): ?string public function setStartingAfter(?string $value = null): self { $this->startingAfter = $value; + $this->_setField('startingAfter'); return $this; } diff --git a/src/Unstable/Admins/AdminsClient.php b/src/Unstable/Admins/AdminsClient.php index 27ee2c5a..efdfddbe 100644 --- a/src/Unstable/Admins/AdminsClient.php +++ b/src/Unstable/Admins/AdminsClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\Admins; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\Types\AdminWithApp; use Intercom\Exceptions\IntercomException; @@ -11,7 +11,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\Admins\Requests\SetAwayAdminRequest; use Intercom\Unstable\Admins\Types\Admin; @@ -64,6 +63,11 @@ public function __construct( * > * > If you are building a custom "Log in with Intercom" flow for your site, and you call the `/me` endpoint to identify the logged-in user, you should not accept any sign-ins from users with unverified email addresses as it poses a potential impersonation security risk. * + * Example: + * ```php + * $client->admins->identify(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -98,16 +102,6 @@ public function identifyAdmin(?array $options = null): ?AdminWithApp } } 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); } @@ -121,6 +115,18 @@ public function identifyAdmin(?array $options = null): ?AdminWithApp /** * You can set an Admin as away for the Inbox. * + * Example: + * ```php + * $client->unstable->admins->setAwayAdmin( + * new SetAwayAdminRequest([ + * 'id' => 1, + * 'awayModeEnabled' => true, + * 'awayModeReassign' => true, + * 'awayStatusReasonId' => 12345, + * ]), + * ); + * ``` + * * @param SetAwayAdminRequest $request * @param ?array{ * baseUrl?: string, @@ -141,7 +147,7 @@ public function setAwayAdmin(SetAwayAdminRequest $request, ?array $options = nul $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "admins/{$request->getId()}/away", + path: "admins/" . RawClient::encodePathParam($request->getId()) . "/away", method: HttpMethod::PUT, body: $request, ), @@ -157,16 +163,6 @@ public function setAwayAdmin(SetAwayAdminRequest $request, ?array $options = nul } } 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); } @@ -180,6 +176,16 @@ public function setAwayAdmin(SetAwayAdminRequest $request, ?array $options = nul /** * You can get a log of activities by all admins in an app. * + * Example: + * ```php + * $client->admins->listAllActivityLogs( + * new ListAllActivityLogsRequest([ + * 'createdAtAfter' => '1677253093', + * 'createdAtBefore' => '1677861493', + * ]), + * ); + * ``` + * * @param ListActivityLogsRequest $request * @param ?array{ * baseUrl?: string, @@ -189,11 +195,11 @@ public function setAwayAdmin(SetAwayAdminRequest $request, ?array $options = nul * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ActivityLogList + * @return ?ActivityLogList * @throws IntercomException * @throws IntercomApiException */ - public function listActivityLogs(ListActivityLogsRequest $request, ?array $options = null): ActivityLogList + public function listActivityLogs(ListActivityLogsRequest $request, ?array $options = null): ?ActivityLogList { $options = array_merge($this->options, $options ?? []); $query = []; @@ -214,20 +220,13 @@ public function listActivityLogs(ListActivityLogsRequest $request, ?array $optio $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ActivityLogList::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); } @@ -241,6 +240,11 @@ public function listActivityLogs(ListActivityLogsRequest $request, ?array $optio /** * You can fetch a list of admins for a given workspace. * + * Example: + * ```php + * $client->admins->list(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -249,11 +253,11 @@ public function listActivityLogs(ListActivityLogsRequest $request, ?array $optio * queryParameters?: array, * bodyProperties?: array, * } $options - * @return AdminList + * @return ?AdminList * @throws IntercomException * @throws IntercomApiException */ - public function listAdmins(?array $options = null): AdminList + public function listAdmins(?array $options = null): ?AdminList { $options = array_merge($this->options, $options ?? []); try { @@ -268,20 +272,13 @@ public function listAdmins(?array $options = null): AdminList $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return AdminList::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); } @@ -295,6 +292,15 @@ public function listAdmins(?array $options = null): AdminList /** * You can retrieve the details of a single admin. * + * Example: + * ```php + * $client->unstable->admins->retrieveAdmin( + * new RetrieveAdminRequest([ + * 'id' => 1, + * ]), + * ); + * ``` + * * @param RetrieveAdminRequest $request * @param ?array{ * baseUrl?: string, @@ -315,7 +321,7 @@ public function retrieveAdmin(RetrieveAdminRequest $request, ?array $options = n $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "admins/{$request->getId()}", + path: "admins/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::GET, ), $options, @@ -330,16 +336,6 @@ public function retrieveAdmin(RetrieveAdminRequest $request, ?array $options = n } } 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); } diff --git a/src/Unstable/Admins/Requests/ListActivityLogsRequest.php b/src/Unstable/Admins/Requests/ListActivityLogsRequest.php index 75968519..7cab0032 100644 --- a/src/Unstable/Admins/Requests/ListActivityLogsRequest.php +++ b/src/Unstable/Admins/Requests/ListActivityLogsRequest.php @@ -43,6 +43,7 @@ public function getCreatedAtAfter(): string public function setCreatedAtAfter(string $value): self { $this->createdAtAfter = $value; + $this->_setField('createdAtAfter'); return $this; } @@ -60,6 +61,7 @@ public function getCreatedAtBefore(): ?string public function setCreatedAtBefore(?string $value = null): self { $this->createdAtBefore = $value; + $this->_setField('createdAtBefore'); return $this; } } diff --git a/src/Unstable/Admins/Requests/RetrieveAdminRequest.php b/src/Unstable/Admins/Requests/RetrieveAdminRequest.php index 82a0e2bf..41d7b980 100644 --- a/src/Unstable/Admins/Requests/RetrieveAdminRequest.php +++ b/src/Unstable/Admins/Requests/RetrieveAdminRequest.php @@ -36,6 +36,7 @@ public function getId(): int public function setId(int $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Admins/Requests/SetAwayAdminRequest.php b/src/Unstable/Admins/Requests/SetAwayAdminRequest.php index 4319e6e6..2a179e81 100644 --- a/src/Unstable/Admins/Requests/SetAwayAdminRequest.php +++ b/src/Unstable/Admins/Requests/SetAwayAdminRequest.php @@ -61,6 +61,7 @@ public function getId(): int public function setId(int $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -78,6 +79,7 @@ public function getAwayModeEnabled(): bool public function setAwayModeEnabled(bool $value): self { $this->awayModeEnabled = $value; + $this->_setField('awayModeEnabled'); return $this; } @@ -95,6 +97,7 @@ public function getAwayModeReassign(): bool public function setAwayModeReassign(bool $value): self { $this->awayModeReassign = $value; + $this->_setField('awayModeReassign'); return $this; } @@ -112,6 +115,7 @@ public function getAwayStatusReasonId(): ?int public function setAwayStatusReasonId(?int $value = null): self { $this->awayStatusReasonId = $value; + $this->_setField('awayStatusReasonId'); return $this; } } diff --git a/src/Unstable/Admins/Types/Admin.php b/src/Unstable/Admins/Types/Admin.php index 20e93976..5572dcd6 100644 --- a/src/Unstable/Admins/Types/Admin.php +++ b/src/Unstable/Admins/Types/Admin.php @@ -131,6 +131,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -148,6 +149,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -165,6 +167,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -182,6 +185,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -199,6 +203,7 @@ public function getJobTitle(): ?string public function setJobTitle(?string $value = null): self { $this->jobTitle = $value; + $this->_setField('jobTitle'); return $this; } @@ -216,6 +221,7 @@ public function getAwayModeEnabled(): ?bool public function setAwayModeEnabled(?bool $value = null): self { $this->awayModeEnabled = $value; + $this->_setField('awayModeEnabled'); return $this; } @@ -233,6 +239,7 @@ public function getAwayModeReassign(): ?bool public function setAwayModeReassign(?bool $value = null): self { $this->awayModeReassign = $value; + $this->_setField('awayModeReassign'); return $this; } @@ -250,6 +257,7 @@ public function getAwayStatusReasonId(): ?int public function setAwayStatusReasonId(?int $value = null): self { $this->awayStatusReasonId = $value; + $this->_setField('awayStatusReasonId'); return $this; } @@ -267,6 +275,7 @@ public function getHasInboxSeat(): ?bool public function setHasInboxSeat(?bool $value = null): self { $this->hasInboxSeat = $value; + $this->_setField('hasInboxSeat'); return $this; } @@ -284,6 +293,7 @@ public function getTeamIds(): ?array public function setTeamIds(?array $value = null): self { $this->teamIds = $value; + $this->_setField('teamIds'); return $this; } @@ -301,6 +311,7 @@ public function getAvatar(): ?string public function setAvatar(?string $value = null): self { $this->avatar = $value; + $this->_setField('avatar'); return $this; } @@ -318,6 +329,7 @@ public function getTeamPriorityLevel(): ?TeamPriorityLevel public function setTeamPriorityLevel(?TeamPriorityLevel $value = null): self { $this->teamPriorityLevel = $value; + $this->_setField('teamPriorityLevel'); return $this; } diff --git a/src/Unstable/AiAgent/Types/AiAgent.php b/src/Unstable/AiAgent/Types/AiAgent.php index 635bd82f..f248224f 100644 --- a/src/Unstable/AiAgent/Types/AiAgent.php +++ b/src/Unstable/AiAgent/Types/AiAgent.php @@ -106,6 +106,7 @@ public function getSourceType(): ?string public function setSourceType(?string $value = null): self { $this->sourceType = $value; + $this->_setField('sourceType'); return $this; } @@ -123,6 +124,7 @@ public function getSourceTitle(): ?string public function setSourceTitle(?string $value = null): self { $this->sourceTitle = $value; + $this->_setField('sourceTitle'); return $this; } @@ -140,6 +142,7 @@ public function getLastAnswerType(): ?string public function setLastAnswerType(?string $value = null): self { $this->lastAnswerType = $value; + $this->_setField('lastAnswerType'); return $this; } @@ -157,6 +160,7 @@ public function getResolutionState(): ?string public function setResolutionState(?string $value = null): self { $this->resolutionState = $value; + $this->_setField('resolutionState'); return $this; } @@ -174,6 +178,7 @@ public function getRating(): ?int public function setRating(?int $value = null): self { $this->rating = $value; + $this->_setField('rating'); return $this; } @@ -191,6 +196,7 @@ public function getRatingRemark(): ?string public function setRatingRemark(?string $value = null): self { $this->ratingRemark = $value; + $this->_setField('ratingRemark'); return $this; } @@ -208,6 +214,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -225,6 +232,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -242,6 +250,7 @@ public function getContentSources(): ?ContentSourcesList public function setContentSources(?ContentSourcesList $value = null): self { $this->contentSources = $value; + $this->_setField('contentSources'); return $this; } diff --git a/src/Unstable/AiContent/AiContentClient.php b/src/Unstable/AiContent/AiContentClient.php index eaabfdf0..dd16dd50 100644 --- a/src/Unstable/AiContent/AiContentClient.php +++ b/src/Unstable/AiContent/AiContentClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\AiContent; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\AiContent\Types\ContentImportSourcesList; use Intercom\Exceptions\IntercomException; @@ -11,7 +11,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\AiContent\Requests\CreateContentImportSourceRequest; use Intercom\Unstable\AiContent\Types\ContentImportSource; @@ -64,6 +63,11 @@ public function __construct( /** * You can retrieve a list of all content import sources for a workspace. * + * Example: + * ```php + * $client->aiContent->listContentImportSources(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -72,11 +76,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContentImportSourcesList + * @return ?ContentImportSourcesList * @throws IntercomException * @throws IntercomApiException */ - public function listContentImportSources(?array $options = null): ContentImportSourcesList + public function listContentImportSources(?array $options = null): ?ContentImportSourcesList { $options = array_merge($this->options, $options ?? []); try { @@ -91,20 +95,13 @@ public function listContentImportSources(?array $options = null): ContentImportS $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -118,6 +115,16 @@ public function listContentImportSources(?array $options = null): ContentImportS /** * You can create a new content import source by sending a POST request to this endpoint. * + * Example: + * ```php + * $client->aiContent->createContentImportSource( + * new CreateContentImportSourceRequest([ + * 'syncBehavior' => 'api', + * 'url' => 'https://www.example.com', + * ]), + * ); + * ``` + * * @param CreateContentImportSourceRequest $request * @param ?array{ * baseUrl?: string, @@ -127,11 +134,11 @@ public function listContentImportSources(?array $options = null): ContentImportS * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContentImportSource + * @return ?ContentImportSource * @throws IntercomException * @throws IntercomApiException */ - public function createContentImportSource(CreateContentImportSourceRequest $request, ?array $options = null): ContentImportSource + public function createContentImportSource(CreateContentImportSourceRequest $request, ?array $options = null): ?ContentImportSource { $options = array_merge($this->options, $options ?? []); try { @@ -147,20 +154,13 @@ public function createContentImportSource(CreateContentImportSourceRequest $requ $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -172,6 +172,15 @@ public function createContentImportSource(CreateContentImportSourceRequest $requ } /** + * Example: + * ```php + * $client->unstable->aiContent->getContentImportSource( + * new GetContentImportSourceRequest([ + * 'id' => 'id', + * ]), + * ); + * ``` + * * @param GetContentImportSourceRequest $request * @param ?array{ * baseUrl?: string, @@ -181,18 +190,18 @@ public function createContentImportSource(CreateContentImportSourceRequest $requ * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContentImportSource + * @return ?ContentImportSource * @throws IntercomException * @throws IntercomApiException */ - public function getContentImportSource(GetContentImportSourceRequest $request, ?array $options = null): ContentImportSource + 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->getId()}", + path: "ai/content_import_sources/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::GET, ), $options, @@ -200,20 +209,13 @@ public function getContentImportSource(GetContentImportSourceRequest $request, ? $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -227,6 +229,17 @@ public function getContentImportSource(GetContentImportSourceRequest $request, ? /** * You can update an existing content import source. * + * Example: + * ```php + * $client->unstable->aiContent->updateContentImportSource( + * new UpdateContentImportSourceRequest([ + * 'id' => 'id', + * 'syncBehavior' => UpdateContentImportSourceRequestSyncBehavior::Api->value, + * 'url' => 'https://www.example.com', + * ]), + * ); + * ``` + * * @param UpdateContentImportSourceRequest $request * @param ?array{ * baseUrl?: string, @@ -236,18 +249,18 @@ public function getContentImportSource(GetContentImportSourceRequest $request, ? * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContentImportSource + * @return ?ContentImportSource * @throws IntercomException * @throws IntercomApiException */ - public function updateContentImportSource(UpdateContentImportSourceRequest $request, ?array $options = null): ContentImportSource + 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->getId()}", + path: "ai/content_import_sources/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::PUT, body: $request, ), @@ -256,20 +269,13 @@ public function updateContentImportSource(UpdateContentImportSourceRequest $requ $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -283,6 +289,15 @@ public function updateContentImportSource(UpdateContentImportSourceRequest $requ /** * 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. * + * Example: + * ```php + * $client->unstable->aiContent->deleteContentImportSource( + * new DeleteContentImportSourceRequest([ + * 'id' => 'id', + * ]), + * ); + * ``` + * * @param DeleteContentImportSourceRequest $request * @param ?array{ * baseUrl?: string, @@ -302,7 +317,7 @@ public function deleteContentImportSource(DeleteContentImportSourceRequest $requ $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "ai/content_import_sources/{$request->getId()}", + path: "ai/content_import_sources/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::DELETE, ), $options, @@ -311,16 +326,6 @@ public function deleteContentImportSource(DeleteContentImportSourceRequest $requ 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); } @@ -334,6 +339,11 @@ public function deleteContentImportSource(DeleteContentImportSourceRequest $requ /** * You can retrieve a list of all external pages for a workspace. * + * Example: + * ```php + * $client->aiContent->listExternalPages(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -342,11 +352,11 @@ public function deleteContentImportSource(DeleteContentImportSourceRequest $requ * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ExternalPagesList + * @return ?ExternalPagesList * @throws IntercomException * @throws IntercomApiException */ - public function listExternalPages(?array $options = null): ExternalPagesList + public function listExternalPages(?array $options = null): ?ExternalPagesList { $options = array_merge($this->options, $options ?? []); try { @@ -361,20 +371,13 @@ public function listExternalPages(?array $options = null): ExternalPagesList $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -388,6 +391,20 @@ public function listExternalPages(?array $options = null): ExternalPagesList /** * 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. * + * Example: + * ```php + * $client->aiContent->createExternalPage( + * new CreateExternalPageRequest([ + * 'title' => 'Test', + * 'html' => '

Test

', + * 'url' => 'https://www.example.com', + * 'locale' => 'en', + * 'sourceId' => 44, + * 'externalId' => 'abc1234', + * ]), + * ); + * ``` + * * @param CreateExternalPageRequest $request * @param ?array{ * baseUrl?: string, @@ -397,11 +414,11 @@ public function listExternalPages(?array $options = null): ExternalPagesList * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ExternalPage + * @return ?ExternalPage * @throws IntercomException * @throws IntercomApiException */ - public function createExternalPage(CreateExternalPageRequest $request, ?array $options = null): ExternalPage + public function createExternalPage(CreateExternalPageRequest $request, ?array $options = null): ?ExternalPage { $options = array_merge($this->options, $options ?? []); try { @@ -417,20 +434,13 @@ public function createExternalPage(CreateExternalPageRequest $request, ?array $o $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -444,6 +454,15 @@ public function createExternalPage(CreateExternalPageRequest $request, ?array $o /** * You can retrieve an external page. * + * Example: + * ```php + * $client->unstable->aiContent->getExternalPage( + * new GetExternalPageRequest([ + * 'id' => 'id', + * ]), + * ); + * ``` + * * @param GetExternalPageRequest $request * @param ?array{ * baseUrl?: string, @@ -453,18 +472,18 @@ public function createExternalPage(CreateExternalPageRequest $request, ?array $o * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ExternalPage + * @return ?ExternalPage * @throws IntercomException * @throws IntercomApiException */ - public function getExternalPage(GetExternalPageRequest $request, ?array $options = null): ExternalPage + 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->getId()}", + path: "ai/external_pages/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::GET, ), $options, @@ -472,20 +491,13 @@ public function getExternalPage(GetExternalPageRequest $request, ?array $options $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -499,6 +511,21 @@ public function getExternalPage(GetExternalPageRequest $request, ?array $options /** * You can update an existing external page (if it was created via the API). * + * Example: + * ```php + * $client->unstable->aiContent->updateExternalPage( + * new UpdateExternalPageRequest([ + * 'id' => 'id', + * 'title' => 'Test', + * 'html' => '

Test

', + * 'url' => 'https://www.example.com', + * 'locale' => 'en', + * 'sourceId' => 47, + * 'externalId' => '5678', + * ]), + * ); + * ``` + * * @param UpdateExternalPageRequest $request * @param ?array{ * baseUrl?: string, @@ -508,18 +535,18 @@ public function getExternalPage(GetExternalPageRequest $request, ?array $options * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ExternalPage + * @return ?ExternalPage * @throws IntercomException * @throws IntercomApiException */ - public function updateExternalPage(UpdateExternalPageRequest $request, ?array $options = null): ExternalPage + 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->getId()}", + path: "ai/external_pages/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::PUT, body: $request, ), @@ -528,20 +555,13 @@ public function updateExternalPage(UpdateExternalPageRequest $request, ?array $o $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -555,6 +575,15 @@ public function updateExternalPage(UpdateExternalPageRequest $request, ?array $o /** * Sending a DELETE request for an external page will remove it from the content library UI and from being used for AI answers. * + * Example: + * ```php + * $client->unstable->aiContent->deleteExternalPage( + * new DeleteExternalPageRequest([ + * 'id' => 'id', + * ]), + * ); + * ``` + * * @param DeleteExternalPageRequest $request * @param ?array{ * baseUrl?: string, @@ -564,18 +593,18 @@ public function updateExternalPage(UpdateExternalPageRequest $request, ?array $o * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ExternalPage + * @return ?ExternalPage * @throws IntercomException * @throws IntercomApiException */ - public function deleteExternalPage(DeleteExternalPageRequest $request, ?array $options = null): ExternalPage + 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->getId()}", + path: "ai/external_pages/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::DELETE, ), $options, @@ -583,20 +612,13 @@ public function deleteExternalPage(DeleteExternalPageRequest $request, ?array $o $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } diff --git a/src/Unstable/AiContent/Requests/CreateContentImportSourceRequest.php b/src/Unstable/AiContent/Requests/CreateContentImportSourceRequest.php index 5e072671..ab04f8f1 100644 --- a/src/Unstable/AiContent/Requests/CreateContentImportSourceRequest.php +++ b/src/Unstable/AiContent/Requests/CreateContentImportSourceRequest.php @@ -55,6 +55,7 @@ public function getSyncBehavior(): string public function setSyncBehavior(string $value): self { $this->syncBehavior = $value; + $this->_setField('syncBehavior'); return $this; } @@ -72,6 +73,7 @@ public function getStatus(): ?string public function setStatus(?string $value = null): self { $this->status = $value; + $this->_setField('status'); return $this; } @@ -89,6 +91,7 @@ public function getUrl(): string public function setUrl(string $value): self { $this->url = $value; + $this->_setField('url'); return $this; } } diff --git a/src/Unstable/AiContent/Requests/CreateExternalPageRequest.php b/src/Unstable/AiContent/Requests/CreateExternalPageRequest.php index ac5483f5..5deafcb5 100644 --- a/src/Unstable/AiContent/Requests/CreateExternalPageRequest.php +++ b/src/Unstable/AiContent/Requests/CreateExternalPageRequest.php @@ -94,6 +94,7 @@ public function getTitle(): string public function setTitle(string $value): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -111,6 +112,7 @@ public function getHtml(): string public function setHtml(string $value): self { $this->html = $value; + $this->_setField('html'); return $this; } @@ -128,6 +130,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -145,6 +148,7 @@ public function getAiAgentAvailability(): ?bool public function setAiAgentAvailability(?bool $value = null): self { $this->aiAgentAvailability = $value; + $this->_setField('aiAgentAvailability'); return $this; } @@ -162,6 +166,7 @@ public function getAiCopilotAvailability(): ?bool public function setAiCopilotAvailability(?bool $value = null): self { $this->aiCopilotAvailability = $value; + $this->_setField('aiCopilotAvailability'); return $this; } @@ -179,6 +184,7 @@ public function getLocale(): string public function setLocale(string $value): self { $this->locale = $value; + $this->_setField('locale'); return $this; } @@ -196,6 +202,7 @@ public function getSourceId(): int public function setSourceId(int $value): self { $this->sourceId = $value; + $this->_setField('sourceId'); return $this; } @@ -213,6 +220,7 @@ public function getExternalId(): string public function setExternalId(string $value): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } } diff --git a/src/Unstable/AiContent/Requests/DeleteContentImportSourceRequest.php b/src/Unstable/AiContent/Requests/DeleteContentImportSourceRequest.php index 6bd8981d..c3adefbf 100644 --- a/src/Unstable/AiContent/Requests/DeleteContentImportSourceRequest.php +++ b/src/Unstable/AiContent/Requests/DeleteContentImportSourceRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/AiContent/Requests/DeleteExternalPageRequest.php b/src/Unstable/AiContent/Requests/DeleteExternalPageRequest.php index 974e1dce..cb146def 100644 --- a/src/Unstable/AiContent/Requests/DeleteExternalPageRequest.php +++ b/src/Unstable/AiContent/Requests/DeleteExternalPageRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/AiContent/Requests/GetContentImportSourceRequest.php b/src/Unstable/AiContent/Requests/GetContentImportSourceRequest.php index 361237aa..4836fd08 100644 --- a/src/Unstable/AiContent/Requests/GetContentImportSourceRequest.php +++ b/src/Unstable/AiContent/Requests/GetContentImportSourceRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/AiContent/Requests/GetExternalPageRequest.php b/src/Unstable/AiContent/Requests/GetExternalPageRequest.php index 36b5fb3d..db548ecf 100644 --- a/src/Unstable/AiContent/Requests/GetExternalPageRequest.php +++ b/src/Unstable/AiContent/Requests/GetExternalPageRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/AiContent/Requests/UpdateContentImportSourceRequest.php b/src/Unstable/AiContent/Requests/UpdateContentImportSourceRequest.php index b5489ed1..08d87d92 100644 --- a/src/Unstable/AiContent/Requests/UpdateContentImportSourceRequest.php +++ b/src/Unstable/AiContent/Requests/UpdateContentImportSourceRequest.php @@ -63,6 +63,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -80,6 +81,7 @@ public function getSyncBehavior(): string public function setSyncBehavior(string $value): self { $this->syncBehavior = $value; + $this->_setField('syncBehavior'); return $this; } @@ -97,6 +99,7 @@ public function getStatus(): ?string public function setStatus(?string $value = null): self { $this->status = $value; + $this->_setField('status'); return $this; } @@ -114,6 +117,7 @@ public function getUrl(): string public function setUrl(string $value): self { $this->url = $value; + $this->_setField('url'); return $this; } } diff --git a/src/Unstable/AiContent/Requests/UpdateExternalPageRequest.php b/src/Unstable/AiContent/Requests/UpdateExternalPageRequest.php index 1f8567ef..d3f89cca 100644 --- a/src/Unstable/AiContent/Requests/UpdateExternalPageRequest.php +++ b/src/Unstable/AiContent/Requests/UpdateExternalPageRequest.php @@ -93,6 +93,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -110,6 +111,7 @@ public function getTitle(): string public function setTitle(string $value): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -127,6 +129,7 @@ public function getHtml(): string public function setHtml(string $value): self { $this->html = $value; + $this->_setField('html'); return $this; } @@ -144,6 +147,7 @@ public function getUrl(): string public function setUrl(string $value): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -161,6 +165,7 @@ public function getFinAvailability(): ?bool public function setFinAvailability(?bool $value = null): self { $this->finAvailability = $value; + $this->_setField('finAvailability'); return $this; } @@ -178,6 +183,7 @@ public function getLocale(): string public function setLocale(string $value): self { $this->locale = $value; + $this->_setField('locale'); return $this; } @@ -195,6 +201,7 @@ public function getSourceId(): int public function setSourceId(int $value): self { $this->sourceId = $value; + $this->_setField('sourceId'); return $this; } @@ -212,6 +219,7 @@ public function getExternalId(): ?string public function setExternalId(?string $value = null): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } } diff --git a/src/Unstable/AiContent/Types/ContentImportSource.php b/src/Unstable/AiContent/Types/ContentImportSource.php index 46694236..06026fa0 100644 --- a/src/Unstable/AiContent/Types/ContentImportSource.php +++ b/src/Unstable/AiContent/Types/ContentImportSource.php @@ -97,6 +97,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -114,6 +115,7 @@ public function getId(): int public function setId(int $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -131,6 +133,7 @@ public function getLastSyncedAt(): int public function setLastSyncedAt(int $value): self { $this->lastSyncedAt = $value; + $this->_setField('lastSyncedAt'); return $this; } @@ -148,6 +151,7 @@ public function getSyncBehavior(): string public function setSyncBehavior(string $value): self { $this->syncBehavior = $value; + $this->_setField('syncBehavior'); return $this; } @@ -165,6 +169,7 @@ public function getStatus(): string public function setStatus(string $value): self { $this->status = $value; + $this->_setField('status'); return $this; } @@ -182,6 +187,7 @@ public function getUrl(): string public function setUrl(string $value): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -199,6 +205,7 @@ public function getCreatedAt(): int public function setCreatedAt(int $value): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -216,6 +223,7 @@ public function getUpdatedAt(): int public function setUpdatedAt(int $value): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } diff --git a/src/Unstable/AiContent/Types/ContentImportSourcesList.php b/src/Unstable/AiContent/Types/ContentImportSourcesList.php index 7e0e28b5..d93e5677 100644 --- a/src/Unstable/AiContent/Types/ContentImportSourcesList.php +++ b/src/Unstable/AiContent/Types/ContentImportSourcesList.php @@ -67,6 +67,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -84,6 +85,7 @@ public function getPages(): ?PagesLink public function setPages(?PagesLink $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } @@ -101,6 +103,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -118,6 +121,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Unstable/AiContent/Types/ExternalPage.php b/src/Unstable/AiContent/Types/ExternalPage.php index ce4b946d..fbbb7335 100644 --- a/src/Unstable/AiContent/Types/ExternalPage.php +++ b/src/Unstable/AiContent/Types/ExternalPage.php @@ -145,6 +145,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -162,6 +163,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -179,6 +181,7 @@ public function getTitle(): string public function setTitle(string $value): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -196,6 +199,7 @@ public function getHtml(): string public function setHtml(string $value): self { $this->html = $value; + $this->_setField('html'); return $this; } @@ -213,6 +217,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -230,6 +235,7 @@ public function getAiAgentAvailability(): bool public function setAiAgentAvailability(bool $value): self { $this->aiAgentAvailability = $value; + $this->_setField('aiAgentAvailability'); return $this; } @@ -247,6 +253,7 @@ public function getAiCopilotAvailability(): bool public function setAiCopilotAvailability(bool $value): self { $this->aiCopilotAvailability = $value; + $this->_setField('aiCopilotAvailability'); return $this; } @@ -264,6 +271,7 @@ public function getFinAvailability(): ?bool public function setFinAvailability(?bool $value = null): self { $this->finAvailability = $value; + $this->_setField('finAvailability'); return $this; } @@ -281,6 +289,7 @@ public function getLocale(): string public function setLocale(string $value): self { $this->locale = $value; + $this->_setField('locale'); return $this; } @@ -298,6 +307,7 @@ public function getSourceId(): int public function setSourceId(int $value): self { $this->sourceId = $value; + $this->_setField('sourceId'); return $this; } @@ -315,6 +325,7 @@ public function getExternalId(): string public function setExternalId(string $value): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } @@ -332,6 +343,7 @@ public function getCreatedAt(): int public function setCreatedAt(int $value): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -349,6 +361,7 @@ public function getUpdatedAt(): int public function setUpdatedAt(int $value): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -366,6 +379,7 @@ public function getLastIngestedAt(): int public function setLastIngestedAt(int $value): self { $this->lastIngestedAt = $value; + $this->_setField('lastIngestedAt'); return $this; } diff --git a/src/Unstable/AiContent/Types/ExternalPagesList.php b/src/Unstable/AiContent/Types/ExternalPagesList.php index 087ed6c5..571016ac 100644 --- a/src/Unstable/AiContent/Types/ExternalPagesList.php +++ b/src/Unstable/AiContent/Types/ExternalPagesList.php @@ -67,6 +67,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -84,6 +85,7 @@ public function getPages(): ?PagesLink public function setPages(?PagesLink $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } @@ -101,6 +103,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -118,6 +121,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Unstable/AiContentSource/Types/ContentSource.php b/src/Unstable/AiContentSource/Types/ContentSource.php index b106283e..0be7431c 100644 --- a/src/Unstable/AiContentSource/Types/ContentSource.php +++ b/src/Unstable/AiContentSource/Types/ContentSource.php @@ -65,6 +65,7 @@ public function getContentType(): ?string public function setContentType(?string $value = null): self { $this->contentType = $value; + $this->_setField('contentType'); return $this; } @@ -82,6 +83,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -99,6 +101,7 @@ public function getTitle(): ?string public function setTitle(?string $value = null): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -116,6 +119,7 @@ public function getLocale(): ?string public function setLocale(?string $value = null): self { $this->locale = $value; + $this->_setField('locale'); return $this; } diff --git a/src/Unstable/Articles/ArticlesClient.php b/src/Unstable/Articles/ArticlesClient.php index 7afaeec2..d7cba2b4 100644 --- a/src/Unstable/Articles/ArticlesClient.php +++ b/src/Unstable/Articles/ArticlesClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\Articles; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\Types\ArticleList; use Intercom\Exceptions\IntercomException; @@ -11,7 +11,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\Articles\Types\Article; use Intercom\Unstable\Articles\Requests\RetrieveArticleRequest; @@ -63,6 +62,13 @@ public function __construct( * > * > Articles will be returned in descending order on the `updated_at` attribute. This means if you need to iterate through results then we'll show the most recently updated articles first. * + * Example: + * ```php + * $client->articles->list( + * new ListArticlesRequest([]), + * ); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -71,11 +77,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ArticleList + * @return ?ArticleList * @throws IntercomException * @throws IntercomApiException */ - public function listArticles(?array $options = null): ArticleList + public function listArticles(?array $options = null): ?ArticleList { $options = array_merge($this->options, $options ?? []); try { @@ -90,20 +96,13 @@ public function listArticles(?array $options = null): ArticleList $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ArticleList::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); } @@ -117,6 +116,15 @@ public function listArticles(?array $options = null): ArticleList /** * You can create a new article by making a POST request to `https://api.intercom.io/articles`. * + * Example: + * ```php + * $client->unstable->articles->createArticle( + * [ + * 'key' => "value", + * ], + * ); + * ``` + * * @param mixed $request * @param ?array{ * baseUrl?: string, @@ -126,11 +134,11 @@ public function listArticles(?array $options = null): ArticleList * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Article + * @return ?Article * @throws IntercomException * @throws IntercomApiException */ - public function createArticle(mixed $request, ?array $options = null): Article + public function createArticle(mixed $request, ?array $options = null): ?Article { $options = array_merge($this->options, $options ?? []); try { @@ -146,20 +154,13 @@ public function createArticle(mixed $request, ?array $options = null): Article $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Article::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); } @@ -173,6 +174,15 @@ public function createArticle(mixed $request, ?array $options = null): Article /** * You can fetch the details of a single article by making a GET request to `https://api.intercom.io/articles/`. * + * Example: + * ```php + * $client->unstable->articles->retrieveArticle( + * new RetrieveArticleRequest([ + * 'id' => 1, + * ]), + * ); + * ``` + * * @param RetrieveArticleRequest $request * @param ?array{ * baseUrl?: string, @@ -182,18 +192,18 @@ public function createArticle(mixed $request, ?array $options = null): Article * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Article + * @return ?Article * @throws IntercomException * @throws IntercomApiException */ - public function retrieveArticle(RetrieveArticleRequest $request, ?array $options = null): Article + public function retrieveArticle(RetrieveArticleRequest $request, ?array $options = null): ?Article { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "articles/{$request->getId()}", + path: "articles/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::GET, ), $options, @@ -201,20 +211,13 @@ public function retrieveArticle(RetrieveArticleRequest $request, ?array $options $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Article::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); } @@ -228,6 +231,15 @@ public function retrieveArticle(RetrieveArticleRequest $request, ?array $options /** * You can delete a single article by making a DELETE request to `https://api.intercom.io/articles/`. * + * Example: + * ```php + * $client->unstable->articles->deleteArticle( + * new DeleteArticleRequest([ + * 'id' => 1, + * ]), + * ); + * ``` + * * @param DeleteArticleRequest $request * @param ?array{ * baseUrl?: string, @@ -237,18 +249,18 @@ public function retrieveArticle(RetrieveArticleRequest $request, ?array $options * queryParameters?: array, * bodyProperties?: array, * } $options - * @return DeletedArticleObject + * @return ?DeletedArticleObject * @throws IntercomException * @throws IntercomApiException */ - public function deleteArticle(DeleteArticleRequest $request, ?array $options = null): DeletedArticleObject + public function deleteArticle(DeleteArticleRequest $request, ?array $options = null): ?DeletedArticleObject { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "articles/{$request->getId()}", + path: "articles/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::DELETE, ), $options, @@ -256,20 +268,13 @@ public function deleteArticle(DeleteArticleRequest $request, ?array $options = n $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return DeletedArticleObject::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); } @@ -283,6 +288,18 @@ public function deleteArticle(DeleteArticleRequest $request, ?array $options = n /** * You can search for articles by making a GET request to `https://api.intercom.io/articles/search`. * + * Example: + * ```php + * $client->articles->search( + * new SearchArticlesRequest([ + * 'phrase' => 'Getting started', + * 'state' => 'published', + * 'helpCenterId' => 1, + * 'highlight' => true, + * ]), + * ); + * ``` + * * @param SearchArticlesRequest $request * @param ?array{ * baseUrl?: string, @@ -292,11 +309,11 @@ public function deleteArticle(DeleteArticleRequest $request, ?array $options = n * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ArticleSearchResponse + * @return ?ArticleSearchResponse * @throws IntercomException * @throws IntercomApiException */ - public function searchArticles(SearchArticlesRequest $request = new SearchArticlesRequest(), ?array $options = null): ArticleSearchResponse + public function searchArticles(SearchArticlesRequest $request = new SearchArticlesRequest(), ?array $options = null): ?ArticleSearchResponse { $options = array_merge($this->options, $options ?? []); $query = []; @@ -325,20 +342,13 @@ public function searchArticles(SearchArticlesRequest $request = new SearchArticl $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ArticleSearchResponse::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); } diff --git a/src/Unstable/Articles/Requests/DeleteArticleRequest.php b/src/Unstable/Articles/Requests/DeleteArticleRequest.php index 4befcc80..cd1b7204 100644 --- a/src/Unstable/Articles/Requests/DeleteArticleRequest.php +++ b/src/Unstable/Articles/Requests/DeleteArticleRequest.php @@ -36,6 +36,7 @@ public function getId(): int public function setId(int $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Articles/Requests/RetrieveArticleRequest.php b/src/Unstable/Articles/Requests/RetrieveArticleRequest.php index ab29665b..aa83d5b9 100644 --- a/src/Unstable/Articles/Requests/RetrieveArticleRequest.php +++ b/src/Unstable/Articles/Requests/RetrieveArticleRequest.php @@ -36,6 +36,7 @@ public function getId(): int public function setId(int $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Articles/Requests/SearchArticlesRequest.php b/src/Unstable/Articles/Requests/SearchArticlesRequest.php index 7ee313c1..dafb340a 100644 --- a/src/Unstable/Articles/Requests/SearchArticlesRequest.php +++ b/src/Unstable/Articles/Requests/SearchArticlesRequest.php @@ -57,6 +57,7 @@ public function getPhrase(): ?string public function setPhrase(?string $value = null): self { $this->phrase = $value; + $this->_setField('phrase'); return $this; } @@ -74,6 +75,7 @@ public function getState(): ?string public function setState(?string $value = null): self { $this->state = $value; + $this->_setField('state'); return $this; } @@ -91,6 +93,7 @@ public function getHelpCenterId(): ?int public function setHelpCenterId(?int $value = null): self { $this->helpCenterId = $value; + $this->_setField('helpCenterId'); return $this; } @@ -108,6 +111,7 @@ public function getHighlight(): ?bool public function setHighlight(?bool $value = null): self { $this->highlight = $value; + $this->_setField('highlight'); return $this; } } diff --git a/src/Unstable/Articles/Traits/ArticleListItem.php b/src/Unstable/Articles/Traits/ArticleListItem.php index 62c492bc..4fcaed1d 100644 --- a/src/Unstable/Articles/Traits/ArticleListItem.php +++ b/src/Unstable/Articles/Traits/ArticleListItem.php @@ -139,6 +139,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -156,6 +157,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -173,6 +175,7 @@ public function getWorkspaceId(): ?string public function setWorkspaceId(?string $value = null): self { $this->workspaceId = $value; + $this->_setField('workspaceId'); return $this; } @@ -190,6 +193,7 @@ public function getTitle(): ?string public function setTitle(?string $value = null): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -207,6 +211,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -224,6 +229,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -241,6 +247,7 @@ public function getAuthorId(): ?int public function setAuthorId(?int $value = null): self { $this->authorId = $value; + $this->_setField('authorId'); return $this; } @@ -258,6 +265,7 @@ public function getState(): ?string public function setState(?string $value = null): self { $this->state = $value; + $this->_setField('state'); return $this; } @@ -275,6 +283,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -292,6 +301,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -309,6 +319,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -326,6 +337,7 @@ public function getParentId(): ?int public function setParentId(?int $value = null): self { $this->parentId = $value; + $this->_setField('parentId'); return $this; } @@ -343,6 +355,7 @@ public function getParentIds(): ?array public function setParentIds(?array $value = null): self { $this->parentIds = $value; + $this->_setField('parentIds'); return $this; } @@ -360,6 +373,7 @@ public function getParentType(): ?string public function setParentType(?string $value = null): self { $this->parentType = $value; + $this->_setField('parentType'); return $this; } @@ -377,6 +391,7 @@ public function getDefaultLocale(): ?string public function setDefaultLocale(?string $value = null): self { $this->defaultLocale = $value; + $this->_setField('defaultLocale'); return $this; } @@ -394,6 +409,7 @@ public function getTranslatedContent(): ?ArticleTranslatedContent public function setTranslatedContent(?ArticleTranslatedContent $value = null): self { $this->translatedContent = $value; + $this->_setField('translatedContent'); return $this; } } diff --git a/src/Unstable/Articles/Types/Article.php b/src/Unstable/Articles/Types/Article.php index 7f7f49e5..d8b02cf9 100644 --- a/src/Unstable/Articles/Types/Article.php +++ b/src/Unstable/Articles/Types/Article.php @@ -78,6 +78,7 @@ public function getStatistics(): ?ArticleStatistics public function setStatistics(?ArticleStatistics $value = null): self { $this->statistics = $value; + $this->_setField('statistics'); return $this; } diff --git a/src/Unstable/Articles/Types/ArticleListItem.php b/src/Unstable/Articles/Types/ArticleListItem.php index 8cb9aa67..893c4808 100644 --- a/src/Unstable/Articles/Types/ArticleListItem.php +++ b/src/Unstable/Articles/Types/ArticleListItem.php @@ -163,6 +163,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -180,6 +181,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -197,6 +199,7 @@ public function getWorkspaceId(): ?string public function setWorkspaceId(?string $value = null): self { $this->workspaceId = $value; + $this->_setField('workspaceId'); return $this; } @@ -214,6 +217,7 @@ public function getTitle(): ?string public function setTitle(?string $value = null): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -231,6 +235,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -248,6 +253,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -265,6 +271,7 @@ public function getAuthorId(): ?int public function setAuthorId(?int $value = null): self { $this->authorId = $value; + $this->_setField('authorId'); return $this; } @@ -282,6 +289,7 @@ public function getState(): ?string public function setState(?string $value = null): self { $this->state = $value; + $this->_setField('state'); return $this; } @@ -299,6 +307,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -316,6 +325,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -333,6 +343,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -350,6 +361,7 @@ public function getParentId(): ?int public function setParentId(?int $value = null): self { $this->parentId = $value; + $this->_setField('parentId'); return $this; } @@ -367,6 +379,7 @@ public function getParentIds(): ?array public function setParentIds(?array $value = null): self { $this->parentIds = $value; + $this->_setField('parentIds'); return $this; } @@ -384,6 +397,7 @@ public function getParentType(): ?string public function setParentType(?string $value = null): self { $this->parentType = $value; + $this->_setField('parentType'); return $this; } @@ -401,6 +415,7 @@ public function getDefaultLocale(): ?string public function setDefaultLocale(?string $value = null): self { $this->defaultLocale = $value; + $this->_setField('defaultLocale'); return $this; } @@ -418,6 +433,7 @@ public function getTranslatedContent(): ?ArticleTranslatedContent public function setTranslatedContent(?ArticleTranslatedContent $value = null): self { $this->translatedContent = $value; + $this->_setField('translatedContent'); return $this; } diff --git a/src/Unstable/Articles/Types/ArticleSearchHighlights.php b/src/Unstable/Articles/Types/ArticleSearchHighlights.php index 809b93f0..d97ecdc9 100644 --- a/src/Unstable/Articles/Types/ArticleSearchHighlights.php +++ b/src/Unstable/Articles/Types/ArticleSearchHighlights.php @@ -58,6 +58,7 @@ public function getArticleId(): ?string public function setArticleId(?string $value = null): self { $this->articleId = $value; + $this->_setField('articleId'); return $this; } @@ -75,6 +76,7 @@ public function getHighlightedTitle(): ?array public function setHighlightedTitle(?array $value = null): self { $this->highlightedTitle = $value; + $this->_setField('highlightedTitle'); return $this; } @@ -92,6 +94,7 @@ public function getHighlightedSummary(): ?array public function setHighlightedSummary(?array $value = null): self { $this->highlightedSummary = $value; + $this->_setField('highlightedSummary'); return $this; } diff --git a/src/Unstable/Articles/Types/ArticleSearchHighlightsHighlightedSummaryItemItem.php b/src/Unstable/Articles/Types/ArticleSearchHighlightsHighlightedSummaryItemItem.php index f7265af6..474bf416 100644 --- a/src/Unstable/Articles/Types/ArticleSearchHighlightsHighlightedSummaryItemItem.php +++ b/src/Unstable/Articles/Types/ArticleSearchHighlightsHighlightedSummaryItemItem.php @@ -49,6 +49,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -66,6 +67,7 @@ public function getText(): ?string public function setText(?string $value = null): self { $this->text = $value; + $this->_setField('text'); return $this; } diff --git a/src/Unstable/Articles/Types/ArticleSearchHighlightsHighlightedTitleItem.php b/src/Unstable/Articles/Types/ArticleSearchHighlightsHighlightedTitleItem.php index 1541e46f..4fad3146 100644 --- a/src/Unstable/Articles/Types/ArticleSearchHighlightsHighlightedTitleItem.php +++ b/src/Unstable/Articles/Types/ArticleSearchHighlightsHighlightedTitleItem.php @@ -49,6 +49,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -66,6 +67,7 @@ public function getText(): ?string public function setText(?string $value = null): self { $this->text = $value; + $this->_setField('text'); return $this; } diff --git a/src/Unstable/Articles/Types/ArticleSearchResponse.php b/src/Unstable/Articles/Types/ArticleSearchResponse.php index e23230e2..98aa12a8 100644 --- a/src/Unstable/Articles/Types/ArticleSearchResponse.php +++ b/src/Unstable/Articles/Types/ArticleSearchResponse.php @@ -66,6 +66,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -83,6 +84,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -100,6 +102,7 @@ public function getData(): ?ArticleSearchResponseData public function setData(?ArticleSearchResponseData $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } @@ -117,6 +120,7 @@ public function getPages(): ?CursorPages public function setPages(?CursorPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } diff --git a/src/Unstable/Articles/Types/ArticleSearchResponseData.php b/src/Unstable/Articles/Types/ArticleSearchResponseData.php index b8e94e7e..3bd8c5db 100644 --- a/src/Unstable/Articles/Types/ArticleSearchResponseData.php +++ b/src/Unstable/Articles/Types/ArticleSearchResponseData.php @@ -50,6 +50,7 @@ public function getArticles(): ?array public function setArticles(?array $value = null): self { $this->articles = $value; + $this->_setField('articles'); return $this; } @@ -67,6 +68,7 @@ public function getHighlights(): ?array public function setHighlights(?array $value = null): self { $this->highlights = $value; + $this->_setField('highlights'); return $this; } diff --git a/src/Unstable/AwayStatusReasons/AwayStatusReasonsClient.php b/src/Unstable/AwayStatusReasons/AwayStatusReasonsClient.php index 01c1bf67..70cb20c0 100644 --- a/src/Unstable/AwayStatusReasons/AwayStatusReasonsClient.php +++ b/src/Unstable/AwayStatusReasons/AwayStatusReasonsClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\AwayStatusReasons; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\Types\AwayStatusReason; use Intercom\Exceptions\IntercomException; @@ -12,7 +12,6 @@ use Intercom\Core\Client\HttpMethod; use Intercom\Core\Json\JsonDecoder; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class AwayStatusReasonsClient @@ -54,6 +53,11 @@ public function __construct( /** * Returns a list of all away status reasons configured for the workspace, including deleted ones. * + * Example: + * ```php + * $client->awayStatusReasons->listAwayStatusReasons(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -62,11 +66,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return array + * @return ?array * @throws IntercomException * @throws IntercomApiException */ - public function listAwayStatusReasons(?array $options = null): array + public function listAwayStatusReasons(?array $options = null): ?array { $options = array_merge($this->options, $options ?? []); try { @@ -81,20 +85,13 @@ public function listAwayStatusReasons(?array $options = null): array $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } diff --git a/src/Unstable/Brands/BrandsClient.php b/src/Unstable/Brands/BrandsClient.php index 0143e8c5..9c9f8c69 100644 --- a/src/Unstable/Brands/BrandsClient.php +++ b/src/Unstable/Brands/BrandsClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\Brands; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\Brands\Types\BrandList; use Intercom\Exceptions\IntercomException; @@ -11,7 +11,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\Brands\Requests\RetrieveBrandRequest; use Intercom\Unstable\Brands\Types\Brand; @@ -56,6 +55,11 @@ public function __construct( * Retrieves all brands for the workspace, including the default brand. * The default brand id always matches the workspace * + * Example: + * ```php + * $client->unstable->brands->listBrands(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -64,11 +68,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return BrandList + * @return ?BrandList * @throws IntercomException * @throws IntercomApiException */ - public function listBrands(?array $options = null): BrandList + public function listBrands(?array $options = null): ?BrandList { $options = array_merge($this->options, $options ?? []); try { @@ -83,20 +87,13 @@ public function listBrands(?array $options = null): BrandList $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -110,6 +107,15 @@ public function listBrands(?array $options = null): BrandList /** * Fetches a specific brand by its unique identifier * + * Example: + * ```php + * $client->unstable->brands->retrieveBrand( + * new RetrieveBrandRequest([ + * 'id' => 'id', + * ]), + * ); + * ``` + * * @param RetrieveBrandRequest $request * @param ?array{ * baseUrl?: string, @@ -119,18 +125,18 @@ public function listBrands(?array $options = null): BrandList * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Brand + * @return ?Brand * @throws IntercomException * @throws IntercomApiException */ - public function retrieveBrand(RetrieveBrandRequest $request, ?array $options = null): Brand + 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()}", + path: "brands/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::GET, ), $options, @@ -138,20 +144,13 @@ public function retrieveBrand(RetrieveBrandRequest $request, ?array $options = n $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } diff --git a/src/Unstable/Brands/Requests/RetrieveBrandRequest.php b/src/Unstable/Brands/Requests/RetrieveBrandRequest.php index 43412678..2d4b3411 100644 --- a/src/Unstable/Brands/Requests/RetrieveBrandRequest.php +++ b/src/Unstable/Brands/Requests/RetrieveBrandRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Brands/Types/Brand.php b/src/Unstable/Brands/Types/Brand.php index e1206d20..81e4835e 100644 --- a/src/Unstable/Brands/Types/Brand.php +++ b/src/Unstable/Brands/Types/Brand.php @@ -97,6 +97,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -114,6 +115,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -131,6 +133,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -148,6 +151,7 @@ public function getIsDefault(): ?bool public function setIsDefault(?bool $value = null): self { $this->isDefault = $value; + $this->_setField('isDefault'); return $this; } @@ -165,6 +169,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -182,6 +187,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -199,6 +205,7 @@ public function getHelpCenterId(): ?string public function setHelpCenterId(?string $value = null): self { $this->helpCenterId = $value; + $this->_setField('helpCenterId'); return $this; } @@ -216,6 +223,7 @@ public function getDefaultAddressSettingsId(): ?string public function setDefaultAddressSettingsId(?string $value = null): self { $this->defaultAddressSettingsId = $value; + $this->_setField('defaultAddressSettingsId'); return $this; } diff --git a/src/Unstable/Brands/Types/BrandList.php b/src/Unstable/Brands/Types/BrandList.php index 90cade1e..6477af32 100644 --- a/src/Unstable/Brands/Types/BrandList.php +++ b/src/Unstable/Brands/Types/BrandList.php @@ -50,6 +50,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -67,6 +68,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Unstable/Calls/CallsClient.php b/src/Unstable/Calls/CallsClient.php index 6f857f88..92820405 100644 --- a/src/Unstable/Calls/CallsClient.php +++ b/src/Unstable/Calls/CallsClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\Calls; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\Calls\Requests\ListCallsRequest; use Intercom\Unstable\Types\CallList; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\Calls\Requests\ShowCallRequest; use Intercom\Unstable\Calls\Types\Call; @@ -66,6 +65,16 @@ public function __construct( /** * Retrieve a paginated list of calls. * + * Example: + * ```php + * $client->calls->listCalls( + * new ListCallsRequest([ + * 'page' => 1, + * 'perPage' => 1, + * ]), + * ); + * ``` + * * @param ListCallsRequest $request * @param ?array{ * baseUrl?: string, @@ -75,11 +84,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return CallList + * @return ?CallList * @throws IntercomException * @throws IntercomApiException */ - public function listCalls(ListCallsRequest $request = new ListCallsRequest(), ?array $options = null): CallList + public function listCalls(ListCallsRequest $request = new ListCallsRequest(), ?array $options = null): ?CallList { $options = array_merge($this->options, $options ?? []); $query = []; @@ -102,20 +111,13 @@ public function listCalls(ListCallsRequest $request = new ListCallsRequest(), ?a $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -129,6 +131,15 @@ public function listCalls(ListCallsRequest $request = new ListCallsRequest(), ?a /** * Retrieve a single call by id. * + * Example: + * ```php + * $client->unstable->calls->showCall( + * new ShowCallRequest([ + * 'id' => 'id', + * ]), + * ); + * ``` + * * @param ShowCallRequest $request * @param ?array{ * baseUrl?: string, @@ -138,18 +149,18 @@ public function listCalls(ListCallsRequest $request = new ListCallsRequest(), ?a * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Call + * @return ?Call * @throws IntercomException * @throws IntercomApiException */ - public function showCall(ShowCallRequest $request, ?array $options = null): Call + 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()}", + path: "calls/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::GET, ), $options, @@ -157,20 +168,13 @@ public function showCall(ShowCallRequest $request, ?array $options = null): Call $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -184,6 +188,15 @@ public function showCall(ShowCallRequest $request, ?array $options = null): Call /** * Redirects to a signed URL for the call's recording if it exists. * + * Example: + * ```php + * $client->unstable->calls->showCallRecording( + * new ShowCallRecordingRequest([ + * 'id' => 'id', + * ]), + * ); + * ``` + * * @param ShowCallRecordingRequest $request * @param ?array{ * baseUrl?: string, @@ -203,7 +216,7 @@ public function showCallRecording(ShowCallRecordingRequest $request, ?array $opt $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "calls/{$request->getId()}/recording", + path: "calls/" . RawClient::encodePathParam($request->getId()) . "/recording", method: HttpMethod::GET, ), $options, @@ -212,16 +225,6 @@ public function showCallRecording(ShowCallRecordingRequest $request, ?array $opt 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); } @@ -235,6 +238,15 @@ public function showCallRecording(ShowCallRecordingRequest $request, ?array $opt /** * Returns the transcript for the specified call as a downloadable text file. * + * Example: + * ```php + * $client->unstable->calls->showCallTranscript( + * new ShowCallTranscriptRequest([ + * 'id' => 'id', + * ]), + * ); + * ``` + * * @param ShowCallTranscriptRequest $request * @param ?array{ * baseUrl?: string, @@ -255,7 +267,7 @@ public function showCallTranscript(ShowCallTranscriptRequest $request, ?array $o $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "calls/{$request->getId()}/transcript", + path: "calls/" . RawClient::encodePathParam($request->getId()) . "/transcript", method: HttpMethod::GET, ), $options, @@ -264,16 +276,6 @@ public function showCallTranscript(ShowCallTranscriptRequest $request, ?array $o 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); } @@ -288,6 +290,18 @@ public function showCallTranscript(ShowCallTranscriptRequest $request, ?array $o * 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. * + * Example: + * ```php + * $client->calls->listCallsWithTranscripts( + * new ListCallsWithTranscriptsRequest([ + * 'conversationIds' => [ + * '64619700005694', + * '64619700005695', + * ], + * ]), + * ); + * ``` + * * @param ListCallsWithTranscriptsRequest $request * @param ?array{ * baseUrl?: string, @@ -297,11 +311,11 @@ public function showCallTranscript(ShowCallTranscriptRequest $request, ?array $o * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ListCallsWithTranscriptsResponse + * @return ?ListCallsWithTranscriptsResponse * @throws IntercomException * @throws IntercomApiException */ - public function listCallsWithTranscripts(ListCallsWithTranscriptsRequest $request, ?array $options = null): ListCallsWithTranscriptsResponse + public function listCallsWithTranscripts(ListCallsWithTranscriptsRequest $request, ?array $options = null): ?ListCallsWithTranscriptsResponse { $options = array_merge($this->options, $options ?? []); try { @@ -317,20 +331,13 @@ public function listCallsWithTranscripts(ListCallsWithTranscriptsRequest $reques $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -350,6 +357,16 @@ public function listCallsWithTranscripts(ListCallsWithTranscriptsRequest $reques * - Five9 * - Zoom Phone * + * Example: + * ```php + * $client->unstable->calls->registerFinVoiceCall( + * new RegisterFinVoiceCallRequest([ + * 'phoneNumber' => '+1234567890', + * 'callId' => 'call-123-abc', + * ]), + * ); + * ``` + * * @param ?RegisterFinVoiceCallRequest $request * @param ?array{ * baseUrl?: string, @@ -359,11 +376,11 @@ public function listCallsWithTranscripts(ListCallsWithTranscriptsRequest $reques * queryParameters?: array, * bodyProperties?: array, * } $options - * @return AiCallResponse + * @return ?AiCallResponse * @throws IntercomException * @throws IntercomApiException */ - public function registerFinVoiceCall(?RegisterFinVoiceCallRequest $request = null, ?array $options = null): AiCallResponse + public function registerFinVoiceCall(?RegisterFinVoiceCallRequest $request = null, ?array $options = null): ?AiCallResponse { $options = array_merge($this->options, $options ?? []); try { @@ -379,20 +396,13 @@ public function registerFinVoiceCall(?RegisterFinVoiceCallRequest $request = nul $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return AiCallResponse::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); } @@ -406,6 +416,15 @@ public function registerFinVoiceCall(?RegisterFinVoiceCallRequest $request = nul /** * Retrieve information about a Fin Voice call using the external reference ID. * + * Example: + * ```php + * $client->unstable->calls->collectFinVoiceCallById( + * new CollectFinVoiceCallByIdRequest([ + * 'id' => 1, + * ]), + * ); + * ``` + * * @param CollectFinVoiceCallByIdRequest $request * @param ?array{ * baseUrl?: string, @@ -415,18 +434,18 @@ public function registerFinVoiceCall(?RegisterFinVoiceCallRequest $request = nul * queryParameters?: array, * bodyProperties?: array, * } $options - * @return AiCallResponse + * @return ?AiCallResponse * @throws IntercomException * @throws IntercomApiException */ - public function collectFinVoiceCallById(CollectFinVoiceCallByIdRequest $request, ?array $options = null): AiCallResponse + public function collectFinVoiceCallById(CollectFinVoiceCallByIdRequest $request, ?array $options = null): ?AiCallResponse { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "fin_voice/collect/{$request->getId()}", + path: "fin_voice/collect/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::GET, ), $options, @@ -434,20 +453,13 @@ public function collectFinVoiceCallById(CollectFinVoiceCallByIdRequest $request, $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return AiCallResponse::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); } @@ -461,6 +473,15 @@ public function collectFinVoiceCallById(CollectFinVoiceCallByIdRequest $request, /** * Retrieve information about a Fin Voice call using the external call identifier. * + * Example: + * ```php + * $client->unstable->calls->collectFinVoiceCallByExternalId( + * new CollectFinVoiceCallByExternalIdRequest([ + * 'externalId' => 'external_id', + * ]), + * ); + * ``` + * * @param CollectFinVoiceCallByExternalIdRequest $request * @param ?array{ * baseUrl?: string, @@ -470,18 +491,18 @@ public function collectFinVoiceCallById(CollectFinVoiceCallByIdRequest $request, * queryParameters?: array, * bodyProperties?: array, * } $options - * @return AiCallResponse + * @return ?AiCallResponse * @throws IntercomException * @throws IntercomApiException */ - public function collectFinVoiceCallByExternalId(CollectFinVoiceCallByExternalIdRequest $request, ?array $options = null): AiCallResponse + public function collectFinVoiceCallByExternalId(CollectFinVoiceCallByExternalIdRequest $request, ?array $options = null): ?AiCallResponse { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "fin_voice/external_id/{$request->getExternalId()}", + path: "fin_voice/external_id/" . RawClient::encodePathParam($request->getExternalId()), method: HttpMethod::GET, ), $options, @@ -489,20 +510,13 @@ public function collectFinVoiceCallByExternalId(CollectFinVoiceCallByExternalIdR $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return AiCallResponse::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); } @@ -518,6 +532,15 @@ public function collectFinVoiceCallByExternalId(CollectFinVoiceCallByExternalIdR * * Returns the most recent matched call for the given phone number, ordered by creation date. * + * Example: + * ```php + * $client->unstable->calls->collectFinVoiceCallByPhoneNumber( + * new CollectFinVoiceCallByPhoneNumberRequest([ + * 'phoneNumber' => 'phone_number', + * ]), + * ); + * ``` + * * @param CollectFinVoiceCallByPhoneNumberRequest $request * @param ?array{ * baseUrl?: string, @@ -527,18 +550,18 @@ public function collectFinVoiceCallByExternalId(CollectFinVoiceCallByExternalIdR * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Error + * @return ?Error * @throws IntercomException * @throws IntercomApiException */ - public function collectFinVoiceCallByPhoneNumber(CollectFinVoiceCallByPhoneNumberRequest $request, ?array $options = null): Error + public function collectFinVoiceCallByPhoneNumber(CollectFinVoiceCallByPhoneNumberRequest $request, ?array $options = null): ?Error { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "fin_voice/phone_number/{$request->getPhoneNumber()}", + path: "fin_voice/phone_number/" . RawClient::encodePathParam($request->getPhoneNumber()), method: HttpMethod::GET, ), $options, @@ -546,20 +569,13 @@ public function collectFinVoiceCallByPhoneNumber(CollectFinVoiceCallByPhoneNumbe $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Error::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); } diff --git a/src/Unstable/Calls/Requests/CollectFinVoiceCallByExternalIdRequest.php b/src/Unstable/Calls/Requests/CollectFinVoiceCallByExternalIdRequest.php index 84f9a021..54695c28 100644 --- a/src/Unstable/Calls/Requests/CollectFinVoiceCallByExternalIdRequest.php +++ b/src/Unstable/Calls/Requests/CollectFinVoiceCallByExternalIdRequest.php @@ -36,6 +36,7 @@ public function getExternalId(): string public function setExternalId(string $value): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } } diff --git a/src/Unstable/Calls/Requests/CollectFinVoiceCallByIdRequest.php b/src/Unstable/Calls/Requests/CollectFinVoiceCallByIdRequest.php index f2412a64..85a22e48 100644 --- a/src/Unstable/Calls/Requests/CollectFinVoiceCallByIdRequest.php +++ b/src/Unstable/Calls/Requests/CollectFinVoiceCallByIdRequest.php @@ -36,6 +36,7 @@ public function getId(): int public function setId(int $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Calls/Requests/CollectFinVoiceCallByPhoneNumberRequest.php b/src/Unstable/Calls/Requests/CollectFinVoiceCallByPhoneNumberRequest.php index 490d628e..d3466d28 100644 --- a/src/Unstable/Calls/Requests/CollectFinVoiceCallByPhoneNumberRequest.php +++ b/src/Unstable/Calls/Requests/CollectFinVoiceCallByPhoneNumberRequest.php @@ -36,6 +36,7 @@ public function getPhoneNumber(): string public function setPhoneNumber(string $value): self { $this->phoneNumber = $value; + $this->_setField('phoneNumber'); return $this; } } diff --git a/src/Unstable/Calls/Requests/ListCallsRequest.php b/src/Unstable/Calls/Requests/ListCallsRequest.php index 69cf13c8..0bd3603f 100644 --- a/src/Unstable/Calls/Requests/ListCallsRequest.php +++ b/src/Unstable/Calls/Requests/ListCallsRequest.php @@ -43,6 +43,7 @@ public function getPage(): ?int public function setPage(?int $value = null): self { $this->page = $value; + $this->_setField('page'); return $this; } @@ -60,6 +61,7 @@ public function getPerPage(): ?int public function setPerPage(?int $value = null): self { $this->perPage = $value; + $this->_setField('perPage'); return $this; } } diff --git a/src/Unstable/Calls/Requests/ListCallsWithTranscriptsRequest.php b/src/Unstable/Calls/Requests/ListCallsWithTranscriptsRequest.php index 58d704a4..b98d0dba 100644 --- a/src/Unstable/Calls/Requests/ListCallsWithTranscriptsRequest.php +++ b/src/Unstable/Calls/Requests/ListCallsWithTranscriptsRequest.php @@ -39,6 +39,7 @@ public function getConversationIds(): array public function setConversationIds(array $value): self { $this->conversationIds = $value; + $this->_setField('conversationIds'); return $this; } } diff --git a/src/Unstable/Calls/Requests/ShowCallRecordingRequest.php b/src/Unstable/Calls/Requests/ShowCallRecordingRequest.php index 71adbfea..db2fa39e 100644 --- a/src/Unstable/Calls/Requests/ShowCallRecordingRequest.php +++ b/src/Unstable/Calls/Requests/ShowCallRecordingRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Calls/Requests/ShowCallRequest.php b/src/Unstable/Calls/Requests/ShowCallRequest.php index f571778b..072e6394 100644 --- a/src/Unstable/Calls/Requests/ShowCallRequest.php +++ b/src/Unstable/Calls/Requests/ShowCallRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Calls/Requests/ShowCallTranscriptRequest.php b/src/Unstable/Calls/Requests/ShowCallTranscriptRequest.php index a5b7e883..eaa0d3be 100644 --- a/src/Unstable/Calls/Requests/ShowCallTranscriptRequest.php +++ b/src/Unstable/Calls/Requests/ShowCallTranscriptRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Calls/Traits/Call.php b/src/Unstable/Calls/Traits/Call.php index f056d4d7..79f93301 100644 --- a/src/Unstable/Calls/Traits/Call.php +++ b/src/Unstable/Calls/Traits/Call.php @@ -189,6 +189,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -206,6 +207,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -223,6 +225,7 @@ public function getConversationId(): ?string public function setConversationId(?string $value = null): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } @@ -240,6 +243,7 @@ public function getAdminId(): ?string public function setAdminId(?string $value = null): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } @@ -257,6 +261,7 @@ public function getContactId(): ?string public function setContactId(?string $value = null): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } @@ -274,6 +279,7 @@ public function getState(): ?string public function setState(?string $value = null): self { $this->state = $value; + $this->_setField('state'); return $this; } @@ -297,6 +303,7 @@ public function getInitiatedAt(): DateTime|int|null public function setInitiatedAt(DateTime|int|null $value = null): self { $this->initiatedAt = $value; + $this->_setField('initiatedAt'); return $this; } @@ -320,6 +327,7 @@ public function getAnsweredAt(): DateTime|int|null public function setAnsweredAt(DateTime|int|null $value = null): self { $this->answeredAt = $value; + $this->_setField('answeredAt'); return $this; } @@ -343,6 +351,7 @@ public function getEndedAt(): DateTime|int|null public function setEndedAt(DateTime|int|null $value = null): self { $this->endedAt = $value; + $this->_setField('endedAt'); return $this; } @@ -366,6 +375,7 @@ public function getCreatedAt(): DateTime|int|null public function setCreatedAt(DateTime|int|null $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -389,6 +399,7 @@ public function getUpdatedAt(): DateTime|int|null public function setUpdatedAt(DateTime|int|null $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -406,6 +417,7 @@ public function getRecordingUrl(): ?string public function setRecordingUrl(?string $value = null): self { $this->recordingUrl = $value; + $this->_setField('recordingUrl'); return $this; } @@ -423,6 +435,7 @@ public function getTranscriptionUrl(): ?string public function setTranscriptionUrl(?string $value = null): self { $this->transcriptionUrl = $value; + $this->_setField('transcriptionUrl'); return $this; } @@ -440,6 +453,7 @@ public function getCallType(): ?string public function setCallType(?string $value = null): self { $this->callType = $value; + $this->_setField('callType'); return $this; } @@ -457,6 +471,7 @@ public function getDirection(): ?string public function setDirection(?string $value = null): self { $this->direction = $value; + $this->_setField('direction'); return $this; } @@ -474,6 +489,7 @@ public function getEndedReason(): ?string public function setEndedReason(?string $value = null): self { $this->endedReason = $value; + $this->_setField('endedReason'); return $this; } @@ -491,6 +507,7 @@ public function getPhone(): ?string public function setPhone(?string $value = null): self { $this->phone = $value; + $this->_setField('phone'); return $this; } @@ -508,6 +525,7 @@ public function getFinRecordingUrl(): ?string public function setFinRecordingUrl(?string $value = null): self { $this->finRecordingUrl = $value; + $this->_setField('finRecordingUrl'); return $this; } @@ -525,6 +543,7 @@ public function getFinTranscriptionUrl(): ?string public function setFinTranscriptionUrl(?string $value = null): self { $this->finTranscriptionUrl = $value; + $this->_setField('finTranscriptionUrl'); return $this; } } diff --git a/src/Unstable/Calls/Types/Call.php b/src/Unstable/Calls/Types/Call.php index 7c9183b2..5c063c72 100644 --- a/src/Unstable/Calls/Types/Call.php +++ b/src/Unstable/Calls/Types/Call.php @@ -217,6 +217,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -234,6 +235,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -251,6 +253,7 @@ public function getConversationId(): ?string public function setConversationId(?string $value = null): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } @@ -268,6 +271,7 @@ public function getAdminId(): ?string public function setAdminId(?string $value = null): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } @@ -285,6 +289,7 @@ public function getContactId(): ?string public function setContactId(?string $value = null): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } @@ -302,6 +307,7 @@ public function getState(): ?string public function setState(?string $value = null): self { $this->state = $value; + $this->_setField('state'); return $this; } @@ -325,6 +331,7 @@ public function getInitiatedAt(): DateTime|int|null public function setInitiatedAt(DateTime|int|null $value = null): self { $this->initiatedAt = $value; + $this->_setField('initiatedAt'); return $this; } @@ -348,6 +355,7 @@ public function getAnsweredAt(): DateTime|int|null public function setAnsweredAt(DateTime|int|null $value = null): self { $this->answeredAt = $value; + $this->_setField('answeredAt'); return $this; } @@ -371,6 +379,7 @@ public function getEndedAt(): DateTime|int|null public function setEndedAt(DateTime|int|null $value = null): self { $this->endedAt = $value; + $this->_setField('endedAt'); return $this; } @@ -394,6 +403,7 @@ public function getCreatedAt(): DateTime|int|null public function setCreatedAt(DateTime|int|null $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -417,6 +427,7 @@ public function getUpdatedAt(): DateTime|int|null public function setUpdatedAt(DateTime|int|null $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -434,6 +445,7 @@ public function getRecordingUrl(): ?string public function setRecordingUrl(?string $value = null): self { $this->recordingUrl = $value; + $this->_setField('recordingUrl'); return $this; } @@ -451,6 +463,7 @@ public function getTranscriptionUrl(): ?string public function setTranscriptionUrl(?string $value = null): self { $this->transcriptionUrl = $value; + $this->_setField('transcriptionUrl'); return $this; } @@ -468,6 +481,7 @@ public function getCallType(): ?string public function setCallType(?string $value = null): self { $this->callType = $value; + $this->_setField('callType'); return $this; } @@ -485,6 +499,7 @@ public function getDirection(): ?string public function setDirection(?string $value = null): self { $this->direction = $value; + $this->_setField('direction'); return $this; } @@ -502,6 +517,7 @@ public function getEndedReason(): ?string public function setEndedReason(?string $value = null): self { $this->endedReason = $value; + $this->_setField('endedReason'); return $this; } @@ -519,6 +535,7 @@ public function getPhone(): ?string public function setPhone(?string $value = null): self { $this->phone = $value; + $this->_setField('phone'); return $this; } @@ -536,6 +553,7 @@ public function getFinRecordingUrl(): ?string public function setFinRecordingUrl(?string $value = null): self { $this->finRecordingUrl = $value; + $this->_setField('finRecordingUrl'); return $this; } @@ -553,6 +571,7 @@ public function getFinTranscriptionUrl(): ?string public function setFinTranscriptionUrl(?string $value = null): self { $this->finTranscriptionUrl = $value; + $this->_setField('finTranscriptionUrl'); return $this; } diff --git a/src/Unstable/Calls/Types/ListCallsWithTranscriptsResponse.php b/src/Unstable/Calls/Types/ListCallsWithTranscriptsResponse.php index 1852a5c8..5db20b0f 100644 --- a/src/Unstable/Calls/Types/ListCallsWithTranscriptsResponse.php +++ b/src/Unstable/Calls/Types/ListCallsWithTranscriptsResponse.php @@ -47,6 +47,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -64,6 +65,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Unstable/Calls/Types/ListCallsWithTranscriptsResponseDataItem.php b/src/Unstable/Calls/Types/ListCallsWithTranscriptsResponseDataItem.php index 2f1b4f34..0a7e2ac5 100644 --- a/src/Unstable/Calls/Types/ListCallsWithTranscriptsResponseDataItem.php +++ b/src/Unstable/Calls/Types/ListCallsWithTranscriptsResponseDataItem.php @@ -104,6 +104,7 @@ public function getTranscript(): ?array public function setTranscript(?array $value = null): self { $this->transcript = $value; + $this->_setField('transcript'); return $this; } @@ -121,6 +122,7 @@ public function getTranscriptStatus(): ?string public function setTranscriptStatus(?string $value = null): self { $this->transcriptStatus = $value; + $this->_setField('transcriptStatus'); return $this; } diff --git a/src/Unstable/Companies/CompaniesClient.php b/src/Unstable/Companies/CompaniesClient.php index 85ddb55c..039304b5 100644 --- a/src/Unstable/Companies/CompaniesClient.php +++ b/src/Unstable/Companies/CompaniesClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\Companies; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\Companies\Requests\RetrieveCompanyRequest; use Intercom\Unstable\Types\CompanyList; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\Companies\Types\Company; use Intercom\Unstable\Companies\Requests\RetrieveACompanyByIdRequest; @@ -78,6 +77,20 @@ public function __construct( * * `https://api.intercom.io/companies?segment_id={segment_id}` * + * Example: + * ```php + * $client->companies->retrieve( + * new RetrieveCompanyRequest([ + * 'name' => 'my company', + * 'companyId' => '12345', + * 'tagId' => '678910', + * 'segmentId' => '98765', + * 'page' => 1, + * 'perPage' => 1, + * ]), + * ); + * ``` + * * @param RetrieveCompanyRequest $request * @param ?array{ * baseUrl?: string, @@ -87,11 +100,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return CompanyList + * @return ?CompanyList * @throws IntercomException * @throws IntercomApiException */ - public function retrieveCompany(RetrieveCompanyRequest $request = new RetrieveCompanyRequest(), ?array $options = null): CompanyList + public function retrieveCompany(RetrieveCompanyRequest $request = new RetrieveCompanyRequest(), ?array $options = null): ?CompanyList { $options = array_merge($this->options, $options ?? []); $query = []; @@ -126,20 +139,13 @@ public function retrieveCompany(RetrieveCompanyRequest $request = new RetrieveCo $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return CompanyList::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); } @@ -161,6 +167,15 @@ public function retrieveCompany(RetrieveCompanyRequest $request = new RetrieveCo * 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 %} * + * Example: + * ```php + * $client->unstable->companies->createOrUpdateCompany( + * [ + * 'key' => "value", + * ], + * ); + * ``` + * * @param mixed $request * @param ?array{ * baseUrl?: string, @@ -170,11 +185,11 @@ public function retrieveCompany(RetrieveCompanyRequest $request = new RetrieveCo * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Company + * @return ?Company * @throws IntercomException * @throws IntercomApiException */ - public function createOrUpdateCompany(mixed $request, ?array $options = null): Company + public function createOrUpdateCompany(mixed $request, ?array $options = null): ?Company { $options = array_merge($this->options, $options ?? []); try { @@ -190,20 +205,13 @@ public function createOrUpdateCompany(mixed $request, ?array $options = null): C $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Company::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); } @@ -217,6 +225,15 @@ public function createOrUpdateCompany(mixed $request, ?array $options = null): C /** * You can fetch a single company. * + * Example: + * ```php + * $client->unstable->companies->retrieveACompanyById( + * new RetrieveACompanyByIdRequest([ + * 'id' => '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', + * ]), + * ); + * ``` + * * @param RetrieveACompanyByIdRequest $request * @param ?array{ * baseUrl?: string, @@ -226,18 +243,18 @@ public function createOrUpdateCompany(mixed $request, ?array $options = null): C * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Company + * @return ?Company * @throws IntercomException * @throws IntercomApiException */ - public function retrieveACompanyById(RetrieveACompanyByIdRequest $request, ?array $options = null): Company + public function retrieveACompanyById(RetrieveACompanyByIdRequest $request, ?array $options = null): ?Company { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "companies/{$request->getId()}", + path: "companies/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::GET, ), $options, @@ -245,20 +262,13 @@ public function retrieveACompanyById(RetrieveACompanyByIdRequest $request, ?arra $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Company::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); } @@ -276,6 +286,15 @@ public function retrieveACompanyById(RetrieveACompanyByIdRequest $request, ?arra * When updating a company it is not possible to update `company_id`. This can only be set once upon creation of the company. * {% /admonition %} * + * Example: + * ```php + * $client->unstable->companies->updateCompany( + * new UpdateCompanyRequest([ + * 'id' => '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', + * ]), + * ); + * ``` + * * @param UpdateCompanyRequest $request * @param ?array{ * baseUrl?: string, @@ -285,18 +304,18 @@ public function retrieveACompanyById(RetrieveACompanyByIdRequest $request, ?arra * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Company + * @return ?Company * @throws IntercomException * @throws IntercomApiException */ - public function updateCompany(UpdateCompanyRequest $request, ?array $options = null): Company + public function updateCompany(UpdateCompanyRequest $request, ?array $options = null): ?Company { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "companies/{$request->getId()}", + path: "companies/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::PUT, ), $options, @@ -304,20 +323,13 @@ public function updateCompany(UpdateCompanyRequest $request, ?array $options = n $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Company::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); } @@ -331,6 +343,15 @@ public function updateCompany(UpdateCompanyRequest $request, ?array $options = n /** * You can delete a single company. * + * Example: + * ```php + * $client->unstable->companies->deleteCompany( + * new DeleteCompanyRequest([ + * 'id' => '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', + * ]), + * ); + * ``` + * * @param DeleteCompanyRequest $request * @param ?array{ * baseUrl?: string, @@ -340,18 +361,18 @@ public function updateCompany(UpdateCompanyRequest $request, ?array $options = n * queryParameters?: array, * bodyProperties?: array, * } $options - * @return DeletedCompanyObject + * @return ?DeletedCompanyObject * @throws IntercomException * @throws IntercomApiException */ - public function deleteCompany(DeleteCompanyRequest $request, ?array $options = null): DeletedCompanyObject + public function deleteCompany(DeleteCompanyRequest $request, ?array $options = null): ?DeletedCompanyObject { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "companies/{$request->getId()}", + path: "companies/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::DELETE, ), $options, @@ -359,20 +380,13 @@ public function deleteCompany(DeleteCompanyRequest $request, ?array $options = n $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return DeletedCompanyObject::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); } @@ -386,6 +400,15 @@ public function deleteCompany(DeleteCompanyRequest $request, ?array $options = n /** * You can fetch a list of all contacts that belong to a company. * + * Example: + * ```php + * $client->unstable->companies->listAttachedContacts( + * new ListAttachedContactsRequest([ + * 'id' => '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', + * ]), + * ); + * ``` + * * @param ListAttachedContactsRequest $request * @param ?array{ * baseUrl?: string, @@ -395,18 +418,18 @@ public function deleteCompany(DeleteCompanyRequest $request, ?array $options = n * queryParameters?: array, * bodyProperties?: array, * } $options - * @return CompanyAttachedContacts + * @return ?CompanyAttachedContacts * @throws IntercomException * @throws IntercomApiException */ - public function listAttachedContacts(ListAttachedContactsRequest $request, ?array $options = null): CompanyAttachedContacts + public function listAttachedContacts(ListAttachedContactsRequest $request, ?array $options = null): ?CompanyAttachedContacts { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "companies/{$request->getId()}/contacts", + path: "companies/" . RawClient::encodePathParam($request->getId()) . "/contacts", method: HttpMethod::GET, ), $options, @@ -414,20 +437,13 @@ public function listAttachedContacts(ListAttachedContactsRequest $request, ?arra $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return CompanyAttachedContacts::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); } @@ -441,6 +457,15 @@ public function listAttachedContacts(ListAttachedContactsRequest $request, ?arra /** * You can fetch a list of all segments that belong to a company. * + * Example: + * ```php + * $client->unstable->companies->listAttachedSegmentsForCompanies( + * new ListAttachedSegmentsForCompaniesRequest([ + * 'id' => '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', + * ]), + * ); + * ``` + * * @param ListAttachedSegmentsForCompaniesRequest $request * @param ?array{ * baseUrl?: string, @@ -450,18 +475,18 @@ public function listAttachedContacts(ListAttachedContactsRequest $request, ?arra * queryParameters?: array, * bodyProperties?: array, * } $options - * @return CompanyAttachedSegments + * @return ?CompanyAttachedSegments * @throws IntercomException * @throws IntercomApiException */ - public function listAttachedSegmentsForCompanies(ListAttachedSegmentsForCompaniesRequest $request, ?array $options = null): CompanyAttachedSegments + public function listAttachedSegmentsForCompanies(ListAttachedSegmentsForCompaniesRequest $request, ?array $options = null): ?CompanyAttachedSegments { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "companies/{$request->getId()}/segments", + path: "companies/" . RawClient::encodePathParam($request->getId()) . "/segments", method: HttpMethod::GET, ), $options, @@ -469,20 +494,13 @@ public function listAttachedSegmentsForCompanies(ListAttachedSegmentsForCompanie $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return CompanyAttachedSegments::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); } @@ -504,6 +522,17 @@ public function listAttachedSegmentsForCompanies(ListAttachedSegmentsForCompanie * See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. * {% /admonition %} * + * Example: + * ```php + * $client->companies->list( + * new ListCompaniesRequest([ + * 'page' => 1, + * 'perPage' => 1, + * 'order' => 'desc', + * ]), + * ); + * ``` + * * @param ListAllCompaniesRequest $request * @param ?array{ * baseUrl?: string, @@ -513,11 +542,11 @@ public function listAttachedSegmentsForCompanies(ListAttachedSegmentsForCompanie * queryParameters?: array, * bodyProperties?: array, * } $options - * @return CompanyList + * @return ?CompanyList * @throws IntercomException * @throws IntercomApiException */ - public function listAllCompanies(ListAllCompaniesRequest $request = new ListAllCompaniesRequest(), ?array $options = null): CompanyList + public function listAllCompanies(ListAllCompaniesRequest $request = new ListAllCompaniesRequest(), ?array $options = null): ?CompanyList { $options = array_merge($this->options, $options ?? []); $query = []; @@ -543,20 +572,13 @@ public function listAllCompanies(ListAllCompaniesRequest $request = new ListAllC $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return CompanyList::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); } @@ -584,6 +606,15 @@ public function listAllCompanies(ListAllCompaniesRequest $request = new ListAllC * If this happens, you will need to restart your scroll query: It is not possible to continue from a specific point when using scroll. * {% /admonition %} * + * Example: + * ```php + * $client->companies->scroll( + * new ScrollCompaniesRequest([ + * 'scrollParam' => 'scroll_param', + * ]), + * ); + * ``` + * * @param ScrollOverAllCompaniesRequest $request * @param ?array{ * baseUrl?: string, @@ -624,16 +655,6 @@ public function scrollOverAllCompanies(ScrollOverAllCompaniesRequest $request = } } 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); } @@ -647,6 +668,16 @@ public function scrollOverAllCompanies(ScrollOverAllCompaniesRequest $request = /** * You can attach a company to a single contact. * + * Example: + * ```php + * $client->unstable->companies->attachContactToACompany( + * new AttachContactToACompanyRequest([ + * 'id' => 'id', + * 'companyId' => '6762f09a1bb69f9f2193bb34', + * ]), + * ); + * ``` + * * @param AttachContactToACompanyRequest $request * @param ?array{ * baseUrl?: string, @@ -656,18 +687,18 @@ public function scrollOverAllCompanies(ScrollOverAllCompaniesRequest $request = * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Company + * @return ?Company * @throws IntercomException * @throws IntercomApiException */ - public function attachContactToACompany(AttachContactToACompanyRequest $request, ?array $options = null): Company + public function attachContactToACompany(AttachContactToACompanyRequest $request, ?array $options = null): ?Company { $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->getId()}/companies", + path: "contacts/" . RawClient::encodePathParam($request->getId()) . "/companies", method: HttpMethod::POST, body: $request, ), @@ -676,20 +707,13 @@ public function attachContactToACompany(AttachContactToACompanyRequest $request, $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Company::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); } @@ -703,6 +727,16 @@ public function attachContactToACompany(AttachContactToACompanyRequest $request, /** * You can detach a company from a single contact. * + * Example: + * ```php + * $client->unstable->companies->detachContactFromACompany( + * new DetachContactFromACompanyRequest([ + * 'contactId' => '58a430d35458202d41b1e65b', + * 'id' => '58a430d35458202d41b1e65b', + * ]), + * ); + * ``` + * * @param DetachContactFromACompanyRequest $request * @param ?array{ * baseUrl?: string, @@ -712,18 +746,18 @@ public function attachContactToACompany(AttachContactToACompanyRequest $request, * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Company + * @return ?Company * @throws IntercomException * @throws IntercomApiException */ - public function detachContactFromACompany(DetachContactFromACompanyRequest $request, ?array $options = null): Company + public function detachContactFromACompany(DetachContactFromACompanyRequest $request, ?array $options = null): ?Company { $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()}/companies/{$request->getId()}", + path: "contacts/" . RawClient::encodePathParam($request->getContactId()) . "/companies/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::DELETE, ), $options, @@ -731,20 +765,13 @@ public function detachContactFromACompany(DetachContactFromACompanyRequest $requ $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Company::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); } diff --git a/src/Unstable/Companies/Requests/AttachContactToACompanyRequest.php b/src/Unstable/Companies/Requests/AttachContactToACompanyRequest.php index 6039c12c..cf04e4ed 100644 --- a/src/Unstable/Companies/Requests/AttachContactToACompanyRequest.php +++ b/src/Unstable/Companies/Requests/AttachContactToACompanyRequest.php @@ -45,6 +45,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -62,6 +63,7 @@ public function getCompanyId(): string public function setCompanyId(string $value): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } } diff --git a/src/Unstable/Companies/Requests/DeleteCompanyRequest.php b/src/Unstable/Companies/Requests/DeleteCompanyRequest.php index d04eb812..678661ba 100644 --- a/src/Unstable/Companies/Requests/DeleteCompanyRequest.php +++ b/src/Unstable/Companies/Requests/DeleteCompanyRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Companies/Requests/DetachContactFromACompanyRequest.php b/src/Unstable/Companies/Requests/DetachContactFromACompanyRequest.php index 8ea6f864..3ca1de70 100644 --- a/src/Unstable/Companies/Requests/DetachContactFromACompanyRequest.php +++ b/src/Unstable/Companies/Requests/DetachContactFromACompanyRequest.php @@ -43,6 +43,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } @@ -60,6 +61,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Companies/Requests/ListAllCompaniesRequest.php b/src/Unstable/Companies/Requests/ListAllCompaniesRequest.php index 984903c6..5f5d013b 100644 --- a/src/Unstable/Companies/Requests/ListAllCompaniesRequest.php +++ b/src/Unstable/Companies/Requests/ListAllCompaniesRequest.php @@ -50,6 +50,7 @@ public function getPage(): ?int public function setPage(?int $value = null): self { $this->page = $value; + $this->_setField('page'); return $this; } @@ -67,6 +68,7 @@ public function getPerPage(): ?int public function setPerPage(?int $value = null): self { $this->perPage = $value; + $this->_setField('perPage'); return $this; } @@ -84,6 +86,7 @@ public function getOrder(): ?string public function setOrder(?string $value = null): self { $this->order = $value; + $this->_setField('order'); return $this; } } diff --git a/src/Unstable/Companies/Requests/ListAttachedContactsRequest.php b/src/Unstable/Companies/Requests/ListAttachedContactsRequest.php index cc0ff728..08d102fd 100644 --- a/src/Unstable/Companies/Requests/ListAttachedContactsRequest.php +++ b/src/Unstable/Companies/Requests/ListAttachedContactsRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Companies/Requests/ListAttachedSegmentsForCompaniesRequest.php b/src/Unstable/Companies/Requests/ListAttachedSegmentsForCompaniesRequest.php index 711bf5d7..051decb0 100644 --- a/src/Unstable/Companies/Requests/ListAttachedSegmentsForCompaniesRequest.php +++ b/src/Unstable/Companies/Requests/ListAttachedSegmentsForCompaniesRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Companies/Requests/RetrieveACompanyByIdRequest.php b/src/Unstable/Companies/Requests/RetrieveACompanyByIdRequest.php index ece187ae..98cc5bfe 100644 --- a/src/Unstable/Companies/Requests/RetrieveACompanyByIdRequest.php +++ b/src/Unstable/Companies/Requests/RetrieveACompanyByIdRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Companies/Requests/RetrieveCompanyRequest.php b/src/Unstable/Companies/Requests/RetrieveCompanyRequest.php index 71546214..3dea7559 100644 --- a/src/Unstable/Companies/Requests/RetrieveCompanyRequest.php +++ b/src/Unstable/Companies/Requests/RetrieveCompanyRequest.php @@ -71,6 +71,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -88,6 +89,7 @@ public function getCompanyId(): ?string public function setCompanyId(?string $value = null): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } @@ -105,6 +107,7 @@ public function getTagId(): ?string public function setTagId(?string $value = null): self { $this->tagId = $value; + $this->_setField('tagId'); return $this; } @@ -122,6 +125,7 @@ public function getSegmentId(): ?string public function setSegmentId(?string $value = null): self { $this->segmentId = $value; + $this->_setField('segmentId'); return $this; } @@ -139,6 +143,7 @@ public function getPage(): ?int public function setPage(?int $value = null): self { $this->page = $value; + $this->_setField('page'); return $this; } @@ -156,6 +161,7 @@ public function getPerPage(): ?int public function setPerPage(?int $value = null): self { $this->perPage = $value; + $this->_setField('perPage'); return $this; } } diff --git a/src/Unstable/Companies/Requests/ScrollOverAllCompaniesRequest.php b/src/Unstable/Companies/Requests/ScrollOverAllCompaniesRequest.php index a1994d51..4a54d609 100644 --- a/src/Unstable/Companies/Requests/ScrollOverAllCompaniesRequest.php +++ b/src/Unstable/Companies/Requests/ScrollOverAllCompaniesRequest.php @@ -36,6 +36,7 @@ public function getScrollParam(): ?string public function setScrollParam(?string $value = null): self { $this->scrollParam = $value; + $this->_setField('scrollParam'); return $this; } } diff --git a/src/Unstable/Companies/Requests/UpdateCompanyRequest.php b/src/Unstable/Companies/Requests/UpdateCompanyRequest.php index fe89a0fc..e173da08 100644 --- a/src/Unstable/Companies/Requests/UpdateCompanyRequest.php +++ b/src/Unstable/Companies/Requests/UpdateCompanyRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Companies/Types/Company.php b/src/Unstable/Companies/Types/Company.php index 5214eaf5..a328aa80 100644 --- a/src/Unstable/Companies/Types/Company.php +++ b/src/Unstable/Companies/Types/Company.php @@ -194,6 +194,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -211,6 +212,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -228,6 +230,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -245,6 +248,7 @@ public function getAppId(): ?string public function setAppId(?string $value = null): self { $this->appId = $value; + $this->_setField('appId'); return $this; } @@ -262,6 +266,7 @@ public function getPlan(): ?CompanyPlan public function setPlan(?CompanyPlan $value = null): self { $this->plan = $value; + $this->_setField('plan'); return $this; } @@ -279,6 +284,7 @@ public function getCompanyId(): ?string public function setCompanyId(?string $value = null): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } @@ -296,6 +302,7 @@ public function getRemoteCreatedAt(): ?int public function setRemoteCreatedAt(?int $value = null): self { $this->remoteCreatedAt = $value; + $this->_setField('remoteCreatedAt'); return $this; } @@ -313,6 +320,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -330,6 +338,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -347,6 +356,7 @@ public function getLastRequestAt(): ?int public function setLastRequestAt(?int $value = null): self { $this->lastRequestAt = $value; + $this->_setField('lastRequestAt'); return $this; } @@ -364,6 +374,7 @@ public function getSize(): ?int public function setSize(?int $value = null): self { $this->size = $value; + $this->_setField('size'); return $this; } @@ -381,6 +392,7 @@ public function getWebsite(): ?string public function setWebsite(?string $value = null): self { $this->website = $value; + $this->_setField('website'); return $this; } @@ -398,6 +410,7 @@ public function getIndustry(): ?string public function setIndustry(?string $value = null): self { $this->industry = $value; + $this->_setField('industry'); return $this; } @@ -415,6 +428,7 @@ public function getMonthlySpend(): ?int public function setMonthlySpend(?int $value = null): self { $this->monthlySpend = $value; + $this->_setField('monthlySpend'); return $this; } @@ -432,6 +446,7 @@ public function getSessionCount(): ?int public function setSessionCount(?int $value = null): self { $this->sessionCount = $value; + $this->_setField('sessionCount'); return $this; } @@ -449,6 +464,7 @@ public function getUserCount(): ?int public function setUserCount(?int $value = null): self { $this->userCount = $value; + $this->_setField('userCount'); return $this; } @@ -466,6 +482,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } @@ -483,6 +500,7 @@ public function getTags(): ?CompanyTags public function setTags(?CompanyTags $value = null): self { $this->tags = $value; + $this->_setField('tags'); return $this; } @@ -500,6 +518,7 @@ public function getSegments(): ?CompanySegments public function setSegments(?CompanySegments $value = null): self { $this->segments = $value; + $this->_setField('segments'); return $this; } @@ -517,6 +536,7 @@ public function getNotes(): ?CompanyNotes public function setNotes(?CompanyNotes $value = null): self { $this->notes = $value; + $this->_setField('notes'); return $this; } diff --git a/src/Unstable/Companies/Types/CompanyNotes.php b/src/Unstable/Companies/Types/CompanyNotes.php index 7c31050d..9c197bac 100644 --- a/src/Unstable/Companies/Types/CompanyNotes.php +++ b/src/Unstable/Companies/Types/CompanyNotes.php @@ -51,6 +51,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -68,6 +69,7 @@ public function getNotes(): ?array public function setNotes(?array $value = null): self { $this->notes = $value; + $this->_setField('notes'); return $this; } diff --git a/src/Unstable/Companies/Types/CompanyPlan.php b/src/Unstable/Companies/Types/CompanyPlan.php index f85feb9e..efd6a2be 100644 --- a/src/Unstable/Companies/Types/CompanyPlan.php +++ b/src/Unstable/Companies/Types/CompanyPlan.php @@ -54,6 +54,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -71,6 +72,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -88,6 +90,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } diff --git a/src/Unstable/Companies/Types/CompanySegments.php b/src/Unstable/Companies/Types/CompanySegments.php index baec465c..e2e6c708 100644 --- a/src/Unstable/Companies/Types/CompanySegments.php +++ b/src/Unstable/Companies/Types/CompanySegments.php @@ -51,6 +51,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -68,6 +69,7 @@ public function getSegments(): ?array public function setSegments(?array $value = null): self { $this->segments = $value; + $this->_setField('segments'); return $this; } diff --git a/src/Unstable/Companies/Types/CompanyTags.php b/src/Unstable/Companies/Types/CompanyTags.php index 55d3e412..539b6745 100644 --- a/src/Unstable/Companies/Types/CompanyTags.php +++ b/src/Unstable/Companies/Types/CompanyTags.php @@ -50,6 +50,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -67,6 +68,7 @@ public function getTags(): ?array public function setTags(?array $value = null): self { $this->tags = $value; + $this->_setField('tags'); return $this; } diff --git a/src/Unstable/Contacts/ContactsClient.php b/src/Unstable/Contacts/ContactsClient.php index a51577f4..087896a1 100644 --- a/src/Unstable/Contacts/ContactsClient.php +++ b/src/Unstable/Contacts/ContactsClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\Contacts; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\Contacts\Requests\ListCompaniesForAContactRequest; use Intercom\Unstable\Types\ContactAttachedCompanies; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\Contacts\Requests\ListSegmentsForAContactRequest; use Intercom\Unstable\Types\ContactSegments; @@ -79,6 +78,15 @@ public function __construct( /** * You can fetch a list of companies that are associated to a contact. * + * Example: + * ```php + * $client->unstable->contacts->listCompaniesForAContact( + * new ListCompaniesForAContactRequest([ + * 'id' => '63a07ddf05a32042dffac965', + * ]), + * ); + * ``` + * * @param ListCompaniesForAContactRequest $request * @param ?array{ * baseUrl?: string, @@ -88,18 +96,18 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContactAttachedCompanies + * @return ?ContactAttachedCompanies * @throws IntercomException * @throws IntercomApiException */ - public function listCompaniesForAContact(ListCompaniesForAContactRequest $request, ?array $options = null): ContactAttachedCompanies + public function listCompaniesForAContact(ListCompaniesForAContactRequest $request, ?array $options = null): ?ContactAttachedCompanies { $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->getId()}/companies", + path: "contacts/" . RawClient::encodePathParam($request->getId()) . "/companies", method: HttpMethod::GET, ), $options, @@ -107,20 +115,13 @@ public function listCompaniesForAContact(ListCompaniesForAContactRequest $reques $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ContactAttachedCompanies::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); } @@ -134,6 +135,15 @@ public function listCompaniesForAContact(ListCompaniesForAContactRequest $reques /** * You can fetch a list of segments that are associated to a contact. * + * Example: + * ```php + * $client->contacts->listAttachedSegments( + * new ListSegmentsAttachedToContactRequest([ + * 'contactId' => '63a07ddf05a32042dffac965', + * ]), + * ); + * ``` + * * @param ListSegmentsForAContactRequest $request * @param ?array{ * baseUrl?: string, @@ -143,18 +153,18 @@ public function listCompaniesForAContact(ListCompaniesForAContactRequest $reques * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContactSegments + * @return ?ContactSegments * @throws IntercomException * @throws IntercomApiException */ - public function listSegmentsForAContact(ListSegmentsForAContactRequest $request, ?array $options = null): ContactSegments + public function listSegmentsForAContact(ListSegmentsForAContactRequest $request, ?array $options = null): ?ContactSegments { $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()}/segments", + path: "contacts/" . RawClient::encodePathParam($request->getContactId()) . "/segments", method: HttpMethod::GET, ), $options, @@ -162,20 +172,13 @@ public function listSegmentsForAContact(ListSegmentsForAContactRequest $request, $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ContactSegments::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); } @@ -195,6 +198,15 @@ public function listSegmentsForAContact(ListSegmentsForAContactRequest $request, * 1.Opt-out subscription types that the user has opted-out from. * 2.Opt-in subscription types that the user has opted-in to receiving. * + * Example: + * ```php + * $client->contacts->listAttachedSubscriptions( + * new ListAttachedSubscriptionsRequest([ + * 'contactId' => '63a07ddf05a32042dffac965', + * ]), + * ); + * ``` + * * @param ListSubscriptionsForAContactRequest $request * @param ?array{ * baseUrl?: string, @@ -204,18 +216,18 @@ public function listSegmentsForAContact(ListSegmentsForAContactRequest $request, * queryParameters?: array, * bodyProperties?: array, * } $options - * @return SubscriptionTypeList + * @return ?SubscriptionTypeList * @throws IntercomException * @throws IntercomApiException */ - public function listSubscriptionsForAContact(ListSubscriptionsForAContactRequest $request, ?array $options = null): SubscriptionTypeList + public function listSubscriptionsForAContact(ListSubscriptionsForAContactRequest $request, ?array $options = null): ?SubscriptionTypeList { $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()}/subscriptions", + path: "contacts/" . RawClient::encodePathParam($request->getContactId()) . "/subscriptions", method: HttpMethod::GET, ), $options, @@ -223,20 +235,13 @@ public function listSubscriptionsForAContact(ListSubscriptionsForAContactRequest $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return SubscriptionTypeList::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); } @@ -250,6 +255,15 @@ public function listSubscriptionsForAContact(ListSubscriptionsForAContactRequest /** * You can fetch a list of all tags that are attached to a specific contact. * + * Example: + * ```php + * $client->contacts->listAttachedTags( + * new ListTagsAttachedToContactRequest([ + * 'contactId' => '63a07ddf05a32042dffac965', + * ]), + * ); + * ``` + * * @param ListTagsForAContactRequest $request * @param ?array{ * baseUrl?: string, @@ -259,18 +273,18 @@ public function listSubscriptionsForAContact(ListSubscriptionsForAContactRequest * queryParameters?: array, * bodyProperties?: array, * } $options - * @return TagList + * @return ?TagList * @throws IntercomException * @throws IntercomApiException */ - public function listTagsForAContact(ListTagsForAContactRequest $request, ?array $options = null): TagList + public function listTagsForAContact(ListTagsForAContactRequest $request, ?array $options = null): ?TagList { $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()}/tags", + path: "contacts/" . RawClient::encodePathParam($request->getContactId()) . "/tags", method: HttpMethod::GET, ), $options, @@ -278,20 +292,13 @@ public function listTagsForAContact(ListTagsForAContactRequest $request, ?array $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return TagList::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); } @@ -305,6 +312,15 @@ public function listTagsForAContact(ListTagsForAContactRequest $request, ?array /** * You can fetch the details of a single contact. * + * Example: + * ```php + * $client->unstable->contacts->showContact( + * new ShowContactRequest([ + * 'id' => '63a07ddf05a32042dffac965', + * ]), + * ); + * ``` + * * @param ShowContactRequest $request * @param ?array{ * baseUrl?: string, @@ -314,18 +330,18 @@ public function listTagsForAContact(ListTagsForAContactRequest $request, ?array * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ShowContactResponse + * @return ?ShowContactResponse * @throws IntercomException * @throws IntercomApiException */ - public function showContact(ShowContactRequest $request, ?array $options = null): ShowContactResponse + public function showContact(ShowContactRequest $request, ?array $options = null): ?ShowContactResponse { $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->getId()}", + path: "contacts/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::GET, ), $options, @@ -333,20 +349,13 @@ public function showContact(ShowContactRequest $request, ?array $options = null) $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ShowContactResponse::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); } @@ -366,6 +375,17 @@ public function showContact(ShowContactRequest $request, ?array $options = null) * 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 %} * + * Example: + * ```php + * $client->unstable->contacts->updateContact( + * new UpdateContactRequest([ + * 'id' => '63a07ddf05a32042dffac965', + * 'email' => 'joebloggs@intercom.io', + * 'name' => 'joe bloggs', + * ]), + * ); + * ``` + * * @param UpdateContactRequest $request * @param ?array{ * baseUrl?: string, @@ -375,18 +395,18 @@ public function showContact(ShowContactRequest $request, ?array $options = null) * queryParameters?: array, * bodyProperties?: array, * } $options - * @return UpdateContactResponse + * @return ?UpdateContactResponse * @throws IntercomException * @throws IntercomApiException */ - public function updateContact(UpdateContactRequest $request, ?array $options = null): UpdateContactResponse + public function updateContact(UpdateContactRequest $request, ?array $options = null): ?UpdateContactResponse { $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->getId()}", + path: "contacts/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::PUT, body: $request, ), @@ -395,20 +415,13 @@ public function updateContact(UpdateContactRequest $request, ?array $options = n $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return UpdateContactResponse::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); } @@ -422,6 +435,15 @@ public function updateContact(UpdateContactRequest $request, ?array $options = n /** * You can delete a single contact. * + * Example: + * ```php + * $client->unstable->contacts->deleteContact( + * new DeleteContactRequest([ + * 'id' => 'id', + * ]), + * ); + * ``` + * * @param DeleteContactRequest $request * @param ?array{ * baseUrl?: string, @@ -431,18 +453,18 @@ public function updateContact(UpdateContactRequest $request, ?array $options = n * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContactDeleted + * @return ?ContactDeleted * @throws IntercomException * @throws IntercomApiException */ - public function deleteContact(DeleteContactRequest $request, ?array $options = null): ContactDeleted + public function deleteContact(DeleteContactRequest $request, ?array $options = null): ?ContactDeleted { $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->getId()}", + path: "contacts/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::DELETE, ), $options, @@ -450,20 +472,13 @@ public function deleteContact(DeleteContactRequest $request, ?array $options = n $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ContactDeleted::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); } @@ -477,6 +492,16 @@ public function deleteContact(DeleteContactRequest $request, ?array $options = n /** * You can merge a contact with a `role` of `lead` into a contact with a `role` of `user`. * + * Example: + * ```php + * $client->contacts->mergeLeadInUser( + * new MergeContactsRequest([ + * 'leadId' => '6762f0d51bb69f9f2193bb7f', + * 'contactId' => '6762f0d51bb69f9f2193bb80', + * ]), + * ); + * ``` + * * @param MergeContactsRequest $request * @param ?array{ * baseUrl?: string, @@ -486,11 +511,11 @@ public function deleteContact(DeleteContactRequest $request, ?array $options = n * queryParameters?: array, * bodyProperties?: array, * } $options - * @return MergeContactResponse + * @return ?MergeContactResponse * @throws IntercomException * @throws IntercomApiException */ - public function mergeContact(MergeContactsRequest $request = new MergeContactsRequest(), ?array $options = null): MergeContactResponse + public function mergeContact(MergeContactsRequest $request = new MergeContactsRequest(), ?array $options = null): ?MergeContactResponse { $options = array_merge($this->options, $options ?? []); try { @@ -506,20 +531,13 @@ public function mergeContact(MergeContactsRequest $request = new MergeContactsRe $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return MergeContactResponse::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); } @@ -632,6 +650,20 @@ public function mergeContact(MergeContactsRequest $request = new MergeContactsRe * | ^ | String | Starts With | * | $ | String | Ends With | * + * Example: + * ```php + * $client->unstable->contacts->searchContacts( + * new SearchRequest([ + * 'query' => new SingleFilterSearchRequest([ + * 'value' => [], + * ]), + * 'pagination' => new StartingAfterPaging([ + * 'perPage' => 5, + * ]), + * ]), + * ); + * ``` + * * @param SearchRequest $request * @param ?array{ * baseUrl?: string, @@ -641,11 +673,11 @@ public function mergeContact(MergeContactsRequest $request = new MergeContactsRe * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContactList + * @return ?ContactList * @throws IntercomException * @throws IntercomApiException */ - public function searchContacts(SearchRequest $request, ?array $options = null): ContactList + public function searchContacts(SearchRequest $request, ?array $options = null): ?ContactList { $options = array_merge($this->options, $options ?? []); try { @@ -661,20 +693,13 @@ public function searchContacts(SearchRequest $request, ?array $options = null): $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ContactList::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); } @@ -692,6 +717,13 @@ public function searchContacts(SearchRequest $request, ?array $options = null): * See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. * {% /admonition %} * + * Example: + * ```php + * $client->contacts->list( + * new ListContactsRequest([]), + * ); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -700,11 +732,11 @@ public function searchContacts(SearchRequest $request, ?array $options = null): * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContactList + * @return ?ContactList * @throws IntercomException * @throws IntercomApiException */ - public function listContacts(?array $options = null): ContactList + public function listContacts(?array $options = null): ?ContactList { $options = array_merge($this->options, $options ?? []); try { @@ -719,20 +751,13 @@ public function listContacts(?array $options = null): ContactList $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ContactList::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); } @@ -746,7 +771,18 @@ public function listContacts(?array $options = null): ContactList /** * You can create a new contact (ie. user or lead). * - * @param mixed $request + * Example: + * ```php + * $client->contacts->create( + * new CreateContactRequestWithEmail([ + * 'email' => 'joebloggs@intercom.io', + * ]), + * ); + * ``` + * + * @param ( + * mixed + * ) $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -755,11 +791,11 @@ public function listContacts(?array $options = null): ContactList * queryParameters?: array, * bodyProperties?: array, * } $options - * @return CreateContactResponse + * @return ?CreateContactResponse * @throws IntercomException * @throws IntercomApiException */ - public function createContact(mixed $request, ?array $options = null): CreateContactResponse + public function createContact(mixed $request, ?array $options = null): ?CreateContactResponse { $options = array_merge($this->options, $options ?? []); try { @@ -775,20 +811,13 @@ public function createContact(mixed $request, ?array $options = null): CreateCon $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return CreateContactResponse::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); } @@ -802,6 +831,15 @@ public function createContact(mixed $request, ?array $options = null): CreateCon /** * You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. * + * Example: + * ```php + * $client->contacts->showContactByExternalId( + * new ShowContactByExternalIdRequest([ + * 'externalId' => 'cdd29344-5e0c-4ef0-ac56-f9ba2979bc27', + * ]), + * ); + * ``` + * * @param ShowContactByExternalIdRequest $request * @param ?array{ * baseUrl?: string, @@ -811,18 +849,18 @@ public function createContact(mixed $request, ?array $options = null): CreateCon * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ShowContactByExternalIdResponse + * @return ?ShowContactByExternalIdResponse * @throws IntercomException * @throws IntercomApiException */ - public function showContactByExternalId(ShowContactByExternalIdRequest $request, ?array $options = null): ShowContactByExternalIdResponse + 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()}", + path: "contacts/find_by_external_id/" . RawClient::encodePathParam($request->getExternalId()), method: HttpMethod::GET, ), $options, @@ -830,20 +868,13 @@ public function showContactByExternalId(ShowContactByExternalIdRequest $request, $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ShowContactByExternalIdResponse::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); } @@ -857,6 +888,15 @@ public function showContactByExternalId(ShowContactByExternalIdRequest $request, /** * You can archive a single contact. * + * Example: + * ```php + * $client->unstable->contacts->archiveContact( + * new ArchiveContactRequest([ + * 'id' => '63a07ddf05a32042dffac965', + * ]), + * ); + * ``` + * * @param ArchiveContactRequest $request * @param ?array{ * baseUrl?: string, @@ -866,18 +906,18 @@ public function showContactByExternalId(ShowContactByExternalIdRequest $request, * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContactArchived + * @return ?ContactArchived * @throws IntercomException * @throws IntercomApiException */ - public function archiveContact(ArchiveContactRequest $request, ?array $options = null): ContactArchived + public function archiveContact(ArchiveContactRequest $request, ?array $options = null): ?ContactArchived { $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->getId()}/archive", + path: "contacts/" . RawClient::encodePathParam($request->getId()) . "/archive", method: HttpMethod::POST, ), $options, @@ -885,20 +925,13 @@ public function archiveContact(ArchiveContactRequest $request, ?array $options = $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ContactArchived::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); } @@ -912,6 +945,15 @@ public function archiveContact(ArchiveContactRequest $request, ?array $options = /** * You can unarchive a single contact. * + * Example: + * ```php + * $client->unstable->contacts->unarchiveContact( + * new UnarchiveContactRequest([ + * 'id' => '63a07ddf05a32042dffac965', + * ]), + * ); + * ``` + * * @param UnarchiveContactRequest $request * @param ?array{ * baseUrl?: string, @@ -921,18 +963,18 @@ public function archiveContact(ArchiveContactRequest $request, ?array $options = * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContactUnarchived + * @return ?ContactUnarchived * @throws IntercomException * @throws IntercomApiException */ - public function unarchiveContact(UnarchiveContactRequest $request, ?array $options = null): ContactUnarchived + public function unarchiveContact(UnarchiveContactRequest $request, ?array $options = null): ?ContactUnarchived { $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->getId()}/unarchive", + path: "contacts/" . RawClient::encodePathParam($request->getId()) . "/unarchive", method: HttpMethod::POST, ), $options, @@ -940,20 +982,13 @@ public function unarchiveContact(UnarchiveContactRequest $request, ?array $optio $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ContactUnarchived::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); } @@ -967,6 +1002,15 @@ public function unarchiveContact(UnarchiveContactRequest $request, ?array $optio /** * 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) * + * Example: + * ```php + * $client->unstable->contacts->blockContact( + * new BlockContactRequest([ + * 'id' => '63a07ddf05a32042dffac965', + * ]), + * ); + * ``` + * * @param BlockContactRequest $request * @param ?array{ * baseUrl?: string, @@ -976,18 +1020,18 @@ public function unarchiveContact(UnarchiveContactRequest $request, ?array $optio * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ContactBlocked + * @return ?ContactBlocked * @throws IntercomException * @throws IntercomApiException */ - public function blockContact(BlockContactRequest $request, ?array $options = null): ContactBlocked + 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->getId()}/block", + path: "contacts/" . RawClient::encodePathParam($request->getId()) . "/block", method: HttpMethod::POST, ), $options, @@ -995,20 +1039,13 @@ public function blockContact(BlockContactRequest $request, ?array $options = nul $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } diff --git a/src/Unstable/Contacts/Requests/ArchiveContactRequest.php b/src/Unstable/Contacts/Requests/ArchiveContactRequest.php index 975b001b..ade8abd3 100644 --- a/src/Unstable/Contacts/Requests/ArchiveContactRequest.php +++ b/src/Unstable/Contacts/Requests/ArchiveContactRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Contacts/Requests/BlockContactRequest.php b/src/Unstable/Contacts/Requests/BlockContactRequest.php index f3d2650a..fbc9e6da 100644 --- a/src/Unstable/Contacts/Requests/BlockContactRequest.php +++ b/src/Unstable/Contacts/Requests/BlockContactRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Contacts/Requests/DeleteContactRequest.php b/src/Unstable/Contacts/Requests/DeleteContactRequest.php index a80b76de..4862ef2a 100644 --- a/src/Unstable/Contacts/Requests/DeleteContactRequest.php +++ b/src/Unstable/Contacts/Requests/DeleteContactRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Contacts/Requests/ListCompaniesForAContactRequest.php b/src/Unstable/Contacts/Requests/ListCompaniesForAContactRequest.php index 82df18ec..e61e2dc0 100644 --- a/src/Unstable/Contacts/Requests/ListCompaniesForAContactRequest.php +++ b/src/Unstable/Contacts/Requests/ListCompaniesForAContactRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Contacts/Requests/ListSegmentsForAContactRequest.php b/src/Unstable/Contacts/Requests/ListSegmentsForAContactRequest.php index ebb1c25b..5eaa96fa 100644 --- a/src/Unstable/Contacts/Requests/ListSegmentsForAContactRequest.php +++ b/src/Unstable/Contacts/Requests/ListSegmentsForAContactRequest.php @@ -36,6 +36,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } } diff --git a/src/Unstable/Contacts/Requests/ListSubscriptionsForAContactRequest.php b/src/Unstable/Contacts/Requests/ListSubscriptionsForAContactRequest.php index 91c60108..42e36cdc 100644 --- a/src/Unstable/Contacts/Requests/ListSubscriptionsForAContactRequest.php +++ b/src/Unstable/Contacts/Requests/ListSubscriptionsForAContactRequest.php @@ -36,6 +36,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } } diff --git a/src/Unstable/Contacts/Requests/ListTagsForAContactRequest.php b/src/Unstable/Contacts/Requests/ListTagsForAContactRequest.php index 9671e214..c520293d 100644 --- a/src/Unstable/Contacts/Requests/ListTagsForAContactRequest.php +++ b/src/Unstable/Contacts/Requests/ListTagsForAContactRequest.php @@ -36,6 +36,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } } diff --git a/src/Unstable/Contacts/Requests/MergeContactsRequest.php b/src/Unstable/Contacts/Requests/MergeContactsRequest.php index 1bd6d73a..f11bedf5 100644 --- a/src/Unstable/Contacts/Requests/MergeContactsRequest.php +++ b/src/Unstable/Contacts/Requests/MergeContactsRequest.php @@ -46,6 +46,7 @@ public function getFrom(): ?string public function setFrom(?string $value = null): self { $this->from = $value; + $this->_setField('from'); return $this; } @@ -63,6 +64,7 @@ public function getInto(): ?string public function setInto(?string $value = null): self { $this->into = $value; + $this->_setField('into'); return $this; } } diff --git a/src/Unstable/Contacts/Requests/ShowContactByExternalIdRequest.php b/src/Unstable/Contacts/Requests/ShowContactByExternalIdRequest.php index f731110e..f323a677 100644 --- a/src/Unstable/Contacts/Requests/ShowContactByExternalIdRequest.php +++ b/src/Unstable/Contacts/Requests/ShowContactByExternalIdRequest.php @@ -36,6 +36,7 @@ public function getExternalId(): string public function setExternalId(string $value): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } } diff --git a/src/Unstable/Contacts/Requests/ShowContactRequest.php b/src/Unstable/Contacts/Requests/ShowContactRequest.php index 72acfa2d..b140b701 100644 --- a/src/Unstable/Contacts/Requests/ShowContactRequest.php +++ b/src/Unstable/Contacts/Requests/ShowContactRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Contacts/Requests/UnarchiveContactRequest.php b/src/Unstable/Contacts/Requests/UnarchiveContactRequest.php index d6234223..5dfeaee5 100644 --- a/src/Unstable/Contacts/Requests/UnarchiveContactRequest.php +++ b/src/Unstable/Contacts/Requests/UnarchiveContactRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Contacts/Requests/UpdateContactRequest.php b/src/Unstable/Contacts/Requests/UpdateContactRequest.php index 67c6ecf2..e104d774 100644 --- a/src/Unstable/Contacts/Requests/UpdateContactRequest.php +++ b/src/Unstable/Contacts/Requests/UpdateContactRequest.php @@ -134,6 +134,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -151,6 +152,7 @@ public function getRole(): ?string public function setRole(?string $value = null): self { $this->role = $value; + $this->_setField('role'); return $this; } @@ -168,6 +170,7 @@ public function getExternalId(): ?string public function setExternalId(?string $value = null): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } @@ -185,6 +188,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -202,6 +206,7 @@ public function getPhone(): ?string public function setPhone(?string $value = null): self { $this->phone = $value; + $this->_setField('phone'); return $this; } @@ -219,6 +224,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -236,6 +242,7 @@ public function getAvatar(): ?string public function setAvatar(?string $value = null): self { $this->avatar = $value; + $this->_setField('avatar'); return $this; } @@ -253,6 +260,7 @@ public function getSignedUpAt(): ?int public function setSignedUpAt(?int $value = null): self { $this->signedUpAt = $value; + $this->_setField('signedUpAt'); return $this; } @@ -270,6 +278,7 @@ public function getLastSeenAt(): ?int public function setLastSeenAt(?int $value = null): self { $this->lastSeenAt = $value; + $this->_setField('lastSeenAt'); return $this; } @@ -287,6 +296,7 @@ public function getOwnerId(): ?int public function setOwnerId(?int $value = null): self { $this->ownerId = $value; + $this->_setField('ownerId'); return $this; } @@ -304,6 +314,7 @@ public function getUnsubscribedFromEmails(): ?bool public function setUnsubscribedFromEmails(?bool $value = null): self { $this->unsubscribedFromEmails = $value; + $this->_setField('unsubscribedFromEmails'); return $this; } @@ -321,6 +332,7 @@ public function getLanguageOverride(): ?string public function setLanguageOverride(?string $value = null): self { $this->languageOverride = $value; + $this->_setField('languageOverride'); return $this; } @@ -338,6 +350,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } } diff --git a/src/Unstable/Contacts/Traits/Contact.php b/src/Unstable/Contacts/Traits/Contact.php index 1fb501ac..84ec91c1 100644 --- a/src/Unstable/Contacts/Traits/Contact.php +++ b/src/Unstable/Contacts/Traits/Contact.php @@ -353,6 +353,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -370,6 +371,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -387,6 +389,7 @@ public function getExternalId(): ?string public function setExternalId(?string $value = null): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } @@ -404,6 +407,7 @@ public function getWorkspaceId(): ?string public function setWorkspaceId(?string $value = null): self { $this->workspaceId = $value; + $this->_setField('workspaceId'); return $this; } @@ -421,6 +425,7 @@ public function getRole(): ?string public function setRole(?string $value = null): self { $this->role = $value; + $this->_setField('role'); return $this; } @@ -438,6 +443,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -455,6 +461,7 @@ public function getEmailDomain(): ?string public function setEmailDomain(?string $value = null): self { $this->emailDomain = $value; + $this->_setField('emailDomain'); return $this; } @@ -472,6 +479,7 @@ public function getPhone(): ?string public function setPhone(?string $value = null): self { $this->phone = $value; + $this->_setField('phone'); return $this; } @@ -489,6 +497,7 @@ public function getFormattedPhone(): ?string public function setFormattedPhone(?string $value = null): self { $this->formattedPhone = $value; + $this->_setField('formattedPhone'); return $this; } @@ -506,6 +515,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -523,6 +533,7 @@ public function getOwnerId(): ?int public function setOwnerId(?int $value = null): self { $this->ownerId = $value; + $this->_setField('ownerId'); return $this; } @@ -540,6 +551,7 @@ public function getHasHardBounced(): ?bool public function setHasHardBounced(?bool $value = null): self { $this->hasHardBounced = $value; + $this->_setField('hasHardBounced'); return $this; } @@ -557,6 +569,7 @@ public function getMarkedEmailAsSpam(): ?bool public function setMarkedEmailAsSpam(?bool $value = null): self { $this->markedEmailAsSpam = $value; + $this->_setField('markedEmailAsSpam'); return $this; } @@ -574,6 +587,7 @@ public function getUnsubscribedFromEmails(): ?bool public function setUnsubscribedFromEmails(?bool $value = null): self { $this->unsubscribedFromEmails = $value; + $this->_setField('unsubscribedFromEmails'); return $this; } @@ -591,6 +605,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -608,6 +623,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -625,6 +641,7 @@ public function getSignedUpAt(): ?int public function setSignedUpAt(?int $value = null): self { $this->signedUpAt = $value; + $this->_setField('signedUpAt'); return $this; } @@ -642,6 +659,7 @@ public function getLastSeenAt(): ?int public function setLastSeenAt(?int $value = null): self { $this->lastSeenAt = $value; + $this->_setField('lastSeenAt'); return $this; } @@ -659,6 +677,7 @@ public function getLastRepliedAt(): ?int public function setLastRepliedAt(?int $value = null): self { $this->lastRepliedAt = $value; + $this->_setField('lastRepliedAt'); return $this; } @@ -676,6 +695,7 @@ public function getLastContactedAt(): ?int public function setLastContactedAt(?int $value = null): self { $this->lastContactedAt = $value; + $this->_setField('lastContactedAt'); return $this; } @@ -693,6 +713,7 @@ public function getLastEmailOpenedAt(): ?int public function setLastEmailOpenedAt(?int $value = null): self { $this->lastEmailOpenedAt = $value; + $this->_setField('lastEmailOpenedAt'); return $this; } @@ -710,6 +731,7 @@ public function getLastEmailClickedAt(): ?int public function setLastEmailClickedAt(?int $value = null): self { $this->lastEmailClickedAt = $value; + $this->_setField('lastEmailClickedAt'); return $this; } @@ -727,6 +749,7 @@ public function getLanguageOverride(): ?string public function setLanguageOverride(?string $value = null): self { $this->languageOverride = $value; + $this->_setField('languageOverride'); return $this; } @@ -744,6 +767,7 @@ public function getBrowser(): ?string public function setBrowser(?string $value = null): self { $this->browser = $value; + $this->_setField('browser'); return $this; } @@ -761,6 +785,7 @@ public function getBrowserVersion(): ?string public function setBrowserVersion(?string $value = null): self { $this->browserVersion = $value; + $this->_setField('browserVersion'); return $this; } @@ -778,6 +803,7 @@ public function getBrowserLanguage(): ?string public function setBrowserLanguage(?string $value = null): self { $this->browserLanguage = $value; + $this->_setField('browserLanguage'); return $this; } @@ -795,6 +821,7 @@ public function getOs(): ?string public function setOs(?string $value = null): self { $this->os = $value; + $this->_setField('os'); return $this; } @@ -812,6 +839,7 @@ public function getAndroidAppName(): ?string public function setAndroidAppName(?string $value = null): self { $this->androidAppName = $value; + $this->_setField('androidAppName'); return $this; } @@ -829,6 +857,7 @@ public function getAndroidAppVersion(): ?string public function setAndroidAppVersion(?string $value = null): self { $this->androidAppVersion = $value; + $this->_setField('androidAppVersion'); return $this; } @@ -846,6 +875,7 @@ public function getAndroidDevice(): ?string public function setAndroidDevice(?string $value = null): self { $this->androidDevice = $value; + $this->_setField('androidDevice'); return $this; } @@ -863,6 +893,7 @@ public function getAndroidOsVersion(): ?string public function setAndroidOsVersion(?string $value = null): self { $this->androidOsVersion = $value; + $this->_setField('androidOsVersion'); return $this; } @@ -880,6 +911,7 @@ public function getAndroidSdkVersion(): ?string public function setAndroidSdkVersion(?string $value = null): self { $this->androidSdkVersion = $value; + $this->_setField('androidSdkVersion'); return $this; } @@ -897,6 +929,7 @@ public function getAndroidLastSeenAt(): ?int public function setAndroidLastSeenAt(?int $value = null): self { $this->androidLastSeenAt = $value; + $this->_setField('androidLastSeenAt'); return $this; } @@ -914,6 +947,7 @@ public function getIosAppName(): ?string public function setIosAppName(?string $value = null): self { $this->iosAppName = $value; + $this->_setField('iosAppName'); return $this; } @@ -931,6 +965,7 @@ public function getIosAppVersion(): ?string public function setIosAppVersion(?string $value = null): self { $this->iosAppVersion = $value; + $this->_setField('iosAppVersion'); return $this; } @@ -948,6 +983,7 @@ public function getIosDevice(): ?string public function setIosDevice(?string $value = null): self { $this->iosDevice = $value; + $this->_setField('iosDevice'); return $this; } @@ -965,6 +1001,7 @@ public function getIosOsVersion(): ?string public function setIosOsVersion(?string $value = null): self { $this->iosOsVersion = $value; + $this->_setField('iosOsVersion'); return $this; } @@ -982,6 +1019,7 @@ public function getIosSdkVersion(): ?string public function setIosSdkVersion(?string $value = null): self { $this->iosSdkVersion = $value; + $this->_setField('iosSdkVersion'); return $this; } @@ -999,6 +1037,7 @@ public function getIosLastSeenAt(): ?int public function setIosLastSeenAt(?int $value = null): self { $this->iosLastSeenAt = $value; + $this->_setField('iosLastSeenAt'); return $this; } @@ -1016,6 +1055,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } @@ -1033,6 +1073,7 @@ public function getAvatar(): ?ContactAvatar public function setAvatar(?ContactAvatar $value = null): self { $this->avatar = $value; + $this->_setField('avatar'); return $this; } @@ -1050,6 +1091,7 @@ public function getTags(): ?ContactTags public function setTags(?ContactTags $value = null): self { $this->tags = $value; + $this->_setField('tags'); return $this; } @@ -1067,6 +1109,7 @@ public function getNotes(): ?ContactNotes public function setNotes(?ContactNotes $value = null): self { $this->notes = $value; + $this->_setField('notes'); return $this; } @@ -1084,6 +1127,7 @@ public function getCompanies(): ?ContactCompanies public function setCompanies(?ContactCompanies $value = null): self { $this->companies = $value; + $this->_setField('companies'); return $this; } @@ -1101,6 +1145,7 @@ public function getLocation(): ?ContactLocation public function setLocation(?ContactLocation $value = null): self { $this->location = $value; + $this->_setField('location'); return $this; } @@ -1118,6 +1163,7 @@ public function getSocialProfiles(): ?ContactSocialProfiles public function setSocialProfiles(?ContactSocialProfiles $value = null): self { $this->socialProfiles = $value; + $this->_setField('socialProfiles'); return $this; } } diff --git a/src/Unstable/Contacts/Types/Contact.php b/src/Unstable/Contacts/Types/Contact.php index 5c58ec2a..8ab78b9b 100644 --- a/src/Unstable/Contacts/Types/Contact.php +++ b/src/Unstable/Contacts/Types/Contact.php @@ -407,6 +407,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -424,6 +425,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -441,6 +443,7 @@ public function getExternalId(): ?string public function setExternalId(?string $value = null): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } @@ -458,6 +461,7 @@ public function getWorkspaceId(): ?string public function setWorkspaceId(?string $value = null): self { $this->workspaceId = $value; + $this->_setField('workspaceId'); return $this; } @@ -475,6 +479,7 @@ public function getRole(): ?string public function setRole(?string $value = null): self { $this->role = $value; + $this->_setField('role'); return $this; } @@ -492,6 +497,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -509,6 +515,7 @@ public function getEmailDomain(): ?string public function setEmailDomain(?string $value = null): self { $this->emailDomain = $value; + $this->_setField('emailDomain'); return $this; } @@ -526,6 +533,7 @@ public function getPhone(): ?string public function setPhone(?string $value = null): self { $this->phone = $value; + $this->_setField('phone'); return $this; } @@ -543,6 +551,7 @@ public function getFormattedPhone(): ?string public function setFormattedPhone(?string $value = null): self { $this->formattedPhone = $value; + $this->_setField('formattedPhone'); return $this; } @@ -560,6 +569,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -577,6 +587,7 @@ public function getOwnerId(): ?int public function setOwnerId(?int $value = null): self { $this->ownerId = $value; + $this->_setField('ownerId'); return $this; } @@ -594,6 +605,7 @@ public function getHasHardBounced(): ?bool public function setHasHardBounced(?bool $value = null): self { $this->hasHardBounced = $value; + $this->_setField('hasHardBounced'); return $this; } @@ -611,6 +623,7 @@ public function getMarkedEmailAsSpam(): ?bool public function setMarkedEmailAsSpam(?bool $value = null): self { $this->markedEmailAsSpam = $value; + $this->_setField('markedEmailAsSpam'); return $this; } @@ -628,6 +641,7 @@ public function getUnsubscribedFromEmails(): ?bool public function setUnsubscribedFromEmails(?bool $value = null): self { $this->unsubscribedFromEmails = $value; + $this->_setField('unsubscribedFromEmails'); return $this; } @@ -645,6 +659,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -662,6 +677,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -679,6 +695,7 @@ public function getSignedUpAt(): ?int public function setSignedUpAt(?int $value = null): self { $this->signedUpAt = $value; + $this->_setField('signedUpAt'); return $this; } @@ -696,6 +713,7 @@ public function getLastSeenAt(): ?int public function setLastSeenAt(?int $value = null): self { $this->lastSeenAt = $value; + $this->_setField('lastSeenAt'); return $this; } @@ -713,6 +731,7 @@ public function getLastRepliedAt(): ?int public function setLastRepliedAt(?int $value = null): self { $this->lastRepliedAt = $value; + $this->_setField('lastRepliedAt'); return $this; } @@ -730,6 +749,7 @@ public function getLastContactedAt(): ?int public function setLastContactedAt(?int $value = null): self { $this->lastContactedAt = $value; + $this->_setField('lastContactedAt'); return $this; } @@ -747,6 +767,7 @@ public function getLastEmailOpenedAt(): ?int public function setLastEmailOpenedAt(?int $value = null): self { $this->lastEmailOpenedAt = $value; + $this->_setField('lastEmailOpenedAt'); return $this; } @@ -764,6 +785,7 @@ public function getLastEmailClickedAt(): ?int public function setLastEmailClickedAt(?int $value = null): self { $this->lastEmailClickedAt = $value; + $this->_setField('lastEmailClickedAt'); return $this; } @@ -781,6 +803,7 @@ public function getLanguageOverride(): ?string public function setLanguageOverride(?string $value = null): self { $this->languageOverride = $value; + $this->_setField('languageOverride'); return $this; } @@ -798,6 +821,7 @@ public function getBrowser(): ?string public function setBrowser(?string $value = null): self { $this->browser = $value; + $this->_setField('browser'); return $this; } @@ -815,6 +839,7 @@ public function getBrowserVersion(): ?string public function setBrowserVersion(?string $value = null): self { $this->browserVersion = $value; + $this->_setField('browserVersion'); return $this; } @@ -832,6 +857,7 @@ public function getBrowserLanguage(): ?string public function setBrowserLanguage(?string $value = null): self { $this->browserLanguage = $value; + $this->_setField('browserLanguage'); return $this; } @@ -849,6 +875,7 @@ public function getOs(): ?string public function setOs(?string $value = null): self { $this->os = $value; + $this->_setField('os'); return $this; } @@ -866,6 +893,7 @@ public function getAndroidAppName(): ?string public function setAndroidAppName(?string $value = null): self { $this->androidAppName = $value; + $this->_setField('androidAppName'); return $this; } @@ -883,6 +911,7 @@ public function getAndroidAppVersion(): ?string public function setAndroidAppVersion(?string $value = null): self { $this->androidAppVersion = $value; + $this->_setField('androidAppVersion'); return $this; } @@ -900,6 +929,7 @@ public function getAndroidDevice(): ?string public function setAndroidDevice(?string $value = null): self { $this->androidDevice = $value; + $this->_setField('androidDevice'); return $this; } @@ -917,6 +947,7 @@ public function getAndroidOsVersion(): ?string public function setAndroidOsVersion(?string $value = null): self { $this->androidOsVersion = $value; + $this->_setField('androidOsVersion'); return $this; } @@ -934,6 +965,7 @@ public function getAndroidSdkVersion(): ?string public function setAndroidSdkVersion(?string $value = null): self { $this->androidSdkVersion = $value; + $this->_setField('androidSdkVersion'); return $this; } @@ -951,6 +983,7 @@ public function getAndroidLastSeenAt(): ?int public function setAndroidLastSeenAt(?int $value = null): self { $this->androidLastSeenAt = $value; + $this->_setField('androidLastSeenAt'); return $this; } @@ -968,6 +1001,7 @@ public function getIosAppName(): ?string public function setIosAppName(?string $value = null): self { $this->iosAppName = $value; + $this->_setField('iosAppName'); return $this; } @@ -985,6 +1019,7 @@ public function getIosAppVersion(): ?string public function setIosAppVersion(?string $value = null): self { $this->iosAppVersion = $value; + $this->_setField('iosAppVersion'); return $this; } @@ -1002,6 +1037,7 @@ public function getIosDevice(): ?string public function setIosDevice(?string $value = null): self { $this->iosDevice = $value; + $this->_setField('iosDevice'); return $this; } @@ -1019,6 +1055,7 @@ public function getIosOsVersion(): ?string public function setIosOsVersion(?string $value = null): self { $this->iosOsVersion = $value; + $this->_setField('iosOsVersion'); return $this; } @@ -1036,6 +1073,7 @@ public function getIosSdkVersion(): ?string public function setIosSdkVersion(?string $value = null): self { $this->iosSdkVersion = $value; + $this->_setField('iosSdkVersion'); return $this; } @@ -1053,6 +1091,7 @@ public function getIosLastSeenAt(): ?int public function setIosLastSeenAt(?int $value = null): self { $this->iosLastSeenAt = $value; + $this->_setField('iosLastSeenAt'); return $this; } @@ -1070,6 +1109,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } @@ -1087,6 +1127,7 @@ public function getAvatar(): ?ContactAvatar public function setAvatar(?ContactAvatar $value = null): self { $this->avatar = $value; + $this->_setField('avatar'); return $this; } @@ -1104,6 +1145,7 @@ public function getTags(): ?ContactTags public function setTags(?ContactTags $value = null): self { $this->tags = $value; + $this->_setField('tags'); return $this; } @@ -1121,6 +1163,7 @@ public function getNotes(): ?ContactNotes public function setNotes(?ContactNotes $value = null): self { $this->notes = $value; + $this->_setField('notes'); return $this; } @@ -1138,6 +1181,7 @@ public function getCompanies(): ?ContactCompanies public function setCompanies(?ContactCompanies $value = null): self { $this->companies = $value; + $this->_setField('companies'); return $this; } @@ -1155,6 +1199,7 @@ public function getLocation(): ?ContactLocation public function setLocation(?ContactLocation $value = null): self { $this->location = $value; + $this->_setField('location'); return $this; } @@ -1172,6 +1217,7 @@ public function getSocialProfiles(): ?ContactSocialProfiles public function setSocialProfiles(?ContactSocialProfiles $value = null): self { $this->socialProfiles = $value; + $this->_setField('socialProfiles'); return $this; } diff --git a/src/Unstable/Contacts/Types/ContactAvatar.php b/src/Unstable/Contacts/Types/ContactAvatar.php index beb3390e..f69f7c2a 100644 --- a/src/Unstable/Contacts/Types/ContactAvatar.php +++ b/src/Unstable/Contacts/Types/ContactAvatar.php @@ -46,6 +46,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -63,6 +64,7 @@ public function getImageUrl(): ?string public function setImageUrl(?string $value = null): self { $this->imageUrl = $value; + $this->_setField('imageUrl'); return $this; } diff --git a/src/Unstable/Contacts/Types/CreateContactResponse.php b/src/Unstable/Contacts/Types/CreateContactResponse.php index cb278878..eaf5d720 100644 --- a/src/Unstable/Contacts/Types/CreateContactResponse.php +++ b/src/Unstable/Contacts/Types/CreateContactResponse.php @@ -138,6 +138,7 @@ public function getEnabledPushMessaging(): ?bool public function setEnabledPushMessaging(?bool $value = null): self { $this->enabledPushMessaging = $value; + $this->_setField('enabledPushMessaging'); return $this; } diff --git a/src/Unstable/Contacts/Types/MergeContactResponse.php b/src/Unstable/Contacts/Types/MergeContactResponse.php index 2ae3b477..e0e79ab7 100644 --- a/src/Unstable/Contacts/Types/MergeContactResponse.php +++ b/src/Unstable/Contacts/Types/MergeContactResponse.php @@ -138,6 +138,7 @@ public function getEnabledPushMessaging(): ?bool public function setEnabledPushMessaging(?bool $value = null): self { $this->enabledPushMessaging = $value; + $this->_setField('enabledPushMessaging'); return $this; } diff --git a/src/Unstable/Contacts/Types/ShowContactByExternalIdResponse.php b/src/Unstable/Contacts/Types/ShowContactByExternalIdResponse.php index ff000453..cc11e76c 100644 --- a/src/Unstable/Contacts/Types/ShowContactByExternalIdResponse.php +++ b/src/Unstable/Contacts/Types/ShowContactByExternalIdResponse.php @@ -138,6 +138,7 @@ public function getEnabledPushMessaging(): ?bool public function setEnabledPushMessaging(?bool $value = null): self { $this->enabledPushMessaging = $value; + $this->_setField('enabledPushMessaging'); return $this; } diff --git a/src/Unstable/Contacts/Types/ShowContactResponse.php b/src/Unstable/Contacts/Types/ShowContactResponse.php index 043dab89..3d798829 100644 --- a/src/Unstable/Contacts/Types/ShowContactResponse.php +++ b/src/Unstable/Contacts/Types/ShowContactResponse.php @@ -138,6 +138,7 @@ public function getEnabledPushMessaging(): ?bool public function setEnabledPushMessaging(?bool $value = null): self { $this->enabledPushMessaging = $value; + $this->_setField('enabledPushMessaging'); return $this; } diff --git a/src/Unstable/Contacts/Types/UpdateContactResponse.php b/src/Unstable/Contacts/Types/UpdateContactResponse.php index 7ed2fe2c..6ed9b03c 100644 --- a/src/Unstable/Contacts/Types/UpdateContactResponse.php +++ b/src/Unstable/Contacts/Types/UpdateContactResponse.php @@ -138,6 +138,7 @@ public function getEnabledPushMessaging(): ?bool public function setEnabledPushMessaging(?bool $value = null): self { $this->enabledPushMessaging = $value; + $this->_setField('enabledPushMessaging'); return $this; } diff --git a/src/Unstable/Conversations/ConversationsClient.php b/src/Unstable/Conversations/ConversationsClient.php index e573068b..8de7d583 100644 --- a/src/Unstable/Conversations/ConversationsClient.php +++ b/src/Unstable/Conversations/ConversationsClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\Conversations; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\Conversations\Requests\ListConversationsRequest; use Intercom\Unstable\Types\ConversationList; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\Conversations\Requests\CreateConversationRequest; use Intercom\Unstable\Messages\Types\Message; @@ -22,7 +21,7 @@ use Intercom\Unstable\Conversations\Requests\DeleteConversationRequest; use Intercom\Unstable\Types\ConversationDeleted; use Intercom\Unstable\Types\SearchRequest; -use Intercom\Unstable\Conversations\Requests\ReplyConversationRequest; +use Intercom\Unstable\Conversations\Requests\ReplyConversationBody; use Intercom\Unstable\Conversations\Requests\ManageConversationRequest; use Intercom\Unstable\Conversations\Requests\AttachContactToConversationRequest; use Intercom\Unstable\Conversations\Requests\DetachContactFromConversationRequest; @@ -77,6 +76,16 @@ public function __construct( * See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#pagination-for-list-apis) for more details on how to use the `starting_after` param. * {% /admonition %} * + * Example: + * ```php + * $client->conversations->list( + * new ListConversationsRequest([ + * 'perPage' => 1, + * 'startingAfter' => 'starting_after', + * ]), + * ); + * ``` + * * @param ListConversationsRequest $request * @param ?array{ * baseUrl?: string, @@ -86,11 +95,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ConversationList + * @return ?ConversationList * @throws IntercomException * @throws IntercomApiException */ - public function listConversations(ListConversationsRequest $request = new ListConversationsRequest(), ?array $options = null): ConversationList + public function listConversations(ListConversationsRequest $request = new ListConversationsRequest(), ?array $options = null): ?ConversationList { $options = array_merge($this->options, $options ?? []); $query = []; @@ -113,20 +122,13 @@ public function listConversations(ListConversationsRequest $request = new ListCo $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ConversationList::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); } @@ -149,6 +151,19 @@ public function listConversations(ListConversationsRequest $request = new ListCo * This will return the Message model that has been created. * * + * Example: + * ```php + * $client->conversations->create( + * new CreateConversationRequest([ + * 'from' => new CreateConversationRequestFrom([ + * 'type' => CreateConversationRequestFromType::User->value, + * 'id' => '6762f11b1bb69f9f2193bba3', + * ]), + * 'body' => 'Hello there', + * ]), + * ); + * ``` + * * @param CreateConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -158,11 +173,11 @@ public function listConversations(ListConversationsRequest $request = new ListCo * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Message + * @return ?Message * @throws IntercomException * @throws IntercomApiException */ - public function createConversation(CreateConversationRequest $request, ?array $options = null): Message + public function createConversation(CreateConversationRequest $request, ?array $options = null): ?Message { $options = array_merge($this->options, $options ?? []); try { @@ -178,20 +193,13 @@ public function createConversation(CreateConversationRequest $request, ?array $o $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Message::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); } @@ -214,6 +222,17 @@ public function createConversation(CreateConversationRequest $request, ?array $o * * For AI agent conversation metadata, please note that you need to have the agent enabled in your workspace, which is a [paid feature](https://www.intercom.com/help/en/articles/8205718-fin-resolutions#h_97f8c2e671). * + * Example: + * ```php + * $client->unstable->conversations->retrieveConversation( + * new RetrieveConversationRequest([ + * 'id' => 1, + * 'displayAs' => 'plaintext', + * 'includeTranslations' => true, + * ]), + * ); + * ``` + * * @param RetrieveConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -223,11 +242,11 @@ public function createConversation(CreateConversationRequest $request, ?array $o * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Conversation + * @return ?Conversation * @throws IntercomException * @throws IntercomApiException */ - public function retrieveConversation(RetrieveConversationRequest $request, ?array $options = null): Conversation + public function retrieveConversation(RetrieveConversationRequest $request, ?array $options = null): ?Conversation { $options = array_merge($this->options, $options ?? []); $query = []; @@ -241,7 +260,7 @@ public function retrieveConversation(RetrieveConversationRequest $request, ?arra $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "conversations/{$request->getId()}", + path: "conversations/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::GET, query: $query, ), @@ -250,20 +269,13 @@ public function retrieveConversation(RetrieveConversationRequest $request, ?arra $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Conversation::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); } @@ -289,6 +301,22 @@ public function retrieveConversation(RetrieveConversationRequest $request, ?arra * {% /admonition %} * * + * Example: + * ```php + * $client->unstable->conversations->updateConversation( + * new UpdateConversationRequest([ + * 'id' => 1, + * 'displayAs' => 'plaintext', + * 'read' => true, + * 'title' => 'new conversation title', + * 'customAttributes' => [ + * 'issue_type' => 'Billing', + * 'priority' => 'High', + * ], + * ]), + * ); + * ``` + * * @param UpdateConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -298,11 +326,11 @@ public function retrieveConversation(RetrieveConversationRequest $request, ?arra * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Conversation + * @return ?Conversation * @throws IntercomException * @throws IntercomApiException */ - public function updateConversation(UpdateConversationRequest $request, ?array $options = null): Conversation + public function updateConversation(UpdateConversationRequest $request, ?array $options = null): ?Conversation { $options = array_merge($this->options, $options ?? []); $query = []; @@ -313,7 +341,7 @@ public function updateConversation(UpdateConversationRequest $request, ?array $o $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "conversations/{$request->getId()}", + path: "conversations/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::PUT, query: $query, body: $request, @@ -323,20 +351,13 @@ public function updateConversation(UpdateConversationRequest $request, ?array $o $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Conversation::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); } @@ -350,6 +371,15 @@ public function updateConversation(UpdateConversationRequest $request, ?array $o /** * You can delete a single conversation. * + * Example: + * ```php + * $client->unstable->conversations->deleteConversation( + * new DeleteConversationRequest([ + * 'id' => 1, + * ]), + * ); + * ``` + * * @param DeleteConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -359,18 +389,18 @@ public function updateConversation(UpdateConversationRequest $request, ?array $o * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ConversationDeleted + * @return ?ConversationDeleted * @throws IntercomException * @throws IntercomApiException */ - public function deleteConversation(DeleteConversationRequest $request, ?array $options = null): ConversationDeleted + 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->getId()}", + path: "conversations/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::DELETE, ), $options, @@ -378,20 +408,13 @@ public function deleteConversation(DeleteConversationRequest $request, ?array $o $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -503,6 +526,20 @@ public function deleteConversation(DeleteConversationRequest $request, ?array $o * | ^ | String | Starts With | * | $ | String | Ends With | * + * Example: + * ```php + * $client->unstable->conversations->searchConversations( + * new SearchRequest([ + * 'query' => new SingleFilterSearchRequest([ + * 'value' => [], + * ]), + * 'pagination' => new StartingAfterPaging([ + * 'perPage' => 5, + * ]), + * ]), + * ); + * ``` + * * @param SearchRequest $request * @param ?array{ * baseUrl?: string, @@ -512,11 +549,11 @@ public function deleteConversation(DeleteConversationRequest $request, ?array $o * queryParameters?: array, * bodyProperties?: array, * } $options - * @return ConversationList + * @return ?ConversationList * @throws IntercomException * @throws IntercomApiException */ - public function searchConversations(SearchRequest $request, ?array $options = null): ConversationList + public function searchConversations(SearchRequest $request, ?array $options = null): ?ConversationList { $options = array_merge($this->options, $options ?? []); try { @@ -532,20 +569,13 @@ public function searchConversations(SearchRequest $request, ?array $options = nu $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return ConversationList::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); } @@ -559,7 +589,22 @@ public function searchConversations(SearchRequest $request, ?array $options = nu /** * You can reply to a conversation with a message from an admin or on behalf of a contact, or with a note for admins. * - * @param ReplyConversationRequest $request + * Example: + * ```php + * $client->unstable->conversations->replyConversation( + * new ReplyConversationBody([ + * 'id' => '123 or "last"', + * 'body' => new ContactReplyIntercomUserIdRequest([ + * 'messageType' => 'comment', + * 'type' => 'user', + * 'body' => 'Thanks again :)', + * 'intercomUserId' => '6762f1571bb69f9f2193bbbb', + * ]), + * ]), + * ); + * ``` + * + * @param ReplyConversationBody $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -568,18 +613,18 @@ public function searchConversations(SearchRequest $request, ?array $options = nu * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Conversation + * @return ?Conversation * @throws IntercomException * @throws IntercomApiException */ - public function replyConversation(ReplyConversationRequest $request, ?array $options = null): Conversation + public function replyConversation(ReplyConversationBody $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->getId()}/reply", + path: "conversations/" . RawClient::encodePathParam($request->getId()) . "/reply", method: HttpMethod::POST, body: $request->getBody(), ), @@ -588,20 +633,13 @@ public function replyConversation(ReplyConversationRequest $request, ?array $opt $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Conversation::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); } @@ -619,6 +657,19 @@ public function replyConversation(ReplyConversationRequest $request, ?array $opt * - Open a conversation which is `snoozed` or `closed` * - Assign a conversation to an admin and/or team. * + * Example: + * ```php + * $client->unstable->conversations->manageConversation( + * new ManageConversationRequest([ + * 'id' => '123', + * 'body' => ManageConversationRequestBody::close(new CloseConversationRequest([ + * 'type' => 'admin', + * 'adminId' => '12345', + * ])), + * ]), + * ); + * ``` + * * @param ManageConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -628,18 +679,18 @@ public function replyConversation(ReplyConversationRequest $request, ?array $opt * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Conversation + * @return ?Conversation * @throws IntercomException * @throws IntercomApiException */ - public function manageConversation(ManageConversationRequest $request, ?array $options = null): Conversation + public function manageConversation(ManageConversationRequest $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->getId()}/parts", + path: "conversations/" . RawClient::encodePathParam($request->getId()) . "/parts", method: HttpMethod::POST, body: $request->getBody(), ), @@ -648,20 +699,13 @@ public function manageConversation(ManageConversationRequest $request, ?array $o $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Conversation::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); } @@ -680,6 +724,19 @@ public function manageConversation(ManageConversationRequest $request, ?array $o * {% /admonition %} * * + * Example: + * ```php + * $client->unstable->conversations->attachContactToConversation( + * new AttachContactToConversationRequest([ + * 'id' => '123', + * 'adminId' => '12345', + * 'customer' => new AttachContactToConversationRequestCustomerIntercomUserId([ + * 'intercomUserId' => '6762f19b1bb69f9f2193bbd4', + * ]), + * ]), + * ); + * ``` + * * @param AttachContactToConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -689,18 +746,18 @@ public function manageConversation(ManageConversationRequest $request, ?array $o * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Conversation + * @return ?Conversation * @throws IntercomException * @throws IntercomApiException */ - public function attachContactToConversation(AttachContactToConversationRequest $request, ?array $options = null): Conversation + public function attachContactToConversation(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->getId()}/customers", + path: "conversations/" . RawClient::encodePathParam($request->getId()) . "/customers", method: HttpMethod::POST, body: $request, ), @@ -709,20 +766,13 @@ public function attachContactToConversation(AttachContactToConversationRequest $ $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Conversation::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); } @@ -741,6 +791,17 @@ public function attachContactToConversation(AttachContactToConversationRequest $ * {% /admonition %} * * + * Example: + * ```php + * $client->conversations->detachContactAsAdmin( + * new DetachContactFromConversationRequest([ + * 'conversationId' => '123', + * 'contactId' => '123', + * 'adminId' => '5017690', + * ]), + * ); + * ``` + * * @param DetachContactFromConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -750,18 +811,18 @@ public function attachContactToConversation(AttachContactToConversationRequest $ * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Conversation + * @return ?Conversation * @throws IntercomException * @throws IntercomApiException */ - public function detachContactFromConversation(DetachContactFromConversationRequest $request, ?array $options = null): Conversation + public function detachContactFromConversation(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/{$request->getContactId()}", + path: "conversations/" . RawClient::encodePathParam($request->getConversationId()) . "/customers/" . RawClient::encodePathParam($request->getContactId()), method: HttpMethod::DELETE, body: $request, ), @@ -770,20 +831,13 @@ public function detachContactFromConversation(DetachContactFromConversationReque $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Conversation::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); } @@ -799,6 +853,15 @@ public function detachContactFromConversation(DetachContactFromConversationReque * * Requires the `read_conversations` OAuth scope. * + * Example: + * ```php + * $client->unstable->conversations->listHandlingEvents( + * new ListHandlingEventsRequest([ + * 'id' => '123', + * ]), + * ); + * ``` + * * @param ListHandlingEventsRequest $request * @param ?array{ * baseUrl?: string, @@ -808,18 +871,18 @@ public function detachContactFromConversation(DetachContactFromConversationReque * queryParameters?: array, * bodyProperties?: array, * } $options - * @return HandlingEventList + * @return ?HandlingEventList * @throws IntercomException * @throws IntercomApiException */ - public function listHandlingEvents(ListHandlingEventsRequest $request, ?array $options = null): HandlingEventList + public function listHandlingEvents(ListHandlingEventsRequest $request, ?array $options = null): ?HandlingEventList { $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->getId()}/handling_events", + path: "conversations/" . RawClient::encodePathParam($request->getId()) . "/handling_events", method: HttpMethod::GET, ), $options, @@ -827,20 +890,13 @@ public function listHandlingEvents(ListHandlingEventsRequest $request, ?array $o $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return HandlingEventList::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); } @@ -859,6 +915,16 @@ public function listHandlingEvents(ListHandlingEventsRequest $request, ?array $o * {% /admonition %} * * + * Example: + * ```php + * $client->conversations->redactConversationPart( + * RedactConversationRequest::conversationPart(new RedactConversationRequestConversationPart([ + * 'conversationId' => '19894788788', + * 'conversationPartId' => '19381789428', + * ])), + * ); + * ``` + * * @param RedactConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -868,11 +934,11 @@ public function listHandlingEvents(ListHandlingEventsRequest $request, ?array $o * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Conversation + * @return ?Conversation * @throws IntercomException * @throws IntercomApiException */ - public function redactConversation(RedactConversationRequest $request, ?array $options = null): Conversation + public function redactConversation(RedactConversationRequest $request, ?array $options = null): ?Conversation { $options = array_merge($this->options, $options ?? []); try { @@ -888,20 +954,13 @@ public function redactConversation(RedactConversationRequest $request, ?array $o $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Conversation::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); } @@ -915,6 +974,16 @@ public function redactConversation(RedactConversationRequest $request, ?array $o /** * You can convert a conversation to a ticket. * + * Example: + * ```php + * $client->unstable->conversations->convertConversationToTicket( + * new ConvertConversationToTicketRequest([ + * 'id' => 1, + * 'ticketTypeId' => '53', + * ]), + * ); + * ``` + * * @param ConvertConversationToTicketRequest $request * @param ?array{ * baseUrl?: string, @@ -935,7 +1004,7 @@ public function convertConversationToTicket(ConvertConversationToTicketRequest $ $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "conversations/{$request->getId()}/convert", + path: "conversations/" . RawClient::encodePathParam($request->getId()) . "/convert", method: HttpMethod::POST, body: $request, ), @@ -951,16 +1020,6 @@ public function convertConversationToTicket(ConvertConversationToTicketRequest $ } } 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); } diff --git a/src/Unstable/Conversations/Requests/AttachContactToConversationRequest.php b/src/Unstable/Conversations/Requests/AttachContactToConversationRequest.php index 02e628c5..cc6aaa2d 100644 --- a/src/Unstable/Conversations/Requests/AttachContactToConversationRequest.php +++ b/src/Unstable/Conversations/Requests/AttachContactToConversationRequest.php @@ -65,6 +65,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -82,6 +83,7 @@ public function getAdminId(): ?string public function setAdminId(?string $value = null): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } @@ -107,6 +109,7 @@ public function getCustomer(): AttachContactToConversationRequestCustomerInterco public function setCustomer(AttachContactToConversationRequestCustomerIntercomUserId|AttachContactToConversationRequestCustomerUserId|AttachContactToConversationRequestCustomerCustomer|null $value = null): self { $this->customer = $value; + $this->_setField('customer'); return $this; } } diff --git a/src/Unstable/Conversations/Requests/ConvertConversationToTicketRequest.php b/src/Unstable/Conversations/Requests/ConvertConversationToTicketRequest.php index 2f652570..ec9a9413 100644 --- a/src/Unstable/Conversations/Requests/ConvertConversationToTicketRequest.php +++ b/src/Unstable/Conversations/Requests/ConvertConversationToTicketRequest.php @@ -67,6 +67,7 @@ public function getId(): int public function setId(int $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -84,6 +85,7 @@ public function getTicketTypeId(): string public function setTicketTypeId(string $value): self { $this->ticketTypeId = $value; + $this->_setField('ticketTypeId'); return $this; } @@ -113,6 +115,7 @@ public function getAttributes(): ?array public function setAttributes(?array $value = null): self { $this->attributes = $value; + $this->_setField('attributes'); return $this; } } diff --git a/src/Unstable/Conversations/Requests/CreateConversationRequest.php b/src/Unstable/Conversations/Requests/CreateConversationRequest.php index a8c3c58e..7883601b 100644 --- a/src/Unstable/Conversations/Requests/CreateConversationRequest.php +++ b/src/Unstable/Conversations/Requests/CreateConversationRequest.php @@ -55,6 +55,7 @@ public function getFrom(): CreateConversationRequestFrom public function setFrom(CreateConversationRequestFrom $value): self { $this->from = $value; + $this->_setField('from'); return $this; } @@ -72,6 +73,7 @@ public function getBody(): string public function setBody(string $value): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -89,6 +91,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } } diff --git a/src/Unstable/Conversations/Requests/DeleteConversationRequest.php b/src/Unstable/Conversations/Requests/DeleteConversationRequest.php index cbb3cc00..62bc1dbf 100644 --- a/src/Unstable/Conversations/Requests/DeleteConversationRequest.php +++ b/src/Unstable/Conversations/Requests/DeleteConversationRequest.php @@ -36,6 +36,7 @@ public function getId(): int public function setId(int $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Conversations/Requests/DetachContactFromConversationRequest.php b/src/Unstable/Conversations/Requests/DetachContactFromConversationRequest.php index bd2c32b1..9db849e5 100644 --- a/src/Unstable/Conversations/Requests/DetachContactFromConversationRequest.php +++ b/src/Unstable/Conversations/Requests/DetachContactFromConversationRequest.php @@ -52,6 +52,7 @@ public function getConversationId(): string public function setConversationId(string $value): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } @@ -69,6 +70,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } @@ -86,6 +88,7 @@ public function getAdminId(): string public function setAdminId(string $value): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } } diff --git a/src/Unstable/Conversations/Requests/ListConversationsRequest.php b/src/Unstable/Conversations/Requests/ListConversationsRequest.php index 205e9ae1..4906e61b 100644 --- a/src/Unstable/Conversations/Requests/ListConversationsRequest.php +++ b/src/Unstable/Conversations/Requests/ListConversationsRequest.php @@ -43,6 +43,7 @@ public function getPerPage(): ?int public function setPerPage(?int $value = null): self { $this->perPage = $value; + $this->_setField('perPage'); return $this; } @@ -60,6 +61,7 @@ public function getStartingAfter(): ?string public function setStartingAfter(?string $value = null): self { $this->startingAfter = $value; + $this->_setField('startingAfter'); return $this; } } diff --git a/src/Unstable/Conversations/Requests/ListHandlingEventsRequest.php b/src/Unstable/Conversations/Requests/ListHandlingEventsRequest.php index 8b061175..040abab2 100644 --- a/src/Unstable/Conversations/Requests/ListHandlingEventsRequest.php +++ b/src/Unstable/Conversations/Requests/ListHandlingEventsRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Conversations/Requests/ManageConversationRequest.php b/src/Unstable/Conversations/Requests/ManageConversationRequest.php index e14e6c87..d518fcc0 100644 --- a/src/Unstable/Conversations/Requests/ManageConversationRequest.php +++ b/src/Unstable/Conversations/Requests/ManageConversationRequest.php @@ -44,6 +44,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -61,6 +62,7 @@ public function getBody(): ManageConversationRequestBody public function setBody(ManageConversationRequestBody $value): self { $this->body = $value; + $this->_setField('body'); return $this; } } diff --git a/src/Unstable/Conversations/Requests/ReplyConversationRequest.php b/src/Unstable/Conversations/Requests/ReplyConversationBody.php similarity index 95% rename from src/Unstable/Conversations/Requests/ReplyConversationRequest.php rename to src/Unstable/Conversations/Requests/ReplyConversationBody.php index 4931520d..aade6f4f 100644 --- a/src/Unstable/Conversations/Requests/ReplyConversationRequest.php +++ b/src/Unstable/Conversations/Requests/ReplyConversationBody.php @@ -8,7 +8,7 @@ use Intercom\Unstable\Types\ContactReplyUserIdRequest; use Intercom\Unstable\Types\AdminReplyConversationRequest; -class ReplyConversationRequest extends JsonSerializableType +class ReplyConversationBody extends JsonSerializableType { /** * @var string $id The Intercom provisioned identifier for the conversation or the string "last" to reply to the last part of the conversation @@ -57,6 +57,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -84,6 +85,7 @@ public function getBody(): ContactReplyIntercomUserIdRequest|ContactReplyEmailRe public function setBody(ContactReplyIntercomUserIdRequest|ContactReplyEmailRequest|ContactReplyUserIdRequest|AdminReplyConversationRequest $value): self { $this->body = $value; + $this->_setField('body'); return $this; } } diff --git a/src/Unstable/Conversations/Requests/RetrieveConversationRequest.php b/src/Unstable/Conversations/Requests/RetrieveConversationRequest.php index c36da92b..81e8aad2 100644 --- a/src/Unstable/Conversations/Requests/RetrieveConversationRequest.php +++ b/src/Unstable/Conversations/Requests/RetrieveConversationRequest.php @@ -50,6 +50,7 @@ public function getId(): int public function setId(int $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -67,6 +68,7 @@ public function getDisplayAs(): ?string public function setDisplayAs(?string $value = null): self { $this->displayAs = $value; + $this->_setField('displayAs'); return $this; } @@ -84,6 +86,7 @@ public function getIncludeTranslations(): ?bool public function setIncludeTranslations(?bool $value = null): self { $this->includeTranslations = $value; + $this->_setField('includeTranslations'); return $this; } } diff --git a/src/Unstable/Conversations/Requests/UpdateConversationRequest.php b/src/Unstable/Conversations/Requests/UpdateConversationRequest.php index d1672868..4a8b92d6 100644 --- a/src/Unstable/Conversations/Requests/UpdateConversationRequest.php +++ b/src/Unstable/Conversations/Requests/UpdateConversationRequest.php @@ -90,6 +90,7 @@ public function getId(): int public function setId(int $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -107,6 +108,7 @@ public function getDisplayAs(): ?string public function setDisplayAs(?string $value = null): self { $this->displayAs = $value; + $this->_setField('displayAs'); return $this; } @@ -124,6 +126,7 @@ public function getRead(): ?bool public function setRead(?bool $value = null): self { $this->read = $value; + $this->_setField('read'); return $this; } @@ -141,6 +144,7 @@ public function getTitle(): ?string public function setTitle(?string $value = null): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -168,6 +172,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } @@ -185,6 +190,7 @@ public function getCompanyId(): ?string public function setCompanyId(?string $value = null): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } } diff --git a/src/Unstable/Conversations/Types/AttachContactToConversationRequestCustomerCustomer.php b/src/Unstable/Conversations/Types/AttachContactToConversationRequestCustomerCustomer.php index b1432bc4..d46073b0 100644 --- a/src/Unstable/Conversations/Types/AttachContactToConversationRequestCustomerCustomer.php +++ b/src/Unstable/Conversations/Types/AttachContactToConversationRequestCustomerCustomer.php @@ -58,6 +58,7 @@ public function getEmail(): string public function setEmail(string $value): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -83,6 +84,7 @@ public function getCustomer(): CustomerRequestIntercomUserId|CustomerRequestUser public function setCustomer(CustomerRequestIntercomUserId|CustomerRequestUserId|CustomerRequestEmail|null $value = null): self { $this->customer = $value; + $this->_setField('customer'); return $this; } diff --git a/src/Unstable/Conversations/Types/AttachContactToConversationRequestCustomerIntercomUserId.php b/src/Unstable/Conversations/Types/AttachContactToConversationRequestCustomerIntercomUserId.php index 6b21e4da..41690d54 100644 --- a/src/Unstable/Conversations/Types/AttachContactToConversationRequestCustomerIntercomUserId.php +++ b/src/Unstable/Conversations/Types/AttachContactToConversationRequestCustomerIntercomUserId.php @@ -58,6 +58,7 @@ public function getIntercomUserId(): string public function setIntercomUserId(string $value): self { $this->intercomUserId = $value; + $this->_setField('intercomUserId'); return $this; } @@ -83,6 +84,7 @@ public function getCustomer(): CustomerRequestIntercomUserId|CustomerRequestUser public function setCustomer(CustomerRequestIntercomUserId|CustomerRequestUserId|CustomerRequestEmail|null $value = null): self { $this->customer = $value; + $this->_setField('customer'); return $this; } diff --git a/src/Unstable/Conversations/Types/AttachContactToConversationRequestCustomerUserId.php b/src/Unstable/Conversations/Types/AttachContactToConversationRequestCustomerUserId.php index a50cd1a0..6436e63f 100644 --- a/src/Unstable/Conversations/Types/AttachContactToConversationRequestCustomerUserId.php +++ b/src/Unstable/Conversations/Types/AttachContactToConversationRequestCustomerUserId.php @@ -58,6 +58,7 @@ public function getUserId(): string public function setUserId(string $value): self { $this->userId = $value; + $this->_setField('userId'); return $this; } @@ -83,6 +84,7 @@ public function getCustomer(): CustomerRequestIntercomUserId|CustomerRequestUser public function setCustomer(CustomerRequestIntercomUserId|CustomerRequestUserId|CustomerRequestEmail|null $value = null): self { $this->customer = $value; + $this->_setField('customer'); return $this; } diff --git a/src/Unstable/Conversations/Types/Conversation.php b/src/Unstable/Conversations/Types/Conversation.php index 55ddc9e6..43d3e363 100644 --- a/src/Unstable/Conversations/Types/Conversation.php +++ b/src/Unstable/Conversations/Types/Conversation.php @@ -283,6 +283,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -300,6 +301,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -317,6 +319,7 @@ public function getTitle(): ?string public function setTitle(?string $value = null): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -334,6 +337,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -351,6 +355,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -368,6 +373,7 @@ public function getWaitingSince(): ?int public function setWaitingSince(?int $value = null): self { $this->waitingSince = $value; + $this->_setField('waitingSince'); return $this; } @@ -385,6 +391,7 @@ public function getSnoozedUntil(): ?int public function setSnoozedUntil(?int $value = null): self { $this->snoozedUntil = $value; + $this->_setField('snoozedUntil'); return $this; } @@ -402,6 +409,7 @@ public function getOpen(): ?bool public function setOpen(?bool $value = null): self { $this->open = $value; + $this->_setField('open'); return $this; } @@ -419,6 +427,7 @@ public function getState(): ?string public function setState(?string $value = null): self { $this->state = $value; + $this->_setField('state'); return $this; } @@ -436,6 +445,7 @@ public function getRead(): ?bool public function setRead(?bool $value = null): self { $this->read = $value; + $this->_setField('read'); return $this; } @@ -453,6 +463,7 @@ public function getPriority(): ?string public function setPriority(?string $value = null): self { $this->priority = $value; + $this->_setField('priority'); return $this; } @@ -470,6 +481,7 @@ public function getAdminAssigneeId(): ?int public function setAdminAssigneeId(?int $value = null): self { $this->adminAssigneeId = $value; + $this->_setField('adminAssigneeId'); return $this; } @@ -487,6 +499,7 @@ public function getTeamAssigneeId(): ?string public function setTeamAssigneeId(?string $value = null): self { $this->teamAssigneeId = $value; + $this->_setField('teamAssigneeId'); return $this; } @@ -504,6 +517,7 @@ public function getCompanyId(): ?string public function setCompanyId(?string $value = null): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } @@ -521,6 +535,7 @@ public function getCompany(): ?Company public function setCompany(?Company $value = null): self { $this->company = $value; + $this->_setField('company'); return $this; } @@ -538,6 +553,7 @@ public function getTags(): ?Tags public function setTags(?Tags $value = null): self { $this->tags = $value; + $this->_setField('tags'); return $this; } @@ -555,6 +571,7 @@ public function getConversationRating(): ?ConversationRating public function setConversationRating(?ConversationRating $value = null): self { $this->conversationRating = $value; + $this->_setField('conversationRating'); return $this; } @@ -572,6 +589,7 @@ public function getSource(): ?ConversationSource public function setSource(?ConversationSource $value = null): self { $this->source = $value; + $this->_setField('source'); return $this; } @@ -589,6 +607,7 @@ public function getContacts(): ?ConversationContacts public function setContacts(?ConversationContacts $value = null): self { $this->contacts = $value; + $this->_setField('contacts'); return $this; } @@ -606,6 +625,7 @@ public function getTeammates(): ?ConversationTeammates public function setTeammates(?ConversationTeammates $value = null): self { $this->teammates = $value; + $this->_setField('teammates'); return $this; } @@ -633,6 +653,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } @@ -650,6 +671,7 @@ public function getFirstContactReply(): ?ConversationFirstContactReply public function setFirstContactReply(?ConversationFirstContactReply $value = null): self { $this->firstContactReply = $value; + $this->_setField('firstContactReply'); return $this; } @@ -667,6 +689,7 @@ public function getSlaApplied(): ?SlaApplied public function setSlaApplied(?SlaApplied $value = null): self { $this->slaApplied = $value; + $this->_setField('slaApplied'); return $this; } @@ -684,6 +707,7 @@ public function getStatistics(): ?ConversationStatistics public function setStatistics(?ConversationStatistics $value = null): self { $this->statistics = $value; + $this->_setField('statistics'); return $this; } @@ -701,6 +725,7 @@ public function getConversationParts(): ?ConversationParts public function setConversationParts(?ConversationParts $value = null): self { $this->conversationParts = $value; + $this->_setField('conversationParts'); return $this; } @@ -718,6 +743,7 @@ public function getLinkedObjects(): ?LinkedObjectList public function setLinkedObjects(?LinkedObjectList $value = null): self { $this->linkedObjects = $value; + $this->_setField('linkedObjects'); return $this; } @@ -735,6 +761,7 @@ public function getAiAgentParticipated(): ?bool public function setAiAgentParticipated(?bool $value = null): self { $this->aiAgentParticipated = $value; + $this->_setField('aiAgentParticipated'); return $this; } @@ -752,6 +779,7 @@ public function getAiAgent(): ?AiAgent public function setAiAgent(?AiAgent $value = null): self { $this->aiAgent = $value; + $this->_setField('aiAgent'); return $this; } diff --git a/src/Unstable/Conversations/Types/CreateConversationRequestFrom.php b/src/Unstable/Conversations/Types/CreateConversationRequestFrom.php index 41747388..0be12544 100644 --- a/src/Unstable/Conversations/Types/CreateConversationRequestFrom.php +++ b/src/Unstable/Conversations/Types/CreateConversationRequestFrom.php @@ -46,6 +46,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -63,6 +64,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } diff --git a/src/Unstable/Conversations/Types/ManageConversationRequestBody.php b/src/Unstable/Conversations/Types/ManageConversationRequestBody.php index ccec3ed8..296eb581 100644 --- a/src/Unstable/Conversations/Types/ManageConversationRequestBody.php +++ b/src/Unstable/Conversations/Types/ManageConversationRequestBody.php @@ -8,7 +8,6 @@ use Intercom\Unstable\Types\OpenConversationRequest; use Intercom\Unstable\Types\AssignConversationRequest; use Exception; -use Intercom\Core\Json\JsonDecoder; class ManageConversationRequestBody extends JsonSerializableType { @@ -275,18 +274,6 @@ public function jsonSerialize(): array 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 */ diff --git a/src/Unstable/CustomChannelEvents/CustomChannelEventsClient.php b/src/Unstable/CustomChannelEvents/CustomChannelEventsClient.php index c04a7063..d1dea780 100644 --- a/src/Unstable/CustomChannelEvents/CustomChannelEventsClient.php +++ b/src/Unstable/CustomChannelEvents/CustomChannelEventsClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\CustomChannelEvents; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\Types\CustomChannelBaseEvent; use Intercom\Unstable\Types\CustomChannelNotificationResponse; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\CustomChannelEvents\Requests\NotifyNewMessageRequest; use Intercom\Unstable\CustomChannelEvents\Requests\NotifyQuickReplySelectedRequest; @@ -58,6 +57,22 @@ public function __construct( * 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. * + * Example: + * ```php + * $client->customChannelEvents->notifyNewConversation( + * new CustomChannelBaseEvent([ + * 'eventId' => 'evt_12345', + * 'externalConversationId' => 'conv_67890', + * 'contact' => new CustomChannelContact([ + * 'type' => CustomChannelContactType::User->value, + * 'externalId' => 'user_001', + * 'name' => 'Jane Doe', + * 'email' => 'jane.doe@example.com', + * ]), + * ]), + * ); + * ``` + * * @param CustomChannelBaseEvent $request * @param ?array{ * baseUrl?: string, @@ -67,11 +82,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return CustomChannelNotificationResponse + * @return ?CustomChannelNotificationResponse * @throws IntercomException * @throws IntercomApiException */ - public function notifyNewConversation(CustomChannelBaseEvent $request, ?array $options = null): CustomChannelNotificationResponse + public function notifyNewConversation(CustomChannelBaseEvent $request, ?array $options = null): ?CustomChannelNotificationResponse { $options = array_merge($this->options, $options ?? []); try { @@ -87,20 +102,13 @@ public function notifyNewConversation(CustomChannelBaseEvent $request, ?array $o $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -115,6 +123,23 @@ public function notifyNewConversation(CustomChannelBaseEvent $request, ?array $o * 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. * + * Example: + * ```php + * $client->customChannelEvents->notifyNewMessage( + * new NotifyNewMessageRequest([ + * 'eventId' => 'evt_54321', + * 'externalConversationId' => 'conv_98765', + * 'contact' => new CustomChannelContact([ + * 'type' => CustomChannelContactType::User->value, + * 'externalId' => 'user_002', + * 'name' => 'John Smith', + * 'email' => 'john.smith@example.com', + * ]), + * 'body' => 'Hello, I need help with my order.', + * ]), + * ); + * ``` + * * @param NotifyNewMessageRequest $request * @param ?array{ * baseUrl?: string, @@ -124,11 +149,11 @@ public function notifyNewConversation(CustomChannelBaseEvent $request, ?array $o * queryParameters?: array, * bodyProperties?: array, * } $options - * @return CustomChannelNotificationResponse + * @return ?CustomChannelNotificationResponse * @throws IntercomException * @throws IntercomApiException */ - public function notifyNewMessage(NotifyNewMessageRequest $request, ?array $options = null): CustomChannelNotificationResponse + public function notifyNewMessage(NotifyNewMessageRequest $request, ?array $options = null): ?CustomChannelNotificationResponse { $options = array_merge($this->options, $options ?? []); try { @@ -144,20 +169,13 @@ public function notifyNewMessage(NotifyNewMessageRequest $request, ?array $optio $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -172,6 +190,23 @@ public function notifyNewMessage(NotifyNewMessageRequest $request, ?array $optio * 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. * + * Example: + * ```php + * $client->customChannelEvents->notifyQuickReplySelected( + * new NotifyQuickReplySelectedRequest([ + * 'eventId' => 'evt_67890', + * 'externalConversationId' => 'conv_13579', + * 'contact' => new CustomChannelContact([ + * 'type' => CustomChannelContactType::User->value, + * 'externalId' => 'user_003', + * 'name' => 'Alice Example', + * 'email' => 'alice@example.com', + * ]), + * 'quickReplyOptionId' => '1234', + * ]), + * ); + * ``` + * * @param NotifyQuickReplySelectedRequest $request * @param ?array{ * baseUrl?: string, @@ -181,11 +216,11 @@ public function notifyNewMessage(NotifyNewMessageRequest $request, ?array $optio * queryParameters?: array, * bodyProperties?: array, * } $options - * @return CustomChannelNotificationResponse + * @return ?CustomChannelNotificationResponse * @throws IntercomException * @throws IntercomApiException */ - public function notifyQuickReplySelected(NotifyQuickReplySelectedRequest $request, ?array $options = null): CustomChannelNotificationResponse + public function notifyQuickReplySelected(NotifyQuickReplySelectedRequest $request, ?array $options = null): ?CustomChannelNotificationResponse { $options = array_merge($this->options, $options ?? []); try { @@ -201,20 +236,13 @@ public function notifyQuickReplySelected(NotifyQuickReplySelectedRequest $reques $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -229,6 +257,26 @@ public function notifyQuickReplySelected(NotifyQuickReplySelectedRequest $reques * 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. * + * Example: + * ```php + * $client->customChannelEvents->notifyAttributeCollected( + * new NotifyAttributeCollectedRequest([ + * 'eventId' => 'evt_24680', + * 'externalConversationId' => 'conv_11223', + * 'contact' => new CustomChannelContact([ + * 'type' => CustomChannelContactType::User->value, + * 'externalId' => 'user_004', + * 'name' => 'Bob Example', + * 'email' => 'bob@example.com', + * ]), + * 'attribute' => new CustomChannelAttribute([ + * 'id' => 'shipping_address', + * 'value' => '123 Main St, Springfield', + * ]), + * ]), + * ); + * ``` + * * @param NotifyAttributeCollectedRequest $request * @param ?array{ * baseUrl?: string, @@ -238,11 +286,11 @@ public function notifyQuickReplySelected(NotifyQuickReplySelectedRequest $reques * queryParameters?: array, * bodyProperties?: array, * } $options - * @return CustomChannelNotificationResponse + * @return ?CustomChannelNotificationResponse * @throws IntercomException * @throws IntercomApiException */ - public function notifyAttributeCollected(NotifyAttributeCollectedRequest $request, ?array $options = null): CustomChannelNotificationResponse + public function notifyAttributeCollected(NotifyAttributeCollectedRequest $request, ?array $options = null): ?CustomChannelNotificationResponse { $options = array_merge($this->options, $options ?? []); try { @@ -258,20 +306,13 @@ public function notifyAttributeCollected(NotifyAttributeCollectedRequest $reques $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } diff --git a/src/Unstable/CustomChannelEvents/Requests/NotifyAttributeCollectedRequest.php b/src/Unstable/CustomChannelEvents/Requests/NotifyAttributeCollectedRequest.php index 4d1230d7..63c297d0 100644 --- a/src/Unstable/CustomChannelEvents/Requests/NotifyAttributeCollectedRequest.php +++ b/src/Unstable/CustomChannelEvents/Requests/NotifyAttributeCollectedRequest.php @@ -49,6 +49,7 @@ public function getAttribute(): CustomChannelAttribute public function setAttribute(CustomChannelAttribute $value): self { $this->attribute = $value; + $this->_setField('attribute'); return $this; } } diff --git a/src/Unstable/CustomChannelEvents/Requests/NotifyNewMessageRequest.php b/src/Unstable/CustomChannelEvents/Requests/NotifyNewMessageRequest.php index baf5128c..a290dcb8 100644 --- a/src/Unstable/CustomChannelEvents/Requests/NotifyNewMessageRequest.php +++ b/src/Unstable/CustomChannelEvents/Requests/NotifyNewMessageRequest.php @@ -48,6 +48,7 @@ public function getBody(): string public function setBody(string $value): self { $this->body = $value; + $this->_setField('body'); return $this; } } diff --git a/src/Unstable/CustomChannelEvents/Requests/NotifyQuickReplySelectedRequest.php b/src/Unstable/CustomChannelEvents/Requests/NotifyQuickReplySelectedRequest.php index 292a91bf..8fc6cbf3 100644 --- a/src/Unstable/CustomChannelEvents/Requests/NotifyQuickReplySelectedRequest.php +++ b/src/Unstable/CustomChannelEvents/Requests/NotifyQuickReplySelectedRequest.php @@ -48,6 +48,7 @@ public function getQuickReplyOptionId(): string public function setQuickReplyOptionId(string $value): self { $this->quickReplyOptionId = $value; + $this->_setField('quickReplyOptionId'); return $this; } } diff --git a/src/Unstable/CustomObjectInstances/CustomObjectInstancesClient.php b/src/Unstable/CustomObjectInstances/CustomObjectInstancesClient.php index 9baf82f3..9786cf42 100644 --- a/src/Unstable/CustomObjectInstances/CustomObjectInstancesClient.php +++ b/src/Unstable/CustomObjectInstances/CustomObjectInstancesClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\CustomObjectInstances; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\CustomObjectInstances\Requests\GetCustomObjectInstancesByExternalIdRequest; use Intercom\Unstable\CustomObjectInstances\Types\CustomObjectInstance; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\CustomObjectInstances\Requests\CreateOrUpdateCustomObjectInstanceRequest; use Intercom\Unstable\CustomObjectInstances\Requests\DeleteCustomObjectInstancesByIdRequest; @@ -59,6 +58,16 @@ public function __construct( /** * Fetch a Custom Object Instance by external_id. * + * Example: + * ```php + * $client->customObjectInstances->getCustomObjectInstancesByExternalId( + * new GetCustomObjectInstancesByExternalIdRequest([ + * 'customObjectTypeIdentifier' => 'Order', + * 'externalId' => 'external_id', + * ]), + * ); + * ``` + * * @param GetCustomObjectInstancesByExternalIdRequest $request * @param ?array{ * baseUrl?: string, @@ -81,7 +90,7 @@ public function getCustomObjectInstancesByExternalId(GetCustomObjectInstancesByE $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "custom_object_instances/{$request->getCustomObjectTypeIdentifier()}", + path: "custom_object_instances/" . RawClient::encodePathParam($request->getCustomObjectTypeIdentifier()), method: HttpMethod::GET, query: $query, ), @@ -97,16 +106,6 @@ public function getCustomObjectInstancesByExternalId(GetCustomObjectInstancesByE } } 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); } @@ -120,6 +119,22 @@ public function getCustomObjectInstancesByExternalId(GetCustomObjectInstancesByE /** * Create or update a custom object instance * + * Example: + * ```php + * $client->customObjectInstances->createCustomObjectInstances( + * new CreateOrUpdateCustomObjectInstanceRequest([ + * 'customObjectTypeIdentifier' => 'Order', + * 'externalId' => '123', + * 'externalCreatedAt' => 1392036272, + * 'externalUpdatedAt' => 1392036272, + * 'customAttributes' => [ + * 'order_number' => 'ORDER-12345', + * 'total_amount' => 'custom_attributes', + * ], + * ]), + * ); + * ``` + * * @param CreateOrUpdateCustomObjectInstanceRequest $request * @param ?array{ * baseUrl?: string, @@ -140,7 +155,7 @@ public function createCustomObjectInstances(CreateOrUpdateCustomObjectInstanceRe $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "custom_object_instances/{$request->getCustomObjectTypeIdentifier()}", + path: "custom_object_instances/" . RawClient::encodePathParam($request->getCustomObjectTypeIdentifier()), method: HttpMethod::POST, body: $request, ), @@ -156,16 +171,6 @@ public function createCustomObjectInstances(CreateOrUpdateCustomObjectInstanceRe } } 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); } @@ -179,6 +184,16 @@ public function createCustomObjectInstances(CreateOrUpdateCustomObjectInstanceRe /** * Delete a single Custom Object instance by external_id. * + * Example: + * ```php + * $client->customObjectInstances->deleteCustomObjectInstancesById( + * new DeleteCustomObjectInstancesByIdRequest([ + * 'customObjectTypeIdentifier' => 'Order', + * 'externalId' => 'external_id', + * ]), + * ); + * ``` + * * @param DeleteCustomObjectInstancesByIdRequest $request * @param ?array{ * baseUrl?: string, @@ -188,11 +203,11 @@ public function createCustomObjectInstances(CreateOrUpdateCustomObjectInstanceRe * queryParameters?: array, * bodyProperties?: array, * } $options - * @return CustomObjectInstanceDeleted + * @return ?CustomObjectInstanceDeleted * @throws IntercomException * @throws IntercomApiException */ - public function deleteCustomObjectInstancesById(DeleteCustomObjectInstancesByIdRequest $request, ?array $options = null): CustomObjectInstanceDeleted + public function deleteCustomObjectInstancesById(DeleteCustomObjectInstancesByIdRequest $request, ?array $options = null): ?CustomObjectInstanceDeleted { $options = array_merge($this->options, $options ?? []); $query = []; @@ -201,7 +216,7 @@ public function deleteCustomObjectInstancesById(DeleteCustomObjectInstancesByIdR $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "custom_object_instances/{$request->getCustomObjectTypeIdentifier()}", + path: "custom_object_instances/" . RawClient::encodePathParam($request->getCustomObjectTypeIdentifier()), method: HttpMethod::DELETE, query: $query, ), @@ -210,20 +225,13 @@ public function deleteCustomObjectInstancesById(DeleteCustomObjectInstancesByIdR $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -237,6 +245,16 @@ public function deleteCustomObjectInstancesById(DeleteCustomObjectInstancesByIdR /** * Fetch a Custom Object Instance by id. * + * Example: + * ```php + * $client->unstable->customObjectInstances->getCustomObjectInstancesById( + * new GetCustomObjectInstancesByIdRequest([ + * 'customObjectTypeIdentifier' => 'Order', + * 'id' => 'id', + * ]), + * ); + * ``` + * * @param GetCustomObjectInstancesByIdRequest $request * @param ?array{ * baseUrl?: string, @@ -257,7 +275,7 @@ public function getCustomObjectInstancesById(GetCustomObjectInstancesByIdRequest $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "custom_object_instances/{$request->getCustomObjectTypeIdentifier()}/{$request->getId()}", + path: "custom_object_instances/" . RawClient::encodePathParam($request->getCustomObjectTypeIdentifier()) . "/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::GET, ), $options, @@ -272,16 +290,6 @@ public function getCustomObjectInstancesById(GetCustomObjectInstancesByIdRequest } } 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); } @@ -295,6 +303,16 @@ public function getCustomObjectInstancesById(GetCustomObjectInstancesByIdRequest /** * Delete a single Custom Object instance using the Intercom defined id. * + * Example: + * ```php + * $client->unstable->customObjectInstances->deleteCustomObjectInstancesByExternalId( + * new DeleteCustomObjectInstancesByExternalIdRequest([ + * 'customObjectTypeIdentifier' => 'Order', + * 'id' => 'id', + * ]), + * ); + * ``` + * * @param DeleteCustomObjectInstancesByExternalIdRequest $request * @param ?array{ * baseUrl?: string, @@ -304,18 +322,18 @@ public function getCustomObjectInstancesById(GetCustomObjectInstancesByIdRequest * queryParameters?: array, * bodyProperties?: array, * } $options - * @return CustomObjectInstanceDeleted + * @return ?CustomObjectInstanceDeleted * @throws IntercomException * @throws IntercomApiException */ - public function deleteCustomObjectInstancesByExternalId(DeleteCustomObjectInstancesByExternalIdRequest $request, ?array $options = null): CustomObjectInstanceDeleted + 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->getId()}", + path: "custom_object_instances/" . RawClient::encodePathParam($request->getCustomObjectTypeIdentifier()) . "/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::DELETE, ), $options, @@ -323,20 +341,13 @@ public function deleteCustomObjectInstancesByExternalId(DeleteCustomObjectInstan $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } diff --git a/src/Unstable/CustomObjectInstances/Requests/CreateOrUpdateCustomObjectInstanceRequest.php b/src/Unstable/CustomObjectInstances/Requests/CreateOrUpdateCustomObjectInstanceRequest.php index 5f18b68f..80f9144e 100644 --- a/src/Unstable/CustomObjectInstances/Requests/CreateOrUpdateCustomObjectInstanceRequest.php +++ b/src/Unstable/CustomObjectInstances/Requests/CreateOrUpdateCustomObjectInstanceRequest.php @@ -71,6 +71,7 @@ public function getCustomObjectTypeIdentifier(): string public function setCustomObjectTypeIdentifier(string $value): self { $this->customObjectTypeIdentifier = $value; + $this->_setField('customObjectTypeIdentifier'); return $this; } @@ -88,6 +89,7 @@ public function getExternalId(): ?string public function setExternalId(?string $value = null): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } @@ -105,6 +107,7 @@ public function getExternalCreatedAt(): ?int public function setExternalCreatedAt(?int $value = null): self { $this->externalCreatedAt = $value; + $this->_setField('externalCreatedAt'); return $this; } @@ -122,6 +125,7 @@ public function getExternalUpdatedAt(): ?int public function setExternalUpdatedAt(?int $value = null): self { $this->externalUpdatedAt = $value; + $this->_setField('externalUpdatedAt'); return $this; } @@ -139,6 +143,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } } diff --git a/src/Unstable/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByExternalIdRequest.php b/src/Unstable/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByExternalIdRequest.php index cd98c17a..d172cf57 100644 --- a/src/Unstable/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByExternalIdRequest.php +++ b/src/Unstable/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByExternalIdRequest.php @@ -43,6 +43,7 @@ public function getCustomObjectTypeIdentifier(): string public function setCustomObjectTypeIdentifier(string $value): self { $this->customObjectTypeIdentifier = $value; + $this->_setField('customObjectTypeIdentifier'); return $this; } @@ -60,6 +61,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByIdRequest.php b/src/Unstable/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByIdRequest.php index 16a07999..20899853 100644 --- a/src/Unstable/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByIdRequest.php +++ b/src/Unstable/CustomObjectInstances/Requests/DeleteCustomObjectInstancesByIdRequest.php @@ -12,7 +12,7 @@ class DeleteCustomObjectInstancesByIdRequest extends JsonSerializableType private string $customObjectTypeIdentifier; /** - * @var string $externalId + * @var string $externalId The unique identifier for the instance in the external system it originated from. */ private string $externalId; @@ -43,6 +43,7 @@ public function getCustomObjectTypeIdentifier(): string public function setCustomObjectTypeIdentifier(string $value): self { $this->customObjectTypeIdentifier = $value; + $this->_setField('customObjectTypeIdentifier'); return $this; } @@ -60,6 +61,7 @@ public function getExternalId(): string public function setExternalId(string $value): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } } diff --git a/src/Unstable/CustomObjectInstances/Requests/GetCustomObjectInstancesByExternalIdRequest.php b/src/Unstable/CustomObjectInstances/Requests/GetCustomObjectInstancesByExternalIdRequest.php index 51b73c69..7b769ea1 100644 --- a/src/Unstable/CustomObjectInstances/Requests/GetCustomObjectInstancesByExternalIdRequest.php +++ b/src/Unstable/CustomObjectInstances/Requests/GetCustomObjectInstancesByExternalIdRequest.php @@ -12,7 +12,7 @@ class GetCustomObjectInstancesByExternalIdRequest extends JsonSerializableType private string $customObjectTypeIdentifier; /** - * @var string $externalId + * @var string $externalId The unique identifier for the instance in the external system it originated from. */ private string $externalId; @@ -43,6 +43,7 @@ public function getCustomObjectTypeIdentifier(): string public function setCustomObjectTypeIdentifier(string $value): self { $this->customObjectTypeIdentifier = $value; + $this->_setField('customObjectTypeIdentifier'); return $this; } @@ -60,6 +61,7 @@ public function getExternalId(): string public function setExternalId(string $value): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } } diff --git a/src/Unstable/CustomObjectInstances/Requests/GetCustomObjectInstancesByIdRequest.php b/src/Unstable/CustomObjectInstances/Requests/GetCustomObjectInstancesByIdRequest.php index b58f2926..c16459bf 100644 --- a/src/Unstable/CustomObjectInstances/Requests/GetCustomObjectInstancesByIdRequest.php +++ b/src/Unstable/CustomObjectInstances/Requests/GetCustomObjectInstancesByIdRequest.php @@ -43,6 +43,7 @@ public function getCustomObjectTypeIdentifier(): string public function setCustomObjectTypeIdentifier(string $value): self { $this->customObjectTypeIdentifier = $value; + $this->_setField('customObjectTypeIdentifier'); return $this; } @@ -60,6 +61,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/CustomObjectInstances/Types/CustomObjectInstance.php b/src/Unstable/CustomObjectInstances/Types/CustomObjectInstance.php index 5de4feb6..0d0dc3fd 100644 --- a/src/Unstable/CustomObjectInstances/Types/CustomObjectInstance.php +++ b/src/Unstable/CustomObjectInstances/Types/CustomObjectInstance.php @@ -98,6 +98,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -115,6 +116,7 @@ public function getExternalId(): ?string public function setExternalId(?string $value = null): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } @@ -132,6 +134,7 @@ public function getExternalCreatedAt(): ?int public function setExternalCreatedAt(?int $value = null): self { $this->externalCreatedAt = $value; + $this->_setField('externalCreatedAt'); return $this; } @@ -149,6 +152,7 @@ public function getExternalUpdatedAt(): ?int public function setExternalUpdatedAt(?int $value = null): self { $this->externalUpdatedAt = $value; + $this->_setField('externalUpdatedAt'); return $this; } @@ -166,6 +170,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -183,6 +188,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -200,6 +206,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -217,6 +224,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } diff --git a/src/Unstable/DataAttributes/DataAttributesClient.php b/src/Unstable/DataAttributes/DataAttributesClient.php index 13125bbe..4217f3ff 100644 --- a/src/Unstable/DataAttributes/DataAttributesClient.php +++ b/src/Unstable/DataAttributes/DataAttributesClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\DataAttributes; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\DataAttributes\Requests\LisDataAttributesRequest; use Intercom\Unstable\Types\DataAttributeList; @@ -12,10 +12,9 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\DataAttributes\Types\DataAttribute; -use Intercom\Unstable\DataAttributes\Requests\UpdateDataAttributeRequest; +use Intercom\Unstable\DataAttributes\Requests\UpdateDataAttributeBody; class DataAttributesClient { @@ -56,6 +55,16 @@ public function __construct( /** * You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. * + * Example: + * ```php + * $client->dataAttributes->list( + * new ListDataAttributesRequest([ + * 'model' => DataAttributesListRequestModel::Contact->value, + * 'includeArchived' => true, + * ]), + * ); + * ``` + * * @param LisDataAttributesRequest $request * @param ?array{ * baseUrl?: string, @@ -65,11 +74,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return DataAttributeList + * @return ?DataAttributeList * @throws IntercomException * @throws IntercomApiException */ - public function lisDataAttributes(LisDataAttributesRequest $request = new LisDataAttributesRequest(), ?array $options = null): DataAttributeList + public function lisDataAttributes(LisDataAttributesRequest $request = new LisDataAttributesRequest(), ?array $options = null): ?DataAttributeList { $options = array_merge($this->options, $options ?? []); $query = []; @@ -92,20 +101,13 @@ public function lisDataAttributes(LisDataAttributesRequest $request = new LisDat $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return DataAttributeList::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); } @@ -119,6 +121,15 @@ public function lisDataAttributes(LisDataAttributesRequest $request = new LisDat /** * You can create a data attributes for a `contact` or a `company`. * + * Example: + * ```php + * $client->unstable->dataAttributes->createDataAttribute( + * [ + * 'key' => "value", + * ], + * ); + * ``` + * * @param mixed $request * @param ?array{ * baseUrl?: string, @@ -128,11 +139,11 @@ public function lisDataAttributes(LisDataAttributesRequest $request = new LisDat * queryParameters?: array, * bodyProperties?: array, * } $options - * @return DataAttribute + * @return ?DataAttribute * @throws IntercomException * @throws IntercomApiException */ - public function createDataAttribute(mixed $request, ?array $options = null): DataAttribute + public function createDataAttribute(mixed $request, ?array $options = null): ?DataAttribute { $options = array_merge($this->options, $options ?? []); try { @@ -148,20 +159,13 @@ public function createDataAttribute(mixed $request, ?array $options = null): Dat $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return DataAttribute::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); } @@ -180,7 +184,19 @@ public function createDataAttribute(mixed $request, ?array $options = null): Dat * > * > It is currently a dangerous action to execute changing a data attribute's type via the API. You will need to update the type via the UI instead. * - * @param UpdateDataAttributeRequest $request + * Example: + * ```php + * $client->unstable->dataAttributes->updateDataAttribute( + * new UpdateDataAttributeBody([ + * 'id' => 1, + * 'body' => [ + * 'key' => "value", + * ], + * ]), + * ); + * ``` + * + * @param UpdateDataAttributeBody $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -189,18 +205,18 @@ public function createDataAttribute(mixed $request, ?array $options = null): Dat * queryParameters?: array, * bodyProperties?: array, * } $options - * @return DataAttribute + * @return ?DataAttribute * @throws IntercomException * @throws IntercomApiException */ - public function updateDataAttribute(UpdateDataAttributeRequest $request, ?array $options = null): DataAttribute + public function updateDataAttribute(UpdateDataAttributeBody $request, ?array $options = null): ?DataAttribute { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "data_attributes/{$request->getId()}", + path: "data_attributes/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::PUT, body: $request->getBody(), ), @@ -209,20 +225,13 @@ public function updateDataAttribute(UpdateDataAttributeRequest $request, ?array $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return DataAttribute::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); } diff --git a/src/Unstable/DataAttributes/Requests/LisDataAttributesRequest.php b/src/Unstable/DataAttributes/Requests/LisDataAttributesRequest.php index 4d41b3e9..ca6c82f7 100644 --- a/src/Unstable/DataAttributes/Requests/LisDataAttributesRequest.php +++ b/src/Unstable/DataAttributes/Requests/LisDataAttributesRequest.php @@ -44,6 +44,7 @@ public function getModel(): ?string public function setModel(?string $value = null): self { $this->model = $value; + $this->_setField('model'); return $this; } @@ -61,6 +62,7 @@ public function getIncludeArchived(): ?bool public function setIncludeArchived(?bool $value = null): self { $this->includeArchived = $value; + $this->_setField('includeArchived'); return $this; } } diff --git a/src/Unstable/DataAttributes/Requests/UpdateDataAttributeRequest.php b/src/Unstable/DataAttributes/Requests/UpdateDataAttributeBody.php similarity index 89% rename from src/Unstable/DataAttributes/Requests/UpdateDataAttributeRequest.php rename to src/Unstable/DataAttributes/Requests/UpdateDataAttributeBody.php index f25e038e..2a444afc 100644 --- a/src/Unstable/DataAttributes/Requests/UpdateDataAttributeRequest.php +++ b/src/Unstable/DataAttributes/Requests/UpdateDataAttributeBody.php @@ -4,7 +4,7 @@ use Intercom\Core\Json\JsonSerializableType; -class UpdateDataAttributeRequest extends JsonSerializableType +class UpdateDataAttributeBody extends JsonSerializableType { /** * @var int $id The data attribute id @@ -43,6 +43,7 @@ public function getId(): int public function setId(int $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -60,6 +61,7 @@ public function getBody(): mixed public function setBody(mixed $value): self { $this->body = $value; + $this->_setField('body'); return $this; } } diff --git a/src/Unstable/DataAttributes/Types/DataAttribute.php b/src/Unstable/DataAttributes/Types/DataAttribute.php index a60bcc15..ebd72380 100644 --- a/src/Unstable/DataAttributes/Types/DataAttribute.php +++ b/src/Unstable/DataAttributes/Types/DataAttribute.php @@ -170,6 +170,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -187,6 +188,7 @@ public function getId(): ?int public function setId(?int $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -204,6 +206,7 @@ public function getModel(): ?string public function setModel(?string $value = null): self { $this->model = $value; + $this->_setField('model'); return $this; } @@ -221,6 +224,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -238,6 +242,7 @@ public function getFullName(): ?string public function setFullName(?string $value = null): self { $this->fullName = $value; + $this->_setField('fullName'); return $this; } @@ -255,6 +260,7 @@ public function getLabel(): ?string public function setLabel(?string $value = null): self { $this->label = $value; + $this->_setField('label'); return $this; } @@ -272,6 +278,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -289,6 +296,7 @@ public function getDataType(): ?string public function setDataType(?string $value = null): self { $this->dataType = $value; + $this->_setField('dataType'); return $this; } @@ -306,6 +314,7 @@ public function getOptions(): ?array public function setOptions(?array $value = null): self { $this->options = $value; + $this->_setField('options'); return $this; } @@ -323,6 +332,7 @@ public function getApiWritable(): ?bool public function setApiWritable(?bool $value = null): self { $this->apiWritable = $value; + $this->_setField('apiWritable'); return $this; } @@ -340,6 +350,7 @@ public function getMessengerWritable(): ?bool public function setMessengerWritable(?bool $value = null): self { $this->messengerWritable = $value; + $this->_setField('messengerWritable'); return $this; } @@ -357,6 +368,7 @@ public function getUiWritable(): ?bool public function setUiWritable(?bool $value = null): self { $this->uiWritable = $value; + $this->_setField('uiWritable'); return $this; } @@ -374,6 +386,7 @@ public function getCustom(): ?bool public function setCustom(?bool $value = null): self { $this->custom = $value; + $this->_setField('custom'); return $this; } @@ -391,6 +404,7 @@ public function getArchived(): ?bool public function setArchived(?bool $value = null): self { $this->archived = $value; + $this->_setField('archived'); return $this; } @@ -408,6 +422,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -425,6 +440,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -442,6 +458,7 @@ public function getAdminId(): ?string public function setAdminId(?string $value = null): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } diff --git a/src/Unstable/DataEvents/DataEventsClient.php b/src/Unstable/DataEvents/DataEventsClient.php index 64ab9e75..f3a13938 100644 --- a/src/Unstable/DataEvents/DataEventsClient.php +++ b/src/Unstable/DataEvents/DataEventsClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\DataEvents; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\DataEvents\Requests\LisDataEventsRequest; use Intercom\Unstable\Types\DataEventSummary; @@ -17,7 +17,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\DataEvents\Requests\CreateDataEventSummariesRequest; @@ -73,6 +72,19 @@ public function __construct( * * You can optionally define the result page size as well with the `per_page` parameter. * + * Example: + * ```php + * $client->events->list( + * new ListEventsRequest([ + * 'filter' => new EventsListRequestFilterUserId([ + * 'userId' => 'user_id', + * ]), + * 'type' => 'type', + * 'summary' => true, + * ]), + * ); + * ``` + * * @param LisDataEventsRequest $request * @param ?array{ * baseUrl?: string, @@ -82,11 +94,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return DataEventSummary + * @return ?DataEventSummary * @throws IntercomException * @throws IntercomApiException */ - public function lisDataEvents(LisDataEventsRequest $request, ?array $options = null): DataEventSummary + public function lisDataEvents(LisDataEventsRequest $request, ?array $options = null): ?DataEventSummary { $options = array_merge($this->options, $options ?? []); $query = []; @@ -108,20 +120,13 @@ public function lisDataEvents(LisDataEventsRequest $request, ?array $options = n $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return DataEventSummary::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); } @@ -176,7 +181,18 @@ public function lisDataEvents(LisDataEventsRequest $request, ?array $options = n * - Server errors will return a `500` response code and may contain an error message in the body. * * - * @param mixed $request + * Example: + * ```php + * $client->unstable->dataEvents->createDataEvent( + * [ + * 'key' => "value", + * ], + * ); + * ``` + * + * @param ( + * mixed + * ) $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -205,16 +221,6 @@ public function createDataEvent(mixed $request, ?array $options = null): void 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); } @@ -229,6 +235,13 @@ public function createDataEvent(mixed $request, ?array $options = null): void * Create event summaries for a user. Event summaries are used to track the number of times an event has occurred, the first time it occurred and the last time it occurred. * * + * Example: + * ```php + * $client->events->summaries( + * new ListEventSummariesRequest([]), + * ); + * ``` + * * @param CreateDataEventSummariesRequest $request * @param ?array{ * baseUrl?: string, @@ -258,16 +271,6 @@ public function dataEventSummaries(CreateDataEventSummariesRequest $request = ne 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); } diff --git a/src/Unstable/DataEvents/Requests/CreateDataEventSummariesRequest.php b/src/Unstable/DataEvents/Requests/CreateDataEventSummariesRequest.php index 847f5c47..aa050e04 100644 --- a/src/Unstable/DataEvents/Requests/CreateDataEventSummariesRequest.php +++ b/src/Unstable/DataEvents/Requests/CreateDataEventSummariesRequest.php @@ -47,6 +47,7 @@ public function getUserId(): ?string public function setUserId(?string $value = null): self { $this->userId = $value; + $this->_setField('userId'); return $this; } @@ -64,6 +65,7 @@ public function getEventSummaries(): ?CreateDataEventSummariesRequestEventSummar public function setEventSummaries(?CreateDataEventSummariesRequestEventSummaries $value = null): self { $this->eventSummaries = $value; + $this->_setField('eventSummaries'); return $this; } } diff --git a/src/Unstable/DataEvents/Requests/LisDataEventsRequest.php b/src/Unstable/DataEvents/Requests/LisDataEventsRequest.php index 24ab1a72..5462f762 100644 --- a/src/Unstable/DataEvents/Requests/LisDataEventsRequest.php +++ b/src/Unstable/DataEvents/Requests/LisDataEventsRequest.php @@ -69,6 +69,7 @@ public function getFilter(): LisDataEventsRequestFilterUserId|LisDataEventsReque public function setFilter(LisDataEventsRequestFilterUserId|LisDataEventsRequestFilterIntercomUserId|LisDataEventsRequestFilterEmail $value): self { $this->filter = $value; + $this->_setField('filter'); return $this; } @@ -86,6 +87,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -103,6 +105,7 @@ public function getSummary(): ?bool public function setSummary(?bool $value = null): self { $this->summary = $value; + $this->_setField('summary'); return $this; } } diff --git a/src/Unstable/DataEvents/Types/CreateDataEventSummariesRequestEventSummaries.php b/src/Unstable/DataEvents/Types/CreateDataEventSummariesRequestEventSummaries.php index 9fb493fc..d8830177 100644 --- a/src/Unstable/DataEvents/Types/CreateDataEventSummariesRequestEventSummaries.php +++ b/src/Unstable/DataEvents/Types/CreateDataEventSummariesRequestEventSummaries.php @@ -65,6 +65,7 @@ public function getEventName(): ?string public function setEventName(?string $value = null): self { $this->eventName = $value; + $this->_setField('eventName'); return $this; } @@ -82,6 +83,7 @@ public function getCount(): ?int public function setCount(?int $value = null): self { $this->count = $value; + $this->_setField('count'); return $this; } @@ -99,6 +101,7 @@ public function getFirst(): ?int public function setFirst(?int $value = null): self { $this->first = $value; + $this->_setField('first'); return $this; } @@ -116,6 +119,7 @@ public function getLast(): ?int public function setLast(?int $value = null): self { $this->last = $value; + $this->_setField('last'); return $this; } diff --git a/src/Unstable/DataEvents/Types/DataEvent.php b/src/Unstable/DataEvents/Types/DataEvent.php index bfbab4fc..83834bf7 100644 --- a/src/Unstable/DataEvents/Types/DataEvent.php +++ b/src/Unstable/DataEvents/Types/DataEvent.php @@ -98,6 +98,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -115,6 +116,7 @@ public function getEventName(): string public function setEventName(string $value): self { $this->eventName = $value; + $this->_setField('eventName'); return $this; } @@ -132,6 +134,7 @@ public function getCreatedAt(): int public function setCreatedAt(int $value): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -149,6 +152,7 @@ public function getUserId(): ?string public function setUserId(?string $value = null): self { $this->userId = $value; + $this->_setField('userId'); return $this; } @@ -166,6 +170,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -183,6 +188,7 @@ public function getIntercomUserId(): ?string public function setIntercomUserId(?string $value = null): self { $this->intercomUserId = $value; + $this->_setField('intercomUserId'); return $this; } @@ -200,6 +206,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -217,6 +224,7 @@ public function getMetadata(): ?array public function setMetadata(?array $value = null): self { $this->metadata = $value; + $this->_setField('metadata'); return $this; } diff --git a/src/Unstable/DataEvents/Types/LisDataEventsRequestFilterEmail.php b/src/Unstable/DataEvents/Types/LisDataEventsRequestFilterEmail.php index b4f44052..27f58cc9 100644 --- a/src/Unstable/DataEvents/Types/LisDataEventsRequestFilterEmail.php +++ b/src/Unstable/DataEvents/Types/LisDataEventsRequestFilterEmail.php @@ -38,6 +38,7 @@ public function getEmail(): string public function setEmail(string $value): self { $this->email = $value; + $this->_setField('email'); return $this; } diff --git a/src/Unstable/DataEvents/Types/LisDataEventsRequestFilterIntercomUserId.php b/src/Unstable/DataEvents/Types/LisDataEventsRequestFilterIntercomUserId.php index 11eb532b..172e6820 100644 --- a/src/Unstable/DataEvents/Types/LisDataEventsRequestFilterIntercomUserId.php +++ b/src/Unstable/DataEvents/Types/LisDataEventsRequestFilterIntercomUserId.php @@ -38,6 +38,7 @@ public function getIntercomUserId(): string public function setIntercomUserId(string $value): self { $this->intercomUserId = $value; + $this->_setField('intercomUserId'); return $this; } diff --git a/src/Unstable/DataEvents/Types/LisDataEventsRequestFilterUserId.php b/src/Unstable/DataEvents/Types/LisDataEventsRequestFilterUserId.php index 61ca526d..e9453505 100644 --- a/src/Unstable/DataEvents/Types/LisDataEventsRequestFilterUserId.php +++ b/src/Unstable/DataEvents/Types/LisDataEventsRequestFilterUserId.php @@ -38,6 +38,7 @@ public function getUserId(): string public function setUserId(string $value): self { $this->userId = $value; + $this->_setField('userId'); return $this; } diff --git a/src/Unstable/DataExport/DataExportClient.php b/src/Unstable/DataExport/DataExportClient.php index 600a5a35..afdd9091 100644 --- a/src/Unstable/DataExport/DataExportClient.php +++ b/src/Unstable/DataExport/DataExportClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\DataExport; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\DataExport\Requests\CreateDataExportsRequest; use Intercom\Unstable\DataExport\Types\DataExport; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\DataExport\Requests\GetDataExportRequest; use Intercom\Unstable\DataExport\Requests\CancelDataExportRequest; @@ -71,6 +70,16 @@ public function __construct( * > * > Requesting data for 2018-06-01 until 2018-06-30 will get all data for those days including those specified - e.g. 2018-06-01 00:00:00 until 2018-06-30 23:59:99. * + * Example: + * ```php + * $client->dataExport->create( + * new CreateDataExportRequest([ + * 'createdAtAfter' => 1734519776, + * 'createdAtBefore' => 1734537776, + * ]), + * ); + * ``` + * * @param CreateDataExportsRequest $request * @param ?array{ * baseUrl?: string, @@ -80,11 +89,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return DataExport + * @return ?DataExport * @throws IntercomException * @throws IntercomApiException */ - public function createDataExport(CreateDataExportsRequest $request, ?array $options = null): DataExport + public function createDataExport(CreateDataExportsRequest $request, ?array $options = null): ?DataExport { $options = array_merge($this->options, $options ?? []); try { @@ -100,20 +109,13 @@ public function createDataExport(CreateDataExportsRequest $request, ?array $opti $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return DataExport::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); } @@ -131,6 +133,15 @@ public function createDataExport(CreateDataExportsRequest $request, ?array $opti * > 🚧 Jobs expire after two days * > All jobs that have completed processing (and are thus available to download from the provided URL) will have an expiry limit of two days from when the export ob completed. After this, the data will no longer be available. * + * Example: + * ```php + * $client->dataExport->find( + * new FindDataExportRequest([ + * 'jobIdentifier' => 'job_identifier', + * ]), + * ); + * ``` + * * @param GetDataExportRequest $request * @param ?array{ * baseUrl?: string, @@ -140,18 +151,18 @@ public function createDataExport(CreateDataExportsRequest $request, ?array $opti * queryParameters?: array, * bodyProperties?: array, * } $options - * @return DataExport + * @return ?DataExport * @throws IntercomException * @throws IntercomApiException */ - public function getDataExport(GetDataExportRequest $request, ?array $options = null): DataExport + public function getDataExport(GetDataExportRequest $request, ?array $options = null): ?DataExport { $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/content/data/{$request->getJobIdentifier()}", + path: "export/content/data/" . RawClient::encodePathParam($request->getJobIdentifier()), method: HttpMethod::GET, ), $options, @@ -159,20 +170,13 @@ public function getDataExport(GetDataExportRequest $request, ?array $options = n $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return DataExport::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); } @@ -186,6 +190,15 @@ public function getDataExport(GetDataExportRequest $request, ?array $options = n /** * You can cancel your job * + * Example: + * ```php + * $client->dataExport->cancel( + * new CancelDataExportRequest([ + * 'jobIdentifier' => 'job_identifier', + * ]), + * ); + * ``` + * * @param CancelDataExportRequest $request * @param ?array{ * baseUrl?: string, @@ -195,18 +208,18 @@ public function getDataExport(GetDataExportRequest $request, ?array $options = n * queryParameters?: array, * bodyProperties?: array, * } $options - * @return DataExport + * @return ?DataExport * @throws IntercomException * @throws IntercomApiException */ - public function cancelDataExport(CancelDataExportRequest $request, ?array $options = null): DataExport + public function cancelDataExport(CancelDataExportRequest $request, ?array $options = null): ?DataExport { $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/cancel/{$request->getJobIdentifier()}", + path: "export/cancel/" . RawClient::encodePathParam($request->getJobIdentifier()), method: HttpMethod::POST, ), $options, @@ -214,20 +227,13 @@ public function cancelDataExport(CancelDataExportRequest $request, ?array $optio $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return DataExport::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); } @@ -247,6 +253,15 @@ public function cancelDataExport(CancelDataExportRequest $request, ?array $optio * > * > You will have to specify the header Accept: `application/octet-stream` when hitting this endpoint. * + * Example: + * ```php + * $client->dataExport->download( + * new DownloadDataExportRequest([ + * 'jobIdentifier' => 'job_identifier', + * ]), + * ); + * ``` + * * @param DownloadDataExportRequest $request * @param ?array{ * baseUrl?: string, @@ -266,7 +281,7 @@ public function downloadDataExport(DownloadDataExportRequest $request, ?array $o $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "download/content/data/{$request->getJobIdentifier()}", + path: "download/content/data/" . RawClient::encodePathParam($request->getJobIdentifier()), method: HttpMethod::GET, ), $options, @@ -275,16 +290,6 @@ public function downloadDataExport(DownloadDataExportRequest $request, ?array $o 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); } diff --git a/src/Unstable/DataExport/Requests/CancelDataExportRequest.php b/src/Unstable/DataExport/Requests/CancelDataExportRequest.php index 18d8b0c8..4350b6fb 100644 --- a/src/Unstable/DataExport/Requests/CancelDataExportRequest.php +++ b/src/Unstable/DataExport/Requests/CancelDataExportRequest.php @@ -36,6 +36,7 @@ public function getJobIdentifier(): string public function setJobIdentifier(string $value): self { $this->jobIdentifier = $value; + $this->_setField('jobIdentifier'); return $this; } } diff --git a/src/Unstable/DataExport/Requests/CreateDataExportsRequest.php b/src/Unstable/DataExport/Requests/CreateDataExportsRequest.php index 51427ef4..8c386aa6 100644 --- a/src/Unstable/DataExport/Requests/CreateDataExportsRequest.php +++ b/src/Unstable/DataExport/Requests/CreateDataExportsRequest.php @@ -46,6 +46,7 @@ public function getCreatedAtAfter(): int public function setCreatedAtAfter(int $value): self { $this->createdAtAfter = $value; + $this->_setField('createdAtAfter'); return $this; } @@ -63,6 +64,7 @@ public function getCreatedAtBefore(): int public function setCreatedAtBefore(int $value): self { $this->createdAtBefore = $value; + $this->_setField('createdAtBefore'); return $this; } } diff --git a/src/Unstable/DataExport/Requests/DownloadDataExportRequest.php b/src/Unstable/DataExport/Requests/DownloadDataExportRequest.php index e5e8f72d..a9916873 100644 --- a/src/Unstable/DataExport/Requests/DownloadDataExportRequest.php +++ b/src/Unstable/DataExport/Requests/DownloadDataExportRequest.php @@ -36,6 +36,7 @@ public function getJobIdentifier(): string public function setJobIdentifier(string $value): self { $this->jobIdentifier = $value; + $this->_setField('jobIdentifier'); return $this; } } diff --git a/src/Unstable/DataExport/Requests/GetDataExportRequest.php b/src/Unstable/DataExport/Requests/GetDataExportRequest.php index 5e8ca277..608ab142 100644 --- a/src/Unstable/DataExport/Requests/GetDataExportRequest.php +++ b/src/Unstable/DataExport/Requests/GetDataExportRequest.php @@ -36,6 +36,7 @@ public function getJobIdentifier(): string public function setJobIdentifier(string $value): self { $this->jobIdentifier = $value; + $this->_setField('jobIdentifier'); return $this; } } diff --git a/src/Unstable/DataExport/Types/DataExport.php b/src/Unstable/DataExport/Types/DataExport.php index faa5bbe7..ce3a7622 100644 --- a/src/Unstable/DataExport/Types/DataExport.php +++ b/src/Unstable/DataExport/Types/DataExport.php @@ -65,6 +65,7 @@ public function getJobIdentfier(): ?string public function setJobIdentfier(?string $value = null): self { $this->jobIdentfier = $value; + $this->_setField('jobIdentfier'); return $this; } @@ -82,6 +83,7 @@ public function getStatus(): ?string public function setStatus(?string $value = null): self { $this->status = $value; + $this->_setField('status'); return $this; } @@ -99,6 +101,7 @@ public function getDownloadExpiresAt(): ?string public function setDownloadExpiresAt(?string $value = null): self { $this->downloadExpiresAt = $value; + $this->_setField('downloadExpiresAt'); return $this; } @@ -116,6 +119,7 @@ public function getDownloadUrl(): ?string public function setDownloadUrl(?string $value = null): self { $this->downloadUrl = $value; + $this->_setField('downloadUrl'); return $this; } diff --git a/src/Unstable/Emails/EmailsClient.php b/src/Unstable/Emails/EmailsClient.php index c4e30954..6ef9e1a8 100644 --- a/src/Unstable/Emails/EmailsClient.php +++ b/src/Unstable/Emails/EmailsClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\Emails; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\Emails\Types\EmailList; use Intercom\Exceptions\IntercomException; @@ -11,7 +11,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\Emails\Requests\RetrieveEmailRequest; use Intercom\Unstable\Emails\Types\EmailSetting; @@ -55,6 +54,11 @@ public function __construct( /** * Lists all sender email address settings for the workspace * + * Example: + * ```php + * $client->unstable->emails->listEmails(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -63,11 +67,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return EmailList + * @return ?EmailList * @throws IntercomException * @throws IntercomApiException */ - public function listEmails(?array $options = null): EmailList + public function listEmails(?array $options = null): ?EmailList { $options = array_merge($this->options, $options ?? []); try { @@ -82,20 +86,13 @@ public function listEmails(?array $options = null): EmailList $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -109,6 +106,15 @@ public function listEmails(?array $options = null): EmailList /** * Fetches a specific email setting by its unique identifier * + * Example: + * ```php + * $client->unstable->emails->retrieveEmail( + * new RetrieveEmailRequest([ + * 'id' => 'id', + * ]), + * ); + * ``` + * * @param RetrieveEmailRequest $request * @param ?array{ * baseUrl?: string, @@ -118,18 +124,18 @@ public function listEmails(?array $options = null): EmailList * queryParameters?: array, * bodyProperties?: array, * } $options - * @return EmailSetting + * @return ?EmailSetting * @throws IntercomException * @throws IntercomApiException */ - public function retrieveEmail(RetrieveEmailRequest $request, ?array $options = null): EmailSetting + 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()}", + path: "emails/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::GET, ), $options, @@ -137,20 +143,13 @@ public function retrieveEmail(RetrieveEmailRequest $request, ?array $options = n $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } diff --git a/src/Unstable/Emails/Requests/RetrieveEmailRequest.php b/src/Unstable/Emails/Requests/RetrieveEmailRequest.php index 467a6773..695233a5 100644 --- a/src/Unstable/Emails/Requests/RetrieveEmailRequest.php +++ b/src/Unstable/Emails/Requests/RetrieveEmailRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Emails/Types/EmailList.php b/src/Unstable/Emails/Types/EmailList.php index a9e40749..74fd3b7f 100644 --- a/src/Unstable/Emails/Types/EmailList.php +++ b/src/Unstable/Emails/Types/EmailList.php @@ -50,6 +50,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -67,6 +68,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Unstable/Emails/Types/EmailSetting.php b/src/Unstable/Emails/Types/EmailSetting.php index d90b86bf..73790da8 100644 --- a/src/Unstable/Emails/Types/EmailSetting.php +++ b/src/Unstable/Emails/Types/EmailSetting.php @@ -113,6 +113,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -130,6 +131,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -147,6 +149,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -164,6 +167,7 @@ public function getVerified(): ?bool public function setVerified(?bool $value = null): self { $this->verified = $value; + $this->_setField('verified'); return $this; } @@ -181,6 +185,7 @@ public function getDomain(): ?string public function setDomain(?string $value = null): self { $this->domain = $value; + $this->_setField('domain'); return $this; } @@ -198,6 +203,7 @@ public function getBrandId(): ?string public function setBrandId(?string $value = null): self { $this->brandId = $value; + $this->_setField('brandId'); return $this; } @@ -215,6 +221,7 @@ public function getForwardingEnabled(): ?bool public function setForwardingEnabled(?bool $value = null): self { $this->forwardingEnabled = $value; + $this->_setField('forwardingEnabled'); return $this; } @@ -232,6 +239,7 @@ public function getForwardedEmailLastReceivedAt(): ?int public function setForwardedEmailLastReceivedAt(?int $value = null): self { $this->forwardedEmailLastReceivedAt = $value; + $this->_setField('forwardedEmailLastReceivedAt'); return $this; } @@ -249,6 +257,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -266,6 +275,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } diff --git a/src/Unstable/Export/ExportClient.php b/src/Unstable/Export/ExportClient.php index f3335efc..ddf89dbe 100644 --- a/src/Unstable/Export/ExportClient.php +++ b/src/Unstable/Export/ExportClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\Export; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\Export\Requests\PostExportReportingDataEnqueueRequest; use Intercom\Unstable\Export\Types\PostExportReportingDataEnqueueResponse; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\Export\Types\GetExportReportingDataGetDatasetsResponse; @@ -53,6 +52,21 @@ public function __construct( } /** + * Example: + * ```php + * $client->export->enqueueANewReportingDataExportJob( + * new PostExportReportingDataEnqueueRequest([ + * 'datasetId' => 'conversation', + * 'attributeIds' => [ + * 'conversation_id', + * 'conversation_started_at', + * ], + * 'startTime' => 1717490000, + * 'endTime' => 1717510000, + * ]), + * ); + * ``` + * * @param PostExportReportingDataEnqueueRequest $request * @param ?array{ * baseUrl?: string, @@ -62,11 +76,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return PostExportReportingDataEnqueueResponse + * @return ?PostExportReportingDataEnqueueResponse * @throws IntercomException * @throws IntercomApiException */ - public function enqueueANewReportingDataExportJob(PostExportReportingDataEnqueueRequest $request, ?array $options = null): PostExportReportingDataEnqueueResponse + public function enqueueANewReportingDataExportJob(PostExportReportingDataEnqueueRequest $request, ?array $options = null): ?PostExportReportingDataEnqueueResponse { $options = array_merge($this->options, $options ?? []); try { @@ -82,20 +96,13 @@ public function enqueueANewReportingDataExportJob(PostExportReportingDataEnqueue $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -107,6 +114,11 @@ public function enqueueANewReportingDataExportJob(PostExportReportingDataEnqueue } /** + * Example: + * ```php + * $client->export->listAvailableDatasetsAndAttributes(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -115,11 +127,11 @@ public function enqueueANewReportingDataExportJob(PostExportReportingDataEnqueue * queryParameters?: array, * bodyProperties?: array, * } $options - * @return GetExportReportingDataGetDatasetsResponse + * @return ?GetExportReportingDataGetDatasetsResponse * @throws IntercomException * @throws IntercomApiException */ - public function listAvailableDatasetsAndAttributes(?array $options = null): GetExportReportingDataGetDatasetsResponse + public function listAvailableDatasetsAndAttributes(?array $options = null): ?GetExportReportingDataGetDatasetsResponse { $options = array_merge($this->options, $options ?? []); try { @@ -134,20 +146,13 @@ public function listAvailableDatasetsAndAttributes(?array $options = null): GetE $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } diff --git a/src/Unstable/Export/Requests/PostExportReportingDataEnqueueRequest.php b/src/Unstable/Export/Requests/PostExportReportingDataEnqueueRequest.php index 7c397d22..5ef1b402 100644 --- a/src/Unstable/Export/Requests/PostExportReportingDataEnqueueRequest.php +++ b/src/Unstable/Export/Requests/PostExportReportingDataEnqueueRequest.php @@ -63,6 +63,7 @@ public function getDatasetId(): string public function setDatasetId(string $value): self { $this->datasetId = $value; + $this->_setField('datasetId'); return $this; } @@ -80,6 +81,7 @@ public function getAttributeIds(): array public function setAttributeIds(array $value): self { $this->attributeIds = $value; + $this->_setField('attributeIds'); return $this; } @@ -97,6 +99,7 @@ public function getStartTime(): int public function setStartTime(int $value): self { $this->startTime = $value; + $this->_setField('startTime'); return $this; } @@ -114,6 +117,7 @@ public function getEndTime(): int public function setEndTime(int $value): self { $this->endTime = $value; + $this->_setField('endTime'); return $this; } } diff --git a/src/Unstable/Export/Types/GetExportReportingDataGetDatasetsResponse.php b/src/Unstable/Export/Types/GetExportReportingDataGetDatasetsResponse.php index 78852f3e..aef2d5fc 100644 --- a/src/Unstable/Export/Types/GetExportReportingDataGetDatasetsResponse.php +++ b/src/Unstable/Export/Types/GetExportReportingDataGetDatasetsResponse.php @@ -47,6 +47,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -64,6 +65,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Unstable/Export/Types/GetExportReportingDataGetDatasetsResponseDataItem.php b/src/Unstable/Export/Types/GetExportReportingDataGetDatasetsResponseDataItem.php index 13e00325..7afccb78 100644 --- a/src/Unstable/Export/Types/GetExportReportingDataGetDatasetsResponseDataItem.php +++ b/src/Unstable/Export/Types/GetExportReportingDataGetDatasetsResponseDataItem.php @@ -71,6 +71,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -88,6 +89,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -105,6 +107,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -122,6 +125,7 @@ public function getDefaultTimeAttributeId(): ?string public function setDefaultTimeAttributeId(?string $value = null): self { $this->defaultTimeAttributeId = $value; + $this->_setField('defaultTimeAttributeId'); return $this; } @@ -139,6 +143,7 @@ public function getAttributes(): ?array public function setAttributes(?array $value = null): self { $this->attributes = $value; + $this->_setField('attributes'); return $this; } diff --git a/src/Unstable/Export/Types/GetExportReportingDataGetDatasetsResponseDataItemAttributesItem.php b/src/Unstable/Export/Types/GetExportReportingDataGetDatasetsResponseDataItemAttributesItem.php index e66fe571..eac584fd 100644 --- a/src/Unstable/Export/Types/GetExportReportingDataGetDatasetsResponseDataItemAttributesItem.php +++ b/src/Unstable/Export/Types/GetExportReportingDataGetDatasetsResponseDataItemAttributesItem.php @@ -46,6 +46,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -63,6 +64,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } diff --git a/src/Unstable/Export/Types/PostExportReportingDataEnqueueResponse.php b/src/Unstable/Export/Types/PostExportReportingDataEnqueueResponse.php index 0fa4e999..981afdf2 100644 --- a/src/Unstable/Export/Types/PostExportReportingDataEnqueueResponse.php +++ b/src/Unstable/Export/Types/PostExportReportingDataEnqueueResponse.php @@ -62,6 +62,7 @@ public function getJobIdentifier(): ?string public function setJobIdentifier(?string $value = null): self { $this->jobIdentifier = $value; + $this->_setField('jobIdentifier'); return $this; } @@ -79,6 +80,7 @@ public function getStatus(): ?string public function setStatus(?string $value = null): self { $this->status = $value; + $this->_setField('status'); return $this; } @@ -96,6 +98,7 @@ public function getDownloadUrl(): ?string public function setDownloadUrl(?string $value = null): self { $this->downloadUrl = $value; + $this->_setField('downloadUrl'); return $this; } @@ -113,6 +116,7 @@ public function getDownloadExpiresAt(): ?string public function setDownloadExpiresAt(?string $value = null): self { $this->downloadExpiresAt = $value; + $this->_setField('downloadExpiresAt'); return $this; } diff --git a/src/Unstable/HelpCenter/HelpCenterClient.php b/src/Unstable/HelpCenter/HelpCenterClient.php index 52b8b482..f3366fbf 100644 --- a/src/Unstable/HelpCenter/HelpCenterClient.php +++ b/src/Unstable/HelpCenter/HelpCenterClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\HelpCenter; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\Types\CollectionList; use Intercom\Exceptions\IntercomException; @@ -11,7 +11,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\HelpCenter\Requests\CreateCollectionRequest; use Intercom\Unstable\HelpCenter\Types\Collection; @@ -64,6 +63,13 @@ public function __construct( * * Collections will be returned in descending order on the `updated_at` attribute. This means if you need to iterate through results then we'll show the most recently updated collections first. * + * Example: + * ```php + * $client->helpCenters->collections->list( + * new ListCollectionsRequest([]), + * ); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -72,11 +78,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return CollectionList + * @return ?CollectionList * @throws IntercomException * @throws IntercomApiException */ - public function listAllCollections(?array $options = null): CollectionList + public function listAllCollections(?array $options = null): ?CollectionList { $options = array_merge($this->options, $options ?? []); try { @@ -91,20 +97,13 @@ public function listAllCollections(?array $options = null): CollectionList $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return CollectionList::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); } @@ -118,6 +117,15 @@ public function listAllCollections(?array $options = null): CollectionList /** * You can create a new collection by making a POST request to `https://api.intercom.io/help_center/collections.` * + * Example: + * ```php + * $client->helpCenters->collections->create( + * new CreateCollectionRequest([ + * 'name' => 'Thanks for everything', + * ]), + * ); + * ``` + * * @param CreateCollectionRequest $request * @param ?array{ * baseUrl?: string, @@ -127,11 +135,11 @@ public function listAllCollections(?array $options = null): CollectionList * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Collection + * @return ?Collection * @throws IntercomException * @throws IntercomApiException */ - public function createCollection(CreateCollectionRequest $request, ?array $options = null): Collection + public function createCollection(CreateCollectionRequest $request, ?array $options = null): ?Collection { $options = array_merge($this->options, $options ?? []); try { @@ -147,20 +155,13 @@ public function createCollection(CreateCollectionRequest $request, ?array $optio $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Collection::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); } @@ -174,6 +175,15 @@ public function createCollection(CreateCollectionRequest $request, ?array $optio /** * You can fetch the details of a single collection by making a GET request to `https://api.intercom.io/help_center/collections/`. * + * Example: + * ```php + * $client->unstable->helpCenter->retrieveCollection( + * new RetrieveCollectionRequest([ + * 'id' => 1, + * ]), + * ); + * ``` + * * @param RetrieveCollectionRequest $request * @param ?array{ * baseUrl?: string, @@ -183,18 +193,18 @@ public function createCollection(CreateCollectionRequest $request, ?array $optio * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Collection + * @return ?Collection * @throws IntercomException * @throws IntercomApiException */ - public function retrieveCollection(RetrieveCollectionRequest $request, ?array $options = null): Collection + public function retrieveCollection(RetrieveCollectionRequest $request, ?array $options = null): ?Collection { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "help_center/collections/{$request->getId()}", + path: "help_center/collections/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::GET, ), $options, @@ -202,20 +212,13 @@ public function retrieveCollection(RetrieveCollectionRequest $request, ?array $o $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Collection::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); } @@ -229,6 +232,16 @@ public function retrieveCollection(RetrieveCollectionRequest $request, ?array $o /** * You can update the details of a single collection by making a PUT request to `https://api.intercom.io/collections/`. * + * Example: + * ```php + * $client->unstable->helpCenter->updateCollection( + * new UpdateCollectionRequest([ + * 'id' => 1, + * 'name' => 'Update collection name', + * ]), + * ); + * ``` + * * @param UpdateCollectionRequest $request * @param ?array{ * baseUrl?: string, @@ -238,18 +251,18 @@ public function retrieveCollection(RetrieveCollectionRequest $request, ?array $o * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Collection + * @return ?Collection * @throws IntercomException * @throws IntercomApiException */ - public function updateCollection(UpdateCollectionRequest $request, ?array $options = null): Collection + public function updateCollection(UpdateCollectionRequest $request, ?array $options = null): ?Collection { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "help_center/collections/{$request->getId()}", + path: "help_center/collections/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::PUT, body: $request, ), @@ -258,20 +271,13 @@ public function updateCollection(UpdateCollectionRequest $request, ?array $optio $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Collection::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); } @@ -285,6 +291,15 @@ public function updateCollection(UpdateCollectionRequest $request, ?array $optio /** * You can delete a single collection by making a DELETE request to `https://api.intercom.io/collections/`. * + * Example: + * ```php + * $client->unstable->helpCenter->deleteCollection( + * new DeleteCollectionRequest([ + * 'id' => 1, + * ]), + * ); + * ``` + * * @param DeleteCollectionRequest $request * @param ?array{ * baseUrl?: string, @@ -294,18 +309,18 @@ public function updateCollection(UpdateCollectionRequest $request, ?array $optio * queryParameters?: array, * bodyProperties?: array, * } $options - * @return DeletedCollectionObject + * @return ?DeletedCollectionObject * @throws IntercomException * @throws IntercomApiException */ - public function deleteCollection(DeleteCollectionRequest $request, ?array $options = null): DeletedCollectionObject + public function deleteCollection(DeleteCollectionRequest $request, ?array $options = null): ?DeletedCollectionObject { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "help_center/collections/{$request->getId()}", + path: "help_center/collections/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::DELETE, ), $options, @@ -313,20 +328,13 @@ public function deleteCollection(DeleteCollectionRequest $request, ?array $optio $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return DeletedCollectionObject::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); } @@ -340,6 +348,15 @@ public function deleteCollection(DeleteCollectionRequest $request, ?array $optio /** * You can fetch the details of a single Help Center by making a GET request to `https://api.intercom.io/help_center/help_center/`. * + * Example: + * ```php + * $client->unstable->helpCenter->retrieveHelpCenter( + * new RetrieveHelpCenterRequest([ + * 'id' => 1, + * ]), + * ); + * ``` + * * @param RetrieveHelpCenterRequest $request * @param ?array{ * baseUrl?: string, @@ -349,18 +366,18 @@ public function deleteCollection(DeleteCollectionRequest $request, ?array $optio * queryParameters?: array, * bodyProperties?: array, * } $options - * @return HelpCenter + * @return ?HelpCenter * @throws IntercomException * @throws IntercomApiException */ - public function retrieveHelpCenter(RetrieveHelpCenterRequest $request, ?array $options = null): HelpCenter + public function retrieveHelpCenter(RetrieveHelpCenterRequest $request, ?array $options = null): ?HelpCenter { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "help_center/help_centers/{$request->getId()}", + path: "help_center/help_centers/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::GET, ), $options, @@ -368,20 +385,13 @@ public function retrieveHelpCenter(RetrieveHelpCenterRequest $request, ?array $o $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return HelpCenter::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); } @@ -395,6 +405,13 @@ public function retrieveHelpCenter(RetrieveHelpCenterRequest $request, ?array $o /** * You can list all Help Centers by making a GET request to `https://api.intercom.io/help_center/help_centers`. * + * Example: + * ```php + * $client->helpCenters->list( + * new ListHelpCentersRequest([]), + * ); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -403,11 +420,11 @@ public function retrieveHelpCenter(RetrieveHelpCenterRequest $request, ?array $o * queryParameters?: array, * bodyProperties?: array, * } $options - * @return HelpCenterList + * @return ?HelpCenterList * @throws IntercomException * @throws IntercomApiException */ - public function listHelpCenters(?array $options = null): HelpCenterList + public function listHelpCenters(?array $options = null): ?HelpCenterList { $options = array_merge($this->options, $options ?? []); try { @@ -422,20 +439,13 @@ public function listHelpCenters(?array $options = null): HelpCenterList $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return HelpCenterList::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); } diff --git a/src/Unstable/HelpCenter/Requests/CreateCollectionRequest.php b/src/Unstable/HelpCenter/Requests/CreateCollectionRequest.php index e68aa027..0630ddbf 100644 --- a/src/Unstable/HelpCenter/Requests/CreateCollectionRequest.php +++ b/src/Unstable/HelpCenter/Requests/CreateCollectionRequest.php @@ -71,6 +71,7 @@ public function getName(): string public function setName(string $value): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -88,6 +89,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -105,6 +107,7 @@ public function getTranslatedContent(): ?GroupTranslatedContent public function setTranslatedContent(?GroupTranslatedContent $value = null): self { $this->translatedContent = $value; + $this->_setField('translatedContent'); return $this; } @@ -122,6 +125,7 @@ public function getParentId(): ?string public function setParentId(?string $value = null): self { $this->parentId = $value; + $this->_setField('parentId'); return $this; } @@ -139,6 +143,7 @@ public function getHelpCenterId(): ?int public function setHelpCenterId(?int $value = null): self { $this->helpCenterId = $value; + $this->_setField('helpCenterId'); return $this; } } diff --git a/src/Unstable/HelpCenter/Requests/DeleteCollectionRequest.php b/src/Unstable/HelpCenter/Requests/DeleteCollectionRequest.php index 3e815ab9..df9a8210 100644 --- a/src/Unstable/HelpCenter/Requests/DeleteCollectionRequest.php +++ b/src/Unstable/HelpCenter/Requests/DeleteCollectionRequest.php @@ -36,6 +36,7 @@ public function getId(): int public function setId(int $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/HelpCenter/Requests/RetrieveCollectionRequest.php b/src/Unstable/HelpCenter/Requests/RetrieveCollectionRequest.php index e866c1f2..ac8e3077 100644 --- a/src/Unstable/HelpCenter/Requests/RetrieveCollectionRequest.php +++ b/src/Unstable/HelpCenter/Requests/RetrieveCollectionRequest.php @@ -36,6 +36,7 @@ public function getId(): int public function setId(int $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/HelpCenter/Requests/RetrieveHelpCenterRequest.php b/src/Unstable/HelpCenter/Requests/RetrieveHelpCenterRequest.php index 85b52159..e0a9849c 100644 --- a/src/Unstable/HelpCenter/Requests/RetrieveHelpCenterRequest.php +++ b/src/Unstable/HelpCenter/Requests/RetrieveHelpCenterRequest.php @@ -36,6 +36,7 @@ public function getId(): int public function setId(int $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/HelpCenter/Requests/UpdateCollectionRequest.php b/src/Unstable/HelpCenter/Requests/UpdateCollectionRequest.php index d180e0fc..a34f8638 100644 --- a/src/Unstable/HelpCenter/Requests/UpdateCollectionRequest.php +++ b/src/Unstable/HelpCenter/Requests/UpdateCollectionRequest.php @@ -70,6 +70,7 @@ public function getId(): int public function setId(int $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -87,6 +88,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -104,6 +106,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -121,6 +124,7 @@ public function getTranslatedContent(): ?GroupTranslatedContent public function setTranslatedContent(?GroupTranslatedContent $value = null): self { $this->translatedContent = $value; + $this->_setField('translatedContent'); return $this; } @@ -138,6 +142,7 @@ public function getParentId(): ?string public function setParentId(?string $value = null): self { $this->parentId = $value; + $this->_setField('parentId'); return $this; } } diff --git a/src/Unstable/HelpCenter/Types/Collection.php b/src/Unstable/HelpCenter/Types/Collection.php index e531d38b..ed6fde81 100644 --- a/src/Unstable/HelpCenter/Types/Collection.php +++ b/src/Unstable/HelpCenter/Types/Collection.php @@ -138,6 +138,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -155,6 +156,7 @@ public function getWorkspaceId(): ?string public function setWorkspaceId(?string $value = null): self { $this->workspaceId = $value; + $this->_setField('workspaceId'); return $this; } @@ -172,6 +174,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -189,6 +192,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -206,6 +210,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -223,6 +228,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -240,6 +246,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -257,6 +264,7 @@ public function getIcon(): ?string public function setIcon(?string $value = null): self { $this->icon = $value; + $this->_setField('icon'); return $this; } @@ -274,6 +282,7 @@ public function getOrder(): ?int public function setOrder(?int $value = null): self { $this->order = $value; + $this->_setField('order'); return $this; } @@ -291,6 +300,7 @@ public function getDefaultLocale(): ?string public function setDefaultLocale(?string $value = null): self { $this->defaultLocale = $value; + $this->_setField('defaultLocale'); return $this; } @@ -308,6 +318,7 @@ public function getTranslatedContent(): ?GroupTranslatedContent public function setTranslatedContent(?GroupTranslatedContent $value = null): self { $this->translatedContent = $value; + $this->_setField('translatedContent'); return $this; } @@ -325,6 +336,7 @@ public function getParentId(): ?string public function setParentId(?string $value = null): self { $this->parentId = $value; + $this->_setField('parentId'); return $this; } @@ -342,6 +354,7 @@ public function getHelpCenterId(): ?int public function setHelpCenterId(?int $value = null): self { $this->helpCenterId = $value; + $this->_setField('helpCenterId'); return $this; } diff --git a/src/Unstable/HelpCenter/Types/HelpCenter.php b/src/Unstable/HelpCenter/Types/HelpCenter.php index 2d330028..1fc6d56c 100644 --- a/src/Unstable/HelpCenter/Types/HelpCenter.php +++ b/src/Unstable/HelpCenter/Types/HelpCenter.php @@ -105,6 +105,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -122,6 +123,7 @@ public function getWorkspaceId(): ?string public function setWorkspaceId(?string $value = null): self { $this->workspaceId = $value; + $this->_setField('workspaceId'); return $this; } @@ -139,6 +141,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -156,6 +159,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -173,6 +177,7 @@ public function getIdentifier(): ?string public function setIdentifier(?string $value = null): self { $this->identifier = $value; + $this->_setField('identifier'); return $this; } @@ -190,6 +195,7 @@ public function getWebsiteTurnedOn(): ?bool public function setWebsiteTurnedOn(?bool $value = null): self { $this->websiteTurnedOn = $value; + $this->_setField('websiteTurnedOn'); return $this; } @@ -207,6 +213,7 @@ public function getDisplayName(): ?string public function setDisplayName(?string $value = null): self { $this->displayName = $value; + $this->_setField('displayName'); return $this; } @@ -224,6 +231,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -241,6 +249,7 @@ public function getCustomDomain(): ?string public function setCustomDomain(?string $value = null): self { $this->customDomain = $value; + $this->_setField('customDomain'); return $this; } diff --git a/src/Unstable/HelpCenter/Types/HelpCenterList.php b/src/Unstable/HelpCenter/Types/HelpCenterList.php index 41e436be..ad65df22 100644 --- a/src/Unstable/HelpCenter/Types/HelpCenterList.php +++ b/src/Unstable/HelpCenter/Types/HelpCenterList.php @@ -50,6 +50,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -67,6 +68,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Unstable/InternalArticles/InternalArticlesClient.php b/src/Unstable/InternalArticles/InternalArticlesClient.php index 41bc9438..fa4a5f10 100644 --- a/src/Unstable/InternalArticles/InternalArticlesClient.php +++ b/src/Unstable/InternalArticles/InternalArticlesClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\InternalArticles; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\Types\InternalArticleList; use Intercom\Exceptions\IntercomException; @@ -11,7 +11,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\Types\CreateInternalArticleRequest; use Intercom\Unstable\InternalArticles\Types\InternalArticleListItem; @@ -61,6 +60,11 @@ public function __construct( /** * You can fetch a list of all internal articles by making a GET request to `https://api.intercom.io/internal_articles`. * + * Example: + * ```php + * $client->internalArticles->listInternalArticles(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -69,11 +73,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return InternalArticleList + * @return ?InternalArticleList * @throws IntercomException * @throws IntercomApiException */ - public function listInternalArticles(?array $options = null): InternalArticleList + public function listInternalArticles(?array $options = null): ?InternalArticleList { $options = array_merge($this->options, $options ?? []); try { @@ -88,20 +92,13 @@ public function listInternalArticles(?array $options = null): InternalArticleLis $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -115,6 +112,18 @@ public function listInternalArticles(?array $options = null): InternalArticleLis /** * You can create a new internal article by making a POST request to `https://api.intercom.io/internal_articles`. * + * Example: + * ```php + * $client->internalArticles->createInternalArticle( + * new CreateInternalArticleRequest([ + * 'title' => 'Thanks for everything', + * 'body' => 'Body of the Article', + * 'authorId' => 991266252, + * 'ownerId' => 991266252, + * ]), + * ); + * ``` + * * @param ?CreateInternalArticleRequest $request * @param ?array{ * baseUrl?: string, @@ -124,11 +133,11 @@ public function listInternalArticles(?array $options = null): InternalArticleLis * queryParameters?: array, * bodyProperties?: array, * } $options - * @return InternalArticleListItem + * @return ?InternalArticleListItem * @throws IntercomException * @throws IntercomApiException */ - public function createInternalArticle(?CreateInternalArticleRequest $request = null, ?array $options = null): InternalArticleListItem + public function createInternalArticle(?CreateInternalArticleRequest $request = null, ?array $options = null): ?InternalArticleListItem { $options = array_merge($this->options, $options ?? []); try { @@ -144,20 +153,13 @@ public function createInternalArticle(?CreateInternalArticleRequest $request = n $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -171,6 +173,15 @@ public function createInternalArticle(?CreateInternalArticleRequest $request = n /** * You can fetch the details of a single internal article by making a GET request to `https://api.intercom.io/internal_articles/`. * + * Example: + * ```php + * $client->unstable->internalArticles->retrieveInternalArticle( + * new RetrieveInternalArticleRequest([ + * 'id' => 1, + * ]), + * ); + * ``` + * * @param RetrieveInternalArticleRequest $request * @param ?array{ * baseUrl?: string, @@ -180,18 +191,18 @@ public function createInternalArticle(?CreateInternalArticleRequest $request = n * queryParameters?: array, * bodyProperties?: array, * } $options - * @return InternalArticleListItem + * @return ?InternalArticleListItem * @throws IntercomException * @throws IntercomApiException */ - public function retrieveInternalArticle(RetrieveInternalArticleRequest $request, ?array $options = null): InternalArticleListItem + 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()}", + path: "internal_articles/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::GET, ), $options, @@ -199,20 +210,13 @@ public function retrieveInternalArticle(RetrieveInternalArticleRequest $request, $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -226,6 +230,17 @@ public function retrieveInternalArticle(RetrieveInternalArticleRequest $request, /** * You can update the details of a single internal article by making a PUT request to `https://api.intercom.io/internal_articles/`. * + * Example: + * ```php + * $client->unstable->internalArticles->updateInternalArticle( + * new UpdateInternalArticleRequestBody([ + * 'id' => 1, + * 'title' => 'Christmas is here!', + * 'body' => '

New gifts in store for the jolly season

', + * ]), + * ); + * ``` + * * @param UpdateInternalArticleRequestBody $request * @param ?array{ * baseUrl?: string, @@ -235,18 +250,18 @@ public function retrieveInternalArticle(RetrieveInternalArticleRequest $request, * queryParameters?: array, * bodyProperties?: array, * } $options - * @return InternalArticleListItem + * @return ?InternalArticleListItem * @throws IntercomException * @throws IntercomApiException */ - public function updateInternalArticle(UpdateInternalArticleRequestBody $request, ?array $options = null): InternalArticleListItem + 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()}", + path: "internal_articles/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::PUT, body: $request, ), @@ -255,20 +270,13 @@ public function updateInternalArticle(UpdateInternalArticleRequestBody $request, $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -282,6 +290,15 @@ public function updateInternalArticle(UpdateInternalArticleRequestBody $request, /** * You can delete a single internal article by making a DELETE request to `https://api.intercom.io/internal_articles/`. * + * Example: + * ```php + * $client->unstable->internalArticles->deleteInternalArticle( + * new DeleteInternalArticleRequest([ + * 'id' => 1, + * ]), + * ); + * ``` + * * @param DeleteInternalArticleRequest $request * @param ?array{ * baseUrl?: string, @@ -291,18 +308,18 @@ public function updateInternalArticle(UpdateInternalArticleRequestBody $request, * queryParameters?: array, * bodyProperties?: array, * } $options - * @return DeletedInternalArticleObject + * @return ?DeletedInternalArticleObject * @throws IntercomException * @throws IntercomApiException */ - public function deleteInternalArticle(DeleteInternalArticleRequest $request, ?array $options = null): DeletedInternalArticleObject + 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()}", + path: "internal_articles/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::DELETE, ), $options, @@ -310,20 +327,13 @@ public function deleteInternalArticle(DeleteInternalArticleRequest $request, ?ar $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -337,6 +347,15 @@ public function deleteInternalArticle(DeleteInternalArticleRequest $request, ?ar /** * You can search for internal articles by making a GET request to `https://api.intercom.io/internal_articles/search`. * + * Example: + * ```php + * $client->internalArticles->searchInternalArticles( + * new SearchInternalArticlesRequest([ + * 'folderId' => 'folder_id', + * ]), + * ); + * ``` + * * @param SearchInternalArticlesRequest $request * @param ?array{ * baseUrl?: string, @@ -346,11 +365,11 @@ public function deleteInternalArticle(DeleteInternalArticleRequest $request, ?ar * queryParameters?: array, * bodyProperties?: array, * } $options - * @return InternalArticleSearchResponse + * @return ?InternalArticleSearchResponse * @throws IntercomException * @throws IntercomApiException */ - public function searchInternalArticles(SearchInternalArticlesRequest $request = new SearchInternalArticlesRequest(), ?array $options = null): InternalArticleSearchResponse + public function searchInternalArticles(SearchInternalArticlesRequest $request = new SearchInternalArticlesRequest(), ?array $options = null): ?InternalArticleSearchResponse { $options = array_merge($this->options, $options ?? []); $query = []; @@ -370,20 +389,13 @@ public function searchInternalArticles(SearchInternalArticlesRequest $request = $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } diff --git a/src/Unstable/InternalArticles/Requests/DeleteInternalArticleRequest.php b/src/Unstable/InternalArticles/Requests/DeleteInternalArticleRequest.php index 50e7744a..2031eb69 100644 --- a/src/Unstable/InternalArticles/Requests/DeleteInternalArticleRequest.php +++ b/src/Unstable/InternalArticles/Requests/DeleteInternalArticleRequest.php @@ -36,6 +36,7 @@ public function getId(): int public function setId(int $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/InternalArticles/Requests/RetrieveInternalArticleRequest.php b/src/Unstable/InternalArticles/Requests/RetrieveInternalArticleRequest.php index e7159638..4f3af0a7 100644 --- a/src/Unstable/InternalArticles/Requests/RetrieveInternalArticleRequest.php +++ b/src/Unstable/InternalArticles/Requests/RetrieveInternalArticleRequest.php @@ -36,6 +36,7 @@ public function getId(): int public function setId(int $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/InternalArticles/Requests/SearchInternalArticlesRequest.php b/src/Unstable/InternalArticles/Requests/SearchInternalArticlesRequest.php index 4c5ce06c..07a6bf74 100644 --- a/src/Unstable/InternalArticles/Requests/SearchInternalArticlesRequest.php +++ b/src/Unstable/InternalArticles/Requests/SearchInternalArticlesRequest.php @@ -36,6 +36,7 @@ public function getFolderId(): ?string public function setFolderId(?string $value = null): self { $this->folderId = $value; + $this->_setField('folderId'); return $this; } } diff --git a/src/Unstable/InternalArticles/Requests/UpdateInternalArticleRequestBody.php b/src/Unstable/InternalArticles/Requests/UpdateInternalArticleRequestBody.php index 76ce544c..6749e6c6 100644 --- a/src/Unstable/InternalArticles/Requests/UpdateInternalArticleRequestBody.php +++ b/src/Unstable/InternalArticles/Requests/UpdateInternalArticleRequestBody.php @@ -69,6 +69,7 @@ public function getId(): int public function setId(int $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -86,6 +87,7 @@ public function getTitle(): ?string public function setTitle(?string $value = null): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -103,6 +105,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -120,6 +123,7 @@ public function getAuthorId(): ?int public function setAuthorId(?int $value = null): self { $this->authorId = $value; + $this->_setField('authorId'); return $this; } @@ -137,6 +141,7 @@ public function getOwnerId(): ?int public function setOwnerId(?int $value = null): self { $this->ownerId = $value; + $this->_setField('ownerId'); return $this; } } diff --git a/src/Unstable/InternalArticles/Types/InternalArticleListItem.php b/src/Unstable/InternalArticles/Types/InternalArticleListItem.php index 4dff4e39..5b8016d7 100644 --- a/src/Unstable/InternalArticles/Types/InternalArticleListItem.php +++ b/src/Unstable/InternalArticles/Types/InternalArticleListItem.php @@ -105,6 +105,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -122,6 +123,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -139,6 +141,7 @@ public function getTitle(): ?string public function setTitle(?string $value = null): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -156,6 +159,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -173,6 +177,7 @@ public function getOwnerId(): ?int public function setOwnerId(?int $value = null): self { $this->ownerId = $value; + $this->_setField('ownerId'); return $this; } @@ -190,6 +195,7 @@ public function getAuthorId(): ?int public function setAuthorId(?int $value = null): self { $this->authorId = $value; + $this->_setField('authorId'); return $this; } @@ -207,6 +213,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -224,6 +231,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -241,6 +249,7 @@ public function getLocale(): ?string public function setLocale(?string $value = null): self { $this->locale = $value; + $this->_setField('locale'); return $this; } diff --git a/src/Unstable/InternalArticles/Types/InternalArticleSearchResponse.php b/src/Unstable/InternalArticles/Types/InternalArticleSearchResponse.php index 2c614965..33a484b2 100644 --- a/src/Unstable/InternalArticles/Types/InternalArticleSearchResponse.php +++ b/src/Unstable/InternalArticles/Types/InternalArticleSearchResponse.php @@ -66,6 +66,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -83,6 +84,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -100,6 +102,7 @@ public function getData(): ?InternalArticleSearchResponseData public function setData(?InternalArticleSearchResponseData $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } @@ -117,6 +120,7 @@ public function getPages(): ?CursorPages public function setPages(?CursorPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } diff --git a/src/Unstable/InternalArticles/Types/InternalArticleSearchResponseData.php b/src/Unstable/InternalArticles/Types/InternalArticleSearchResponseData.php index f4dd5d29..e2aefa97 100644 --- a/src/Unstable/InternalArticles/Types/InternalArticleSearchResponseData.php +++ b/src/Unstable/InternalArticles/Types/InternalArticleSearchResponseData.php @@ -42,6 +42,7 @@ public function getInternalArticles(): ?array public function setInternalArticles(?array $value = null): self { $this->internalArticles = $value; + $this->_setField('internalArticles'); return $this; } diff --git a/src/Unstable/Jobs/JobsClient.php b/src/Unstable/Jobs/JobsClient.php index 805c0458..b6ac4b50 100644 --- a/src/Unstable/Jobs/JobsClient.php +++ b/src/Unstable/Jobs/JobsClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\Jobs; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\Jobs\Requests\JobsStatusRequest; use Intercom\Unstable\Jobs\Types\Jobs; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class JobsClient @@ -54,6 +53,15 @@ public function __construct( /** * Retrieve the status of job execution. * + * Example: + * ```php + * $client->unstable->jobs->status( + * new JobsStatusRequest([ + * 'id' => 'id', + * ]), + * ); + * ``` + * * @param JobsStatusRequest $request * @param ?array{ * baseUrl?: string, @@ -63,18 +71,18 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Jobs + * @return ?Jobs * @throws IntercomException * @throws IntercomApiException */ - public function status(JobsStatusRequest $request, ?array $options = null): Jobs + 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->getId()}", + path: "jobs/status/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::GET, ), $options, @@ -82,20 +90,13 @@ public function status(JobsStatusRequest $request, ?array $options = null): Jobs $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } diff --git a/src/Unstable/Jobs/Requests/JobsStatusRequest.php b/src/Unstable/Jobs/Requests/JobsStatusRequest.php index a9254ad7..15ca8cff 100644 --- a/src/Unstable/Jobs/Requests/JobsStatusRequest.php +++ b/src/Unstable/Jobs/Requests/JobsStatusRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Jobs/Types/Jobs.php b/src/Unstable/Jobs/Types/Jobs.php index 33def70e..b5157f4b 100644 --- a/src/Unstable/Jobs/Types/Jobs.php +++ b/src/Unstable/Jobs/Types/Jobs.php @@ -89,6 +89,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -106,6 +107,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -123,6 +125,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -140,6 +143,7 @@ public function getStatus(): ?string public function setStatus(?string $value = null): self { $this->status = $value; + $this->_setField('status'); return $this; } @@ -157,6 +161,7 @@ public function getResourceType(): ?string public function setResourceType(?string $value = null): self { $this->resourceType = $value; + $this->_setField('resourceType'); return $this; } @@ -174,6 +179,7 @@ public function getResourceId(): ?string public function setResourceId(?string $value = null): self { $this->resourceId = $value; + $this->_setField('resourceId'); return $this; } @@ -191,6 +197,7 @@ public function getResourceUrl(): ?string public function setResourceUrl(?string $value = null): self { $this->resourceUrl = $value; + $this->_setField('resourceUrl'); return $this; } diff --git a/src/Unstable/Macros/MacrosClient.php b/src/Unstable/Macros/MacrosClient.php index ed5e868a..eb81eb6b 100644 --- a/src/Unstable/Macros/MacrosClient.php +++ b/src/Unstable/Macros/MacrosClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\Macros; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\Macros\Requests\ListMacrosRequest; use Intercom\Unstable\Macros\Types\MacroList; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\Macros\Requests\GetMacroRequest; use Intercom\Unstable\Macros\Types\Macro; @@ -68,6 +67,17 @@ public function __construct( * - From: `{{user.name | fallback: 'there'}}` * - To: `` * + * Example: + * ```php + * $client->unstable->macros->listMacros( + * new ListMacrosRequest([ + * 'perPage' => 1, + * 'startingAfter' => 'WzE3MTk0OTM3NTcuMCwgIjEyMyJd', + * 'updatedSince' => 1000000, + * ]), + * ); + * ``` + * * @param ListMacrosRequest $request * @param ?array{ * baseUrl?: string, @@ -77,11 +87,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return MacroList + * @return ?MacroList * @throws IntercomException * @throws IntercomApiException */ - public function listMacros(ListMacrosRequest $request = new ListMacrosRequest(), ?array $options = null): MacroList + public function listMacros(ListMacrosRequest $request = new ListMacrosRequest(), ?array $options = null): ?MacroList { $options = array_merge($this->options, $options ?? []); $query = []; @@ -107,20 +117,13 @@ public function listMacros(ListMacrosRequest $request = new ListMacrosRequest(), $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return MacroList::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); } @@ -150,6 +153,15 @@ public function listMacros(ListMacrosRequest $request = new ListMacrosRequest(), * * Default values in placeholders are HTML-escaped for security. * + * Example: + * ```php + * $client->unstable->macros->getMacro( + * new GetMacroRequest([ + * 'id' => '123', + * ]), + * ); + * ``` + * * @param GetMacroRequest $request * @param ?array{ * baseUrl?: string, @@ -170,7 +182,7 @@ public function getMacro(GetMacroRequest $request, ?array $options = null): ?Mac $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "macros/{$request->getId()}", + path: "macros/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::GET, ), $options, @@ -185,16 +197,6 @@ public function getMacro(GetMacroRequest $request, ?array $options = null): ?Mac } } 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); } diff --git a/src/Unstable/Macros/Requests/GetMacroRequest.php b/src/Unstable/Macros/Requests/GetMacroRequest.php index c89919b6..91c6d3a5 100644 --- a/src/Unstable/Macros/Requests/GetMacroRequest.php +++ b/src/Unstable/Macros/Requests/GetMacroRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Macros/Requests/ListMacrosRequest.php b/src/Unstable/Macros/Requests/ListMacrosRequest.php index 1d5a3ac5..5f97112f 100644 --- a/src/Unstable/Macros/Requests/ListMacrosRequest.php +++ b/src/Unstable/Macros/Requests/ListMacrosRequest.php @@ -50,6 +50,7 @@ public function getPerPage(): ?int public function setPerPage(?int $value = null): self { $this->perPage = $value; + $this->_setField('perPage'); return $this; } @@ -67,6 +68,7 @@ public function getStartingAfter(): ?string public function setStartingAfter(?string $value = null): self { $this->startingAfter = $value; + $this->_setField('startingAfter'); return $this; } @@ -84,6 +86,7 @@ public function getUpdatedSince(): ?int public function setUpdatedSince(?int $value = null): self { $this->updatedSince = $value; + $this->_setField('updatedSince'); return $this; } } diff --git a/src/Unstable/Macros/Types/Macro.php b/src/Unstable/Macros/Types/Macro.php index 53dcd59c..d7cc185e 100644 --- a/src/Unstable/Macros/Types/Macro.php +++ b/src/Unstable/Macros/Types/Macro.php @@ -116,6 +116,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -133,6 +134,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -150,6 +152,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -167,6 +170,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -184,6 +188,7 @@ public function getBodyText(): ?string public function setBodyText(?string $value = null): self { $this->bodyText = $value; + $this->_setField('bodyText'); return $this; } @@ -201,6 +206,7 @@ public function getCreatedAt(): ?DateTime public function setCreatedAt(?DateTime $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -218,6 +224,7 @@ public function getUpdatedAt(): ?DateTime public function setUpdatedAt(?DateTime $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -235,6 +242,7 @@ public function getVisibleTo(): ?string public function setVisibleTo(?string $value = null): self { $this->visibleTo = $value; + $this->_setField('visibleTo'); return $this; } @@ -252,6 +260,7 @@ public function getVisibleToTeamIds(): ?array public function setVisibleToTeamIds(?array $value = null): self { $this->visibleToTeamIds = $value; + $this->_setField('visibleToTeamIds'); return $this; } @@ -269,6 +278,7 @@ public function getAvailableOn(): ?array public function setAvailableOn(?array $value = null): self { $this->availableOn = $value; + $this->_setField('availableOn'); return $this; } diff --git a/src/Unstable/Macros/Types/MacroList.php b/src/Unstable/Macros/Types/MacroList.php index 11a0c338..b61139f1 100644 --- a/src/Unstable/Macros/Types/MacroList.php +++ b/src/Unstable/Macros/Types/MacroList.php @@ -59,6 +59,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -76,6 +77,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } @@ -93,6 +95,7 @@ public function getPages(): ?MacroListPages public function setPages(?MacroListPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } diff --git a/src/Unstable/Macros/Types/MacroListPages.php b/src/Unstable/Macros/Types/MacroListPages.php index 76164e57..23d697b6 100644 --- a/src/Unstable/Macros/Types/MacroListPages.php +++ b/src/Unstable/Macros/Types/MacroListPages.php @@ -57,6 +57,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -74,6 +75,7 @@ public function getPerPage(): ?int public function setPerPage(?int $value = null): self { $this->perPage = $value; + $this->_setField('perPage'); return $this; } @@ -91,6 +93,7 @@ public function getNext(): ?MacroListPagesNext public function setNext(?MacroListPagesNext $value = null): self { $this->next = $value; + $this->_setField('next'); return $this; } diff --git a/src/Unstable/Macros/Types/MacroListPagesNext.php b/src/Unstable/Macros/Types/MacroListPagesNext.php index cd5e3874..6933462e 100644 --- a/src/Unstable/Macros/Types/MacroListPagesNext.php +++ b/src/Unstable/Macros/Types/MacroListPagesNext.php @@ -41,6 +41,7 @@ public function getStartingAfter(): ?string public function setStartingAfter(?string $value = null): self { $this->startingAfter = $value; + $this->_setField('startingAfter'); return $this; } diff --git a/src/Unstable/Messages/MessagesClient.php b/src/Unstable/Messages/MessagesClient.php index 7413e3ec..895ab60d 100644 --- a/src/Unstable/Messages/MessagesClient.php +++ b/src/Unstable/Messages/MessagesClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\Messages; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\Messages\Types\Message; use Intercom\Exceptions\IntercomException; @@ -10,8 +10,9 @@ use Intercom\Core\Json\JsonApiRequest; use Intercom\Environments; use Intercom\Core\Client\HttpMethod; +use Intercom\Core\Json\JsonSerializer; +use Intercom\Core\Types\Union; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\Messages\Requests\GetWhatsAppMessageStatusRequest; use Intercom\Unstable\Types\WhatsappMessageStatusList; @@ -65,7 +66,23 @@ public function __construct( * > * > 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 mixed $request + * Example: + * ```php + * $client->unstable->messages->createMessage( + * [ + * 'from' => [ + * 'type' => "user", + * 'id' => "6762f2341bb69f9f2193bc17", + * ], + * 'body' => "heyy", + * 'referer' => "https://twitter.com/bob", + * ], + * ); + * ``` + * + * @param ( + * mixed + * )|null $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -74,11 +91,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Message + * @return ?Message * @throws IntercomException * @throws IntercomApiException */ - public function createMessage(mixed $request = null, ?array $options = null): Message + public function createMessage(mixed $request = null, ?array $options = null): ?Message { $options = array_merge($this->options, $options ?? []); try { @@ -87,27 +104,20 @@ public function createMessage(mixed $request = null, ?array $options = null): Me baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, path: "messages", method: HttpMethod::POST, - body: $request, + body: $request ? JsonSerializer::serializeUnion($request, new Union('mixed', 'null')) : null, ), $options, ); $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Message::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); } @@ -125,6 +135,17 @@ public function createMessage(mixed $request = null, ?array $options = null): Me * This endpoint returns paginated status events for WhatsApp messages sent via the Outbound module, providing * information about delivery state and related message details. * + * Example: + * ```php + * $client->unstable->messages->getWhatsAppMessageStatus( + * new GetWhatsAppMessageStatusRequest([ + * 'rulesetId' => 'ruleset_id', + * 'perPage' => 1, + * 'startingAfter' => 'starting_after', + * ]), + * ); + * ``` + * * @param GetWhatsAppMessageStatusRequest $request * @param ?array{ * baseUrl?: string, @@ -134,11 +155,11 @@ public function createMessage(mixed $request = null, ?array $options = null): Me * queryParameters?: array, * bodyProperties?: array, * } $options - * @return WhatsappMessageStatusList + * @return ?WhatsappMessageStatusList * @throws IntercomException * @throws IntercomApiException */ - public function getWhatsAppMessageStatus(GetWhatsAppMessageStatusRequest $request, ?array $options = null): WhatsappMessageStatusList + public function getWhatsAppMessageStatus(GetWhatsAppMessageStatusRequest $request, ?array $options = null): ?WhatsappMessageStatusList { $options = array_merge($this->options, $options ?? []); $query = []; @@ -162,20 +183,13 @@ public function getWhatsAppMessageStatus(GetWhatsAppMessageStatusRequest $reques $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return WhatsappMessageStatusList::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); } diff --git a/src/Unstable/Messages/Requests/GetWhatsAppMessageStatusRequest.php b/src/Unstable/Messages/Requests/GetWhatsAppMessageStatusRequest.php index d06d2a28..6d4501ae 100644 --- a/src/Unstable/Messages/Requests/GetWhatsAppMessageStatusRequest.php +++ b/src/Unstable/Messages/Requests/GetWhatsAppMessageStatusRequest.php @@ -50,6 +50,7 @@ public function getRulesetId(): string public function setRulesetId(string $value): self { $this->rulesetId = $value; + $this->_setField('rulesetId'); return $this; } @@ -67,6 +68,7 @@ public function getPerPage(): ?int public function setPerPage(?int $value = null): self { $this->perPage = $value; + $this->_setField('perPage'); return $this; } @@ -84,6 +86,7 @@ public function getStartingAfter(): ?string public function setStartingAfter(?string $value = null): self { $this->startingAfter = $value; + $this->_setField('startingAfter'); return $this; } } diff --git a/src/Unstable/Messages/Types/Message.php b/src/Unstable/Messages/Types/Message.php index f4f1fa04..edeacb93 100644 --- a/src/Unstable/Messages/Types/Message.php +++ b/src/Unstable/Messages/Types/Message.php @@ -89,6 +89,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -106,6 +107,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -123,6 +125,7 @@ public function getCreatedAt(): int public function setCreatedAt(int $value): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -140,6 +143,7 @@ public function getSubject(): ?string public function setSubject(?string $value = null): self { $this->subject = $value; + $this->_setField('subject'); return $this; } @@ -157,6 +161,7 @@ public function getBody(): string public function setBody(string $value): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -174,6 +179,7 @@ public function getMessageType(): string public function setMessageType(string $value): self { $this->messageType = $value; + $this->_setField('messageType'); return $this; } @@ -191,6 +197,7 @@ public function getConversationId(): ?string public function setConversationId(?string $value = null): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } diff --git a/src/Unstable/News/NewsClient.php b/src/Unstable/News/NewsClient.php index d1411ce3..e9a89cbf 100644 --- a/src/Unstable/News/NewsClient.php +++ b/src/Unstable/News/NewsClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\News; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\Types\PaginatedResponse; use Intercom\Exceptions\IntercomException; @@ -11,7 +11,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\Types\NewsItemRequest; use Intercom\Unstable\News\Types\NewsItem; @@ -62,6 +61,11 @@ public function __construct( /** * You can fetch a list of all news items * + * Example: + * ```php + * $client->news->items->list(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -70,11 +74,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return PaginatedResponse + * @return ?PaginatedResponse * @throws IntercomException * @throws IntercomApiException */ - public function listNewsItems(?array $options = null): PaginatedResponse + public function listNewsItems(?array $options = null): ?PaginatedResponse { $options = array_merge($this->options, $options ?? []); try { @@ -89,20 +93,13 @@ public function listNewsItems(?array $options = null): PaginatedResponse $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return PaginatedResponse::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); } @@ -116,6 +113,34 @@ public function listNewsItems(?array $options = null): PaginatedResponse /** * You can create a news item * + * Example: + * ```php + * $client->news->items->create( + * new NewsItemRequest([ + * 'title' => 'Halloween is here!', + * 'body' => '

New costumes in store for this spooky season

', + * 'senderId' => 991267834, + * 'state' => NewsItemRequestState::Live->value, + * 'deliverSilently' => true, + * 'labels' => [ + * 'Product', + * 'Update', + * 'New', + * ], + * 'reactions' => [ + * '😆', + * '😅', + * ], + * 'newsfeedAssignments' => [ + * new NewsfeedAssignment([ + * 'newsfeedId' => 53, + * 'publishedAt' => 1664638214, + * ]), + * ], + * ]), + * ); + * ``` + * * @param NewsItemRequest $request * @param ?array{ * baseUrl?: string, @@ -125,11 +150,11 @@ public function listNewsItems(?array $options = null): PaginatedResponse * queryParameters?: array, * bodyProperties?: array, * } $options - * @return NewsItem + * @return ?NewsItem * @throws IntercomException * @throws IntercomApiException */ - public function createNewsItem(NewsItemRequest $request, ?array $options = null): NewsItem + public function createNewsItem(NewsItemRequest $request, ?array $options = null): ?NewsItem { $options = array_merge($this->options, $options ?? []); try { @@ -145,20 +170,13 @@ public function createNewsItem(NewsItemRequest $request, ?array $options = null) $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return NewsItem::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); } @@ -172,6 +190,15 @@ public function createNewsItem(NewsItemRequest $request, ?array $options = null) /** * You can fetch the details of a single news item. * + * Example: + * ```php + * $client->unstable->news->retrieveNewsItem( + * new RetrieveNewsItemRequest([ + * 'id' => 1, + * ]), + * ); + * ``` + * * @param RetrieveNewsItemRequest $request * @param ?array{ * baseUrl?: string, @@ -181,18 +208,18 @@ public function createNewsItem(NewsItemRequest $request, ?array $options = null) * queryParameters?: array, * bodyProperties?: array, * } $options - * @return NewsItem + * @return ?NewsItem * @throws IntercomException * @throws IntercomApiException */ - public function retrieveNewsItem(RetrieveNewsItemRequest $request, ?array $options = null): NewsItem + public function retrieveNewsItem(RetrieveNewsItemRequest $request, ?array $options = null): ?NewsItem { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "news/news_items/{$request->getId()}", + path: "news/news_items/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::GET, ), $options, @@ -200,20 +227,13 @@ public function retrieveNewsItem(RetrieveNewsItemRequest $request, ?array $optio $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return NewsItem::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); } @@ -225,6 +245,24 @@ public function retrieveNewsItem(RetrieveNewsItemRequest $request, ?array $optio } /** + * Example: + * ```php + * $client->unstable->news->updateNewsItem( + * new UpdateNewsItemRequest([ + * 'id' => 1, + * 'body' => new NewsItemRequest([ + * 'title' => 'Christmas is here!', + * 'body' => '

New gifts in store for the jolly season

', + * 'senderId' => 991267845, + * 'reactions' => [ + * '😝', + * '😂', + * ], + * ]), + * ]), + * ); + * ``` + * * @param UpdateNewsItemRequest $request * @param ?array{ * baseUrl?: string, @@ -234,18 +272,18 @@ public function retrieveNewsItem(RetrieveNewsItemRequest $request, ?array $optio * queryParameters?: array, * bodyProperties?: array, * } $options - * @return NewsItem + * @return ?NewsItem * @throws IntercomException * @throws IntercomApiException */ - public function updateNewsItem(UpdateNewsItemRequest $request, ?array $options = null): NewsItem + public function updateNewsItem(UpdateNewsItemRequest $request, ?array $options = null): ?NewsItem { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "news/news_items/{$request->getId()}", + path: "news/news_items/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::PUT, body: $request->getBody(), ), @@ -254,20 +292,13 @@ public function updateNewsItem(UpdateNewsItemRequest $request, ?array $options = $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return NewsItem::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); } @@ -281,6 +312,15 @@ public function updateNewsItem(UpdateNewsItemRequest $request, ?array $options = /** * You can delete a single news item. * + * Example: + * ```php + * $client->unstable->news->deleteNewsItem( + * new DeleteNewsItemRequest([ + * 'id' => 1, + * ]), + * ); + * ``` + * * @param DeleteNewsItemRequest $request * @param ?array{ * baseUrl?: string, @@ -290,18 +330,18 @@ public function updateNewsItem(UpdateNewsItemRequest $request, ?array $options = * queryParameters?: array, * bodyProperties?: array, * } $options - * @return DeletedObject + * @return ?DeletedObject * @throws IntercomException * @throws IntercomApiException */ - public function deleteNewsItem(DeleteNewsItemRequest $request, ?array $options = null): DeletedObject + public function deleteNewsItem(DeleteNewsItemRequest $request, ?array $options = null): ?DeletedObject { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "news/news_items/{$request->getId()}", + path: "news/news_items/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::DELETE, ), $options, @@ -309,20 +349,13 @@ public function deleteNewsItem(DeleteNewsItemRequest $request, ?array $options = $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return DeletedObject::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); } @@ -336,6 +369,15 @@ public function deleteNewsItem(DeleteNewsItemRequest $request, ?array $options = /** * You can fetch a list of all news items that are live on a given newsfeed * + * Example: + * ```php + * $client->unstable->news->listLiveNewsfeedItems( + * new ListLiveNewsfeedItemsRequest([ + * 'id' => '123', + * ]), + * ); + * ``` + * * @param ListLiveNewsfeedItemsRequest $request * @param ?array{ * baseUrl?: string, @@ -345,18 +387,18 @@ public function deleteNewsItem(DeleteNewsItemRequest $request, ?array $options = * queryParameters?: array, * bodyProperties?: array, * } $options - * @return PaginatedResponse + * @return ?PaginatedResponse * @throws IntercomException * @throws IntercomApiException */ - public function listLiveNewsfeedItems(ListLiveNewsfeedItemsRequest $request, ?array $options = null): PaginatedResponse + public function listLiveNewsfeedItems(ListLiveNewsfeedItemsRequest $request, ?array $options = null): ?PaginatedResponse { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "news/newsfeeds/{$request->getId()}/items", + path: "news/newsfeeds/" . RawClient::encodePathParam($request->getId()) . "/items", method: HttpMethod::GET, ), $options, @@ -364,20 +406,13 @@ public function listLiveNewsfeedItems(ListLiveNewsfeedItemsRequest $request, ?ar $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return PaginatedResponse::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); } @@ -391,6 +426,11 @@ public function listLiveNewsfeedItems(ListLiveNewsfeedItemsRequest $request, ?ar /** * You can fetch a list of all newsfeeds * + * Example: + * ```php + * $client->news->feeds->list(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -399,11 +439,11 @@ public function listLiveNewsfeedItems(ListLiveNewsfeedItemsRequest $request, ?ar * queryParameters?: array, * bodyProperties?: array, * } $options - * @return PaginatedResponse + * @return ?PaginatedResponse * @throws IntercomException * @throws IntercomApiException */ - public function listNewsfeeds(?array $options = null): PaginatedResponse + public function listNewsfeeds(?array $options = null): ?PaginatedResponse { $options = array_merge($this->options, $options ?? []); try { @@ -418,20 +458,13 @@ public function listNewsfeeds(?array $options = null): PaginatedResponse $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return PaginatedResponse::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); } @@ -445,6 +478,15 @@ public function listNewsfeeds(?array $options = null): PaginatedResponse /** * You can fetch the details of a single newsfeed * + * Example: + * ```php + * $client->unstable->news->retrieveNewsfeed( + * new RetrieveNewsfeedRequest([ + * 'id' => '123', + * ]), + * ); + * ``` + * * @param RetrieveNewsfeedRequest $request * @param ?array{ * baseUrl?: string, @@ -454,18 +496,18 @@ public function listNewsfeeds(?array $options = null): PaginatedResponse * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Newsfeed + * @return ?Newsfeed * @throws IntercomException * @throws IntercomApiException */ - public function retrieveNewsfeed(RetrieveNewsfeedRequest $request, ?array $options = null): Newsfeed + public function retrieveNewsfeed(RetrieveNewsfeedRequest $request, ?array $options = null): ?Newsfeed { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "news/newsfeeds/{$request->getId()}", + path: "news/newsfeeds/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::GET, ), $options, @@ -473,20 +515,13 @@ public function retrieveNewsfeed(RetrieveNewsfeedRequest $request, ?array $optio $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Newsfeed::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); } diff --git a/src/Unstable/News/Requests/DeleteNewsItemRequest.php b/src/Unstable/News/Requests/DeleteNewsItemRequest.php index 6c2012ad..26d6ee43 100644 --- a/src/Unstable/News/Requests/DeleteNewsItemRequest.php +++ b/src/Unstable/News/Requests/DeleteNewsItemRequest.php @@ -36,6 +36,7 @@ public function getId(): int public function setId(int $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/News/Requests/ListLiveNewsfeedItemsRequest.php b/src/Unstable/News/Requests/ListLiveNewsfeedItemsRequest.php index af36040e..cc5780a7 100644 --- a/src/Unstable/News/Requests/ListLiveNewsfeedItemsRequest.php +++ b/src/Unstable/News/Requests/ListLiveNewsfeedItemsRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/News/Requests/RetrieveNewsItemRequest.php b/src/Unstable/News/Requests/RetrieveNewsItemRequest.php index da69e611..932f20d2 100644 --- a/src/Unstable/News/Requests/RetrieveNewsItemRequest.php +++ b/src/Unstable/News/Requests/RetrieveNewsItemRequest.php @@ -36,6 +36,7 @@ public function getId(): int public function setId(int $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/News/Requests/RetrieveNewsfeedRequest.php b/src/Unstable/News/Requests/RetrieveNewsfeedRequest.php index 3ff99160..27d174b1 100644 --- a/src/Unstable/News/Requests/RetrieveNewsfeedRequest.php +++ b/src/Unstable/News/Requests/RetrieveNewsfeedRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/News/Requests/UpdateNewsItemRequest.php b/src/Unstable/News/Requests/UpdateNewsItemRequest.php index da433458..78f87271 100644 --- a/src/Unstable/News/Requests/UpdateNewsItemRequest.php +++ b/src/Unstable/News/Requests/UpdateNewsItemRequest.php @@ -44,6 +44,7 @@ public function getId(): int public function setId(int $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -61,6 +62,7 @@ public function getBody(): NewsItemRequest public function setBody(NewsItemRequest $value): self { $this->body = $value; + $this->_setField('body'); return $this; } } diff --git a/src/Unstable/News/Types/NewsItem.php b/src/Unstable/News/Types/NewsItem.php index 0135982e..230f03ff 100644 --- a/src/Unstable/News/Types/NewsItem.php +++ b/src/Unstable/News/Types/NewsItem.php @@ -147,6 +147,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -164,6 +165,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -181,6 +183,7 @@ public function getWorkspaceId(): ?string public function setWorkspaceId(?string $value = null): self { $this->workspaceId = $value; + $this->_setField('workspaceId'); return $this; } @@ -198,6 +201,7 @@ public function getTitle(): ?string public function setTitle(?string $value = null): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -215,6 +219,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -232,6 +237,7 @@ public function getSenderId(): ?int public function setSenderId(?int $value = null): self { $this->senderId = $value; + $this->_setField('senderId'); return $this; } @@ -249,6 +255,7 @@ public function getState(): ?string public function setState(?string $value = null): self { $this->state = $value; + $this->_setField('state'); return $this; } @@ -266,6 +273,7 @@ public function getNewsfeedAssignments(): ?array public function setNewsfeedAssignments(?array $value = null): self { $this->newsfeedAssignments = $value; + $this->_setField('newsfeedAssignments'); return $this; } @@ -283,6 +291,7 @@ public function getLabels(): ?array public function setLabels(?array $value = null): self { $this->labels = $value; + $this->_setField('labels'); return $this; } @@ -300,6 +309,7 @@ public function getCoverImageUrl(): ?string public function setCoverImageUrl(?string $value = null): self { $this->coverImageUrl = $value; + $this->_setField('coverImageUrl'); return $this; } @@ -317,6 +327,7 @@ public function getReactions(): ?array public function setReactions(?array $value = null): self { $this->reactions = $value; + $this->_setField('reactions'); return $this; } @@ -334,6 +345,7 @@ public function getDeliverSilently(): ?bool public function setDeliverSilently(?bool $value = null): self { $this->deliverSilently = $value; + $this->_setField('deliverSilently'); return $this; } @@ -351,6 +363,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -368,6 +381,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } diff --git a/src/Unstable/News/Types/Newsfeed.php b/src/Unstable/News/Types/Newsfeed.php index 3e8db8dc..2de1fece 100644 --- a/src/Unstable/News/Types/Newsfeed.php +++ b/src/Unstable/News/Types/Newsfeed.php @@ -75,6 +75,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -92,6 +93,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -109,6 +111,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -126,6 +129,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -143,6 +147,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } diff --git a/src/Unstable/News/Types/NewsfeedAssignment.php b/src/Unstable/News/Types/NewsfeedAssignment.php index 6ac17aee..38d43e72 100644 --- a/src/Unstable/News/Types/NewsfeedAssignment.php +++ b/src/Unstable/News/Types/NewsfeedAssignment.php @@ -49,6 +49,7 @@ public function getNewsfeedId(): ?int public function setNewsfeedId(?int $value = null): self { $this->newsfeedId = $value; + $this->_setField('newsfeedId'); return $this; } @@ -66,6 +67,7 @@ public function getPublishedAt(): ?int public function setPublishedAt(?int $value = null): self { $this->publishedAt = $value; + $this->_setField('publishedAt'); return $this; } diff --git a/src/Unstable/Notes/NotesClient.php b/src/Unstable/Notes/NotesClient.php index e0416920..69c7035a 100644 --- a/src/Unstable/Notes/NotesClient.php +++ b/src/Unstable/Notes/NotesClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\Notes; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\Notes\Requests\ListCompanyNotesRequest; use Intercom\Unstable\Types\NoteList; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\Notes\Requests\ListNotesRequest; use Intercom\Unstable\Notes\Requests\CreateNoteRequest; @@ -58,6 +57,15 @@ public function __construct( /** * You can fetch a list of notes that are associated to a company. * + * Example: + * ```php + * $client->unstable->notes->listCompanyNotes( + * new ListCompanyNotesRequest([ + * 'id' => '5f4d3c1c-7b1b-4d7d-a97e-6095715c6632', + * ]), + * ); + * ``` + * * @param ListCompanyNotesRequest $request * @param ?array{ * baseUrl?: string, @@ -67,18 +75,18 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return NoteList + * @return ?NoteList * @throws IntercomException * @throws IntercomApiException */ - public function listCompanyNotes(ListCompanyNotesRequest $request, ?array $options = null): NoteList + public function listCompanyNotes(ListCompanyNotesRequest $request, ?array $options = null): ?NoteList { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "companies/{$request->getId()}/notes", + path: "companies/" . RawClient::encodePathParam($request->getId()) . "/notes", method: HttpMethod::GET, ), $options, @@ -86,20 +94,13 @@ public function listCompanyNotes(ListCompanyNotesRequest $request, ?array $optio $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return NoteList::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); } @@ -113,6 +114,15 @@ public function listCompanyNotes(ListCompanyNotesRequest $request, ?array $optio /** * You can fetch a list of notes that are associated to a contact. * + * Example: + * ```php + * $client->unstable->notes->listNotes( + * new ListNotesRequest([ + * 'id' => 1, + * ]), + * ); + * ``` + * * @param ListNotesRequest $request * @param ?array{ * baseUrl?: string, @@ -122,18 +132,18 @@ public function listCompanyNotes(ListCompanyNotesRequest $request, ?array $optio * queryParameters?: array, * bodyProperties?: array, * } $options - * @return NoteList + * @return ?NoteList * @throws IntercomException * @throws IntercomApiException */ - public function listNotes(ListNotesRequest $request, ?array $options = null): NoteList + public function listNotes(ListNotesRequest $request, ?array $options = null): ?NoteList { $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->getId()}/notes", + path: "contacts/" . RawClient::encodePathParam($request->getId()) . "/notes", method: HttpMethod::GET, ), $options, @@ -141,20 +151,13 @@ public function listNotes(ListNotesRequest $request, ?array $options = null): No $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return NoteList::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); } @@ -168,6 +171,18 @@ public function listNotes(ListNotesRequest $request, ?array $options = null): No /** * You can add a note to a single contact. * + * Example: + * ```php + * $client->unstable->notes->createNote( + * new CreateNoteRequest([ + * 'id' => 1, + * 'body' => 'Hello', + * 'contactId' => '6762f0ad1bb69f9f2193bb62', + * 'adminId' => '123', + * ]), + * ); + * ``` + * * @param CreateNoteRequest $request * @param ?array{ * baseUrl?: string, @@ -177,18 +192,18 @@ public function listNotes(ListNotesRequest $request, ?array $options = null): No * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Note + * @return ?Note * @throws IntercomException * @throws IntercomApiException */ - public function createNote(CreateNoteRequest $request, ?array $options = null): Note + public function createNote(CreateNoteRequest $request, ?array $options = null): ?Note { $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->getId()}/notes", + path: "contacts/" . RawClient::encodePathParam($request->getId()) . "/notes", method: HttpMethod::POST, body: $request, ), @@ -197,20 +212,13 @@ public function createNote(CreateNoteRequest $request, ?array $options = null): $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Note::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); } @@ -224,6 +232,15 @@ public function createNote(CreateNoteRequest $request, ?array $options = null): /** * You can fetch the details of a single note. * + * Example: + * ```php + * $client->unstable->notes->retrieveNote( + * new RetrieveNoteRequest([ + * 'id' => 1, + * ]), + * ); + * ``` + * * @param RetrieveNoteRequest $request * @param ?array{ * baseUrl?: string, @@ -233,18 +250,18 @@ public function createNote(CreateNoteRequest $request, ?array $options = null): * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Note + * @return ?Note * @throws IntercomException * @throws IntercomApiException */ - public function retrieveNote(RetrieveNoteRequest $request, ?array $options = null): Note + public function retrieveNote(RetrieveNoteRequest $request, ?array $options = null): ?Note { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "notes/{$request->getId()}", + path: "notes/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::GET, ), $options, @@ -252,20 +269,13 @@ public function retrieveNote(RetrieveNoteRequest $request, ?array $options = nul $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Note::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); } diff --git a/src/Unstable/Notes/Requests/CreateNoteRequest.php b/src/Unstable/Notes/Requests/CreateNoteRequest.php index 1aa618fe..f73e224a 100644 --- a/src/Unstable/Notes/Requests/CreateNoteRequest.php +++ b/src/Unstable/Notes/Requests/CreateNoteRequest.php @@ -61,6 +61,7 @@ public function getId(): int public function setId(int $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -78,6 +79,7 @@ public function getBody(): string public function setBody(string $value): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -95,6 +97,7 @@ public function getContactId(): ?string public function setContactId(?string $value = null): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } @@ -112,6 +115,7 @@ public function getAdminId(): ?string public function setAdminId(?string $value = null): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } } diff --git a/src/Unstable/Notes/Requests/ListCompanyNotesRequest.php b/src/Unstable/Notes/Requests/ListCompanyNotesRequest.php index 54b001c8..8fce371e 100644 --- a/src/Unstable/Notes/Requests/ListCompanyNotesRequest.php +++ b/src/Unstable/Notes/Requests/ListCompanyNotesRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Notes/Requests/ListNotesRequest.php b/src/Unstable/Notes/Requests/ListNotesRequest.php index 57a1e026..d548bac3 100644 --- a/src/Unstable/Notes/Requests/ListNotesRequest.php +++ b/src/Unstable/Notes/Requests/ListNotesRequest.php @@ -36,6 +36,7 @@ public function getId(): int public function setId(int $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Notes/Requests/RetrieveNoteRequest.php b/src/Unstable/Notes/Requests/RetrieveNoteRequest.php index 49ef9cf9..31569560 100644 --- a/src/Unstable/Notes/Requests/RetrieveNoteRequest.php +++ b/src/Unstable/Notes/Requests/RetrieveNoteRequest.php @@ -36,6 +36,7 @@ public function getId(): int public function setId(int $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Notes/Types/CompanyNote.php b/src/Unstable/Notes/Types/CompanyNote.php index 1eddf570..43ba945a 100644 --- a/src/Unstable/Notes/Types/CompanyNote.php +++ b/src/Unstable/Notes/Types/CompanyNote.php @@ -82,6 +82,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -99,6 +100,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -116,6 +118,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -133,6 +136,7 @@ public function getCompany(): ?CompanyNoteCompany public function setCompany(?CompanyNoteCompany $value = null): self { $this->company = $value; + $this->_setField('company'); return $this; } @@ -150,6 +154,7 @@ public function getAuthor(): ?Admin public function setAuthor(?Admin $value = null): self { $this->author = $value; + $this->_setField('author'); return $this; } @@ -167,6 +172,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } diff --git a/src/Unstable/Notes/Types/CompanyNoteCompany.php b/src/Unstable/Notes/Types/CompanyNoteCompany.php index 5d2154cf..5e6cb365 100644 --- a/src/Unstable/Notes/Types/CompanyNoteCompany.php +++ b/src/Unstable/Notes/Types/CompanyNoteCompany.php @@ -49,6 +49,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -66,6 +67,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } diff --git a/src/Unstable/Notes/Types/Note.php b/src/Unstable/Notes/Types/Note.php index 8c6573ca..31679843 100644 --- a/src/Unstable/Notes/Types/Note.php +++ b/src/Unstable/Notes/Types/Note.php @@ -82,6 +82,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -99,6 +100,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -116,6 +118,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -133,6 +136,7 @@ public function getContact(): ?NoteContact public function setContact(?NoteContact $value = null): self { $this->contact = $value; + $this->_setField('contact'); return $this; } @@ -150,6 +154,7 @@ public function getAuthor(): ?Admin public function setAuthor(?Admin $value = null): self { $this->author = $value; + $this->_setField('author'); return $this; } @@ -167,6 +172,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } diff --git a/src/Unstable/Notes/Types/NoteContact.php b/src/Unstable/Notes/Types/NoteContact.php index 7c8c3f4f..334f5fed 100644 --- a/src/Unstable/Notes/Types/NoteContact.php +++ b/src/Unstable/Notes/Types/NoteContact.php @@ -49,6 +49,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -66,6 +67,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } diff --git a/src/Unstable/Segments/Requests/ListSegmentsRequest.php b/src/Unstable/Segments/Requests/ListSegmentsRequest.php index af088e3a..d50b1163 100644 --- a/src/Unstable/Segments/Requests/ListSegmentsRequest.php +++ b/src/Unstable/Segments/Requests/ListSegmentsRequest.php @@ -36,6 +36,7 @@ public function getIncludeCount(): ?bool public function setIncludeCount(?bool $value = null): self { $this->includeCount = $value; + $this->_setField('includeCount'); return $this; } } diff --git a/src/Unstable/Segments/Requests/RetrieveSegmentRequest.php b/src/Unstable/Segments/Requests/RetrieveSegmentRequest.php index 0fc49ce0..4c9c7b2f 100644 --- a/src/Unstable/Segments/Requests/RetrieveSegmentRequest.php +++ b/src/Unstable/Segments/Requests/RetrieveSegmentRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Segments/SegmentsClient.php b/src/Unstable/Segments/SegmentsClient.php index fdfae883..0d55e7d7 100644 --- a/src/Unstable/Segments/SegmentsClient.php +++ b/src/Unstable/Segments/SegmentsClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\Segments; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\Segments\Requests\ListSegmentsRequest; use Intercom\Unstable\Types\SegmentList; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\Segments\Requests\RetrieveSegmentRequest; use Intercom\Unstable\Segments\Types\Segment; @@ -56,6 +55,15 @@ public function __construct( /** * You can fetch a list of all segments. * + * Example: + * ```php + * $client->segments->list( + * new ListSegmentsRequest([ + * 'includeCount' => true, + * ]), + * ); + * ``` + * * @param ListSegmentsRequest $request * @param ?array{ * baseUrl?: string, @@ -65,11 +73,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return SegmentList + * @return ?SegmentList * @throws IntercomException * @throws IntercomApiException */ - public function listSegments(ListSegmentsRequest $request = new ListSegmentsRequest(), ?array $options = null): SegmentList + public function listSegments(ListSegmentsRequest $request = new ListSegmentsRequest(), ?array $options = null): ?SegmentList { $options = array_merge($this->options, $options ?? []); $query = []; @@ -89,20 +97,13 @@ public function listSegments(ListSegmentsRequest $request = new ListSegmentsRequ $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return SegmentList::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); } @@ -116,6 +117,15 @@ public function listSegments(ListSegmentsRequest $request = new ListSegmentsRequ /** * You can fetch the details of a single segment. * + * Example: + * ```php + * $client->unstable->segments->retrieveSegment( + * new RetrieveSegmentRequest([ + * 'id' => '123', + * ]), + * ); + * ``` + * * @param RetrieveSegmentRequest $request * @param ?array{ * baseUrl?: string, @@ -125,18 +135,18 @@ public function listSegments(ListSegmentsRequest $request = new ListSegmentsRequ * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Segment + * @return ?Segment * @throws IntercomException * @throws IntercomApiException */ - public function retrieveSegment(RetrieveSegmentRequest $request, ?array $options = null): Segment + public function retrieveSegment(RetrieveSegmentRequest $request, ?array $options = null): ?Segment { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "segments/{$request->getId()}", + path: "segments/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::GET, ), $options, @@ -144,20 +154,13 @@ public function retrieveSegment(RetrieveSegmentRequest $request, ?array $options $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Segment::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); } diff --git a/src/Unstable/Segments/Types/Segment.php b/src/Unstable/Segments/Types/Segment.php index b753be40..28306754 100644 --- a/src/Unstable/Segments/Types/Segment.php +++ b/src/Unstable/Segments/Types/Segment.php @@ -89,6 +89,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -106,6 +107,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -123,6 +125,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -140,6 +143,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -157,6 +161,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -174,6 +179,7 @@ public function getPersonType(): ?string public function setPersonType(?string $value = null): self { $this->personType = $value; + $this->_setField('personType'); return $this; } @@ -191,6 +197,7 @@ public function getCount(): ?int public function setCount(?int $value = null): self { $this->count = $value; + $this->_setField('count'); return $this; } diff --git a/src/Unstable/SubscriptionTypes/Requests/AttachSubscriptionTypeToContactRequest.php b/src/Unstable/SubscriptionTypes/Requests/AttachSubscriptionTypeToContactRequest.php index 686e7646..9a4960b3 100644 --- a/src/Unstable/SubscriptionTypes/Requests/AttachSubscriptionTypeToContactRequest.php +++ b/src/Unstable/SubscriptionTypes/Requests/AttachSubscriptionTypeToContactRequest.php @@ -53,6 +53,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } @@ -70,6 +71,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -87,6 +89,7 @@ public function getConsentType(): string public function setConsentType(string $value): self { $this->consentType = $value; + $this->_setField('consentType'); return $this; } } diff --git a/src/Unstable/SubscriptionTypes/Requests/DetachSubscriptionTypeToContactRequest.php b/src/Unstable/SubscriptionTypes/Requests/DetachSubscriptionTypeToContactRequest.php index 4b01e997..e6b28e0e 100644 --- a/src/Unstable/SubscriptionTypes/Requests/DetachSubscriptionTypeToContactRequest.php +++ b/src/Unstable/SubscriptionTypes/Requests/DetachSubscriptionTypeToContactRequest.php @@ -43,6 +43,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } @@ -60,6 +61,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/SubscriptionTypes/SubscriptionTypesClient.php b/src/Unstable/SubscriptionTypes/SubscriptionTypesClient.php index 62db4cea..aad51082 100644 --- a/src/Unstable/SubscriptionTypes/SubscriptionTypesClient.php +++ b/src/Unstable/SubscriptionTypes/SubscriptionTypesClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\SubscriptionTypes; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\SubscriptionTypes\Requests\AttachSubscriptionTypeToContactRequest; use Intercom\Unstable\SubscriptionTypes\Types\SubscriptionType; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\SubscriptionTypes\Requests\DetachSubscriptionTypeToContactRequest; use Intercom\Unstable\Types\SubscriptionTypeList; @@ -62,6 +61,17 @@ public function __construct( * * This will return a subscription type model for the subscription type that was added to the contact. * + * Example: + * ```php + * $client->contacts->attachSubscription( + * new AttachSubscriptionToContactRequest([ + * 'contactId' => '63a07ddf05a32042dffac965', + * 'subscriptionId' => '37846', + * 'consentType' => 'opt_in', + * ]), + * ); + * ``` + * * @param AttachSubscriptionTypeToContactRequest $request * @param ?array{ * baseUrl?: string, @@ -71,18 +81,18 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return SubscriptionType + * @return ?SubscriptionType * @throws IntercomException * @throws IntercomApiException */ - public function attachSubscriptionTypeToContact(AttachSubscriptionTypeToContactRequest $request, ?array $options = null): SubscriptionType + public function attachSubscriptionTypeToContact(AttachSubscriptionTypeToContactRequest $request, ?array $options = null): ?SubscriptionType { $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()}/subscriptions", + path: "contacts/" . RawClient::encodePathParam($request->getContactId()) . "/subscriptions", method: HttpMethod::POST, body: $request, ), @@ -91,20 +101,13 @@ public function attachSubscriptionTypeToContact(AttachSubscriptionTypeToContactR $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return SubscriptionType::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); } @@ -118,6 +121,16 @@ public function attachSubscriptionTypeToContact(AttachSubscriptionTypeToContactR /** * You can remove a specific subscription from a contact. This will return a subscription type model for the subscription type that was removed from the contact. * + * Example: + * ```php + * $client->unstable->subscriptionTypes->detachSubscriptionTypeToContact( + * new DetachSubscriptionTypeToContactRequest([ + * 'contactId' => '63a07ddf05a32042dffac965', + * 'id' => '37846', + * ]), + * ); + * ``` + * * @param DetachSubscriptionTypeToContactRequest $request * @param ?array{ * baseUrl?: string, @@ -127,18 +140,18 @@ public function attachSubscriptionTypeToContact(AttachSubscriptionTypeToContactR * queryParameters?: array, * bodyProperties?: array, * } $options - * @return SubscriptionType + * @return ?SubscriptionType * @throws IntercomException * @throws IntercomApiException */ - public function detachSubscriptionTypeToContact(DetachSubscriptionTypeToContactRequest $request, ?array $options = null): SubscriptionType + public function detachSubscriptionTypeToContact(DetachSubscriptionTypeToContactRequest $request, ?array $options = null): ?SubscriptionType { $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()}/subscriptions/{$request->getId()}", + path: "contacts/" . RawClient::encodePathParam($request->getContactId()) . "/subscriptions/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::DELETE, ), $options, @@ -146,20 +159,13 @@ public function detachSubscriptionTypeToContact(DetachSubscriptionTypeToContactR $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return SubscriptionType::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); } @@ -173,6 +179,11 @@ public function detachSubscriptionTypeToContact(DetachSubscriptionTypeToContactR /** * You can list all subscription types. A list of subscription type objects will be returned. * + * Example: + * ```php + * $client->subscriptionTypes->list(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -181,11 +192,11 @@ public function detachSubscriptionTypeToContact(DetachSubscriptionTypeToContactR * queryParameters?: array, * bodyProperties?: array, * } $options - * @return SubscriptionTypeList + * @return ?SubscriptionTypeList * @throws IntercomException * @throws IntercomApiException */ - public function listSubscriptionTypes(?array $options = null): SubscriptionTypeList + public function listSubscriptionTypes(?array $options = null): ?SubscriptionTypeList { $options = array_merge($this->options, $options ?? []); try { @@ -200,20 +211,13 @@ public function listSubscriptionTypes(?array $options = null): SubscriptionTypeL $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return SubscriptionTypeList::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); } diff --git a/src/Unstable/SubscriptionTypes/Types/SubscriptionType.php b/src/Unstable/SubscriptionTypes/Types/SubscriptionType.php index 423e7c81..6ed5b275 100644 --- a/src/Unstable/SubscriptionTypes/Types/SubscriptionType.php +++ b/src/Unstable/SubscriptionTypes/Types/SubscriptionType.php @@ -91,6 +91,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -108,6 +109,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -125,6 +127,7 @@ public function getState(): ?string public function setState(?string $value = null): self { $this->state = $value; + $this->_setField('state'); return $this; } @@ -142,6 +145,7 @@ public function getDefaultTranslation(): ?Translation public function setDefaultTranslation(?Translation $value = null): self { $this->defaultTranslation = $value; + $this->_setField('defaultTranslation'); return $this; } @@ -159,6 +163,7 @@ public function getTranslations(): ?array public function setTranslations(?array $value = null): self { $this->translations = $value; + $this->_setField('translations'); return $this; } @@ -176,6 +181,7 @@ public function getConsentType(): ?string public function setConsentType(?string $value = null): self { $this->consentType = $value; + $this->_setField('consentType'); return $this; } @@ -193,6 +199,7 @@ public function getContentTypes(): ?array public function setContentTypes(?array $value = null): self { $this->contentTypes = $value; + $this->_setField('contentTypes'); return $this; } diff --git a/src/Unstable/Switch_/SwitchClient.php b/src/Unstable/Switch_/SwitchClient.php index f87cecda..ff1be71d 100644 --- a/src/Unstable/Switch_/SwitchClient.php +++ b/src/Unstable/Switch_/SwitchClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\Switch_; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\Types\PhoneSwitch; use Intercom\Exceptions\IntercomException; @@ -11,7 +11,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class SwitchClient @@ -56,6 +55,15 @@ public function __construct( * * If custom attributes are specified, they will be added to the user or lead's custom data attributes. * + * Example: + * ```php + * $client->unstable->switch->createPhoneSwitch( + * [ + * 'key' => "value", + * ], + * ); + * ``` + * * @param mixed $request * @param ?array{ * baseUrl?: string, @@ -92,16 +100,6 @@ public function createPhoneSwitch(mixed $request, ?array $options = null): ?Phon } } 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); } diff --git a/src/Unstable/Tags/Requests/AttachTagToContactRequest.php b/src/Unstable/Tags/Requests/AttachTagToContactRequest.php index ab56c1b5..4c393365 100644 --- a/src/Unstable/Tags/Requests/AttachTagToContactRequest.php +++ b/src/Unstable/Tags/Requests/AttachTagToContactRequest.php @@ -45,6 +45,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } @@ -62,6 +63,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Tags/Requests/AttachTagToConversationRequest.php b/src/Unstable/Tags/Requests/AttachTagToConversationRequest.php index aef6f82e..f14bafa5 100644 --- a/src/Unstable/Tags/Requests/AttachTagToConversationRequest.php +++ b/src/Unstable/Tags/Requests/AttachTagToConversationRequest.php @@ -53,6 +53,7 @@ public function getConversationId(): string public function setConversationId(string $value): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } @@ -70,6 +71,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -87,6 +89,7 @@ public function getAdminId(): string public function setAdminId(string $value): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } } diff --git a/src/Unstable/Tags/Requests/AttachTagToTicketRequest.php b/src/Unstable/Tags/Requests/AttachTagToTicketRequest.php index 6e852b6a..9459b6fc 100644 --- a/src/Unstable/Tags/Requests/AttachTagToTicketRequest.php +++ b/src/Unstable/Tags/Requests/AttachTagToTicketRequest.php @@ -53,6 +53,7 @@ public function getTicketId(): string public function setTicketId(string $value): self { $this->ticketId = $value; + $this->_setField('ticketId'); return $this; } @@ -70,6 +71,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -87,6 +89,7 @@ public function getAdminId(): string public function setAdminId(string $value): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } } diff --git a/src/Unstable/Tags/Requests/DeleteTagRequest.php b/src/Unstable/Tags/Requests/DeleteTagRequest.php index a80b46a1..112ffd8b 100644 --- a/src/Unstable/Tags/Requests/DeleteTagRequest.php +++ b/src/Unstable/Tags/Requests/DeleteTagRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Tags/Requests/DetachTagFromContactRequest.php b/src/Unstable/Tags/Requests/DetachTagFromContactRequest.php index a4ed44ee..811248d8 100644 --- a/src/Unstable/Tags/Requests/DetachTagFromContactRequest.php +++ b/src/Unstable/Tags/Requests/DetachTagFromContactRequest.php @@ -43,6 +43,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } @@ -60,6 +61,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Tags/Requests/DetachTagFromConversationRequest.php b/src/Unstable/Tags/Requests/DetachTagFromConversationRequest.php index e907cce6..fbd4e005 100644 --- a/src/Unstable/Tags/Requests/DetachTagFromConversationRequest.php +++ b/src/Unstable/Tags/Requests/DetachTagFromConversationRequest.php @@ -52,6 +52,7 @@ public function getConversationId(): string public function setConversationId(string $value): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } @@ -69,6 +70,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -86,6 +88,7 @@ public function getAdminId(): string public function setAdminId(string $value): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } } diff --git a/src/Unstable/Tags/Requests/DetachTagFromTicketRequest.php b/src/Unstable/Tags/Requests/DetachTagFromTicketRequest.php index bb5941d7..65e245b1 100644 --- a/src/Unstable/Tags/Requests/DetachTagFromTicketRequest.php +++ b/src/Unstable/Tags/Requests/DetachTagFromTicketRequest.php @@ -52,6 +52,7 @@ public function getTicketId(): string public function setTicketId(string $value): self { $this->ticketId = $value; + $this->_setField('ticketId'); return $this; } @@ -69,6 +70,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -86,6 +88,7 @@ public function getAdminId(): string public function setAdminId(string $value): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } } diff --git a/src/Unstable/Tags/Requests/FindTagRequest.php b/src/Unstable/Tags/Requests/FindTagRequest.php index b908c395..0924f6e9 100644 --- a/src/Unstable/Tags/Requests/FindTagRequest.php +++ b/src/Unstable/Tags/Requests/FindTagRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Tags/TagsClient.php b/src/Unstable/Tags/TagsClient.php index 5c7d36fc..0efdd888 100644 --- a/src/Unstable/Tags/TagsClient.php +++ b/src/Unstable/Tags/TagsClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\Tags; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\Tags\Requests\AttachTagToContactRequest; use Intercom\Unstable\Tags\Types\Tag; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\Tags\Requests\DetachTagFromContactRequest; use Intercom\Unstable\Tags\Requests\AttachTagToConversationRequest; @@ -68,6 +67,16 @@ public function __construct( /** * You can tag a specific contact. This will return a tag object for the tag that was added to the contact. * + * Example: + * ```php + * $client->tags->tagContact( + * new TagContactRequest([ + * 'contactId' => '63a07ddf05a32042dffac965', + * 'tagId' => '7522907', + * ]), + * ); + * ``` + * * @param AttachTagToContactRequest $request * @param ?array{ * baseUrl?: string, @@ -77,18 +86,18 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Tag + * @return ?Tag * @throws IntercomException * @throws IntercomApiException */ - public function attachTagToContact(AttachTagToContactRequest $request, ?array $options = null): Tag + public function attachTagToContact(AttachTagToContactRequest $request, ?array $options = null): ?Tag { $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()}/tags", + path: "contacts/" . RawClient::encodePathParam($request->getContactId()) . "/tags", method: HttpMethod::POST, body: $request, ), @@ -97,20 +106,13 @@ public function attachTagToContact(AttachTagToContactRequest $request, ?array $o $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Tag::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); } @@ -124,6 +126,16 @@ public function attachTagToContact(AttachTagToContactRequest $request, ?array $o /** * You can remove tag from a specific contact. This will return a tag object for the tag that was removed from the contact. * + * Example: + * ```php + * $client->unstable->tags->detachTagFromContact( + * new DetachTagFromContactRequest([ + * 'contactId' => '63a07ddf05a32042dffac965', + * 'id' => '7522907', + * ]), + * ); + * ``` + * * @param DetachTagFromContactRequest $request * @param ?array{ * baseUrl?: string, @@ -133,18 +145,18 @@ public function attachTagToContact(AttachTagToContactRequest $request, ?array $o * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Tag + * @return ?Tag * @throws IntercomException * @throws IntercomApiException */ - public function detachTagFromContact(DetachTagFromContactRequest $request, ?array $options = null): Tag + public function detachTagFromContact(DetachTagFromContactRequest $request, ?array $options = null): ?Tag { $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()}/tags/{$request->getId()}", + path: "contacts/" . RawClient::encodePathParam($request->getContactId()) . "/tags/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::DELETE, ), $options, @@ -152,20 +164,13 @@ public function detachTagFromContact(DetachTagFromContactRequest $request, ?arra $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Tag::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); } @@ -179,6 +184,17 @@ public function detachTagFromContact(DetachTagFromContactRequest $request, ?arra /** * You can tag a specific conversation. This will return a tag object for the tag that was added to the conversation. * + * Example: + * ```php + * $client->tags->tagConversation( + * new TagConversationRequest([ + * 'conversationId' => '64619700005694', + * 'tagId' => '7522907', + * 'adminId' => '780', + * ]), + * ); + * ``` + * * @param AttachTagToConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -188,18 +204,18 @@ public function detachTagFromContact(DetachTagFromContactRequest $request, ?arra * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Tag + * @return ?Tag * @throws IntercomException * @throws IntercomApiException */ - public function attachTagToConversation(AttachTagToConversationRequest $request, ?array $options = null): Tag + public function attachTagToConversation(AttachTagToConversationRequest $request, ?array $options = null): ?Tag { $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()}/tags", + path: "conversations/" . RawClient::encodePathParam($request->getConversationId()) . "/tags", method: HttpMethod::POST, body: $request, ), @@ -208,20 +224,13 @@ public function attachTagToConversation(AttachTagToConversationRequest $request, $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Tag::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); } @@ -235,6 +244,17 @@ public function attachTagToConversation(AttachTagToConversationRequest $request, /** * You can remove tag from a specific conversation. This will return a tag object for the tag that was removed from the conversation. * + * Example: + * ```php + * $client->unstable->tags->detachTagFromConversation( + * new DetachTagFromConversationRequest([ + * 'conversationId' => '64619700005694', + * 'id' => '7522907', + * 'adminId' => '123', + * ]), + * ); + * ``` + * * @param DetachTagFromConversationRequest $request * @param ?array{ * baseUrl?: string, @@ -244,18 +264,18 @@ public function attachTagToConversation(AttachTagToConversationRequest $request, * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Tag + * @return ?Tag * @throws IntercomException * @throws IntercomApiException */ - public function detachTagFromConversation(DetachTagFromConversationRequest $request, ?array $options = null): Tag + public function detachTagFromConversation(DetachTagFromConversationRequest $request, ?array $options = null): ?Tag { $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()}/tags/{$request->getId()}", + path: "conversations/" . RawClient::encodePathParam($request->getConversationId()) . "/tags/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::DELETE, body: $request, ), @@ -264,20 +284,13 @@ public function detachTagFromConversation(DetachTagFromConversationRequest $requ $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Tag::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); } @@ -292,6 +305,11 @@ public function detachTagFromConversation(DetachTagFromConversationRequest $requ * You can fetch a list of all tags for a given workspace. * * + * Example: + * ```php + * $client->tags->list(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -300,11 +318,11 @@ public function detachTagFromConversation(DetachTagFromConversationRequest $requ * queryParameters?: array, * bodyProperties?: array, * } $options - * @return TagList + * @return ?TagList * @throws IntercomException * @throws IntercomApiException */ - public function listTags(?array $options = null): TagList + public function listTags(?array $options = null): ?TagList { $options = array_merge($this->options, $options ?? []); try { @@ -319,20 +337,13 @@ public function listTags(?array $options = null): TagList $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return TagList::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); } @@ -358,6 +369,15 @@ public function listTags(?array $options = null): TagList * * Each operation will return a tag object. * + * Example: + * ```php + * $client->tags->create( + * new CreateOrUpdateTagRequest([ + * 'name' => 'test', + * ]), + * ); + * ``` + * * @param ( * CreateOrUpdateTagRequest * |TagCompanyRequest @@ -372,11 +392,11 @@ public function listTags(?array $options = null): TagList * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Tag + * @return ?Tag * @throws IntercomException * @throws IntercomApiException */ - public function createTag(CreateOrUpdateTagRequest|TagCompanyRequest|UntagCompanyRequest|TagMultipleUsersRequest $request, ?array $options = null): Tag + public function createTag(CreateOrUpdateTagRequest|TagCompanyRequest|UntagCompanyRequest|TagMultipleUsersRequest $request, ?array $options = null): ?Tag { $options = array_merge($this->options, $options ?? []); try { @@ -392,20 +412,13 @@ public function createTag(CreateOrUpdateTagRequest|TagCompanyRequest|UntagCompan $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Tag::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); } @@ -420,6 +433,15 @@ public function createTag(CreateOrUpdateTagRequest|TagCompanyRequest|UntagCompan * You can fetch the details of tags that are on the workspace by their id. * This will return a tag object. * + * Example: + * ```php + * $client->unstable->tags->findTag( + * new FindTagRequest([ + * 'id' => '123', + * ]), + * ); + * ``` + * * @param FindTagRequest $request * @param ?array{ * baseUrl?: string, @@ -429,18 +451,18 @@ public function createTag(CreateOrUpdateTagRequest|TagCompanyRequest|UntagCompan * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Tag + * @return ?Tag * @throws IntercomException * @throws IntercomApiException */ - public function findTag(FindTagRequest $request, ?array $options = null): Tag + public function findTag(FindTagRequest $request, ?array $options = null): ?Tag { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "tags/{$request->getId()}", + path: "tags/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::GET, ), $options, @@ -448,20 +470,13 @@ public function findTag(FindTagRequest $request, ?array $options = null): Tag $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Tag::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); } @@ -475,6 +490,15 @@ public function findTag(FindTagRequest $request, ?array $options = null): Tag /** * You can delete the details of tags that are on the workspace by passing in the id. * + * Example: + * ```php + * $client->unstable->tags->deleteTag( + * new DeleteTagRequest([ + * 'id' => '123', + * ]), + * ); + * ``` + * * @param DeleteTagRequest $request * @param ?array{ * baseUrl?: string, @@ -494,7 +518,7 @@ public function deleteTag(DeleteTagRequest $request, ?array $options = null): vo $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "tags/{$request->getId()}", + path: "tags/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::DELETE, ), $options, @@ -503,16 +527,6 @@ public function deleteTag(DeleteTagRequest $request, ?array $options = null): vo 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); } @@ -526,6 +540,17 @@ public function deleteTag(DeleteTagRequest $request, ?array $options = null): vo /** * You can tag a specific ticket. This will return a tag object for the tag that was added to the ticket. * + * Example: + * ```php + * $client->tags->tagTicket( + * new TagTicketRequest([ + * 'ticketId' => '64619700005694', + * 'tagId' => '7522907', + * 'adminId' => '780', + * ]), + * ); + * ``` + * * @param AttachTagToTicketRequest $request * @param ?array{ * baseUrl?: string, @@ -535,18 +560,18 @@ public function deleteTag(DeleteTagRequest $request, ?array $options = null): vo * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Tag + * @return ?Tag * @throws IntercomException * @throws IntercomApiException */ - public function attachTagToTicket(AttachTagToTicketRequest $request, ?array $options = null): Tag + public function attachTagToTicket(AttachTagToTicketRequest $request, ?array $options = null): ?Tag { $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()}/tags", + path: "tickets/" . RawClient::encodePathParam($request->getTicketId()) . "/tags", method: HttpMethod::POST, body: $request, ), @@ -555,20 +580,13 @@ public function attachTagToTicket(AttachTagToTicketRequest $request, ?array $opt $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Tag::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); } @@ -582,6 +600,17 @@ public function attachTagToTicket(AttachTagToTicketRequest $request, ?array $opt /** * You can remove tag from a specific ticket. This will return a tag object for the tag that was removed from the ticket. * + * Example: + * ```php + * $client->unstable->tags->detachTagFromTicket( + * new DetachTagFromTicketRequest([ + * 'ticketId' => '64619700005694', + * 'id' => '7522907', + * 'adminId' => '123', + * ]), + * ); + * ``` + * * @param DetachTagFromTicketRequest $request * @param ?array{ * baseUrl?: string, @@ -591,18 +620,18 @@ public function attachTagToTicket(AttachTagToTicketRequest $request, ?array $opt * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Tag + * @return ?Tag * @throws IntercomException * @throws IntercomApiException */ - public function detachTagFromTicket(DetachTagFromTicketRequest $request, ?array $options = null): Tag + public function detachTagFromTicket(DetachTagFromTicketRequest $request, ?array $options = null): ?Tag { $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()}/tags/{$request->getId()}", + path: "tickets/" . RawClient::encodePathParam($request->getTicketId()) . "/tags/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::DELETE, body: $request, ), @@ -611,20 +640,13 @@ public function detachTagFromTicket(DetachTagFromTicketRequest $request, ?array $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Tag::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); } diff --git a/src/Unstable/Tags/Types/Tag.php b/src/Unstable/Tags/Types/Tag.php index f1966fa3..c527eae1 100644 --- a/src/Unstable/Tags/Types/Tag.php +++ b/src/Unstable/Tags/Types/Tag.php @@ -74,6 +74,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -91,6 +92,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -108,6 +110,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -125,6 +128,7 @@ public function getAppliedAt(): ?int public function setAppliedAt(?int $value = null): self { $this->appliedAt = $value; + $this->_setField('appliedAt'); return $this; } @@ -142,6 +146,7 @@ public function getAppliedBy(): ?Reference public function setAppliedBy(?Reference $value = null): self { $this->appliedBy = $value; + $this->_setField('appliedBy'); return $this; } diff --git a/src/Unstable/Tags/Types/TagBasic.php b/src/Unstable/Tags/Types/TagBasic.php index 2f855a3f..fb6810ba 100644 --- a/src/Unstable/Tags/Types/TagBasic.php +++ b/src/Unstable/Tags/Types/TagBasic.php @@ -57,6 +57,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -74,6 +75,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -91,6 +93,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } diff --git a/src/Unstable/Teams/Requests/RetrieveTeamRequest.php b/src/Unstable/Teams/Requests/RetrieveTeamRequest.php index 9cb8b3bf..f0573c2b 100644 --- a/src/Unstable/Teams/Requests/RetrieveTeamRequest.php +++ b/src/Unstable/Teams/Requests/RetrieveTeamRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Teams/TeamsClient.php b/src/Unstable/Teams/TeamsClient.php index 74c6c02f..ce254a53 100644 --- a/src/Unstable/Teams/TeamsClient.php +++ b/src/Unstable/Teams/TeamsClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\Teams; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\Types\TeamList; use Intercom\Exceptions\IntercomException; @@ -11,7 +11,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\Teams\Requests\RetrieveTeamRequest; use Intercom\Unstable\Teams\Types\Team; @@ -55,6 +54,11 @@ public function __construct( /** * This will return a list of team objects for the App. * + * Example: + * ```php + * $client->teams->list(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -63,11 +67,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return TeamList + * @return ?TeamList * @throws IntercomException * @throws IntercomApiException */ - public function listTeams(?array $options = null): TeamList + public function listTeams(?array $options = null): ?TeamList { $options = array_merge($this->options, $options ?? []); try { @@ -82,20 +86,13 @@ public function listTeams(?array $options = null): TeamList $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return TeamList::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); } @@ -109,6 +106,15 @@ public function listTeams(?array $options = null): TeamList /** * You can fetch the details of a single team, containing an array of admins that belong to this team. * + * Example: + * ```php + * $client->unstable->teams->retrieveTeam( + * new RetrieveTeamRequest([ + * 'id' => '123', + * ]), + * ); + * ``` + * * @param RetrieveTeamRequest $request * @param ?array{ * baseUrl?: string, @@ -118,18 +124,18 @@ public function listTeams(?array $options = null): TeamList * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Team + * @return ?Team * @throws IntercomException * @throws IntercomApiException */ - public function retrieveTeam(RetrieveTeamRequest $request, ?array $options = null): Team + public function retrieveTeam(RetrieveTeamRequest $request, ?array $options = null): ?Team { $options = array_merge($this->options, $options ?? []); try { $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "teams/{$request->getId()}", + path: "teams/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::GET, ), $options, @@ -137,20 +143,13 @@ public function retrieveTeam(RetrieveTeamRequest $request, ?array $options = nul $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Team::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); } diff --git a/src/Unstable/Teams/Types/Team.php b/src/Unstable/Teams/Types/Team.php index e0f8a55d..f08b9b64 100644 --- a/src/Unstable/Teams/Types/Team.php +++ b/src/Unstable/Teams/Types/Team.php @@ -75,6 +75,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -92,6 +93,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -109,6 +111,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -126,6 +129,7 @@ public function getAdminIds(): ?array public function setAdminIds(?array $value = null): self { $this->adminIds = $value; + $this->_setField('adminIds'); return $this; } @@ -143,6 +147,7 @@ public function getAdminPriorityLevel(): ?AdminPriorityLevel public function setAdminPriorityLevel(?AdminPriorityLevel $value = null): self { $this->adminPriorityLevel = $value; + $this->_setField('adminPriorityLevel'); return $this; } diff --git a/src/Unstable/TicketStates/TicketStatesClient.php b/src/Unstable/TicketStates/TicketStatesClient.php index 209b6943..3fa70063 100644 --- a/src/Unstable/TicketStates/TicketStatesClient.php +++ b/src/Unstable/TicketStates/TicketStatesClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\TicketStates; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\Types\TicketStateList; use Intercom\Exceptions\IntercomException; @@ -11,7 +11,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class TicketStatesClient @@ -53,6 +52,11 @@ public function __construct( /** * You can get a list of all ticket states for a workspace. * + * Example: + * ```php + * $client->ticketStates->listTicketStates(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -61,11 +65,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return TicketStateList + * @return ?TicketStateList * @throws IntercomException * @throws IntercomApiException */ - public function listTicketStates(?array $options = null): TicketStateList + public function listTicketStates(?array $options = null): ?TicketStateList { $options = array_merge($this->options, $options ?? []); try { @@ -80,20 +84,13 @@ public function listTicketStates(?array $options = null): TicketStateList $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } diff --git a/src/Unstable/TicketTypeAttributes/Requests/CreateTicketTypeAttributeRequest.php b/src/Unstable/TicketTypeAttributes/Requests/CreateTicketTypeAttributeRequest.php index f4fc4958..121f1794 100644 --- a/src/Unstable/TicketTypeAttributes/Requests/CreateTicketTypeAttributeRequest.php +++ b/src/Unstable/TicketTypeAttributes/Requests/CreateTicketTypeAttributeRequest.php @@ -118,6 +118,7 @@ public function getTicketTypeId(): string public function setTicketTypeId(string $value): self { $this->ticketTypeId = $value; + $this->_setField('ticketTypeId'); return $this; } @@ -135,6 +136,7 @@ public function getName(): string public function setName(string $value): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -152,6 +154,7 @@ public function getDescription(): string public function setDescription(string $value): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -169,6 +172,7 @@ public function getDataType(): string public function setDataType(string $value): self { $this->dataType = $value; + $this->_setField('dataType'); return $this; } @@ -186,6 +190,7 @@ public function getRequiredToCreate(): ?bool public function setRequiredToCreate(?bool $value = null): self { $this->requiredToCreate = $value; + $this->_setField('requiredToCreate'); return $this; } @@ -203,6 +208,7 @@ public function getRequiredToCreateForContacts(): ?bool public function setRequiredToCreateForContacts(?bool $value = null): self { $this->requiredToCreateForContacts = $value; + $this->_setField('requiredToCreateForContacts'); return $this; } @@ -220,6 +226,7 @@ public function getVisibleOnCreate(): ?bool public function setVisibleOnCreate(?bool $value = null): self { $this->visibleOnCreate = $value; + $this->_setField('visibleOnCreate'); return $this; } @@ -237,6 +244,7 @@ public function getVisibleToContacts(): ?bool public function setVisibleToContacts(?bool $value = null): self { $this->visibleToContacts = $value; + $this->_setField('visibleToContacts'); return $this; } @@ -254,6 +262,7 @@ public function getMultiline(): ?bool public function setMultiline(?bool $value = null): self { $this->multiline = $value; + $this->_setField('multiline'); return $this; } @@ -271,6 +280,7 @@ public function getListItems(): ?string public function setListItems(?string $value = null): self { $this->listItems = $value; + $this->_setField('listItems'); return $this; } @@ -288,6 +298,7 @@ public function getAllowMultipleValues(): ?bool public function setAllowMultipleValues(?bool $value = null): self { $this->allowMultipleValues = $value; + $this->_setField('allowMultipleValues'); return $this; } } diff --git a/src/Unstable/TicketTypeAttributes/Requests/UpdateTicketTypeAttributeRequest.php b/src/Unstable/TicketTypeAttributes/Requests/UpdateTicketTypeAttributeRequest.php index 1e10c7d1..91c9f8a0 100644 --- a/src/Unstable/TicketTypeAttributes/Requests/UpdateTicketTypeAttributeRequest.php +++ b/src/Unstable/TicketTypeAttributes/Requests/UpdateTicketTypeAttributeRequest.php @@ -124,6 +124,7 @@ public function getTicketTypeId(): string public function setTicketTypeId(string $value): self { $this->ticketTypeId = $value; + $this->_setField('ticketTypeId'); return $this; } @@ -141,6 +142,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -158,6 +160,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -175,6 +178,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -192,6 +196,7 @@ public function getRequiredToCreate(): ?bool public function setRequiredToCreate(?bool $value = null): self { $this->requiredToCreate = $value; + $this->_setField('requiredToCreate'); return $this; } @@ -209,6 +214,7 @@ public function getRequiredToCreateForContacts(): ?bool public function setRequiredToCreateForContacts(?bool $value = null): self { $this->requiredToCreateForContacts = $value; + $this->_setField('requiredToCreateForContacts'); return $this; } @@ -226,6 +232,7 @@ public function getVisibleOnCreate(): ?bool public function setVisibleOnCreate(?bool $value = null): self { $this->visibleOnCreate = $value; + $this->_setField('visibleOnCreate'); return $this; } @@ -243,6 +250,7 @@ public function getVisibleToContacts(): ?bool public function setVisibleToContacts(?bool $value = null): self { $this->visibleToContacts = $value; + $this->_setField('visibleToContacts'); return $this; } @@ -260,6 +268,7 @@ public function getMultiline(): ?bool public function setMultiline(?bool $value = null): self { $this->multiline = $value; + $this->_setField('multiline'); return $this; } @@ -277,6 +286,7 @@ public function getListItems(): ?string public function setListItems(?string $value = null): self { $this->listItems = $value; + $this->_setField('listItems'); return $this; } @@ -294,6 +304,7 @@ public function getAllowMultipleValues(): ?bool public function setAllowMultipleValues(?bool $value = null): self { $this->allowMultipleValues = $value; + $this->_setField('allowMultipleValues'); return $this; } @@ -311,6 +322,7 @@ public function getArchived(): ?bool public function setArchived(?bool $value = null): self { $this->archived = $value; + $this->_setField('archived'); return $this; } } diff --git a/src/Unstable/TicketTypeAttributes/TicketTypeAttributesClient.php b/src/Unstable/TicketTypeAttributes/TicketTypeAttributesClient.php index a5e63146..ac691b0b 100644 --- a/src/Unstable/TicketTypeAttributes/TicketTypeAttributesClient.php +++ b/src/Unstable/TicketTypeAttributes/TicketTypeAttributesClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\TicketTypeAttributes; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\TicketTypeAttributes\Requests\CreateTicketTypeAttributeRequest; use Intercom\Unstable\Types\TicketTypeAttribute; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\TicketTypeAttributes\Requests\UpdateTicketTypeAttributeRequest; @@ -55,6 +54,19 @@ public function __construct( /** * You can create a new attribute for a ticket type. * + * Example: + * ```php + * $client->ticketTypes->attributes->create( + * new CreateTicketTypeAttributeRequest([ + * 'ticketTypeId' => 'ticket_type_id', + * 'name' => 'Attribute Title', + * 'description' => 'Attribute Description', + * 'dataType' => CreateTicketTypeAttributeRequestDataType::String->value, + * 'requiredToCreate' => false, + * ]), + * ); + * ``` + * * @param CreateTicketTypeAttributeRequest $request * @param ?array{ * baseUrl?: string, @@ -75,7 +87,7 @@ public function createTicketTypeAttribute(CreateTicketTypeAttributeRequest $requ $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "ticket_types/{$request->getTicketTypeId()}/attributes", + path: "ticket_types/" . RawClient::encodePathParam($request->getTicketTypeId()) . "/attributes", method: HttpMethod::POST, body: $request, ), @@ -91,16 +103,6 @@ public function createTicketTypeAttribute(CreateTicketTypeAttributeRequest $requ } } 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); } @@ -114,6 +116,17 @@ public function createTicketTypeAttribute(CreateTicketTypeAttributeRequest $requ /** * You can update an existing attribute for a ticket type. * + * Example: + * ```php + * $client->unstable->ticketTypeAttributes->updateTicketTypeAttribute( + * new UpdateTicketTypeAttributeRequest([ + * 'ticketTypeId' => 'ticket_type_id', + * 'id' => 'id', + * 'description' => 'New Attribute Description', + * ]), + * ); + * ``` + * * @param UpdateTicketTypeAttributeRequest $request * @param ?array{ * baseUrl?: string, @@ -134,7 +147,7 @@ public function updateTicketTypeAttribute(UpdateTicketTypeAttributeRequest $requ $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "ticket_types/{$request->getTicketTypeId()}/attributes/{$request->getId()}", + path: "ticket_types/" . RawClient::encodePathParam($request->getTicketTypeId()) . "/attributes/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::PUT, body: $request, ), @@ -150,16 +163,6 @@ public function updateTicketTypeAttribute(UpdateTicketTypeAttributeRequest $requ } } 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); } diff --git a/src/Unstable/TicketTypes/Requests/GetTicketTypeRequest.php b/src/Unstable/TicketTypes/Requests/GetTicketTypeRequest.php index 681e2f7f..c05c0a2d 100644 --- a/src/Unstable/TicketTypes/Requests/GetTicketTypeRequest.php +++ b/src/Unstable/TicketTypes/Requests/GetTicketTypeRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/TicketTypes/TicketTypesClient.php b/src/Unstable/TicketTypes/TicketTypesClient.php index 1f5e7a64..8cbea7b3 100644 --- a/src/Unstable/TicketTypes/TicketTypesClient.php +++ b/src/Unstable/TicketTypes/TicketTypesClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\TicketTypes; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\Types\TicketTypeList; use Intercom\Exceptions\IntercomException; @@ -11,7 +11,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\Tickets\Types\TicketType; use Intercom\Unstable\TicketTypes\Requests\GetTicketTypeRequest; @@ -55,6 +54,11 @@ public function __construct( /** * You can get a list of all ticket types for a workspace. * + * Example: + * ```php + * $client->ticketTypes->list(); + * ``` + * * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -63,11 +67,11 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return TicketTypeList + * @return ?TicketTypeList * @throws IntercomException * @throws IntercomApiException */ - public function listTicketTypes(?array $options = null): TicketTypeList + public function listTicketTypes(?array $options = null): ?TicketTypeList { $options = array_merge($this->options, $options ?? []); try { @@ -82,20 +86,13 @@ public function listTicketTypes(?array $options = null): TicketTypeList $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return TicketTypeList::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); } @@ -113,6 +110,15 @@ public function listTicketTypes(?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/) * + * Example: + * ```php + * $client->unstable->ticketTypes->createTicketType( + * [ + * 'key' => "value", + * ], + * ); + * ``` + * * @param mixed $request * @param ?array{ * baseUrl?: string, @@ -149,16 +155,6 @@ public function createTicketType(mixed $request, ?array $options = null): ?Ticke } } 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); } @@ -172,6 +168,15 @@ public function createTicketType(mixed $request, ?array $options = null): ?Ticke /** * You can fetch the details of a single ticket type. * + * Example: + * ```php + * $client->unstable->ticketTypes->getTicketType( + * new GetTicketTypeRequest([ + * 'id' => 'id', + * ]), + * ); + * ``` + * * @param GetTicketTypeRequest $request * @param ?array{ * baseUrl?: string, @@ -192,7 +197,7 @@ public function getTicketType(GetTicketTypeRequest $request, ?array $options = n $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "ticket_types/{$request->getId()}", + path: "ticket_types/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::GET, ), $options, @@ -207,16 +212,6 @@ public function getTicketType(GetTicketTypeRequest $request, ?array $options = n } } 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); } diff --git a/src/Unstable/Tickets/Requests/DeleteTicketRequest.php b/src/Unstable/Tickets/Requests/DeleteTicketRequest.php index 3f56f5f9..3d4f8285 100644 --- a/src/Unstable/Tickets/Requests/DeleteTicketRequest.php +++ b/src/Unstable/Tickets/Requests/DeleteTicketRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Tickets/Requests/EnqueueCreateTicketRequest.php b/src/Unstable/Tickets/Requests/EnqueueCreateTicketRequest.php index b78bb51e..b0ed8d96 100644 --- a/src/Unstable/Tickets/Requests/EnqueueCreateTicketRequest.php +++ b/src/Unstable/Tickets/Requests/EnqueueCreateTicketRequest.php @@ -5,10 +5,10 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Unstable\Traits\CreateTicketRequestBody; use Intercom\Core\Json\JsonProperty; -use Intercom\Unstable\Types\CreateTicketRequestContactsItemId; -use Intercom\Unstable\Types\CreateTicketRequestContactsItemExternalId; -use Intercom\Unstable\Types\CreateTicketRequestContactsItemEmail; -use Intercom\Unstable\Types\CreateTicketRequestAssignment; +use Intercom\Unstable\Types\CreateTicketRequestBodyContactsItemId; +use Intercom\Unstable\Types\CreateTicketRequestBodyContactsItemExternalId; +use Intercom\Unstable\Types\CreateTicketRequestBodyContactsItemEmail; +use Intercom\Unstable\Types\CreateTicketRequestBodyAssignment; class EnqueueCreateTicketRequest extends JsonSerializableType { @@ -24,15 +24,15 @@ class EnqueueCreateTicketRequest extends JsonSerializableType * @param array{ * ticketTypeId: string, * contacts: array<( - * CreateTicketRequestContactsItemId - * |CreateTicketRequestContactsItemExternalId - * |CreateTicketRequestContactsItemEmail + * CreateTicketRequestBodyContactsItemId + * |CreateTicketRequestBodyContactsItemExternalId + * |CreateTicketRequestBodyContactsItemEmail * )>, * skipNotifications?: ?bool, * conversationToLinkId?: ?string, * companyId?: ?string, * createdAt?: ?int, - * assignment?: ?CreateTicketRequestAssignment, + * assignment?: ?CreateTicketRequestBodyAssignment, * } $values */ public function __construct( @@ -61,6 +61,7 @@ public function getSkipNotifications(): ?bool public function setSkipNotifications(?bool $value = null): self { $this->skipNotifications = $value; + $this->_setField('skipNotifications'); return $this; } } diff --git a/src/Unstable/Tickets/Requests/GetTicketRequest.php b/src/Unstable/Tickets/Requests/GetTicketRequest.php index 6fc5bf96..bbf808d5 100644 --- a/src/Unstable/Tickets/Requests/GetTicketRequest.php +++ b/src/Unstable/Tickets/Requests/GetTicketRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Tickets/Requests/ReplyTicketRequest.php b/src/Unstable/Tickets/Requests/ReplyTicketRequest.php index 4bb9a483..bdd963be 100644 --- a/src/Unstable/Tickets/Requests/ReplyTicketRequest.php +++ b/src/Unstable/Tickets/Requests/ReplyTicketRequest.php @@ -11,7 +11,7 @@ class ReplyTicketRequest extends JsonSerializableType { /** - * @var string $id + * @var string $id The id of the ticket to target. */ private string $id; @@ -57,6 +57,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -84,6 +85,7 @@ public function getBody(): ContactReplyTicketIntercomUserIdRequest|ContactReplyT public function setBody(ContactReplyTicketIntercomUserIdRequest|ContactReplyTicketUserIdRequest|ContactReplyTicketEmailRequest|AdminReplyTicketRequest $value): self { $this->body = $value; + $this->_setField('body'); return $this; } } diff --git a/src/Unstable/Tickets/Requests/UpdateTicketRequest.php b/src/Unstable/Tickets/Requests/UpdateTicketRequest.php index 6c0f5eda..71788de6 100644 --- a/src/Unstable/Tickets/Requests/UpdateTicketRequest.php +++ b/src/Unstable/Tickets/Requests/UpdateTicketRequest.php @@ -102,6 +102,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -119,6 +120,7 @@ public function getTicketAttributes(): ?array public function setTicketAttributes(?array $value = null): self { $this->ticketAttributes = $value; + $this->_setField('ticketAttributes'); return $this; } @@ -136,6 +138,7 @@ public function getTicketStateId(): ?string public function setTicketStateId(?string $value = null): self { $this->ticketStateId = $value; + $this->_setField('ticketStateId'); return $this; } @@ -153,6 +156,7 @@ public function getCompanyId(): ?string public function setCompanyId(?string $value = null): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } @@ -170,6 +174,7 @@ public function getOpen(): ?bool public function setOpen(?bool $value = null): self { $this->open = $value; + $this->_setField('open'); return $this; } @@ -187,6 +192,7 @@ public function getIsShared(): ?bool public function setIsShared(?bool $value = null): self { $this->isShared = $value; + $this->_setField('isShared'); return $this; } @@ -204,6 +210,7 @@ public function getSnoozedUntil(): ?int public function setSnoozedUntil(?int $value = null): self { $this->snoozedUntil = $value; + $this->_setField('snoozedUntil'); return $this; } @@ -221,6 +228,7 @@ public function getAdminId(): ?int public function setAdminId(?int $value = null): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } @@ -238,6 +246,7 @@ public function getAssigneeId(): ?string public function setAssigneeId(?string $value = null): self { $this->assigneeId = $value; + $this->_setField('assigneeId'); return $this; } } diff --git a/src/Unstable/Tickets/TicketsClient.php b/src/Unstable/Tickets/TicketsClient.php index 78542127..6f41b1f7 100644 --- a/src/Unstable/Tickets/TicketsClient.php +++ b/src/Unstable/Tickets/TicketsClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\Tickets; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\Tickets\Requests\ReplyTicketRequest; use Intercom\Unstable\Types\TicketReply; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\Tickets\Requests\EnqueueCreateTicketRequest; use Intercom\Unstable\Jobs\Types\Jobs; @@ -63,6 +62,21 @@ public function __construct( /** * You can reply to a ticket with a message from an admin or on behalf of a contact, or with a note for admins. * + * Example: + * ```php + * $client->unstable->tickets->replyTicket( + * new ReplyTicketRequest([ + * 'id' => '123', + * 'body' => new ContactReplyTicketIntercomUserIdRequest([ + * 'messageType' => 'comment', + * 'type' => 'user', + * 'body' => 'Thanks again :)', + * 'intercomUserId' => '6762f2971bb69f9f2193bc49', + * ]), + * ]), + * ); + * ``` + * * @param ReplyTicketRequest $request * @param ?array{ * baseUrl?: string, @@ -72,18 +86,18 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return TicketReply + * @return ?TicketReply * @throws IntercomException * @throws IntercomApiException */ - public function replyTicket(ReplyTicketRequest $request, ?array $options = null): TicketReply + public function replyTicket(ReplyTicketRequest $request, ?array $options = null): ?TicketReply { $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->getId()}/reply", + path: "tickets/" . RawClient::encodePathParam($request->getId()) . "/reply", method: HttpMethod::POST, body: $request->getBody(), ), @@ -92,20 +106,13 @@ public function replyTicket(ReplyTicketRequest $request, ?array $options = null) $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return TicketReply::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); } @@ -119,6 +126,20 @@ public function replyTicket(ReplyTicketRequest $request, ?array $options = null) /** * 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. * + * Example: + * ```php + * $client->tickets->enqueueCreateTicket( + * new EnqueueCreateTicketRequest([ + * 'ticketTypeId' => '1234', + * 'contacts' => [ + * new CreateTicketRequestBodyContactsItemId([ + * 'id' => '6762f2d81bb69f9f2193bc54', + * ]), + * ], + * ]), + * ); + * ``` + * * @param EnqueueCreateTicketRequest $request * @param ?array{ * baseUrl?: string, @@ -128,11 +149,11 @@ public function replyTicket(ReplyTicketRequest $request, ?array $options = null) * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Jobs + * @return ?Jobs * @throws IntercomException * @throws IntercomApiException */ - public function enqueueCreateTicket(EnqueueCreateTicketRequest $request, ?array $options = null): Jobs + public function enqueueCreateTicket(EnqueueCreateTicketRequest $request, ?array $options = null): ?Jobs { $options = array_merge($this->options, $options ?? []); try { @@ -148,20 +169,13 @@ public function enqueueCreateTicket(EnqueueCreateTicketRequest $request, ?array $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -175,6 +189,15 @@ public function enqueueCreateTicket(EnqueueCreateTicketRequest $request, ?array /** * You can fetch the details of a single ticket. * + * Example: + * ```php + * $client->unstable->tickets->getTicket( + * new GetTicketRequest([ + * 'id' => 'id', + * ]), + * ); + * ``` + * * @param GetTicketRequest $request * @param ?array{ * baseUrl?: string, @@ -195,7 +218,7 @@ public function getTicket(GetTicketRequest $request, ?array $options = null): ?T $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "tickets/{$request->getId()}", + path: "tickets/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::GET, ), $options, @@ -210,16 +233,6 @@ public function getTicket(GetTicketRequest $request, ?array $options = null): ?T } } 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); } @@ -233,6 +246,24 @@ public function getTicket(GetTicketRequest $request, ?array $options = null): ?T /** * You can update a ticket. * + * Example: + * ```php + * $client->unstable->tickets->updateTicket( + * new UpdateTicketRequest([ + * 'id' => 'id', + * 'ticketAttributes' => [ + * '_default_title_' => "example", + * '_default_description_' => "there is a problem", + * ], + * 'ticketStateId' => '123', + * 'open' => true, + * 'snoozedUntil' => 1673609604, + * 'adminId' => 991268011, + * 'assigneeId' => '123', + * ]), + * ); + * ``` + * * @param UpdateTicketRequest $request * @param ?array{ * baseUrl?: string, @@ -253,7 +284,7 @@ public function updateTicket(UpdateTicketRequest $request, ?array $options = nul $response = $this->client->sendRequest( new JsonApiRequest( baseUrl: $options['baseUrl'] ?? $this->client->options['baseUrl'] ?? Environments::UsProduction->value, - path: "tickets/{$request->getId()}", + path: "tickets/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::PUT, body: $request, ), @@ -269,16 +300,6 @@ public function updateTicket(UpdateTicketRequest $request, ?array $options = nul } } 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); } @@ -292,6 +313,15 @@ public function updateTicket(UpdateTicketRequest $request, ?array $options = nul /** * You can delete a ticket using the Intercom provided ID. * + * Example: + * ```php + * $client->unstable->tickets->deleteTicket( + * new DeleteTicketRequest([ + * 'id' => 'id', + * ]), + * ); + * ``` + * * @param DeleteTicketRequest $request * @param ?array{ * baseUrl?: string, @@ -301,18 +331,18 @@ public function updateTicket(UpdateTicketRequest $request, ?array $options = nul * queryParameters?: array, * bodyProperties?: array, * } $options - * @return DeleteTicketResponse + * @return ?DeleteTicketResponse * @throws IntercomException * @throws IntercomApiException */ - public function deleteTicket(DeleteTicketRequest $request, ?array $options = null): DeleteTicketResponse + 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->getId()}", + path: "tickets/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::DELETE, ), $options, @@ -320,20 +350,13 @@ public function deleteTicket(DeleteTicketRequest $request, ?array $options = nul $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } 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); } @@ -415,6 +438,20 @@ public function deleteTicket(DeleteTicketRequest $request, ?array $options = nul * | ^ | String | Starts With | * | $ | String | Ends With | * + * Example: + * ```php + * $client->unstable->tickets->searchTickets( + * new SearchRequest([ + * 'query' => new SingleFilterSearchRequest([ + * 'value' => [], + * ]), + * 'pagination' => new StartingAfterPaging([ + * 'perPage' => 5, + * ]), + * ]), + * ); + * ``` + * * @param SearchRequest $request * @param ?array{ * baseUrl?: string, @@ -424,11 +461,11 @@ public function deleteTicket(DeleteTicketRequest $request, ?array $options = nul * queryParameters?: array, * bodyProperties?: array, * } $options - * @return TicketList + * @return ?TicketList * @throws IntercomException * @throws IntercomApiException */ - public function searchTickets(SearchRequest $request, ?array $options = null): TicketList + public function searchTickets(SearchRequest $request, ?array $options = null): ?TicketList { $options = array_merge($this->options, $options ?? []); try { @@ -444,20 +481,13 @@ public function searchTickets(SearchRequest $request, ?array $options = null): T $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return TicketList::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); } diff --git a/src/Unstable/Tickets/Types/DeleteTicketResponse.php b/src/Unstable/Tickets/Types/DeleteTicketResponse.php index 7ed8896a..df4e472b 100644 --- a/src/Unstable/Tickets/Types/DeleteTicketResponse.php +++ b/src/Unstable/Tickets/Types/DeleteTicketResponse.php @@ -57,6 +57,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -74,6 +75,7 @@ public function getObject(): ?string public function setObject(?string $value = null): self { $this->object = $value; + $this->_setField('object'); return $this; } @@ -91,6 +93,7 @@ public function getDeleted(): ?bool public function setDeleted(?bool $value = null): self { $this->deleted = $value; + $this->_setField('deleted'); return $this; } diff --git a/src/Unstable/Tickets/Types/Ticket.php b/src/Unstable/Tickets/Types/Ticket.php index aadce148..6bb9d5b9 100644 --- a/src/Unstable/Tickets/Types/Ticket.php +++ b/src/Unstable/Tickets/Types/Ticket.php @@ -188,6 +188,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -205,6 +206,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -222,6 +224,7 @@ public function getTicketId(): ?string public function setTicketId(?string $value = null): self { $this->ticketId = $value; + $this->_setField('ticketId'); return $this; } @@ -239,6 +242,7 @@ public function getCategory(): ?string public function setCategory(?string $value = null): self { $this->category = $value; + $this->_setField('category'); return $this; } @@ -270,6 +274,7 @@ public function getTicketAttributes(): ?array public function setTicketAttributes(?array $value = null): self { $this->ticketAttributes = $value; + $this->_setField('ticketAttributes'); return $this; } @@ -287,6 +292,7 @@ public function getTicketState(): ?TicketState public function setTicketState(?TicketState $value = null): self { $this->ticketState = $value; + $this->_setField('ticketState'); return $this; } @@ -304,6 +310,7 @@ public function getTicketType(): ?TicketType public function setTicketType(?TicketType $value = null): self { $this->ticketType = $value; + $this->_setField('ticketType'); return $this; } @@ -321,6 +328,7 @@ public function getContacts(): ?TicketContacts public function setContacts(?TicketContacts $value = null): self { $this->contacts = $value; + $this->_setField('contacts'); return $this; } @@ -338,6 +346,7 @@ public function getAdminAssigneeId(): ?string public function setAdminAssigneeId(?string $value = null): self { $this->adminAssigneeId = $value; + $this->_setField('adminAssigneeId'); return $this; } @@ -355,6 +364,7 @@ public function getTeamAssigneeId(): ?string public function setTeamAssigneeId(?string $value = null): self { $this->teamAssigneeId = $value; + $this->_setField('teamAssigneeId'); return $this; } @@ -372,6 +382,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -389,6 +400,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -406,6 +418,7 @@ public function getOpen(): ?bool public function setOpen(?bool $value = null): self { $this->open = $value; + $this->_setField('open'); return $this; } @@ -423,6 +436,7 @@ public function getSnoozedUntil(): ?int public function setSnoozedUntil(?int $value = null): self { $this->snoozedUntil = $value; + $this->_setField('snoozedUntil'); return $this; } @@ -440,6 +454,7 @@ public function getLinkedObjects(): ?LinkedObjectList public function setLinkedObjects(?LinkedObjectList $value = null): self { $this->linkedObjects = $value; + $this->_setField('linkedObjects'); return $this; } @@ -457,6 +472,7 @@ public function getTicketParts(): ?TicketParts public function setTicketParts(?TicketParts $value = null): self { $this->ticketParts = $value; + $this->_setField('ticketParts'); return $this; } @@ -474,6 +490,7 @@ public function getIsShared(): ?bool public function setIsShared(?bool $value = null): self { $this->isShared = $value; + $this->_setField('isShared'); return $this; } diff --git a/src/Unstable/Tickets/Types/TicketContacts.php b/src/Unstable/Tickets/Types/TicketContacts.php index 19bb7787..43732db1 100644 --- a/src/Unstable/Tickets/Types/TicketContacts.php +++ b/src/Unstable/Tickets/Types/TicketContacts.php @@ -51,6 +51,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -68,6 +69,7 @@ public function getContacts(): ?array public function setContacts(?array $value = null): self { $this->contacts = $value; + $this->_setField('contacts'); return $this; } diff --git a/src/Unstable/Tickets/Types/TicketPart.php b/src/Unstable/Tickets/Types/TicketPart.php index 0f1c798d..2ffef5c7 100644 --- a/src/Unstable/Tickets/Types/TicketPart.php +++ b/src/Unstable/Tickets/Types/TicketPart.php @@ -157,6 +157,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -174,6 +175,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -191,6 +193,7 @@ public function getPartType(): ?string public function setPartType(?string $value = null): self { $this->partType = $value; + $this->_setField('partType'); return $this; } @@ -208,6 +211,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -225,6 +229,7 @@ public function getPreviousTicketState(): ?string public function setPreviousTicketState(?string $value = null): self { $this->previousTicketState = $value; + $this->_setField('previousTicketState'); return $this; } @@ -242,6 +247,7 @@ public function getTicketState(): ?string public function setTicketState(?string $value = null): self { $this->ticketState = $value; + $this->_setField('ticketState'); return $this; } @@ -259,6 +265,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -276,6 +283,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -293,6 +301,7 @@ public function getAssignedTo(): ?Reference public function setAssignedTo(?Reference $value = null): self { $this->assignedTo = $value; + $this->_setField('assignedTo'); return $this; } @@ -310,6 +319,7 @@ public function getAuthor(): ?TicketPartAuthor public function setAuthor(?TicketPartAuthor $value = null): self { $this->author = $value; + $this->_setField('author'); return $this; } @@ -327,6 +337,7 @@ public function getAttachments(): ?array public function setAttachments(?array $value = null): self { $this->attachments = $value; + $this->_setField('attachments'); return $this; } @@ -344,6 +355,7 @@ public function getExternalId(): ?string public function setExternalId(?string $value = null): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } @@ -361,6 +373,7 @@ public function getRedacted(): ?bool public function setRedacted(?bool $value = null): self { $this->redacted = $value; + $this->_setField('redacted'); return $this; } @@ -378,6 +391,7 @@ public function getAppPackageCode(): ?string public function setAppPackageCode(?string $value = null): self { $this->appPackageCode = $value; + $this->_setField('appPackageCode'); return $this; } @@ -395,6 +409,7 @@ public function getUpdatedAttributeData(): ?TicketPartUpdatedAttributeData public function setUpdatedAttributeData(?TicketPartUpdatedAttributeData $value = null): self { $this->updatedAttributeData = $value; + $this->_setField('updatedAttributeData'); return $this; } diff --git a/src/Unstable/Tickets/Types/TicketPartUpdatedAttributeData.php b/src/Unstable/Tickets/Types/TicketPartUpdatedAttributeData.php index 4f208cb4..29bd87d2 100644 --- a/src/Unstable/Tickets/Types/TicketPartUpdatedAttributeData.php +++ b/src/Unstable/Tickets/Types/TicketPartUpdatedAttributeData.php @@ -49,6 +49,7 @@ public function getAttribute(): TicketPartUpdatedAttributeDataAttribute public function setAttribute(TicketPartUpdatedAttributeDataAttribute $value): self { $this->attribute = $value; + $this->_setField('attribute'); return $this; } @@ -66,6 +67,7 @@ public function getValue(): TicketPartUpdatedAttributeDataValue public function setValue(TicketPartUpdatedAttributeDataValue $value): self { $this->value = $value; + $this->_setField('value'); return $this; } diff --git a/src/Unstable/Tickets/Types/TicketPartUpdatedAttributeDataAttribute.php b/src/Unstable/Tickets/Types/TicketPartUpdatedAttributeDataAttribute.php index 07cad123..216997ae 100644 --- a/src/Unstable/Tickets/Types/TicketPartUpdatedAttributeDataAttribute.php +++ b/src/Unstable/Tickets/Types/TicketPartUpdatedAttributeDataAttribute.php @@ -57,6 +57,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -74,6 +75,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -91,6 +93,7 @@ public function getLabel(): string public function setLabel(string $value): self { $this->label = $value; + $this->_setField('label'); return $this; } diff --git a/src/Unstable/Tickets/Types/TicketPartUpdatedAttributeDataValue.php b/src/Unstable/Tickets/Types/TicketPartUpdatedAttributeDataValue.php index 8d7b3fde..bbef42d0 100644 --- a/src/Unstable/Tickets/Types/TicketPartUpdatedAttributeDataValue.php +++ b/src/Unstable/Tickets/Types/TicketPartUpdatedAttributeDataValue.php @@ -72,6 +72,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -97,6 +98,7 @@ public function getId(): string|array|null public function setId(string|array|null $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -120,6 +122,7 @@ public function getLabel(): string|array public function setLabel(string|array $value): self { $this->label = $value; + $this->_setField('label'); return $this; } diff --git a/src/Unstable/Tickets/Types/TicketState.php b/src/Unstable/Tickets/Types/TicketState.php index 9721e933..7b675c9a 100644 --- a/src/Unstable/Tickets/Types/TicketState.php +++ b/src/Unstable/Tickets/Types/TicketState.php @@ -73,6 +73,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -90,6 +91,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -107,6 +109,7 @@ public function getCategory(): ?string public function setCategory(?string $value = null): self { $this->category = $value; + $this->_setField('category'); return $this; } @@ -124,6 +127,7 @@ public function getInternalLabel(): ?string public function setInternalLabel(?string $value = null): self { $this->internalLabel = $value; + $this->_setField('internalLabel'); return $this; } @@ -141,6 +145,7 @@ public function getExternalLabel(): ?string public function setExternalLabel(?string $value = null): self { $this->externalLabel = $value; + $this->_setField('externalLabel'); return $this; } diff --git a/src/Unstable/Tickets/Types/TicketStateDetailed.php b/src/Unstable/Tickets/Types/TicketStateDetailed.php index d7bad132..964c1d01 100644 --- a/src/Unstable/Tickets/Types/TicketStateDetailed.php +++ b/src/Unstable/Tickets/Types/TicketStateDetailed.php @@ -89,6 +89,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -106,6 +107,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -123,6 +125,7 @@ public function getCategory(): ?string public function setCategory(?string $value = null): self { $this->category = $value; + $this->_setField('category'); return $this; } @@ -140,6 +143,7 @@ public function getInternalLabel(): ?string public function setInternalLabel(?string $value = null): self { $this->internalLabel = $value; + $this->_setField('internalLabel'); return $this; } @@ -157,6 +161,7 @@ public function getExternalLabel(): ?string public function setExternalLabel(?string $value = null): self { $this->externalLabel = $value; + $this->_setField('externalLabel'); return $this; } @@ -174,6 +179,7 @@ public function getArchived(): ?bool public function setArchived(?bool $value = null): self { $this->archived = $value; + $this->_setField('archived'); return $this; } @@ -191,6 +197,7 @@ public function getTicketTypes(): ?TicketStateDetailedTicketTypes public function setTicketTypes(?TicketStateDetailedTicketTypes $value = null): self { $this->ticketTypes = $value; + $this->_setField('ticketTypes'); return $this; } diff --git a/src/Unstable/Tickets/Types/TicketStateDetailedTicketTypes.php b/src/Unstable/Tickets/Types/TicketStateDetailedTicketTypes.php index 8b332cf2..ef9dee99 100644 --- a/src/Unstable/Tickets/Types/TicketStateDetailedTicketTypes.php +++ b/src/Unstable/Tickets/Types/TicketStateDetailedTicketTypes.php @@ -51,6 +51,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -68,6 +69,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Unstable/Tickets/Types/TicketType.php b/src/Unstable/Tickets/Types/TicketType.php index 1a3b00da..16320f30 100644 --- a/src/Unstable/Tickets/Types/TicketType.php +++ b/src/Unstable/Tickets/Types/TicketType.php @@ -130,6 +130,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -147,6 +148,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -164,6 +166,7 @@ public function getCategory(): ?string public function setCategory(?string $value = null): self { $this->category = $value; + $this->_setField('category'); return $this; } @@ -181,6 +184,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -198,6 +202,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -215,6 +220,7 @@ public function getIcon(): ?string public function setIcon(?string $value = null): self { $this->icon = $value; + $this->_setField('icon'); return $this; } @@ -232,6 +238,7 @@ public function getWorkspaceId(): ?string public function setWorkspaceId(?string $value = null): self { $this->workspaceId = $value; + $this->_setField('workspaceId'); return $this; } @@ -249,6 +256,7 @@ public function getTicketTypeAttributes(): ?TicketTypeAttributeList public function setTicketTypeAttributes(?TicketTypeAttributeList $value = null): self { $this->ticketTypeAttributes = $value; + $this->_setField('ticketTypeAttributes'); return $this; } @@ -266,6 +274,7 @@ public function getTicketStates(): ?TicketTypeTicketStates public function setTicketStates(?TicketTypeTicketStates $value = null): self { $this->ticketStates = $value; + $this->_setField('ticketStates'); return $this; } @@ -283,6 +292,7 @@ public function getArchived(): ?bool public function setArchived(?bool $value = null): self { $this->archived = $value; + $this->_setField('archived'); return $this; } @@ -300,6 +310,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -317,6 +328,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } diff --git a/src/Unstable/Tickets/Types/TicketTypeTicketStates.php b/src/Unstable/Tickets/Types/TicketTypeTicketStates.php index aae159a9..3d130a31 100644 --- a/src/Unstable/Tickets/Types/TicketTypeTicketStates.php +++ b/src/Unstable/Tickets/Types/TicketTypeTicketStates.php @@ -51,6 +51,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -68,6 +69,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Unstable/Traits/ContactReference.php b/src/Unstable/Traits/ContactReference.php index b1fd8936..0fc88d2c 100644 --- a/src/Unstable/Traits/ContactReference.php +++ b/src/Unstable/Traits/ContactReference.php @@ -45,6 +45,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -62,6 +63,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -79,6 +81,7 @@ public function getExternalId(): ?string public function setExternalId(?string $value = null): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } } diff --git a/src/Unstable/Traits/ContactReplyBaseRequest.php b/src/Unstable/Traits/ContactReplyBaseRequest.php index d387c228..9755f4d5 100644 --- a/src/Unstable/Traits/ContactReplyBaseRequest.php +++ b/src/Unstable/Traits/ContactReplyBaseRequest.php @@ -66,6 +66,7 @@ public function getMessageType(): string public function setMessageType(string $value): self { $this->messageType = $value; + $this->_setField('messageType'); return $this; } @@ -83,6 +84,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -100,6 +102,7 @@ public function getBody(): string public function setBody(string $value): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -117,6 +120,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -134,6 +138,7 @@ public function getAttachmentUrls(): ?array public function setAttachmentUrls(?array $value = null): self { $this->attachmentUrls = $value; + $this->_setField('attachmentUrls'); return $this; } @@ -151,6 +156,7 @@ public function getReplyOptions(): ?array public function setReplyOptions(?array $value = null): self { $this->replyOptions = $value; + $this->_setField('replyOptions'); return $this; } } diff --git a/src/Unstable/Traits/CreateTicketRequestBody.php b/src/Unstable/Traits/CreateTicketRequestBody.php index f76dc3b6..9056f4d7 100644 --- a/src/Unstable/Traits/CreateTicketRequestBody.php +++ b/src/Unstable/Traits/CreateTicketRequestBody.php @@ -2,10 +2,10 @@ namespace Intercom\Unstable\Traits; -use Intercom\Unstable\Types\CreateTicketRequestContactsItemId; -use Intercom\Unstable\Types\CreateTicketRequestContactsItemExternalId; -use Intercom\Unstable\Types\CreateTicketRequestContactsItemEmail; -use Intercom\Unstable\Types\CreateTicketRequestAssignment; +use Intercom\Unstable\Types\CreateTicketRequestBodyContactsItemId; +use Intercom\Unstable\Types\CreateTicketRequestBodyContactsItemExternalId; +use Intercom\Unstable\Types\CreateTicketRequestBodyContactsItemEmail; +use Intercom\Unstable\Types\CreateTicketRequestBodyAssignment; use Intercom\Core\Json\JsonProperty; use Intercom\Core\Types\ArrayType; use Intercom\Core\Types\Union; @@ -15,14 +15,14 @@ * * @property string $ticketTypeId * @property array<( - * CreateTicketRequestContactsItemId - * |CreateTicketRequestContactsItemExternalId - * |CreateTicketRequestContactsItemEmail + * CreateTicketRequestBodyContactsItemId + * |CreateTicketRequestBodyContactsItemExternalId + * |CreateTicketRequestBodyContactsItemEmail * )> $contacts * @property ?string $conversationToLinkId * @property ?string $companyId * @property ?int $createdAt - * @property ?CreateTicketRequestAssignment $assignment + * @property ?CreateTicketRequestBodyAssignment $assignment */ trait CreateTicketRequestBody { @@ -34,12 +34,12 @@ trait CreateTicketRequestBody /** * @var array<( - * CreateTicketRequestContactsItemId - * |CreateTicketRequestContactsItemExternalId - * |CreateTicketRequestContactsItemEmail + * CreateTicketRequestBodyContactsItemId + * |CreateTicketRequestBodyContactsItemExternalId + * |CreateTicketRequestBodyContactsItemEmail * )> $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)])] + #[JsonProperty('contacts'), ArrayType([new Union(CreateTicketRequestBodyContactsItemId::class, CreateTicketRequestBodyContactsItemExternalId::class, CreateTicketRequestBodyContactsItemEmail::class)])] private array $contacts; /** @@ -67,10 +67,10 @@ trait CreateTicketRequestBody private ?int $createdAt; /** - * @var ?CreateTicketRequestAssignment $assignment + * @var ?CreateTicketRequestBodyAssignment $assignment */ #[JsonProperty('assignment')] - private ?CreateTicketRequestAssignment $assignment; + private ?CreateTicketRequestBodyAssignment $assignment; /** * @return string @@ -86,14 +86,15 @@ public function getTicketTypeId(): string public function setTicketTypeId(string $value): self { $this->ticketTypeId = $value; + $this->_setField('ticketTypeId'); return $this; } /** * @return array<( - * CreateTicketRequestContactsItemId - * |CreateTicketRequestContactsItemExternalId - * |CreateTicketRequestContactsItemEmail + * CreateTicketRequestBodyContactsItemId + * |CreateTicketRequestBodyContactsItemExternalId + * |CreateTicketRequestBodyContactsItemEmail * )> */ public function getContacts(): array @@ -103,14 +104,15 @@ public function getContacts(): array /** * @param array<( - * CreateTicketRequestContactsItemId - * |CreateTicketRequestContactsItemExternalId - * |CreateTicketRequestContactsItemEmail + * CreateTicketRequestBodyContactsItemId + * |CreateTicketRequestBodyContactsItemExternalId + * |CreateTicketRequestBodyContactsItemEmail * )> $value */ public function setContacts(array $value): self { $this->contacts = $value; + $this->_setField('contacts'); return $this; } @@ -128,6 +130,7 @@ public function getConversationToLinkId(): ?string public function setConversationToLinkId(?string $value = null): self { $this->conversationToLinkId = $value; + $this->_setField('conversationToLinkId'); return $this; } @@ -145,6 +148,7 @@ public function getCompanyId(): ?string public function setCompanyId(?string $value = null): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } @@ -162,23 +166,25 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } /** - * @return ?CreateTicketRequestAssignment + * @return ?CreateTicketRequestBodyAssignment */ - public function getAssignment(): ?CreateTicketRequestAssignment + public function getAssignment(): ?CreateTicketRequestBodyAssignment { return $this->assignment; } /** - * @param ?CreateTicketRequestAssignment $value + * @param ?CreateTicketRequestBodyAssignment $value */ - public function setAssignment(?CreateTicketRequestAssignment $value = null): self + public function setAssignment(?CreateTicketRequestBodyAssignment $value = null): self { $this->assignment = $value; + $this->_setField('assignment'); return $this; } } diff --git a/src/Unstable/Traits/CustomChannelBaseEvent.php b/src/Unstable/Traits/CustomChannelBaseEvent.php index 3fd4113a..97ea789e 100644 --- a/src/Unstable/Traits/CustomChannelBaseEvent.php +++ b/src/Unstable/Traits/CustomChannelBaseEvent.php @@ -44,6 +44,7 @@ public function getEventId(): string public function setEventId(string $value): self { $this->eventId = $value; + $this->_setField('eventId'); return $this; } @@ -61,6 +62,7 @@ public function getExternalConversationId(): string public function setExternalConversationId(string $value): self { $this->externalConversationId = $value; + $this->_setField('externalConversationId'); return $this; } @@ -78,6 +80,7 @@ public function getContact(): CustomChannelContact public function setContact(CustomChannelContact $value): self { $this->contact = $value; + $this->_setField('contact'); return $this; } } diff --git a/src/Unstable/Traits/QuickReplyOption.php b/src/Unstable/Traits/QuickReplyOption.php index 65ba7beb..0835a745 100644 --- a/src/Unstable/Traits/QuickReplyOption.php +++ b/src/Unstable/Traits/QuickReplyOption.php @@ -36,6 +36,7 @@ public function getText(): string public function setText(string $value): self { $this->text = $value; + $this->_setField('text'); return $this; } @@ -53,6 +54,7 @@ public function getUuid(): string public function setUuid(string $value): self { $this->uuid = $value; + $this->_setField('uuid'); return $this; } } diff --git a/src/Unstable/Types/ActivityLog.php b/src/Unstable/Types/ActivityLog.php index dd2f298e..52054600 100644 --- a/src/Unstable/Types/ActivityLog.php +++ b/src/Unstable/Types/ActivityLog.php @@ -81,6 +81,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -98,6 +99,7 @@ public function getPerformedBy(): ?ActivityLogPerformedBy public function setPerformedBy(?ActivityLogPerformedBy $value = null): self { $this->performedBy = $value; + $this->_setField('performedBy'); return $this; } @@ -115,6 +117,7 @@ public function getMetadata(): ?ActivityLogMetadata public function setMetadata(?ActivityLogMetadata $value = null): self { $this->metadata = $value; + $this->_setField('metadata'); return $this; } @@ -132,6 +135,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -149,6 +153,7 @@ public function getActivityType(): ?string public function setActivityType(?string $value = null): self { $this->activityType = $value; + $this->_setField('activityType'); return $this; } @@ -166,6 +171,7 @@ public function getActivityDescription(): ?string public function setActivityDescription(?string $value = null): self { $this->activityDescription = $value; + $this->_setField('activityDescription'); return $this; } diff --git a/src/Unstable/Types/ActivityLogList.php b/src/Unstable/Types/ActivityLogList.php index fd5b9c70..d2764648 100644 --- a/src/Unstable/Types/ActivityLogList.php +++ b/src/Unstable/Types/ActivityLogList.php @@ -59,6 +59,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -76,6 +77,7 @@ public function getPages(): ?CursorPages public function setPages(?CursorPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } @@ -93,6 +95,7 @@ public function getActivityLogs(): ?array public function setActivityLogs(?array $value = null): self { $this->activityLogs = $value; + $this->_setField('activityLogs'); return $this; } diff --git a/src/Unstable/Types/ActivityLogMetadata.php b/src/Unstable/Types/ActivityLogMetadata.php index 2d9c6c9a..54457e27 100644 --- a/src/Unstable/Types/ActivityLogMetadata.php +++ b/src/Unstable/Types/ActivityLogMetadata.php @@ -121,6 +121,7 @@ public function getSignInMethod(): ?string public function setSignInMethod(?string $value = null): self { $this->signInMethod = $value; + $this->_setField('signInMethod'); return $this; } @@ -138,6 +139,7 @@ public function getExternalId(): ?string public function setExternalId(?string $value = null): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } @@ -155,6 +157,7 @@ public function getAwayMode(): ?bool public function setAwayMode(?bool $value = null): self { $this->awayMode = $value; + $this->_setField('awayMode'); return $this; } @@ -172,6 +175,7 @@ public function getAwayStatusReason(): ?string public function setAwayStatusReason(?string $value = null): self { $this->awayStatusReason = $value; + $this->_setField('awayStatusReason'); return $this; } @@ -189,6 +193,7 @@ public function getReassignConversations(): ?bool public function setReassignConversations(?bool $value = null): self { $this->reassignConversations = $value; + $this->_setField('reassignConversations'); return $this; } @@ -206,6 +211,7 @@ public function getSource(): ?string public function setSource(?string $value = null): self { $this->source = $value; + $this->_setField('source'); return $this; } @@ -223,6 +229,7 @@ public function getAutoChanged(): ?string public function setAutoChanged(?string $value = null): self { $this->autoChanged = $value; + $this->_setField('autoChanged'); return $this; } @@ -240,6 +247,7 @@ public function getUpdateBy(): ?int public function setUpdateBy(?int $value = null): self { $this->updateBy = $value; + $this->_setField('updateBy'); return $this; } @@ -257,6 +265,7 @@ public function getUpdateByName(): ?string public function setUpdateByName(?string $value = null): self { $this->updateByName = $value; + $this->_setField('updateByName'); return $this; } @@ -274,6 +283,7 @@ public function getConversationAssignmentLimit(): ?int public function setConversationAssignmentLimit(?int $value = null): self { $this->conversationAssignmentLimit = $value; + $this->_setField('conversationAssignmentLimit'); return $this; } @@ -291,6 +301,7 @@ public function getTicketAssignmentLimit(): ?int public function setTicketAssignmentLimit(?int $value = null): self { $this->ticketAssignmentLimit = $value; + $this->_setField('ticketAssignmentLimit'); return $this; } diff --git a/src/Unstable/Types/ActivityLogPerformedBy.php b/src/Unstable/Types/ActivityLogPerformedBy.php index 193efe80..88c94be0 100644 --- a/src/Unstable/Types/ActivityLogPerformedBy.php +++ b/src/Unstable/Types/ActivityLogPerformedBy.php @@ -65,6 +65,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -82,6 +83,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -99,6 +101,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -116,6 +119,7 @@ public function getIp(): ?string public function setIp(?string $value = null): self { $this->ip = $value; + $this->_setField('ip'); return $this; } diff --git a/src/Unstable/Types/AddressableList.php b/src/Unstable/Types/AddressableList.php index 86dfd529..3d3f8b47 100644 --- a/src/Unstable/Types/AddressableList.php +++ b/src/Unstable/Types/AddressableList.php @@ -57,6 +57,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -74,6 +75,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -91,6 +93,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } diff --git a/src/Unstable/Types/AdminList.php b/src/Unstable/Types/AdminList.php index eb44133d..e51cff76 100644 --- a/src/Unstable/Types/AdminList.php +++ b/src/Unstable/Types/AdminList.php @@ -52,6 +52,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -69,6 +70,7 @@ public function getAdmins(): ?array public function setAdmins(?array $value = null): self { $this->admins = $value; + $this->_setField('admins'); return $this; } diff --git a/src/Unstable/Types/AdminPriorityLevel.php b/src/Unstable/Types/AdminPriorityLevel.php index db73a767..804863e3 100644 --- a/src/Unstable/Types/AdminPriorityLevel.php +++ b/src/Unstable/Types/AdminPriorityLevel.php @@ -50,6 +50,7 @@ public function getPrimaryAdminIds(): ?array public function setPrimaryAdminIds(?array $value = null): self { $this->primaryAdminIds = $value; + $this->_setField('primaryAdminIds'); return $this; } @@ -67,6 +68,7 @@ public function getSecondaryAdminIds(): ?array public function setSecondaryAdminIds(?array $value = null): self { $this->secondaryAdminIds = $value; + $this->_setField('secondaryAdminIds'); return $this; } diff --git a/src/Unstable/Types/AdminReplyConversationRequest.php b/src/Unstable/Types/AdminReplyConversationRequest.php index 4e6b3c09..b52c4a31 100644 --- a/src/Unstable/Types/AdminReplyConversationRequest.php +++ b/src/Unstable/Types/AdminReplyConversationRequest.php @@ -98,6 +98,7 @@ public function getMessageType(): string public function setMessageType(string $value): self { $this->messageType = $value; + $this->_setField('messageType'); return $this; } @@ -115,6 +116,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -132,6 +134,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -149,6 +152,7 @@ public function getAdminId(): string public function setAdminId(string $value): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } @@ -166,6 +170,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -183,6 +188,7 @@ public function getReplyOptions(): ?array public function setReplyOptions(?array $value = null): self { $this->replyOptions = $value; + $this->_setField('replyOptions'); return $this; } @@ -200,6 +206,7 @@ public function getAttachmentUrls(): ?array public function setAttachmentUrls(?array $value = null): self { $this->attachmentUrls = $value; + $this->_setField('attachmentUrls'); return $this; } @@ -217,6 +224,7 @@ public function getAttachmentFiles(): ?array public function setAttachmentFiles(?array $value = null): self { $this->attachmentFiles = $value; + $this->_setField('attachmentFiles'); return $this; } diff --git a/src/Unstable/Types/AdminReplyTicketRequest.php b/src/Unstable/Types/AdminReplyTicketRequest.php index 89064185..317da547 100644 --- a/src/Unstable/Types/AdminReplyTicketRequest.php +++ b/src/Unstable/Types/AdminReplyTicketRequest.php @@ -90,6 +90,7 @@ public function getMessageType(): string public function setMessageType(string $value): self { $this->messageType = $value; + $this->_setField('messageType'); return $this; } @@ -107,6 +108,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -124,6 +126,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -141,6 +144,7 @@ public function getAdminId(): string public function setAdminId(string $value): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } @@ -158,6 +162,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -175,6 +180,7 @@ public function getReplyOptions(): ?array public function setReplyOptions(?array $value = null): self { $this->replyOptions = $value; + $this->_setField('replyOptions'); return $this; } @@ -192,6 +198,7 @@ public function getAttachmentUrls(): ?array public function setAttachmentUrls(?array $value = null): self { $this->attachmentUrls = $value; + $this->_setField('attachmentUrls'); return $this; } diff --git a/src/Unstable/Types/AdminReplyTicketRequestReplyOptionsItem.php b/src/Unstable/Types/AdminReplyTicketRequestReplyOptionsItem.php index ad71d0fd..bfed92af 100644 --- a/src/Unstable/Types/AdminReplyTicketRequestReplyOptionsItem.php +++ b/src/Unstable/Types/AdminReplyTicketRequestReplyOptionsItem.php @@ -46,6 +46,7 @@ public function getText(): string public function setText(string $value): self { $this->text = $value; + $this->_setField('text'); return $this; } @@ -63,6 +64,7 @@ public function getUuid(): string public function setUuid(string $value): self { $this->uuid = $value; + $this->_setField('uuid'); return $this; } diff --git a/src/Unstable/Types/AdminWithApp.php b/src/Unstable/Types/AdminWithApp.php index ad0cc479..b3e728d2 100644 --- a/src/Unstable/Types/AdminWithApp.php +++ b/src/Unstable/Types/AdminWithApp.php @@ -130,6 +130,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -147,6 +148,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -164,6 +166,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -181,6 +184,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -198,6 +202,7 @@ public function getJobTitle(): ?string public function setJobTitle(?string $value = null): self { $this->jobTitle = $value; + $this->_setField('jobTitle'); return $this; } @@ -215,6 +220,7 @@ public function getAwayModeEnabled(): ?bool public function setAwayModeEnabled(?bool $value = null): self { $this->awayModeEnabled = $value; + $this->_setField('awayModeEnabled'); return $this; } @@ -232,6 +238,7 @@ public function getAwayModeReassign(): ?bool public function setAwayModeReassign(?bool $value = null): self { $this->awayModeReassign = $value; + $this->_setField('awayModeReassign'); return $this; } @@ -249,6 +256,7 @@ public function getHasInboxSeat(): ?bool public function setHasInboxSeat(?bool $value = null): self { $this->hasInboxSeat = $value; + $this->_setField('hasInboxSeat'); return $this; } @@ -266,6 +274,7 @@ public function getTeamIds(): ?array public function setTeamIds(?array $value = null): self { $this->teamIds = $value; + $this->_setField('teamIds'); return $this; } @@ -283,6 +292,7 @@ public function getAvatar(): ?AdminWithAppAvatar public function setAvatar(?AdminWithAppAvatar $value = null): self { $this->avatar = $value; + $this->_setField('avatar'); return $this; } @@ -300,6 +310,7 @@ public function getEmailVerified(): ?bool public function setEmailVerified(?bool $value = null): self { $this->emailVerified = $value; + $this->_setField('emailVerified'); return $this; } @@ -317,6 +328,7 @@ public function getApp(): ?App public function setApp(?App $value = null): self { $this->app = $value; + $this->_setField('app'); return $this; } diff --git a/src/Unstable/Types/AdminWithAppAvatar.php b/src/Unstable/Types/AdminWithAppAvatar.php index d4874fad..c330cf50 100644 --- a/src/Unstable/Types/AdminWithAppAvatar.php +++ b/src/Unstable/Types/AdminWithAppAvatar.php @@ -49,6 +49,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -66,6 +67,7 @@ public function getImageUrl(): ?string public function setImageUrl(?string $value = null): self { $this->imageUrl = $value; + $this->_setField('imageUrl'); return $this; } diff --git a/src/Unstable/Types/AiCallResponse.php b/src/Unstable/Types/AiCallResponse.php index e7eeb3d7..c0e2eabd 100644 --- a/src/Unstable/Types/AiCallResponse.php +++ b/src/Unstable/Types/AiCallResponse.php @@ -114,6 +114,7 @@ public function getId(): ?int public function setId(?int $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -131,6 +132,7 @@ public function getAppId(): ?int public function setAppId(?int $value = null): self { $this->appId = $value; + $this->_setField('appId'); return $this; } @@ -148,6 +150,7 @@ public function getUserPhoneNumber(): ?string public function setUserPhoneNumber(?string $value = null): self { $this->userPhoneNumber = $value; + $this->_setField('userPhoneNumber'); return $this; } @@ -165,6 +168,7 @@ public function getStatus(): ?string public function setStatus(?string $value = null): self { $this->status = $value; + $this->_setField('status'); return $this; } @@ -182,6 +186,7 @@ public function getIntercomCallId(): ?string public function setIntercomCallId(?string $value = null): self { $this->intercomCallId = $value; + $this->_setField('intercomCallId'); return $this; } @@ -199,6 +204,7 @@ public function getExternalCallId(): ?string public function setExternalCallId(?string $value = null): self { $this->externalCallId = $value; + $this->_setField('externalCallId'); return $this; } @@ -216,6 +222,7 @@ public function getIntercomConversationId(): ?string public function setIntercomConversationId(?string $value = null): self { $this->intercomConversationId = $value; + $this->_setField('intercomConversationId'); return $this; } @@ -233,6 +240,7 @@ public function getCallTranscript(): ?array public function setCallTranscript(?array $value = null): self { $this->callTranscript = $value; + $this->_setField('callTranscript'); return $this; } @@ -250,6 +258,7 @@ public function getCallSummary(): ?string public function setCallSummary(?string $value = null): self { $this->callSummary = $value; + $this->_setField('callSummary'); return $this; } @@ -267,6 +276,7 @@ public function getIntent(): ?array public function setIntent(?array $value = null): self { $this->intent = $value; + $this->_setField('intent'); return $this; } diff --git a/src/Unstable/Types/App.php b/src/Unstable/Types/App.php index dacc0a3e..93641048 100644 --- a/src/Unstable/Types/App.php +++ b/src/Unstable/Types/App.php @@ -89,6 +89,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -106,6 +107,7 @@ public function getIdCode(): ?string public function setIdCode(?string $value = null): self { $this->idCode = $value; + $this->_setField('idCode'); return $this; } @@ -123,6 +125,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -140,6 +143,7 @@ public function getRegion(): ?string public function setRegion(?string $value = null): self { $this->region = $value; + $this->_setField('region'); return $this; } @@ -157,6 +161,7 @@ public function getTimezone(): ?string public function setTimezone(?string $value = null): self { $this->timezone = $value; + $this->_setField('timezone'); return $this; } @@ -174,6 +179,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -191,6 +197,7 @@ public function getIdentityVerification(): ?bool public function setIdentityVerification(?bool $value = null): self { $this->identityVerification = $value; + $this->_setField('identityVerification'); return $this; } diff --git a/src/Unstable/Types/ArticleContent.php b/src/Unstable/Types/ArticleContent.php index 5d1b2ff7..8f54f54d 100644 --- a/src/Unstable/Types/ArticleContent.php +++ b/src/Unstable/Types/ArticleContent.php @@ -105,6 +105,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -122,6 +123,7 @@ public function getTitle(): ?string public function setTitle(?string $value = null): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -139,6 +141,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -156,6 +159,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -173,6 +177,7 @@ public function getAuthorId(): ?int public function setAuthorId(?int $value = null): self { $this->authorId = $value; + $this->_setField('authorId'); return $this; } @@ -190,6 +195,7 @@ public function getState(): ?string public function setState(?string $value = null): self { $this->state = $value; + $this->_setField('state'); return $this; } @@ -207,6 +213,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -224,6 +231,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -241,6 +249,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } diff --git a/src/Unstable/Types/ArticleList.php b/src/Unstable/Types/ArticleList.php index c2381951..3c260f12 100644 --- a/src/Unstable/Types/ArticleList.php +++ b/src/Unstable/Types/ArticleList.php @@ -67,6 +67,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -84,6 +85,7 @@ public function getPages(): ?CursorPages public function setPages(?CursorPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } @@ -101,6 +103,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -118,6 +121,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Unstable/Types/ArticleStatistics.php b/src/Unstable/Types/ArticleStatistics.php index 7f34b7fc..d7301059 100644 --- a/src/Unstable/Types/ArticleStatistics.php +++ b/src/Unstable/Types/ArticleStatistics.php @@ -89,6 +89,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -106,6 +107,7 @@ public function getViews(): ?int public function setViews(?int $value = null): self { $this->views = $value; + $this->_setField('views'); return $this; } @@ -123,6 +125,7 @@ public function getConversions(): ?int public function setConversions(?int $value = null): self { $this->conversions = $value; + $this->_setField('conversions'); return $this; } @@ -140,6 +143,7 @@ public function getReactions(): ?int public function setReactions(?int $value = null): self { $this->reactions = $value; + $this->_setField('reactions'); return $this; } @@ -157,6 +161,7 @@ public function getHappyReactionPercentage(): ?float public function setHappyReactionPercentage(?float $value = null): self { $this->happyReactionPercentage = $value; + $this->_setField('happyReactionPercentage'); return $this; } @@ -174,6 +179,7 @@ public function getNeutralReactionPercentage(): ?float public function setNeutralReactionPercentage(?float $value = null): self { $this->neutralReactionPercentage = $value; + $this->_setField('neutralReactionPercentage'); return $this; } @@ -191,6 +197,7 @@ public function getSadReactionPercentage(): ?float public function setSadReactionPercentage(?float $value = null): self { $this->sadReactionPercentage = $value; + $this->_setField('sadReactionPercentage'); return $this; } diff --git a/src/Unstable/Types/ArticleTranslatedContent.php b/src/Unstable/Types/ArticleTranslatedContent.php index 27e54b20..9f6e828b 100644 --- a/src/Unstable/Types/ArticleTranslatedContent.php +++ b/src/Unstable/Types/ArticleTranslatedContent.php @@ -337,6 +337,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -354,6 +355,7 @@ public function getAr(): ?ArticleContent public function setAr(?ArticleContent $value = null): self { $this->ar = $value; + $this->_setField('ar'); return $this; } @@ -371,6 +373,7 @@ public function getBg(): ?ArticleContent public function setBg(?ArticleContent $value = null): self { $this->bg = $value; + $this->_setField('bg'); return $this; } @@ -388,6 +391,7 @@ public function getBs(): ?ArticleContent public function setBs(?ArticleContent $value = null): self { $this->bs = $value; + $this->_setField('bs'); return $this; } @@ -405,6 +409,7 @@ public function getCa(): ?ArticleContent public function setCa(?ArticleContent $value = null): self { $this->ca = $value; + $this->_setField('ca'); return $this; } @@ -422,6 +427,7 @@ public function getCs(): ?ArticleContent public function setCs(?ArticleContent $value = null): self { $this->cs = $value; + $this->_setField('cs'); return $this; } @@ -439,6 +445,7 @@ public function getDa(): ?ArticleContent public function setDa(?ArticleContent $value = null): self { $this->da = $value; + $this->_setField('da'); return $this; } @@ -456,6 +463,7 @@ public function getDe(): ?ArticleContent public function setDe(?ArticleContent $value = null): self { $this->de = $value; + $this->_setField('de'); return $this; } @@ -473,6 +481,7 @@ public function getEl(): ?ArticleContent public function setEl(?ArticleContent $value = null): self { $this->el = $value; + $this->_setField('el'); return $this; } @@ -490,6 +499,7 @@ public function getEn(): ?ArticleContent public function setEn(?ArticleContent $value = null): self { $this->en = $value; + $this->_setField('en'); return $this; } @@ -507,6 +517,7 @@ public function getEs(): ?ArticleContent public function setEs(?ArticleContent $value = null): self { $this->es = $value; + $this->_setField('es'); return $this; } @@ -524,6 +535,7 @@ public function getEt(): ?ArticleContent public function setEt(?ArticleContent $value = null): self { $this->et = $value; + $this->_setField('et'); return $this; } @@ -541,6 +553,7 @@ public function getFi(): ?ArticleContent public function setFi(?ArticleContent $value = null): self { $this->fi = $value; + $this->_setField('fi'); return $this; } @@ -558,6 +571,7 @@ public function getFr(): ?ArticleContent public function setFr(?ArticleContent $value = null): self { $this->fr = $value; + $this->_setField('fr'); return $this; } @@ -575,6 +589,7 @@ public function getHe(): ?ArticleContent public function setHe(?ArticleContent $value = null): self { $this->he = $value; + $this->_setField('he'); return $this; } @@ -592,6 +607,7 @@ public function getHr(): ?ArticleContent public function setHr(?ArticleContent $value = null): self { $this->hr = $value; + $this->_setField('hr'); return $this; } @@ -609,6 +625,7 @@ public function getHu(): ?ArticleContent public function setHu(?ArticleContent $value = null): self { $this->hu = $value; + $this->_setField('hu'); return $this; } @@ -626,6 +643,7 @@ public function getId(): ?ArticleContent public function setId(?ArticleContent $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -643,6 +661,7 @@ public function getIt(): ?ArticleContent public function setIt(?ArticleContent $value = null): self { $this->it = $value; + $this->_setField('it'); return $this; } @@ -660,6 +679,7 @@ public function getJa(): ?ArticleContent public function setJa(?ArticleContent $value = null): self { $this->ja = $value; + $this->_setField('ja'); return $this; } @@ -677,6 +697,7 @@ public function getKo(): ?ArticleContent public function setKo(?ArticleContent $value = null): self { $this->ko = $value; + $this->_setField('ko'); return $this; } @@ -694,6 +715,7 @@ public function getLt(): ?ArticleContent public function setLt(?ArticleContent $value = null): self { $this->lt = $value; + $this->_setField('lt'); return $this; } @@ -711,6 +733,7 @@ public function getLv(): ?ArticleContent public function setLv(?ArticleContent $value = null): self { $this->lv = $value; + $this->_setField('lv'); return $this; } @@ -728,6 +751,7 @@ public function getMn(): ?ArticleContent public function setMn(?ArticleContent $value = null): self { $this->mn = $value; + $this->_setField('mn'); return $this; } @@ -745,6 +769,7 @@ public function getNb(): ?ArticleContent public function setNb(?ArticleContent $value = null): self { $this->nb = $value; + $this->_setField('nb'); return $this; } @@ -762,6 +787,7 @@ public function getNl(): ?ArticleContent public function setNl(?ArticleContent $value = null): self { $this->nl = $value; + $this->_setField('nl'); return $this; } @@ -779,6 +805,7 @@ public function getPl(): ?ArticleContent public function setPl(?ArticleContent $value = null): self { $this->pl = $value; + $this->_setField('pl'); return $this; } @@ -796,6 +823,7 @@ public function getPt(): ?ArticleContent public function setPt(?ArticleContent $value = null): self { $this->pt = $value; + $this->_setField('pt'); return $this; } @@ -813,6 +841,7 @@ public function getRo(): ?ArticleContent public function setRo(?ArticleContent $value = null): self { $this->ro = $value; + $this->_setField('ro'); return $this; } @@ -830,6 +859,7 @@ public function getRu(): ?ArticleContent public function setRu(?ArticleContent $value = null): self { $this->ru = $value; + $this->_setField('ru'); return $this; } @@ -847,6 +877,7 @@ public function getSl(): ?ArticleContent public function setSl(?ArticleContent $value = null): self { $this->sl = $value; + $this->_setField('sl'); return $this; } @@ -864,6 +895,7 @@ public function getSr(): ?ArticleContent public function setSr(?ArticleContent $value = null): self { $this->sr = $value; + $this->_setField('sr'); return $this; } @@ -881,6 +913,7 @@ public function getSv(): ?ArticleContent public function setSv(?ArticleContent $value = null): self { $this->sv = $value; + $this->_setField('sv'); return $this; } @@ -898,6 +931,7 @@ public function getTr(): ?ArticleContent public function setTr(?ArticleContent $value = null): self { $this->tr = $value; + $this->_setField('tr'); return $this; } @@ -915,6 +949,7 @@ public function getVi(): ?ArticleContent public function setVi(?ArticleContent $value = null): self { $this->vi = $value; + $this->_setField('vi'); return $this; } @@ -932,6 +967,7 @@ public function getPtBr(): ?ArticleContent public function setPtBr(?ArticleContent $value = null): self { $this->ptBr = $value; + $this->_setField('ptBr'); return $this; } @@ -949,6 +985,7 @@ public function getZhCn(): ?ArticleContent public function setZhCn(?ArticleContent $value = null): self { $this->zhCn = $value; + $this->_setField('zhCn'); return $this; } @@ -966,6 +1003,7 @@ public function getZhTw(): ?ArticleContent public function setZhTw(?ArticleContent $value = null): self { $this->zhTw = $value; + $this->_setField('zhTw'); return $this; } diff --git a/src/Unstable/Types/AssignConversationRequest.php b/src/Unstable/Types/AssignConversationRequest.php index a8f76623..0cf717aa 100644 --- a/src/Unstable/Types/AssignConversationRequest.php +++ b/src/Unstable/Types/AssignConversationRequest.php @@ -65,6 +65,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -82,6 +83,7 @@ public function getAdminId(): string public function setAdminId(string $value): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } @@ -99,6 +101,7 @@ public function getAssigneeId(): string public function setAssigneeId(string $value): self { $this->assigneeId = $value; + $this->_setField('assigneeId'); return $this; } @@ -116,6 +119,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } diff --git a/src/Unstable/Types/AwayStatusReason.php b/src/Unstable/Types/AwayStatusReason.php index 7dd63075..0c784171 100644 --- a/src/Unstable/Types/AwayStatusReason.php +++ b/src/Unstable/Types/AwayStatusReason.php @@ -94,6 +94,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -111,6 +112,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -128,6 +130,7 @@ public function getLabel(): ?string public function setLabel(?string $value = null): self { $this->label = $value; + $this->_setField('label'); return $this; } @@ -145,6 +148,7 @@ public function getEmoji(): ?string public function setEmoji(?string $value = null): self { $this->emoji = $value; + $this->_setField('emoji'); return $this; } @@ -162,6 +166,7 @@ public function getOrder(): ?int public function setOrder(?int $value = null): self { $this->order = $value; + $this->_setField('order'); return $this; } @@ -179,6 +184,7 @@ public function getDeleted(): ?bool public function setDeleted(?bool $value = null): self { $this->deleted = $value; + $this->_setField('deleted'); return $this; } @@ -196,6 +202,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -213,6 +220,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } diff --git a/src/Unstable/Types/CallList.php b/src/Unstable/Types/CallList.php index 943a7af4..f984915c 100644 --- a/src/Unstable/Types/CallList.php +++ b/src/Unstable/Types/CallList.php @@ -67,6 +67,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -84,6 +85,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } @@ -101,6 +103,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -118,6 +121,7 @@ public function getPages(): ?CursorPages public function setPages(?CursorPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } diff --git a/src/Unstable/Types/CloseConversationRequest.php b/src/Unstable/Types/CloseConversationRequest.php index 47036486..39ef2157 100644 --- a/src/Unstable/Types/CloseConversationRequest.php +++ b/src/Unstable/Types/CloseConversationRequest.php @@ -57,6 +57,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -74,6 +75,7 @@ public function getAdminId(): string public function setAdminId(string $value): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } @@ -91,6 +93,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } diff --git a/src/Unstable/Types/CollectionList.php b/src/Unstable/Types/CollectionList.php index a5133dd2..7f78c08b 100644 --- a/src/Unstable/Types/CollectionList.php +++ b/src/Unstable/Types/CollectionList.php @@ -67,6 +67,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -84,6 +85,7 @@ public function getPages(): ?CursorPages public function setPages(?CursorPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } @@ -101,6 +103,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -118,6 +121,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Unstable/Types/CompanyAttachedContacts.php b/src/Unstable/Types/CompanyAttachedContacts.php index 76329af1..2f8ba26d 100644 --- a/src/Unstable/Types/CompanyAttachedContacts.php +++ b/src/Unstable/Types/CompanyAttachedContacts.php @@ -67,6 +67,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -84,6 +85,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } @@ -101,6 +103,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -118,6 +121,7 @@ public function getPages(): ?CursorPages public function setPages(?CursorPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } diff --git a/src/Unstable/Types/CompanyAttachedSegments.php b/src/Unstable/Types/CompanyAttachedSegments.php index 4c830efa..34263da7 100644 --- a/src/Unstable/Types/CompanyAttachedSegments.php +++ b/src/Unstable/Types/CompanyAttachedSegments.php @@ -51,6 +51,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -68,6 +69,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Unstable/Types/CompanyData.php b/src/Unstable/Types/CompanyData.php index 301a7ce5..19dd89c6 100644 --- a/src/Unstable/Types/CompanyData.php +++ b/src/Unstable/Types/CompanyData.php @@ -57,6 +57,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -74,6 +75,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -91,6 +93,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } diff --git a/src/Unstable/Types/CompanyList.php b/src/Unstable/Types/CompanyList.php index 76dbf331..a3b4c208 100644 --- a/src/Unstable/Types/CompanyList.php +++ b/src/Unstable/Types/CompanyList.php @@ -67,6 +67,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -84,6 +85,7 @@ public function getPages(): ?CursorPages public function setPages(?CursorPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } @@ -101,6 +103,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -118,6 +121,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Unstable/Types/CompanyScroll.php b/src/Unstable/Types/CompanyScroll.php index c1873792..ce563330 100644 --- a/src/Unstable/Types/CompanyScroll.php +++ b/src/Unstable/Types/CompanyScroll.php @@ -75,6 +75,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -92,6 +93,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } @@ -109,6 +111,7 @@ public function getPages(): ?CursorPages public function setPages(?CursorPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } @@ -126,6 +129,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -143,6 +147,7 @@ public function getScrollParam(): ?string public function setScrollParam(?string $value = null): self { $this->scrollParam = $value; + $this->_setField('scrollParam'); return $this; } diff --git a/src/Unstable/Types/ContactArchived.php b/src/Unstable/Types/ContactArchived.php index d068de3a..01163602 100644 --- a/src/Unstable/Types/ContactArchived.php +++ b/src/Unstable/Types/ContactArchived.php @@ -50,6 +50,7 @@ public function getArchived(): ?bool public function setArchived(?bool $value = null): self { $this->archived = $value; + $this->_setField('archived'); return $this; } diff --git a/src/Unstable/Types/ContactAttachedCompanies.php b/src/Unstable/Types/ContactAttachedCompanies.php index 7bfc2fce..cb3a5833 100644 --- a/src/Unstable/Types/ContactAttachedCompanies.php +++ b/src/Unstable/Types/ContactAttachedCompanies.php @@ -67,6 +67,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -84,6 +85,7 @@ public function getCompanies(): ?array public function setCompanies(?array $value = null): self { $this->companies = $value; + $this->_setField('companies'); return $this; } @@ -101,6 +103,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -118,6 +121,7 @@ public function getPages(): ?PagesLink public function setPages(?PagesLink $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } diff --git a/src/Unstable/Types/ContactBlocked.php b/src/Unstable/Types/ContactBlocked.php index ee405652..4c7def71 100644 --- a/src/Unstable/Types/ContactBlocked.php +++ b/src/Unstable/Types/ContactBlocked.php @@ -50,6 +50,7 @@ public function getBlocked(): ?bool public function setBlocked(?bool $value = null): self { $this->blocked = $value; + $this->_setField('blocked'); return $this; } diff --git a/src/Unstable/Types/ContactCompanies.php b/src/Unstable/Types/ContactCompanies.php index 3d6d404d..15ee7f24 100644 --- a/src/Unstable/Types/ContactCompanies.php +++ b/src/Unstable/Types/ContactCompanies.php @@ -66,6 +66,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } @@ -83,6 +84,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -100,6 +102,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -117,6 +120,7 @@ public function getHasMore(): ?bool public function setHasMore(?bool $value = null): self { $this->hasMore = $value; + $this->_setField('hasMore'); return $this; } diff --git a/src/Unstable/Types/ContactDeleted.php b/src/Unstable/Types/ContactDeleted.php index d2801ec0..5908b95c 100644 --- a/src/Unstable/Types/ContactDeleted.php +++ b/src/Unstable/Types/ContactDeleted.php @@ -50,6 +50,7 @@ public function getDeleted(): ?bool public function setDeleted(?bool $value = null): self { $this->deleted = $value; + $this->_setField('deleted'); return $this; } diff --git a/src/Unstable/Types/ContactList.php b/src/Unstable/Types/ContactList.php index 24cf5a51..b51d03a8 100644 --- a/src/Unstable/Types/ContactList.php +++ b/src/Unstable/Types/ContactList.php @@ -67,6 +67,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -84,6 +85,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } @@ -101,6 +103,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -118,6 +121,7 @@ public function getPages(): ?CursorPages public function setPages(?CursorPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } diff --git a/src/Unstable/Types/ContactLocation.php b/src/Unstable/Types/ContactLocation.php index 3641b47a..b974cdae 100644 --- a/src/Unstable/Types/ContactLocation.php +++ b/src/Unstable/Types/ContactLocation.php @@ -65,6 +65,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -82,6 +83,7 @@ public function getCountry(): ?string public function setCountry(?string $value = null): self { $this->country = $value; + $this->_setField('country'); return $this; } @@ -99,6 +101,7 @@ public function getRegion(): ?string public function setRegion(?string $value = null): self { $this->region = $value; + $this->_setField('region'); return $this; } @@ -116,6 +119,7 @@ public function getCity(): ?string public function setCity(?string $value = null): self { $this->city = $value; + $this->_setField('city'); return $this; } diff --git a/src/Unstable/Types/ContactNotes.php b/src/Unstable/Types/ContactNotes.php index 7ac8ebf8..a1ca1381 100644 --- a/src/Unstable/Types/ContactNotes.php +++ b/src/Unstable/Types/ContactNotes.php @@ -66,6 +66,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } @@ -83,6 +84,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -100,6 +102,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -117,6 +120,7 @@ public function getHasMore(): ?bool public function setHasMore(?bool $value = null): self { $this->hasMore = $value; + $this->_setField('hasMore'); return $this; } diff --git a/src/Unstable/Types/ContactReference.php b/src/Unstable/Types/ContactReference.php index 24f9f150..9e079748 100644 --- a/src/Unstable/Types/ContactReference.php +++ b/src/Unstable/Types/ContactReference.php @@ -57,6 +57,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -74,6 +75,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -91,6 +93,7 @@ public function getExternalId(): ?string public function setExternalId(?string $value = null): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } diff --git a/src/Unstable/Types/ContactReplyBaseRequest.php b/src/Unstable/Types/ContactReplyBaseRequest.php index 97115018..a3b85d49 100644 --- a/src/Unstable/Types/ContactReplyBaseRequest.php +++ b/src/Unstable/Types/ContactReplyBaseRequest.php @@ -79,6 +79,7 @@ public function getMessageType(): string public function setMessageType(string $value): self { $this->messageType = $value; + $this->_setField('messageType'); return $this; } @@ -96,6 +97,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -113,6 +115,7 @@ public function getBody(): string public function setBody(string $value): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -130,6 +133,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -147,6 +151,7 @@ public function getAttachmentUrls(): ?array public function setAttachmentUrls(?array $value = null): self { $this->attachmentUrls = $value; + $this->_setField('attachmentUrls'); return $this; } @@ -164,6 +169,7 @@ public function getReplyOptions(): ?array public function setReplyOptions(?array $value = null): self { $this->replyOptions = $value; + $this->_setField('replyOptions'); return $this; } diff --git a/src/Unstable/Types/ContactReplyBaseRequestReplyOptionsItem.php b/src/Unstable/Types/ContactReplyBaseRequestReplyOptionsItem.php index 057d6829..5c6ad9d0 100644 --- a/src/Unstable/Types/ContactReplyBaseRequestReplyOptionsItem.php +++ b/src/Unstable/Types/ContactReplyBaseRequestReplyOptionsItem.php @@ -46,6 +46,7 @@ public function getText(): string public function setText(string $value): self { $this->text = $value; + $this->_setField('text'); return $this; } @@ -63,6 +64,7 @@ public function getUuid(): string public function setUuid(string $value): self { $this->uuid = $value; + $this->_setField('uuid'); return $this; } diff --git a/src/Unstable/Types/ContactReplyEmailRequest.php b/src/Unstable/Types/ContactReplyEmailRequest.php index 7771ba0a..56934d7a 100644 --- a/src/Unstable/Types/ContactReplyEmailRequest.php +++ b/src/Unstable/Types/ContactReplyEmailRequest.php @@ -65,6 +65,7 @@ public function getEmail(): string public function setEmail(string $value): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -82,6 +83,7 @@ public function getAttachmentFiles(): ?array public function setAttachmentFiles(?array $value = null): self { $this->attachmentFiles = $value; + $this->_setField('attachmentFiles'); return $this; } diff --git a/src/Unstable/Types/ContactReplyIntercomUserIdRequest.php b/src/Unstable/Types/ContactReplyIntercomUserIdRequest.php index 3b55f201..6233d01e 100644 --- a/src/Unstable/Types/ContactReplyIntercomUserIdRequest.php +++ b/src/Unstable/Types/ContactReplyIntercomUserIdRequest.php @@ -65,6 +65,7 @@ public function getIntercomUserId(): string public function setIntercomUserId(string $value): self { $this->intercomUserId = $value; + $this->_setField('intercomUserId'); return $this; } @@ -82,6 +83,7 @@ public function getAttachmentFiles(): ?array public function setAttachmentFiles(?array $value = null): self { $this->attachmentFiles = $value; + $this->_setField('attachmentFiles'); return $this; } diff --git a/src/Unstable/Types/ContactReplyTicketEmailRequest.php b/src/Unstable/Types/ContactReplyTicketEmailRequest.php index 54b0c344..7d486bbf 100644 --- a/src/Unstable/Types/ContactReplyTicketEmailRequest.php +++ b/src/Unstable/Types/ContactReplyTicketEmailRequest.php @@ -56,6 +56,7 @@ public function getEmail(): string public function setEmail(string $value): self { $this->email = $value; + $this->_setField('email'); return $this; } diff --git a/src/Unstable/Types/ContactReplyTicketIntercomUserIdRequest.php b/src/Unstable/Types/ContactReplyTicketIntercomUserIdRequest.php index 4b5a79e0..f0325a7e 100644 --- a/src/Unstable/Types/ContactReplyTicketIntercomUserIdRequest.php +++ b/src/Unstable/Types/ContactReplyTicketIntercomUserIdRequest.php @@ -56,6 +56,7 @@ public function getIntercomUserId(): string public function setIntercomUserId(string $value): self { $this->intercomUserId = $value; + $this->_setField('intercomUserId'); return $this; } diff --git a/src/Unstable/Types/ContactReplyTicketUserIdRequest.php b/src/Unstable/Types/ContactReplyTicketUserIdRequest.php index 79e818f6..bd4b3cbd 100644 --- a/src/Unstable/Types/ContactReplyTicketUserIdRequest.php +++ b/src/Unstable/Types/ContactReplyTicketUserIdRequest.php @@ -56,6 +56,7 @@ public function getUserId(): string public function setUserId(string $value): self { $this->userId = $value; + $this->_setField('userId'); return $this; } diff --git a/src/Unstable/Types/ContactReplyUserIdRequest.php b/src/Unstable/Types/ContactReplyUserIdRequest.php index 271453e1..8d9285d6 100644 --- a/src/Unstable/Types/ContactReplyUserIdRequest.php +++ b/src/Unstable/Types/ContactReplyUserIdRequest.php @@ -65,6 +65,7 @@ public function getUserId(): string public function setUserId(string $value): self { $this->userId = $value; + $this->_setField('userId'); return $this; } @@ -82,6 +83,7 @@ public function getAttachmentFiles(): ?array public function setAttachmentFiles(?array $value = null): self { $this->attachmentFiles = $value; + $this->_setField('attachmentFiles'); return $this; } diff --git a/src/Unstable/Types/ContactSegments.php b/src/Unstable/Types/ContactSegments.php index d90fd7c4..8af305d8 100644 --- a/src/Unstable/Types/ContactSegments.php +++ b/src/Unstable/Types/ContactSegments.php @@ -51,6 +51,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -68,6 +69,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Unstable/Types/ContactSocialProfiles.php b/src/Unstable/Types/ContactSocialProfiles.php index 84feeedc..e2c70e2e 100644 --- a/src/Unstable/Types/ContactSocialProfiles.php +++ b/src/Unstable/Types/ContactSocialProfiles.php @@ -42,6 +42,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Unstable/Types/ContactSubscriptionTypes.php b/src/Unstable/Types/ContactSubscriptionTypes.php index e1e4b095..9c305fae 100644 --- a/src/Unstable/Types/ContactSubscriptionTypes.php +++ b/src/Unstable/Types/ContactSubscriptionTypes.php @@ -66,6 +66,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } @@ -83,6 +84,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -100,6 +102,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -117,6 +120,7 @@ public function getHasMore(): ?bool public function setHasMore(?bool $value = null): self { $this->hasMore = $value; + $this->_setField('hasMore'); return $this; } diff --git a/src/Unstable/Types/ContactTags.php b/src/Unstable/Types/ContactTags.php index 04573e4f..3a28dbc4 100644 --- a/src/Unstable/Types/ContactTags.php +++ b/src/Unstable/Types/ContactTags.php @@ -66,6 +66,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } @@ -83,6 +84,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -100,6 +102,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -117,6 +120,7 @@ public function getHasMore(): ?bool public function setHasMore(?bool $value = null): self { $this->hasMore = $value; + $this->_setField('hasMore'); return $this; } diff --git a/src/Unstable/Types/ContactUnarchived.php b/src/Unstable/Types/ContactUnarchived.php index 02e9265c..db7312df 100644 --- a/src/Unstable/Types/ContactUnarchived.php +++ b/src/Unstable/Types/ContactUnarchived.php @@ -50,6 +50,7 @@ public function getArchived(): ?bool public function setArchived(?bool $value = null): self { $this->archived = $value; + $this->_setField('archived'); return $this; } diff --git a/src/Unstable/Types/ContentSourcesList.php b/src/Unstable/Types/ContentSourcesList.php index a1a54085..aca00603 100644 --- a/src/Unstable/Types/ContentSourcesList.php +++ b/src/Unstable/Types/ContentSourcesList.php @@ -56,6 +56,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -73,6 +74,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -90,6 +92,7 @@ public function getContentSources(): ?array public function setContentSources(?array $value = null): self { $this->contentSources = $value; + $this->_setField('contentSources'); return $this; } diff --git a/src/Unstable/Types/ConversationAttachmentFiles.php b/src/Unstable/Types/ConversationAttachmentFiles.php index 4d7a343c..669c4a0c 100644 --- a/src/Unstable/Types/ConversationAttachmentFiles.php +++ b/src/Unstable/Types/ConversationAttachmentFiles.php @@ -57,6 +57,7 @@ public function getContentType(): ?string public function setContentType(?string $value = null): self { $this->contentType = $value; + $this->_setField('contentType'); return $this; } @@ -74,6 +75,7 @@ public function getData(): ?string public function setData(?string $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } @@ -91,6 +93,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } diff --git a/src/Unstable/Types/ConversationAttributeUpdatedByAdmin.php b/src/Unstable/Types/ConversationAttributeUpdatedByAdmin.php index d55ac2c6..b6ca729c 100644 --- a/src/Unstable/Types/ConversationAttributeUpdatedByAdmin.php +++ b/src/Unstable/Types/ConversationAttributeUpdatedByAdmin.php @@ -49,6 +49,7 @@ public function getAttribute(): ?ConversationAttributeUpdatedByAdminAttribute public function setAttribute(?ConversationAttributeUpdatedByAdminAttribute $value = null): self { $this->attribute = $value; + $this->_setField('attribute'); return $this; } @@ -66,6 +67,7 @@ public function getValue(): ?ConversationAttributeUpdatedByAdminValue public function setValue(?ConversationAttributeUpdatedByAdminValue $value = null): self { $this->value = $value; + $this->_setField('value'); return $this; } diff --git a/src/Unstable/Types/ConversationAttributeUpdatedByAdminAttribute.php b/src/Unstable/Types/ConversationAttributeUpdatedByAdminAttribute.php index 87d02383..e5add50a 100644 --- a/src/Unstable/Types/ConversationAttributeUpdatedByAdminAttribute.php +++ b/src/Unstable/Types/ConversationAttributeUpdatedByAdminAttribute.php @@ -38,6 +38,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } diff --git a/src/Unstable/Types/ConversationAttributeUpdatedByAdminValue.php b/src/Unstable/Types/ConversationAttributeUpdatedByAdminValue.php index a0c5d7e6..5a479286 100644 --- a/src/Unstable/Types/ConversationAttributeUpdatedByAdminValue.php +++ b/src/Unstable/Types/ConversationAttributeUpdatedByAdminValue.php @@ -46,6 +46,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -63,6 +64,7 @@ public function getPrevious(): ?string public function setPrevious(?string $value = null): self { $this->previous = $value; + $this->_setField('previous'); return $this; } diff --git a/src/Unstable/Types/ConversationAttributeUpdatedByUser.php b/src/Unstable/Types/ConversationAttributeUpdatedByUser.php index e8d6d073..bc24efe3 100644 --- a/src/Unstable/Types/ConversationAttributeUpdatedByUser.php +++ b/src/Unstable/Types/ConversationAttributeUpdatedByUser.php @@ -49,6 +49,7 @@ public function getAttribute(): ?ConversationAttributeUpdatedByUserAttribute public function setAttribute(?ConversationAttributeUpdatedByUserAttribute $value = null): self { $this->attribute = $value; + $this->_setField('attribute'); return $this; } @@ -66,6 +67,7 @@ public function getValue(): ?ConversationAttributeUpdatedByUserValue public function setValue(?ConversationAttributeUpdatedByUserValue $value = null): self { $this->value = $value; + $this->_setField('value'); return $this; } diff --git a/src/Unstable/Types/ConversationAttributeUpdatedByUserAttribute.php b/src/Unstable/Types/ConversationAttributeUpdatedByUserAttribute.php index 490691dd..19edeaca 100644 --- a/src/Unstable/Types/ConversationAttributeUpdatedByUserAttribute.php +++ b/src/Unstable/Types/ConversationAttributeUpdatedByUserAttribute.php @@ -38,6 +38,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } diff --git a/src/Unstable/Types/ConversationAttributeUpdatedByUserValue.php b/src/Unstable/Types/ConversationAttributeUpdatedByUserValue.php index fc891717..24f5ef55 100644 --- a/src/Unstable/Types/ConversationAttributeUpdatedByUserValue.php +++ b/src/Unstable/Types/ConversationAttributeUpdatedByUserValue.php @@ -46,6 +46,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -63,6 +64,7 @@ public function getPrevious(): ?string public function setPrevious(?string $value = null): self { $this->previous = $value; + $this->_setField('previous'); return $this; } diff --git a/src/Unstable/Types/ConversationAttributeUpdatedByWorkflow.php b/src/Unstable/Types/ConversationAttributeUpdatedByWorkflow.php index d2601218..dddc0f96 100644 --- a/src/Unstable/Types/ConversationAttributeUpdatedByWorkflow.php +++ b/src/Unstable/Types/ConversationAttributeUpdatedByWorkflow.php @@ -57,6 +57,7 @@ public function getWorkflow(): ?ConversationAttributeUpdatedByWorkflowWorkflow public function setWorkflow(?ConversationAttributeUpdatedByWorkflowWorkflow $value = null): self { $this->workflow = $value; + $this->_setField('workflow'); return $this; } @@ -74,6 +75,7 @@ public function getAttribute(): ?ConversationAttributeUpdatedByWorkflowAttribute public function setAttribute(?ConversationAttributeUpdatedByWorkflowAttribute $value = null): self { $this->attribute = $value; + $this->_setField('attribute'); return $this; } @@ -91,6 +93,7 @@ public function getValue(): ?ConversationAttributeUpdatedByWorkflowValue public function setValue(?ConversationAttributeUpdatedByWorkflowValue $value = null): self { $this->value = $value; + $this->_setField('value'); return $this; } diff --git a/src/Unstable/Types/ConversationAttributeUpdatedByWorkflowAttribute.php b/src/Unstable/Types/ConversationAttributeUpdatedByWorkflowAttribute.php index 8002c16c..a5b6e01b 100644 --- a/src/Unstable/Types/ConversationAttributeUpdatedByWorkflowAttribute.php +++ b/src/Unstable/Types/ConversationAttributeUpdatedByWorkflowAttribute.php @@ -38,6 +38,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } diff --git a/src/Unstable/Types/ConversationAttributeUpdatedByWorkflowValue.php b/src/Unstable/Types/ConversationAttributeUpdatedByWorkflowValue.php index 85f6a23f..910f939a 100644 --- a/src/Unstable/Types/ConversationAttributeUpdatedByWorkflowValue.php +++ b/src/Unstable/Types/ConversationAttributeUpdatedByWorkflowValue.php @@ -38,6 +38,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } diff --git a/src/Unstable/Types/ConversationAttributeUpdatedByWorkflowWorkflow.php b/src/Unstable/Types/ConversationAttributeUpdatedByWorkflowWorkflow.php index 3a5a9d1a..1276ce71 100644 --- a/src/Unstable/Types/ConversationAttributeUpdatedByWorkflowWorkflow.php +++ b/src/Unstable/Types/ConversationAttributeUpdatedByWorkflowWorkflow.php @@ -38,6 +38,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } diff --git a/src/Unstable/Types/ConversationContacts.php b/src/Unstable/Types/ConversationContacts.php index 9175fb83..228a3894 100644 --- a/src/Unstable/Types/ConversationContacts.php +++ b/src/Unstable/Types/ConversationContacts.php @@ -50,6 +50,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -67,6 +68,7 @@ public function getContacts(): ?array public function setContacts(?array $value = null): self { $this->contacts = $value; + $this->_setField('contacts'); return $this; } diff --git a/src/Unstable/Types/ConversationDeleted.php b/src/Unstable/Types/ConversationDeleted.php index 0476628d..523f5bd3 100644 --- a/src/Unstable/Types/ConversationDeleted.php +++ b/src/Unstable/Types/ConversationDeleted.php @@ -57,6 +57,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -74,6 +75,7 @@ public function getObject(): ?string public function setObject(?string $value = null): self { $this->object = $value; + $this->_setField('object'); return $this; } @@ -91,6 +93,7 @@ public function getDeleted(): ?bool public function setDeleted(?bool $value = null): self { $this->deleted = $value; + $this->_setField('deleted'); return $this; } diff --git a/src/Unstable/Types/ConversationFirstContactReply.php b/src/Unstable/Types/ConversationFirstContactReply.php index dff63cde..36b220a2 100644 --- a/src/Unstable/Types/ConversationFirstContactReply.php +++ b/src/Unstable/Types/ConversationFirstContactReply.php @@ -57,6 +57,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -74,6 +75,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -91,6 +93,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } diff --git a/src/Unstable/Types/ConversationList.php b/src/Unstable/Types/ConversationList.php index a4ed113a..8f78491f 100644 --- a/src/Unstable/Types/ConversationList.php +++ b/src/Unstable/Types/ConversationList.php @@ -67,6 +67,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -84,6 +85,7 @@ public function getConversations(): ?array public function setConversations(?array $value = null): self { $this->conversations = $value; + $this->_setField('conversations'); return $this; } @@ -101,6 +103,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -118,6 +121,7 @@ public function getPages(): ?CursorPages public function setPages(?CursorPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } diff --git a/src/Unstable/Types/ConversationPart.php b/src/Unstable/Types/ConversationPart.php index 6be10a46..ddfbed1b 100644 --- a/src/Unstable/Types/ConversationPart.php +++ b/src/Unstable/Types/ConversationPart.php @@ -212,6 +212,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -229,6 +230,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -246,6 +248,7 @@ public function getPartType(): ?string public function setPartType(?string $value = null): self { $this->partType = $value; + $this->_setField('partType'); return $this; } @@ -263,6 +266,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -280,6 +284,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -297,6 +302,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -314,6 +320,7 @@ public function getNotifiedAt(): ?int public function setNotifiedAt(?int $value = null): self { $this->notifiedAt = $value; + $this->_setField('notifiedAt'); return $this; } @@ -331,6 +338,7 @@ public function getAssignedTo(): ?Reference public function setAssignedTo(?Reference $value = null): self { $this->assignedTo = $value; + $this->_setField('assignedTo'); return $this; } @@ -348,6 +356,7 @@ public function getAuthor(): ?ConversationPartAuthor public function setAuthor(?ConversationPartAuthor $value = null): self { $this->author = $value; + $this->_setField('author'); return $this; } @@ -365,6 +374,7 @@ public function getAttachments(): ?array public function setAttachments(?array $value = null): self { $this->attachments = $value; + $this->_setField('attachments'); return $this; } @@ -382,6 +392,7 @@ public function getExternalId(): ?string public function setExternalId(?string $value = null): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } @@ -399,6 +410,7 @@ public function getRedacted(): ?bool public function setRedacted(?bool $value = null): self { $this->redacted = $value; + $this->_setField('redacted'); return $this; } @@ -416,6 +428,7 @@ public function getEmailMessageMetadata(): ?EmailMessageMetadata public function setEmailMessageMetadata(?EmailMessageMetadata $value = null): self { $this->emailMessageMetadata = $value; + $this->_setField('emailMessageMetadata'); return $this; } @@ -433,6 +446,7 @@ public function getMetadata(): ?ConversationPartMetadata public function setMetadata(?ConversationPartMetadata $value = null): self { $this->metadata = $value; + $this->_setField('metadata'); return $this; } @@ -450,6 +464,7 @@ public function getState(): ?string public function setState(?string $value = null): self { $this->state = $value; + $this->_setField('state'); return $this; } @@ -467,6 +482,7 @@ public function getTags(): ?array public function setTags(?array $value = null): self { $this->tags = $value; + $this->_setField('tags'); return $this; } @@ -516,6 +532,7 @@ public function getEventDetails(): ConversationAttributeUpdatedByWorkflow|Conver public function setEventDetails(ConversationAttributeUpdatedByWorkflow|ConversationAttributeUpdatedByAdmin|ConversationAttributeUpdatedByUser|CustomActionStarted|CustomActionFinished|OperatorWorkflowEvent|ConversationTagsUpdated|Snoozed|PriorityChanged|ConversationSlaAppliedByRule|ConversationSlaAppliedByWorkflow|ConversationSlaTargetMissed|ConversationSlaPaused|ConversationSlaUnpaused|ConversationSlaRemoved|null $value = null): self { $this->eventDetails = $value; + $this->_setField('eventDetails'); return $this; } @@ -533,6 +550,7 @@ public function getAppPackageCode(): ?string public function setAppPackageCode(?string $value = null): self { $this->appPackageCode = $value; + $this->_setField('appPackageCode'); return $this; } diff --git a/src/Unstable/Types/ConversationPartAuthor.php b/src/Unstable/Types/ConversationPartAuthor.php index 0dca1967..e72bf70e 100644 --- a/src/Unstable/Types/ConversationPartAuthor.php +++ b/src/Unstable/Types/ConversationPartAuthor.php @@ -81,6 +81,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -98,6 +99,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -115,6 +117,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -132,6 +135,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -149,6 +153,7 @@ public function getFromAiAgent(): ?bool public function setFromAiAgent(?bool $value = null): self { $this->fromAiAgent = $value; + $this->_setField('fromAiAgent'); return $this; } @@ -166,6 +171,7 @@ public function getIsAiAnswer(): ?bool public function setIsAiAnswer(?bool $value = null): self { $this->isAiAnswer = $value; + $this->_setField('isAiAnswer'); return $this; } diff --git a/src/Unstable/Types/ConversationPartMetadata.php b/src/Unstable/Types/ConversationPartMetadata.php index 8db048ac..679cfc64 100644 --- a/src/Unstable/Types/ConversationPartMetadata.php +++ b/src/Unstable/Types/ConversationPartMetadata.php @@ -50,6 +50,7 @@ public function getQuickReplyOptions(): ?array public function setQuickReplyOptions(?array $value = null): self { $this->quickReplyOptions = $value; + $this->_setField('quickReplyOptions'); return $this; } @@ -67,6 +68,7 @@ public function getQuickReplyUuid(): ?string public function setQuickReplyUuid(?string $value = null): self { $this->quickReplyUuid = $value; + $this->_setField('quickReplyUuid'); return $this; } diff --git a/src/Unstable/Types/ConversationPartMetadataQuickReplyOptionsItem.php b/src/Unstable/Types/ConversationPartMetadataQuickReplyOptionsItem.php index 81abcf3d..2406d677 100644 --- a/src/Unstable/Types/ConversationPartMetadataQuickReplyOptionsItem.php +++ b/src/Unstable/Types/ConversationPartMetadataQuickReplyOptionsItem.php @@ -46,6 +46,7 @@ public function getTranslations(): ?array public function setTranslations(?array $value = null): self { $this->translations = $value; + $this->_setField('translations'); return $this; } diff --git a/src/Unstable/Types/ConversationParts.php b/src/Unstable/Types/ConversationParts.php index 30df2007..b05cfd1c 100644 --- a/src/Unstable/Types/ConversationParts.php +++ b/src/Unstable/Types/ConversationParts.php @@ -58,6 +58,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -75,6 +76,7 @@ public function getConversationParts(): ?array public function setConversationParts(?array $value = null): self { $this->conversationParts = $value; + $this->_setField('conversationParts'); return $this; } @@ -92,6 +94,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } diff --git a/src/Unstable/Types/ConversationRating.php b/src/Unstable/Types/ConversationRating.php index 7ad4553e..9bc58a05 100644 --- a/src/Unstable/Types/ConversationRating.php +++ b/src/Unstable/Types/ConversationRating.php @@ -81,6 +81,7 @@ public function getRating(): ?int public function setRating(?int $value = null): self { $this->rating = $value; + $this->_setField('rating'); return $this; } @@ -98,6 +99,7 @@ public function getRemark(): ?string public function setRemark(?string $value = null): self { $this->remark = $value; + $this->_setField('remark'); return $this; } @@ -115,6 +117,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -132,6 +135,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -149,6 +153,7 @@ public function getContact(): ?ContactReference public function setContact(?ContactReference $value = null): self { $this->contact = $value; + $this->_setField('contact'); return $this; } @@ -166,6 +171,7 @@ public function getTeammate(): ?Reference public function setTeammate(?Reference $value = null): self { $this->teammate = $value; + $this->_setField('teammate'); return $this; } diff --git a/src/Unstable/Types/ConversationResponseTime.php b/src/Unstable/Types/ConversationResponseTime.php index 413b5480..fc4fb2b9 100644 --- a/src/Unstable/Types/ConversationResponseTime.php +++ b/src/Unstable/Types/ConversationResponseTime.php @@ -57,6 +57,7 @@ public function getTeamId(): ?int public function setTeamId(?int $value = null): self { $this->teamId = $value; + $this->_setField('teamId'); return $this; } @@ -74,6 +75,7 @@ public function getTeamName(): ?string public function setTeamName(?string $value = null): self { $this->teamName = $value; + $this->_setField('teamName'); return $this; } @@ -91,6 +93,7 @@ public function getResponseTime(): ?int public function setResponseTime(?int $value = null): self { $this->responseTime = $value; + $this->_setField('responseTime'); return $this; } diff --git a/src/Unstable/Types/ConversationSlaAppliedByRule.php b/src/Unstable/Types/ConversationSlaAppliedByRule.php index 8781cc48..2c8669fb 100644 --- a/src/Unstable/Types/ConversationSlaAppliedByRule.php +++ b/src/Unstable/Types/ConversationSlaAppliedByRule.php @@ -49,6 +49,7 @@ public function getSlaName(): ?string public function setSlaName(?string $value = null): self { $this->slaName = $value; + $this->_setField('slaName'); return $this; } @@ -66,6 +67,7 @@ public function getSlaDefinition(): ?ConversationSlaAppliedByRuleSlaDefinition public function setSlaDefinition(?ConversationSlaAppliedByRuleSlaDefinition $value = null): self { $this->slaDefinition = $value; + $this->_setField('slaDefinition'); return $this; } diff --git a/src/Unstable/Types/ConversationSlaAppliedByRuleSlaDefinition.php b/src/Unstable/Types/ConversationSlaAppliedByRuleSlaDefinition.php index b5730c7a..cb83af02 100644 --- a/src/Unstable/Types/ConversationSlaAppliedByRuleSlaDefinition.php +++ b/src/Unstable/Types/ConversationSlaAppliedByRuleSlaDefinition.php @@ -65,6 +65,7 @@ public function getFirstReplyTime(): ?int public function setFirstReplyTime(?int $value = null): self { $this->firstReplyTime = $value; + $this->_setField('firstReplyTime'); return $this; } @@ -82,6 +83,7 @@ public function getNextReplyTime(): ?int public function setNextReplyTime(?int $value = null): self { $this->nextReplyTime = $value; + $this->_setField('nextReplyTime'); return $this; } @@ -99,6 +101,7 @@ public function getResolutionTime(): ?int public function setResolutionTime(?int $value = null): self { $this->resolutionTime = $value; + $this->_setField('resolutionTime'); return $this; } @@ -116,6 +119,7 @@ public function getTimeToClose(): ?int public function setTimeToClose(?int $value = null): self { $this->timeToClose = $value; + $this->_setField('timeToClose'); return $this; } diff --git a/src/Unstable/Types/ConversationSlaAppliedByWorkflow.php b/src/Unstable/Types/ConversationSlaAppliedByWorkflow.php index ed4356bc..2ae0c5f1 100644 --- a/src/Unstable/Types/ConversationSlaAppliedByWorkflow.php +++ b/src/Unstable/Types/ConversationSlaAppliedByWorkflow.php @@ -49,6 +49,7 @@ public function getSlaName(): ?string public function setSlaName(?string $value = null): self { $this->slaName = $value; + $this->_setField('slaName'); return $this; } @@ -66,6 +67,7 @@ public function getSlaDefinition(): ?ConversationSlaAppliedByWorkflowSlaDefiniti public function setSlaDefinition(?ConversationSlaAppliedByWorkflowSlaDefinition $value = null): self { $this->slaDefinition = $value; + $this->_setField('slaDefinition'); return $this; } diff --git a/src/Unstable/Types/ConversationSlaAppliedByWorkflowSlaDefinition.php b/src/Unstable/Types/ConversationSlaAppliedByWorkflowSlaDefinition.php index 14336c7b..24ec304b 100644 --- a/src/Unstable/Types/ConversationSlaAppliedByWorkflowSlaDefinition.php +++ b/src/Unstable/Types/ConversationSlaAppliedByWorkflowSlaDefinition.php @@ -65,6 +65,7 @@ public function getFirstReplyTime(): ?int public function setFirstReplyTime(?int $value = null): self { $this->firstReplyTime = $value; + $this->_setField('firstReplyTime'); return $this; } @@ -82,6 +83,7 @@ public function getNextReplyTime(): ?int public function setNextReplyTime(?int $value = null): self { $this->nextReplyTime = $value; + $this->_setField('nextReplyTime'); return $this; } @@ -99,6 +101,7 @@ public function getResolutionTime(): ?int public function setResolutionTime(?int $value = null): self { $this->resolutionTime = $value; + $this->_setField('resolutionTime'); return $this; } @@ -116,6 +119,7 @@ public function getTimeToClose(): ?int public function setTimeToClose(?int $value = null): self { $this->timeToClose = $value; + $this->_setField('timeToClose'); return $this; } diff --git a/src/Unstable/Types/ConversationSlaPaused.php b/src/Unstable/Types/ConversationSlaPaused.php index 68df27bc..486f3142 100644 --- a/src/Unstable/Types/ConversationSlaPaused.php +++ b/src/Unstable/Types/ConversationSlaPaused.php @@ -58,6 +58,7 @@ public function getSlaName(): ?string public function setSlaName(?string $value = null): self { $this->slaName = $value; + $this->_setField('slaName'); return $this; } @@ -75,6 +76,7 @@ public function getCurrentSlaStatus(): ?string public function setCurrentSlaStatus(?string $value = null): self { $this->currentSlaStatus = $value; + $this->_setField('currentSlaStatus'); return $this; } @@ -92,6 +94,7 @@ public function getSlaStates(): ?array public function setSlaStates(?array $value = null): self { $this->slaStates = $value; + $this->_setField('slaStates'); return $this; } diff --git a/src/Unstable/Types/ConversationSlaPausedSlaStatesValue.php b/src/Unstable/Types/ConversationSlaPausedSlaStatesValue.php index 024986c4..cee18587 100644 --- a/src/Unstable/Types/ConversationSlaPausedSlaStatesValue.php +++ b/src/Unstable/Types/ConversationSlaPausedSlaStatesValue.php @@ -46,6 +46,7 @@ public function getStatus(): ?string public function setStatus(?string $value = null): self { $this->status = $value; + $this->_setField('status'); return $this; } @@ -63,6 +64,7 @@ public function getSecondsRemaining(): ?int public function setSecondsRemaining(?int $value = null): self { $this->secondsRemaining = $value; + $this->_setField('secondsRemaining'); return $this; } diff --git a/src/Unstable/Types/ConversationSlaRemoved.php b/src/Unstable/Types/ConversationSlaRemoved.php index a446c628..72998b5a 100644 --- a/src/Unstable/Types/ConversationSlaRemoved.php +++ b/src/Unstable/Types/ConversationSlaRemoved.php @@ -41,6 +41,7 @@ public function getSlaName(): ?string public function setSlaName(?string $value = null): self { $this->slaName = $value; + $this->_setField('slaName'); return $this; } diff --git a/src/Unstable/Types/ConversationSlaTargetMissed.php b/src/Unstable/Types/ConversationSlaTargetMissed.php index f2d7213c..1bf5d93a 100644 --- a/src/Unstable/Types/ConversationSlaTargetMissed.php +++ b/src/Unstable/Types/ConversationSlaTargetMissed.php @@ -66,6 +66,7 @@ public function getSlaName(): ?string public function setSlaName(?string $value = null): self { $this->slaName = $value; + $this->_setField('slaName'); return $this; } @@ -83,6 +84,7 @@ public function getSlaTargetType(): ?string public function setSlaTargetType(?string $value = null): self { $this->slaTargetType = $value; + $this->_setField('slaTargetType'); return $this; } @@ -100,6 +102,7 @@ public function getCurrentSlaStatus(): ?string public function setCurrentSlaStatus(?string $value = null): self { $this->currentSlaStatus = $value; + $this->_setField('currentSlaStatus'); return $this; } @@ -117,6 +120,7 @@ public function getSlaStates(): ?array public function setSlaStates(?array $value = null): self { $this->slaStates = $value; + $this->_setField('slaStates'); return $this; } diff --git a/src/Unstable/Types/ConversationSlaTargetMissedSlaStatesValue.php b/src/Unstable/Types/ConversationSlaTargetMissedSlaStatesValue.php index c8aab440..707f874f 100644 --- a/src/Unstable/Types/ConversationSlaTargetMissedSlaStatesValue.php +++ b/src/Unstable/Types/ConversationSlaTargetMissedSlaStatesValue.php @@ -46,6 +46,7 @@ public function getStatus(): ?string public function setStatus(?string $value = null): self { $this->status = $value; + $this->_setField('status'); return $this; } @@ -63,6 +64,7 @@ public function getSecondsRemaining(): ?int public function setSecondsRemaining(?int $value = null): self { $this->secondsRemaining = $value; + $this->_setField('secondsRemaining'); return $this; } diff --git a/src/Unstable/Types/ConversationSlaUnpaused.php b/src/Unstable/Types/ConversationSlaUnpaused.php index 4ece2170..f3b790fe 100644 --- a/src/Unstable/Types/ConversationSlaUnpaused.php +++ b/src/Unstable/Types/ConversationSlaUnpaused.php @@ -41,6 +41,7 @@ public function getSlaName(): ?string public function setSlaName(?string $value = null): self { $this->slaName = $value; + $this->_setField('slaName'); return $this; } diff --git a/src/Unstable/Types/ConversationSource.php b/src/Unstable/Types/ConversationSource.php index 22508ba9..12c29155 100644 --- a/src/Unstable/Types/ConversationSource.php +++ b/src/Unstable/Types/ConversationSource.php @@ -106,6 +106,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -123,6 +124,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -140,6 +142,7 @@ public function getDeliveredAs(): ?string public function setDeliveredAs(?string $value = null): self { $this->deliveredAs = $value; + $this->_setField('deliveredAs'); return $this; } @@ -157,6 +160,7 @@ public function getSubject(): ?string public function setSubject(?string $value = null): self { $this->subject = $value; + $this->_setField('subject'); return $this; } @@ -174,6 +178,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -191,6 +196,7 @@ public function getAuthor(): ?ConversationPartAuthor public function setAuthor(?ConversationPartAuthor $value = null): self { $this->author = $value; + $this->_setField('author'); return $this; } @@ -208,6 +214,7 @@ public function getAttachments(): ?array public function setAttachments(?array $value = null): self { $this->attachments = $value; + $this->_setField('attachments'); return $this; } @@ -225,6 +232,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -242,6 +250,7 @@ public function getRedacted(): ?bool public function setRedacted(?bool $value = null): self { $this->redacted = $value; + $this->_setField('redacted'); return $this; } diff --git a/src/Unstable/Types/ConversationStatistics.php b/src/Unstable/Types/ConversationStatistics.php index b4d2a196..96140933 100644 --- a/src/Unstable/Types/ConversationStatistics.php +++ b/src/Unstable/Types/ConversationStatistics.php @@ -218,6 +218,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -235,6 +236,7 @@ public function getTimeToAssignment(): ?int public function setTimeToAssignment(?int $value = null): self { $this->timeToAssignment = $value; + $this->_setField('timeToAssignment'); return $this; } @@ -252,6 +254,7 @@ public function getTimeToAdminReply(): ?int public function setTimeToAdminReply(?int $value = null): self { $this->timeToAdminReply = $value; + $this->_setField('timeToAdminReply'); return $this; } @@ -269,6 +272,7 @@ public function getTimeToFirstClose(): ?int public function setTimeToFirstClose(?int $value = null): self { $this->timeToFirstClose = $value; + $this->_setField('timeToFirstClose'); return $this; } @@ -286,6 +290,7 @@ public function getTimeToLastClose(): ?int public function setTimeToLastClose(?int $value = null): self { $this->timeToLastClose = $value; + $this->_setField('timeToLastClose'); return $this; } @@ -303,6 +308,7 @@ public function getMedianTimeToReply(): ?int public function setMedianTimeToReply(?int $value = null): self { $this->medianTimeToReply = $value; + $this->_setField('medianTimeToReply'); return $this; } @@ -320,6 +326,7 @@ public function getFirstContactReplyAt(): ?int public function setFirstContactReplyAt(?int $value = null): self { $this->firstContactReplyAt = $value; + $this->_setField('firstContactReplyAt'); return $this; } @@ -337,6 +344,7 @@ public function getFirstAssignmentAt(): ?int public function setFirstAssignmentAt(?int $value = null): self { $this->firstAssignmentAt = $value; + $this->_setField('firstAssignmentAt'); return $this; } @@ -354,6 +362,7 @@ public function getFirstAdminReplyAt(): ?int public function setFirstAdminReplyAt(?int $value = null): self { $this->firstAdminReplyAt = $value; + $this->_setField('firstAdminReplyAt'); return $this; } @@ -371,6 +380,7 @@ public function getFirstCloseAt(): ?int public function setFirstCloseAt(?int $value = null): self { $this->firstCloseAt = $value; + $this->_setField('firstCloseAt'); return $this; } @@ -388,6 +398,7 @@ public function getLastAssignmentAt(): ?int public function setLastAssignmentAt(?int $value = null): self { $this->lastAssignmentAt = $value; + $this->_setField('lastAssignmentAt'); return $this; } @@ -405,6 +416,7 @@ public function getLastAssignmentAdminReplyAt(): ?int public function setLastAssignmentAdminReplyAt(?int $value = null): self { $this->lastAssignmentAdminReplyAt = $value; + $this->_setField('lastAssignmentAdminReplyAt'); return $this; } @@ -422,6 +434,7 @@ public function getLastContactReplyAt(): ?int public function setLastContactReplyAt(?int $value = null): self { $this->lastContactReplyAt = $value; + $this->_setField('lastContactReplyAt'); return $this; } @@ -439,6 +452,7 @@ public function getLastAdminReplyAt(): ?int public function setLastAdminReplyAt(?int $value = null): self { $this->lastAdminReplyAt = $value; + $this->_setField('lastAdminReplyAt'); return $this; } @@ -456,6 +470,7 @@ public function getLastCloseAt(): ?int public function setLastCloseAt(?int $value = null): self { $this->lastCloseAt = $value; + $this->_setField('lastCloseAt'); return $this; } @@ -473,6 +488,7 @@ public function getLastClosedById(): ?string public function setLastClosedById(?string $value = null): self { $this->lastClosedById = $value; + $this->_setField('lastClosedById'); return $this; } @@ -490,6 +506,7 @@ public function getCountReopens(): ?int public function setCountReopens(?int $value = null): self { $this->countReopens = $value; + $this->_setField('countReopens'); return $this; } @@ -507,6 +524,7 @@ public function getCountAssignments(): ?int public function setCountAssignments(?int $value = null): self { $this->countAssignments = $value; + $this->_setField('countAssignments'); return $this; } @@ -524,6 +542,7 @@ public function getCountConversationParts(): ?int public function setCountConversationParts(?int $value = null): self { $this->countConversationParts = $value; + $this->_setField('countConversationParts'); return $this; } @@ -541,6 +560,7 @@ public function getAssignedTeamFirstResponseTimeByTeam(): ?array public function setAssignedTeamFirstResponseTimeByTeam(?array $value = null): self { $this->assignedTeamFirstResponseTimeByTeam = $value; + $this->_setField('assignedTeamFirstResponseTimeByTeam'); return $this; } @@ -558,6 +578,7 @@ public function getAssignedTeamFirstResponseTimeInOfficeHours(): ?array public function setAssignedTeamFirstResponseTimeInOfficeHours(?array $value = null): self { $this->assignedTeamFirstResponseTimeInOfficeHours = $value; + $this->_setField('assignedTeamFirstResponseTimeInOfficeHours'); return $this; } @@ -575,6 +596,7 @@ public function getHandlingTime(): ?int public function setHandlingTime(?int $value = null): self { $this->handlingTime = $value; + $this->_setField('handlingTime'); return $this; } @@ -592,6 +614,7 @@ public function getAdjustedHandlingTime(): ?int public function setAdjustedHandlingTime(?int $value = null): self { $this->adjustedHandlingTime = $value; + $this->_setField('adjustedHandlingTime'); return $this; } diff --git a/src/Unstable/Types/ConversationTagsUpdated.php b/src/Unstable/Types/ConversationTagsUpdated.php index f1ee2ad3..978229df 100644 --- a/src/Unstable/Types/ConversationTagsUpdated.php +++ b/src/Unstable/Types/ConversationTagsUpdated.php @@ -50,6 +50,7 @@ public function getTagsAdded(): ?array public function setTagsAdded(?array $value = null): self { $this->tagsAdded = $value; + $this->_setField('tagsAdded'); return $this; } @@ -67,6 +68,7 @@ public function getTagsRemoved(): ?array public function setTagsRemoved(?array $value = null): self { $this->tagsRemoved = $value; + $this->_setField('tagsRemoved'); return $this; } diff --git a/src/Unstable/Types/ConversationTeammates.php b/src/Unstable/Types/ConversationTeammates.php index ddb5154c..28b85862 100644 --- a/src/Unstable/Types/ConversationTeammates.php +++ b/src/Unstable/Types/ConversationTeammates.php @@ -50,6 +50,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -67,6 +68,7 @@ public function getTeammates(): ?array public function setTeammates(?array $value = null): self { $this->teammates = $value; + $this->_setField('teammates'); return $this; } diff --git a/src/Unstable/Types/CreateArticleRequest.php b/src/Unstable/Types/CreateArticleRequest.php index a14c324a..9d2c3966 100644 --- a/src/Unstable/Types/CreateArticleRequest.php +++ b/src/Unstable/Types/CreateArticleRequest.php @@ -97,6 +97,7 @@ public function getTitle(): string public function setTitle(string $value): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -114,6 +115,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -131,6 +133,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -148,6 +151,7 @@ public function getAuthorId(): int public function setAuthorId(int $value): self { $this->authorId = $value; + $this->_setField('authorId'); return $this; } @@ -165,6 +169,7 @@ public function getState(): ?string public function setState(?string $value = null): self { $this->state = $value; + $this->_setField('state'); return $this; } @@ -182,6 +187,7 @@ public function getParentId(): ?int public function setParentId(?int $value = null): self { $this->parentId = $value; + $this->_setField('parentId'); return $this; } @@ -199,6 +205,7 @@ public function getParentType(): ?string public function setParentType(?string $value = null): self { $this->parentType = $value; + $this->_setField('parentType'); return $this; } @@ -216,6 +223,7 @@ public function getTranslatedContent(): ?ArticleTranslatedContent public function setTranslatedContent(?ArticleTranslatedContent $value = null): self { $this->translatedContent = $value; + $this->_setField('translatedContent'); return $this; } diff --git a/src/Unstable/Types/CreateDataAttributeRequestModel.php b/src/Unstable/Types/CreateDataAttributeRequestModel.php new file mode 100644 index 00000000..5bb2f02f --- /dev/null +++ b/src/Unstable/Types/CreateDataAttributeRequestModel.php @@ -0,0 +1,9 @@ +dataType = $value; + $this->_setField('dataType'); return $this; } diff --git a/src/Unstable/Types/CreateDataAttributeRequestOptions.php b/src/Unstable/Types/CreateDataAttributeRequestOptions.php index 8ca2779a..818c6ef6 100644 --- a/src/Unstable/Types/CreateDataAttributeRequestOptions.php +++ b/src/Unstable/Types/CreateDataAttributeRequestOptions.php @@ -47,6 +47,7 @@ public function getDataType(): ?string public function setDataType(?string $value = null): self { $this->dataType = $value; + $this->_setField('dataType'); return $this; } @@ -64,6 +65,7 @@ public function getOptions(): array public function setOptions(array $value): self { $this->options = $value; + $this->_setField('options'); return $this; } diff --git a/src/Unstable/Types/CreateDataAttributeRequestOptionsOptionsItem.php b/src/Unstable/Types/CreateDataAttributeRequestOptionsOptionsItem.php index f4f33bef..a3b28052 100644 --- a/src/Unstable/Types/CreateDataAttributeRequestOptionsOptionsItem.php +++ b/src/Unstable/Types/CreateDataAttributeRequestOptionsOptionsItem.php @@ -38,6 +38,7 @@ public function getValue(): ?string public function setValue(?string $value = null): self { $this->value = $value; + $this->_setField('value'); return $this; } diff --git a/src/Unstable/Types/CreateInternalArticleRequest.php b/src/Unstable/Types/CreateInternalArticleRequest.php index 52396465..12ba5f8f 100644 --- a/src/Unstable/Types/CreateInternalArticleRequest.php +++ b/src/Unstable/Types/CreateInternalArticleRequest.php @@ -65,6 +65,7 @@ public function getTitle(): string public function setTitle(string $value): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -82,6 +83,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -99,6 +101,7 @@ public function getAuthorId(): int public function setAuthorId(int $value): self { $this->authorId = $value; + $this->_setField('authorId'); return $this; } @@ -116,6 +119,7 @@ public function getOwnerId(): int public function setOwnerId(int $value): self { $this->ownerId = $value; + $this->_setField('ownerId'); return $this; } diff --git a/src/Unstable/Types/CreateMessageRequestFrom.php b/src/Unstable/Types/CreateMessageRequestFrom.php new file mode 100644 index 00000000..da460d0d --- /dev/null +++ b/src/Unstable/Types/CreateMessageRequestFrom.php @@ -0,0 +1,81 @@ +type = $values['type']; + $this->id = $values['id']; + } + + /** + * @return 'admin' + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param 'admin' $value + */ + public function setType(string $value): self + { + $this->type = $value; + $this->_setField('type'); + return $this; + } + + /** + * @return int + */ + public function getId(): int + { + return $this->id; + } + + /** + * @param int $value + */ + public function setId(int $value): self + { + $this->id = $value; + $this->_setField('id'); + return $this; + } + + /** + * @return string + */ + public function __toString(): string + { + return $this->toJson(); + } +} diff --git a/src/Unstable/Types/CreateMessageRequestMessageType.php b/src/Unstable/Types/CreateMessageRequestMessageType.php new file mode 100644 index 00000000..4bd0c8dc --- /dev/null +++ b/src/Unstable/Types/CreateMessageRequestMessageType.php @@ -0,0 +1,11 @@ +name = $value; + $this->_setField('name'); return $this; } @@ -123,6 +124,7 @@ public function getCompanyId(): ?string public function setCompanyId(?string $value = null): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } @@ -140,6 +142,7 @@ public function getPlan(): ?string public function setPlan(?string $value = null): self { $this->plan = $value; + $this->_setField('plan'); return $this; } @@ -157,6 +160,7 @@ public function getSize(): ?int public function setSize(?int $value = null): self { $this->size = $value; + $this->_setField('size'); return $this; } @@ -174,6 +178,7 @@ public function getWebsite(): ?string public function setWebsite(?string $value = null): self { $this->website = $value; + $this->_setField('website'); return $this; } @@ -191,6 +196,7 @@ public function getIndustry(): ?string public function setIndustry(?string $value = null): self { $this->industry = $value; + $this->_setField('industry'); return $this; } @@ -208,6 +214,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } @@ -225,6 +232,7 @@ public function getRemoteCreatedAt(): ?int public function setRemoteCreatedAt(?int $value = null): self { $this->remoteCreatedAt = $value; + $this->_setField('remoteCreatedAt'); return $this; } @@ -242,6 +250,7 @@ public function getMonthlySpend(): ?int public function setMonthlySpend(?int $value = null): self { $this->monthlySpend = $value; + $this->_setField('monthlySpend'); return $this; } diff --git a/src/Unstable/Types/CreateOrUpdateTagRequest.php b/src/Unstable/Types/CreateOrUpdateTagRequest.php index eb5f8215..27d606fa 100644 --- a/src/Unstable/Types/CreateOrUpdateTagRequest.php +++ b/src/Unstable/Types/CreateOrUpdateTagRequest.php @@ -49,6 +49,7 @@ public function getName(): string public function setName(string $value): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -66,6 +67,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } diff --git a/src/Unstable/Types/CreatePhoneSwitchRequest.php b/src/Unstable/Types/CreatePhoneSwitchRequest.php index 645f03f6..b5cf259d 100644 --- a/src/Unstable/Types/CreatePhoneSwitchRequest.php +++ b/src/Unstable/Types/CreatePhoneSwitchRequest.php @@ -62,6 +62,7 @@ public function getPhone(): string public function setPhone(string $value): self { $this->phone = $value; + $this->_setField('phone'); return $this; } @@ -89,6 +90,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } diff --git a/src/Unstable/Types/CreateTicketRequestBody.php b/src/Unstable/Types/CreateTicketRequestBody.php index 1cc0c982..ae37a2f1 100644 --- a/src/Unstable/Types/CreateTicketRequestBody.php +++ b/src/Unstable/Types/CreateTicketRequestBody.php @@ -20,12 +20,12 @@ class CreateTicketRequestBody extends JsonSerializableType /** * @var array<( - * CreateTicketRequestContactsItemId - * |CreateTicketRequestContactsItemExternalId - * |CreateTicketRequestContactsItemEmail + * CreateTicketRequestBodyContactsItemId + * |CreateTicketRequestBodyContactsItemExternalId + * |CreateTicketRequestBodyContactsItemEmail * )> $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)])] + #[JsonProperty('contacts'), ArrayType([new Union(CreateTicketRequestBodyContactsItemId::class, CreateTicketRequestBodyContactsItemExternalId::class, CreateTicketRequestBodyContactsItemEmail::class)])] private array $contacts; /** @@ -53,23 +53,23 @@ class CreateTicketRequestBody extends JsonSerializableType private ?int $createdAt; /** - * @var ?CreateTicketRequestAssignment $assignment + * @var ?CreateTicketRequestBodyAssignment $assignment */ #[JsonProperty('assignment')] - private ?CreateTicketRequestAssignment $assignment; + private ?CreateTicketRequestBodyAssignment $assignment; /** * @param array{ * ticketTypeId: string, * contacts: array<( - * CreateTicketRequestContactsItemId - * |CreateTicketRequestContactsItemExternalId - * |CreateTicketRequestContactsItemEmail + * CreateTicketRequestBodyContactsItemId + * |CreateTicketRequestBodyContactsItemExternalId + * |CreateTicketRequestBodyContactsItemEmail * )>, * conversationToLinkId?: ?string, * companyId?: ?string, * createdAt?: ?int, - * assignment?: ?CreateTicketRequestAssignment, + * assignment?: ?CreateTicketRequestBodyAssignment, * } $values */ public function __construct( @@ -97,14 +97,15 @@ public function getTicketTypeId(): string public function setTicketTypeId(string $value): self { $this->ticketTypeId = $value; + $this->_setField('ticketTypeId'); return $this; } /** * @return array<( - * CreateTicketRequestContactsItemId - * |CreateTicketRequestContactsItemExternalId - * |CreateTicketRequestContactsItemEmail + * CreateTicketRequestBodyContactsItemId + * |CreateTicketRequestBodyContactsItemExternalId + * |CreateTicketRequestBodyContactsItemEmail * )> */ public function getContacts(): array @@ -114,14 +115,15 @@ public function getContacts(): array /** * @param array<( - * CreateTicketRequestContactsItemId - * |CreateTicketRequestContactsItemExternalId - * |CreateTicketRequestContactsItemEmail + * CreateTicketRequestBodyContactsItemId + * |CreateTicketRequestBodyContactsItemExternalId + * |CreateTicketRequestBodyContactsItemEmail * )> $value */ public function setContacts(array $value): self { $this->contacts = $value; + $this->_setField('contacts'); return $this; } @@ -139,6 +141,7 @@ public function getConversationToLinkId(): ?string public function setConversationToLinkId(?string $value = null): self { $this->conversationToLinkId = $value; + $this->_setField('conversationToLinkId'); return $this; } @@ -156,6 +159,7 @@ public function getCompanyId(): ?string public function setCompanyId(?string $value = null): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } @@ -173,23 +177,25 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } /** - * @return ?CreateTicketRequestAssignment + * @return ?CreateTicketRequestBodyAssignment */ - public function getAssignment(): ?CreateTicketRequestAssignment + public function getAssignment(): ?CreateTicketRequestBodyAssignment { return $this->assignment; } /** - * @param ?CreateTicketRequestAssignment $value + * @param ?CreateTicketRequestBodyAssignment $value */ - public function setAssignment(?CreateTicketRequestAssignment $value = null): self + public function setAssignment(?CreateTicketRequestBodyAssignment $value = null): self { $this->assignment = $value; + $this->_setField('assignment'); return $this; } diff --git a/src/Unstable/Types/CreateTicketRequestAssignment.php b/src/Unstable/Types/CreateTicketRequestBodyAssignment.php similarity index 91% rename from src/Unstable/Types/CreateTicketRequestAssignment.php rename to src/Unstable/Types/CreateTicketRequestBodyAssignment.php index aae0cceb..62375847 100644 --- a/src/Unstable/Types/CreateTicketRequestAssignment.php +++ b/src/Unstable/Types/CreateTicketRequestBodyAssignment.php @@ -5,7 +5,7 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; -class CreateTicketRequestAssignment extends JsonSerializableType +class CreateTicketRequestBodyAssignment extends JsonSerializableType { /** * @var ?string $adminAssigneeId The ID of the admin to which the ticket is assigned. If not provided, the ticket will be unassigned. @@ -46,6 +46,7 @@ public function getAdminAssigneeId(): ?string public function setAdminAssigneeId(?string $value = null): self { $this->adminAssigneeId = $value; + $this->_setField('adminAssigneeId'); return $this; } @@ -63,6 +64,7 @@ public function getTeamAssigneeId(): ?string public function setTeamAssigneeId(?string $value = null): self { $this->teamAssigneeId = $value; + $this->_setField('teamAssigneeId'); return $this; } diff --git a/src/Unstable/Types/CreateTicketRequestContactsItemEmail.php b/src/Unstable/Types/CreateTicketRequestBodyContactsItemEmail.php similarity index 89% rename from src/Unstable/Types/CreateTicketRequestContactsItemEmail.php rename to src/Unstable/Types/CreateTicketRequestBodyContactsItemEmail.php index 4464d340..c011d6a9 100644 --- a/src/Unstable/Types/CreateTicketRequestContactsItemEmail.php +++ b/src/Unstable/Types/CreateTicketRequestBodyContactsItemEmail.php @@ -5,7 +5,7 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; -class CreateTicketRequestContactsItemEmail extends JsonSerializableType +class CreateTicketRequestBodyContactsItemEmail extends JsonSerializableType { /** * @var string $email The email you have defined for the contact who is being added as a participant. If a contact with this email does not exist, one will be created. @@ -38,6 +38,7 @@ public function getEmail(): string public function setEmail(string $value): self { $this->email = $value; + $this->_setField('email'); return $this; } diff --git a/src/Unstable/Types/CreateTicketRequestContactsItemExternalId.php b/src/Unstable/Types/CreateTicketRequestBodyContactsItemExternalId.php similarity index 88% rename from src/Unstable/Types/CreateTicketRequestContactsItemExternalId.php rename to src/Unstable/Types/CreateTicketRequestBodyContactsItemExternalId.php index 93055e02..b0943cf2 100644 --- a/src/Unstable/Types/CreateTicketRequestContactsItemExternalId.php +++ b/src/Unstable/Types/CreateTicketRequestBodyContactsItemExternalId.php @@ -5,7 +5,7 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; -class CreateTicketRequestContactsItemExternalId extends JsonSerializableType +class CreateTicketRequestBodyContactsItemExternalId extends JsonSerializableType { /** * @var string $externalId The external_id you have defined for the contact who is being added as a participant. @@ -38,6 +38,7 @@ public function getExternalId(): string public function setExternalId(string $value): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } diff --git a/src/Unstable/Types/CreateTicketRequestContactsItemId.php b/src/Unstable/Types/CreateTicketRequestBodyContactsItemId.php similarity index 88% rename from src/Unstable/Types/CreateTicketRequestContactsItemId.php rename to src/Unstable/Types/CreateTicketRequestBodyContactsItemId.php index a190eacd..24370228 100644 --- a/src/Unstable/Types/CreateTicketRequestContactsItemId.php +++ b/src/Unstable/Types/CreateTicketRequestBodyContactsItemId.php @@ -5,7 +5,7 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; -class CreateTicketRequestContactsItemId extends JsonSerializableType +class CreateTicketRequestBodyContactsItemId extends JsonSerializableType { /** * @var string $id The identifier for the contact as given by Intercom. @@ -38,6 +38,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } diff --git a/src/Unstable/Types/CreateTicketTypeRequest.php b/src/Unstable/Types/CreateTicketTypeRequest.php index 03ffc1eb..e59bebf5 100644 --- a/src/Unstable/Types/CreateTicketTypeRequest.php +++ b/src/Unstable/Types/CreateTicketTypeRequest.php @@ -74,6 +74,7 @@ public function getName(): string public function setName(string $value): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -91,6 +92,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -108,6 +110,7 @@ public function getCategory(): ?string public function setCategory(?string $value = null): self { $this->category = $value; + $this->_setField('category'); return $this; } @@ -125,6 +128,7 @@ public function getIcon(): ?string public function setIcon(?string $value = null): self { $this->icon = $value; + $this->_setField('icon'); return $this; } @@ -142,6 +146,7 @@ public function getIsInternal(): ?bool public function setIsInternal(?bool $value = null): self { $this->isInternal = $value; + $this->_setField('isInternal'); return $this; } diff --git a/src/Unstable/Types/CursorPages.php b/src/Unstable/Types/CursorPages.php index 817d3c1f..2582151d 100644 --- a/src/Unstable/Types/CursorPages.php +++ b/src/Unstable/Types/CursorPages.php @@ -74,6 +74,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -91,6 +92,7 @@ public function getPage(): ?int public function setPage(?int $value = null): self { $this->page = $value; + $this->_setField('page'); return $this; } @@ -108,6 +110,7 @@ public function getNext(): ?StartingAfterPaging public function setNext(?StartingAfterPaging $value = null): self { $this->next = $value; + $this->_setField('next'); return $this; } @@ -125,6 +128,7 @@ public function getPerPage(): ?int public function setPerPage(?int $value = null): self { $this->perPage = $value; + $this->_setField('perPage'); return $this; } @@ -142,6 +146,7 @@ public function getTotalPages(): ?int public function setTotalPages(?int $value = null): self { $this->totalPages = $value; + $this->_setField('totalPages'); return $this; } diff --git a/src/Unstable/Types/CustomActionFinished.php b/src/Unstable/Types/CustomActionFinished.php index 3b4c761d..aaf825f0 100644 --- a/src/Unstable/Types/CustomActionFinished.php +++ b/src/Unstable/Types/CustomActionFinished.php @@ -41,6 +41,7 @@ public function getAction(): ?CustomActionFinishedAction public function setAction(?CustomActionFinishedAction $value = null): self { $this->action = $value; + $this->_setField('action'); return $this; } diff --git a/src/Unstable/Types/CustomActionFinishedAction.php b/src/Unstable/Types/CustomActionFinishedAction.php index 7770a041..05dc76f1 100644 --- a/src/Unstable/Types/CustomActionFinishedAction.php +++ b/src/Unstable/Types/CustomActionFinishedAction.php @@ -46,6 +46,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -63,6 +64,7 @@ public function getResult(): ?string public function setResult(?string $value = null): self { $this->result = $value; + $this->_setField('result'); return $this; } diff --git a/src/Unstable/Types/CustomActionStarted.php b/src/Unstable/Types/CustomActionStarted.php index 038e50e9..20b6762e 100644 --- a/src/Unstable/Types/CustomActionStarted.php +++ b/src/Unstable/Types/CustomActionStarted.php @@ -41,6 +41,7 @@ public function getAction(): ?CustomActionStartedAction public function setAction(?CustomActionStartedAction $value = null): self { $this->action = $value; + $this->_setField('action'); return $this; } diff --git a/src/Unstable/Types/CustomActionStartedAction.php b/src/Unstable/Types/CustomActionStartedAction.php index b21c521e..02924c0c 100644 --- a/src/Unstable/Types/CustomActionStartedAction.php +++ b/src/Unstable/Types/CustomActionStartedAction.php @@ -38,6 +38,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } diff --git a/src/Unstable/Types/CustomChannelAttribute.php b/src/Unstable/Types/CustomChannelAttribute.php index 9d8a2d34..a333915c 100644 --- a/src/Unstable/Types/CustomChannelAttribute.php +++ b/src/Unstable/Types/CustomChannelAttribute.php @@ -46,6 +46,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -63,6 +64,7 @@ public function getValue(): string public function setValue(string $value): self { $this->value = $value; + $this->_setField('value'); return $this; } diff --git a/src/Unstable/Types/CustomChannelBaseEvent.php b/src/Unstable/Types/CustomChannelBaseEvent.php index d0825032..e1e57b36 100644 --- a/src/Unstable/Types/CustomChannelBaseEvent.php +++ b/src/Unstable/Types/CustomChannelBaseEvent.php @@ -54,6 +54,7 @@ public function getEventId(): string public function setEventId(string $value): self { $this->eventId = $value; + $this->_setField('eventId'); return $this; } @@ -71,6 +72,7 @@ public function getExternalConversationId(): string public function setExternalConversationId(string $value): self { $this->externalConversationId = $value; + $this->_setField('externalConversationId'); return $this; } @@ -88,6 +90,7 @@ public function getContact(): CustomChannelContact public function setContact(CustomChannelContact $value): self { $this->contact = $value; + $this->_setField('contact'); return $this; } diff --git a/src/Unstable/Types/CustomChannelContact.php b/src/Unstable/Types/CustomChannelContact.php index 714e2b3b..bf56ad33 100644 --- a/src/Unstable/Types/CustomChannelContact.php +++ b/src/Unstable/Types/CustomChannelContact.php @@ -62,6 +62,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -79,6 +80,7 @@ public function getExternalId(): string public function setExternalId(string $value): self { $this->externalId = $value; + $this->_setField('externalId'); return $this; } @@ -96,6 +98,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -113,6 +116,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } diff --git a/src/Unstable/Types/CustomChannelNotificationResponse.php b/src/Unstable/Types/CustomChannelNotificationResponse.php index e5650ef8..e130dfaa 100644 --- a/src/Unstable/Types/CustomChannelNotificationResponse.php +++ b/src/Unstable/Types/CustomChannelNotificationResponse.php @@ -62,6 +62,7 @@ public function getExternalConversationId(): string public function setExternalConversationId(string $value): self { $this->externalConversationId = $value; + $this->_setField('externalConversationId'); return $this; } @@ -79,6 +80,7 @@ public function getConversationId(): string public function setConversationId(string $value): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } @@ -96,6 +98,7 @@ public function getExternalContactId(): string public function setExternalContactId(string $value): self { $this->externalContactId = $value; + $this->_setField('externalContactId'); return $this; } @@ -113,6 +116,7 @@ public function getContactId(): string public function setContactId(string $value): self { $this->contactId = $value; + $this->_setField('contactId'); return $this; } diff --git a/src/Unstable/Types/CustomObjectInstanceDeleted.php b/src/Unstable/Types/CustomObjectInstanceDeleted.php index 383da161..ea570b74 100644 --- a/src/Unstable/Types/CustomObjectInstanceDeleted.php +++ b/src/Unstable/Types/CustomObjectInstanceDeleted.php @@ -57,6 +57,7 @@ public function getObject(): ?string public function setObject(?string $value = null): self { $this->object = $value; + $this->_setField('object'); return $this; } @@ -74,6 +75,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -91,6 +93,7 @@ public function getDeleted(): ?bool public function setDeleted(?bool $value = null): self { $this->deleted = $value; + $this->_setField('deleted'); return $this; } diff --git a/src/Unstable/Types/CustomObjectInstanceList.php b/src/Unstable/Types/CustomObjectInstanceList.php index 056978c4..ad4793df 100644 --- a/src/Unstable/Types/CustomObjectInstanceList.php +++ b/src/Unstable/Types/CustomObjectInstanceList.php @@ -52,6 +52,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -69,6 +70,7 @@ public function getInstances(): ?array public function setInstances(?array $value = null): self { $this->instances = $value; + $this->_setField('instances'); return $this; } diff --git a/src/Unstable/Types/CustomerRequestEmail.php b/src/Unstable/Types/CustomerRequestEmail.php index 0d966030..06394bee 100644 --- a/src/Unstable/Types/CustomerRequestEmail.php +++ b/src/Unstable/Types/CustomerRequestEmail.php @@ -38,6 +38,7 @@ public function getEmail(): string public function setEmail(string $value): self { $this->email = $value; + $this->_setField('email'); return $this; } diff --git a/src/Unstable/Types/CustomerRequestIntercomUserId.php b/src/Unstable/Types/CustomerRequestIntercomUserId.php index e0eda056..1bdcde81 100644 --- a/src/Unstable/Types/CustomerRequestIntercomUserId.php +++ b/src/Unstable/Types/CustomerRequestIntercomUserId.php @@ -38,6 +38,7 @@ public function getIntercomUserId(): string public function setIntercomUserId(string $value): self { $this->intercomUserId = $value; + $this->_setField('intercomUserId'); return $this; } diff --git a/src/Unstable/Types/CustomerRequestUserId.php b/src/Unstable/Types/CustomerRequestUserId.php index 390fc075..d51659c3 100644 --- a/src/Unstable/Types/CustomerRequestUserId.php +++ b/src/Unstable/Types/CustomerRequestUserId.php @@ -38,6 +38,7 @@ public function getUserId(): string public function setUserId(string $value): self { $this->userId = $value; + $this->_setField('userId'); return $this; } diff --git a/src/Unstable/Types/DataAttributeList.php b/src/Unstable/Types/DataAttributeList.php index 6be5d63b..5ed4c99f 100644 --- a/src/Unstable/Types/DataAttributeList.php +++ b/src/Unstable/Types/DataAttributeList.php @@ -51,6 +51,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -68,6 +69,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Unstable/Types/DataEventList.php b/src/Unstable/Types/DataEventList.php index f2fa5a8d..554a2fe2 100644 --- a/src/Unstable/Types/DataEventList.php +++ b/src/Unstable/Types/DataEventList.php @@ -59,6 +59,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -76,6 +77,7 @@ public function getEvents(): ?array public function setEvents(?array $value = null): self { $this->events = $value; + $this->_setField('events'); return $this; } @@ -93,6 +95,7 @@ public function getPages(): ?DataEventListPages public function setPages(?DataEventListPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } diff --git a/src/Unstable/Types/DataEventListPages.php b/src/Unstable/Types/DataEventListPages.php index 49d9b991..3650fe12 100644 --- a/src/Unstable/Types/DataEventListPages.php +++ b/src/Unstable/Types/DataEventListPages.php @@ -49,6 +49,7 @@ public function getNext(): ?string public function setNext(?string $value = null): self { $this->next = $value; + $this->_setField('next'); return $this; } @@ -66,6 +67,7 @@ public function getSince(): ?string public function setSince(?string $value = null): self { $this->since = $value; + $this->_setField('since'); return $this; } diff --git a/src/Unstable/Types/DataEventSummary.php b/src/Unstable/Types/DataEventSummary.php index 804bc3bd..58766081 100644 --- a/src/Unstable/Types/DataEventSummary.php +++ b/src/Unstable/Types/DataEventSummary.php @@ -75,6 +75,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -92,6 +93,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -109,6 +111,7 @@ public function getIntercomUserId(): ?string public function setIntercomUserId(?string $value = null): self { $this->intercomUserId = $value; + $this->_setField('intercomUserId'); return $this; } @@ -126,6 +129,7 @@ public function getUserId(): ?string public function setUserId(?string $value = null): self { $this->userId = $value; + $this->_setField('userId'); return $this; } @@ -143,6 +147,7 @@ public function getEvents(): ?array public function setEvents(?array $value = null): self { $this->events = $value; + $this->_setField('events'); return $this; } diff --git a/src/Unstable/Types/DataEventSummaryItem.php b/src/Unstable/Types/DataEventSummaryItem.php index fb79e2ed..c6d0beaa 100644 --- a/src/Unstable/Types/DataEventSummaryItem.php +++ b/src/Unstable/Types/DataEventSummaryItem.php @@ -73,6 +73,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -90,6 +91,7 @@ public function getFirst(): ?string public function setFirst(?string $value = null): self { $this->first = $value; + $this->_setField('first'); return $this; } @@ -107,6 +109,7 @@ public function getLast(): ?string public function setLast(?string $value = null): self { $this->last = $value; + $this->_setField('last'); return $this; } @@ -124,6 +127,7 @@ public function getCount(): ?int public function setCount(?int $value = null): self { $this->count = $value; + $this->_setField('count'); return $this; } @@ -141,6 +145,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } diff --git a/src/Unstable/Types/DataExportCsv.php b/src/Unstable/Types/DataExportCsv.php index 0052578a..add1994c 100644 --- a/src/Unstable/Types/DataExportCsv.php +++ b/src/Unstable/Types/DataExportCsv.php @@ -241,6 +241,7 @@ public function getUserId(): ?string public function setUserId(?string $value = null): self { $this->userId = $value; + $this->_setField('userId'); return $this; } @@ -258,6 +259,7 @@ public function getUserExternalId(): ?string public function setUserExternalId(?string $value = null): self { $this->userExternalId = $value; + $this->_setField('userExternalId'); return $this; } @@ -275,6 +277,7 @@ public function getCompanyId(): ?string public function setCompanyId(?string $value = null): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } @@ -292,6 +295,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -309,6 +313,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -326,6 +331,7 @@ public function getRulesetId(): ?string public function setRulesetId(?string $value = null): self { $this->rulesetId = $value; + $this->_setField('rulesetId'); return $this; } @@ -343,6 +349,7 @@ public function getContentId(): ?string public function setContentId(?string $value = null): self { $this->contentId = $value; + $this->_setField('contentId'); return $this; } @@ -360,6 +367,7 @@ public function getContentType(): ?string public function setContentType(?string $value = null): self { $this->contentType = $value; + $this->_setField('contentType'); return $this; } @@ -377,6 +385,7 @@ public function getContentTitle(): ?string public function setContentTitle(?string $value = null): self { $this->contentTitle = $value; + $this->_setField('contentTitle'); return $this; } @@ -394,6 +403,7 @@ public function getRulesetVersionId(): ?string public function setRulesetVersionId(?string $value = null): self { $this->rulesetVersionId = $value; + $this->_setField('rulesetVersionId'); return $this; } @@ -411,6 +421,7 @@ public function getReceiptId(): ?string public function setReceiptId(?string $value = null): self { $this->receiptId = $value; + $this->_setField('receiptId'); return $this; } @@ -428,6 +439,7 @@ public function getReceivedAt(): ?int public function setReceivedAt(?int $value = null): self { $this->receivedAt = $value; + $this->_setField('receivedAt'); return $this; } @@ -445,6 +457,7 @@ public function getSeriesId(): ?string public function setSeriesId(?string $value = null): self { $this->seriesId = $value; + $this->_setField('seriesId'); return $this; } @@ -462,6 +475,7 @@ public function getSeriesTitle(): ?string public function setSeriesTitle(?string $value = null): self { $this->seriesTitle = $value; + $this->_setField('seriesTitle'); return $this; } @@ -479,6 +493,7 @@ public function getNodeId(): ?string public function setNodeId(?string $value = null): self { $this->nodeId = $value; + $this->_setField('nodeId'); return $this; } @@ -496,6 +511,7 @@ public function getFirstReply(): ?int public function setFirstReply(?int $value = null): self { $this->firstReply = $value; + $this->_setField('firstReply'); return $this; } @@ -513,6 +529,7 @@ public function getFirstCompletion(): ?int public function setFirstCompletion(?int $value = null): self { $this->firstCompletion = $value; + $this->_setField('firstCompletion'); return $this; } @@ -530,6 +547,7 @@ public function getFirstSeriesCompletion(): ?int public function setFirstSeriesCompletion(?int $value = null): self { $this->firstSeriesCompletion = $value; + $this->_setField('firstSeriesCompletion'); return $this; } @@ -547,6 +565,7 @@ public function getFirstSeriesDisengagement(): ?int public function setFirstSeriesDisengagement(?int $value = null): self { $this->firstSeriesDisengagement = $value; + $this->_setField('firstSeriesDisengagement'); return $this; } @@ -564,6 +583,7 @@ public function getFirstSeriesExit(): ?int public function setFirstSeriesExit(?int $value = null): self { $this->firstSeriesExit = $value; + $this->_setField('firstSeriesExit'); return $this; } @@ -581,6 +601,7 @@ public function getFirstGoalSuccess(): ?int public function setFirstGoalSuccess(?int $value = null): self { $this->firstGoalSuccess = $value; + $this->_setField('firstGoalSuccess'); return $this; } @@ -598,6 +619,7 @@ public function getFirstOpen(): ?int public function setFirstOpen(?int $value = null): self { $this->firstOpen = $value; + $this->_setField('firstOpen'); return $this; } @@ -615,6 +637,7 @@ public function getFirstClick(): ?int public function setFirstClick(?int $value = null): self { $this->firstClick = $value; + $this->_setField('firstClick'); return $this; } @@ -632,6 +655,7 @@ public function getFirstDismisall(): ?int public function setFirstDismisall(?int $value = null): self { $this->firstDismisall = $value; + $this->_setField('firstDismisall'); return $this; } @@ -649,6 +673,7 @@ public function getFirstUnsubscribe(): ?int public function setFirstUnsubscribe(?int $value = null): self { $this->firstUnsubscribe = $value; + $this->_setField('firstUnsubscribe'); return $this; } @@ -666,6 +691,7 @@ public function getFirstHardBounce(): ?int public function setFirstHardBounce(?int $value = null): self { $this->firstHardBounce = $value; + $this->_setField('firstHardBounce'); return $this; } diff --git a/src/Unstable/Types/DeletedArticleObject.php b/src/Unstable/Types/DeletedArticleObject.php index 27cc40c2..146113a2 100644 --- a/src/Unstable/Types/DeletedArticleObject.php +++ b/src/Unstable/Types/DeletedArticleObject.php @@ -57,6 +57,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -74,6 +75,7 @@ public function getObject(): ?string public function setObject(?string $value = null): self { $this->object = $value; + $this->_setField('object'); return $this; } @@ -91,6 +93,7 @@ public function getDeleted(): ?bool public function setDeleted(?bool $value = null): self { $this->deleted = $value; + $this->_setField('deleted'); return $this; } diff --git a/src/Unstable/Types/DeletedCollectionObject.php b/src/Unstable/Types/DeletedCollectionObject.php index eeca73a4..43fc6695 100644 --- a/src/Unstable/Types/DeletedCollectionObject.php +++ b/src/Unstable/Types/DeletedCollectionObject.php @@ -57,6 +57,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -74,6 +75,7 @@ public function getObject(): ?string public function setObject(?string $value = null): self { $this->object = $value; + $this->_setField('object'); return $this; } @@ -91,6 +93,7 @@ public function getDeleted(): ?bool public function setDeleted(?bool $value = null): self { $this->deleted = $value; + $this->_setField('deleted'); return $this; } diff --git a/src/Unstable/Types/DeletedCompanyObject.php b/src/Unstable/Types/DeletedCompanyObject.php index d2e5c840..92507a98 100644 --- a/src/Unstable/Types/DeletedCompanyObject.php +++ b/src/Unstable/Types/DeletedCompanyObject.php @@ -57,6 +57,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -74,6 +75,7 @@ public function getObject(): ?string public function setObject(?string $value = null): self { $this->object = $value; + $this->_setField('object'); return $this; } @@ -91,6 +93,7 @@ public function getDeleted(): ?bool public function setDeleted(?bool $value = null): self { $this->deleted = $value; + $this->_setField('deleted'); return $this; } diff --git a/src/Unstable/Types/DeletedInternalArticleObject.php b/src/Unstable/Types/DeletedInternalArticleObject.php index 7d79800c..5ecdafe1 100644 --- a/src/Unstable/Types/DeletedInternalArticleObject.php +++ b/src/Unstable/Types/DeletedInternalArticleObject.php @@ -57,6 +57,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -74,6 +75,7 @@ public function getObject(): ?string public function setObject(?string $value = null): self { $this->object = $value; + $this->_setField('object'); return $this; } @@ -91,6 +93,7 @@ public function getDeleted(): ?bool public function setDeleted(?bool $value = null): self { $this->deleted = $value; + $this->_setField('deleted'); return $this; } diff --git a/src/Unstable/Types/DeletedObject.php b/src/Unstable/Types/DeletedObject.php index 745c7474..518c31e9 100644 --- a/src/Unstable/Types/DeletedObject.php +++ b/src/Unstable/Types/DeletedObject.php @@ -57,6 +57,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -74,6 +75,7 @@ public function getObject(): ?string public function setObject(?string $value = null): self { $this->object = $value; + $this->_setField('object'); return $this; } @@ -91,6 +93,7 @@ public function getDeleted(): ?bool public function setDeleted(?bool $value = null): self { $this->deleted = $value; + $this->_setField('deleted'); return $this; } diff --git a/src/Unstable/Types/EmailAddressHeader.php b/src/Unstable/Types/EmailAddressHeader.php index aae9bf68..aa3fa9a5 100644 --- a/src/Unstable/Types/EmailAddressHeader.php +++ b/src/Unstable/Types/EmailAddressHeader.php @@ -57,6 +57,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -74,6 +75,7 @@ public function getEmailAddress(): ?string public function setEmailAddress(?string $value = null): self { $this->emailAddress = $value; + $this->_setField('emailAddress'); return $this; } @@ -91,6 +93,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } diff --git a/src/Unstable/Types/EmailMessageMetadata.php b/src/Unstable/Types/EmailMessageMetadata.php index 9fb3f199..903cd027 100644 --- a/src/Unstable/Types/EmailMessageMetadata.php +++ b/src/Unstable/Types/EmailMessageMetadata.php @@ -58,6 +58,7 @@ public function getSubject(): ?string public function setSubject(?string $value = null): self { $this->subject = $value; + $this->_setField('subject'); return $this; } @@ -75,6 +76,7 @@ public function getEmailAddressHeaders(): ?array public function setEmailAddressHeaders(?array $value = null): self { $this->emailAddressHeaders = $value; + $this->_setField('emailAddressHeaders'); return $this; } @@ -92,6 +94,7 @@ public function getMessageId(): ?string public function setMessageId(?string $value = null): self { $this->messageId = $value; + $this->_setField('messageId'); return $this; } diff --git a/src/Unstable/Types/Error.php b/src/Unstable/Types/Error.php index 896c7306..0ed87d56 100644 --- a/src/Unstable/Types/Error.php +++ b/src/Unstable/Types/Error.php @@ -58,6 +58,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -75,6 +76,7 @@ public function getRequestId(): ?string public function setRequestId(?string $value = null): self { $this->requestId = $value; + $this->_setField('requestId'); return $this; } @@ -92,6 +94,7 @@ public function getErrors(): array public function setErrors(array $value): self { $this->errors = $value; + $this->_setField('errors'); return $this; } diff --git a/src/Unstable/Types/ErrorErrorsItem.php b/src/Unstable/Types/ErrorErrorsItem.php index 3856aa30..64ce3b93 100644 --- a/src/Unstable/Types/ErrorErrorsItem.php +++ b/src/Unstable/Types/ErrorErrorsItem.php @@ -54,6 +54,7 @@ public function getCode(): string public function setCode(string $value): self { $this->code = $value; + $this->_setField('code'); return $this; } @@ -71,6 +72,7 @@ public function getMessage(): ?string public function setMessage(?string $value = null): self { $this->message = $value; + $this->_setField('message'); return $this; } @@ -88,6 +90,7 @@ public function getField(): ?string public function setField(?string $value = null): self { $this->field = $value; + $this->_setField('field'); return $this; } diff --git a/src/Unstable/Types/FileAttribute.php b/src/Unstable/Types/FileAttribute.php index 78aa6c2c..b0c56dcc 100644 --- a/src/Unstable/Types/FileAttribute.php +++ b/src/Unstable/Types/FileAttribute.php @@ -89,6 +89,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -106,6 +107,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -123,6 +125,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -140,6 +143,7 @@ public function getContentType(): ?string public function setContentType(?string $value = null): self { $this->contentType = $value; + $this->_setField('contentType'); return $this; } @@ -157,6 +161,7 @@ public function getFilesize(): ?int public function setFilesize(?int $value = null): self { $this->filesize = $value; + $this->_setField('filesize'); return $this; } @@ -174,6 +179,7 @@ public function getWidth(): ?int public function setWidth(?int $value = null): self { $this->width = $value; + $this->_setField('width'); return $this; } @@ -191,6 +197,7 @@ public function getHeight(): ?int public function setHeight(?int $value = null): self { $this->height = $value; + $this->_setField('height'); return $this; } diff --git a/src/Unstable/Types/GroupContent.php b/src/Unstable/Types/GroupContent.php index 50881191..6e741ea2 100644 --- a/src/Unstable/Types/GroupContent.php +++ b/src/Unstable/Types/GroupContent.php @@ -57,6 +57,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -74,6 +75,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -91,6 +93,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } diff --git a/src/Unstable/Types/GroupTranslatedContent.php b/src/Unstable/Types/GroupTranslatedContent.php index dcba90ad..da894ca2 100644 --- a/src/Unstable/Types/GroupTranslatedContent.php +++ b/src/Unstable/Types/GroupTranslatedContent.php @@ -337,6 +337,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -354,6 +355,7 @@ public function getAr(): ?GroupContent public function setAr(?GroupContent $value = null): self { $this->ar = $value; + $this->_setField('ar'); return $this; } @@ -371,6 +373,7 @@ public function getBg(): ?GroupContent public function setBg(?GroupContent $value = null): self { $this->bg = $value; + $this->_setField('bg'); return $this; } @@ -388,6 +391,7 @@ public function getBs(): ?GroupContent public function setBs(?GroupContent $value = null): self { $this->bs = $value; + $this->_setField('bs'); return $this; } @@ -405,6 +409,7 @@ public function getCa(): ?GroupContent public function setCa(?GroupContent $value = null): self { $this->ca = $value; + $this->_setField('ca'); return $this; } @@ -422,6 +427,7 @@ public function getCs(): ?GroupContent public function setCs(?GroupContent $value = null): self { $this->cs = $value; + $this->_setField('cs'); return $this; } @@ -439,6 +445,7 @@ public function getDa(): ?GroupContent public function setDa(?GroupContent $value = null): self { $this->da = $value; + $this->_setField('da'); return $this; } @@ -456,6 +463,7 @@ public function getDe(): ?GroupContent public function setDe(?GroupContent $value = null): self { $this->de = $value; + $this->_setField('de'); return $this; } @@ -473,6 +481,7 @@ public function getEl(): ?GroupContent public function setEl(?GroupContent $value = null): self { $this->el = $value; + $this->_setField('el'); return $this; } @@ -490,6 +499,7 @@ public function getEn(): ?GroupContent public function setEn(?GroupContent $value = null): self { $this->en = $value; + $this->_setField('en'); return $this; } @@ -507,6 +517,7 @@ public function getEs(): ?GroupContent public function setEs(?GroupContent $value = null): self { $this->es = $value; + $this->_setField('es'); return $this; } @@ -524,6 +535,7 @@ public function getEt(): ?GroupContent public function setEt(?GroupContent $value = null): self { $this->et = $value; + $this->_setField('et'); return $this; } @@ -541,6 +553,7 @@ public function getFi(): ?GroupContent public function setFi(?GroupContent $value = null): self { $this->fi = $value; + $this->_setField('fi'); return $this; } @@ -558,6 +571,7 @@ public function getFr(): ?GroupContent public function setFr(?GroupContent $value = null): self { $this->fr = $value; + $this->_setField('fr'); return $this; } @@ -575,6 +589,7 @@ public function getHe(): ?GroupContent public function setHe(?GroupContent $value = null): self { $this->he = $value; + $this->_setField('he'); return $this; } @@ -592,6 +607,7 @@ public function getHr(): ?GroupContent public function setHr(?GroupContent $value = null): self { $this->hr = $value; + $this->_setField('hr'); return $this; } @@ -609,6 +625,7 @@ public function getHu(): ?GroupContent public function setHu(?GroupContent $value = null): self { $this->hu = $value; + $this->_setField('hu'); return $this; } @@ -626,6 +643,7 @@ public function getId(): ?GroupContent public function setId(?GroupContent $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -643,6 +661,7 @@ public function getIt(): ?GroupContent public function setIt(?GroupContent $value = null): self { $this->it = $value; + $this->_setField('it'); return $this; } @@ -660,6 +679,7 @@ public function getJa(): ?GroupContent public function setJa(?GroupContent $value = null): self { $this->ja = $value; + $this->_setField('ja'); return $this; } @@ -677,6 +697,7 @@ public function getKo(): ?GroupContent public function setKo(?GroupContent $value = null): self { $this->ko = $value; + $this->_setField('ko'); return $this; } @@ -694,6 +715,7 @@ public function getLt(): ?GroupContent public function setLt(?GroupContent $value = null): self { $this->lt = $value; + $this->_setField('lt'); return $this; } @@ -711,6 +733,7 @@ public function getLv(): ?GroupContent public function setLv(?GroupContent $value = null): self { $this->lv = $value; + $this->_setField('lv'); return $this; } @@ -728,6 +751,7 @@ public function getMn(): ?GroupContent public function setMn(?GroupContent $value = null): self { $this->mn = $value; + $this->_setField('mn'); return $this; } @@ -745,6 +769,7 @@ public function getNb(): ?GroupContent public function setNb(?GroupContent $value = null): self { $this->nb = $value; + $this->_setField('nb'); return $this; } @@ -762,6 +787,7 @@ public function getNl(): ?GroupContent public function setNl(?GroupContent $value = null): self { $this->nl = $value; + $this->_setField('nl'); return $this; } @@ -779,6 +805,7 @@ public function getPl(): ?GroupContent public function setPl(?GroupContent $value = null): self { $this->pl = $value; + $this->_setField('pl'); return $this; } @@ -796,6 +823,7 @@ public function getPt(): ?GroupContent public function setPt(?GroupContent $value = null): self { $this->pt = $value; + $this->_setField('pt'); return $this; } @@ -813,6 +841,7 @@ public function getRo(): ?GroupContent public function setRo(?GroupContent $value = null): self { $this->ro = $value; + $this->_setField('ro'); return $this; } @@ -830,6 +859,7 @@ public function getRu(): ?GroupContent public function setRu(?GroupContent $value = null): self { $this->ru = $value; + $this->_setField('ru'); return $this; } @@ -847,6 +877,7 @@ public function getSl(): ?GroupContent public function setSl(?GroupContent $value = null): self { $this->sl = $value; + $this->_setField('sl'); return $this; } @@ -864,6 +895,7 @@ public function getSr(): ?GroupContent public function setSr(?GroupContent $value = null): self { $this->sr = $value; + $this->_setField('sr'); return $this; } @@ -881,6 +913,7 @@ public function getSv(): ?GroupContent public function setSv(?GroupContent $value = null): self { $this->sv = $value; + $this->_setField('sv'); return $this; } @@ -898,6 +931,7 @@ public function getTr(): ?GroupContent public function setTr(?GroupContent $value = null): self { $this->tr = $value; + $this->_setField('tr'); return $this; } @@ -915,6 +949,7 @@ public function getVi(): ?GroupContent public function setVi(?GroupContent $value = null): self { $this->vi = $value; + $this->_setField('vi'); return $this; } @@ -932,6 +967,7 @@ public function getPtBr(): ?GroupContent public function setPtBr(?GroupContent $value = null): self { $this->ptBr = $value; + $this->_setField('ptBr'); return $this; } @@ -949,6 +985,7 @@ public function getZhCn(): ?GroupContent public function setZhCn(?GroupContent $value = null): self { $this->zhCn = $value; + $this->_setField('zhCn'); return $this; } @@ -966,6 +1003,7 @@ public function getZhTw(): ?GroupContent public function setZhTw(?GroupContent $value = null): self { $this->zhTw = $value; + $this->_setField('zhTw'); return $this; } diff --git a/src/Unstable/Types/HandlingEvent.php b/src/Unstable/Types/HandlingEvent.php index ed6810c4..4881a9da 100644 --- a/src/Unstable/Types/HandlingEvent.php +++ b/src/Unstable/Types/HandlingEvent.php @@ -67,6 +67,7 @@ public function getTeammate(): TeammateReference public function setTeammate(TeammateReference $value): self { $this->teammate = $value; + $this->_setField('teammate'); return $this; } @@ -84,6 +85,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -101,6 +103,7 @@ public function getTimestamp(): DateTime public function setTimestamp(DateTime $value): self { $this->timestamp = $value; + $this->_setField('timestamp'); return $this; } @@ -118,6 +121,7 @@ public function getReason(): ?string public function setReason(?string $value = null): self { $this->reason = $value; + $this->_setField('reason'); return $this; } diff --git a/src/Unstable/Types/HandlingEventList.php b/src/Unstable/Types/HandlingEventList.php index daf8ed9c..3af1a646 100644 --- a/src/Unstable/Types/HandlingEventList.php +++ b/src/Unstable/Types/HandlingEventList.php @@ -42,6 +42,7 @@ public function getHandlingEvents(): ?array public function setHandlingEvents(?array $value = null): self { $this->handlingEvents = $value; + $this->_setField('handlingEvents'); return $this; } diff --git a/src/Unstable/Types/InternalArticleList.php b/src/Unstable/Types/InternalArticleList.php index dcd59d83..199f4d29 100644 --- a/src/Unstable/Types/InternalArticleList.php +++ b/src/Unstable/Types/InternalArticleList.php @@ -67,6 +67,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -84,6 +85,7 @@ public function getPages(): ?CursorPages public function setPages(?CursorPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } @@ -101,6 +103,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -118,6 +121,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Unstable/Types/LinkedObject.php b/src/Unstable/Types/LinkedObject.php index 5ca5ec94..39fdc388 100644 --- a/src/Unstable/Types/LinkedObject.php +++ b/src/Unstable/Types/LinkedObject.php @@ -57,6 +57,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -74,6 +75,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -91,6 +93,7 @@ public function getCategory(): ?string public function setCategory(?string $value = null): self { $this->category = $value; + $this->_setField('category'); return $this; } diff --git a/src/Unstable/Types/LinkedObjectList.php b/src/Unstable/Types/LinkedObjectList.php index cd63d41d..1318143c 100644 --- a/src/Unstable/Types/LinkedObjectList.php +++ b/src/Unstable/Types/LinkedObjectList.php @@ -66,6 +66,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -83,6 +84,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -100,6 +102,7 @@ public function getHasMore(): ?bool public function setHasMore(?bool $value = null): self { $this->hasMore = $value; + $this->_setField('hasMore'); return $this; } @@ -117,6 +120,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Unstable/Types/MultipleFilterSearchRequest.php b/src/Unstable/Types/MultipleFilterSearchRequest.php index cc307403..c759d957 100644 --- a/src/Unstable/Types/MultipleFilterSearchRequest.php +++ b/src/Unstable/Types/MultipleFilterSearchRequest.php @@ -56,6 +56,7 @@ public function getOperator(): ?string public function setOperator(?string $value = null): self { $this->operator = $value; + $this->_setField('operator'); return $this; } @@ -79,6 +80,7 @@ public function getValue(): array|null public function setValue(array|null $value = null): self { $this->value = $value; + $this->_setField('value'); return $this; } diff --git a/src/Unstable/Types/NewsItemRequest.php b/src/Unstable/Types/NewsItemRequest.php index 966bcdeb..1445e3a4 100644 --- a/src/Unstable/Types/NewsItemRequest.php +++ b/src/Unstable/Types/NewsItemRequest.php @@ -100,6 +100,7 @@ public function getTitle(): string public function setTitle(string $value): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -117,6 +118,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -134,6 +136,7 @@ public function getSenderId(): int public function setSenderId(int $value): self { $this->senderId = $value; + $this->_setField('senderId'); return $this; } @@ -151,6 +154,7 @@ public function getState(): ?string public function setState(?string $value = null): self { $this->state = $value; + $this->_setField('state'); return $this; } @@ -168,6 +172,7 @@ public function getDeliverSilently(): ?bool public function setDeliverSilently(?bool $value = null): self { $this->deliverSilently = $value; + $this->_setField('deliverSilently'); return $this; } @@ -185,6 +190,7 @@ public function getLabels(): ?array public function setLabels(?array $value = null): self { $this->labels = $value; + $this->_setField('labels'); return $this; } @@ -202,6 +208,7 @@ public function getReactions(): ?array public function setReactions(?array $value = null): self { $this->reactions = $value; + $this->_setField('reactions'); return $this; } @@ -219,6 +226,7 @@ public function getNewsfeedAssignments(): ?array public function setNewsfeedAssignments(?array $value = null): self { $this->newsfeedAssignments = $value; + $this->_setField('newsfeedAssignments'); return $this; } diff --git a/src/Unstable/Types/NotFoundErrorBody.php b/src/Unstable/Types/NotFoundErrorBody.php index 8c32c725..77554f14 100644 --- a/src/Unstable/Types/NotFoundErrorBody.php +++ b/src/Unstable/Types/NotFoundErrorBody.php @@ -55,6 +55,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -72,6 +73,7 @@ public function getRequestId(): ?string public function setRequestId(?string $value = null): self { $this->requestId = $value; + $this->_setField('requestId'); return $this; } @@ -89,6 +91,7 @@ public function getErrors(): array public function setErrors(array $value): self { $this->errors = $value; + $this->_setField('errors'); return $this; } diff --git a/src/Unstable/Types/NotFoundErrorBodyErrorsItem.php b/src/Unstable/Types/NotFoundErrorBodyErrorsItem.php index cdd1d01f..921d2f04 100644 --- a/src/Unstable/Types/NotFoundErrorBodyErrorsItem.php +++ b/src/Unstable/Types/NotFoundErrorBodyErrorsItem.php @@ -46,6 +46,7 @@ public function getCode(): string public function setCode(string $value): self { $this->code = $value; + $this->_setField('code'); return $this; } @@ -63,6 +64,7 @@ public function getMessage(): ?string public function setMessage(?string $value = null): self { $this->message = $value; + $this->_setField('message'); return $this; } diff --git a/src/Unstable/Types/NoteList.php b/src/Unstable/Types/NoteList.php index e71c55c2..d19eeba3 100644 --- a/src/Unstable/Types/NoteList.php +++ b/src/Unstable/Types/NoteList.php @@ -67,6 +67,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -84,6 +85,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } @@ -101,6 +103,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -118,6 +121,7 @@ public function getPages(): ?CursorPages public function setPages(?CursorPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } diff --git a/src/Unstable/Types/OpenConversationRequest.php b/src/Unstable/Types/OpenConversationRequest.php index 8cc8a0b0..97b2aba4 100644 --- a/src/Unstable/Types/OpenConversationRequest.php +++ b/src/Unstable/Types/OpenConversationRequest.php @@ -41,6 +41,7 @@ public function getAdminId(): string public function setAdminId(string $value): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } diff --git a/src/Unstable/Types/OperatorWorkflowEvent.php b/src/Unstable/Types/OperatorWorkflowEvent.php index ac4d073a..9142ff00 100644 --- a/src/Unstable/Types/OperatorWorkflowEvent.php +++ b/src/Unstable/Types/OperatorWorkflowEvent.php @@ -49,6 +49,7 @@ public function getWorkflow(): ?OperatorWorkflowEventWorkflow public function setWorkflow(?OperatorWorkflowEventWorkflow $value = null): self { $this->workflow = $value; + $this->_setField('workflow'); return $this; } @@ -66,6 +67,7 @@ public function getEvent(): ?OperatorWorkflowEventEvent public function setEvent(?OperatorWorkflowEventEvent $value = null): self { $this->event = $value; + $this->_setField('event'); return $this; } diff --git a/src/Unstable/Types/OperatorWorkflowEventEvent.php b/src/Unstable/Types/OperatorWorkflowEventEvent.php index 564312ef..5e363c52 100644 --- a/src/Unstable/Types/OperatorWorkflowEventEvent.php +++ b/src/Unstable/Types/OperatorWorkflowEventEvent.php @@ -46,6 +46,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -63,6 +64,7 @@ public function getResult(): ?string public function setResult(?string $value = null): self { $this->result = $value; + $this->_setField('result'); return $this; } diff --git a/src/Unstable/Types/OperatorWorkflowEventWorkflow.php b/src/Unstable/Types/OperatorWorkflowEventWorkflow.php index 1ddb45de..b8fa5dcd 100644 --- a/src/Unstable/Types/OperatorWorkflowEventWorkflow.php +++ b/src/Unstable/Types/OperatorWorkflowEventWorkflow.php @@ -38,6 +38,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } diff --git a/src/Unstable/Types/PagesLink.php b/src/Unstable/Types/PagesLink.php index 34a945e8..98ef8a22 100644 --- a/src/Unstable/Types/PagesLink.php +++ b/src/Unstable/Types/PagesLink.php @@ -75,6 +75,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -92,6 +93,7 @@ public function getPage(): ?int public function setPage(?int $value = null): self { $this->page = $value; + $this->_setField('page'); return $this; } @@ -109,6 +111,7 @@ public function getNext(): ?string public function setNext(?string $value = null): self { $this->next = $value; + $this->_setField('next'); return $this; } @@ -126,6 +129,7 @@ public function getPerPage(): ?int public function setPerPage(?int $value = null): self { $this->perPage = $value; + $this->_setField('perPage'); return $this; } @@ -143,6 +147,7 @@ public function getTotalPages(): ?int public function setTotalPages(?int $value = null): self { $this->totalPages = $value; + $this->_setField('totalPages'); return $this; } diff --git a/src/Unstable/Types/PaginatedResponse.php b/src/Unstable/Types/PaginatedResponse.php index 3cf8fbdb..64a9b13c 100644 --- a/src/Unstable/Types/PaginatedResponse.php +++ b/src/Unstable/Types/PaginatedResponse.php @@ -66,6 +66,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -83,6 +84,7 @@ public function getPages(): ?CursorPages public function setPages(?CursorPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } @@ -100,6 +102,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -117,6 +120,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Unstable/Types/PaginatedResponseDataItem.php b/src/Unstable/Types/PaginatedResponseDataItem.php index 6663e2a4..3daa6124 100644 --- a/src/Unstable/Types/PaginatedResponseDataItem.php +++ b/src/Unstable/Types/PaginatedResponseDataItem.php @@ -6,7 +6,6 @@ use Intercom\Unstable\News\Types\NewsItem; use Intercom\Unstable\News\Types\Newsfeed; use Exception; -use Intercom\Core\Json\JsonDecoder; class PaginatedResponseDataItem extends JsonSerializableType { @@ -185,18 +184,6 @@ public function jsonSerialize(): array 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 */ diff --git a/src/Unstable/Types/PartAttachment.php b/src/Unstable/Types/PartAttachment.php index ad3d9b8a..6ecc50b3 100644 --- a/src/Unstable/Types/PartAttachment.php +++ b/src/Unstable/Types/PartAttachment.php @@ -89,6 +89,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -106,6 +107,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -123,6 +125,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } @@ -140,6 +143,7 @@ public function getContentType(): ?string public function setContentType(?string $value = null): self { $this->contentType = $value; + $this->_setField('contentType'); return $this; } @@ -157,6 +161,7 @@ public function getFilesize(): ?int public function setFilesize(?int $value = null): self { $this->filesize = $value; + $this->_setField('filesize'); return $this; } @@ -174,6 +179,7 @@ public function getWidth(): ?int public function setWidth(?int $value = null): self { $this->width = $value; + $this->_setField('width'); return $this; } @@ -191,6 +197,7 @@ public function getHeight(): ?int public function setHeight(?int $value = null): self { $this->height = $value; + $this->_setField('height'); return $this; } diff --git a/src/Unstable/Types/PhoneSwitch.php b/src/Unstable/Types/PhoneSwitch.php index a3f24921..e8324903 100644 --- a/src/Unstable/Types/PhoneSwitch.php +++ b/src/Unstable/Types/PhoneSwitch.php @@ -49,6 +49,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -66,6 +67,7 @@ public function getPhone(): ?string public function setPhone(?string $value = null): self { $this->phone = $value; + $this->_setField('phone'); return $this; } diff --git a/src/Unstable/Types/PriorityChanged.php b/src/Unstable/Types/PriorityChanged.php index 5d7ac57e..1ca24203 100644 --- a/src/Unstable/Types/PriorityChanged.php +++ b/src/Unstable/Types/PriorityChanged.php @@ -49,6 +49,7 @@ public function getCurrentPriority(): ?string public function setCurrentPriority(?string $value = null): self { $this->currentPriority = $value; + $this->_setField('currentPriority'); return $this; } @@ -66,6 +67,7 @@ public function getPreviousPriority(): ?string public function setPreviousPriority(?string $value = null): self { $this->previousPriority = $value; + $this->_setField('previousPriority'); return $this; } diff --git a/src/Unstable/Types/QuickReplyOption.php b/src/Unstable/Types/QuickReplyOption.php index 2c59861e..d5ba25c2 100644 --- a/src/Unstable/Types/QuickReplyOption.php +++ b/src/Unstable/Types/QuickReplyOption.php @@ -46,6 +46,7 @@ public function getText(): string public function setText(string $value): self { $this->text = $value; + $this->_setField('text'); return $this; } @@ -63,6 +64,7 @@ public function getUuid(): string public function setUuid(string $value): self { $this->uuid = $value; + $this->_setField('uuid'); return $this; } diff --git a/src/Unstable/Types/Recipient.php b/src/Unstable/Types/Recipient.php index 3632630d..1093e72f 100644 --- a/src/Unstable/Types/Recipient.php +++ b/src/Unstable/Types/Recipient.php @@ -49,6 +49,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -66,6 +67,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } diff --git a/src/Unstable/Types/RedactConversationRequest.php b/src/Unstable/Types/RedactConversationRequest.php index 09c48299..487ef5ef 100644 --- a/src/Unstable/Types/RedactConversationRequest.php +++ b/src/Unstable/Types/RedactConversationRequest.php @@ -4,7 +4,6 @@ use Intercom\Core\Json\JsonSerializableType; use Exception; -use Intercom\Core\Json\JsonDecoder; class RedactConversationRequest extends JsonSerializableType { @@ -183,18 +182,6 @@ public function jsonSerialize(): array 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 */ diff --git a/src/Unstable/Types/RedactConversationRequestConversationPart.php b/src/Unstable/Types/RedactConversationRequestConversationPart.php index 07c0fc9a..45151a72 100644 --- a/src/Unstable/Types/RedactConversationRequestConversationPart.php +++ b/src/Unstable/Types/RedactConversationRequestConversationPart.php @@ -49,6 +49,7 @@ public function getConversationId(): string public function setConversationId(string $value): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } @@ -66,6 +67,7 @@ public function getConversationPartId(): string public function setConversationPartId(string $value): self { $this->conversationPartId = $value; + $this->_setField('conversationPartId'); return $this; } diff --git a/src/Unstable/Types/RedactConversationRequestSource.php b/src/Unstable/Types/RedactConversationRequestSource.php index fae7f81a..ba4ff817 100644 --- a/src/Unstable/Types/RedactConversationRequestSource.php +++ b/src/Unstable/Types/RedactConversationRequestSource.php @@ -49,6 +49,7 @@ public function getConversationId(): string public function setConversationId(string $value): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } @@ -66,6 +67,7 @@ public function getSourceId(): string public function setSourceId(string $value): self { $this->sourceId = $value; + $this->_setField('sourceId'); return $this; } diff --git a/src/Unstable/Types/Reference.php b/src/Unstable/Types/Reference.php index a49061f1..9ae91a65 100644 --- a/src/Unstable/Types/Reference.php +++ b/src/Unstable/Types/Reference.php @@ -49,6 +49,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -66,6 +67,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } diff --git a/src/Unstable/Types/RegisterFinVoiceCallRequest.php b/src/Unstable/Types/RegisterFinVoiceCallRequest.php index dd755814..5f067ccc 100644 --- a/src/Unstable/Types/RegisterFinVoiceCallRequest.php +++ b/src/Unstable/Types/RegisterFinVoiceCallRequest.php @@ -66,6 +66,7 @@ public function getPhoneNumber(): string public function setPhoneNumber(string $value): self { $this->phoneNumber = $value; + $this->_setField('phoneNumber'); return $this; } @@ -83,6 +84,7 @@ public function getCallId(): string public function setCallId(string $value): self { $this->callId = $value; + $this->_setField('callId'); return $this; } @@ -100,6 +102,7 @@ public function getSource(): ?string public function setSource(?string $value = null): self { $this->source = $value; + $this->_setField('source'); return $this; } @@ -117,6 +120,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Unstable/Types/SearchRequest.php b/src/Unstable/Types/SearchRequest.php index 8dc37b08..6a3603cf 100644 --- a/src/Unstable/Types/SearchRequest.php +++ b/src/Unstable/Types/SearchRequest.php @@ -62,6 +62,7 @@ public function getQuery(): SingleFilterSearchRequest|MultipleFilterSearchReques public function setQuery(SingleFilterSearchRequest|MultipleFilterSearchRequest $value): self { $this->query = $value; + $this->_setField('query'); return $this; } @@ -79,6 +80,7 @@ public function getPagination(): ?StartingAfterPaging public function setPagination(?StartingAfterPaging $value = null): self { $this->pagination = $value; + $this->_setField('pagination'); return $this; } diff --git a/src/Unstable/Types/SegmentList.php b/src/Unstable/Types/SegmentList.php index beffdc17..48961469 100644 --- a/src/Unstable/Types/SegmentList.php +++ b/src/Unstable/Types/SegmentList.php @@ -59,6 +59,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -76,6 +77,7 @@ public function getSegments(): ?array public function setSegments(?array $value = null): self { $this->segments = $value; + $this->_setField('segments'); return $this; } @@ -93,6 +95,7 @@ public function getPages(): ?array public function setPages(?array $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } diff --git a/src/Unstable/Types/SingleFilterSearchRequest.php b/src/Unstable/Types/SingleFilterSearchRequest.php index 3e8983ba..576a859f 100644 --- a/src/Unstable/Types/SingleFilterSearchRequest.php +++ b/src/Unstable/Types/SingleFilterSearchRequest.php @@ -72,6 +72,7 @@ public function getField(): ?string public function setField(?string $value = null): self { $this->field = $value; + $this->_setField('field'); return $this; } @@ -89,6 +90,7 @@ public function getOperator(): ?string public function setOperator(?string $value = null): self { $this->operator = $value; + $this->_setField('operator'); return $this; } @@ -120,6 +122,7 @@ public function getValue(): string|int|array|null public function setValue(string|int|array|null $value = null): self { $this->value = $value; + $this->_setField('value'); return $this; } diff --git a/src/Unstable/Types/SlaApplied.php b/src/Unstable/Types/SlaApplied.php index 00992a62..2e2266e7 100644 --- a/src/Unstable/Types/SlaApplied.php +++ b/src/Unstable/Types/SlaApplied.php @@ -63,6 +63,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -80,6 +81,7 @@ public function getSlaName(): ?string public function setSlaName(?string $value = null): self { $this->slaName = $value; + $this->_setField('slaName'); return $this; } @@ -97,6 +99,7 @@ public function getSlaStatus(): ?string public function setSlaStatus(?string $value = null): self { $this->slaStatus = $value; + $this->_setField('slaStatus'); return $this; } diff --git a/src/Unstable/Types/SnoozeConversationRequest.php b/src/Unstable/Types/SnoozeConversationRequest.php index b64817fc..0f544382 100644 --- a/src/Unstable/Types/SnoozeConversationRequest.php +++ b/src/Unstable/Types/SnoozeConversationRequest.php @@ -49,6 +49,7 @@ public function getAdminId(): string public function setAdminId(string $value): self { $this->adminId = $value; + $this->_setField('adminId'); return $this; } @@ -66,6 +67,7 @@ public function getSnoozedUntil(): int public function setSnoozedUntil(int $value): self { $this->snoozedUntil = $value; + $this->_setField('snoozedUntil'); return $this; } diff --git a/src/Unstable/Types/Snoozed.php b/src/Unstable/Types/Snoozed.php index d0c34732..7ddd4d4d 100644 --- a/src/Unstable/Types/Snoozed.php +++ b/src/Unstable/Types/Snoozed.php @@ -51,6 +51,7 @@ public function getUntil(): ?string public function setUntil(?string $value = null): self { $this->until = $value; + $this->_setField('until'); return $this; } @@ -68,6 +69,7 @@ public function getCustomUntilTime(): ?DateTime public function setCustomUntilTime(?DateTime $value = null): self { $this->customUntilTime = $value; + $this->_setField('customUntilTime'); return $this; } diff --git a/src/Unstable/Types/SocialProfile.php b/src/Unstable/Types/SocialProfile.php index d4c2fa47..2744bef1 100644 --- a/src/Unstable/Types/SocialProfile.php +++ b/src/Unstable/Types/SocialProfile.php @@ -57,6 +57,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -74,6 +75,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -91,6 +93,7 @@ public function getUrl(): ?string public function setUrl(?string $value = null): self { $this->url = $value; + $this->_setField('url'); return $this; } diff --git a/src/Unstable/Types/StartingAfterPaging.php b/src/Unstable/Types/StartingAfterPaging.php index 95088542..cec96be5 100644 --- a/src/Unstable/Types/StartingAfterPaging.php +++ b/src/Unstable/Types/StartingAfterPaging.php @@ -46,6 +46,7 @@ public function getPerPage(): ?int public function setPerPage(?int $value = null): self { $this->perPage = $value; + $this->_setField('perPage'); return $this; } @@ -63,6 +64,7 @@ public function getStartingAfter(): ?string public function setStartingAfter(?string $value = null): self { $this->startingAfter = $value; + $this->_setField('startingAfter'); return $this; } diff --git a/src/Unstable/Types/SubscriptionTypeList.php b/src/Unstable/Types/SubscriptionTypeList.php index 702db284..bb9f4b78 100644 --- a/src/Unstable/Types/SubscriptionTypeList.php +++ b/src/Unstable/Types/SubscriptionTypeList.php @@ -51,6 +51,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -68,6 +69,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Unstable/Types/TagCompanyRequest.php b/src/Unstable/Types/TagCompanyRequest.php index 55f69920..abe48769 100644 --- a/src/Unstable/Types/TagCompanyRequest.php +++ b/src/Unstable/Types/TagCompanyRequest.php @@ -50,6 +50,7 @@ public function getName(): string public function setName(string $value): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -67,6 +68,7 @@ public function getCompanies(): array public function setCompanies(array $value): self { $this->companies = $value; + $this->_setField('companies'); return $this; } diff --git a/src/Unstable/Types/TagCompanyRequestCompaniesItem.php b/src/Unstable/Types/TagCompanyRequestCompaniesItem.php index 82cb3fc5..fe2ec5cb 100644 --- a/src/Unstable/Types/TagCompanyRequestCompaniesItem.php +++ b/src/Unstable/Types/TagCompanyRequestCompaniesItem.php @@ -46,6 +46,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -63,6 +64,7 @@ public function getCompanyId(): ?string public function setCompanyId(?string $value = null): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } diff --git a/src/Unstable/Types/TagList.php b/src/Unstable/Types/TagList.php index 092cba57..a8479651 100644 --- a/src/Unstable/Types/TagList.php +++ b/src/Unstable/Types/TagList.php @@ -51,6 +51,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -68,6 +69,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Unstable/Types/TagMultipleUsersRequest.php b/src/Unstable/Types/TagMultipleUsersRequest.php index 9fdc8cba..f5223f0f 100644 --- a/src/Unstable/Types/TagMultipleUsersRequest.php +++ b/src/Unstable/Types/TagMultipleUsersRequest.php @@ -50,6 +50,7 @@ public function getName(): string public function setName(string $value): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -67,6 +68,7 @@ public function getUsers(): array public function setUsers(array $value): self { $this->users = $value; + $this->_setField('users'); return $this; } diff --git a/src/Unstable/Types/TagMultipleUsersRequestUsersItem.php b/src/Unstable/Types/TagMultipleUsersRequestUsersItem.php index c35c0a53..0e0a100d 100644 --- a/src/Unstable/Types/TagMultipleUsersRequestUsersItem.php +++ b/src/Unstable/Types/TagMultipleUsersRequestUsersItem.php @@ -38,6 +38,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } diff --git a/src/Unstable/Types/Tags.php b/src/Unstable/Types/Tags.php index 64aef7eb..b2a1c4e8 100644 --- a/src/Unstable/Types/Tags.php +++ b/src/Unstable/Types/Tags.php @@ -51,6 +51,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -68,6 +69,7 @@ public function getTags(): ?array public function setTags(?array $value = null): self { $this->tags = $value; + $this->_setField('tags'); return $this; } diff --git a/src/Unstable/Types/TeamList.php b/src/Unstable/Types/TeamList.php index 2973ba2a..7d1f55f4 100644 --- a/src/Unstable/Types/TeamList.php +++ b/src/Unstable/Types/TeamList.php @@ -51,6 +51,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -68,6 +69,7 @@ public function getTeams(): ?array public function setTeams(?array $value = null): self { $this->teams = $value; + $this->_setField('teams'); return $this; } diff --git a/src/Unstable/Types/TeamPriorityLevel.php b/src/Unstable/Types/TeamPriorityLevel.php index 8a7ee6b9..fb210a6c 100644 --- a/src/Unstable/Types/TeamPriorityLevel.php +++ b/src/Unstable/Types/TeamPriorityLevel.php @@ -50,6 +50,7 @@ public function getPrimaryTeamIds(): ?array public function setPrimaryTeamIds(?array $value = null): self { $this->primaryTeamIds = $value; + $this->_setField('primaryTeamIds'); return $this; } @@ -67,6 +68,7 @@ public function getSecondaryTeamIds(): ?array public function setSecondaryTeamIds(?array $value = null): self { $this->secondaryTeamIds = $value; + $this->_setField('secondaryTeamIds'); return $this; } diff --git a/src/Unstable/Types/TeammateReference.php b/src/Unstable/Types/TeammateReference.php index ae095976..a987c6d5 100644 --- a/src/Unstable/Types/TeammateReference.php +++ b/src/Unstable/Types/TeammateReference.php @@ -65,6 +65,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -82,6 +83,7 @@ public function getId(): int public function setId(int $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -99,6 +101,7 @@ public function getName(): string public function setName(string $value): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -116,6 +119,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } diff --git a/src/Unstable/Types/TicketList.php b/src/Unstable/Types/TicketList.php index 250a1f1c..2ae76b23 100644 --- a/src/Unstable/Types/TicketList.php +++ b/src/Unstable/Types/TicketList.php @@ -68,6 +68,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -85,6 +86,7 @@ public function getTickets(): ?array public function setTickets(?array $value = null): self { $this->tickets = $value; + $this->_setField('tickets'); return $this; } @@ -102,6 +104,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -119,6 +122,7 @@ public function getPages(): ?CursorPages public function setPages(?CursorPages $value = null): self { $this->pages = $value; + $this->_setField('pages'); return $this; } diff --git a/src/Unstable/Types/TicketPartAuthor.php b/src/Unstable/Types/TicketPartAuthor.php index d555ed50..e17608cc 100644 --- a/src/Unstable/Types/TicketPartAuthor.php +++ b/src/Unstable/Types/TicketPartAuthor.php @@ -65,6 +65,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -82,6 +83,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -99,6 +101,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -116,6 +119,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } diff --git a/src/Unstable/Types/TicketParts.php b/src/Unstable/Types/TicketParts.php index edc3cf0e..0d9c3249 100644 --- a/src/Unstable/Types/TicketParts.php +++ b/src/Unstable/Types/TicketParts.php @@ -59,6 +59,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -76,6 +77,7 @@ public function getTicketParts(): ?array public function setTicketParts(?array $value = null): self { $this->ticketParts = $value; + $this->_setField('ticketParts'); return $this; } @@ -93,6 +95,7 @@ public function getTotalCount(): ?int public function setTotalCount(?int $value = null): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } diff --git a/src/Unstable/Types/TicketReply.php b/src/Unstable/Types/TicketReply.php index 9b485cb3..fe7c5c93 100644 --- a/src/Unstable/Types/TicketReply.php +++ b/src/Unstable/Types/TicketReply.php @@ -106,6 +106,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -123,6 +124,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -140,6 +142,7 @@ public function getPartType(): ?string public function setPartType(?string $value = null): self { $this->partType = $value; + $this->_setField('partType'); return $this; } @@ -157,6 +160,7 @@ public function getBody(): ?string public function setBody(?string $value = null): self { $this->body = $value; + $this->_setField('body'); return $this; } @@ -174,6 +178,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -191,6 +196,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -208,6 +214,7 @@ public function getAuthor(): ?TicketPartAuthor public function setAuthor(?TicketPartAuthor $value = null): self { $this->author = $value; + $this->_setField('author'); return $this; } @@ -225,6 +232,7 @@ public function getAttachments(): ?array public function setAttachments(?array $value = null): self { $this->attachments = $value; + $this->_setField('attachments'); return $this; } @@ -242,6 +250,7 @@ public function getRedacted(): ?bool public function setRedacted(?bool $value = null): self { $this->redacted = $value; + $this->_setField('redacted'); return $this; } diff --git a/src/Unstable/Types/TicketStateList.php b/src/Unstable/Types/TicketStateList.php index 504749f7..ac1f65e9 100644 --- a/src/Unstable/Types/TicketStateList.php +++ b/src/Unstable/Types/TicketStateList.php @@ -52,6 +52,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -69,6 +70,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Unstable/Types/TicketTypeAttribute.php b/src/Unstable/Types/TicketTypeAttribute.php index cb64800f..c7e0f251 100644 --- a/src/Unstable/Types/TicketTypeAttribute.php +++ b/src/Unstable/Types/TicketTypeAttribute.php @@ -170,6 +170,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -187,6 +188,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -204,6 +206,7 @@ public function getWorkspaceId(): ?string public function setWorkspaceId(?string $value = null): self { $this->workspaceId = $value; + $this->_setField('workspaceId'); return $this; } @@ -221,6 +224,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -238,6 +242,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -255,6 +260,7 @@ public function getDataType(): ?string public function setDataType(?string $value = null): self { $this->dataType = $value; + $this->_setField('dataType'); return $this; } @@ -272,6 +278,7 @@ public function getInputOptions(): ?array public function setInputOptions(?array $value = null): self { $this->inputOptions = $value; + $this->_setField('inputOptions'); return $this; } @@ -289,6 +296,7 @@ public function getOrder(): ?int public function setOrder(?int $value = null): self { $this->order = $value; + $this->_setField('order'); return $this; } @@ -306,6 +314,7 @@ public function getRequiredToCreate(): ?bool public function setRequiredToCreate(?bool $value = null): self { $this->requiredToCreate = $value; + $this->_setField('requiredToCreate'); return $this; } @@ -323,6 +332,7 @@ public function getRequiredToCreateForContacts(): ?bool public function setRequiredToCreateForContacts(?bool $value = null): self { $this->requiredToCreateForContacts = $value; + $this->_setField('requiredToCreateForContacts'); return $this; } @@ -340,6 +350,7 @@ public function getVisibleOnCreate(): ?bool public function setVisibleOnCreate(?bool $value = null): self { $this->visibleOnCreate = $value; + $this->_setField('visibleOnCreate'); return $this; } @@ -357,6 +368,7 @@ public function getVisibleToContacts(): ?bool public function setVisibleToContacts(?bool $value = null): self { $this->visibleToContacts = $value; + $this->_setField('visibleToContacts'); return $this; } @@ -374,6 +386,7 @@ public function getDefault(): ?bool public function setDefault(?bool $value = null): self { $this->default = $value; + $this->_setField('default'); return $this; } @@ -391,6 +404,7 @@ public function getTicketTypeId(): ?int public function setTicketTypeId(?int $value = null): self { $this->ticketTypeId = $value; + $this->_setField('ticketTypeId'); return $this; } @@ -408,6 +422,7 @@ public function getArchived(): ?bool public function setArchived(?bool $value = null): self { $this->archived = $value; + $this->_setField('archived'); return $this; } @@ -425,6 +440,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -442,6 +458,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } diff --git a/src/Unstable/Types/TicketTypeAttributeList.php b/src/Unstable/Types/TicketTypeAttributeList.php index 4f4df327..279af3c4 100644 --- a/src/Unstable/Types/TicketTypeAttributeList.php +++ b/src/Unstable/Types/TicketTypeAttributeList.php @@ -51,6 +51,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -68,6 +69,7 @@ public function getTicketTypeAttributes(): ?array public function setTicketTypeAttributes(?array $value = null): self { $this->ticketTypeAttributes = $value; + $this->_setField('ticketTypeAttributes'); return $this; } diff --git a/src/Unstable/Types/TicketTypeList.php b/src/Unstable/Types/TicketTypeList.php index 5870660c..59ea9c4e 100644 --- a/src/Unstable/Types/TicketTypeList.php +++ b/src/Unstable/Types/TicketTypeList.php @@ -52,6 +52,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -69,6 +70,7 @@ public function getData(): ?array public function setData(?array $value = null): self { $this->data = $value; + $this->_setField('data'); return $this; } diff --git a/src/Unstable/Types/Translation.php b/src/Unstable/Types/Translation.php index ac5d892b..929f5b3a 100644 --- a/src/Unstable/Types/Translation.php +++ b/src/Unstable/Types/Translation.php @@ -57,6 +57,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -74,6 +75,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -91,6 +93,7 @@ public function getLocale(): ?string public function setLocale(?string $value = null): self { $this->locale = $value; + $this->_setField('locale'); return $this; } diff --git a/src/Unstable/Types/UntagCompanyRequest.php b/src/Unstable/Types/UntagCompanyRequest.php index 8f087713..6c5324e4 100644 --- a/src/Unstable/Types/UntagCompanyRequest.php +++ b/src/Unstable/Types/UntagCompanyRequest.php @@ -50,6 +50,7 @@ public function getName(): string public function setName(string $value): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -67,6 +68,7 @@ public function getCompanies(): array public function setCompanies(array $value): self { $this->companies = $value; + $this->_setField('companies'); return $this; } diff --git a/src/Unstable/Types/UntagCompanyRequestCompaniesItem.php b/src/Unstable/Types/UntagCompanyRequestCompaniesItem.php index a24ceca4..fc31b1df 100644 --- a/src/Unstable/Types/UntagCompanyRequestCompaniesItem.php +++ b/src/Unstable/Types/UntagCompanyRequestCompaniesItem.php @@ -54,6 +54,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -71,6 +72,7 @@ public function getCompanyId(): ?string public function setCompanyId(?string $value = null): self { $this->companyId = $value; + $this->_setField('companyId'); return $this; } @@ -88,6 +90,7 @@ public function getUntag(): ?bool public function setUntag(?bool $value = null): self { $this->untag = $value; + $this->_setField('untag'); return $this; } diff --git a/src/Unstable/Types/UpdateDataAttributeRequestOptions.php b/src/Unstable/Types/UpdateDataAttributeRequestBodyOptions.php similarity index 57% rename from src/Unstable/Types/UpdateDataAttributeRequestOptions.php rename to src/Unstable/Types/UpdateDataAttributeRequestBodyOptions.php index 9b1f82f9..f4d8d29b 100644 --- a/src/Unstable/Types/UpdateDataAttributeRequestOptions.php +++ b/src/Unstable/Types/UpdateDataAttributeRequestBodyOptions.php @@ -6,17 +6,17 @@ use Intercom\Core\Json\JsonProperty; use Intercom\Core\Types\ArrayType; -class UpdateDataAttributeRequestOptions extends JsonSerializableType +class UpdateDataAttributeRequestBodyOptions extends JsonSerializableType { /** - * @var array $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. + * @var array $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])] + #[JsonProperty('options'), ArrayType([UpdateDataAttributeRequestBodyOptionsOptionsItem::class])] private array $options; /** * @param array{ - * options: array, + * options: array, * } $values */ public function __construct( @@ -26,7 +26,7 @@ public function __construct( } /** - * @return array + * @return array */ public function getOptions(): array { @@ -34,11 +34,12 @@ public function getOptions(): array } /** - * @param array $value + * @param array $value */ public function setOptions(array $value): self { $this->options = $value; + $this->_setField('options'); return $this; } diff --git a/src/Unstable/Types/UpdateDataAttributeRequestOptionsOptionsItem.php b/src/Unstable/Types/UpdateDataAttributeRequestBodyOptionsOptionsItem.php similarity index 87% rename from src/Unstable/Types/UpdateDataAttributeRequestOptionsOptionsItem.php rename to src/Unstable/Types/UpdateDataAttributeRequestBodyOptionsOptionsItem.php index 24643a45..191f5c12 100644 --- a/src/Unstable/Types/UpdateDataAttributeRequestOptionsOptionsItem.php +++ b/src/Unstable/Types/UpdateDataAttributeRequestBodyOptionsOptionsItem.php @@ -5,7 +5,7 @@ use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; -class UpdateDataAttributeRequestOptionsOptionsItem extends JsonSerializableType +class UpdateDataAttributeRequestBodyOptionsOptionsItem extends JsonSerializableType { /** * @var ?string $value @@ -38,6 +38,7 @@ public function getValue(): ?string public function setValue(?string $value = null): self { $this->value = $value; + $this->_setField('value'); return $this; } diff --git a/src/Unstable/Types/Visitor.php b/src/Unstable/Types/Visitor.php index e8f64882..62f07b25 100644 --- a/src/Unstable/Types/Visitor.php +++ b/src/Unstable/Types/Visitor.php @@ -298,6 +298,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -315,6 +316,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -332,6 +334,7 @@ public function getUserId(): ?string public function setUserId(?string $value = null): self { $this->userId = $value; + $this->_setField('userId'); return $this; } @@ -349,6 +352,7 @@ public function getAnonymous(): ?bool public function setAnonymous(?bool $value = null): self { $this->anonymous = $value; + $this->_setField('anonymous'); return $this; } @@ -366,6 +370,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } @@ -383,6 +388,7 @@ public function getPhone(): ?string public function setPhone(?string $value = null): self { $this->phone = $value; + $this->_setField('phone'); return $this; } @@ -400,6 +406,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } @@ -417,6 +424,7 @@ public function getPseudonym(): ?string public function setPseudonym(?string $value = null): self { $this->pseudonym = $value; + $this->_setField('pseudonym'); return $this; } @@ -434,6 +442,7 @@ public function getAvatar(): ?VisitorAvatar public function setAvatar(?VisitorAvatar $value = null): self { $this->avatar = $value; + $this->_setField('avatar'); return $this; } @@ -451,6 +460,7 @@ public function getAppId(): ?string public function setAppId(?string $value = null): self { $this->appId = $value; + $this->_setField('appId'); return $this; } @@ -468,6 +478,7 @@ public function getCompanies(): ?VisitorCompanies public function setCompanies(?VisitorCompanies $value = null): self { $this->companies = $value; + $this->_setField('companies'); return $this; } @@ -485,6 +496,7 @@ public function getLocationData(): ?VisitorLocationData public function setLocationData(?VisitorLocationData $value = null): self { $this->locationData = $value; + $this->_setField('locationData'); return $this; } @@ -502,6 +514,7 @@ public function getLasRequestAt(): ?int public function setLasRequestAt(?int $value = null): self { $this->lasRequestAt = $value; + $this->_setField('lasRequestAt'); return $this; } @@ -519,6 +532,7 @@ public function getCreatedAt(): ?int public function setCreatedAt(?int $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -536,6 +550,7 @@ public function getRemoteCreatedAt(): ?int public function setRemoteCreatedAt(?int $value = null): self { $this->remoteCreatedAt = $value; + $this->_setField('remoteCreatedAt'); return $this; } @@ -553,6 +568,7 @@ public function getSignedUpAt(): ?int public function setSignedUpAt(?int $value = null): self { $this->signedUpAt = $value; + $this->_setField('signedUpAt'); return $this; } @@ -570,6 +586,7 @@ public function getUpdatedAt(): ?int public function setUpdatedAt(?int $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -587,6 +604,7 @@ public function getSessionCount(): ?int public function setSessionCount(?int $value = null): self { $this->sessionCount = $value; + $this->_setField('sessionCount'); return $this; } @@ -604,6 +622,7 @@ public function getSocialProfiles(): ?VisitorSocialProfiles public function setSocialProfiles(?VisitorSocialProfiles $value = null): self { $this->socialProfiles = $value; + $this->_setField('socialProfiles'); return $this; } @@ -621,6 +640,7 @@ public function getOwnerId(): ?string public function setOwnerId(?string $value = null): self { $this->ownerId = $value; + $this->_setField('ownerId'); return $this; } @@ -638,6 +658,7 @@ public function getUnsubscribedFromEmails(): ?bool public function setUnsubscribedFromEmails(?bool $value = null): self { $this->unsubscribedFromEmails = $value; + $this->_setField('unsubscribedFromEmails'); return $this; } @@ -655,6 +676,7 @@ public function getMarkedEmailAsSpam(): ?bool public function setMarkedEmailAsSpam(?bool $value = null): self { $this->markedEmailAsSpam = $value; + $this->_setField('markedEmailAsSpam'); return $this; } @@ -672,6 +694,7 @@ public function getHasHardBounced(): ?bool public function setHasHardBounced(?bool $value = null): self { $this->hasHardBounced = $value; + $this->_setField('hasHardBounced'); return $this; } @@ -689,6 +712,7 @@ public function getTags(): ?VisitorTags public function setTags(?VisitorTags $value = null): self { $this->tags = $value; + $this->_setField('tags'); return $this; } @@ -706,6 +730,7 @@ public function getSegments(): ?VisitorSegments public function setSegments(?VisitorSegments $value = null): self { $this->segments = $value; + $this->_setField('segments'); return $this; } @@ -723,6 +748,7 @@ public function getCustomAttributes(): ?array public function setCustomAttributes(?array $value = null): self { $this->customAttributes = $value; + $this->_setField('customAttributes'); return $this; } @@ -740,6 +766,7 @@ public function getReferrer(): ?string public function setReferrer(?string $value = null): self { $this->referrer = $value; + $this->_setField('referrer'); return $this; } @@ -757,6 +784,7 @@ public function getUtmCampaign(): ?string public function setUtmCampaign(?string $value = null): self { $this->utmCampaign = $value; + $this->_setField('utmCampaign'); return $this; } @@ -774,6 +802,7 @@ public function getUtmContent(): ?string public function setUtmContent(?string $value = null): self { $this->utmContent = $value; + $this->_setField('utmContent'); return $this; } @@ -791,6 +820,7 @@ public function getUtmMedium(): ?string public function setUtmMedium(?string $value = null): self { $this->utmMedium = $value; + $this->_setField('utmMedium'); return $this; } @@ -808,6 +838,7 @@ public function getUtmSource(): ?string public function setUtmSource(?string $value = null): self { $this->utmSource = $value; + $this->_setField('utmSource'); return $this; } @@ -825,6 +856,7 @@ public function getUtmTerm(): ?string public function setUtmTerm(?string $value = null): self { $this->utmTerm = $value; + $this->_setField('utmTerm'); return $this; } @@ -842,6 +874,7 @@ public function getDoNotTrack(): ?bool public function setDoNotTrack(?bool $value = null): self { $this->doNotTrack = $value; + $this->_setField('doNotTrack'); return $this; } diff --git a/src/Unstable/Types/VisitorAvatar.php b/src/Unstable/Types/VisitorAvatar.php index f1d4cdc3..f898fc51 100644 --- a/src/Unstable/Types/VisitorAvatar.php +++ b/src/Unstable/Types/VisitorAvatar.php @@ -46,6 +46,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -63,6 +64,7 @@ public function getImageUrl(): ?string public function setImageUrl(?string $value = null): self { $this->imageUrl = $value; + $this->_setField('imageUrl'); return $this; } diff --git a/src/Unstable/Types/VisitorCompanies.php b/src/Unstable/Types/VisitorCompanies.php index 870866d3..2b7c6380 100644 --- a/src/Unstable/Types/VisitorCompanies.php +++ b/src/Unstable/Types/VisitorCompanies.php @@ -48,6 +48,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -65,6 +66,7 @@ public function getCompanies(): ?array public function setCompanies(?array $value = null): self { $this->companies = $value; + $this->_setField('companies'); return $this; } diff --git a/src/Unstable/Types/VisitorDeletedObject.php b/src/Unstable/Types/VisitorDeletedObject.php index f49bebbc..b5bfdb9c 100644 --- a/src/Unstable/Types/VisitorDeletedObject.php +++ b/src/Unstable/Types/VisitorDeletedObject.php @@ -57,6 +57,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -74,6 +75,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -91,6 +93,7 @@ public function getUserId(): ?string public function setUserId(?string $value = null): self { $this->userId = $value; + $this->_setField('userId'); return $this; } diff --git a/src/Unstable/Types/VisitorLocationData.php b/src/Unstable/Types/VisitorLocationData.php index 845943f8..e3b704ea 100644 --- a/src/Unstable/Types/VisitorLocationData.php +++ b/src/Unstable/Types/VisitorLocationData.php @@ -94,6 +94,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -111,6 +112,7 @@ public function getCityName(): ?string public function setCityName(?string $value = null): self { $this->cityName = $value; + $this->_setField('cityName'); return $this; } @@ -128,6 +130,7 @@ public function getContinentCode(): ?string public function setContinentCode(?string $value = null): self { $this->continentCode = $value; + $this->_setField('continentCode'); return $this; } @@ -145,6 +148,7 @@ public function getCountryCode(): ?string public function setCountryCode(?string $value = null): self { $this->countryCode = $value; + $this->_setField('countryCode'); return $this; } @@ -162,6 +166,7 @@ public function getCountryName(): ?string public function setCountryName(?string $value = null): self { $this->countryName = $value; + $this->_setField('countryName'); return $this; } @@ -179,6 +184,7 @@ public function getPostalCode(): ?string public function setPostalCode(?string $value = null): self { $this->postalCode = $value; + $this->_setField('postalCode'); return $this; } @@ -196,6 +202,7 @@ public function getRegionName(): ?string public function setRegionName(?string $value = null): self { $this->regionName = $value; + $this->_setField('regionName'); return $this; } @@ -213,6 +220,7 @@ public function getTimezone(): ?string public function setTimezone(?string $value = null): self { $this->timezone = $value; + $this->_setField('timezone'); return $this; } diff --git a/src/Unstable/Types/VisitorSegments.php b/src/Unstable/Types/VisitorSegments.php index 9041847d..e5d07543 100644 --- a/src/Unstable/Types/VisitorSegments.php +++ b/src/Unstable/Types/VisitorSegments.php @@ -47,6 +47,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -64,6 +65,7 @@ public function getSegments(): ?array public function setSegments(?array $value = null): self { $this->segments = $value; + $this->_setField('segments'); return $this; } diff --git a/src/Unstable/Types/VisitorSocialProfiles.php b/src/Unstable/Types/VisitorSocialProfiles.php index cf957f6b..c4ca5b29 100644 --- a/src/Unstable/Types/VisitorSocialProfiles.php +++ b/src/Unstable/Types/VisitorSocialProfiles.php @@ -47,6 +47,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -64,6 +65,7 @@ public function getSocialProfiles(): ?array public function setSocialProfiles(?array $value = null): self { $this->socialProfiles = $value; + $this->_setField('socialProfiles'); return $this; } diff --git a/src/Unstable/Types/VisitorTags.php b/src/Unstable/Types/VisitorTags.php index 6dae5924..932834e7 100644 --- a/src/Unstable/Types/VisitorTags.php +++ b/src/Unstable/Types/VisitorTags.php @@ -47,6 +47,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -64,6 +65,7 @@ public function getTags(): ?array public function setTags(?array $value = null): self { $this->tags = $value; + $this->_setField('tags'); return $this; } diff --git a/src/Unstable/Types/VisitorTagsTagsItem.php b/src/Unstable/Types/VisitorTagsTagsItem.php index cdff8661..788ae8ff 100644 --- a/src/Unstable/Types/VisitorTagsTagsItem.php +++ b/src/Unstable/Types/VisitorTagsTagsItem.php @@ -54,6 +54,7 @@ public function getType(): ?string public function setType(?string $value = null): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -71,6 +72,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -88,6 +90,7 @@ public function getName(): ?string public function setName(?string $value = null): self { $this->name = $value; + $this->_setField('name'); return $this; } diff --git a/src/Unstable/Types/WhatsappMessageStatusList.php b/src/Unstable/Types/WhatsappMessageStatusList.php index 2f4dcbda..3da28ac7 100644 --- a/src/Unstable/Types/WhatsappMessageStatusList.php +++ b/src/Unstable/Types/WhatsappMessageStatusList.php @@ -71,6 +71,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -88,6 +89,7 @@ public function getRulesetId(): string public function setRulesetId(string $value): self { $this->rulesetId = $value; + $this->_setField('rulesetId'); return $this; } @@ -105,6 +107,7 @@ public function getPages(): WhatsappMessageStatusListPages public function setPages(WhatsappMessageStatusListPages $value): self { $this->pages = $value; + $this->_setField('pages'); return $this; } @@ -122,6 +125,7 @@ public function getTotalCount(): int public function setTotalCount(int $value): self { $this->totalCount = $value; + $this->_setField('totalCount'); return $this; } @@ -139,6 +143,7 @@ public function getEvents(): array public function setEvents(array $value): self { $this->events = $value; + $this->_setField('events'); return $this; } diff --git a/src/Unstable/Types/WhatsappMessageStatusListEventsItem.php b/src/Unstable/Types/WhatsappMessageStatusListEventsItem.php index 045a9ae4..49ab9da8 100644 --- a/src/Unstable/Types/WhatsappMessageStatusListEventsItem.php +++ b/src/Unstable/Types/WhatsappMessageStatusListEventsItem.php @@ -94,6 +94,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -111,6 +112,7 @@ public function getConversationId(): string public function setConversationId(string $value): self { $this->conversationId = $value; + $this->_setField('conversationId'); return $this; } @@ -128,6 +130,7 @@ public function getStatus(): string public function setStatus(string $value): self { $this->status = $value; + $this->_setField('status'); return $this; } @@ -145,6 +148,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -162,6 +166,7 @@ public function getCreatedAt(): int public function setCreatedAt(int $value): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -179,6 +184,7 @@ public function getUpdatedAt(): int public function setUpdatedAt(int $value): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -196,6 +202,7 @@ public function getWhatsappMessageId(): string public function setWhatsappMessageId(string $value): self { $this->whatsappMessageId = $value; + $this->_setField('whatsappMessageId'); return $this; } @@ -213,6 +220,7 @@ public function getTemplateName(): ?string public function setTemplateName(?string $value = null): self { $this->templateName = $value; + $this->_setField('templateName'); return $this; } diff --git a/src/Unstable/Types/WhatsappMessageStatusListPages.php b/src/Unstable/Types/WhatsappMessageStatusListPages.php index 54e5c817..6142047b 100644 --- a/src/Unstable/Types/WhatsappMessageStatusListPages.php +++ b/src/Unstable/Types/WhatsappMessageStatusListPages.php @@ -62,6 +62,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -79,6 +80,7 @@ public function getPerPage(): int public function setPerPage(int $value): self { $this->perPage = $value; + $this->_setField('perPage'); return $this; } @@ -96,6 +98,7 @@ public function getTotalPages(): int public function setTotalPages(int $value): self { $this->totalPages = $value; + $this->_setField('totalPages'); return $this; } @@ -113,6 +116,7 @@ public function getNext(): ?WhatsappMessageStatusListPagesNext public function setNext(?WhatsappMessageStatusListPagesNext $value = null): self { $this->next = $value; + $this->_setField('next'); return $this; } diff --git a/src/Unstable/Types/WhatsappMessageStatusListPagesNext.php b/src/Unstable/Types/WhatsappMessageStatusListPagesNext.php index 89dd449a..7d9c7533 100644 --- a/src/Unstable/Types/WhatsappMessageStatusListPagesNext.php +++ b/src/Unstable/Types/WhatsappMessageStatusListPagesNext.php @@ -41,6 +41,7 @@ public function getStartingAfter(): ?string public function setStartingAfter(?string $value = null): self { $this->startingAfter = $value; + $this->_setField('startingAfter'); return $this; } diff --git a/src/Unstable/Types/WorkflowExport.php b/src/Unstable/Types/WorkflowExport.php index e858e5f6..d2360314 100644 --- a/src/Unstable/Types/WorkflowExport.php +++ b/src/Unstable/Types/WorkflowExport.php @@ -67,6 +67,7 @@ public function getExportVersion(): ?string public function setExportVersion(?string $value = null): self { $this->exportVersion = $value; + $this->_setField('exportVersion'); return $this; } @@ -84,6 +85,7 @@ public function getExportedAt(): ?DateTime public function setExportedAt(?DateTime $value = null): self { $this->exportedAt = $value; + $this->_setField('exportedAt'); return $this; } @@ -101,6 +103,7 @@ public function getAppId(): ?int public function setAppId(?int $value = null): self { $this->appId = $value; + $this->_setField('appId'); return $this; } @@ -118,6 +121,7 @@ public function getWorkflow(): ?WorkflowExportWorkflow public function setWorkflow(?WorkflowExportWorkflow $value = null): self { $this->workflow = $value; + $this->_setField('workflow'); return $this; } diff --git a/src/Unstable/Types/WorkflowExportWorkflow.php b/src/Unstable/Types/WorkflowExportWorkflow.php index 19ade078..7221a556 100644 --- a/src/Unstable/Types/WorkflowExportWorkflow.php +++ b/src/Unstable/Types/WorkflowExportWorkflow.php @@ -140,6 +140,7 @@ public function getId(): ?string public function setId(?string $value = null): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -157,6 +158,7 @@ public function getTitle(): ?string public function setTitle(?string $value = null): self { $this->title = $value; + $this->_setField('title'); return $this; } @@ -174,6 +176,7 @@ public function getDescription(): ?string public function setDescription(?string $value = null): self { $this->description = $value; + $this->_setField('description'); return $this; } @@ -191,6 +194,7 @@ public function getTriggerType(): ?string public function setTriggerType(?string $value = null): self { $this->triggerType = $value; + $this->_setField('triggerType'); return $this; } @@ -208,6 +212,7 @@ public function getState(): ?string public function setState(?string $value = null): self { $this->state = $value; + $this->_setField('state'); return $this; } @@ -225,6 +230,7 @@ public function getTargetChannels(): ?array public function setTargetChannels(?array $value = null): self { $this->targetChannels = $value; + $this->_setField('targetChannels'); return $this; } @@ -242,6 +248,7 @@ public function getPreferredDevices(): ?array public function setPreferredDevices(?array $value = null): self { $this->preferredDevices = $value; + $this->_setField('preferredDevices'); return $this; } @@ -259,6 +266,7 @@ public function getCreatedAt(): ?DateTime public function setCreatedAt(?DateTime $value = null): self { $this->createdAt = $value; + $this->_setField('createdAt'); return $this; } @@ -276,6 +284,7 @@ public function getUpdatedAt(): ?DateTime public function setUpdatedAt(?DateTime $value = null): self { $this->updatedAt = $value; + $this->_setField('updatedAt'); return $this; } @@ -293,6 +302,7 @@ public function getTargeting(): ?array public function setTargeting(?array $value = null): self { $this->targeting = $value; + $this->_setField('targeting'); return $this; } @@ -310,6 +320,7 @@ public function getSnapshot(): ?array public function setSnapshot(?array $value = null): self { $this->snapshot = $value; + $this->_setField('snapshot'); return $this; } @@ -327,6 +338,7 @@ public function getAttributes(): ?array public function setAttributes(?array $value = null): self { $this->attributes = $value; + $this->_setField('attributes'); return $this; } @@ -344,6 +356,7 @@ public function getEmbeddedRules(): ?array public function setEmbeddedRules(?array $value = null): self { $this->embeddedRules = $value; + $this->_setField('embeddedRules'); return $this; } diff --git a/src/Unstable/UnstableClient.php b/src/Unstable/UnstableClient.php index bba2c916..7987fc2b 100644 --- a/src/Unstable/UnstableClient.php +++ b/src/Unstable/UnstableClient.php @@ -36,7 +36,7 @@ use Intercom\Unstable\Visitors\VisitorsClient; use Intercom\Unstable\Brands\BrandsClient; use Intercom\Unstable\Emails\EmailsClient; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; class UnstableClient diff --git a/src/Unstable/Visitors/Requests/ConvertVisitorRequest.php b/src/Unstable/Visitors/Requests/ConvertVisitorRequest.php index c866dea7..680d99e2 100644 --- a/src/Unstable/Visitors/Requests/ConvertVisitorRequest.php +++ b/src/Unstable/Visitors/Requests/ConvertVisitorRequest.php @@ -14,13 +14,17 @@ class ConvertVisitorRequest extends JsonSerializableType private string $type; /** - * @var mixed $user + * @var ( + * mixed + * ) $user The unique identifiers retained after converting or merging. */ #[JsonProperty('user')] private mixed $user; /** - * @var mixed $visitor + * @var ( + * mixed + * ) $visitor The unique identifiers to convert a single Visitor. */ #[JsonProperty('visitor')] private mixed $visitor; @@ -28,8 +32,12 @@ class ConvertVisitorRequest extends JsonSerializableType /** * @param array{ * type: string, - * user: mixed, - * visitor: mixed, + * user: ( + * mixed + * ), + * visitor: ( + * mixed + * ), * } $values */ public function __construct( @@ -54,11 +62,14 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } /** - * @return mixed + * @return ( + * mixed + * ) */ public function getUser(): mixed { @@ -66,16 +77,21 @@ public function getUser(): mixed } /** - * @param mixed $value + * @param ( + * mixed + * ) $value */ public function setUser(mixed $value): self { $this->user = $value; + $this->_setField('user'); return $this; } /** - * @return mixed + * @return ( + * mixed + * ) */ public function getVisitor(): mixed { @@ -83,11 +99,14 @@ public function getVisitor(): mixed } /** - * @param mixed $value + * @param ( + * mixed + * ) $value */ public function setVisitor(mixed $value): self { $this->visitor = $value; + $this->_setField('visitor'); return $this; } } diff --git a/src/Unstable/Visitors/Requests/RetrieveVisitorWithUserIdRequest.php b/src/Unstable/Visitors/Requests/RetrieveVisitorWithUserIdRequest.php index 3fb07738..14fa65fa 100644 --- a/src/Unstable/Visitors/Requests/RetrieveVisitorWithUserIdRequest.php +++ b/src/Unstable/Visitors/Requests/RetrieveVisitorWithUserIdRequest.php @@ -36,6 +36,7 @@ public function getUserId(): string public function setUserId(string $value): self { $this->userId = $value; + $this->_setField('userId'); return $this; } } diff --git a/src/Unstable/Visitors/VisitorsClient.php b/src/Unstable/Visitors/VisitorsClient.php index fc853134..580c11ba 100644 --- a/src/Unstable/Visitors/VisitorsClient.php +++ b/src/Unstable/Visitors/VisitorsClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\Visitors; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\Visitors\Requests\RetrieveVisitorWithUserIdRequest; use Intercom\Unstable\Types\Visitor; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Unstable\Visitors\Requests\ConvertVisitorRequest; use Intercom\Unstable\Contacts\Types\Contact; @@ -56,6 +55,15 @@ public function __construct( /** * You can fetch the details of a single visitor. * + * Example: + * ```php + * $client->visitors->find( + * new FindVisitorRequest([ + * 'userId' => 'user_id', + * ]), + * ); + * ``` + * * @param RetrieveVisitorWithUserIdRequest $request * @param ?array{ * baseUrl?: string, @@ -94,16 +102,6 @@ public function retrieveVisitorWithUserId(RetrieveVisitorWithUserIdRequest $requ } } 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); } @@ -121,7 +119,19 @@ public function retrieveVisitorWithUserId(RetrieveVisitorWithUserIdRequest $requ * * **Option 2.** You can update a visitor by passing in the `id` of the visitor in the Request body. * - * @param mixed $request + * Example: + * ```php + * $client->visitors->update( + * new UpdateVisitorRequestWithId([ + * 'id' => '6762f30c1bb69f9f2193bc5e', + * 'name' => 'Gareth Bale', + * ]), + * ); + * ``` + * + * @param ( + * mixed + * ) $request * @param ?array{ * baseUrl?: string, * maxRetries?: int, @@ -157,16 +167,6 @@ public function updateVisitor(mixed $request, ?array $options = null): ?Visitor } } 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); } @@ -184,6 +184,21 @@ public function updateVisitor(mixed $request, ?array $options = null): ?Visitor * > * > If the User exists, then the Visitor will be merged into it, the Visitor deleted and the User returned. If the User does not exist, the Visitor will be converted to a User, with the User identifiers replacing it's Visitor identifiers. * + * Example: + * ```php + * $client->unstable->visitors->convertVisitor( + * new ConvertVisitorRequest([ + * 'type' => 'user', + * 'user' => [ + * 'email' => "foo@bar.com", + * ], + * 'visitor' => [ + * 'user_id' => "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3", + * ], + * ]), + * ); + * ``` + * * @param ConvertVisitorRequest $request * @param ?array{ * baseUrl?: string, @@ -193,11 +208,11 @@ public function updateVisitor(mixed $request, ?array $options = null): ?Visitor * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Contact + * @return ?Contact * @throws IntercomException * @throws IntercomApiException */ - public function convertVisitor(ConvertVisitorRequest $request, ?array $options = null): Contact + public function convertVisitor(ConvertVisitorRequest $request, ?array $options = null): ?Contact { $options = array_merge($this->options, $options ?? []); try { @@ -213,20 +228,13 @@ public function convertVisitor(ConvertVisitorRequest $request, ?array $options = $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Contact::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); } diff --git a/src/Unstable/Workflows/Requests/ExportWorkflowRequest.php b/src/Unstable/Workflows/Requests/ExportWorkflowRequest.php index 89b4199f..eda28168 100644 --- a/src/Unstable/Workflows/Requests/ExportWorkflowRequest.php +++ b/src/Unstable/Workflows/Requests/ExportWorkflowRequest.php @@ -36,6 +36,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } } diff --git a/src/Unstable/Workflows/WorkflowsClient.php b/src/Unstable/Workflows/WorkflowsClient.php index 07c6eaa0..53d00b23 100644 --- a/src/Unstable/Workflows/WorkflowsClient.php +++ b/src/Unstable/Workflows/WorkflowsClient.php @@ -2,7 +2,7 @@ namespace Intercom\Unstable\Workflows; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Unstable\Workflows\Requests\ExportWorkflowRequest; use Intercom\Unstable\Types\WorkflowExport; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; class WorkflowsClient @@ -60,6 +59,15 @@ public function __construct( * This API is currently in the Unstable version. Its behavior may change in future releases. * {% /admonition %} * + * Example: + * ```php + * $client->unstable->workflows->exportWorkflow( + * new ExportWorkflowRequest([ + * 'id' => '12345', + * ]), + * ); + * ``` + * * @param ExportWorkflowRequest $request * @param ?array{ * baseUrl?: string, @@ -69,18 +77,18 @@ public function __construct( * queryParameters?: array, * bodyProperties?: array, * } $options - * @return WorkflowExport + * @return ?WorkflowExport * @throws IntercomException * @throws IntercomApiException */ - public function exportWorkflow(ExportWorkflowRequest $request, ?array $options = null): WorkflowExport + public function exportWorkflow(ExportWorkflowRequest $request, ?array $options = null): ?WorkflowExport { $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/workflows/{$request->getId()}", + path: "export/workflows/" . RawClient::encodePathParam($request->getId()), method: HttpMethod::GET, ), $options, @@ -88,20 +96,13 @@ public function exportWorkflow(ExportWorkflowRequest $request, ?array $options = $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return WorkflowExport::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); } diff --git a/src/Utils/File.php b/src/Utils/File.php index 2cf8934d..2ba94753 100644 --- a/src/Utils/File.php +++ b/src/Utils/File.php @@ -3,7 +3,7 @@ namespace Intercom\Utils; use Exception; -use GuzzleHttp\Psr7\Utils; +use Http\Discovery\Psr17FactoryDiscovery; use Psr\Http\Message\StreamInterface; use Intercom\Core\Multipart\MultipartFormDataPart; @@ -50,11 +50,11 @@ public static function createFromFilepath( ?string $filename = null, ?string $contentType = null, ): File { - $resource = fopen($filepath, 'r'); + $resource = @fopen($filepath, 'r'); if (!$resource) { throw new Exception("Unable to open file $filepath"); } - $stream = Utils::streamFor($resource); + $stream = Psr17FactoryDiscovery::findStreamFactory()->createStreamFromResource($resource); if (!$stream->isReadable()) { throw new Exception("File $filepath is not readable"); } @@ -79,7 +79,7 @@ public static function createFromString( ?string $contentType = null, ): File { return new self( - stream: Utils::streamFor($content), + stream: Psr17FactoryDiscovery::findStreamFactory()->createStream($content), filename: $filename, contentType: $contentType, ); @@ -95,7 +95,7 @@ public static function createFromString( public function toMultipartFormDataPart(string $name, ?string $contentType = null): MultipartFormDataPart { $contentType ??= $this->contentType; - $headers = $contentType != null + $headers = $contentType !== null ? ['Content-Type' => $contentType] : null; @@ -120,6 +120,10 @@ public function close(): void */ public function __destruct() { - $this->close(); + try { + $this->close(); + } catch (\Throwable) { + // Swallow errors during garbage collection to avoid fatal errors. + } } } diff --git a/src/Visitors/Requests/FindVisitorRequest.php b/src/Visitors/Requests/FindVisitorRequest.php index 7f24c15a..a1ae833e 100644 --- a/src/Visitors/Requests/FindVisitorRequest.php +++ b/src/Visitors/Requests/FindVisitorRequest.php @@ -36,6 +36,7 @@ public function getUserId(): string public function setUserId(string $value): self { $this->userId = $value; + $this->_setField('userId'); return $this; } } diff --git a/src/Visitors/Requests/MergeVisitorToContactRequest.php b/src/Visitors/Requests/MergeVisitorToContactRequest.php index 14745cfe..8c5d4626 100644 --- a/src/Visitors/Requests/MergeVisitorToContactRequest.php +++ b/src/Visitors/Requests/MergeVisitorToContactRequest.php @@ -74,6 +74,7 @@ public function getType(): string public function setType(string $value): self { $this->type = $value; + $this->_setField('type'); return $this; } @@ -97,6 +98,7 @@ public function getUser(): UserWithId|UserWithUserId public function setUser(UserWithId|UserWithUserId $value): self { $this->user = $value; + $this->_setField('user'); return $this; } @@ -122,6 +124,7 @@ public function getVisitor(): VisitorWithId|VisitorWithUserId|VisitorWithEmail public function setVisitor(VisitorWithId|VisitorWithUserId|VisitorWithEmail $value): self { $this->visitor = $value; + $this->_setField('visitor'); return $this; } } diff --git a/src/Visitors/Types/UserWithId.php b/src/Visitors/Types/UserWithId.php index af681c5f..0ea9226b 100644 --- a/src/Visitors/Types/UserWithId.php +++ b/src/Visitors/Types/UserWithId.php @@ -46,6 +46,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } @@ -63,6 +64,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } diff --git a/src/Visitors/Types/UserWithUserId.php b/src/Visitors/Types/UserWithUserId.php index f50a584b..83d14f1a 100644 --- a/src/Visitors/Types/UserWithUserId.php +++ b/src/Visitors/Types/UserWithUserId.php @@ -46,6 +46,7 @@ public function getUserId(): string public function setUserId(string $value): self { $this->userId = $value; + $this->_setField('userId'); return $this; } @@ -63,6 +64,7 @@ public function getEmail(): ?string public function setEmail(?string $value = null): self { $this->email = $value; + $this->_setField('email'); return $this; } diff --git a/src/Visitors/Types/VisitorWithEmail.php b/src/Visitors/Types/VisitorWithEmail.php index 6965286e..1231ef86 100644 --- a/src/Visitors/Types/VisitorWithEmail.php +++ b/src/Visitors/Types/VisitorWithEmail.php @@ -38,6 +38,7 @@ public function getEmail(): string public function setEmail(string $value): self { $this->email = $value; + $this->_setField('email'); return $this; } diff --git a/src/Visitors/Types/VisitorWithId.php b/src/Visitors/Types/VisitorWithId.php index 72aca340..b306bcd8 100644 --- a/src/Visitors/Types/VisitorWithId.php +++ b/src/Visitors/Types/VisitorWithId.php @@ -38,6 +38,7 @@ public function getId(): string public function setId(string $value): self { $this->id = $value; + $this->_setField('id'); return $this; } diff --git a/src/Visitors/Types/VisitorWithUserId.php b/src/Visitors/Types/VisitorWithUserId.php index 484af008..1efba6bf 100644 --- a/src/Visitors/Types/VisitorWithUserId.php +++ b/src/Visitors/Types/VisitorWithUserId.php @@ -38,6 +38,7 @@ public function getUserId(): string public function setUserId(string $value): self { $this->userId = $value; + $this->_setField('userId'); return $this; } diff --git a/src/Visitors/VisitorsClient.php b/src/Visitors/VisitorsClient.php index 8e758c97..557fd792 100644 --- a/src/Visitors/VisitorsClient.php +++ b/src/Visitors/VisitorsClient.php @@ -2,7 +2,7 @@ namespace Intercom\Visitors; -use GuzzleHttp\ClientInterface; +use Psr\Http\Client\ClientInterface; use Intercom\Core\Client\RawClient; use Intercom\Visitors\Requests\FindVisitorRequest; use Intercom\Types\Visitor; @@ -12,7 +12,6 @@ use Intercom\Environments; use Intercom\Core\Client\HttpMethod; use JsonException; -use GuzzleHttp\Exception\RequestException; use Psr\Http\Client\ClientExceptionInterface; use Intercom\Types\UpdateVisitorRequestWithId; use Intercom\Types\UpdateVisitorRequestWithUserId; @@ -60,6 +59,15 @@ public function __construct( /** * You can fetch the details of a single visitor. * + * Example: + * ```php + * $client->visitors->find( + * new FindVisitorRequest([ + * 'userId' => 'user_id', + * ]), + * ); + * ``` + * * @param FindVisitorRequest $request * @param ?array{ * baseUrl?: string, @@ -98,16 +106,6 @@ public function find(FindVisitorRequest $request, ?array $options = null): ?Visi } } 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); } @@ -125,6 +123,16 @@ public function find(FindVisitorRequest $request, ?array $options = null): ?Visi * * **Option 2.** You can update a visitor by passing in the `id` of the visitor in the Request body. * + * Example: + * ```php + * $client->visitors->update( + * new UpdateVisitorRequestWithId([ + * 'id' => '6762f30c1bb69f9f2193bc5e', + * 'name' => 'Gareth Bale', + * ]), + * ); + * ``` + * * @param ( * UpdateVisitorRequestWithId * |UpdateVisitorRequestWithUserId @@ -164,16 +172,6 @@ public function update(UpdateVisitorRequestWithId|UpdateVisitorRequestWithUserId } } 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); } @@ -191,6 +189,22 @@ public function update(UpdateVisitorRequestWithId|UpdateVisitorRequestWithUserId * > * > If the User exists, then the Visitor will be merged into it, the Visitor deleted and the User returned. If the User does not exist, the Visitor will be converted to a User, with the User identifiers replacing it's Visitor identifiers. * + * Example: + * ```php + * $client->unstable->visitors->convertVisitor( + * new ConvertVisitorRequest([ + * 'type' => 'user', + * 'user' => [ + * 'id' => "8a88a590-e1c3-41e2-a502-e0649dbf721c", + * 'email' => "foo@bar.com", + * ], + * 'visitor' => [ + * 'user_id' => "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3", + * ], + * ]), + * ); + * ``` + * * @param MergeVisitorToContactRequest $request * @param ?array{ * baseUrl?: string, @@ -200,11 +214,11 @@ public function update(UpdateVisitorRequestWithId|UpdateVisitorRequestWithUserId * queryParameters?: array, * bodyProperties?: array, * } $options - * @return Contact + * @return ?Contact * @throws IntercomException * @throws IntercomApiException */ - public function mergeToContact(MergeVisitorToContactRequest $request, ?array $options = null): Contact + public function mergeToContact(MergeVisitorToContactRequest $request, ?array $options = null): ?Contact { $options = array_merge($this->options, $options ?? []); try { @@ -220,20 +234,13 @@ public function mergeToContact(MergeVisitorToContactRequest $request, ?array $op $statusCode = $response->getStatusCode(); if ($statusCode >= 200 && $statusCode < 400) { $json = $response->getBody()->getContents(); + if (empty($json)) { + return null; + } return Contact::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); } diff --git a/tests/Core/Client/RawClientTest.php b/tests/Core/Client/RawClientTest.php index e2c3f2a9..6069c2ec 100644 --- a/tests/Core/Client/RawClientTest.php +++ b/tests/Core/Client/RawClientTest.php @@ -2,21 +2,23 @@ namespace Intercom\Tests\Core\Client; -use GuzzleHttp\Client; -use GuzzleHttp\Handler\MockHandler; -use GuzzleHttp\HandlerStack; -use GuzzleHttp\Promise as P; -use GuzzleHttp\Psr7\Request; -use GuzzleHttp\Psr7\Response; +use InvalidArgumentException; use PHPUnit\Framework\TestCase; use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Message\RequestInterface; +use Psr\Http\Message\ResponseInterface; use Intercom\Core\Client\HttpMethod; +use Intercom\Core\Client\HttpClientBuilder; +use Intercom\Core\Client\MockHttpClient; use Intercom\Core\Client\RawClient; -use Intercom\Core\Client\RetryMiddleware; +use Intercom\Core\Client\RetryDecoratingClient; use Intercom\Core\Json\JsonApiRequest; +use Intercom\Core\Json\JsonEncoder; use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; +use Intercom\Core\Multipart\MultipartApiRequest; +use Intercom\Core\Multipart\MultipartFormData; +use Intercom\Core\Multipart\MultipartFormDataPart; class JsonRequest extends JsonSerializableType { @@ -49,20 +51,13 @@ public function getName(): ?string class RawClientTest extends TestCase { private string $baseUrl = 'https://api.example.com'; - private MockHandler $mockHandler; + private MockHttpClient $mockClient; private RawClient $rawClient; protected function setUp(): void { - $this->mockHandler = new MockHandler(); - $handlerStack = HandlerStack::create($this->mockHandler); - // since the client is constructed manually, we need to add the retry middleware manually - $handlerStack->push(RetryMiddleware::create([ - 'maxRetries' => 0, - 'baseDelay' => 0, - ])); - $client = new Client(['handler' => $handlerStack]); - $this->rawClient = new RawClient(['client' => $client]); + $this->mockClient = new MockHttpClient(); + $this->rawClient = new RawClient(['client' => $this->mockClient, 'maxRetries' => 0]); } /** @@ -70,7 +65,7 @@ protected function setUp(): void */ public function testHeaders(): void { - $this->mockHandler->append(new Response(200)); + $this->mockClient->append(self::createResponse(200)); $request = new JsonApiRequest( $this->baseUrl, @@ -81,8 +76,8 @@ public function testHeaders(): void $this->rawClient->sendRequest($request); - $lastRequest = $this->mockHandler->getLastRequest(); - assert($lastRequest instanceof RequestInterface); + $lastRequest = $this->mockClient->getLastRequest(); + $this->assertInstanceOf(RequestInterface::class, $lastRequest); $this->assertEquals('application/json', $lastRequest->getHeaderLine('Content-Type')); $this->assertEquals('TestValue', $lastRequest->getHeaderLine('X-Custom-Header')); } @@ -92,7 +87,7 @@ public function testHeaders(): void */ public function testQueryParameters(): void { - $this->mockHandler->append(new Response(200)); + $this->mockClient->append(self::createResponse(200)); $request = new JsonApiRequest( $this->baseUrl, @@ -104,20 +99,86 @@ public function testQueryParameters(): void $this->rawClient->sendRequest($request); - $lastRequest = $this->mockHandler->getLastRequest(); - assert($lastRequest instanceof RequestInterface); + $lastRequest = $this->mockClient->getLastRequest(); + $this->assertInstanceOf(RequestInterface::class, $lastRequest); $this->assertEquals( 'https://api.example.com/test?param1=value1¶m2=a¶m2=b¶m3=true', (string)$lastRequest->getUri() ); } + public function testEncodePathParam(): void + { + $this->assertEquals('..%2Fconnections', RawClient::encodePathParam('../connections')); + $this->assertEquals('user%20id%3F', RawClient::encodePathParam('user id?')); + $this->assertEquals('user_1', RawClient::encodePathParam('user_1')); + $this->assertEquals('42', RawClient::encodePathParam(42)); + $this->assertEquals('true', RawClient::encodePathParam(true)); + $this->assertEquals('false', RawClient::encodePathParam(false)); + $this->assertEquals('', RawClient::encodePathParam(null)); + } + + /** + * @throws ClientExceptionInterface + */ + public function testEncodedPathParamDoesNotTraverse(): void + { + $this->mockClient->append(self::createResponse(200)); + + $request = new JsonApiRequest( + $this->baseUrl, + '/users/' . RawClient::encodePathParam('../connections'), + HttpMethod::GET + ); + + $this->rawClient->sendRequest($request); + + $lastRequest = $this->mockClient->getLastRequest(); + $this->assertInstanceOf(RequestInterface::class, $lastRequest); + $this->assertEquals( + 'https://api.example.com/users/..%2Fconnections', + (string)$lastRequest->getUri() + ); + } + + /** + * @throws ClientExceptionInterface + */ + public function testRejectsDotSegmentPaths(): void + { + foreach (['/plants/..', '/plants/./leaves', '/plants/../leaves/L1', '/plants/%2e%2E/leaves'] as $path) { + $request = new JsonApiRequest($this->baseUrl, $path, HttpMethod::DELETE); + try { + $this->rawClient->sendRequest($request); + $this->fail("Expected InvalidArgumentException for path {$path}"); + } catch (InvalidArgumentException $e) { + $this->assertStringContainsString('path segments are not allowed', $e->getMessage()); + } + } + $this->assertNull($this->mockClient->getLastRequest()); + } + + /** + * @throws ClientExceptionInterface + */ + public function testAllowsPathSegmentsContainingDots(): void + { + $this->mockClient->append(self::createResponse(200)); + + $request = new JsonApiRequest($this->baseUrl, '/plants/v1.2/...', HttpMethod::GET); + $this->rawClient->sendRequest($request); + + $lastRequest = $this->mockClient->getLastRequest(); + $this->assertInstanceOf(RequestInterface::class, $lastRequest); + $this->assertEquals('https://api.example.com/plants/v1.2/...', (string)$lastRequest->getUri()); + } + /** * @throws ClientExceptionInterface */ public function testJsonBody(): void { - $this->mockHandler->append(new Response(200)); + $this->mockClient->append(self::createResponse(200)); $body = ['key' => 'value']; $request = new JsonApiRequest( @@ -131,15 +192,15 @@ public function testJsonBody(): void $this->rawClient->sendRequest($request); - $lastRequest = $this->mockHandler->getLastRequest(); - assert($lastRequest instanceof RequestInterface); + $lastRequest = $this->mockClient->getLastRequest(); + $this->assertInstanceOf(RequestInterface::class, $lastRequest); $this->assertEquals('application/json', $lastRequest->getHeaderLine('Content-Type')); - $this->assertEquals(json_encode($body), (string)$lastRequest->getBody()); + $this->assertEquals(JsonEncoder::encode($body), (string)$lastRequest->getBody()); } public function testAdditionalHeaders(): void { - $this->mockHandler->append(new Response(200)); + $this->mockClient->append(self::createResponse(200)); $body = new JsonRequest([ 'name' => 'john.doe' @@ -165,8 +226,8 @@ public function testAdditionalHeaders(): void ] ); - $lastRequest = $this->mockHandler->getLastRequest(); - assert($lastRequest instanceof RequestInterface); + $lastRequest = $this->mockClient->getLastRequest(); + $this->assertInstanceOf(RequestInterface::class, $lastRequest); $this->assertEquals('application/json', $lastRequest->getHeaderLine('Content-Type')); $this->assertEquals('1.0.0', $lastRequest->getHeaderLine('X-API-Version')); $this->assertEquals('test', $lastRequest->getHeaderLine('X-Tenancy')); @@ -174,7 +235,7 @@ public function testAdditionalHeaders(): void public function testOverrideAdditionalHeaders(): void { - $this->mockHandler->append(new Response(200)); + $this->mockClient->append(self::createResponse(200)); $body = new JsonRequest([ 'name' => 'john.doe' @@ -200,15 +261,15 @@ public function testOverrideAdditionalHeaders(): void ] ); - $lastRequest = $this->mockHandler->getLastRequest(); - assert($lastRequest instanceof RequestInterface); + $lastRequest = $this->mockClient->getLastRequest(); + $this->assertInstanceOf(RequestInterface::class, $lastRequest); $this->assertEquals('application/json', $lastRequest->getHeaderLine('Content-Type')); $this->assertEquals('2.0.0', $lastRequest->getHeaderLine('X-API-Version')); } public function testAdditionalBodyProperties(): void { - $this->mockHandler->append(new Response(200)); + $this->mockClient->append(self::createResponse(200)); $body = new JsonRequest([ 'name' => 'john.doe' @@ -236,15 +297,15 @@ public function testAdditionalBodyProperties(): void 'age' => 42 ]; - $lastRequest = $this->mockHandler->getLastRequest(); - assert($lastRequest instanceof RequestInterface); + $lastRequest = $this->mockClient->getLastRequest(); + $this->assertInstanceOf(RequestInterface::class, $lastRequest); $this->assertEquals('application/json', $lastRequest->getHeaderLine('Content-Type')); - $this->assertEquals(json_encode($expectedJson), (string)$lastRequest->getBody()); + $this->assertEquals(JsonEncoder::encode($expectedJson), (string)$lastRequest->getBody()); } public function testOverrideAdditionalBodyProperties(): void { - $this->mockHandler->append(new Response(200)); + $this->mockClient->append(self::createResponse(200)); $body = [ 'name' => 'john.doe' @@ -271,15 +332,15 @@ public function testOverrideAdditionalBodyProperties(): void 'name' => 'jane.doe', ]; - $lastRequest = $this->mockHandler->getLastRequest(); - assert($lastRequest instanceof RequestInterface); + $lastRequest = $this->mockClient->getLastRequest(); + $this->assertInstanceOf(RequestInterface::class, $lastRequest); $this->assertEquals('application/json', $lastRequest->getHeaderLine('Content-Type')); - $this->assertEquals(json_encode($expectedJson), (string)$lastRequest->getBody()); + $this->assertEquals(JsonEncoder::encode($expectedJson), (string)$lastRequest->getBody()); } public function testAdditionalQueryParameters(): void { - $this->mockHandler->append(new Response(200)); + $this->mockClient->append(self::createResponse(200)); $query = ['key' => 'value']; $request = new JsonApiRequest( @@ -300,15 +361,15 @@ public function testAdditionalQueryParameters(): void ] ); - $lastRequest = $this->mockHandler->getLastRequest(); - assert($lastRequest instanceof RequestInterface); + $lastRequest = $this->mockClient->getLastRequest(); + $this->assertInstanceOf(RequestInterface::class, $lastRequest); $this->assertEquals('application/json', $lastRequest->getHeaderLine('Content-Type')); $this->assertEquals('key=value&extra=42', $lastRequest->getUri()->getQuery()); } public function testOverrideQueryParameters(): void { - $this->mockHandler->append(new Response(200)); + $this->mockClient->append(self::createResponse(200)); $query = ['key' => 'invalid']; $request = new JsonApiRequest( @@ -329,15 +390,15 @@ public function testOverrideQueryParameters(): void ] ); - $lastRequest = $this->mockHandler->getLastRequest(); - assert($lastRequest instanceof RequestInterface); + $lastRequest = $this->mockClient->getLastRequest(); + $this->assertInstanceOf(RequestInterface::class, $lastRequest); $this->assertEquals('application/json', $lastRequest->getHeaderLine('Content-Type')); $this->assertEquals('key=value', $lastRequest->getUri()->getQuery()); } public function testDefaultRetries(): void { - $this->mockHandler->append(new Response(500)); + $this->mockClient->append(self::createResponse(500)); $request = new JsonApiRequest( $this->baseUrl, @@ -345,15 +406,9 @@ public function testDefaultRetries(): void HttpMethod::GET ); - try { - $this->rawClient->sendRequest($request); - $this->fail("Request should've failed but succeeded."); - } catch (ClientExceptionInterface) { - } - - $lastRequest = $this->mockHandler->getLastRequest(); - assert($lastRequest instanceof RequestInterface); - $this->assertEquals(0, $this->mockHandler->count()); + $response = $this->rawClient->sendRequest($request); + $this->assertEquals(500, $response->getStatusCode()); + $this->assertEquals(0, $this->mockClient->count()); } /** @@ -361,38 +416,44 @@ public function testDefaultRetries(): void */ public function testExplicitRetriesSuccess(): void { - $this->mockHandler->append(new Response(500), new Response(500), new Response(200)); - - $request = new JsonApiRequest( - $this->baseUrl, - '/test', - HttpMethod::GET + $mockClient = new MockHttpClient(); + $mockClient->append(self::createResponse(500), self::createResponse(500), self::createResponse(200)); + + $retryClient = new RetryDecoratingClient( + $mockClient, + maxRetries: 2, + sleepFunction: function (int $_microseconds): void { + }, ); - $this->rawClient->sendRequest($request, ['maxRetries' => 2]); + $requestFactory = \Http\Discovery\Psr17FactoryDiscovery::findRequestFactory(); + $request = $requestFactory->createRequest('GET', $this->baseUrl . '/test'); - $lastRequest = $this->mockHandler->getLastRequest(); - assert($lastRequest instanceof RequestInterface); - $this->assertEquals(0, $this->mockHandler->count()); + $response = $retryClient->sendRequest($request); + + $this->assertEquals(200, $response->getStatusCode()); + $this->assertEquals(0, $mockClient->count()); } public function testExplicitRetriesFailure(): void { - $this->mockHandler->append(new Response(500), new Response(500), new Response(500)); - - $request = new JsonApiRequest( - $this->baseUrl, - '/test', - HttpMethod::GET + $mockClient = new MockHttpClient(); + $mockClient->append(self::createResponse(500), self::createResponse(500), self::createResponse(500)); + + $retryClient = new RetryDecoratingClient( + $mockClient, + maxRetries: 2, + sleepFunction: function (int $_microseconds): void { + }, ); - try { - $this->rawClient->sendRequest($request, ['maxRetries' => 2]); - $this->fail("Request should've failed but succeeded."); - } catch (ClientExceptionInterface) { - } + $requestFactory = \Http\Discovery\Psr17FactoryDiscovery::findRequestFactory(); + $request = $requestFactory->createRequest('GET', $this->baseUrl . '/test'); - $this->assertEquals(0, $this->mockHandler->count()); + $response = $retryClient->sendRequest($request); + + $this->assertEquals(500, $response->getStatusCode()); + $this->assertEquals(0, $mockClient->count()); } /** @@ -400,272 +461,822 @@ public function testExplicitRetriesFailure(): void */ public function testShouldRetryOnStatusCodes(): void { - $this->mockHandler->append( - new Response(408), - new Response(429), - new Response(500), - new Response(501), - new Response(502), - new Response(503), - new Response(504), - new Response(505), - new Response(599), - new Response(200), + $mockClient = new MockHttpClient(); + $mockClient->append( + self::createResponse(408), + self::createResponse(429), + self::createResponse(500), + self::createResponse(501), + self::createResponse(502), + self::createResponse(503), + self::createResponse(504), + self::createResponse(505), + self::createResponse(599), + self::createResponse(200), ); - $countOfErrorRequests = $this->mockHandler->count() - 1; + $countOfErrorRequests = $mockClient->count() - 1; - $request = new JsonApiRequest( - $this->baseUrl, - '/test', - HttpMethod::GET + $retryClient = new RetryDecoratingClient( + $mockClient, + maxRetries: $countOfErrorRequests, + sleepFunction: function (int $_microseconds): void { + }, ); - $this->rawClient->sendRequest($request, ['maxRetries' => $countOfErrorRequests]); + $requestFactory = \Http\Discovery\Psr17FactoryDiscovery::findRequestFactory(); + $request = $requestFactory->createRequest('GET', $this->baseUrl . '/test'); - $this->assertEquals(0, $this->mockHandler->count()); + $response = $retryClient->sendRequest($request); + + $this->assertEquals(200, $response->getStatusCode()); + $this->assertEquals(0, $mockClient->count()); } public function testShouldFailOn400Response(): void { - $this->mockHandler->append(new Response(400), new Response(200)); - - $request = new JsonApiRequest( - $this->baseUrl, - '/test', - HttpMethod::GET + $mockClient = new MockHttpClient(); + $mockClient->append(self::createResponse(400), self::createResponse(200)); + + $retryClient = new RetryDecoratingClient( + $mockClient, + maxRetries: 2, + sleepFunction: function (int $_microseconds): void { + }, ); - try { - $this->rawClient->sendRequest($request, ['maxRetries' => 2]); - $this->fail("Request should've failed but succeeded."); - } catch (ClientExceptionInterface) { - } + $requestFactory = \Http\Discovery\Psr17FactoryDiscovery::findRequestFactory(); + $request = $requestFactory->createRequest('GET', $this->baseUrl . '/test'); + + $response = $retryClient->sendRequest($request); - $this->assertEquals(1, $this->mockHandler->count()); + $this->assertEquals(400, $response->getStatusCode()); + $this->assertEquals(1, $mockClient->count()); } public function testRetryAfterSecondsHeaderControlsDelay(): void { - $responses = [ - new Response(503, ['Retry-After' => '10']), - new Response(200), - ]; - $capturedOptions = []; + $mockClient = new MockHttpClient(); + $mockClient->append( + self::createResponse(503, ['Retry-After' => '10']), + self::createResponse(200), + ); - $handler = function (RequestInterface $request, array $options) use (&$responses, &$capturedOptions) { - $capturedOptions[] = $options; - $response = array_shift($responses); - return P\Create::promiseFor($response); + $capturedDelays = []; + $sleepFunction = function (int $microseconds) use (&$capturedDelays): void { + $capturedDelays[] = (int) ($microseconds / 1000); // Convert microseconds to milliseconds }; - $middleware = RetryMiddleware::create([ - 'maxRetries' => 2, - 'baseDelay' => 1000, - ]); + $retryClient = new RetryDecoratingClient( + $mockClient, + maxRetries: 2, + baseDelay: 1000, + sleepFunction: $sleepFunction, + ); - $retryHandler = $middleware($handler); - $request = new Request('GET', $this->baseUrl . '/test'); + $requestFactory = \Http\Discovery\Psr17FactoryDiscovery::findRequestFactory(); + $request = $requestFactory->createRequest('GET', $this->baseUrl . '/test'); - $promise = $retryHandler($request, ['delay' => 0]); - $promise->wait(); + $retryClient->sendRequest($request); - $this->assertCount(2, $capturedOptions); - $this->assertSame(0, $capturedOptions[0]['delay']); - $delay = $capturedOptions[1]['delay']; - $this->assertGreaterThanOrEqual(10000, $delay); - $this->assertLessThanOrEqual(12000, $delay); + $this->assertCount(1, $capturedDelays); + $this->assertGreaterThanOrEqual(10000, $capturedDelays[0]); + $this->assertLessThanOrEqual(12000, $capturedDelays[0]); } public function testRetryAfterHttpDateHeaderIsHandled(): void { $retryAfterDate = gmdate('D, d M Y H:i:s \G\M\T', time() + 5); - $responses = [ - new Response(503, ['Retry-After' => $retryAfterDate]), - new Response(200), - ]; - $capturedOptions = []; + $mockClient = new MockHttpClient(); + $mockClient->append( + self::createResponse(503, ['Retry-After' => $retryAfterDate]), + self::createResponse(200), + ); - $handler = function (RequestInterface $request, array $options) use (&$responses, &$capturedOptions) { - $capturedOptions[] = $options; - $response = array_shift($responses); - return P\Create::promiseFor($response); + $capturedDelays = []; + $sleepFunction = function (int $microseconds) use (&$capturedDelays): void { + $capturedDelays[] = (int) ($microseconds / 1000); }; - $middleware = RetryMiddleware::create([ - 'maxRetries' => 2, - 'baseDelay' => 1000, - ]); + $retryClient = new RetryDecoratingClient( + $mockClient, + maxRetries: 2, + baseDelay: 1000, + sleepFunction: $sleepFunction, + ); - $retryHandler = $middleware($handler); - $request = new Request('GET', $this->baseUrl . '/test'); + $requestFactory = \Http\Discovery\Psr17FactoryDiscovery::findRequestFactory(); + $request = $requestFactory->createRequest('GET', $this->baseUrl . '/test'); - $promise = $retryHandler($request, ['delay' => 0]); - $promise->wait(); + $retryClient->sendRequest($request); - $this->assertCount(2, $capturedOptions); - $delay = $capturedOptions[1]['delay']; - $this->assertGreaterThan(0, $delay); - $this->assertLessThanOrEqual(60000, $delay); + $this->assertCount(1, $capturedDelays); + $this->assertGreaterThan(0, $capturedDelays[0]); + $this->assertLessThanOrEqual(60000, $capturedDelays[0]); } public function testRateLimitResetHeaderControlsDelay(): void { $resetTime = (int) floor(microtime(true)) + 5; - $responses = [ - new Response(429, ['X-RateLimit-Reset' => (string) $resetTime]), - new Response(200), - ]; - $capturedOptions = []; - $handler = function (RequestInterface $request, array $options) use (&$responses, &$capturedOptions) { - $capturedOptions[] = $options; - $response = array_shift($responses); - return P\Create::promiseFor($response); + $mockClient = new MockHttpClient(); + $mockClient->append( + self::createResponse(429, ['X-RateLimit-Reset' => (string) $resetTime]), + self::createResponse(200), + ); + + $capturedDelays = []; + $sleepFunction = function (int $microseconds) use (&$capturedDelays): void { + $capturedDelays[] = (int) ($microseconds / 1000); }; - $middleware = RetryMiddleware::create([ - 'maxRetries' => 2, - 'baseDelay' => 1000, - ]); + $retryClient = new RetryDecoratingClient( + $mockClient, + maxRetries: 2, + baseDelay: 1000, + sleepFunction: $sleepFunction, + ); - $retryHandler = $middleware($handler); - $request = new Request('GET', $this->baseUrl . '/test'); + $requestFactory = \Http\Discovery\Psr17FactoryDiscovery::findRequestFactory(); + $request = $requestFactory->createRequest('GET', $this->baseUrl . '/test'); - $promise = $retryHandler($request, ['delay' => 0]); - $promise->wait(); + $retryClient->sendRequest($request); - $this->assertCount(2, $capturedOptions); - $delay = $capturedOptions[1]['delay']; - $this->assertGreaterThan(0, $delay); - $this->assertLessThanOrEqual(60000, $delay); + $this->assertCount(1, $capturedDelays); + $this->assertGreaterThan(0, $capturedDelays[0]); + $this->assertLessThanOrEqual(60000, $capturedDelays[0]); } public function testRateLimitResetHeaderRespectsMaxDelayAndPositiveJitter(): void { $resetTime = (int) floor(microtime(true)) + 1000; - $responses = [ - new Response(429, ['X-RateLimit-Reset' => (string) $resetTime]), - new Response(200), - ]; - $capturedOptions = []; - $handler = function (RequestInterface $request, array $options) use (&$responses, &$capturedOptions) { - $capturedOptions[] = $options; - $response = array_shift($responses); - return P\Create::promiseFor($response); + $mockClient = new MockHttpClient(); + $mockClient->append( + self::createResponse(429, ['X-RateLimit-Reset' => (string) $resetTime]), + self::createResponse(200), + ); + + $capturedDelays = []; + $sleepFunction = function (int $microseconds) use (&$capturedDelays): void { + $capturedDelays[] = (int) ($microseconds / 1000); }; - $middleware = RetryMiddleware::create([ - 'maxRetries' => 1, - 'baseDelay' => 1000, - ]); + $retryClient = new RetryDecoratingClient( + $mockClient, + maxRetries: 1, + baseDelay: 1000, + sleepFunction: $sleepFunction, + ); - $retryHandler = $middleware($handler); - $request = new Request('GET', $this->baseUrl . '/test'); + $requestFactory = \Http\Discovery\Psr17FactoryDiscovery::findRequestFactory(); + $request = $requestFactory->createRequest('GET', $this->baseUrl . '/test'); - $promise = $retryHandler($request, ['delay' => 0]); - $promise->wait(); + $retryClient->sendRequest($request); - $delay = $capturedOptions[1]['delay']; - $this->assertGreaterThanOrEqual(60000, $delay); - $this->assertLessThanOrEqual(72000, $delay); + $this->assertCount(1, $capturedDelays); + $this->assertGreaterThanOrEqual(60000, $capturedDelays[0]); + $this->assertLessThanOrEqual(72000, $capturedDelays[0]); } public function testExponentialBackoffWithSymmetricJitterWhenNoHeaders(): void { - $responses = [ - new Response(503), - new Response(200), - ]; - $capturedOptions = []; + $mockClient = new MockHttpClient(); + $mockClient->append( + self::createResponse(503), + self::createResponse(200), + ); - $handler = function (RequestInterface $request, array $options) use (&$responses, &$capturedOptions) { - $capturedOptions[] = $options; - $response = array_shift($responses); - return P\Create::promiseFor($response); + $capturedDelays = []; + $sleepFunction = function (int $microseconds) use (&$capturedDelays): void { + $capturedDelays[] = (int) ($microseconds / 1000); }; - $middleware = RetryMiddleware::create([ - 'maxRetries' => 1, - 'baseDelay' => 1000, - ]); + $retryClient = new RetryDecoratingClient( + $mockClient, + maxRetries: 1, + baseDelay: 1000, + sleepFunction: $sleepFunction, + ); - $retryHandler = $middleware($handler); - $request = new Request('GET', $this->baseUrl . '/test'); + $requestFactory = \Http\Discovery\Psr17FactoryDiscovery::findRequestFactory(); + $request = $requestFactory->createRequest('GET', $this->baseUrl . '/test'); - $promise = $retryHandler($request, ['delay' => 0]); - $promise->wait(); + $retryClient->sendRequest($request); - $this->assertCount(2, $capturedOptions); - $delay = $capturedOptions[1]['delay']; - $this->assertGreaterThanOrEqual(900, $delay); - $this->assertLessThanOrEqual(1100, $delay); + $this->assertCount(1, $capturedDelays); + $this->assertGreaterThanOrEqual(900, $capturedDelays[0]); + $this->assertLessThanOrEqual(1100, $capturedDelays[0]); } public function testRetryAfterHeaderTakesPrecedenceOverRateLimitReset(): void { $resetTime = (int) floor(microtime(true)) + 30; - $responses = [ - new Response(503, [ + + $mockClient = new MockHttpClient(); + $mockClient->append( + self::createResponse(503, [ 'Retry-After' => '5', 'X-RateLimit-Reset' => (string) $resetTime, ]), - new Response(200), - ]; - $capturedOptions = []; + self::createResponse(200), + ); - $handler = function (RequestInterface $request, array $options) use (&$responses, &$capturedOptions) { - $capturedOptions[] = $options; - $response = array_shift($responses); - return P\Create::promiseFor($response); + $capturedDelays = []; + $sleepFunction = function (int $microseconds) use (&$capturedDelays): void { + $capturedDelays[] = (int) ($microseconds / 1000); }; - $middleware = RetryMiddleware::create([ - 'maxRetries' => 2, - 'baseDelay' => 1000, - ]); + $retryClient = new RetryDecoratingClient( + $mockClient, + maxRetries: 2, + baseDelay: 1000, + sleepFunction: $sleepFunction, + ); - $retryHandler = $middleware($handler); - $request = new Request('GET', $this->baseUrl . '/test'); + $requestFactory = \Http\Discovery\Psr17FactoryDiscovery::findRequestFactory(); + $request = $requestFactory->createRequest('GET', $this->baseUrl . '/test'); - $promise = $retryHandler($request, ['delay' => 0]); - $promise->wait(); + $retryClient->sendRequest($request); - $this->assertCount(2, $capturedOptions); - $delay = $capturedOptions[1]['delay']; - $this->assertGreaterThanOrEqual(5000, $delay); - $this->assertLessThanOrEqual(6000, $delay); + $this->assertCount(1, $capturedDelays); + $this->assertGreaterThanOrEqual(5000, $capturedDelays[0]); + $this->assertLessThanOrEqual(6000, $capturedDelays[0]); } public function testMaxDelayCapIsApplied(): void { - $responses = [ - new Response(503, ['Retry-After' => '120']), - new Response(200), - ]; - $capturedOptions = []; + $mockClient = new MockHttpClient(); + $mockClient->append( + self::createResponse(503, ['Retry-After' => '120']), + self::createResponse(200), + ); - $handler = function (RequestInterface $request, array $options) use (&$responses, &$capturedOptions) { - $capturedOptions[] = $options; - $response = array_shift($responses); - return P\Create::promiseFor($response); + $capturedDelays = []; + $sleepFunction = function (int $microseconds) use (&$capturedDelays): void { + $capturedDelays[] = (int) ($microseconds / 1000); }; - $middleware = RetryMiddleware::create([ - 'maxRetries' => 2, - 'baseDelay' => 1000, + $retryClient = new RetryDecoratingClient( + $mockClient, + maxRetries: 2, + baseDelay: 1000, + sleepFunction: $sleepFunction, + ); + + $requestFactory = \Http\Discovery\Psr17FactoryDiscovery::findRequestFactory(); + $request = $requestFactory->createRequest('GET', $this->baseUrl . '/test'); + + $retryClient->sendRequest($request); + + $this->assertCount(1, $capturedDelays); + $this->assertGreaterThanOrEqual(60000, $capturedDelays[0]); + $this->assertLessThanOrEqual(72000, $capturedDelays[0]); + } + + public function testMultipartContentTypeIncludesBoundary(): void + { + $this->mockClient->append(self::createResponse(200)); + + $formData = new MultipartFormData(); + $formData->add('field', 'value'); + + $request = new MultipartApiRequest( + $this->baseUrl, + '/upload', + HttpMethod::POST, + [], + [], + $formData, + ); + + $this->rawClient->sendRequest($request); + + $lastRequest = $this->mockClient->getLastRequest(); + $this->assertInstanceOf(RequestInterface::class, $lastRequest); + + $contentType = $lastRequest->getHeaderLine('Content-Type'); + $this->assertStringStartsWith('multipart/form-data; boundary=', $contentType); + + $boundary = substr($contentType, strlen('multipart/form-data; boundary=')); + $body = (string) $lastRequest->getBody(); + $this->assertStringContainsString("--{$boundary}\r\n", $body); + $this->assertStringContainsString("Content-Disposition: form-data; name=\"field\"\r\n", $body); + $this->assertStringContainsString("value", $body); + $this->assertStringContainsString("--{$boundary}--\r\n", $body); + } + + public function testMultipartWithFilename(): void + { + $this->mockClient->append(self::createResponse(200)); + + $formData = new MultipartFormData(); + $formData->addPart(new MultipartFormDataPart( + name: 'document', + value: 'file-contents', + filename: 'report.pdf', + headers: ['Content-Type' => 'application/pdf'], + )); + + $request = new MultipartApiRequest( + $this->baseUrl, + '/upload', + HttpMethod::POST, + [], + [], + $formData, + ); + + $this->rawClient->sendRequest($request); + + $lastRequest = $this->mockClient->getLastRequest(); + $this->assertInstanceOf(RequestInterface::class, $lastRequest); + + $body = (string) $lastRequest->getBody(); + $this->assertStringContainsString( + 'Content-Disposition: form-data; name="document"; filename="report.pdf"', + $body, + ); + $this->assertStringContainsString('Content-Type: application/pdf', $body); + $this->assertStringContainsString('file-contents', $body); + } + + public function testMultipartWithMultipleParts(): void + { + $this->mockClient->append(self::createResponse(200)); + + $formData = new MultipartFormData(); + $formData->add('name', 'John'); + $formData->add('age', 30); + $formData->addPart(new MultipartFormDataPart( + name: 'avatar', + value: 'image-data', + filename: 'avatar.png', + )); + + $request = new MultipartApiRequest( + $this->baseUrl, + '/profile', + HttpMethod::POST, + [], + [], + $formData, + ); + + $this->rawClient->sendRequest($request); + + $lastRequest = $this->mockClient->getLastRequest(); + $this->assertInstanceOf(RequestInterface::class, $lastRequest); + + $body = (string) $lastRequest->getBody(); + $this->assertStringContainsString('name="name"', $body); + $this->assertStringContainsString('John', $body); + $this->assertStringContainsString('name="age"', $body); + $this->assertStringContainsString('30', $body); + $this->assertStringContainsString('name="avatar"; filename="avatar.png"', $body); + $this->assertStringContainsString('image-data', $body); + } + + public function testMultipartDoesNotIncludeJsonContentType(): void + { + $this->mockClient->append(self::createResponse(200)); + + $formData = new MultipartFormData(); + $formData->add('field', 'value'); + + $request = new MultipartApiRequest( + $this->baseUrl, + '/upload', + HttpMethod::POST, + [], + [], + $formData, + ); + + $this->rawClient->sendRequest($request); + + $lastRequest = $this->mockClient->getLastRequest(); + $this->assertInstanceOf(RequestInterface::class, $lastRequest); + + $contentType = $lastRequest->getHeaderLine('Content-Type'); + $this->assertStringStartsWith('multipart/form-data; boundary=', $contentType); + $this->assertStringNotContainsString('application/json', $contentType); + } + + public function testMultipartNullBodySendsNoBody(): void + { + $this->mockClient->append(self::createResponse(200)); + + $request = new MultipartApiRequest( + $this->baseUrl, + '/upload', + HttpMethod::POST, + ); + + $this->rawClient->sendRequest($request); + + $lastRequest = $this->mockClient->getLastRequest(); + $this->assertInstanceOf(RequestInterface::class, $lastRequest); + + $this->assertEquals('', (string) $lastRequest->getBody()); + $this->assertStringNotContainsString('multipart/form-data', $lastRequest->getHeaderLine('Content-Type')); + } + + public function testJsonNullBodySendsNoBody(): void + { + $this->mockClient->append(self::createResponse(200)); + + $request = new JsonApiRequest( + $this->baseUrl, + '/test', + HttpMethod::POST, + ); + + $this->rawClient->sendRequest($request); + + $lastRequest = $this->mockClient->getLastRequest(); + $this->assertInstanceOf(RequestInterface::class, $lastRequest); + + $this->assertEquals('', (string) $lastRequest->getBody()); + } + + public function testEmptyJsonBodySerializesAsObject(): void + { + $this->mockClient->append(self::createResponse(200)); + + $request = new JsonApiRequest( + $this->baseUrl, + '/test', + HttpMethod::POST, + [], + [], + ['key' => 'value'], + ); + + $this->rawClient->sendRequest( + $request, + options: [ + 'bodyProperties' => [ + 'key' => 'value', + ], + ], + ); + + $lastRequest = $this->mockClient->getLastRequest(); + $this->assertInstanceOf(RequestInterface::class, $lastRequest); + + // When bodyProperties override all keys, the merged result should still + // serialize as a JSON object {}, not an array []. + $decoded = json_decode((string) $lastRequest->getBody(), true); + $this->assertIsArray($decoded); + $this->assertEquals('value', $decoded['key']); + } + + public function testAuthHeadersAreIncluded(): void + { + $mockClient = new MockHttpClient(); + $mockClient->append(self::createResponse(200)); + + $rawClient = new RawClient([ + 'client' => $mockClient, + 'maxRetries' => 0, + 'getAuthHeaders' => fn () => ['Authorization' => 'Bearer test-token'], ]); - $retryHandler = $middleware($handler); - $request = new Request('GET', $this->baseUrl . '/test'); + $request = new JsonApiRequest( + $this->baseUrl, + '/test', + HttpMethod::GET, + ); + + $rawClient->sendRequest($request); - $promise = $retryHandler($request, ['delay' => 0]); - $promise->wait(); + $lastRequest = $mockClient->getLastRequest(); + $this->assertInstanceOf(RequestInterface::class, $lastRequest); - $this->assertCount(2, $capturedOptions); - $delay = $capturedOptions[1]['delay']; - $this->assertGreaterThanOrEqual(60000, $delay); - $this->assertLessThanOrEqual(72000, $delay); + $this->assertEquals('Bearer test-token', $lastRequest->getHeaderLine('Authorization')); } + + public function testAuthHeadersAreIncludedInMultipart(): void + { + $mockClient = new MockHttpClient(); + $mockClient->append(self::createResponse(200)); + + $rawClient = new RawClient([ + 'client' => $mockClient, + 'maxRetries' => 0, + 'getAuthHeaders' => fn () => ['Authorization' => 'Bearer test-token'], + ]); + + $formData = new MultipartFormData(); + $formData->add('field', 'value'); + + $request = new MultipartApiRequest( + $this->baseUrl, + '/upload', + HttpMethod::POST, + [], + [], + $formData, + ); + + $rawClient->sendRequest($request); + + $lastRequest = $mockClient->getLastRequest(); + $this->assertInstanceOf(RequestInterface::class, $lastRequest); + + $this->assertEquals('Bearer test-token', $lastRequest->getHeaderLine('Authorization')); + $this->assertStringStartsWith('multipart/form-data; boundary=', $lastRequest->getHeaderLine('Content-Type')); + } + + /** + * Creates a PSR-7 response using discovery, without depending on any specific implementation. + * + * @param int $statusCode + * @param array $headers + * @param string $body + * @return ResponseInterface + */ + private static function createResponse( + int $statusCode = 200, + array $headers = [], + string $body = '', + ): ResponseInterface { + $response = \Http\Discovery\Psr17FactoryDiscovery::findResponseFactory() + ->createResponse($statusCode); + foreach ($headers as $name => $value) { + $response = $response->withHeader($name, $value); + } + if ($body !== '') { + $response = $response->withBody( + \Http\Discovery\Psr17FactoryDiscovery::findStreamFactory() + ->createStream($body), + ); + } + return $response; + } + + + public function testTimeoutOptionIsAccepted(): void + { + $this->mockClient->append(self::createResponse(200)); + + $request = new JsonApiRequest( + $this->baseUrl, + '/test', + HttpMethod::GET, + ); + + // MockHttpClient is not Guzzle/Symfony, so a warning is triggered once. + set_error_handler(static function (int $errno, string $errstr): bool { + return $errno === E_USER_WARNING + && str_contains($errstr, 'Timeout option is not supported'); + }); + + try { + $response = $this->rawClient->sendRequest( + $request, + options: [ + 'timeout' => 3.0 + ] + ); + + $this->assertEquals(200, $response->getStatusCode()); + + $lastRequest = $this->mockClient->getLastRequest(); + $this->assertInstanceOf(RequestInterface::class, $lastRequest); + } finally { + restore_error_handler(); + } + } + + public function testClientLevelTimeoutIsAccepted(): void + { + $mockClient = new MockHttpClient(); + $mockClient->append(self::createResponse(200)); + + $rawClient = new RawClient([ + 'client' => $mockClient, + 'maxRetries' => 0, + 'timeout' => 5.0, + ]); + + $request = new JsonApiRequest( + $this->baseUrl, + '/test', + HttpMethod::GET, + ); + + set_error_handler(static function (int $errno, string $errstr): bool { + return $errno === E_USER_WARNING + && str_contains($errstr, 'Timeout option is not supported'); + }); + + try { + $response = $rawClient->sendRequest($request); + $this->assertEquals(200, $response->getStatusCode()); + } finally { + restore_error_handler(); + } + } + + public function testPerRequestTimeoutOverridesClientTimeout(): void + { + $mockClient = new MockHttpClient(); + $mockClient->append(self::createResponse(200)); + + $rawClient = new RawClient([ + 'client' => $mockClient, + 'maxRetries' => 0, + 'timeout' => 5.0, + ]); + + $request = new JsonApiRequest( + $this->baseUrl, + '/test', + HttpMethod::GET, + ); + + set_error_handler(static function (int $errno, string $errstr): bool { + return $errno === E_USER_WARNING + && str_contains($errstr, 'Timeout option is not supported'); + }); + + try { + $response = $rawClient->sendRequest( + $request, + options: [ + 'timeout' => 1.0 + ] + ); + + $this->assertEquals(200, $response->getStatusCode()); + } finally { + restore_error_handler(); + } + } + + public function testDiscoveryFindsHttpClient(): void + { + // HttpClientBuilder::build() with no client arg uses Psr18ClientDiscovery. + $client = HttpClientBuilder::build(); + $this->assertInstanceOf(\Psr\Http\Client\ClientInterface::class, $client); + } + + public function testDiscoveryFindsFactories(): void + { + $requestFactory = HttpClientBuilder::requestFactory(); + $this->assertInstanceOf(\Psr\Http\Message\RequestFactoryInterface::class, $requestFactory); + + $streamFactory = HttpClientBuilder::streamFactory(); + $this->assertInstanceOf(\Psr\Http\Message\StreamFactoryInterface::class, $streamFactory); + + // Verify they produce usable objects + $request = $requestFactory->createRequest('GET', 'https://example.com'); + $this->assertEquals('GET', $request->getMethod()); + + $stream = $streamFactory->createStream('hello'); + $this->assertEquals('hello', (string) $stream); + } + + public function testInterfaceExistsDetectsGuzzle(): void + { + $this->assertTrue( + interface_exists('GuzzleHttp\ClientInterface'), + 'interface_exists should detect GuzzleHttp\ClientInterface when Guzzle is installed', + ); + } + + public function testTimeoutForwardsToGuzzleSend(): void + { + $expectedResponse = self::createResponse(200); + + $guzzleClient = new class ($expectedResponse) implements \Psr\Http\Client\ClientInterface, \GuzzleHttp\ClientInterface { + private ResponseInterface $response; + /** @var array */ + public array $lastOptions = []; + + public function __construct(ResponseInterface $response) + { + $this->response = $response; + } + + /** @param array $options */ + public function send(\Psr\Http\Message\RequestInterface $request, array $options = []): ResponseInterface + { + $this->lastOptions = $options; + return $this->response; + } + + /** @param array $options */ + public function sendAsync(\Psr\Http\Message\RequestInterface $request, array $options = []): \GuzzleHttp\Promise\PromiseInterface + { + throw new \RuntimeException('Not implemented'); + } + + /** @param array $options */ + public function request(string $method, $uri, array $options = []): ResponseInterface + { + throw new \RuntimeException('Not implemented'); + } + + /** @param array $options */ + public function requestAsync(string $method, $uri, array $options = []): \GuzzleHttp\Promise\PromiseInterface + { + throw new \RuntimeException('Not implemented'); + } + + public function getConfig(?string $option = null) + { + return null; + } + + public function sendRequest(\Psr\Http\Message\RequestInterface $request): ResponseInterface + { + return $this->response; + } + }; + + $retryClient = new RetryDecoratingClient( + $guzzleClient, + maxRetries: 0, + sleepFunction: function (int $_microseconds): void { + }, + ); + + $requestFactory = \Http\Discovery\Psr17FactoryDiscovery::findRequestFactory(); + $request = $requestFactory->createRequest('GET', $this->baseUrl . '/test'); + + $response = $retryClient->send($request, timeout: 5.0); + + $this->assertEquals(200, $response->getStatusCode()); + $this->assertArrayHasKey('timeout', $guzzleClient->lastOptions); + $this->assertEquals(5.0, $guzzleClient->lastOptions['timeout']); + } + + public function testNoTimeoutDoesNotCallGuzzleSend(): void + { + $expectedResponse = self::createResponse(200); + + $guzzleClient = new class ($expectedResponse) implements \Psr\Http\Client\ClientInterface, \GuzzleHttp\ClientInterface { + private ResponseInterface $response; + public bool $sendCalled = false; + + public function __construct(ResponseInterface $response) + { + $this->response = $response; + } + + /** @param array $options */ + public function send(\Psr\Http\Message\RequestInterface $request, array $options = []): ResponseInterface + { + $this->sendCalled = true; + return $this->response; + } + + /** @param array $options */ + public function sendAsync(\Psr\Http\Message\RequestInterface $request, array $options = []): \GuzzleHttp\Promise\PromiseInterface + { + throw new \RuntimeException('Not implemented'); + } + + /** @param array $options */ + public function request(string $method, $uri, array $options = []): ResponseInterface + { + throw new \RuntimeException('Not implemented'); + } + + /** @param array $options */ + public function requestAsync(string $method, $uri, array $options = []): \GuzzleHttp\Promise\PromiseInterface + { + throw new \RuntimeException('Not implemented'); + } + + public function getConfig(?string $option = null) + { + return null; + } + + public function sendRequest(\Psr\Http\Message\RequestInterface $request): ResponseInterface + { + return $this->response; + } + }; + + $retryClient = new RetryDecoratingClient( + $guzzleClient, + maxRetries: 0, + sleepFunction: function (int $_microseconds): void { + }, + ); + + $requestFactory = \Http\Discovery\Psr17FactoryDiscovery::findRequestFactory(); + $request = $requestFactory->createRequest('GET', $this->baseUrl . '/test'); + + $response = $retryClient->send($request, timeout: null); + + $this->assertEquals(200, $response->getStatusCode()); + $this->assertFalse($guzzleClient->sendCalled, 'Guzzle send() should not be called when timeout is null'); + } + } diff --git a/tests/Core/Json/AdditionalPropertiesTest.php b/tests/Core/Json/AdditionalPropertiesTest.php index 8e33e98c..e3f40c3f 100644 --- a/tests/Core/Json/AdditionalPropertiesTest.php +++ b/tests/Core/Json/AdditionalPropertiesTest.php @@ -3,6 +3,7 @@ namespace Intercom\Tests\Core\Json; use PHPUnit\Framework\TestCase; +use Intercom\Core\Json\JsonEncoder; use Intercom\Core\Json\JsonProperty; use Intercom\Core\Json\JsonSerializableType; @@ -54,13 +55,12 @@ class AdditionalPropertiesTest extends TestCase { public function testExtraProperties(): void { - $expectedJson = json_encode( + $expectedJson = JsonEncoder::encode( [ 'name' => 'john.doe', 'email' => 'john.doe@example.com', 'age' => 42 ], - JSON_THROW_ON_ERROR ); $person = Person::fromJson($expectedJson); diff --git a/tests/Core/Json/DateArrayTest.php b/tests/Core/Json/DateArrayTest.php index 50613d29..2472f3f9 100644 --- a/tests/Core/Json/DateArrayTest.php +++ b/tests/Core/Json/DateArrayTest.php @@ -4,6 +4,7 @@ use DateTime; use PHPUnit\Framework\TestCase; +use Intercom\Core\Json\JsonEncoder; use Intercom\Core\Json\JsonProperty; use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Types\ArrayType; @@ -33,11 +34,10 @@ class DateArrayTest extends TestCase { public function testDateTimeInArrays(): void { - $expectedJson = json_encode( + $expectedJson = JsonEncoder::encode( [ 'dates' => ['2023-01-01', '2023-02-01', '2023-03-01'] ], - JSON_THROW_ON_ERROR ); $object = DateArray::fromJson($expectedJson); diff --git a/tests/Core/Json/EmptyArrayTest.php b/tests/Core/Json/EmptyArrayTest.php index e4680fd9..706ced8b 100644 --- a/tests/Core/Json/EmptyArrayTest.php +++ b/tests/Core/Json/EmptyArrayTest.php @@ -3,6 +3,7 @@ namespace Intercom\Tests\Core\Json; use PHPUnit\Framework\TestCase; +use Intercom\Core\Json\JsonEncoder; use Intercom\Core\Json\JsonProperty; use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Types\ArrayType; @@ -51,21 +52,27 @@ class EmptyArrayTest extends TestCase { public function testEmptyArray(): void { - $expectedJson = json_encode( + $inputJson = JsonEncoder::encode( [ 'empty_string_array' => [], 'empty_map_array' => [], 'empty_dates_array' => [] ], - JSON_THROW_ON_ERROR ); - $object = EmptyArray::fromJson($expectedJson); + $object = EmptyArray::fromJson($inputJson); $this->assertEmpty($object->emptyStringArray, 'empty_string_array should be empty.'); $this->assertEmpty($object->emptyMapArray, 'empty_map_array should be empty.'); $this->assertEmpty($object->emptyDatesArray, 'empty_dates_array should be empty.'); $actualJson = $object->toJson(); - $this->assertJsonStringEqualsJsonString($expectedJson, $actualJson, 'Serialized JSON does not match original JSON for EmptyArraysType.'); + $expectedJson = JsonEncoder::encode( + [ + 'empty_string_array' => [], + 'empty_map_array' => new \stdClass(), + 'empty_dates_array' => [] + ], + ); + $this->assertJsonStringEqualsJsonString($expectedJson, $actualJson, 'Serialized JSON does not match expected JSON for EmptyArraysType.'); } } diff --git a/tests/Core/Json/EmptyObjectTest.php b/tests/Core/Json/EmptyObjectTest.php new file mode 100644 index 00000000..9f8fc5cd --- /dev/null +++ b/tests/Core/Json/EmptyObjectTest.php @@ -0,0 +1,409 @@ +optionalField = $values['optionalField'] ?? null; + } +} + +class EmptyObjectWithNestedObject extends JsonSerializableType +{ + /** + * @var string $name + */ + #[JsonProperty('name')] + public string $name; + + /** + * @var EmptyObject $nested + */ + #[JsonProperty('nested')] + public EmptyObject $nested; + + /** + * @param array{ + * name: string, + * nested: EmptyObject, + * } $values + */ + public function __construct( + array $values, + ) { + $this->name = $values['name']; + $this->nested = $values['nested']; + } +} + +class ObjectWithEmptyMap extends JsonSerializableType +{ + /** + * @var array $metadata + */ + #[JsonProperty('metadata'), ArrayType(['string' => 'string'])] + public array $metadata; + + /** + * @param array{ + * metadata: array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->metadata = $values['metadata']; + } +} + +class ObjectWithListAndMap extends JsonSerializableType +{ + /** + * @var string[] $list + */ + #[ArrayType(['string'])] + #[JsonProperty('list')] + public array $list; + + /** + * @var array $map + */ + #[ArrayType(['string' => 'string'])] + #[JsonProperty('map')] + public array $map; + + /** + * @param array{ + * list: string[], + * map: array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->list = $values['list']; + $this->map = $values['map']; + } +} + +class EmptyUnionMember extends JsonSerializableType +{ + /** + * @var string|null $tag + */ + #[JsonProperty('tag')] + public ?string $tag; + + /** + * @param array{ + * tag?: string|null, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->tag = $values['tag'] ?? null; + } +} + +class ObjectWithUnionEmpty extends JsonSerializableType +{ + /** + * @var string|EmptyUnionMember|null $value + */ + #[Union('string', EmptyUnionMember::class, 'null')] + #[JsonProperty('value')] + public mixed $value; + + /** + * @param array{ + * value: string|EmptyUnionMember|null, + * } $values + */ + public function __construct( + array $values, + ) { + $this->value = $values['value']; + } +} + +class ObjectWithListOfMaps extends JsonSerializableType +{ + /** + * @var array> $items + */ + #[ArrayType([['string' => 'string']])] + #[JsonProperty('items')] + public array $items; + + /** + * @param array{ + * items: array>, + * } $values + */ + public function __construct( + array $values, + ) { + $this->items = $values['items']; + } +} + +class ObjectWithMapOfObjects extends JsonSerializableType +{ + /** + * @var array $entries + */ + #[ArrayType(['string' => EmptyUnionMember::class])] + #[JsonProperty('entries')] + public array $entries; + + /** + * @param array{ + * entries: array, + * } $values + */ + public function __construct( + array $values, + ) { + $this->entries = $values['entries']; + } +} + +class ObjectWithAdditionalOnly extends JsonSerializableType +{ + /** + * @var string|null $name + */ + #[JsonProperty('name')] + public ?string $name; + + /** + * @param array{ + * name?: string|null, + * } $values + */ + public function __construct( + array $values = [], + ) { + $this->name = $values['name'] ?? null; + } +} + +class EmptyObjectTest extends TestCase +{ + public function testEmptyObjectSerializesToObject(): void + { + $object = new EmptyObject([]); + $json = $object->toJson(); + $this->assertEquals('{}', $json, 'Empty object should serialize to {} not [].'); + } + + public function testEmptyObjectWithFieldSetSerializesCorrectly(): void + { + $object = new EmptyObject(['optionalField' => 'value']); + $json = $object->toJson(); + $this->assertJsonStringEqualsJsonString('{"optional_field": "value"}', $json); + } + + public function testNestedEmptyObjectSerializesToObject(): void + { + $parent = new EmptyObjectWithNestedObject([ + 'name' => 'test', + 'nested' => new EmptyObject([]), + ]); + $json = $parent->toJson(); + $expected = '{"name": "test", "nested": {}}'; + $this->assertJsonStringEqualsJsonString($expected, $json, 'Nested empty object should serialize to {} not [].'); + } + + public function testDeserializeEmptyObject(): void + { + $json = '{}'; + $object = EmptyObject::fromJson($json); + $this->assertNull($object->optionalField); + $this->assertEquals('{}', $object->toJson(), 'Deserialized empty object should re-serialize to {}.'); + } + + public function testEmptyMapSerializesToObject(): void + { + $object = new ObjectWithEmptyMap(['metadata' => []]); + $json = $object->toJson(); + $this->assertJsonStringEqualsJsonString('{"metadata":{}}', $json, 'Empty map should serialize to {} not [].'); + } + + public function testNonEmptyMapSerializesCorrectly(): void + { + $object = new ObjectWithEmptyMap(['metadata' => ['key' => 'value']]); + $json = $object->toJson(); + $this->assertJsonStringEqualsJsonString('{"metadata":{"key":"value"}}', $json); + } + + public function testEmptyListAndEmptyMapSideBySide(): void + { + $object = new ObjectWithListAndMap(['list' => [], 'map' => []]); + $json = $object->toJson(); + $this->assertJsonStringEqualsJsonString( + '{"list":[],"map":{}}', + $json, + 'Empty list should serialize as [] and empty map as {} on the same object.' + ); + } + + public function testNonEmptyListAndEmptyMap(): void + { + $object = new ObjectWithListAndMap(['list' => ['a', 'b'], 'map' => []]); + $json = $object->toJson(); + $this->assertJsonStringEqualsJsonString( + '{"list":["a","b"],"map":{}}', + $json + ); + } + + public function testEmptyListAndNonEmptyMap(): void + { + $object = new ObjectWithListAndMap(['list' => [], 'map' => ['key' => 'val']]); + $json = $object->toJson(); + $this->assertJsonStringEqualsJsonString( + '{"list":[],"map":{"key":"val"}}', + $json + ); + } + + public function testUnionWithEmptyObject(): void + { + $object = new ObjectWithUnionEmpty(['value' => new EmptyUnionMember([])]); + $json = $object->toJson(); + $this->assertJsonStringEqualsJsonString( + '{"value":{}}', + $json, + 'Union containing an empty object should serialize to {} via the stdClass guard path.' + ); + } + + public function testUnionWithNonEmptyObject(): void + { + $object = new ObjectWithUnionEmpty(['value' => new EmptyUnionMember(['tag' => 'hello'])]); + $json = $object->toJson(); + $this->assertJsonStringEqualsJsonString( + '{"value":{"tag":"hello"}}', + $json + ); + } + + public function testUnionWithStringFallback(): void + { + $object = new ObjectWithUnionEmpty(['value' => 'plain string']); + $json = $object->toJson(); + $this->assertJsonStringEqualsJsonString( + '{"value":"plain string"}', + $json + ); + } + + public function testListOfEmptyMaps(): void + { + $object = new ObjectWithListOfMaps(['items' => [[], []]]); + $json = $object->toJson(); + $this->assertJsonStringEqualsJsonString( + '{"items":[{},{}]}', + $json, + 'A list of empty maps should produce [{},{}] — each empty map is {} but the list stays [].' + ); + } + + public function testListOfMixedMaps(): void + { + $object = new ObjectWithListOfMaps(['items' => [['a' => 'b'], [], ['c' => 'd']]]); + $json = $object->toJson(); + $this->assertJsonStringEqualsJsonString( + '{"items":[{"a":"b"},{},{"c":"d"}]}', + $json + ); + } + + public function testMapOfEmptyObjects(): void + { + $object = new ObjectWithMapOfObjects([ + 'entries' => [ + 'first' => new EmptyUnionMember([]), + 'second' => new EmptyUnionMember([]), + ] + ]); + $json = $object->toJson(); + $this->assertJsonStringEqualsJsonString( + '{"entries":{"first":{},"second":{}}}', + $json, + 'A map whose values are empty objects should produce {"a":{},"b":{}}.' + ); + } + + public function testMapOfMixedObjects(): void + { + $object = new ObjectWithMapOfObjects([ + 'entries' => [ + 'empty' => new EmptyUnionMember([]), + 'filled' => new EmptyUnionMember(['tag' => 'present']), + ] + ]); + $json = $object->toJson(); + $this->assertJsonStringEqualsJsonString( + '{"entries":{"empty":{},"filled":{"tag":"present"}}}', + $json + ); + } + + public function testEmptyObjectWithAdditionalPropertiesOnly(): void + { + $json = '{"extra_key":"extra_value"}'; + $object = ObjectWithAdditionalOnly::fromJson($json); + $this->assertNull($object->name); + $this->assertEquals(['extra_key' => 'extra_value'], $object->getAdditionalProperties()); + + $reserialized = $object->toJson(); + $this->assertEquals('{}', $reserialized, 'Object with only additional properties (no declared fields set) should serialize to {}.'); + } + + public function testEmptyObjectNoAdditionalProperties(): void + { + $object = new ObjectWithAdditionalOnly([]); + $json = $object->toJson(); + $this->assertEquals('{}', $json, 'Object with all null properties and no additional properties should serialize to {}.'); + } + + public function testRoundTripListAndMap(): void + { + $inputJson = '{"list":[],"map":{}}'; + $object = ObjectWithListAndMap::fromJson($inputJson); + $this->assertEmpty($object->list); + $this->assertEmpty($object->map); + $this->assertJsonStringEqualsJsonString($inputJson, $object->toJson()); + } + + public function testRoundTripUnionWithEmptyObject(): void + { + $inputJson = '{"value":{}}'; + $object = ObjectWithUnionEmpty::fromJson($inputJson); + $this->assertInstanceOf(EmptyUnionMember::class, $object->value); + $this->assertJsonStringEqualsJsonString($inputJson, $object->toJson()); + } +} diff --git a/tests/Core/Json/EnumTest.php b/tests/Core/Json/EnumTest.php index d38e59a1..3655a93e 100644 --- a/tests/Core/Json/EnumTest.php +++ b/tests/Core/Json/EnumTest.php @@ -4,6 +4,7 @@ use JsonSerializable; use PHPUnit\Framework\TestCase; +use Intercom\Core\Json\JsonEncoder; use Intercom\Core\Json\JsonProperty; use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Types\ArrayType; @@ -60,10 +61,10 @@ public function testEnumSerialization(): void [Shape::Square, Shape::Circle, Shape::Triangle] ); - $expectedJson = json_encode([ + $expectedJson = JsonEncoder::encode([ 'shape' => 'CIRCLE', 'shapes' => ['SQUARE', 'CIRCLE', 'TRIANGLE'] - ], JSON_THROW_ON_ERROR); + ]); $actualJson = $object->toJson(); diff --git a/tests/Core/Json/ExhaustiveTest.php b/tests/Core/Json/ExhaustiveTest.php index 1be79b13..4713d21c 100644 --- a/tests/Core/Json/ExhaustiveTest.php +++ b/tests/Core/Json/ExhaustiveTest.php @@ -4,6 +4,7 @@ use DateTime; use PHPUnit\Framework\TestCase; +use Intercom\Core\Json\JsonEncoder; use Intercom\Core\Json\JsonProperty; use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Types\ArrayType; @@ -136,7 +137,7 @@ class ExhaustiveTest extends TestCase */ public function testExhaustive(): void { - $expectedJson = json_encode( + $expectedJson = JsonEncoder::encode( [ 'nested_type' => ['nested_property' => '1995-07-20'], 'simple_property' => 'Test String', @@ -155,7 +156,6 @@ public function testExhaustive(): void ], 'dates_array' => ['2023-01-01', null, '2023-03-01'] // Testing nullable dates in array> ], - JSON_THROW_ON_ERROR ); $object = Type::fromJson($expectedJson); diff --git a/tests/Core/Json/InvalidTest.php b/tests/Core/Json/InvalidTest.php index 7630e3f7..92296835 100644 --- a/tests/Core/Json/InvalidTest.php +++ b/tests/Core/Json/InvalidTest.php @@ -3,6 +3,7 @@ namespace Intercom\Tests\Core\Json; use PHPUnit\Framework\TestCase; +use Intercom\Core\Json\JsonEncoder; use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Json\JsonProperty; @@ -31,11 +32,10 @@ class InvalidTest extends TestCase public function testInvalidJsonThrowsException(): void { $this->expectException(\TypeError::class); - $json = json_encode( + $json = JsonEncoder::encode( [ 'integer_property' => 'not_an_integer' ], - JSON_THROW_ON_ERROR ); Invalid::fromJson($json); } diff --git a/tests/Core/Json/NestedUnionArrayTest.php b/tests/Core/Json/NestedUnionArrayTest.php index f6570f6a..565d4499 100644 --- a/tests/Core/Json/NestedUnionArrayTest.php +++ b/tests/Core/Json/NestedUnionArrayTest.php @@ -4,6 +4,7 @@ use DateTime; use PHPUnit\Framework\TestCase; +use Intercom\Core\Json\JsonEncoder; use Intercom\Core\Json\JsonProperty; use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Types\ArrayType; @@ -55,7 +56,7 @@ class NestedUnionArrayTest extends TestCase { public function testNestedUnionArray(): void { - $expectedJson = json_encode( + $expectedJson = JsonEncoder::encode( [ 'nested_array' => [ 1 => [ @@ -69,7 +70,6 @@ public function testNestedUnionArray(): void ] ] ], - JSON_THROW_ON_ERROR ); $object = NestedUnionArray::fromJson($expectedJson); diff --git a/tests/Core/Json/NullPropertyTest.php b/tests/Core/Json/NullPropertyTest.php index 1656b1ba..b008b173 100644 --- a/tests/Core/Json/NullPropertyTest.php +++ b/tests/Core/Json/NullPropertyTest.php @@ -2,9 +2,12 @@ namespace Intercom\Tests\Core\Json; +use DateTime; use PHPUnit\Framework\TestCase; +use JsonException; use Intercom\Core\Json\JsonProperty; use Intercom\Core\Json\JsonSerializableType; +use Intercom\Core\Types\Date; class NullProperty extends JsonSerializableType { @@ -20,10 +23,24 @@ class NullProperty extends JsonSerializableType #[JsonProperty('null_property')] public ?string $nullProperty; + /** + * @var DateTime|null $nullDate + */ + #[JsonProperty('null_date'), Date(Date::TYPE_DATE)] + public ?DateTime $nullDate; + + /** + * @var DateTime|null $nullDateTime + */ + #[JsonProperty('null_datetime'), Date(Date::TYPE_DATETIME)] + public ?DateTime $nullDateTime; + /** * @param array{ * nonNullProperty: string, * nullProperty?: string|null, + * nullDate?: DateTime|null, + * nullDateTime?: DateTime|null, * } $values */ public function __construct( @@ -31,6 +48,8 @@ public function __construct( ) { $this->nonNullProperty = $values['nonNullProperty']; $this->nullProperty = $values['nullProperty'] ?? null; + $this->nullDate = $values['nullDate'] ?? null; + $this->nullDateTime = $values['nullDateTime'] ?? null; } } @@ -50,4 +69,34 @@ public function testNullPropertiesAreOmitted(): void $this->assertArrayNotHasKey('null_property', $serialized, 'null_property should be omitted from the serialized JSON.'); $this->assertEquals('Test String', $serialized['non_null_property'], 'non_null_property should have the correct value.'); } + + public function testNullDatePropertiesDeserialize(): void + { + $object = NullProperty::fromJson('{"non_null_property": "Test String", "null_date": null, "null_datetime": null}'); + $this->assertEquals('Test String', $object->nonNullProperty); + $this->assertNull($object->nullDate, 'null_date should deserialize to null.'); + $this->assertNull($object->nullDateTime, 'null_datetime should deserialize to null.'); + } + + public function testMissingDatePropertiesDeserialize(): void + { + $object = NullProperty::fromJson('{"non_null_property": "Test String"}'); + $this->assertNull($object->nullDate, 'Omitted null_date should deserialize to null.'); + $this->assertNull($object->nullDateTime, 'Omitted null_datetime should deserialize to null.'); + } + + public function testNonNullDatePropertiesDeserialize(): void + { + $object = NullProperty::fromJson('{"non_null_property": "Test String", "null_date": "2023-01-01", "null_datetime": "2023-01-01T12:00:00Z"}'); + $this->assertInstanceOf(DateTime::class, $object->nullDate); + $this->assertEquals('2023-01-01', $object->nullDate->format('Y-m-d')); + $this->assertInstanceOf(DateTime::class, $object->nullDateTime); + $this->assertEquals('2023-01-01T12:00:00+00:00', $object->nullDateTime->format(DateTime::ATOM)); + } + + public function testInvalidDatePropertyThrows(): void + { + $this->expectException(JsonException::class); + NullProperty::fromJson('{"non_null_property": "Test String", "null_datetime": 12345}'); + } } diff --git a/tests/Core/Json/NullableArrayTest.php b/tests/Core/Json/NullableArrayTest.php index 9b3a1192..7512e5b0 100644 --- a/tests/Core/Json/NullableArrayTest.php +++ b/tests/Core/Json/NullableArrayTest.php @@ -3,6 +3,7 @@ namespace Intercom\Tests\Core\Json; use PHPUnit\Framework\TestCase; +use Intercom\Core\Json\JsonEncoder; use Intercom\Core\Json\JsonProperty; use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Types\ArrayType; @@ -33,11 +34,10 @@ class NullableArrayTest extends TestCase { public function testNullableArray(): void { - $expectedJson = json_encode( + $expectedJson = JsonEncoder::encode( [ 'nullable_string_array' => ['one', null, 'three'] ], - JSON_THROW_ON_ERROR ); $object = NullableArray::fromJson($expectedJson); diff --git a/tests/Core/Json/ScalarTest.php b/tests/Core/Json/ScalarTest.php index ae30aace..8db4ddd8 100644 --- a/tests/Core/Json/ScalarTest.php +++ b/tests/Core/Json/ScalarTest.php @@ -3,6 +3,7 @@ namespace Intercom\Tests\Core\Json; use PHPUnit\Framework\TestCase; +use Intercom\Core\Json\JsonEncoder; use Intercom\Core\Json\JsonProperty; use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Types\ArrayType; @@ -89,7 +90,7 @@ class ScalarTest extends TestCase { public function testAllScalarTypesIncludingFloat(): void { - $expectedJson = json_encode( + $expectedJson = JsonEncoder::encode( [ 'integer_property' => 42, 'float_property' => 3.14159, @@ -99,7 +100,6 @@ public function testAllScalarTypesIncludingFloat(): void 'int_float_array' => [1, 2.5, 3, 4.75], 'float_array' => [1, 2, 3, 4] // Ensure we handle "integer-looking" floats ], - JSON_THROW_ON_ERROR ); $object = Scalar::fromJson($expectedJson); diff --git a/tests/Core/Json/TraitTest.php b/tests/Core/Json/TraitTest.php index df149de6..31dc377e 100644 --- a/tests/Core/Json/TraitTest.php +++ b/tests/Core/Json/TraitTest.php @@ -3,6 +3,7 @@ namespace Intercom\Tests\Core\Json; use PHPUnit\Framework\TestCase; +use Intercom\Core\Json\JsonEncoder; use Intercom\Core\Json\JsonProperty; use Intercom\Core\Json\JsonSerializableType; @@ -42,12 +43,11 @@ class TraitTest extends TestCase { public function testTraitPropertyAndString(): void { - $expectedJson = json_encode( + $expectedJson = JsonEncoder::encode( [ 'integer_property' => 42, 'string_property' => 'Hello, World!', ], - JSON_THROW_ON_ERROR ); $object = TypeWithTrait::fromJson($expectedJson); diff --git a/tests/Core/Json/UnionArrayTest.php b/tests/Core/Json/UnionArrayTest.php index 5a7d58ec..6eae2cc4 100644 --- a/tests/Core/Json/UnionArrayTest.php +++ b/tests/Core/Json/UnionArrayTest.php @@ -4,6 +4,7 @@ use DateTime; use PHPUnit\Framework\TestCase; +use Intercom\Core\Json\JsonEncoder; use Intercom\Core\Json\JsonProperty; use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Types\ArrayType; @@ -34,7 +35,7 @@ class UnionArrayTest extends TestCase { public function testUnionArray(): void { - $expectedJson = json_encode( + $expectedJson = JsonEncoder::encode( [ 'mixed_dates' => [ 1 => '2023-01-01T12:00:00Z', @@ -42,7 +43,6 @@ public function testUnionArray(): void 3 => 'Some String' ] ], - JSON_THROW_ON_ERROR ); $object = UnionArray::fromJson($expectedJson); diff --git a/tests/Core/Json/UnionPropertyTest.php b/tests/Core/Json/UnionPropertyTest.php index 1fafd95f..7d264d2f 100644 --- a/tests/Core/Json/UnionPropertyTest.php +++ b/tests/Core/Json/UnionPropertyTest.php @@ -3,6 +3,7 @@ namespace Intercom\Tests\Core\Json; use PHPUnit\Framework\TestCase; +use Intercom\Core\Json\JsonEncoder; use Intercom\Core\Json\JsonProperty; use Intercom\Core\Json\JsonSerializableType; use Intercom\Core\Types\Union; @@ -29,11 +30,10 @@ class UnionPropertyTest extends TestCase { public function testWithMapOfIntToInt(): void { - $expectedJson = json_encode( + $expectedJson = JsonEncoder::encode( [ 'complexUnion' => [1 => 100, 2 => 200] ], - JSON_THROW_ON_ERROR ); $object = UnionProperty::fromJson($expectedJson); @@ -46,7 +46,7 @@ public function testWithMapOfIntToInt(): void public function testWithNestedUnionPropertyType(): void { - $expectedJson = json_encode( + $expectedJson = JsonEncoder::encode( [ 'complexUnion' => new UnionProperty( [ @@ -54,7 +54,6 @@ public function testWithNestedUnionPropertyType(): void ] ) ], - JSON_THROW_ON_ERROR ); $object = UnionProperty::fromJson($expectedJson); @@ -67,10 +66,7 @@ public function testWithNestedUnionPropertyType(): void public function testWithNull(): void { - $expectedJson = json_encode( - [], - JSON_THROW_ON_ERROR - ); + $expectedJson = '{}'; $object = UnionProperty::fromJson($expectedJson); $this->assertNull($object->complexUnion, 'complexUnion should be null.'); @@ -81,11 +77,10 @@ public function testWithNull(): void public function testWithInteger(): void { - $expectedJson = json_encode( + $expectedJson = JsonEncoder::encode( [ 'complexUnion' => 42 ], - JSON_THROW_ON_ERROR ); $object = UnionProperty::fromJson($expectedJson); @@ -98,11 +93,10 @@ public function testWithInteger(): void public function testWithString(): void { - $expectedJson = json_encode( + $expectedJson = JsonEncoder::encode( [ 'complexUnion' => 'Some String' ], - JSON_THROW_ON_ERROR ); $object = UnionProperty::fromJson($expectedJson); diff --git a/tests/Core/Pagination/CursorPagerTest/CursorPagerTest.php b/tests/Core/Pagination/CursorPagerTest/CursorPagerTest.php index 5530891f..7d60ab57 100644 --- a/tests/Core/Pagination/CursorPagerTest/CursorPagerTest.php +++ b/tests/Core/Pagination/CursorPagerTest/CursorPagerTest.php @@ -127,6 +127,6 @@ private function assertPager(Pager $pager): void // no more pages $pages->next(); - $this->assertNull($pages->current()); + $this->assertFalse($pages->valid()); } } diff --git a/tests/Core/Pagination/HasNextPageOffsetPagerTest/HasNextPageOffsetPagerTest.php b/tests/Core/Pagination/HasNextPageOffsetPagerTest/HasNextPageOffsetPagerTest.php index 5a771d86..0a0e04f7 100644 --- a/tests/Core/Pagination/HasNextPageOffsetPagerTest/HasNextPageOffsetPagerTest.php +++ b/tests/Core/Pagination/HasNextPageOffsetPagerTest/HasNextPageOffsetPagerTest.php @@ -81,7 +81,7 @@ function (Request $request) use ($responses) { $responses->next(); return $response; }, - fn (Request $request) => $request->pagination?->page ?? 0, + fn (Request $request) => $request->pagination->page ?? 0, function (Request $request, int $offset) { if ($request->pagination === null) { $request->pagination = new Pagination(0); diff --git a/tests/Core/Pagination/IntOffsetPagerTest/IntOffsetPagerTest.php b/tests/Core/Pagination/IntOffsetPagerTest/IntOffsetPagerTest.php index e0e3dec8..612eb9f0 100644 --- a/tests/Core/Pagination/IntOffsetPagerTest/IntOffsetPagerTest.php +++ b/tests/Core/Pagination/IntOffsetPagerTest/IntOffsetPagerTest.php @@ -79,7 +79,7 @@ function (Request $request) use ($responses) { $responses->next(); return $response; }, - fn (Request $request) => $request->pagination?->page ?? 0, + fn (Request $request) => $request->pagination->page ?? 0, function (Request $request, int $offset) { if ($request->pagination === null) { $request->pagination = new Pagination(0); diff --git a/tests/Core/Pagination/StepOffsetPagerTest/StepOffsetPagerTest.php b/tests/Core/Pagination/StepOffsetPagerTest/StepOffsetPagerTest.php index 1d3d916b..ec0472db 100644 --- a/tests/Core/Pagination/StepOffsetPagerTest/StepOffsetPagerTest.php +++ b/tests/Core/Pagination/StepOffsetPagerTest/StepOffsetPagerTest.php @@ -85,7 +85,7 @@ function (Request $request) use ($responses) { $responses->next(); return $response; }, - fn (Request $request) => $request->pagination?->itemOffset ?? 0, + fn (Request $request) => $request->pagination->itemOffset ?? 0, function (Request $request, int $offset) { if ($request->pagination === null) { $request->pagination = new Pagination(0, 2); @@ -126,6 +126,6 @@ private function assertPager(Pager $pager): void // no more pages $pages->next(); - $this->assertNull($pages->current()); + $this->assertFalse($pages->valid()); } } diff --git a/tests/Legacy/IntercomResourcePathTest.php b/tests/Legacy/IntercomResourcePathTest.php index 67bbcd78..96de264f 100644 --- a/tests/Legacy/IntercomResourcePathTest.php +++ b/tests/Legacy/IntercomResourcePathTest.php @@ -8,6 +8,7 @@ use GuzzleHttp\Psr7\Response; use Intercom\Legacy\IntercomClient; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; class IntercomResourcePathTest extends TestCase @@ -49,16 +50,14 @@ public function testKeepsPlainIdUnchanged(): void $this->assertSame('users/abc123', $this->client->users->userPath('abc123')); } - /** - * @dataProvider invalidIdProvider - */ + #[DataProvider('invalidIdProvider')] public function testRejectsDotSegmentId(string $id): void { $this->expectException(InvalidArgumentException::class); $this->client->contacts->getContact($id); } - public function invalidIdProvider(): array + public static function invalidIdProvider(): array { return [[''], ['.'], ['..']]; }