diff --git a/.github/workflows/label-ai-generated-prs.yml b/.github/workflows/label-ai-generated-prs.yml deleted file mode 100644 index 547cbfec..00000000 --- a/.github/workflows/label-ai-generated-prs.yml +++ /dev/null @@ -1,11 +0,0 @@ -# .github/workflows/label-ai-generated-prs.yml -name: Label AI-generated PRs - -on: - pull_request: - types: [opened, edited, synchronize] # run when the body changes too - -jobs: - call-label-ai-prs: - uses: intercom/github-action-workflows/.github/workflows/label-ai-prs.yml@main - secrets: inherit \ No newline at end of file diff --git a/README.md b/README.md index dce13154..08d01dae 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ npm i -s intercom-client ## Reference -A full reference for this library is available [here](./reference.md). +A full reference for this library is available [here](https://github.com/intercom/intercom-node/blob/HEAD/./reference.md). ## Usage @@ -64,6 +64,7 @@ try { console.log(err.statusCode); console.log(err.message); console.log(err.body); + console.log(err.rawResponse); } } ``` @@ -144,6 +145,18 @@ const response = await client.articles.create(..., { controller.abort(); // aborts the request ``` +### Access Raw Response Data + +The SDK provides access to raw response data, including headers, through the `.withRawResponse()` method. +The `.withRawResponse()` method returns a promise that results to an object with a `data` and a `rawResponse` property. + +```typescript +const { data, rawResponse } = await client.articles.create(...).withRawResponse(); + +console.log(data); +console.log(rawResponse.headers['X-My-Header']); +``` + ### Runtime Compatibility The SDK defaults to `node-fetch` but will use the global fetch client if present. The SDK works in the following @@ -158,7 +171,7 @@ runtimes: ### Customizing Fetch Client -The SDK provides a way for your to customize the underlying HTTP client / Fetch function. If you're running in an +The SDK provides a way for you to customize the underlying HTTP client / Fetch function. If you're running in an unsupported environment, this provides a way for you to break glass and ensure the SDK works. ```typescript diff --git a/package.json b/package.json index e3b19250..00b818fa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "intercom-client", - "version": "6.3.0", + "version": "6.4.0", "private": false, "repository": "https://github.com/intercom/intercom-node", "main": "./index.js", @@ -40,6 +40,7 @@ "os": false, "path": false }, + "packageManager": "yarn@1.22.22", "license": "Apache-2.0", "description": "Official Node bindings to the Intercom API", "homepage": "https://github.com/intercom/intercom-node", diff --git a/reference.md b/reference.md index a73a1fe3..df65e9f7 100644 --- a/reference.md +++ b/reference.md @@ -6833,168 +6833,6 @@ await client.visitors.mergeToContact({ -## CustomChannelEvents - -
client.customChannelEvents.notifyAttributeCollected() -> void -
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.customChannelEvents.notifyAttributeCollected(); -``` - -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**requestOptions:** `CustomChannelEvents.RequestOptions` - -
-
-
-
- -
-
-
- -
client.customChannelEvents.notifyNewMessage() -> void -
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.customChannelEvents.notifyNewMessage(); -``` - -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**requestOptions:** `CustomChannelEvents.RequestOptions` - -
-
-
-
- -
-
-
- -
client.customChannelEvents.notifyNewConversation() -> void -
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.customChannelEvents.notifyNewConversation(); -``` - -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**requestOptions:** `CustomChannelEvents.RequestOptions` - -
-
-
-
- -
-
-
- -
client.customChannelEvents.notifyQuickReplySelected() -> void -
-
- -#### 🔌 Usage - -
-
- -
-
- -```typescript -await client.customChannelEvents.notifyQuickReplySelected(); -``` - -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**requestOptions:** `CustomChannelEvents.RequestOptions` - -
-
-
-
- -
-
-
- ## HelpCenters Collections
client.helpCenters.collections.list({ ...params }) -> core.Page @@ -7976,3 +7814,9265 @@ await client.ticketTypes.attributes.update({
+ +## Admins + +
client.unstable.admins.identifyAdmin() -> Intercom.AdminWithApp | undefined +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can view the currently authorised admin along with the embedded app object (a "workspace" in legacy terminology). + +> 🚧 Single Sign On +> +> 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. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.admins.identifyAdmin(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `Admins.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.admins.setAwayAdmin({ ...params }) -> Intercom.Admin | undefined +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can set an Admin as away for the Inbox. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.admins.setAwayAdmin({ + id: 1, + away_mode_enabled: true, + away_mode_reassign: true, + away_status_reason_id: 12345, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.SetAwayAdminRequest` + +
+
+ +
+
+ +**requestOptions:** `Admins.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.admins.listActivityLogs({ ...params }) -> Intercom.ActivityLogList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can get a log of activities by all admins in an app. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.admins.listActivityLogs({ + created_at_after: "1677253093", + created_at_before: "1677861493", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.ListActivityLogsRequest` + +
+
+ +
+
+ +**requestOptions:** `Admins.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.admins.listAdmins() -> Intercom.AdminList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of admins for a given workspace. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.admins.listAdmins(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `Admins.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.admins.retrieveAdmin({ ...params }) -> Intercom.Admin | undefined +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can retrieve the details of a single admin. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.admins.retrieveAdmin({ + id: 1, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.RetrieveAdminRequest` + +
+
+ +
+
+ +**requestOptions:** `Admins.RequestOptions` + +
+
+
+
+ +
+
+
+ +## AI Content + +
client.unstable.aiContent.listContentImportSources() -> Intercom.ContentImportSourcesList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can retrieve a list of all content import sources for a workspace. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.aiContent.listContentImportSources(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `AiContent.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.aiContent.createContentImportSource({ ...params }) -> Intercom.ContentImportSource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new content import source by sending a POST request to this endpoint. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.aiContent.createContentImportSource({ + url: "https://www.example.com", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.CreateContentImportSourceRequest` + +
+
+ +
+
+ +**requestOptions:** `AiContent.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.aiContent.getContentImportSource({ ...params }) -> Intercom.ContentImportSource +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.aiContent.getContentImportSource({ + id: "id", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.GetContentImportSourceRequest` + +
+
+ +
+
+ +**requestOptions:** `AiContent.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.aiContent.updateContentImportSource({ ...params }) -> Intercom.ContentImportSource +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update an existing content import source. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.aiContent.updateContentImportSource({ + id: "id", + sync_behavior: "api", + url: "https://www.example.com", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.UpdateContentImportSourceRequest` + +
+
+ +
+
+ +**requestOptions:** `AiContent.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.aiContent.deleteContentImportSource({ ...params }) -> void +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.aiContent.deleteContentImportSource({ + id: "id", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.DeleteContentImportSourceRequest` + +
+
+ +
+
+ +**requestOptions:** `AiContent.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.aiContent.listExternalPages() -> Intercom.ExternalPagesList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can retrieve a list of all external pages for a workspace. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.aiContent.listExternalPages(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `AiContent.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.aiContent.createExternalPage({ ...params }) -> Intercom.ExternalPage +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.aiContent.createExternalPage({ + title: "Test", + html: "

Test

", + url: "https://www.example.com", + source_id: 44, + external_id: "abc1234", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.CreateExternalPageRequest` + +
+
+ +
+
+ +**requestOptions:** `AiContent.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.aiContent.getExternalPage({ ...params }) -> Intercom.ExternalPage +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can retrieve an external page. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.aiContent.getExternalPage({ + id: "id", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.GetExternalPageRequest` + +
+
+ +
+
+ +**requestOptions:** `AiContent.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.aiContent.updateExternalPage({ ...params }) -> Intercom.ExternalPage +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update an existing external page (if it was created via the API). + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.aiContent.updateExternalPage({ + id: "id", + title: "Test", + html: "

Test

", + url: "https://www.example.com", + source_id: 47, + external_id: "5678", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.UpdateExternalPageRequest` + +
+
+ +
+
+ +**requestOptions:** `AiContent.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.aiContent.deleteExternalPage({ ...params }) -> Intercom.ExternalPage +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Sending a DELETE request for an external page will remove it from the content library UI and from being used for AI answers. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.aiContent.deleteExternalPage({ + id: "id", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.DeleteExternalPageRequest` + +
+
+ +
+
+ +**requestOptions:** `AiContent.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Articles + +
client.unstable.articles.listArticles() -> Intercom.ArticleList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all articles by making a GET request to `https://api.intercom.io/articles`. + +> 📘 How are the articles sorted and ordered? +> +> 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. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.articles.listArticles(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `Articles.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.articles.createArticle({ ...params }) -> Intercom.Article +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new article by making a POST request to `https://api.intercom.io/articles`. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.articles.createArticle({ + key: "value", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `unknown` + +
+
+ +
+
+ +**requestOptions:** `Articles.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.articles.retrieveArticle({ ...params }) -> Intercom.Article +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single article by making a GET request to `https://api.intercom.io/articles/`. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.articles.retrieveArticle({ + id: 1, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.RetrieveArticleRequest` + +
+
+ +
+
+ +**requestOptions:** `Articles.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.articles.deleteArticle({ ...params }) -> Intercom.DeletedArticleObject +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single article by making a DELETE request to `https://api.intercom.io/articles/`. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.articles.deleteArticle({ + id: 1, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.DeleteArticleRequest` + +
+
+ +
+
+ +**requestOptions:** `Articles.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.articles.searchArticles({ ...params }) -> Intercom.ArticleSearchResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can search for articles by making a GET request to `https://api.intercom.io/articles/search`. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.articles.searchArticles({ + phrase: "Getting started", + state: "published", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.SearchArticlesRequest` + +
+
+ +
+
+ +**requestOptions:** `Articles.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Away Status Reasons + +
client.unstable.awayStatusReasons.listAwayStatusReasons() -> Intercom.AwayStatusReason[] +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Returns a list of all away status reasons configured for the workspace, including deleted ones. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.awayStatusReasons.listAwayStatusReasons(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `AwayStatusReasons.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Unstable Export + +
client.unstable.export.enqueueANewReportingDataExportJob({ ...params }) -> Intercom.PostExportReportingDataEnqueueResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.export.enqueueANewReportingDataExportJob({ + dataset_id: "conversation", + attribute_ids: ["conversation.id", "conversation.first_user_conversation_part_created_at"], + start_time: 1717490000, + end_time: 1717510000, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.PostExportReportingDataEnqueueRequest` + +
+
+ +
+
+ +**requestOptions:** `Export.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.export.listAvailableDatasetsAndAttributes() -> Intercom.GetExportReportingDataGetDatasetsResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.export.listAvailableDatasetsAndAttributes(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `Export.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Help Center + +
client.unstable.helpCenter.listAllCollections() -> Intercom.CollectionList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all collections by making a GET request to `https://api.intercom.io/help_center/collections`. + +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. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.helpCenter.listAllCollections(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `HelpCenter.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.helpCenter.createCollection({ ...params }) -> Intercom.Collection +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new collection by making a POST request to `https://api.intercom.io/help_center/collections.` + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.helpCenter.createCollection({ + name: "Thanks for everything", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.CreateCollectionRequest` + +
+
+ +
+
+ +**requestOptions:** `HelpCenter.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.helpCenter.retrieveCollection({ ...params }) -> Intercom.Collection +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single collection by making a GET request to `https://api.intercom.io/help_center/collections/`. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.helpCenter.retrieveCollection({ + id: 1, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.RetrieveCollectionRequest` + +
+
+ +
+
+ +**requestOptions:** `HelpCenter.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.helpCenter.updateCollection({ ...params }) -> Intercom.Collection +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update the details of a single collection by making a PUT request to `https://api.intercom.io/collections/`. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.helpCenter.updateCollection({ + id: 1, + name: "Update collection name", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.UpdateCollectionRequest` + +
+
+ +
+
+ +**requestOptions:** `HelpCenter.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.helpCenter.deleteCollection({ ...params }) -> Intercom.DeletedCollectionObject +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single collection by making a DELETE request to `https://api.intercom.io/collections/`. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.helpCenter.deleteCollection({ + id: 1, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.DeleteCollectionRequest` + +
+
+ +
+
+ +**requestOptions:** `HelpCenter.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.helpCenter.retrieveHelpCenter({ ...params }) -> Intercom.HelpCenter +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single Help Center by making a GET request to `https://api.intercom.io/help_center/help_center/`. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.helpCenter.retrieveHelpCenter({ + id: 1, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.RetrieveHelpCenterRequest` + +
+
+ +
+
+ +**requestOptions:** `HelpCenter.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.helpCenter.listHelpCenters() -> Intercom.HelpCenterList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can list all Help Centers by making a GET request to `https://api.intercom.io/help_center/help_centers`. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.helpCenter.listHelpCenters(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `HelpCenter.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Companies + +
client.unstable.companies.retrieveCompany({ ...params }) -> Intercom.CompanyList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a single company by passing in `company_id` or `name`. + +`https://api.intercom.io/companies?name={name}` + +`https://api.intercom.io/companies?company_id={company_id}` + +You can fetch all companies and filter by `segment_id` or `tag_id` as a query parameter. + +`https://api.intercom.io/companies?tag_id={tag_id}` + +`https://api.intercom.io/companies?segment_id={segment_id}` + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.companies.retrieveCompany({ + name: "my company", + company_id: "12345", + tag_id: "678910", + segment_id: "98765", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.RetrieveCompanyRequest` + +
+
+ +
+
+ +**requestOptions:** `Companies.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.companies.createOrUpdateCompany({ ...params }) -> Intercom.Company +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create or update a company. + +Companies will be only visible in Intercom when there is at least one associated user. + +Companies are looked up via `company_id` in a `POST` request, if not found via `company_id`, the new company will be created, if found, that company will be updated. + +{% admonition type="warning" name="Using `company_id`" %} +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 %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.companies.createOrUpdateCompany({ + key: "value", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `unknown` + +
+
+ +
+
+ +**requestOptions:** `Companies.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.companies.retrieveACompanyById({ ...params }) -> Intercom.Company +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a single company. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.companies.retrieveACompanyById({ + id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.RetrieveACompanyByIdRequest` + +
+
+ +
+
+ +**requestOptions:** `Companies.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.companies.updateCompany({ ...params }) -> Intercom.Company +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update a single company using the Intercom provisioned `id`. + +{% admonition type="warning" name="Using `company_id`" %} +When updating a company it is not possible to update `company_id`. This can only be set once upon creation of the company. +{% /admonition %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.companies.updateCompany({ + id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.UpdateCompanyRequest` + +
+
+ +
+
+ +**requestOptions:** `Companies.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.companies.deleteCompany({ ...params }) -> Intercom.DeletedCompanyObject +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single company. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.companies.deleteCompany({ + id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.DeleteCompanyRequest` + +
+
+ +
+
+ +**requestOptions:** `Companies.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.companies.listAttachedContacts({ ...params }) -> Intercom.CompanyAttachedContacts +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all contacts that belong to a company. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.companies.listAttachedContacts({ + id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.ListAttachedContactsRequest` + +
+
+ +
+
+ +**requestOptions:** `Companies.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.companies.listAttachedSegmentsForCompanies({ ...params }) -> Intercom.CompanyAttachedSegments +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all segments that belong to a company. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.companies.listAttachedSegmentsForCompanies({ + id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.ListAttachedSegmentsForCompaniesRequest` + +
+
+ +
+
+ +**requestOptions:** `Companies.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.companies.listAllCompanies({ ...params }) -> Intercom.CompanyList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can list companies. The company list is sorted by the `last_request_at` field and by default is ordered descending, most recently requested first. + +Note that the API does not include companies who have no associated users in list responses. + +When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the [Scroll API](https://developers.intercom.com/reference#iterating-over-all-companies). +{% admonition type="warning" name="Pagination" %} +You can use pagination to limit the number of results returned. The default is `20` results per page. +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 %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.companies.listAllCompanies({ + order: "desc", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.ListAllCompaniesRequest` + +
+
+ +
+
+ +**requestOptions:** `Companies.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.companies.scrollOverAllCompanies({ ...params }) -> Intercom.CompanyScroll | undefined +
+
+ +#### 📝 Description + +
+
+ +
+
+ + The `list all companies` functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset. + +- Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app. +- If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail +- If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire + +{% admonition type="info" name="Scroll Parameter" %} +You can get the first page of companies by simply sending a GET request to the scroll endpoint. +For subsequent requests you will need to use the scroll parameter from the response. +{% /admonition %} +{% admonition type="danger" name="Scroll network timeouts" %} +Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message: +"Request failed due to an internal network error. Please restart the scroll operation." +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 %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.companies.scrollOverAllCompanies(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.ScrollOverAllCompaniesRequest` + +
+
+ +
+
+ +**requestOptions:** `Companies.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.companies.attachContactToACompany({ ...params }) -> Intercom.Company +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can attach a company to a single contact. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.companies.attachContactToACompany({ + id: "id", + company_id: "6762f09a1bb69f9f2193bb34", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.AttachContactToACompanyRequest` + +
+
+ +
+
+ +**requestOptions:** `Companies.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.companies.detachContactFromACompany({ ...params }) -> Intercom.Company +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can detach a company from a single contact. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.companies.detachContactFromACompany({ + contact_id: "58a430d35458202d41b1e65b", + id: "58a430d35458202d41b1e65b", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.DetachContactFromACompanyRequest` + +
+
+ +
+
+ +**requestOptions:** `Companies.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Contacts + +
client.unstable.contacts.listCompaniesForAContact({ ...params }) -> Intercom.ContactAttachedCompanies +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of companies that are associated to a contact. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.contacts.listCompaniesForAContact({ + id: "63a07ddf05a32042dffac965", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.ListCompaniesForAContactRequest` + +
+
+ +
+
+ +**requestOptions:** `Contacts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.contacts.listSegmentsForAContact({ ...params }) -> Intercom.ContactSegments +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of segments that are associated to a contact. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.contacts.listSegmentsForAContact({ + contact_id: "63a07ddf05a32042dffac965", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.ListSegmentsForAContactRequest` + +
+
+ +
+
+ +**requestOptions:** `Contacts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.contacts.listSubscriptionsForAContact({ ...params }) -> Intercom.SubscriptionTypeList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of subscription types that are attached to a contact. These can be subscriptions that a user has 'opted-in' to or has 'opted-out' from, depending on the subscription type. +This will return a list of Subscription Type objects that the contact is associated with. + +The data property will show a combined list of: + +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. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.contacts.listSubscriptionsForAContact({ + contact_id: "63a07ddf05a32042dffac965", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.ListSubscriptionsForAContactRequest` + +
+
+ +
+
+ +**requestOptions:** `Contacts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.contacts.listTagsForAContact({ ...params }) -> Intercom.TagList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all tags that are attached to a specific contact. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.contacts.listTagsForAContact({ + contact_id: "63a07ddf05a32042dffac965", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.ListTagsForAContactRequest` + +
+
+ +
+
+ +**requestOptions:** `Contacts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.contacts.showContact({ ...params }) -> Intercom.ShowContactResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single contact. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.contacts.showContact({ + id: "63a07ddf05a32042dffac965", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.ShowContactRequest` + +
+
+ +
+
+ +**requestOptions:** `Contacts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.contacts.updateContact({ ...params }) -> Intercom.UpdateContactResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update an existing contact (ie. user or lead). + +{% admonition type="info" %} +This endpoint handles both **contact updates** and **custom object associations**. + +See _`update a contact with an association to a custom object instance`_ in the request/response examples to see the custom object association format. +{% /admonition %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.contacts.updateContact({ + id: "63a07ddf05a32042dffac965", + email: "joebloggs@intercom.io", + name: "joe bloggs", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.UpdateContactRequest` + +
+
+ +
+
+ +**requestOptions:** `Contacts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.contacts.deleteContact({ ...params }) -> Intercom.ContactDeleted +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single contact. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.contacts.deleteContact({ + id: "id", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.DeleteContactRequest` + +
+
+ +
+
+ +**requestOptions:** `Contacts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.contacts.mergeContact({ ...params }) -> Intercom.MergeContactResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can merge a contact with a `role` of `lead` into a contact with a `role` of `user`. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.contacts.mergeContact({ + from: "6762f0d51bb69f9f2193bb7f", + into: "6762f0d51bb69f9f2193bb80", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.MergeContactsRequest` + +
+
+ +
+
+ +**requestOptions:** `Contacts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.contacts.searchContacts({ ...params }) -> Intercom.ContactList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can search for multiple contacts by the value of their attributes in order to fetch exactly who you want. + +To search for contacts, you need to send a `POST` request to `https://api.intercom.io/contacts/search`. + +This will accept a query object in the body which will define your filters in order to search for contacts. + +{% admonition type="warning" name="Optimizing search queries" %} +Search queries can be complex, so optimizing them can help the performance of your search. +Use the `AND` and `OR` operators to combine multiple filters to get the exact results you need and utilize +pagination to limit the number of results returned. The default is `50` results per page. +See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param. +{% /admonition %} + +### Contact Creation Delay + +If a contact has recently been created, there is a possibility that it will not yet be available when searching. This means that it may not appear in the response. This delay can take a few minutes. If you need to be instantly notified it is recommended to use webhooks and iterate to see if they match your search filters. + +### Nesting & Limitations + +You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). +There are some limitations to the amount of multiple's there can be: + +- There's a limit of max 2 nested filters +- There's a limit of max 15 filters for each AND or OR group + +### Searching for Timestamp Fields + +All timestamp fields (created_at, updated_at etc.) are indexed as Dates for Contact Search queries; Datetime queries are not currently supported. This means you can only query for timestamp fields by day - not hour, minute or second. +For example, if you search for all Contacts with a created_at value greater (>) than 1577869200 (the UNIX timestamp for January 1st, 2020 9:00 AM), that will be interpreted as 1577836800 (January 1st, 2020 12:00 AM). The search results will then include Contacts created from January 2nd, 2020 12:00 AM onwards. +If you'd like to get contacts created on January 1st, 2020 you should search with a created_at value equal (=) to 1577836800 (January 1st, 2020 12:00 AM). +This behaviour applies only to timestamps used in search queries. The search results will still contain the full UNIX timestamp and be sorted accordingly. + +### Accepted Fields + +Most key listed as part of the Contacts Model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foorbar"`). + +| Field | Type | +| ---------------------------------- | ------------------------------ | +| id | String | +| role | String
Accepts user or lead | +| name | String | +| avatar | String | +| owner_id | Integer | +| email | String | +| email_domain | String | +| phone | String | +| formatted_phone | String | +| external_id | String | +| created_at | Date (UNIX Timestamp) | +| signed_up_at | Date (UNIX Timestamp) | +| updated_at | Date (UNIX Timestamp) | +| last_seen_at | Date (UNIX Timestamp) | +| last_contacted_at | Date (UNIX Timestamp) | +| last_replied_at | Date (UNIX Timestamp) | +| last_email_opened_at | Date (UNIX Timestamp) | +| last_email_clicked_at | Date (UNIX Timestamp) | +| language_override | String | +| browser | String | +| browser_language | String | +| os | String | +| location.country | String | +| location.region | String | +| location.city | String | +| unsubscribed_from_emails | Boolean | +| marked_email_as_spam | Boolean | +| has_hard_bounced | Boolean | +| ios_last_seen_at | Date (UNIX Timestamp) | +| ios_app_version | String | +| ios_device | String | +| ios_app_device | String | +| ios_os_version | String | +| ios_app_name | String | +| ios_sdk_version | String | +| android_last_seen_at | Date (UNIX Timestamp) | +| android_app_version | String | +| android_device | String | +| android_app_name | String | +| andoid_sdk_version | String | +| segment_id | String | +| tag_id | String | +| custom_attributes.{attribute_name} | String | + +### Accepted Operators + +{% admonition type="warning" name="Searching based on `created_at`" %} +You cannot use the `<=` or `>=` operators to search by `created_at`. +{% /admonition %} + +The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). The operator has to be compatible with the field's type (eg. you cannot search with `>` for a given string value as it's only compatible for integer's and dates). + +| Operator | Valid Types | Description | +| :------- | :------------------------------- | :--------------------------------------------------------------- | +| = | All | Equals | +| != | All | Doesn't Equal | +| IN | All | In
Shortcut for `OR` queries
Values must be in Array | +| NIN | All | Not In
Shortcut for `OR !` queries
Values must be in Array | +| > | Integer
Date (UNIX Timestamp) | Greater than | +| < | Integer
Date (UNIX Timestamp) | Lower than | +| ~ | String | Contains | +| !~ | String | Doesn't Contain | +| ^ | String | Starts With | +| $ | String | Ends With | + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.contacts.searchContacts({ + query: { + operator: "AND", + value: [ + { + field: "created_at", + operator: ">", + value: "1306054154", + }, + ], + }, + pagination: { + per_page: 5, + }, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.SearchRequest` + +
+
+ +
+
+ +**requestOptions:** `Contacts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.contacts.listContacts() -> Intercom.ContactList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all contacts (ie. users or leads) in your workspace. +{% admonition type="warning" name="Pagination" %} +You can use pagination to limit the number of results returned. The default is `50` results per page. +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 %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.contacts.listContacts(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `Contacts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.contacts.createContact({ ...params }) -> Intercom.CreateContactResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new contact (ie. user or lead). + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.contacts.createContact({ + email: "joebloggs@intercom.io", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.CreateContactRequestTwo` + +
+
+ +
+
+ +**requestOptions:** `Contacts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.contacts.showContactByExternalId({ ...params }) -> Intercom.ShowContactByExternalIdResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.contacts.showContactByExternalId({ + external_id: "cdd29344-5e0c-4ef0-ac56-f9ba2979bc27", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.ShowContactByExternalIdRequest` + +
+
+ +
+
+ +**requestOptions:** `Contacts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.contacts.archiveContact({ ...params }) -> Intercom.ContactArchived +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can archive a single contact. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.contacts.archiveContact({ + id: "63a07ddf05a32042dffac965", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.ArchiveContactRequest` + +
+
+ +
+
+ +**requestOptions:** `Contacts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.contacts.unarchiveContact({ ...params }) -> Intercom.ContactUnarchived +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can unarchive a single contact. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.contacts.unarchiveContact({ + id: "63a07ddf05a32042dffac965", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.UnarchiveContactRequest` + +
+
+ +
+
+ +**requestOptions:** `Contacts.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.contacts.blockContact({ ...params }) -> Intercom.ContactBlocked +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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) + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.contacts.blockContact({ + id: "63a07ddf05a32042dffac965", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.BlockContactRequest` + +
+
+ +
+
+ +**requestOptions:** `Contacts.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Notes + +
client.unstable.notes.listNotes({ ...params }) -> Intercom.NoteList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of notes that are associated to a contact. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.notes.listNotes({ + id: 1, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.ListNotesRequest` + +
+
+ +
+
+ +**requestOptions:** `Notes.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.notes.createNote({ ...params }) -> Intercom.Note +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can add a note to a single contact. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.notes.createNote({ + id: 1, + body: "Hello", + contact_id: "6762f0ad1bb69f9f2193bb62", + admin_id: "123", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.CreateNoteRequest` + +
+
+ +
+
+ +**requestOptions:** `Notes.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.notes.retrieveNote({ ...params }) -> Intercom.Note +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single note. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.notes.retrieveNote({ + id: 1, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.RetrieveNoteRequest` + +
+
+ +
+
+ +**requestOptions:** `Notes.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Subscription Types + +
client.unstable.subscriptionTypes.attachSubscriptionTypeToContact({ ...params }) -> Intercom.SubscriptionType +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can add a specific subscription to a contact. In Intercom, we have two different subscription types based on user consent - opt-out and opt-in: + +1.Attaching a contact to an opt-out subscription type will opt that user out from receiving messages related to that subscription type. + +2.Attaching a contact to an opt-in subscription type will opt that user in to receiving messages related to that subscription type. + +This will return a subscription type model for the subscription type that was added to the contact. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.subscriptionTypes.attachSubscriptionTypeToContact({ + contact_id: "63a07ddf05a32042dffac965", + id: "37846", + consent_type: "opt_in", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.AttachSubscriptionTypeToContactRequest` + +
+
+ +
+
+ +**requestOptions:** `SubscriptionTypes.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.subscriptionTypes.detachSubscriptionTypeToContact({ ...params }) -> Intercom.SubscriptionType +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.subscriptionTypes.detachSubscriptionTypeToContact({ + contact_id: "63a07ddf05a32042dffac965", + id: "37846", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.DetachSubscriptionTypeToContactRequest` + +
+
+ +
+
+ +**requestOptions:** `SubscriptionTypes.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.subscriptionTypes.listSubscriptionTypes() -> Intercom.SubscriptionTypeList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can list all subscription types. A list of subscription type objects will be returned. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.subscriptionTypes.listSubscriptionTypes(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `SubscriptionTypes.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Tags + +
client.unstable.tags.attachTagToContact({ ...params }) -> Intercom.Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can tag a specific contact. This will return a tag object for the tag that was added to the contact. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.tags.attachTagToContact({ + contact_id: "63a07ddf05a32042dffac965", + id: "7522907", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.AttachTagToContactRequest` + +
+
+ +
+
+ +**requestOptions:** `Tags.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.tags.detachTagFromContact({ ...params }) -> Intercom.Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can remove tag from a specific contact. This will return a tag object for the tag that was removed from the contact. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.tags.detachTagFromContact({ + contact_id: "63a07ddf05a32042dffac965", + id: "7522907", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.DetachTagFromContactRequest` + +
+
+ +
+
+ +**requestOptions:** `Tags.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.tags.attachTagToConversation({ ...params }) -> Intercom.Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can tag a specific conversation. This will return a tag object for the tag that was added to the conversation. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.tags.attachTagToConversation({ + conversation_id: "64619700005694", + id: "7522907", + admin_id: "780", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.AttachTagToConversationRequest` + +
+
+ +
+
+ +**requestOptions:** `Tags.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.tags.detachTagFromConversation({ ...params }) -> Intercom.Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can remove tag from a specific conversation. This will return a tag object for the tag that was removed from the conversation. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.tags.detachTagFromConversation({ + conversation_id: "64619700005694", + id: "7522907", + admin_id: "123", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.DetachTagFromConversationRequest` + +
+
+ +
+
+ +**requestOptions:** `Tags.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.tags.listTags() -> Intercom.TagList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all tags for a given workspace. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.tags.listTags(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `Tags.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.tags.createTag({ ...params }) -> Intercom.Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can use this endpoint to perform the following operations: + +**1. Create a new tag:** You can create a new tag by passing in the tag name as specified in "Create or Update Tag Request Payload" described below. + +**2. Update an existing tag:** You can update an existing tag by passing the id of the tag as specified in "Create or Update Tag Request Payload" described below. + +**3. Tag Companies:** You can tag single company or a list of companies. You can tag a company by passing in the tag name and the company details as specified in "Tag Company Request Payload" described below. Also, if the tag doesn't exist then a new one will be created automatically. + +**4. Untag Companies:** You can untag a single company or a list of companies. You can untag a company by passing in the tag id and the company details as specified in "Untag Company Request Payload" described below. + +**5. Tag Multiple Users:** You can tag a list of users. You can tag the users by passing in the tag name and the user details as specified in "Tag Users Request Payload" described below. + +Each operation will return a tag object. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.tags.createTag({ + name: "test", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.CreateTagRequestBody` + +
+
+ +
+
+ +**requestOptions:** `Tags.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.tags.findTag({ ...params }) -> Intercom.Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of tags that are on the workspace by their id. +This will return a tag object. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.tags.findTag({ + id: "123", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.FindTagRequest` + +
+
+ +
+
+ +**requestOptions:** `Tags.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.tags.deleteTag({ ...params }) -> void +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete the details of tags that are on the workspace by passing in the id. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.tags.deleteTag({ + id: "123", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.DeleteTagRequest` + +
+
+ +
+
+ +**requestOptions:** `Tags.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.tags.attachTagToTicket({ ...params }) -> Intercom.Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can tag a specific ticket. This will return a tag object for the tag that was added to the ticket. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.tags.attachTagToTicket({ + ticket_id: "64619700005694", + id: "7522907", + admin_id: "780", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.AttachTagToTicketRequest` + +
+
+ +
+
+ +**requestOptions:** `Tags.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.tags.detachTagFromTicket({ ...params }) -> Intercom.Tag +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can remove tag from a specific ticket. This will return a tag object for the tag that was removed from the ticket. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.tags.detachTagFromTicket({ + ticket_id: "64619700005694", + id: "7522907", + admin_id: "123", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.DetachTagFromTicketRequest` + +
+
+ +
+
+ +**requestOptions:** `Tags.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Conversations + +
client.unstable.conversations.listConversations({ ...params }) -> Intercom.ConversationList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all conversations. + +You can optionally request the result page size and the cursor to start after to fetch the result. +{% admonition type="warning" name="Pagination" %} +You can use pagination to limit the number of results returned. The default is `20` results per page. +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 %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.conversations.listConversations(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.ListConversationsRequest` + +
+
+ +
+
+ +**requestOptions:** `Conversations.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.conversations.createConversation({ ...params }) -> Intercom.Message +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a conversation that has been initiated by a contact (ie. user or lead). +The conversation can be an in-app message only. + +{% admonition type="info" name="Sending for visitors" %} +You can also send a message from a visitor by specifying their `user_id` or `id` value in the `from` field, along with a `type` field value of `contact`. +This visitor will be automatically converted to a contact with a lead role once the conversation is created. +{% /admonition %} + +This will return the Message model that has been created. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.conversations.createConversation({ + from: { + type: "user", + id: "6762f11b1bb69f9f2193bba3", + }, + body: "Hello there", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.CreateConversationRequest` + +
+
+ +
+
+ +**requestOptions:** `Conversations.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.conversations.retrieveConversation({ ...params }) -> Intercom.Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single conversation. + +This will return a single Conversation model with all its conversation parts. + +{% admonition type="warning" name="Hard limit of 500 parts" %} +The maximum number of conversation parts that can be returned via the API is 500. If you have more than that we will return the 500 most recent conversation parts. +{% /admonition %} + +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). + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.conversations.retrieveConversation({ + id: 1, + display_as: "plaintext", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.RetrieveConversationRequest` + +
+
+ +
+
+ +**requestOptions:** `Conversations.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.conversations.updateConversation({ ...params }) -> Intercom.Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update an existing conversation. + +{% admonition type="info" name="Replying and other actions" %} +If you want to reply to a coveration or take an action such as assign, unassign, open, close or snooze, take a look at the reply and manage endpoints. +{% /admonition %} + +{% admonition type="info" %} +This endpoint handles both **conversation updates** and **custom object associations**. + +See _`update a conversation with an association to a custom object instance`_ in the request/response examples to see the custom object association format. +{% /admonition %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.conversations.updateConversation({ + id: 1, + display_as: "plaintext", + read: true, + title: "new conversation title", + custom_attributes: { + issue_type: "Billing", + priority: "High", + }, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.UpdateConversationRequest` + +
+
+ +
+
+ +**requestOptions:** `Conversations.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.conversations.deleteConversation({ ...params }) -> Intercom.ConversationDeleted +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single conversation. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.conversations.deleteConversation({ + id: 1, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.DeleteConversationRequest` + +
+
+ +
+
+ +**requestOptions:** `Conversations.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.conversations.searchConversations({ ...params }) -> Intercom.ConversationList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can search for multiple conversations by the value of their attributes in order to fetch exactly which ones you want. + +To search for conversations, you need to send a `POST` request to `https://api.intercom.io/conversations/search`. + +This will accept a query object in the body which will define your filters in order to search for conversations. +{% admonition type="warning" name="Optimizing search queries" %} +Search queries can be complex, so optimizing them can help the performance of your search. +Use the `AND` and `OR` operators to combine multiple filters to get the exact results you need and utilize +pagination to limit the number of results returned. The default is `20` results per page and maximum is `150`. +See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param. +{% /admonition %} + +### Nesting & Limitations + +You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). +There are some limitations to the amount of multiple's there can be: + +- There's a limit of max 2 nested filters +- There's a limit of max 15 filters for each AND or OR group + +### Accepted Fields + +Most keys listed in the conversation model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foorbar"`). +The `source.body` field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a `"I need support"` body - the query should contain a `=` operator with the value `"support"` for such conversation to be returned. A query with a `=` operator and a `"need support"` value will not yield a result. + +| Field | Type | +| :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | +| id | String | +| created_at | Date (UNIX timestamp) | +| updated_at | Date (UNIX timestamp) | +| source.type | String
Accepted fields are `conversation`, `email`, `facebook`, `instagram`, `phone_call`, `phone_switch`, `push`, `sms`, `twitter` and `whatsapp`. | +| source.id | String | +| source.delivered_as | String | +| source.subject | String | +| source.body | String | +| source.author.id | String | +| source.author.type | String | +| source.author.name | String | +| source.author.email | String | +| source.url | String | +| contact_ids | String | +| teammate_ids | String | +| admin_assignee_id | String | +| team_assignee_id | String | +| channel_initiated | String | +| open | Boolean | +| read | Boolean | +| state | String | +| waiting_since | Date (UNIX timestamp) | +| snoozed_until | Date (UNIX timestamp) | +| tag_ids | String | +| priority | String | +| statistics.time_to_assignment | Integer | +| statistics.time_to_admin_reply | Integer | +| statistics.time_to_first_close | Integer | +| statistics.time_to_last_close | Integer | +| statistics.median_time_to_reply | Integer | +| statistics.first_contact_reply_at | Date (UNIX timestamp) | +| statistics.first_assignment_at | Date (UNIX timestamp) | +| statistics.first_admin_reply_at | Date (UNIX timestamp) | +| statistics.first_close_at | Date (UNIX timestamp) | +| statistics.last_assignment_at | Date (UNIX timestamp) | +| statistics.last_assignment_admin_reply_at | Date (UNIX timestamp) | +| statistics.last_contact_reply_at | Date (UNIX timestamp) | +| statistics.last_admin_reply_at | Date (UNIX timestamp) | +| statistics.last_close_at | Date (UNIX timestamp) | +| statistics.last_closed_by_id | String | +| statistics.count_reopens | Integer | +| statistics.count_assignments | Integer | +| statistics.count_conversation_parts | Integer | +| conversation_rating.requested_at | Date (UNIX timestamp) | +| conversation_rating.replied_at | Date (UNIX timestamp) | +| conversation_rating.score | Integer | +| conversation_rating.remark | String | +| conversation_rating.contact_id | String | +| conversation_rating.admin_d | String | +| ai_agent_participated | Boolean | +| ai_agent.resolution_state | String | +| ai_agent.last_answer_type | String | +| ai_agent.rating | Integer | +| ai_agent.rating_remark | String | +| ai_agent.source_type | String | +| ai_agent.source_title | String | + +### Accepted Operators + +The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). The operator has to be compatible with the field's type (eg. you cannot search with `>` for a given string value as it's only compatible for integer's and dates). + +| Operator | Valid Types | Description | +| :------- | :---------------------------- | :--------------------------------------------------------- | +| = | All | Equals | +| != | All | Doesn't Equal | +| IN | All | In Shortcut for `OR` queries Values most be in Array | +| NIN | All | Not In Shortcut for `OR !` queries Values must be in Array | +| > | Integer Date (UNIX Timestamp) | Greater (or equal) than | +| < | Integer Date (UNIX Timestamp) | Lower (or equal) than | +| ~ | String | Contains | +| !~ | String | Doesn't Contain | +| ^ | String | Starts With | +| $ | String | Ends With | + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.conversations.searchConversations({ + query: { + operator: "AND", + value: [ + { + field: "created_at", + operator: ">", + value: "1306054154", + }, + ], + }, + pagination: { + per_page: 5, + }, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.SearchRequest` + +
+
+ +
+
+ +**requestOptions:** `Conversations.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.conversations.replyConversation({ ...params }) -> Intercom.Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can reply to a conversation with a message from an admin or on behalf of a contact, or with a note for admins. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.conversations.replyConversation({ + id: '123 or "last"', + body: { + message_type: "comment", + type: "user", + body: "Thanks again :)", + intercom_user_id: "6762f1571bb69f9f2193bbbb", + }, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.ReplyConversationRequest` + +
+
+ +
+
+ +**requestOptions:** `Conversations.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.conversations.manageConversation({ ...params }) -> Intercom.Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +For managing conversations you can: + +- Close a conversation +- Snooze a conversation to reopen on a future date +- Open a conversation which is `snoozed` or `closed` +- Assign a conversation to an admin and/or team. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.conversations.manageConversation({ + id: "123", + body: { + message_type: "close", + type: "admin", + admin_id: "12345", + }, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.ManageConversationRequest` + +
+
+ +
+
+ +**requestOptions:** `Conversations.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.conversations.attachContactToConversation({ ...params }) -> Intercom.Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + +{% admonition type="warning" name="Contacts without an email" %} +If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with `role` set to `lead`. +{% /admonition %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.conversations.attachContactToConversation({ + id: "123", + admin_id: "12345", + customer: { + intercom_user_id: "6762f19b1bb69f9f2193bbd4", + }, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.AttachContactToConversationRequest` + +
+
+ +
+
+ +**requestOptions:** `Conversations.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.conversations.detachContactFromConversation({ ...params }) -> Intercom.Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + +{% admonition type="warning" name="Contacts without an email" %} +If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with `role` set to `lead`. +{% /admonition %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.conversations.detachContactFromConversation({ + conversation_id: "123", + contact_id: "123", + admin_id: "5017690", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.DetachContactFromConversationRequest` + +
+
+ +
+
+ +**requestOptions:** `Conversations.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.conversations.redactConversation({ ...params }) -> Intercom.Conversation +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can redact a conversation part or the source message of a conversation (as seen in the source object). + +{% admonition type="info" name="Redacting parts and messages" %} +If you are redacting a conversation part, it must have a `body`. If you are redacting a source message, it must have been created by a contact. We will return a `conversation_part_not_redactable` error if these criteria are not met. +{% /admonition %} + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.conversations.redactConversation({ + type: "conversation_part", + conversation_id: "19894788788", + conversation_part_id: "19381789428", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.RedactConversationRequest` + +
+
+ +
+
+ +**requestOptions:** `Conversations.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.conversations.convertConversationToTicket({ ...params }) -> Intercom.Ticket | undefined +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can convert a conversation to a ticket. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.conversations.convertConversationToTicket({ + id: 1, + ticket_type_id: "53", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.ConvertConversationToTicketRequest` + +
+
+ +
+
+ +**requestOptions:** `Conversations.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Unstable CustomChannelEvents + +
client.unstable.customChannelEvents.notifyNewConversation({ ...params }) -> Intercom.CustomChannelNotificationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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 restricted to customers with access to the closed beta for "Fin over API". + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.customChannelEvents.notifyNewConversation({ + event_id: "evt_12345", + external_conversation_id: "conv_67890", + contact: { + type: "user", + external_id: "user_001", + name: "Jane Doe", + email: "jane.doe@example.com", + }, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.CustomChannelBaseEvent` + +
+
+ +
+
+ +**requestOptions:** `CustomChannelEvents.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.customChannelEvents.notifyNewMessage({ ...params }) -> Intercom.CustomChannelNotificationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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 restricted to customers with access to the closed beta for "Fin over API". + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.customChannelEvents.notifyNewMessage({ + event_id: "evt_54321", + external_conversation_id: "conv_98765", + contact: { + type: "user", + external_id: "user_002", + name: "John Smith", + email: "john.smith@example.com", + }, + body: "Hello, I need help with my order.", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.NotifyNewMessageRequest` + +
+
+ +
+
+ +**requestOptions:** `CustomChannelEvents.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.customChannelEvents.notifyQuickReplySelected({ ...params }) -> Intercom.CustomChannelNotificationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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 restricted to customers with access to the closed beta for "Fin over API". + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.customChannelEvents.notifyQuickReplySelected({ + event_id: "evt_67890", + external_conversation_id: "conv_13579", + contact: { + type: "user", + external_id: "user_003", + name: "Alice Example", + email: "alice@example.com", + }, + quick_reply_option_id: "1234", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.NotifyQuickReplySelectedRequest` + +
+
+ +
+
+ +**requestOptions:** `CustomChannelEvents.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.customChannelEvents.notifyAttributeCollected({ ...params }) -> Intercom.CustomChannelNotificationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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 restricted to customers with access to the closed beta for "Fin over API". + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.customChannelEvents.notifyAttributeCollected({ + event_id: "evt_24680", + external_conversation_id: "conv_11223", + contact: { + type: "user", + external_id: "user_004", + name: "Bob Example", + email: "bob@example.com", + }, + attribute: { + id: "shipping_address", + value: "123 Main St, Springfield", + }, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.NotifyAttributeCollectedRequest` + +
+
+ +
+
+ +**requestOptions:** `CustomChannelEvents.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Custom Object Instances + +
client.unstable.customObjectInstances.getCustomObjectInstancesByExternalId({ ...params }) -> Intercom.CustomObjectInstance | undefined +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Fetch a Custom Object Instance by external_id. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.customObjectInstances.getCustomObjectInstancesByExternalId({ + custom_object_type_identifier: "Order", + external_id: "external_id", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.GetCustomObjectInstancesByExternalIdRequest` + +
+
+ +
+
+ +**requestOptions:** `CustomObjectInstances.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.customObjectInstances.createCustomObjectInstances({ ...params }) -> Intercom.CustomObjectInstance | undefined +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create or update a custom object instance + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.customObjectInstances.createCustomObjectInstances({ + custom_object_type_identifier: "Order", + external_id: "123", + external_created_at: 1392036272, + external_updated_at: 1392036272, + custom_attributes: { + order_number: "ORDER-12345", + total_amount: "custom_attributes", + }, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.CreateOrUpdateCustomObjectInstanceRequest` + +
+
+ +
+
+ +**requestOptions:** `CustomObjectInstances.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.customObjectInstances.deleteCustomObjectInstancesById({ ...params }) -> Intercom.CustomObjectInstanceDeleted +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a single Custom Object instance by external_id. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.customObjectInstances.deleteCustomObjectInstancesById({ + custom_object_type_identifier: "Order", + external_id: "external_id", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.DeleteCustomObjectInstancesByIdRequest` + +
+
+ +
+
+ +**requestOptions:** `CustomObjectInstances.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.customObjectInstances.getCustomObjectInstancesById({ ...params }) -> Intercom.CustomObjectInstance | undefined +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Fetch a Custom Object Instance by id. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.customObjectInstances.getCustomObjectInstancesById({ + custom_object_type_identifier: "Order", + id: "id", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.GetCustomObjectInstancesByIdRequest` + +
+
+ +
+
+ +**requestOptions:** `CustomObjectInstances.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.customObjectInstances.deleteCustomObjectInstancesByExternalId({ ...params }) -> Intercom.CustomObjectInstanceDeleted +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a single Custom Object instance using the Intercom defined id. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.customObjectInstances.deleteCustomObjectInstancesByExternalId({ + custom_object_type_identifier: "Order", + id: "id", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.DeleteCustomObjectInstancesByExternalIdRequest` + +
+
+ +
+
+ +**requestOptions:** `CustomObjectInstances.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Data Attributes + +
client.unstable.dataAttributes.lisDataAttributes({ ...params }) -> Intercom.DataAttributeList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.dataAttributes.lisDataAttributes(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.LisDataAttributesRequest` + +
+
+ +
+
+ +**requestOptions:** `DataAttributes.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.dataAttributes.createDataAttribute({ ...params }) -> Intercom.DataAttribute +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a data attributes for a `contact` or a `company`. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.dataAttributes.createDataAttribute({ + name: "Mithril Shirt", + model: "company", + data_type: "string", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.CreateDataAttributeRequest` + +
+
+ +
+
+ +**requestOptions:** `DataAttributes.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.dataAttributes.updateDataAttribute({ ...params }) -> Intercom.DataAttribute +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update a data attribute. + +> 🚧 Updating the data type is not possible +> +> 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. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.dataAttributes.updateDataAttribute({ + id: 1, + archived: false, + description: "Just a plain old ring", + options: ["options", "options"], +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.UpdateDataAttributeRequest` + +
+
+ +
+
+ +**requestOptions:** `DataAttributes.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Data Events + +
client.unstable.dataEvents.lisDataEvents({ ...params }) -> Intercom.DataEventSummary +
+
+ +#### 📝 Description + +
+
+ +
+
+ +> 🚧 +> +> Please note that you can only 'list' events that are less than 90 days old. Event counts and summaries will still include your events older than 90 days but you cannot 'list' these events individually if they are older than 90 days + +The events belonging to a customer can be listed by sending a GET request to `https://api.intercom.io/events` with a user or lead identifier along with a `type` parameter. The identifier parameter can be one of `user_id`, `email` or `intercom_user_id`. The `type` parameter value must be `user`. + +- `https://api.intercom.io/events?type=user&user_id={user_id}` +- `https://api.intercom.io/events?type=user&email={email}` +- `https://api.intercom.io/events?type=user&intercom_user_id={id}` (this call can be used to list leads) + +The `email` parameter value should be [url encoded](http://en.wikipedia.org/wiki/Percent-encoding) when sending. + +You can optionally define the result page size as well with the `per_page` parameter. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.dataEvents.lisDataEvents({ + filter: { + user_id: "user_id", + }, + type: "type", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.LisDataEventsRequest` + +
+
+ +
+
+ +**requestOptions:** `DataEvents.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.dataEvents.createDataEvent({ ...params }) -> void +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You will need an Access Token that has write permissions to send Events. Once you have a key you can submit events via POST to the Events resource, which is located at https://api.intercom.io/events, or you can send events using one of the client libraries. When working with the HTTP API directly a client should send the event with a `Content-Type` of `application/json`. + +When using the JavaScript API, [adding the code to your app](http://docs.intercom.io/configuring-Intercom/tracking-user-events-in-your-app) makes the Events API available. Once added, you can submit an event using the `trackEvent` method. This will associate the event with the Lead or currently logged-in user or logged-out visitor/lead and send it to Intercom. The final parameter is a map that can be used to send optional metadata about the event. + +With the Ruby client you pass a hash describing the event to `Intercom::Event.create`, or call the `track_user` method directly on the current user object (e.g. `user.track_event`). + +**NB: For the JSON object types, please note that we do not currently support nested JSON structure.** + +| Type | Description | Example | +| :-------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------- | +| String | The value is a JSON String | `"source":"desktop"` | +| Number | The value is a JSON Number | `"load": 3.67` | +| Date | The key ends with the String `_date` and the value is a [Unix timestamp](http://en.wikipedia.org/wiki/Unix_time), assumed to be in the [UTC](http://en.wikipedia.org/wiki/Coordinated_Universal_Time) timezone. | `"contact_date": 1392036272` | +| Link | The value is a HTTP or HTTPS URI. | `"article": "https://example.org/ab1de.html"` | +| Rich Link | The value is a JSON object that contains `url` and `value` keys. | `"article": {"url": "https://example.org/ab1de.html", "value":"the dude abides"}` | +| Monetary Amount | The value is a JSON object that contains `amount` and `currency` keys. The `amount` key is a positive integer representing the amount in cents. The price in the example to the right denotes €349.99. | `"price": {"amount": 34999, "currency": "eur"}` | + +**Lead Events** + +When submitting events for Leads, you will need to specify the Lead's `id`. + +**Metadata behaviour** + +- We currently limit the number of tracked metadata keys to 10 per event. Once the quota is reached, we ignore any further keys we receive. The first 10 metadata keys are determined by the order in which they are sent in with the event. +- It is not possible to change the metadata keys once the event has been sent. A new event will need to be created with the new keys and you can archive the old one. +- There might be up to 24 hrs delay when you send a new metadata for an existing event. + +**Event de-duplication** + +The API may detect and ignore duplicate events. Each event is uniquely identified as a combination of the following data - the Workspace identifier, the Contact external identifier, the Data Event name and the Data Event created time. As a result, it is **strongly recommended** to send a second granularity Unix timestamp in the `created_at` field. + +Duplicated events are responded to using the normal `202 Accepted` code - an error is not thrown, however repeat requests will be counted against any rate limit that is in place. + +### HTTP API Responses + +- Successful responses to submitted events return `202 Accepted` with an empty body. +- Unauthorised access will be rejected with a `401 Unauthorized` or `403 Forbidden` response code. +- Events sent about users that cannot be found will return a `404 Not Found`. +- Event lists containing duplicate events will have those duplicates ignored. +- Server errors will return a `500` response code and may contain an error message in the body. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.dataEvents.createDataEvent({ + key: "value", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.CreateDataEventRequestTwo` + +
+
+ +
+
+ +**requestOptions:** `DataEvents.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.dataEvents.dataEventSummaries({ ...params }) -> void +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.dataEvents.dataEventSummaries(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.CreateDataEventSummariesRequest` + +
+
+ +
+
+ +**requestOptions:** `DataEvents.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Data Export + +
client.unstable.dataExport.createDataExport({ ...params }) -> Intercom.DataExport +
+
+ +#### 📝 Description + +
+
+ +
+
+ +To create your export job, you need to send a `POST` request to the export endpoint `https://api.intercom.io/export/content/data`. + +The only parameters you need to provide are the range of dates that you want exported. + +> 🚧 Limit of one active job +> +> You can only have one active job per workspace. You will receive a HTTP status code of 429 with the message Exceeded rate limit of 1 pending message data export jobs if you attempt to create a second concurrent job. + +> ❗️ Updated_at not included +> +> It should be noted that the timeframe only includes messages sent during the time period and not messages that were only updated during this period. For example, if a message was updated yesterday but sent two days ago, you would need to set the created_at_after date before the message was sent to include that in your retrieval job. + +> 📘 Date ranges are inclusive +> +> 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. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.dataExport.createDataExport({ + created_at_after: 1734519776, + created_at_before: 1734537776, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.CreateDataExportsRequest` + +
+
+ +
+
+ +**requestOptions:** `DataExport.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.dataExport.getDataExport({ ...params }) -> Intercom.DataExport +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can view the status of your job by sending a `GET` request to the URL +`https://api.intercom.io/export/content/data/{job_identifier}` - the `{job_identifier}` is the value returned in the response when you first created the export job. More on it can be seen in the Export Job Model. + +> 🚧 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. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.dataExport.getDataExport({ + job_identifier: "job_identifier", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.GetDataExportRequest` + +
+
+ +
+
+ +**requestOptions:** `DataExport.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.dataExport.cancelDataExport({ ...params }) -> Intercom.DataExport +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can cancel your job + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.dataExport.cancelDataExport({ + job_identifier: "job_identifier", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.CancelDataExportRequest` + +
+
+ +
+
+ +**requestOptions:** `DataExport.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.dataExport.downloadDataExport({ ...params }) -> void +
+
+ +#### 📝 Description + +
+
+ +
+
+ +When a job has a status of complete, and thus a filled download_url, you can download your data by hitting that provided URL, formatted like so: https://api.intercom.io/download/content/data/xyz1234. + +Your exported message data will be streamed continuously back down to you in a gzipped CSV format. + +> 📘 Octet header required +> +> You will have to specify the header Accept: `application/octet-stream` when hitting this endpoint. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.dataExport.downloadDataExport({ + job_identifier: "job_identifier", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.DownloadDataExportRequest` + +
+
+ +
+
+ +**requestOptions:** `DataExport.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Jobs + +
client.unstable.jobs.status({ ...params }) -> Intercom.Jobs +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve the status of job execution. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.jobs.status({ + id: "id", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.JobsStatusRequest` + +
+
+ +
+
+ +**requestOptions:** `Jobs.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Messages + +
client.unstable.messages.createMessage({ ...params }) -> Intercom.Message +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a message that has been initiated by an admin. The conversation can be either an in-app message, an email or sms. + +> 🚧 Sending for visitors +> +> There can be a short delay between when a contact is created and when a contact becomes available to be messaged through the API. A 404 Not Found error will be returned in this case. + +This will return the Message model that has been created. + +> 🚧 Retrieving Associated Conversations +> +> 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. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.messages.createMessage({ + from: { + type: "user", + id: "6762f2341bb69f9f2193bc17", + }, + body: "heyy", + referer: "https://twitter.com/bob", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.CreateMessageRequestTwo` + +
+
+ +
+
+ +**requestOptions:** `Messages.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.messages.getWhatsAppMessageStatus({ ...params }) -> Intercom.WhatsappMessageStatusList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieves statuses of messages sent from the Outbound module. Currently, this API only supports WhatsApp messages. + +This endpoint returns paginated status events for WhatsApp messages sent via the Outbound module, providing +information about delivery state and related message details. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.messages.getWhatsAppMessageStatus({ + ruleset_id: "ruleset_id", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.GetWhatsAppMessageStatusRequest` + +
+
+ +
+
+ +**requestOptions:** `Messages.RequestOptions` + +
+
+
+
+ +
+
+
+ +## News + +
client.unstable.news.listNewsItems() -> Intercom.PaginatedResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all news items + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.news.listNewsItems(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `News.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.news.createNewsItem({ ...params }) -> Intercom.NewsItem +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a news item + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.news.createNewsItem({ + title: "Halloween is here!", + body: "

New costumes in store for this spooky season

", + sender_id: 991267834, + state: "live", + deliver_silently: true, + labels: ["Product", "Update", "New"], + reactions: ["\uD83D\uDE06", "\uD83D\uDE05"], + newsfeed_assignments: [ + { + newsfeed_id: 53, + published_at: 1664638214, + }, + ], +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.NewsItemRequest` + +
+
+ +
+
+ +**requestOptions:** `News.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.news.retrieveNewsItem({ ...params }) -> Intercom.NewsItem +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single news item. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.news.retrieveNewsItem({ + id: 1, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.RetrieveNewsItemRequest` + +
+
+ +
+
+ +**requestOptions:** `News.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.news.updateNewsItem({ ...params }) -> Intercom.NewsItem +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.news.updateNewsItem({ + id: 1, + body: { + title: "Christmas is here!", + body: "

New gifts in store for the jolly season

", + sender_id: 991267845, + reactions: ["\uD83D\uDE1D", "\uD83D\uDE02"], + }, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.UpdateNewsItemRequest` + +
+
+ +
+
+ +**requestOptions:** `News.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.news.deleteNewsItem({ ...params }) -> Intercom.DeletedObject +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a single news item. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.news.deleteNewsItem({ + id: 1, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.DeleteNewsItemRequest` + +
+
+ +
+
+ +**requestOptions:** `News.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.news.listLiveNewsfeedItems({ ...params }) -> Intercom.PaginatedResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all news items that are live on a given newsfeed + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.news.listLiveNewsfeedItems({ + id: "123", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.ListLiveNewsfeedItemsRequest` + +
+
+ +
+
+ +**requestOptions:** `News.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.news.listNewsfeeds() -> Intercom.PaginatedResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all newsfeeds + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.news.listNewsfeeds(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `News.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.news.retrieveNewsfeed({ ...params }) -> Intercom.Newsfeed +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single newsfeed + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.news.retrieveNewsfeed({ + id: "123", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.RetrieveNewsfeedRequest` + +
+
+ +
+
+ +**requestOptions:** `News.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Segments + +
client.unstable.segments.listSegments({ ...params }) -> Intercom.SegmentList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch a list of all segments. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.segments.listSegments(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.ListSegmentsRequest` + +
+
+ +
+
+ +**requestOptions:** `Segments.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.segments.retrieveSegment({ ...params }) -> Intercom.Segment +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single segment. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.segments.retrieveSegment({ + id: "123", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.RetrieveSegmentRequest` + +
+
+ +
+
+ +**requestOptions:** `Segments.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Switch + +
client.unstable.switch.createPhoneSwitch({ ...params }) -> Intercom.PhoneSwitch | undefined +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can use the API to deflect phone calls to the Intercom Messenger. +Calling this endpoint will send an SMS with a link to the Messenger to the phone number specified. + +If custom attributes are specified, they will be added to the user or lead's custom data attributes. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.switch.createPhoneSwitch({ + key: "value", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `unknown` + +
+
+ +
+
+ +**requestOptions:** `Switch.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Teams + +
client.unstable.teams.listTeams() -> Intercom.TeamList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +This will return a list of team objects for the App. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.teams.listTeams(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `Teams.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.teams.retrieveTeam({ ...params }) -> Intercom.Team +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single team, containing an array of admins that belong to this team. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.teams.retrieveTeam({ + id: "123", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.RetrieveTeamRequest` + +
+
+ +
+
+ +**requestOptions:** `Teams.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Ticket States + +
client.unstable.ticketStates.listTicketStates() -> Intercom.TicketStateList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can get a list of all ticket states for a workspace. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.ticketStates.listTicketStates(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `TicketStates.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Ticket Type Attributes + +
client.unstable.ticketTypeAttributes.createTicketTypeAttribute({ ...params }) -> Intercom.TicketTypeAttribute | undefined +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new attribute for a ticket type. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.ticketTypeAttributes.createTicketTypeAttribute({ + ticket_type_id: "ticket_type_id", + name: "Attribute Title", + description: "Attribute Description", + data_type: "string", + required_to_create: false, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.CreateTicketTypeAttributeRequest` + +
+
+ +
+
+ +**requestOptions:** `TicketTypeAttributes.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.ticketTypeAttributes.updateTicketTypeAttribute({ ...params }) -> Intercom.TicketTypeAttribute | undefined +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update an existing attribute for a ticket type. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.ticketTypeAttributes.updateTicketTypeAttribute({ + ticket_type_id: "ticket_type_id", + id: "id", + description: "New Attribute Description", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.UpdateTicketTypeAttributeRequest` + +
+
+ +
+
+ +**requestOptions:** `TicketTypeAttributes.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Ticket Types + +
client.unstable.ticketTypes.listTicketTypes() -> Intercom.TicketTypeList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can get a list of all ticket types for a workspace. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.ticketTypes.listTicketTypes(); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**requestOptions:** `TicketTypes.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.ticketTypes.createTicketType({ ...params }) -> Intercom.TicketType | undefined +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can create a new ticket type. + +> 📘 Creating ticket types. +> +> 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/) + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.ticketTypes.createTicketType({ + key: "value", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `unknown` + +
+
+ +
+
+ +**requestOptions:** `TicketTypes.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.ticketTypes.getTicketType({ ...params }) -> Intercom.TicketType | undefined +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single ticket type. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.ticketTypes.getTicketType({ + id: "id", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.GetTicketTypeRequest` + +
+
+ +
+
+ +**requestOptions:** `TicketTypes.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Tickets + +
client.unstable.tickets.replyTicket({ ...params }) -> Intercom.TicketReply +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can reply to a ticket with a message from an admin or on behalf of a contact, or with a note for admins. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.tickets.replyTicket({ + id: "123", + body: { + message_type: "comment", + type: "user", + body: "Thanks again :)", + intercom_user_id: "6762f2971bb69f9f2193bc49", + }, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.ReplyTicketRequest` + +
+
+ +
+
+ +**requestOptions:** `Tickets.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.tickets.enqueueCreateTicket({ ...params }) -> Intercom.Jobs +
+
+ +#### 📝 Description + +
+
+ +
+
+ +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. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.tickets.enqueueCreateTicket({ + ticket_type_id: "1234", + contacts: [ + { + id: "6762f2d81bb69f9f2193bc54", + }, + ], +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.EnqueueCreateTicketRequest` + +
+
+ +
+
+ +**requestOptions:** `Tickets.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.tickets.getTicket({ ...params }) -> Intercom.Ticket | undefined +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single ticket. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.tickets.getTicket({ + id: "id", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.GetTicketRequest` + +
+
+ +
+
+ +**requestOptions:** `Tickets.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.tickets.updateTicket({ ...params }) -> Intercom.Ticket | undefined +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can update a ticket. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.tickets.updateTicket({ + id: "id", + ticket_attributes: { + _default_title_: "example", + _default_description_: "there is a problem", + }, + ticket_state_id: "123", + open: true, + snoozed_until: 1673609604, + admin_id: 991268011, + assignee_id: "123", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.UpdateTicketRequest` + +
+
+ +
+
+ +**requestOptions:** `Tickets.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.tickets.deleteTicket({ ...params }) -> Intercom.DeleteTicketResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can delete a ticket using the Intercom provided ID. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.tickets.deleteTicket({ + id: "id", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.DeleteTicketRequest` + +
+
+ +
+
+ +**requestOptions:** `Tickets.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.tickets.searchTickets({ ...params }) -> Intercom.TicketList +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can search for multiple tickets by the value of their attributes in order to fetch exactly which ones you want. + +To search for tickets, you send a `POST` request to `https://api.intercom.io/tickets/search`. + +This will accept a query object in the body which will define your filters. +{% admonition type="warning" name="Optimizing search queries" %} +Search queries can be complex, so optimizing them can help the performance of your search. +Use the `AND` and `OR` operators to combine multiple filters to get the exact results you need and utilize +pagination to limit the number of results returned. The default is `20` results per page. +See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param. +{% /admonition %} + +### Nesting & Limitations + +You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). +There are some limitations to the amount of multiples there can be: + +- There's a limit of max 2 nested filters +- There's a limit of max 15 filters for each AND or OR group + +### Accepted Fields + +Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foobar"`). +The `source.body` field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a `"I need support"` body - the query should contain a `=` operator with the value `"support"` for such conversation to be returned. A query with a `=` operator and a `"need support"` value will not yield a result. + +| Field | Type | +| :-------------------- | :------------------------------------------------------------- | +| id | String | +| created_at | Date (UNIX timestamp) | +| updated_at | Date (UNIX timestamp) | +| _default_title_ | String | +| _default_description_ | String | +| category | String | +| ticket_type_id | String | +| contact_ids | String | +| teammate_ids | String | +| admin_assignee_id | String | +| team_assignee_id | String | +| open | Boolean | +| state | String | +| snoozed_until | Date (UNIX timestamp) | +| ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer | + +### Accepted Operators + +{% admonition type="info" name="Searching based on `created_at`" %} +You may use the `<=` or `>=` operators to search by `created_at`. +{% /admonition %} + +The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). The operator has to be compatible with the field's type (eg. you cannot search with `>` for a given string value as it's only compatible for integer's and dates). + +| Operator | Valid Types | Description | +| :------- | :---------------------------- | :--------------------------------------------------------- | +| = | All | Equals | +| != | All | Doesn't Equal | +| IN | All | In Shortcut for `OR` queries Values most be in Array | +| NIN | All | Not In Shortcut for `OR !` queries Values must be in Array | +| > | Integer Date (UNIX Timestamp) | Greater (or equal) than | +| < | Integer Date (UNIX Timestamp) | Lower (or equal) than | +| ~ | String | Contains | +| !~ | String | Doesn't Contain | +| ^ | String | Starts With | +| $ | String | Ends With | + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.tickets.searchTickets({ + query: { + operator: "AND", + value: [ + { + field: "created_at", + operator: ">", + value: "1306054154", + }, + ], + }, + pagination: { + per_page: 5, + }, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.SearchRequest` + +
+
+ +
+
+ +**requestOptions:** `Tickets.RequestOptions` + +
+
+
+
+ +
+
+
+ +## Visitors + +
client.unstable.visitors.retrieveVisitorWithUserId({ ...params }) -> Intercom.Visitor | undefined +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can fetch the details of a single visitor. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.visitors.retrieveVisitorWithUserId({ + user_id: "user_id", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.RetrieveVisitorWithUserIdRequest` + +
+
+ +
+
+ +**requestOptions:** `Visitors.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.visitors.updateVisitor({ ...params }) -> Intercom.Visitor | undefined +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Sending a PUT request to `/visitors` will result in an update of an existing Visitor. + +**Option 1.** You can update a visitor by passing in the `user_id` of the visitor in the Request body. + +**Option 2.** You can update a visitor by passing in the `id` of the visitor in the Request body. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.visitors.updateVisitor({ + id: "6762f30c1bb69f9f2193bc5e", + name: "Gareth Bale", +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.UpdateVisitorRequestOne` + +
+
+ +
+
+ +**requestOptions:** `Visitors.RequestOptions` + +
+
+
+
+ +
+
+
+ +
client.unstable.visitors.convertVisitor({ ...params }) -> Intercom.Contact +
+
+ +#### 📝 Description + +
+
+ +
+
+ +You can merge a Visitor to a Contact of role type `lead` or `user`. + +> 📘 What happens upon a visitor being converted? +> +> 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. + +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```typescript +await client.unstable.visitors.convertVisitor({ + type: "user", + user: { + email: "foo@bar.com", + }, + visitor: { + user_id: "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3", + }, +}); +``` + +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**request:** `Intercom.unstable.ConvertVisitorRequest` + +
+
+ +
+
+ +**requestOptions:** `Visitors.RequestOptions` + +
+
+
+
+ +
+
+
diff --git a/src/Client.ts b/src/Client.ts index b240ddcb..bdbba22c 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -23,8 +23,8 @@ import { Teams } from "./api/resources/teams/client/Client"; import { TicketTypes } from "./api/resources/ticketTypes/client/Client"; import { Tickets } from "./api/resources/tickets/client/Client"; import { Visitors } from "./api/resources/visitors/client/Client"; -import { CustomChannelEvents } from "./api/resources/customChannelEvents/client/Client"; import { News } from "./api/resources/news/client/Client"; +import { Unstable } from "./api/resources/unstable/client/Client"; export declare namespace IntercomClient { export interface Options { @@ -107,8 +107,8 @@ export class IntercomClient { protected _ticketTypes: TicketTypes | undefined; protected _tickets: Tickets | undefined; protected _visitors: Visitors | undefined; - protected _customChannelEvents: CustomChannelEvents | undefined; protected _news: News | undefined; + protected _unstable: Unstable | undefined; constructor(protected readonly _options: IntercomClient.Options = {}) {} @@ -188,11 +188,11 @@ export class IntercomClient { return (this._visitors ??= new Visitors(this._options)); } - public get customChannelEvents(): CustomChannelEvents { - return (this._customChannelEvents ??= new CustomChannelEvents(this._options)); - } - public get news(): News { return (this._news ??= new News(this._options)); } + + public get unstable(): Unstable { + return (this._unstable ??= new Unstable(this._options)); + } } diff --git a/src/api/errors/BadRequestError.ts b/src/api/errors/BadRequestError.ts index 34319f60..6d3e423f 100644 --- a/src/api/errors/BadRequestError.ts +++ b/src/api/errors/BadRequestError.ts @@ -3,13 +3,15 @@ */ import * as errors from "../../errors/index"; +import * as core from "../../core"; export class BadRequestError extends errors.IntercomError { - constructor(body?: unknown) { + constructor(body?: unknown, rawResponse?: core.RawResponse) { super({ message: "BadRequestError", statusCode: 400, body: body, + rawResponse: rawResponse, }); Object.setPrototypeOf(this, BadRequestError.prototype); } diff --git a/src/api/errors/ForbiddenError.ts b/src/api/errors/ForbiddenError.ts index 733bdc33..45a3327c 100644 --- a/src/api/errors/ForbiddenError.ts +++ b/src/api/errors/ForbiddenError.ts @@ -4,13 +4,15 @@ import * as errors from "../../errors/index"; import * as Intercom from "../index"; +import * as core from "../../core"; export class ForbiddenError extends errors.IntercomError { - constructor(body: Intercom.Error_) { + constructor(body: Intercom.Error_, rawResponse?: core.RawResponse) { super({ message: "ForbiddenError", statusCode: 403, body: body, + rawResponse: rawResponse, }); Object.setPrototypeOf(this, ForbiddenError.prototype); } diff --git a/src/api/errors/NotFoundError.ts b/src/api/errors/NotFoundError.ts index 27ed057b..e99cdf65 100644 --- a/src/api/errors/NotFoundError.ts +++ b/src/api/errors/NotFoundError.ts @@ -3,13 +3,15 @@ */ import * as errors from "../../errors/index"; +import * as core from "../../core"; export class NotFoundError extends errors.IntercomError { - constructor(body?: unknown) { + constructor(body?: unknown, rawResponse?: core.RawResponse) { super({ message: "NotFoundError", statusCode: 404, body: body, + rawResponse: rawResponse, }); Object.setPrototypeOf(this, NotFoundError.prototype); } diff --git a/src/api/errors/UnauthorizedError.ts b/src/api/errors/UnauthorizedError.ts index dcbab95b..0cafa7ae 100644 --- a/src/api/errors/UnauthorizedError.ts +++ b/src/api/errors/UnauthorizedError.ts @@ -4,13 +4,15 @@ import * as errors from "../../errors/index"; import * as Intercom from "../index"; +import * as core from "../../core"; export class UnauthorizedError extends errors.IntercomError { - constructor(body: Intercom.Error_) { + constructor(body: Intercom.Error_, rawResponse?: core.RawResponse) { super({ message: "UnauthorizedError", statusCode: 401, body: body, + rawResponse: rawResponse, }); Object.setPrototypeOf(this, UnauthorizedError.prototype); } diff --git a/src/api/errors/UnprocessableEntityError.ts b/src/api/errors/UnprocessableEntityError.ts index ac84eaf2..7bb55289 100644 --- a/src/api/errors/UnprocessableEntityError.ts +++ b/src/api/errors/UnprocessableEntityError.ts @@ -3,13 +3,15 @@ */ import * as errors from "../../errors/index"; +import * as core from "../../core"; export class UnprocessableEntityError extends errors.IntercomError { - constructor(body?: unknown) { + constructor(body?: unknown, rawResponse?: core.RawResponse) { super({ message: "UnprocessableEntityError", statusCode: 422, body: body, + rawResponse: rawResponse, }); Object.setPrototypeOf(this, UnprocessableEntityError.prototype); } diff --git a/src/api/resources/admins/client/Client.ts b/src/api/resources/admins/client/Client.ts index 58adcd11..007cc89c 100644 --- a/src/api/resources/admins/client/Client.ts +++ b/src/api/resources/admins/client/Client.ts @@ -88,7 +88,13 @@ export class Admins { * @example * await client.admins.identify() */ - public async identify(requestOptions?: Admins.RequestOptions): Promise { + public identify(requestOptions?: Admins.RequestOptions): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__identify(requestOptions)); + } + + private async __identify( + requestOptions?: Admins.RequestOptions, + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -101,8 +107,8 @@ export class Admins { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -115,13 +121,14 @@ export class Admins { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.AdminWithApp; + return { data: _response.body as Intercom.AdminWithApp, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } @@ -130,12 +137,14 @@ export class Admins { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /me."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -156,10 +165,17 @@ export class Admins { * away_mode_reassign: true * }) */ - public async away( + public away( request: Intercom.ConfigureAwayAdminRequest, requestOptions?: Admins.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__away(request, requestOptions)); + } + + private async __away( + request: Intercom.ConfigureAwayAdminRequest, + requestOptions?: Admins.RequestOptions, + ): Promise> { const { admin_id: adminId, ..._body } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -173,8 +189,8 @@ export class Admins { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -188,19 +204,23 @@ export class Admins { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Admin; + return { data: _response.body as Intercom.Admin, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -210,12 +230,14 @@ export class Admins { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling PUT /admins/{admin_id}/away."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -234,10 +256,17 @@ export class Admins { * created_at_before: "1677861493" * }) */ - public async listAllActivityLogs( + public listAllActivityLogs( request: Intercom.ListAllActivityLogsRequest, requestOptions?: Admins.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listAllActivityLogs(request, requestOptions)); + } + + private async __listAllActivityLogs( + request: Intercom.ListAllActivityLogsRequest, + requestOptions?: Admins.RequestOptions, + ): Promise> { const { created_at_after: createdAtAfter, created_at_before: createdAtBefore } = request; const _queryParams: Record = {}; _queryParams["created_at_after"] = createdAtAfter; @@ -257,8 +286,8 @@ export class Admins { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -272,17 +301,21 @@ export class Admins { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.ActivityLogList; + return { data: _response.body as Intercom.ActivityLogList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -292,12 +325,14 @@ export class Admins { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /admins/activity_logs."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -312,7 +347,11 @@ export class Admins { * @example * await client.admins.list() */ - public async list(requestOptions?: Admins.RequestOptions): Promise { + public list(requestOptions?: Admins.RequestOptions): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__list(requestOptions)); + } + + private async __list(requestOptions?: Admins.RequestOptions): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -325,8 +364,8 @@ export class Admins { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -339,17 +378,21 @@ export class Admins { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.AdminList; + return { data: _response.body as Intercom.AdminList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -359,12 +402,14 @@ export class Admins { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /admins."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -383,10 +428,17 @@ export class Admins { * admin_id: "123" * }) */ - public async find( + public find( + request: Intercom.FindAdminRequest, + requestOptions?: Admins.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); + } + + private async __find( request: Intercom.FindAdminRequest, requestOptions?: Admins.RequestOptions, - ): Promise { + ): Promise> { const { admin_id: adminId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -400,8 +452,8 @@ export class Admins { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -414,19 +466,23 @@ export class Admins { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Admin; + return { data: _response.body as Intercom.Admin, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -436,12 +492,14 @@ export class Admins { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /admins/{admin_id}."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } diff --git a/src/api/resources/articles/client/Client.ts b/src/api/resources/articles/client/Client.ts index f39c3695..78948f01 100644 --- a/src/api/resources/articles/client/Client.ts +++ b/src/api/resources/articles/client/Client.ts @@ -94,72 +94,83 @@ export class Articles { request: Intercom.ListArticlesRequest = {}, requestOptions?: Articles.RequestOptions, ): Promise> { - const list = async (request: Intercom.ListArticlesRequest): Promise => { - const { page, per_page: perPage } = request; - const _queryParams: Record = {}; - if (page != null) { - _queryParams["page"] = page.toString(); - } - if (perPage != null) { - _queryParams["per_page"] = perPage.toString(); - } - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: urlJoin( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "articles", - ), - method: "GET", - headers: { - Authorization: await this._getAuthorizationHeader(), - "X-Fern-Language": "JavaScript", - "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", - "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - queryParameters: _queryParams, - requestType: "json", - timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, - maxRetries: requestOptions?.maxRetries, - abortSignal: requestOptions?.abortSignal, - }); - if (_response.ok) { - return _response.body as Intercom.ArticleList; - } - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); - default: + const list = core.HttpResponsePromise.interceptFunction( + async (request: Intercom.ListArticlesRequest): Promise> => { + const { page, per_page: perPage } = request; + const _queryParams: Record = {}; + if (page != null) { + _queryParams["page"] = page.toString(); + } + if (perPage != null) { + _queryParams["per_page"] = perPage.toString(); + } + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "articles", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: + requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.ArticleList, rawResponse: _response.rawResponse }; + } + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + switch (_response.error.reason) { + case "non-json": throw new errors.IntercomError({ statusCode: _response.error.statusCode, - body: _response.error.body, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /articles."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } - } - switch (_response.error.reason) { - case "non-json": - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.rawBody, - }); - case "timeout": - throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /articles."); - case "unknown": - throw new errors.IntercomError({ - message: _response.error.errorMessage, - }); - } - }; + }, + ); let _offset = request?.page != null ? request?.page : 1; + const dataWithRawResponse = await list(request).withRawResponse(); return new core.Pageable({ - response: await list(request), + response: dataWithRawResponse.data, + rawResponse: dataWithRawResponse.rawResponse, hasNextPage: (response) => (response?.data ?? []).length > 0, getItems: (response) => response?.data ?? [], loadPage: (_response) => { @@ -208,10 +219,17 @@ export class Articles { * state: "published" * }) */ - public async create( + public create( request: Intercom.CreateArticleRequest, requestOptions?: Articles.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); + } + + private async __create( + request: Intercom.CreateArticleRequest, + requestOptions?: Articles.RequestOptions, + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -224,8 +242,8 @@ export class Articles { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -239,19 +257,23 @@ export class Articles { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Article; + return { data: _response.body as Intercom.Article, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.BadRequestError(_response.error.body as unknown); + throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -261,12 +283,14 @@ export class Articles { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /articles."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -285,10 +309,17 @@ export class Articles { * article_id: "123" * }) */ - public async find( + public find( + request: Intercom.FindArticleRequest, + requestOptions?: Articles.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); + } + + private async __find( request: Intercom.FindArticleRequest, requestOptions?: Articles.RequestOptions, - ): Promise { + ): Promise> { const { article_id: articleId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -302,8 +333,8 @@ export class Articles { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -316,19 +347,23 @@ export class Articles { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Article; + return { data: _response.body as Intercom.Article, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -338,12 +373,14 @@ export class Articles { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /articles/{article_id}."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -364,10 +401,17 @@ export class Articles { * body: "

New gifts in store for the jolly season

" * }) */ - public async update( + public update( request: Intercom.UpdateArticleRequest, requestOptions?: Articles.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions)); + } + + private async __update( + request: Intercom.UpdateArticleRequest, + requestOptions?: Articles.RequestOptions, + ): Promise> { const { article_id: articleId, ..._body } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -381,8 +425,8 @@ export class Articles { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -396,19 +440,23 @@ export class Articles { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Article; + return { data: _response.body as Intercom.Article, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -418,12 +466,14 @@ export class Articles { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling PUT /articles/{article_id}."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -442,10 +492,17 @@ export class Articles { * article_id: "123" * }) */ - public async delete( + public delete( + request: Intercom.DeleteArticleRequest, + requestOptions?: Articles.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__delete(request, requestOptions)); + } + + private async __delete( request: Intercom.DeleteArticleRequest, requestOptions?: Articles.RequestOptions, - ): Promise { + ): Promise> { const { article_id: articleId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -459,8 +516,8 @@ export class Articles { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -473,19 +530,23 @@ export class Articles { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.DeletedArticleObject; + return { data: _response.body as Intercom.DeletedArticleObject, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -495,12 +556,14 @@ export class Articles { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling DELETE /articles/{article_id}."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -519,10 +582,17 @@ export class Articles { * state: "published" * }) */ - public async search( + public search( + request: Intercom.SearchArticlesRequest = {}, + requestOptions?: Articles.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__search(request, requestOptions)); + } + + private async __search( request: Intercom.SearchArticlesRequest = {}, requestOptions?: Articles.RequestOptions, - ): Promise { + ): Promise> { const { phrase, state, help_center_id: helpCenterId, highlight } = request; const _queryParams: Record = {}; if (phrase != null) { @@ -553,8 +623,8 @@ export class Articles { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -568,17 +638,21 @@ export class Articles { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.SearchArticlesResponse; + return { data: _response.body as Intercom.SearchArticlesResponse, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -588,12 +662,14 @@ export class Articles { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /articles/search."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } diff --git a/src/api/resources/companies/client/Client.ts b/src/api/resources/companies/client/Client.ts index de1baaf2..5ac7d49b 100644 --- a/src/api/resources/companies/client/Client.ts +++ b/src/api/resources/companies/client/Client.ts @@ -102,10 +102,17 @@ export class Companies { * segment_id: "98765" * }) */ - public async retrieve( + public retrieve( request: Intercom.RetrieveCompanyRequest = {}, requestOptions?: Companies.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieve(request, requestOptions)); + } + + private async __retrieve( + request: Intercom.RetrieveCompanyRequest = {}, + requestOptions?: Companies.RequestOptions, + ): Promise> { const { name, company_id: companyId, tag_id: tagId, segment_id: segmentId, page, per_page: perPage } = request; const _queryParams: Record = {}; if (name != null) { @@ -144,8 +151,8 @@ export class Companies { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -159,19 +166,23 @@ export class Companies { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.CompaniesRetrieveResponse; + return { data: _response.body as Intercom.CompaniesRetrieveResponse, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -181,12 +192,14 @@ export class Companies { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /companies."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -218,10 +231,17 @@ export class Companies { * @example * await client.companies.createOrUpdate() */ - public async createOrUpdate( + public createOrUpdate( + request: Intercom.CreateOrUpdateCompanyRequest = {}, + requestOptions?: Companies.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createOrUpdate(request, requestOptions)); + } + + private async __createOrUpdate( request: Intercom.CreateOrUpdateCompanyRequest = {}, requestOptions?: Companies.RequestOptions, - ): Promise { + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -234,8 +254,8 @@ export class Companies { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -249,19 +269,23 @@ export class Companies { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Company; + return { data: _response.body as Intercom.Company, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.BadRequestError(_response.error.body as unknown); + throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -271,12 +295,14 @@ export class Companies { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /companies."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -295,10 +321,17 @@ export class Companies { * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" * }) */ - public async find( + public find( request: Intercom.FindCompanyRequest, requestOptions?: Companies.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); + } + + private async __find( + request: Intercom.FindCompanyRequest, + requestOptions?: Companies.RequestOptions, + ): Promise> { const { company_id: companyId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -312,8 +345,8 @@ export class Companies { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -326,19 +359,23 @@ export class Companies { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Company; + return { data: _response.body as Intercom.Company, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -348,12 +385,14 @@ export class Companies { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /companies/{company_id}."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -376,10 +415,17 @@ export class Companies { * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" * }) */ - public async update( + public update( request: Intercom.UpdateCompanyRequest, requestOptions?: Companies.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions)); + } + + private async __update( + request: Intercom.UpdateCompanyRequest, + requestOptions?: Companies.RequestOptions, + ): Promise> { const { company_id: companyId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -393,8 +439,8 @@ export class Companies { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -407,19 +453,23 @@ export class Companies { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Company; + return { data: _response.body as Intercom.Company, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -429,12 +479,14 @@ export class Companies { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling PUT /companies/{company_id}."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -453,10 +505,17 @@ export class Companies { * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" * }) */ - public async delete( + public delete( request: Intercom.DeleteCompanyRequest, requestOptions?: Companies.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__delete(request, requestOptions)); + } + + private async __delete( + request: Intercom.DeleteCompanyRequest, + requestOptions?: Companies.RequestOptions, + ): Promise> { const { company_id: companyId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -470,8 +529,8 @@ export class Companies { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -484,19 +543,23 @@ export class Companies { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.DeletedCompanyObject; + return { data: _response.body as Intercom.DeletedCompanyObject, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -506,12 +569,14 @@ export class Companies { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling DELETE /companies/{company_id}."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -530,10 +595,17 @@ export class Companies { * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" * }) */ - public async listAttachedContacts( + public listAttachedContacts( + request: Intercom.ListAttachedContactsRequest, + requestOptions?: Companies.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listAttachedContacts(request, requestOptions)); + } + + private async __listAttachedContacts( request: Intercom.ListAttachedContactsRequest, requestOptions?: Companies.RequestOptions, - ): Promise { + ): Promise> { const { company_id: companyId, page, per_page: perPage } = request; const _queryParams: Record = {}; if (page != null) { @@ -556,8 +628,8 @@ export class Companies { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -571,19 +643,23 @@ export class Companies { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.CompanyAttachedContacts; + return { data: _response.body as Intercom.CompanyAttachedContacts, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -593,6 +669,7 @@ export class Companies { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -601,6 +678,7 @@ export class Companies { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -619,10 +697,17 @@ export class Companies { * company_id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" * }) */ - public async listAttachedSegments( + public listAttachedSegments( + request: Intercom.ListSegmentsAttachedToCompanyRequest, + requestOptions?: Companies.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listAttachedSegments(request, requestOptions)); + } + + private async __listAttachedSegments( request: Intercom.ListSegmentsAttachedToCompanyRequest, requestOptions?: Companies.RequestOptions, - ): Promise { + ): Promise> { const { company_id: companyId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -636,8 +721,8 @@ export class Companies { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -650,19 +735,23 @@ export class Companies { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.CompanyAttachedSegments; + return { data: _response.body as Intercom.CompanyAttachedSegments, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -672,6 +761,7 @@ export class Companies { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -680,6 +770,7 @@ export class Companies { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -709,75 +800,86 @@ export class Companies { request: Intercom.ListCompaniesRequest = {}, requestOptions?: Companies.RequestOptions, ): Promise> { - const list = async (request: Intercom.ListCompaniesRequest): Promise => { - const { page, per_page: perPage, order } = request; - const _queryParams: Record = {}; - if (page != null) { - _queryParams["page"] = page.toString(); - } - if (perPage != null) { - _queryParams["per_page"] = perPage.toString(); - } - if (order != null) { - _queryParams["order"] = order; - } - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: urlJoin( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "companies/list", - ), - method: "POST", - headers: { - Authorization: await this._getAuthorizationHeader(), - "X-Fern-Language": "JavaScript", - "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", - "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - queryParameters: _queryParams, - requestType: "json", - timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, - maxRetries: requestOptions?.maxRetries, - abortSignal: requestOptions?.abortSignal, - }); - if (_response.ok) { - return _response.body as Intercom.CompanyList; - } - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); - default: + const list = core.HttpResponsePromise.interceptFunction( + async (request: Intercom.ListCompaniesRequest): Promise> => { + const { page, per_page: perPage, order } = request; + const _queryParams: Record = {}; + if (page != null) { + _queryParams["page"] = page.toString(); + } + if (perPage != null) { + _queryParams["per_page"] = perPage.toString(); + } + if (order != null) { + _queryParams["order"] = order; + } + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "companies/list", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: + requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.CompanyList, rawResponse: _response.rawResponse }; + } + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + switch (_response.error.reason) { + case "non-json": throw new errors.IntercomError({ statusCode: _response.error.statusCode, - body: _response.error.body, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /companies/list."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } - } - switch (_response.error.reason) { - case "non-json": - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.rawBody, - }); - case "timeout": - throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /companies/list."); - case "unknown": - throw new errors.IntercomError({ - message: _response.error.errorMessage, - }); - } - }; + }, + ); let _offset = request?.page != null ? request?.page : 1; + const dataWithRawResponse = await list(request).withRawResponse(); return new core.Pageable({ - response: await list(request), + response: dataWithRawResponse.data, + rawResponse: dataWithRawResponse.rawResponse, hasNextPage: (response) => (response?.data ?? []).length > 0, getItems: (response) => response?.data ?? [], loadPage: (_response) => { @@ -816,68 +918,79 @@ export class Companies { request: Intercom.ScrollCompaniesRequest = {}, requestOptions?: Companies.RequestOptions, ): Promise> { - const list = async (request: Intercom.ScrollCompaniesRequest): Promise => { - const { scroll_param: scrollParam } = request; - const _queryParams: Record = {}; - if (scrollParam != null) { - _queryParams["scroll_param"] = scrollParam; - } - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: urlJoin( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "companies/scroll", - ), - method: "GET", - headers: { - Authorization: await this._getAuthorizationHeader(), - "X-Fern-Language": "JavaScript", - "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", - "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - queryParameters: _queryParams, - requestType: "json", - timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, - maxRetries: requestOptions?.maxRetries, - abortSignal: requestOptions?.abortSignal, - }); - if (_response.ok) { - return _response.body as Intercom.CompanyScroll; - } - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); - default: + const list = core.HttpResponsePromise.interceptFunction( + async (request: Intercom.ScrollCompaniesRequest): Promise> => { + const { scroll_param: scrollParam } = request; + const _queryParams: Record = {}; + if (scrollParam != null) { + _queryParams["scroll_param"] = scrollParam; + } + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "companies/scroll", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: + requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.CompanyScroll, rawResponse: _response.rawResponse }; + } + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + switch (_response.error.reason) { + case "non-json": throw new errors.IntercomError({ statusCode: _response.error.statusCode, - body: _response.error.body, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /companies/scroll."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } - } - switch (_response.error.reason) { - case "non-json": - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.rawBody, - }); - case "timeout": - throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /companies/scroll."); - case "unknown": - throw new errors.IntercomError({ - message: _response.error.errorMessage, - }); - } - }; + }, + ); + const dataWithRawResponse = await list(request).withRawResponse(); return new core.Pageable({ - response: await list(request), + response: dataWithRawResponse.data, + rawResponse: dataWithRawResponse.rawResponse, hasNextPage: (response) => response?.scroll_param != null, getItems: (response) => response?.data ?? [], loadPage: (response) => { @@ -914,10 +1027,17 @@ export class Companies { * id: "123" * }) */ - public async attachContact( + public attachContact( + request: Intercom.AttachContactToCompanyRequest, + requestOptions?: Companies.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__attachContact(request, requestOptions)); + } + + private async __attachContact( request: Intercom.AttachContactToCompanyRequest, requestOptions?: Companies.RequestOptions, - ): Promise { + ): Promise> { const { contact_id: contactId, ..._body } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -931,8 +1051,8 @@ export class Companies { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -946,21 +1066,25 @@ export class Companies { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Company; + return { data: _response.body as Intercom.Company, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.BadRequestError(_response.error.body as unknown); + throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -970,6 +1094,7 @@ export class Companies { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -978,6 +1103,7 @@ export class Companies { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -997,10 +1123,17 @@ export class Companies { * company_id: "58a430d35458202d41b1e65b" * }) */ - public async detachContact( + public detachContact( + request: Intercom.DetachContactFromCompanyRequest, + requestOptions?: Companies.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__detachContact(request, requestOptions)); + } + + private async __detachContact( request: Intercom.DetachContactFromCompanyRequest, requestOptions?: Companies.RequestOptions, - ): Promise { + ): Promise> { const { contact_id: contactId, company_id: companyId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -1014,8 +1147,8 @@ export class Companies { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -1028,19 +1161,23 @@ export class Companies { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Company; + return { data: _response.body as Intercom.Company, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -1050,6 +1187,7 @@ export class Companies { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -1058,6 +1196,7 @@ export class Companies { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } diff --git a/src/api/resources/contacts/client/Client.ts b/src/api/resources/contacts/client/Client.ts index a932e14b..894de6c9 100644 --- a/src/api/resources/contacts/client/Client.ts +++ b/src/api/resources/contacts/client/Client.ts @@ -93,78 +93,92 @@ export class Contacts { request: Intercom.ListAttachedCompaniesRequest, requestOptions?: Contacts.RequestOptions, ): Promise> { - const list = async ( - request: Intercom.ListAttachedCompaniesRequest, - ): Promise => { - const { contact_id: contactId, page, per_page: perPage } = request; - const _queryParams: Record = {}; - if (page != null) { - _queryParams["page"] = page.toString(); - } - if (perPage != null) { - _queryParams["per_page"] = perPage.toString(); - } - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: urlJoin( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${encodeURIComponent(contactId)}/companies`, - ), - method: "GET", - headers: { - Authorization: await this._getAuthorizationHeader(), - "X-Fern-Language": "JavaScript", - "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", - "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - queryParameters: _queryParams, - requestType: "json", - timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, - maxRetries: requestOptions?.maxRetries, - abortSignal: requestOptions?.abortSignal, - }); - if (_response.ok) { - return _response.body as Intercom.ContactAttachedCompanies; - } - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); - case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); - default: + const list = core.HttpResponsePromise.interceptFunction( + async ( + request: Intercom.ListAttachedCompaniesRequest, + ): Promise> => { + const { contact_id: contactId, page, per_page: perPage } = request; + const _queryParams: Record = {}; + if (page != null) { + _queryParams["page"] = page.toString(); + } + if (perPage != null) { + _queryParams["per_page"] = perPage.toString(); + } + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${encodeURIComponent(contactId)}/companies`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: + requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.ContactAttachedCompanies, + rawResponse: _response.rawResponse, + }; + } + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + switch (_response.error.reason) { + case "non-json": throw new errors.IntercomError({ statusCode: _response.error.statusCode, - body: _response.error.body, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling GET /contacts/{contact_id}/companies.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } - } - switch (_response.error.reason) { - case "non-json": - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.rawBody, - }); - case "timeout": - throw new errors.IntercomTimeoutError( - "Timeout exceeded when calling GET /contacts/{contact_id}/companies.", - ); - case "unknown": - throw new errors.IntercomError({ - message: _response.error.errorMessage, - }); - } - }; + }, + ); let _offset = request?.page != null ? request?.page : 1; + const dataWithRawResponse = await list(request).withRawResponse(); return new core.Pageable({ - response: await list(request), + response: dataWithRawResponse.data, + rawResponse: dataWithRawResponse.rawResponse, hasNextPage: (response) => (response?.companies ?? []).length > 0, getItems: (response) => response?.companies ?? [], loadPage: (_response) => { @@ -188,10 +202,17 @@ export class Contacts { * contact_id: "63a07ddf05a32042dffac965" * }) */ - public async listAttachedSegments( + public listAttachedSegments( + request: Intercom.ListSegmentsAttachedToContactRequest, + requestOptions?: Contacts.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listAttachedSegments(request, requestOptions)); + } + + private async __listAttachedSegments( request: Intercom.ListSegmentsAttachedToContactRequest, requestOptions?: Contacts.RequestOptions, - ): Promise { + ): Promise> { const { contact_id: contactId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -205,8 +226,8 @@ export class Contacts { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -219,19 +240,23 @@ export class Contacts { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.ContactSegments; + return { data: _response.body as Intercom.ContactSegments, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -241,6 +266,7 @@ export class Contacts { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -249,6 +275,7 @@ export class Contacts { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -273,10 +300,17 @@ export class Contacts { * contact_id: "63a07ddf05a32042dffac965" * }) */ - public async listAttachedSubscriptions( + public listAttachedSubscriptions( + request: Intercom.ListAttachedSubscriptionsRequest, + requestOptions?: Contacts.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listAttachedSubscriptions(request, requestOptions)); + } + + private async __listAttachedSubscriptions( request: Intercom.ListAttachedSubscriptionsRequest, requestOptions?: Contacts.RequestOptions, - ): Promise { + ): Promise> { const { contact_id: contactId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -290,8 +324,8 @@ export class Contacts { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -304,19 +338,23 @@ export class Contacts { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.SubscriptionTypeList; + return { data: _response.body as Intercom.SubscriptionTypeList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -326,6 +364,7 @@ export class Contacts { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -334,6 +373,7 @@ export class Contacts { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -367,10 +407,17 @@ export class Contacts { * consent_type: "opt_in" * }) */ - public async attachSubscription( + public attachSubscription( request: Intercom.AttachSubscriptionToContactRequest, requestOptions?: Contacts.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__attachSubscription(request, requestOptions)); + } + + private async __attachSubscription( + request: Intercom.AttachSubscriptionToContactRequest, + requestOptions?: Contacts.RequestOptions, + ): Promise> { const { contact_id: contactId, ..._body } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -384,8 +431,8 @@ export class Contacts { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -399,19 +446,23 @@ export class Contacts { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.SubscriptionType; + return { data: _response.body as Intercom.SubscriptionType, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -421,6 +472,7 @@ export class Contacts { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -429,6 +481,7 @@ export class Contacts { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -448,10 +501,17 @@ export class Contacts { * subscription_id: "37846" * }) */ - public async detachSubscription( + public detachSubscription( + request: Intercom.DetachSubscriptionFromContactRequest, + requestOptions?: Contacts.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__detachSubscription(request, requestOptions)); + } + + private async __detachSubscription( request: Intercom.DetachSubscriptionFromContactRequest, requestOptions?: Contacts.RequestOptions, - ): Promise { + ): Promise> { const { contact_id: contactId, subscription_id: subscriptionId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -465,8 +525,8 @@ export class Contacts { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -479,19 +539,23 @@ export class Contacts { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.SubscriptionType; + return { data: _response.body as Intercom.SubscriptionType, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -501,6 +565,7 @@ export class Contacts { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -509,6 +574,7 @@ export class Contacts { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -527,10 +593,17 @@ export class Contacts { * contact_id: "63a07ddf05a32042dffac965" * }) */ - public async listAttachedTags( + public listAttachedTags( + request: Intercom.ListTagsAttachedToContactRequest, + requestOptions?: Contacts.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listAttachedTags(request, requestOptions)); + } + + private async __listAttachedTags( request: Intercom.ListTagsAttachedToContactRequest, requestOptions?: Contacts.RequestOptions, - ): Promise { + ): Promise> { const { contact_id: contactId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -544,8 +617,8 @@ export class Contacts { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -558,19 +631,23 @@ export class Contacts { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.TagList; + return { data: _response.body as Intercom.TagList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -580,12 +657,14 @@ export class Contacts { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /contacts/{contact_id}/tags."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -603,10 +682,17 @@ export class Contacts { * contact_id: "63a07ddf05a32042dffac965" * }) */ - public async find( + public find( request: Intercom.FindContactRequest, requestOptions?: Contacts.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); + } + + private async __find( + request: Intercom.FindContactRequest, + requestOptions?: Contacts.RequestOptions, + ): Promise> { const { contact_id: contactId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -620,8 +706,8 @@ export class Contacts { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -634,17 +720,21 @@ export class Contacts { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Contact; + return { data: _response.body as Intercom.Contact, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -654,12 +744,14 @@ export class Contacts { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /contacts/{contact_id}."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -679,10 +771,17 @@ export class Contacts { * name: "joe bloggs" * }) */ - public async update( + public update( request: Intercom.UpdateContactRequest, requestOptions?: Contacts.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions)); + } + + private async __update( + request: Intercom.UpdateContactRequest, + requestOptions?: Contacts.RequestOptions, + ): Promise> { const { contact_id: contactId, ..._body } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -696,8 +795,8 @@ export class Contacts { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -711,17 +810,21 @@ export class Contacts { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Contact; + return { data: _response.body as Intercom.Contact, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -731,12 +834,14 @@ export class Contacts { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling PUT /contacts/{contact_id}."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -754,10 +859,17 @@ export class Contacts { * contact_id: "contact_id" * }) */ - public async delete( + public delete( + request: Intercom.DeleteContactRequest, + requestOptions?: Contacts.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__delete(request, requestOptions)); + } + + private async __delete( request: Intercom.DeleteContactRequest, requestOptions?: Contacts.RequestOptions, - ): Promise { + ): Promise> { const { contact_id: contactId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -771,8 +883,8 @@ export class Contacts { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -785,17 +897,21 @@ export class Contacts { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.ContactDeleted; + return { data: _response.body as Intercom.ContactDeleted, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -805,12 +921,14 @@ export class Contacts { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling DELETE /contacts/{contact_id}."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -829,10 +947,17 @@ export class Contacts { * into: "667d60ac8a68186f43bafdbc" * }) */ - public async mergeLeadInUser( + public mergeLeadInUser( + request: Intercom.MergeContactsRequest, + requestOptions?: Contacts.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__mergeLeadInUser(request, requestOptions)); + } + + private async __mergeLeadInUser( request: Intercom.MergeContactsRequest, requestOptions?: Contacts.RequestOptions, - ): Promise { + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -845,8 +970,8 @@ export class Contacts { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -860,17 +985,21 @@ export class Contacts { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Contact; + return { data: _response.body as Intercom.Contact, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -880,12 +1009,14 @@ export class Contacts { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /contacts/merge."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -1015,63 +1146,74 @@ export class Contacts { request: Intercom.SearchRequest, requestOptions?: Contacts.RequestOptions, ): Promise> { - const list = async (request: Intercom.SearchRequest): Promise => { - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: urlJoin( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "contacts/search", - ), - method: "POST", - headers: { - Authorization: await this._getAuthorizationHeader(), - "X-Fern-Language": "JavaScript", - "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", - "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", - body: request, - timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, - maxRetries: requestOptions?.maxRetries, - abortSignal: requestOptions?.abortSignal, - }); - if (_response.ok) { - return _response.body as Intercom.ContactList; - } - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); - default: + const list = core.HttpResponsePromise.interceptFunction( + async (request: Intercom.SearchRequest): Promise> => { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "contacts/search", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: + requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.ContactList, rawResponse: _response.rawResponse }; + } + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + switch (_response.error.reason) { + case "non-json": throw new errors.IntercomError({ statusCode: _response.error.statusCode, - body: _response.error.body, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /contacts/search."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } - } - switch (_response.error.reason) { - case "non-json": - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.rawBody, - }); - case "timeout": - throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /contacts/search."); - case "unknown": - throw new errors.IntercomError({ - message: _response.error.errorMessage, - }); - } - }; + }, + ); + const dataWithRawResponse = await list(request).withRawResponse(); return new core.Pageable({ - response: await list(request), + response: dataWithRawResponse.data, + rawResponse: dataWithRawResponse.rawResponse, hasNextPage: (response) => response?.pages?.next?.starting_after != null, getItems: (response) => response?.data ?? [], loadPage: (response) => { @@ -1101,74 +1243,85 @@ export class Contacts { request: Intercom.ListContactsRequest = {}, requestOptions?: Contacts.RequestOptions, ): Promise> { - const list = async (request: Intercom.ListContactsRequest): Promise => { - const { page, per_page: perPage, starting_after: startingAfter } = request; - const _queryParams: Record = {}; - if (page != null) { - _queryParams["page"] = page.toString(); - } - if (perPage != null) { - _queryParams["per_page"] = perPage.toString(); - } - if (startingAfter != null) { - _queryParams["starting_after"] = startingAfter; - } - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: urlJoin( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "contacts", - ), - method: "GET", - headers: { - Authorization: await this._getAuthorizationHeader(), - "X-Fern-Language": "JavaScript", - "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", - "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - queryParameters: _queryParams, - requestType: "json", - timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, - maxRetries: requestOptions?.maxRetries, - abortSignal: requestOptions?.abortSignal, - }); - if (_response.ok) { - return _response.body as Intercom.ContactList; - } - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); - default: + const list = core.HttpResponsePromise.interceptFunction( + async (request: Intercom.ListContactsRequest): Promise> => { + const { page, per_page: perPage, starting_after: startingAfter } = request; + const _queryParams: Record = {}; + if (page != null) { + _queryParams["page"] = page.toString(); + } + if (perPage != null) { + _queryParams["per_page"] = perPage.toString(); + } + if (startingAfter != null) { + _queryParams["starting_after"] = startingAfter; + } + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "contacts", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: + requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.ContactList, rawResponse: _response.rawResponse }; + } + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + switch (_response.error.reason) { + case "non-json": throw new errors.IntercomError({ statusCode: _response.error.statusCode, - body: _response.error.body, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /contacts."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } - } - switch (_response.error.reason) { - case "non-json": - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.rawBody, - }); - case "timeout": - throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /contacts."); - case "unknown": - throw new errors.IntercomError({ - message: _response.error.errorMessage, - }); - } - }; + }, + ); + const dataWithRawResponse = await list(request).withRawResponse(); return new core.Pageable({ - response: await list(request), + response: dataWithRawResponse.data, + rawResponse: dataWithRawResponse.rawResponse, hasNextPage: (response) => response?.pages?.next?.starting_after != null, getItems: (response) => response?.data ?? [], loadPage: (response) => { @@ -1190,10 +1343,17 @@ export class Contacts { * email: "joebloggs@intercom.io" * }) */ - public async create( + public create( request: Intercom.CreateContactRequest, requestOptions?: Contacts.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); + } + + private async __create( + request: Intercom.CreateContactRequest, + requestOptions?: Contacts.RequestOptions, + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -1206,8 +1366,8 @@ export class Contacts { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -1221,17 +1381,21 @@ export class Contacts { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Contact; + return { data: _response.body as Intercom.Contact, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -1241,12 +1405,14 @@ export class Contacts { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /contacts."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -1262,10 +1428,17 @@ export class Contacts { * contact_id: "63a07ddf05a32042dffac965" * }) */ - public async archive( + public archive( + request: Intercom.ArchiveContactRequest, + requestOptions?: Contacts.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__archive(request, requestOptions)); + } + + private async __archive( request: Intercom.ArchiveContactRequest, requestOptions?: Contacts.RequestOptions, - ): Promise { + ): Promise> { const { contact_id: contactId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -1279,8 +1452,8 @@ export class Contacts { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -1293,13 +1466,14 @@ export class Contacts { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.ContactArchived; + return { data: _response.body as Intercom.ContactArchived, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } @@ -1308,6 +1482,7 @@ export class Contacts { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -1316,6 +1491,7 @@ export class Contacts { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -1331,10 +1507,17 @@ export class Contacts { * contact_id: "63a07ddf05a32042dffac965" * }) */ - public async unarchive( + public unarchive( + request: Intercom.UnarchiveContactRequest, + requestOptions?: Contacts.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__unarchive(request, requestOptions)); + } + + private async __unarchive( request: Intercom.UnarchiveContactRequest, requestOptions?: Contacts.RequestOptions, - ): Promise { + ): Promise> { const { contact_id: contactId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -1348,8 +1531,8 @@ export class Contacts { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -1362,13 +1545,14 @@ export class Contacts { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.ContactUnarchived; + return { data: _response.body as Intercom.ContactUnarchived, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } @@ -1377,6 +1561,7 @@ export class Contacts { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -1385,6 +1570,7 @@ export class Contacts { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } diff --git a/src/api/resources/conversations/client/Client.ts b/src/api/resources/conversations/client/Client.ts index b678ff40..d24ccbfd 100644 --- a/src/api/resources/conversations/client/Client.ts +++ b/src/api/resources/conversations/client/Client.ts @@ -97,75 +97,92 @@ export class Conversations { request: Intercom.ListConversationsRequest = {}, requestOptions?: Conversations.RequestOptions, ): Promise> { - const list = async ( - request: Intercom.ListConversationsRequest, - ): Promise => { - const { per_page: perPage, starting_after: startingAfter } = request; - const _queryParams: Record = {}; - if (perPage != null) { - _queryParams["per_page"] = perPage.toString(); - } - if (startingAfter != null) { - _queryParams["starting_after"] = startingAfter; - } - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: urlJoin( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "conversations", - ), - method: "GET", - headers: { - Authorization: await this._getAuthorizationHeader(), - "X-Fern-Language": "JavaScript", - "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", - "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - queryParameters: _queryParams, - requestType: "json", - timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, - maxRetries: requestOptions?.maxRetries, - abortSignal: requestOptions?.abortSignal, - }); - if (_response.ok) { - return _response.body as Intercom.PaginatedConversationResponse; - } - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); - case 403: - throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_); - default: + const list = core.HttpResponsePromise.interceptFunction( + async ( + request: Intercom.ListConversationsRequest, + ): Promise> => { + const { per_page: perPage, starting_after: startingAfter } = request; + const _queryParams: Record = {}; + if (perPage != null) { + _queryParams["per_page"] = perPage.toString(); + } + if (startingAfter != null) { + _queryParams["starting_after"] = startingAfter; + } + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "conversations", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: + requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.PaginatedConversationResponse, + rawResponse: _response.rawResponse, + }; + } + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.ForbiddenError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + switch (_response.error.reason) { + case "non-json": throw new errors.IntercomError({ statusCode: _response.error.statusCode, - body: _response.error.body, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /conversations."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } - } - switch (_response.error.reason) { - case "non-json": - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.rawBody, - }); - case "timeout": - throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /conversations."); - case "unknown": - throw new errors.IntercomError({ - message: _response.error.errorMessage, - }); - } - }; + }, + ); + const dataWithRawResponse = await list(request).withRawResponse(); return new core.Pageable({ - response: await list(request), + response: dataWithRawResponse.data, + rawResponse: dataWithRawResponse.rawResponse, hasNextPage: (response) => response?.pages?.next?.starting_after != null, getItems: (response) => response?.conversations ?? [], loadPage: (response) => { @@ -210,10 +227,17 @@ export class Conversations { * body: "Hello there" * }) */ - public async create( + public create( request: Intercom.CreateConversationRequest, requestOptions?: Conversations.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); + } + + private async __create( + request: Intercom.CreateConversationRequest, + requestOptions?: Conversations.RequestOptions, + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -226,8 +250,8 @@ export class Conversations { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -241,21 +265,25 @@ export class Conversations { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Message; + return { data: _response.body as Intercom.Message, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 403: - throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_); + throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_, _response.rawResponse); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -265,12 +293,14 @@ export class Conversations { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /conversations."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -300,10 +330,17 @@ export class Conversations { * display_as: "plaintext" * }) */ - public async find( + public find( + request: Intercom.FindConversationRequest, + requestOptions?: Conversations.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); + } + + private async __find( request: Intercom.FindConversationRequest, requestOptions?: Conversations.RequestOptions, - ): Promise { + ): Promise> { const { conversation_id: conversationId, display_as: displayAs } = request; const _queryParams: Record = {}; if (displayAs != null) { @@ -322,8 +359,8 @@ export class Conversations { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -337,21 +374,25 @@ export class Conversations { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Conversation; + return { data: _response.body as Intercom.Conversation, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 403: - throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_); + throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_, _response.rawResponse); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -361,6 +402,7 @@ export class Conversations { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -369,6 +411,7 @@ export class Conversations { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -399,10 +442,17 @@ export class Conversations { * } * }) */ - public async update( + public update( request: Intercom.UpdateConversationRequest, requestOptions?: Conversations.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions)); + } + + private async __update( + request: Intercom.UpdateConversationRequest, + requestOptions?: Conversations.RequestOptions, + ): Promise> { const { conversation_id: conversationId, display_as: displayAs, ..._body } = request; const _queryParams: Record = {}; if (displayAs != null) { @@ -421,8 +471,8 @@ export class Conversations { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -437,21 +487,25 @@ export class Conversations { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Conversation; + return { data: _response.body as Intercom.Conversation, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 403: - throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_); + throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_, _response.rawResponse); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -461,6 +515,7 @@ export class Conversations { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -469,6 +524,7 @@ export class Conversations { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -596,58 +652,73 @@ export class Conversations { request: Intercom.SearchRequest, requestOptions?: Conversations.RequestOptions, ): Promise> { - const list = async (request: Intercom.SearchRequest): Promise => { - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: urlJoin( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "conversations/search", - ), - method: "POST", - headers: { - Authorization: await this._getAuthorizationHeader(), - "X-Fern-Language": "JavaScript", - "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", - "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", - body: request, - timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, - maxRetries: requestOptions?.maxRetries, - abortSignal: requestOptions?.abortSignal, - }); - if (_response.ok) { - return _response.body as Intercom.PaginatedConversationResponse; - } - if (_response.error.reason === "status-code") { - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, + const list = core.HttpResponsePromise.interceptFunction( + async ( + request: Intercom.SearchRequest, + ): Promise> => { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "conversations/search", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: + requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, }); - } - switch (_response.error.reason) { - case "non-json": + if (_response.ok) { + return { + data: _response.body as Intercom.PaginatedConversationResponse, + rawResponse: _response.rawResponse, + }; + } + if (_response.error.reason === "status-code") { throw new errors.IntercomError({ statusCode: _response.error.statusCode, - body: _response.error.rawBody, - }); - case "timeout": - throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /conversations/search."); - case "unknown": - throw new errors.IntercomError({ - message: _response.error.errorMessage, + body: _response.error.body, + rawResponse: _response.rawResponse, }); - } - }; + } + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling POST /conversations/search.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + }, + ); + const dataWithRawResponse = await list(request).withRawResponse(); return new core.Pageable({ - response: await list(request), + response: dataWithRawResponse.data, + rawResponse: dataWithRawResponse.rawResponse, hasNextPage: (response) => response?.pages?.next?.starting_after != null, getItems: (response) => response?.conversations ?? [], loadPage: (response) => { @@ -712,10 +783,17 @@ export class Conversations { * } * }) */ - public async reply( + public reply( request: Intercom.ReplyToConversationRequest, requestOptions?: Conversations.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__reply(request, requestOptions)); + } + + private async __reply( + request: Intercom.ReplyToConversationRequest, + requestOptions?: Conversations.RequestOptions, + ): Promise> { const { conversation_id: conversationId, body: _body } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -729,8 +807,8 @@ export class Conversations { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -744,21 +822,25 @@ export class Conversations { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Conversation; + return { data: _response.body as Intercom.Conversation, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 403: - throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_); + throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_, _response.rawResponse); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -768,6 +850,7 @@ export class Conversations { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -776,6 +859,7 @@ export class Conversations { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -834,10 +918,17 @@ export class Conversations { * } * }) */ - public async manage( + public manage( request: Intercom.ManageConversationPartsRequest, requestOptions?: Conversations.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__manage(request, requestOptions)); + } + + private async __manage( + request: Intercom.ManageConversationPartsRequest, + requestOptions?: Conversations.RequestOptions, + ): Promise> { const { conversation_id: conversationId, body: _body } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -851,8 +942,8 @@ export class Conversations { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -866,21 +957,25 @@ export class Conversations { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Conversation; + return { data: _response.body as Intercom.Conversation, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 403: - throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_); + throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_, _response.rawResponse); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -890,6 +985,7 @@ export class Conversations { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -898,6 +994,7 @@ export class Conversations { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -923,10 +1020,17 @@ export class Conversations { * conversation_id: "123" * }) */ - public async runAssignmentRules( + public runAssignmentRules( + request: Intercom.AutoAssignConversationRequest, + requestOptions?: Conversations.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__runAssignmentRules(request, requestOptions)); + } + + private async __runAssignmentRules( request: Intercom.AutoAssignConversationRequest, requestOptions?: Conversations.RequestOptions, - ): Promise { + ): Promise> { const { conversation_id: conversationId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -940,8 +1044,8 @@ export class Conversations { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -954,21 +1058,25 @@ export class Conversations { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Conversation; + return { data: _response.body as Intercom.Conversation, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 403: - throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_); + throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_, _response.rawResponse); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -978,6 +1086,7 @@ export class Conversations { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -986,6 +1095,7 @@ export class Conversations { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -1022,10 +1132,17 @@ export class Conversations { * } * }) */ - public async attachContactAsAdmin( + public attachContactAsAdmin( + request: Intercom.AttachContactToConversationRequest, + requestOptions?: Conversations.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__attachContactAsAdmin(request, requestOptions)); + } + + private async __attachContactAsAdmin( request: Intercom.AttachContactToConversationRequest, requestOptions?: Conversations.RequestOptions, - ): Promise { + ): Promise> { const { conversation_id: conversationId, ..._body } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -1039,8 +1156,8 @@ export class Conversations { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -1054,21 +1171,25 @@ export class Conversations { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Conversation; + return { data: _response.body as Intercom.Conversation, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 403: - throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_); + throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_, _response.rawResponse); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -1078,6 +1199,7 @@ export class Conversations { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -1086,6 +1208,7 @@ export class Conversations { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -1112,10 +1235,17 @@ export class Conversations { * admin_id: "5017690" * }) */ - public async detachContactAsAdmin( + public detachContactAsAdmin( request: Intercom.DetachContactFromConversationRequest, requestOptions?: Conversations.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__detachContactAsAdmin(request, requestOptions)); + } + + private async __detachContactAsAdmin( + request: Intercom.DetachContactFromConversationRequest, + requestOptions?: Conversations.RequestOptions, + ): Promise> { const { conversation_id: conversationId, contact_id: contactId, ..._body } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -1129,8 +1259,8 @@ export class Conversations { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -1144,23 +1274,27 @@ export class Conversations { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Conversation; + return { data: _response.body as Intercom.Conversation, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 403: - throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_); + throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_, _response.rawResponse); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); case 422: - throw new Intercom.UnprocessableEntityError(_response.error.body as unknown); + throw new Intercom.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -1170,6 +1304,7 @@ export class Conversations { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -1178,6 +1313,7 @@ export class Conversations { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -1209,10 +1345,17 @@ export class Conversations { * conversation_part_id: "really_123_doesnt_exist" * }) */ - public async redactConversationPart( + public redactConversationPart( + request: Intercom.RedactConversationRequest, + requestOptions?: Conversations.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__redactConversationPart(request, requestOptions)); + } + + private async __redactConversationPart( request: Intercom.RedactConversationRequest, requestOptions?: Conversations.RequestOptions, - ): Promise { + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -1225,8 +1368,8 @@ export class Conversations { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -1240,19 +1383,23 @@ export class Conversations { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Conversation; + return { data: _response.body as Intercom.Conversation, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -1262,12 +1409,14 @@ export class Conversations { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /conversations/redact."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -1292,10 +1441,17 @@ export class Conversations { * ticket_type_id: "80" * }) */ - public async convertToTicket( + public convertToTicket( + request: Intercom.ConvertConversationToTicketRequest, + requestOptions?: Conversations.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__convertToTicket(request, requestOptions)); + } + + private async __convertToTicket( request: Intercom.ConvertConversationToTicketRequest, requestOptions?: Conversations.RequestOptions, - ): Promise { + ): Promise> { const { conversation_id: conversationId, ..._body } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -1309,8 +1465,8 @@ export class Conversations { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -1324,17 +1480,18 @@ export class Conversations { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Ticket; + return { data: _response.body as Intercom.Ticket, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.BadRequestError(_response.error.body as unknown); + throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -1344,6 +1501,7 @@ export class Conversations { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -1352,6 +1510,7 @@ export class Conversations { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } diff --git a/src/api/resources/dataAttributes/client/Client.ts b/src/api/resources/dataAttributes/client/Client.ts index fe06c4fe..cd6b4d7e 100644 --- a/src/api/resources/dataAttributes/client/Client.ts +++ b/src/api/resources/dataAttributes/client/Client.ts @@ -86,10 +86,17 @@ export class DataAttributes { * @example * await client.dataAttributes.list() */ - public async list( + public list( request: Intercom.ListDataAttributesRequest = {}, requestOptions?: DataAttributes.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__list(request, requestOptions)); + } + + private async __list( + request: Intercom.ListDataAttributesRequest = {}, + requestOptions?: DataAttributes.RequestOptions, + ): Promise> { const { model, include_archived: includeArchived } = request; const _queryParams: Record = {}; if (model != null) { @@ -112,8 +119,8 @@ export class DataAttributes { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -127,17 +134,21 @@ export class DataAttributes { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.DataAttributeList; + return { data: _response.body as Intercom.DataAttributeList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -147,12 +158,14 @@ export class DataAttributes { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /data_attributes."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -210,10 +223,17 @@ export class DataAttributes { * options: ["options"] * }) */ - public async create( + public create( + request: Intercom.CreateDataAttributeRequest, + requestOptions?: DataAttributes.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); + } + + private async __create( request: Intercom.CreateDataAttributeRequest, requestOptions?: DataAttributes.RequestOptions, - ): Promise { + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -226,8 +246,8 @@ export class DataAttributes { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -241,19 +261,23 @@ export class DataAttributes { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.DataAttribute; + return { data: _response.body as Intercom.DataAttribute, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.BadRequestError(_response.error.body as unknown); + throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -263,12 +287,14 @@ export class DataAttributes { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /data_attributes."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -320,10 +346,17 @@ export class DataAttributes { * description: "Trying to archieve" * }) */ - public async update( + public update( + request: Intercom.UpdateDataAttributeRequest, + requestOptions?: DataAttributes.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions)); + } + + private async __update( request: Intercom.UpdateDataAttributeRequest, requestOptions?: DataAttributes.RequestOptions, - ): Promise { + ): Promise> { const { data_attribute_id: dataAttributeId, ..._body } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -337,8 +370,8 @@ export class DataAttributes { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -352,23 +385,27 @@ export class DataAttributes { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.DataAttribute; + return { data: _response.body as Intercom.DataAttribute, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.BadRequestError(_response.error.body as unknown); + throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); case 422: - throw new Intercom.UnprocessableEntityError(_response.error.body as unknown); + throw new Intercom.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -378,6 +415,7 @@ export class DataAttributes { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -386,6 +424,7 @@ export class DataAttributes { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } diff --git a/src/api/resources/dataExport/client/Client.ts b/src/api/resources/dataExport/client/Client.ts index f4c041aa..72d82c09 100644 --- a/src/api/resources/dataExport/client/Client.ts +++ b/src/api/resources/dataExport/client/Client.ts @@ -101,10 +101,17 @@ export class DataExport { * created_at_before: 1719492967 * }) */ - public async create( + public create( request: Intercom.CreateDataExportRequest, requestOptions?: DataExport.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); + } + + private async __create( + request: Intercom.CreateDataExportRequest, + requestOptions?: DataExport.RequestOptions, + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -117,8 +124,8 @@ export class DataExport { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -132,13 +139,14 @@ export class DataExport { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.DataExport; + return { data: _response.body as Intercom.DataExport, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } @@ -147,12 +155,14 @@ export class DataExport { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /export/content/data."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -172,10 +182,17 @@ export class DataExport { * job_identifier: "job_identifier" * }) */ - public async find( + public find( + request: Intercom.FindDataExportRequest, + requestOptions?: DataExport.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); + } + + private async __find( request: Intercom.FindDataExportRequest, requestOptions?: DataExport.RequestOptions, - ): Promise { + ): Promise> { const { job_identifier: jobIdentifier } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -189,8 +206,8 @@ export class DataExport { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -203,13 +220,14 @@ export class DataExport { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.DataExport; + return { data: _response.body as Intercom.DataExport, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } @@ -218,6 +236,7 @@ export class DataExport { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -226,6 +245,7 @@ export class DataExport { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -241,10 +261,17 @@ export class DataExport { * job_identifier: "job_identifier" * }) */ - public async cancel( + public cancel( request: Intercom.CancelDataExportRequest, requestOptions?: DataExport.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__cancel(request, requestOptions)); + } + + private async __cancel( + request: Intercom.CancelDataExportRequest, + requestOptions?: DataExport.RequestOptions, + ): Promise> { const { job_identifier: jobIdentifier } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -258,8 +285,8 @@ export class DataExport { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -272,13 +299,14 @@ export class DataExport { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.DataExport; + return { data: _response.body as Intercom.DataExport, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } @@ -287,6 +315,7 @@ export class DataExport { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -295,6 +324,7 @@ export class DataExport { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -316,10 +346,17 @@ export class DataExport { * job_identifier: "job_identifier" * }) */ - public async download( + public download( + request: Intercom.DownloadDataExportRequest, + requestOptions?: DataExport.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__download(request, requestOptions)); + } + + private async __download( request: Intercom.DownloadDataExportRequest, requestOptions?: DataExport.RequestOptions, - ): Promise { + ): Promise> { const { job_identifier: jobIdentifier } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -333,8 +370,8 @@ export class DataExport { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -347,13 +384,14 @@ export class DataExport { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return; + return { data: undefined, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } @@ -362,6 +400,7 @@ export class DataExport { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -370,6 +409,7 @@ export class DataExport { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } diff --git a/src/api/resources/events/client/Client.ts b/src/api/resources/events/client/Client.ts index 3b8c96f7..a51cd863 100644 --- a/src/api/resources/events/client/Client.ts +++ b/src/api/resources/events/client/Client.ts @@ -98,10 +98,17 @@ export class Events { * type: "type" * }) */ - public async list( + public list( request: Intercom.ListEventsRequest, requestOptions?: Events.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__list(request, requestOptions)); + } + + private async __list( + request: Intercom.ListEventsRequest, + requestOptions?: Events.RequestOptions, + ): Promise> { const { user_id: userId, intercom_user_id: intercomUserId, @@ -144,8 +151,8 @@ export class Events { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -159,17 +166,21 @@ export class Events { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.DataEventSummary; + return { data: _response.body as Intercom.DataEventSummary, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -179,12 +190,14 @@ export class Events { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /events."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -244,10 +257,17 @@ export class Events { * created_at: 1671028894 * }) */ - public async create( + public create( + request: Intercom.CreateDataEventRequest, + requestOptions?: Events.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); + } + + private async __create( request: Intercom.CreateDataEventRequest, requestOptions?: Events.RequestOptions, - ): Promise { + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -260,8 +280,8 @@ export class Events { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -275,17 +295,21 @@ export class Events { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return; + return { data: undefined, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -295,12 +319,14 @@ export class Events { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /events."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -316,10 +342,17 @@ export class Events { * @example * await client.events.summaries() */ - public async summaries( + public summaries( + request: Intercom.ListEventSummariesRequest = {}, + requestOptions?: Events.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__summaries(request, requestOptions)); + } + + private async __summaries( request: Intercom.ListEventSummariesRequest = {}, requestOptions?: Events.RequestOptions, - ): Promise { + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -332,8 +365,8 @@ export class Events { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -347,17 +380,21 @@ export class Events { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return; + return { data: undefined, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -367,12 +404,14 @@ export class Events { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /events/summaries."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } diff --git a/src/api/resources/helpCenters/client/Client.ts b/src/api/resources/helpCenters/client/Client.ts index 523ddf97..f8a1cf28 100644 --- a/src/api/resources/helpCenters/client/Client.ts +++ b/src/api/resources/helpCenters/client/Client.ts @@ -93,10 +93,17 @@ export class HelpCenters { * help_center_id: "123" * }) */ - public async find( + public find( request: Intercom.FindHelpCenterRequest, requestOptions?: HelpCenters.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); + } + + private async __find( + request: Intercom.FindHelpCenterRequest, + requestOptions?: HelpCenters.RequestOptions, + ): Promise> { const { help_center_id: helpCenterId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -110,8 +117,8 @@ export class HelpCenters { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -124,19 +131,23 @@ export class HelpCenters { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.HelpCenter; + return { data: _response.body as Intercom.HelpCenter, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -146,6 +157,7 @@ export class HelpCenters { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -154,6 +166,7 @@ export class HelpCenters { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -173,74 +186,87 @@ export class HelpCenters { request: Intercom.ListHelpCentersRequest = {}, requestOptions?: HelpCenters.RequestOptions, ): Promise> { - const list = async (request: Intercom.ListHelpCentersRequest): Promise => { - const { page, per_page: perPage } = request; - const _queryParams: Record = {}; - if (page != null) { - _queryParams["page"] = page.toString(); - } - if (perPage != null) { - _queryParams["per_page"] = perPage.toString(); - } - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: urlJoin( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "help_center/help_centers", - ), - method: "GET", - headers: { - Authorization: await this._getAuthorizationHeader(), - "X-Fern-Language": "JavaScript", - "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", - "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - queryParameters: _queryParams, - requestType: "json", - timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, - maxRetries: requestOptions?.maxRetries, - abortSignal: requestOptions?.abortSignal, - }); - if (_response.ok) { - return _response.body as Intercom.HelpCenterList; - } - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); - default: + const list = core.HttpResponsePromise.interceptFunction( + async ( + request: Intercom.ListHelpCentersRequest, + ): Promise> => { + const { page, per_page: perPage } = request; + const _queryParams: Record = {}; + if (page != null) { + _queryParams["page"] = page.toString(); + } + if (perPage != null) { + _queryParams["per_page"] = perPage.toString(); + } + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "help_center/help_centers", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: + requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.HelpCenterList, rawResponse: _response.rawResponse }; + } + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + switch (_response.error.reason) { + case "non-json": throw new errors.IntercomError({ statusCode: _response.error.statusCode, - body: _response.error.body, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling GET /help_center/help_centers.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } - } - switch (_response.error.reason) { - case "non-json": - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.rawBody, - }); - case "timeout": - throw new errors.IntercomTimeoutError( - "Timeout exceeded when calling GET /help_center/help_centers.", - ); - case "unknown": - throw new errors.IntercomError({ - message: _response.error.errorMessage, - }); - } - }; + }, + ); let _offset = request?.page != null ? request?.page : 1; + const dataWithRawResponse = await list(request).withRawResponse(); return new core.Pageable({ - response: await list(request), + response: dataWithRawResponse.data, + rawResponse: dataWithRawResponse.rawResponse, hasNextPage: (response) => (response?.data ?? []).length > 0, getItems: (response) => response?.data ?? [], loadPage: (_response) => { diff --git a/src/api/resources/helpCenters/resources/collections/client/Client.ts b/src/api/resources/helpCenters/resources/collections/client/Client.ts index e5b4fb85..b123a0c1 100644 --- a/src/api/resources/helpCenters/resources/collections/client/Client.ts +++ b/src/api/resources/helpCenters/resources/collections/client/Client.ts @@ -89,74 +89,87 @@ export class Collections { request: Intercom.helpCenters.ListCollectionsRequest = {}, requestOptions?: Collections.RequestOptions, ): Promise> { - const list = async (request: Intercom.helpCenters.ListCollectionsRequest): Promise => { - const { page, per_page: perPage } = request; - const _queryParams: Record = {}; - if (page != null) { - _queryParams["page"] = page.toString(); - } - if (perPage != null) { - _queryParams["per_page"] = perPage.toString(); - } - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: urlJoin( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "help_center/collections", - ), - method: "GET", - headers: { - Authorization: await this._getAuthorizationHeader(), - "X-Fern-Language": "JavaScript", - "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", - "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - queryParameters: _queryParams, - requestType: "json", - timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, - maxRetries: requestOptions?.maxRetries, - abortSignal: requestOptions?.abortSignal, - }); - if (_response.ok) { - return _response.body as Intercom.CollectionList; - } - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); - default: + const list = core.HttpResponsePromise.interceptFunction( + async ( + request: Intercom.helpCenters.ListCollectionsRequest, + ): Promise> => { + const { page, per_page: perPage } = request; + const _queryParams: Record = {}; + if (page != null) { + _queryParams["page"] = page.toString(); + } + if (perPage != null) { + _queryParams["per_page"] = perPage.toString(); + } + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "help_center/collections", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: + requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.CollectionList, rawResponse: _response.rawResponse }; + } + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + switch (_response.error.reason) { + case "non-json": throw new errors.IntercomError({ statusCode: _response.error.statusCode, - body: _response.error.body, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling GET /help_center/collections.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } - } - switch (_response.error.reason) { - case "non-json": - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.rawBody, - }); - case "timeout": - throw new errors.IntercomTimeoutError( - "Timeout exceeded when calling GET /help_center/collections.", - ); - case "unknown": - throw new errors.IntercomError({ - message: _response.error.errorMessage, - }); - } - }; + }, + ); let _offset = request?.page != null ? request?.page : 1; + const dataWithRawResponse = await list(request).withRawResponse(); return new core.Pageable({ - response: await list(request), + response: dataWithRawResponse.data, + rawResponse: dataWithRawResponse.rawResponse, hasNextPage: (response) => (response?.data ?? []).length > 0, getItems: (response) => response?.data ?? [], loadPage: (_response) => { @@ -186,10 +199,17 @@ export class Collections { * description: "Missing required parameter" * }) */ - public async create( + public create( request: Intercom.helpCenters.CreateCollectionRequest, requestOptions?: Collections.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); + } + + private async __create( + request: Intercom.helpCenters.CreateCollectionRequest, + requestOptions?: Collections.RequestOptions, + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -202,8 +222,8 @@ export class Collections { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -217,19 +237,23 @@ export class Collections { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Collection; + return { data: _response.body as Intercom.Collection, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.BadRequestError(_response.error.body as unknown); + throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -239,12 +263,14 @@ export class Collections { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /help_center/collections."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -263,10 +289,17 @@ export class Collections { * collection_id: "123" * }) */ - public async find( + public find( request: Intercom.helpCenters.FindCollectionRequest, requestOptions?: Collections.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); + } + + private async __find( + request: Intercom.helpCenters.FindCollectionRequest, + requestOptions?: Collections.RequestOptions, + ): Promise> { const { collection_id: collectionId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -280,8 +313,8 @@ export class Collections { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -294,19 +327,23 @@ export class Collections { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Collection; + return { data: _response.body as Intercom.Collection, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -316,6 +353,7 @@ export class Collections { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -324,6 +362,7 @@ export class Collections { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -343,10 +382,17 @@ export class Collections { * name: "Update collection name" * }) */ - public async update( + public update( request: Intercom.helpCenters.UpdateCollectionRequest, requestOptions?: Collections.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions)); + } + + private async __update( + request: Intercom.helpCenters.UpdateCollectionRequest, + requestOptions?: Collections.RequestOptions, + ): Promise> { const { collection_id: collectionId, ..._body } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -360,8 +406,8 @@ export class Collections { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -375,19 +421,23 @@ export class Collections { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Collection; + return { data: _response.body as Intercom.Collection, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -397,6 +447,7 @@ export class Collections { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -405,6 +456,7 @@ export class Collections { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -423,10 +475,17 @@ export class Collections { * collection_id: "123" * }) */ - public async delete( + public delete( request: Intercom.helpCenters.DeleteCollectionRequest, requestOptions?: Collections.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__delete(request, requestOptions)); + } + + private async __delete( + request: Intercom.helpCenters.DeleteCollectionRequest, + requestOptions?: Collections.RequestOptions, + ): Promise> { const { collection_id: collectionId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -440,8 +499,8 @@ export class Collections { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -454,19 +513,23 @@ export class Collections { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.DeletedCollectionObject; + return { data: _response.body as Intercom.DeletedCollectionObject, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -476,6 +539,7 @@ export class Collections { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -484,6 +548,7 @@ export class Collections { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } diff --git a/src/api/resources/index.ts b/src/api/resources/index.ts index 3e1d913c..7761ecb9 100644 --- a/src/api/resources/index.ts +++ b/src/api/resources/index.ts @@ -36,12 +36,12 @@ export * as dataEvents from "./dataEvents"; export * from "./dataEvents/types"; export * as news from "./news"; export * from "./news/types"; +export * as unstable from "./unstable"; export * as helpCenters from "./helpCenters"; export * as events from "./events"; export * as phoneCallRedirects from "./phoneCallRedirects"; export * as ticketTypes from "./ticketTypes"; export * as visitors from "./visitors"; -export * as customChannelEvents from "./customChannelEvents"; export * from "./admins/client/requests"; export * from "./articles/client/requests"; export * from "./helpCenters/client/requests"; diff --git a/src/api/resources/messages/client/Client.ts b/src/api/resources/messages/client/Client.ts index 97ff5961..9fd4d027 100644 --- a/src/api/resources/messages/client/Client.ts +++ b/src/api/resources/messages/client/Client.ts @@ -166,10 +166,17 @@ export class Messages { * create_conversation_without_contact_reply: true * }) */ - public async create( + public create( request: Intercom.CreateMessageRequest, requestOptions?: Messages.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); + } + + private async __create( + request: Intercom.CreateMessageRequest, + requestOptions?: Messages.RequestOptions, + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -182,8 +189,8 @@ export class Messages { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -197,23 +204,27 @@ export class Messages { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Message; + return { data: _response.body as Intercom.Message, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.BadRequestError(_response.error.body as unknown); + throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 403: - throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_); + throw new Intercom.ForbiddenError(_response.error.body as Intercom.Error_, _response.rawResponse); case 422: - throw new Intercom.UnprocessableEntityError(_response.error.body as unknown); + throw new Intercom.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -223,12 +234,14 @@ export class Messages { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /messages."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } diff --git a/src/api/resources/news/resources/feeds/client/Client.ts b/src/api/resources/news/resources/feeds/client/Client.ts index 35a6e147..7af908b2 100644 --- a/src/api/resources/news/resources/feeds/client/Client.ts +++ b/src/api/resources/news/resources/feeds/client/Client.ts @@ -85,10 +85,17 @@ export class Feeds { * newsfeed_id: "123" * }) */ - public async listItems( + public listItems( request: Intercom.news.ListNewsFeedItemsRequest, requestOptions?: Feeds.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listItems(request, requestOptions)); + } + + private async __listItems( + request: Intercom.news.ListNewsFeedItemsRequest, + requestOptions?: Feeds.RequestOptions, + ): Promise> { const { newsfeed_id: newsfeedId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -102,8 +109,8 @@ export class Feeds { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -116,17 +123,21 @@ export class Feeds { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.PaginatedNewsItemResponse; + return { data: _response.body as Intercom.PaginatedNewsItemResponse, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -136,6 +147,7 @@ export class Feeds { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -144,6 +156,7 @@ export class Feeds { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -158,7 +171,13 @@ export class Feeds { * @example * await client.news.feeds.list() */ - public async list(requestOptions?: Feeds.RequestOptions): Promise { + public list(requestOptions?: Feeds.RequestOptions): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__list(requestOptions)); + } + + private async __list( + requestOptions?: Feeds.RequestOptions, + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -171,8 +190,8 @@ export class Feeds { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -185,17 +204,21 @@ export class Feeds { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.PaginatedNewsfeedResponse; + return { data: _response.body as Intercom.PaginatedNewsfeedResponse, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -205,12 +228,14 @@ export class Feeds { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /news/newsfeeds."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -228,10 +253,17 @@ export class Feeds { * newsfeed_id: "123" * }) */ - public async find( + public find( + request: Intercom.news.FindNewsFeedRequest, + requestOptions?: Feeds.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); + } + + private async __find( request: Intercom.news.FindNewsFeedRequest, requestOptions?: Feeds.RequestOptions, - ): Promise { + ): Promise> { const { newsfeed_id: newsfeedId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -245,8 +277,8 @@ export class Feeds { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -259,17 +291,21 @@ export class Feeds { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Newsfeed; + return { data: _response.body as Intercom.Newsfeed, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -279,6 +315,7 @@ export class Feeds { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -287,6 +324,7 @@ export class Feeds { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } diff --git a/src/api/resources/news/resources/items/client/Client.ts b/src/api/resources/news/resources/items/client/Client.ts index 7321ae29..2dc9fa97 100644 --- a/src/api/resources/news/resources/items/client/Client.ts +++ b/src/api/resources/news/resources/items/client/Client.ts @@ -82,7 +82,13 @@ export class Items { * @example * await client.news.items.list() */ - public async list(requestOptions?: Items.RequestOptions): Promise { + public list(requestOptions?: Items.RequestOptions): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__list(requestOptions)); + } + + private async __list( + requestOptions?: Items.RequestOptions, + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -95,8 +101,8 @@ export class Items { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -109,17 +115,21 @@ export class Items { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.PaginatedNewsItemResponse; + return { data: _response.body as Intercom.PaginatedNewsItemResponse, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -129,12 +139,14 @@ export class Items { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /news/news_items."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -162,10 +174,17 @@ export class Items { * }] * }) */ - public async create( + public create( + request: Intercom.NewsItemRequest, + requestOptions?: Items.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); + } + + private async __create( request: Intercom.NewsItemRequest, requestOptions?: Items.RequestOptions, - ): Promise { + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -178,8 +197,8 @@ export class Items { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -193,17 +212,21 @@ export class Items { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.NewsItem; + return { data: _response.body as Intercom.NewsItem, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -213,12 +236,14 @@ export class Items { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /news/news_items."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -237,10 +262,17 @@ export class Items { * news_item_id: "123" * }) */ - public async find( + public find( request: Intercom.news.FindNewsItemRequest, requestOptions?: Items.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); + } + + private async __find( + request: Intercom.news.FindNewsItemRequest, + requestOptions?: Items.RequestOptions, + ): Promise> { const { news_item_id: newsItemId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -254,8 +286,8 @@ export class Items { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -268,19 +300,23 @@ export class Items { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.NewsItem; + return { data: _response.body as Intercom.NewsItem, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -290,6 +326,7 @@ export class Items { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -298,6 +335,7 @@ export class Items { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -331,10 +369,17 @@ export class Items { * } * }) */ - public async update( + public update( + request: Intercom.news.UpdateNewsItemRequest, + requestOptions?: Items.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions)); + } + + private async __update( request: Intercom.news.UpdateNewsItemRequest, requestOptions?: Items.RequestOptions, - ): Promise { + ): Promise> { const { news_item_id: newsItemId, body: _body } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -348,8 +393,8 @@ export class Items { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -363,19 +408,23 @@ export class Items { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.NewsItem; + return { data: _response.body as Intercom.NewsItem, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -385,6 +434,7 @@ export class Items { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -393,6 +443,7 @@ export class Items { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -411,10 +462,17 @@ export class Items { * news_item_id: "123" * }) */ - public async delete( + public delete( + request: Intercom.news.DeleteNewsItemRequest, + requestOptions?: Items.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__delete(request, requestOptions)); + } + + private async __delete( request: Intercom.news.DeleteNewsItemRequest, requestOptions?: Items.RequestOptions, - ): Promise { + ): Promise> { const { news_item_id: newsItemId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -428,8 +486,8 @@ export class Items { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -442,19 +500,23 @@ export class Items { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.DeletedObject; + return { data: _response.body as Intercom.DeletedObject, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -464,6 +526,7 @@ export class Items { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -472,6 +535,7 @@ export class Items { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } diff --git a/src/api/resources/notes/client/Client.ts b/src/api/resources/notes/client/Client.ts index a7307111..44866b02 100644 --- a/src/api/resources/notes/client/Client.ts +++ b/src/api/resources/notes/client/Client.ts @@ -92,74 +92,82 @@ export class Notes { request: Intercom.ListContactNotesRequest, requestOptions?: Notes.RequestOptions, ): Promise> { - const list = async (request: Intercom.ListContactNotesRequest): Promise => { - const { contact_id: contactId, page, per_page: perPage } = request; - const _queryParams: Record = {}; - if (page != null) { - _queryParams["page"] = page.toString(); - } - if (perPage != null) { - _queryParams["per_page"] = perPage.toString(); - } - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: urlJoin( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - `contacts/${encodeURIComponent(contactId)}/notes`, - ), - method: "GET", - headers: { - Authorization: await this._getAuthorizationHeader(), - "X-Fern-Language": "JavaScript", - "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", - "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - queryParameters: _queryParams, - requestType: "json", - timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, - maxRetries: requestOptions?.maxRetries, - abortSignal: requestOptions?.abortSignal, - }); - if (_response.ok) { - return _response.body as Intercom.NoteList; - } - if (_response.error.reason === "status-code") { - switch (_response.error.statusCode) { - case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); - default: + const list = core.HttpResponsePromise.interceptFunction( + async (request: Intercom.ListContactNotesRequest): Promise> => { + const { contact_id: contactId, page, per_page: perPage } = request; + const _queryParams: Record = {}; + if (page != null) { + _queryParams["page"] = page.toString(); + } + if (perPage != null) { + _queryParams["per_page"] = perPage.toString(); + } + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${encodeURIComponent(contactId)}/notes`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: + requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.NoteList, rawResponse: _response.rawResponse }; + } + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + switch (_response.error.reason) { + case "non-json": throw new errors.IntercomError({ statusCode: _response.error.statusCode, - body: _response.error.body, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling GET /contacts/{contact_id}/notes.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } - } - switch (_response.error.reason) { - case "non-json": - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.rawBody, - }); - case "timeout": - throw new errors.IntercomTimeoutError( - "Timeout exceeded when calling GET /contacts/{contact_id}/notes.", - ); - case "unknown": - throw new errors.IntercomError({ - message: _response.error.errorMessage, - }); - } - }; + }, + ); let _offset = request?.page != null ? request?.page : 1; + const dataWithRawResponse = await list(request).withRawResponse(); return new core.Pageable({ - response: await list(request), + response: dataWithRawResponse.data, + rawResponse: dataWithRawResponse.rawResponse, hasNextPage: (response) => (response?.data ?? []).length > 0, getItems: (response) => response?.data ?? [], loadPage: (_response) => { @@ -184,10 +192,17 @@ export class Notes { * admin_id: "123" * }) */ - public async create( + public create( + request: Intercom.CreateContactNoteRequest, + requestOptions?: Notes.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); + } + + private async __create( request: Intercom.CreateContactNoteRequest, requestOptions?: Notes.RequestOptions, - ): Promise { + ): Promise> { const { contact_id: contactId, ..._body } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -201,8 +216,8 @@ export class Notes { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -216,17 +231,18 @@ export class Notes { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Note; + return { data: _response.body as Intercom.Note, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -236,6 +252,7 @@ export class Notes { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -244,6 +261,7 @@ export class Notes { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -262,10 +280,17 @@ export class Notes { * note_id: "1" * }) */ - public async find( + public find( request: Intercom.FindNoteRequest, requestOptions?: Notes.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); + } + + private async __find( + request: Intercom.FindNoteRequest, + requestOptions?: Notes.RequestOptions, + ): Promise> { const { note_id: noteId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -279,8 +304,8 @@ export class Notes { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -293,19 +318,23 @@ export class Notes { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Note; + return { data: _response.body as Intercom.Note, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -315,12 +344,14 @@ export class Notes { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /notes/{note_id}."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } diff --git a/src/api/resources/phoneCallRedirects/client/Client.ts b/src/api/resources/phoneCallRedirects/client/Client.ts index c9b53a74..2c057d93 100644 --- a/src/api/resources/phoneCallRedirects/client/Client.ts +++ b/src/api/resources/phoneCallRedirects/client/Client.ts @@ -103,10 +103,17 @@ export class PhoneCallRedirects { * } * }) */ - public async create( + public create( request: Intercom.CreatePhoneCallRedirectRequest, requestOptions?: PhoneCallRedirects.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); + } + + private async __create( + request: Intercom.CreatePhoneCallRedirectRequest, + requestOptions?: PhoneCallRedirects.RequestOptions, + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -119,8 +126,8 @@ export class PhoneCallRedirects { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -134,21 +141,25 @@ export class PhoneCallRedirects { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.PhoneSwitch; + return { data: _response.body as Intercom.PhoneSwitch, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.BadRequestError(_response.error.body as unknown); + throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 422: - throw new Intercom.UnprocessableEntityError(_response.error.body as unknown); + throw new Intercom.UnprocessableEntityError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -158,12 +169,14 @@ export class PhoneCallRedirects { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /phone_call_redirects."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } diff --git a/src/api/resources/segments/client/Client.ts b/src/api/resources/segments/client/Client.ts index cc2d5ea6..738a10b7 100644 --- a/src/api/resources/segments/client/Client.ts +++ b/src/api/resources/segments/client/Client.ts @@ -86,10 +86,17 @@ export class Segments { * @example * await client.segments.list() */ - public async list( + public list( request: Intercom.ListSegmentsRequest = {}, requestOptions?: Segments.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__list(request, requestOptions)); + } + + private async __list( + request: Intercom.ListSegmentsRequest = {}, + requestOptions?: Segments.RequestOptions, + ): Promise> { const { include_count: includeCount } = request; const _queryParams: Record = {}; if (includeCount != null) { @@ -108,8 +115,8 @@ export class Segments { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -123,17 +130,21 @@ export class Segments { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.SegmentList; + return { data: _response.body as Intercom.SegmentList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -143,12 +154,14 @@ export class Segments { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /segments."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -167,10 +180,17 @@ export class Segments { * segment_id: "123" * }) */ - public async find( + public find( + request: Intercom.FindSegmentRequest, + requestOptions?: Segments.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); + } + + private async __find( request: Intercom.FindSegmentRequest, requestOptions?: Segments.RequestOptions, - ): Promise { + ): Promise> { const { segment_id: segmentId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -184,8 +204,8 @@ export class Segments { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -198,19 +218,23 @@ export class Segments { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Segment; + return { data: _response.body as Intercom.Segment, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -220,12 +244,14 @@ export class Segments { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /segments/{segment_id}."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } diff --git a/src/api/resources/subscriptionTypes/client/Client.ts b/src/api/resources/subscriptionTypes/client/Client.ts index b07d4e1e..abfe8aa7 100644 --- a/src/api/resources/subscriptionTypes/client/Client.ts +++ b/src/api/resources/subscriptionTypes/client/Client.ts @@ -85,7 +85,15 @@ export class SubscriptionTypes { * @example * await client.subscriptionTypes.list() */ - public async list(requestOptions?: SubscriptionTypes.RequestOptions): Promise { + public list( + requestOptions?: SubscriptionTypes.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__list(requestOptions)); + } + + private async __list( + requestOptions?: SubscriptionTypes.RequestOptions, + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -98,8 +106,8 @@ export class SubscriptionTypes { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -112,17 +120,21 @@ export class SubscriptionTypes { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.SubscriptionTypeList; + return { data: _response.body as Intercom.SubscriptionTypeList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -132,12 +144,14 @@ export class SubscriptionTypes { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /subscription_types."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } diff --git a/src/api/resources/tags/client/Client.ts b/src/api/resources/tags/client/Client.ts index 8aee0957..db51c738 100644 --- a/src/api/resources/tags/client/Client.ts +++ b/src/api/resources/tags/client/Client.ts @@ -96,10 +96,17 @@ export class Tags { * id: "123" * }) */ - public async tagContact( + public tagContact( request: Intercom.TagContactRequest, requestOptions?: Tags.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__tagContact(request, requestOptions)); + } + + private async __tagContact( + request: Intercom.TagContactRequest, + requestOptions?: Tags.RequestOptions, + ): Promise> { const { contact_id: contactId, ..._body } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -113,8 +120,8 @@ export class Tags { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -128,19 +135,23 @@ export class Tags { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Tag; + return { data: _response.body as Intercom.Tag, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -150,6 +161,7 @@ export class Tags { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -158,6 +170,7 @@ export class Tags { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -177,10 +190,17 @@ export class Tags { * tag_id: "7522907" * }) */ - public async untagContact( + public untagContact( + request: Intercom.UntagContactRequest, + requestOptions?: Tags.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__untagContact(request, requestOptions)); + } + + private async __untagContact( request: Intercom.UntagContactRequest, requestOptions?: Tags.RequestOptions, - ): Promise { + ): Promise> { const { contact_id: contactId, tag_id: tagId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -194,8 +214,8 @@ export class Tags { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -208,19 +228,23 @@ export class Tags { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Tag; + return { data: _response.body as Intercom.Tag, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -230,6 +254,7 @@ export class Tags { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -238,6 +263,7 @@ export class Tags { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -258,10 +284,17 @@ export class Tags { * admin_id: "780" * }) */ - public async tagConversation( + public tagConversation( request: Intercom.TagConversationRequest, requestOptions?: Tags.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__tagConversation(request, requestOptions)); + } + + private async __tagConversation( + request: Intercom.TagConversationRequest, + requestOptions?: Tags.RequestOptions, + ): Promise> { const { conversation_id: conversationId, ..._body } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -275,8 +308,8 @@ export class Tags { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -290,19 +323,23 @@ export class Tags { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Tag; + return { data: _response.body as Intercom.Tag, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -312,6 +349,7 @@ export class Tags { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -320,6 +358,7 @@ export class Tags { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -340,10 +379,17 @@ export class Tags { * admin_id: "123" * }) */ - public async untagConversation( + public untagConversation( request: Intercom.UntagConversationRequest, requestOptions?: Tags.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__untagConversation(request, requestOptions)); + } + + private async __untagConversation( + request: Intercom.UntagConversationRequest, + requestOptions?: Tags.RequestOptions, + ): Promise> { const { conversation_id: conversationId, tag_id: tagId, ..._body } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -357,8 +403,8 @@ export class Tags { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -372,19 +418,23 @@ export class Tags { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Tag; + return { data: _response.body as Intercom.Tag, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -394,6 +444,7 @@ export class Tags { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -402,6 +453,7 @@ export class Tags { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -416,7 +468,11 @@ export class Tags { * @example * await client.tags.list() */ - public async list(requestOptions?: Tags.RequestOptions): Promise { + public list(requestOptions?: Tags.RequestOptions): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__list(requestOptions)); + } + + private async __list(requestOptions?: Tags.RequestOptions): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -429,8 +485,8 @@ export class Tags { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -443,17 +499,21 @@ export class Tags { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.TagList; + return { data: _response.body as Intercom.TagList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -463,12 +523,14 @@ export class Tags { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /tags."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -521,10 +583,17 @@ export class Tags { * }] * }) */ - public async create( + public create( + request: Intercom.TagsCreateRequestBody, + requestOptions?: Tags.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); + } + + private async __create( request: Intercom.TagsCreateRequestBody, requestOptions?: Tags.RequestOptions, - ): Promise { + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -537,8 +606,8 @@ export class Tags { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -552,21 +621,25 @@ export class Tags { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Tag; + return { data: _response.body as Intercom.Tag, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.BadRequestError(_response.error.body as unknown); + throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -576,12 +649,14 @@ export class Tags { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /tags."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -601,7 +676,17 @@ export class Tags { * tag_id: "123" * }) */ - public async find(request: Intercom.FindTagRequest, requestOptions?: Tags.RequestOptions): Promise { + public find( + request: Intercom.FindTagRequest, + requestOptions?: Tags.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); + } + + private async __find( + request: Intercom.FindTagRequest, + requestOptions?: Tags.RequestOptions, + ): Promise> { const { tag_id: tagId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -615,8 +700,8 @@ export class Tags { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -629,19 +714,23 @@ export class Tags { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Tag; + return { data: _response.body as Intercom.Tag, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -651,12 +740,14 @@ export class Tags { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /tags/{tag_id}."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -676,7 +767,17 @@ export class Tags { * tag_id: "123" * }) */ - public async delete(request: Intercom.DeleteTagRequest, requestOptions?: Tags.RequestOptions): Promise { + public delete( + request: Intercom.DeleteTagRequest, + requestOptions?: Tags.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__delete(request, requestOptions)); + } + + private async __delete( + request: Intercom.DeleteTagRequest, + requestOptions?: Tags.RequestOptions, + ): Promise> { const { tag_id: tagId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -690,8 +791,8 @@ export class Tags { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -704,21 +805,25 @@ export class Tags { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return; + return { data: undefined, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.BadRequestError(_response.error.body as unknown); + throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -728,12 +833,14 @@ export class Tags { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling DELETE /tags/{tag_id}."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -754,10 +861,17 @@ export class Tags { * admin_id: "780" * }) */ - public async tagTicket( + public tagTicket( + request: Intercom.TagTicketRequest, + requestOptions?: Tags.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__tagTicket(request, requestOptions)); + } + + private async __tagTicket( request: Intercom.TagTicketRequest, requestOptions?: Tags.RequestOptions, - ): Promise { + ): Promise> { const { ticket_id: ticketId, ..._body } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -771,8 +885,8 @@ export class Tags { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -786,19 +900,23 @@ export class Tags { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Tag; + return { data: _response.body as Intercom.Tag, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -808,12 +926,14 @@ export class Tags { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /tickets/{ticket_id}/tags."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -834,10 +954,17 @@ export class Tags { * admin_id: "123" * }) */ - public async untagTicket( + public untagTicket( + request: Intercom.UntagTicketRequest, + requestOptions?: Tags.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__untagTicket(request, requestOptions)); + } + + private async __untagTicket( request: Intercom.UntagTicketRequest, requestOptions?: Tags.RequestOptions, - ): Promise { + ): Promise> { const { ticket_id: ticketId, tag_id: tagId, ..._body } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -851,8 +978,8 @@ export class Tags { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -866,19 +993,23 @@ export class Tags { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Tag; + return { data: _response.body as Intercom.Tag, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -888,6 +1019,7 @@ export class Tags { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -896,6 +1028,7 @@ export class Tags { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } diff --git a/src/api/resources/teams/client/Client.ts b/src/api/resources/teams/client/Client.ts index 33d2fe91..2d523ac4 100644 --- a/src/api/resources/teams/client/Client.ts +++ b/src/api/resources/teams/client/Client.ts @@ -85,7 +85,11 @@ export class Teams { * @example * await client.teams.list() */ - public async list(requestOptions?: Teams.RequestOptions): Promise { + public list(requestOptions?: Teams.RequestOptions): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__list(requestOptions)); + } + + private async __list(requestOptions?: Teams.RequestOptions): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -98,8 +102,8 @@ export class Teams { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -112,17 +116,21 @@ export class Teams { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.TeamList; + return { data: _response.body as Intercom.TeamList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -132,12 +140,14 @@ export class Teams { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /teams."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -156,10 +166,17 @@ export class Teams { * team_id: "123" * }) */ - public async find( + public find( + request: Intercom.FindTeamRequest, + requestOptions?: Teams.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); + } + + private async __find( request: Intercom.FindTeamRequest, requestOptions?: Teams.RequestOptions, - ): Promise { + ): Promise> { const { team_id: teamId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -173,8 +190,8 @@ export class Teams { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -187,19 +204,23 @@ export class Teams { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Team; + return { data: _response.body as Intercom.Team, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -209,12 +230,14 @@ export class Teams { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /teams/{team_id}."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } diff --git a/src/api/resources/ticketTypes/client/Client.ts b/src/api/resources/ticketTypes/client/Client.ts index 102a5367..f4909e81 100644 --- a/src/api/resources/ticketTypes/client/Client.ts +++ b/src/api/resources/ticketTypes/client/Client.ts @@ -92,7 +92,13 @@ export class TicketTypes { * @example * await client.ticketTypes.list() */ - public async list(requestOptions?: TicketTypes.RequestOptions): Promise { + public list(requestOptions?: TicketTypes.RequestOptions): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__list(requestOptions)); + } + + private async __list( + requestOptions?: TicketTypes.RequestOptions, + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -105,8 +111,8 @@ export class TicketTypes { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -119,17 +125,21 @@ export class TicketTypes { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.TicketTypeList; + return { data: _response.body as Intercom.TicketTypeList, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -139,12 +149,14 @@ export class TicketTypes { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /ticket_types."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -169,10 +181,17 @@ export class TicketTypes { * icon: "\uD83C\uDF9F\uFE0F" * }) */ - public async create( + public create( + request: Intercom.CreateTicketTypeRequest, + requestOptions?: TicketTypes.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); + } + + private async __create( request: Intercom.CreateTicketTypeRequest, requestOptions?: TicketTypes.RequestOptions, - ): Promise { + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -185,8 +204,8 @@ export class TicketTypes { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -200,17 +219,21 @@ export class TicketTypes { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.TicketType; + return { data: _response.body as Intercom.TicketType, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -220,12 +243,14 @@ export class TicketTypes { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /ticket_types."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -243,10 +268,17 @@ export class TicketTypes { * ticket_type_id: "ticket_type_id" * }) */ - public async get( + public get( request: Intercom.FindTicketTypeRequest, requestOptions?: TicketTypes.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__get(request, requestOptions)); + } + + private async __get( + request: Intercom.FindTicketTypeRequest, + requestOptions?: TicketTypes.RequestOptions, + ): Promise> { const { ticket_type_id: ticketTypeId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -260,8 +292,8 @@ export class TicketTypes { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -274,17 +306,21 @@ export class TicketTypes { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.TicketType; + return { data: _response.body as Intercom.TicketType, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -294,6 +330,7 @@ export class TicketTypes { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -302,6 +339,7 @@ export class TicketTypes { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -325,10 +363,17 @@ export class TicketTypes { * name: "Bug Report 2" * }) */ - public async update( + public update( + request: Intercom.UpdateTicketTypeRequest, + requestOptions?: TicketTypes.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions)); + } + + private async __update( request: Intercom.UpdateTicketTypeRequest, requestOptions?: TicketTypes.RequestOptions, - ): Promise { + ): Promise> { const { ticket_type_id: ticketTypeId, ..._body } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -342,8 +387,8 @@ export class TicketTypes { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -357,17 +402,21 @@ export class TicketTypes { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.TicketType; + return { data: _response.body as Intercom.TicketType, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -377,6 +426,7 @@ export class TicketTypes { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -385,6 +435,7 @@ export class TicketTypes { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } diff --git a/src/api/resources/ticketTypes/resources/attributes/client/Client.ts b/src/api/resources/ticketTypes/resources/attributes/client/Client.ts index d95d26c5..32ac1e89 100644 --- a/src/api/resources/ticketTypes/resources/attributes/client/Client.ts +++ b/src/api/resources/ticketTypes/resources/attributes/client/Client.ts @@ -89,10 +89,17 @@ export class Attributes { * required_to_create: false * }) */ - public async create( + public create( request: Intercom.ticketTypes.CreateTicketTypeAttributeRequest, requestOptions?: Attributes.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); + } + + private async __create( + request: Intercom.ticketTypes.CreateTicketTypeAttributeRequest, + requestOptions?: Attributes.RequestOptions, + ): Promise> { const { ticket_type_id: ticketTypeId, ..._body } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -106,8 +113,8 @@ export class Attributes { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -121,17 +128,21 @@ export class Attributes { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.TicketTypeAttribute; + return { data: _response.body as Intercom.TicketTypeAttribute, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -141,6 +152,7 @@ export class Attributes { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -149,6 +161,7 @@ export class Attributes { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -168,10 +181,17 @@ export class Attributes { * description: "New Attribute Description" * }) */ - public async update( + public update( + request: Intercom.ticketTypes.UpdateTicketTypeAttributeRequest, + requestOptions?: Attributes.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions)); + } + + private async __update( request: Intercom.ticketTypes.UpdateTicketTypeAttributeRequest, requestOptions?: Attributes.RequestOptions, - ): Promise { + ): Promise> { const { ticket_type_id: ticketTypeId, attribute_id: attributeId, ..._body } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -185,8 +205,8 @@ export class Attributes { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -200,17 +220,21 @@ export class Attributes { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.TicketTypeAttribute; + return { data: _response.body as Intercom.TicketTypeAttribute, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -220,6 +244,7 @@ export class Attributes { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( @@ -228,6 +253,7 @@ export class Attributes { case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } diff --git a/src/api/resources/tickets/client/Client.ts b/src/api/resources/tickets/client/Client.ts index 2fc45671..a47554f7 100644 --- a/src/api/resources/tickets/client/Client.ts +++ b/src/api/resources/tickets/client/Client.ts @@ -135,10 +135,17 @@ export class Tickets { * } * }) */ - public async reply( + public reply( request: Intercom.ReplyToTicketRequest, requestOptions?: Tickets.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__reply(request, requestOptions)); + } + + private async __reply( + request: Intercom.ReplyToTicketRequest, + requestOptions?: Tickets.RequestOptions, + ): Promise> { const { ticket_id: ticketId, body: _body } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -152,8 +159,8 @@ export class Tickets { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -167,21 +174,25 @@ export class Tickets { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.TicketReply; + return { data: _response.body as Intercom.TicketReply, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: - throw new Intercom.BadRequestError(_response.error.body as unknown); + throw new Intercom.BadRequestError(_response.error.body as unknown, _response.rawResponse); case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -191,12 +202,14 @@ export class Tickets { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /tickets/{ticket_id}/reply."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -221,10 +234,17 @@ export class Tickets { * } * }) */ - public async create( + public create( request: Intercom.CreateTicketRequest, requestOptions?: Tickets.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); + } + + private async __create( + request: Intercom.CreateTicketRequest, + requestOptions?: Tickets.RequestOptions, + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -237,8 +257,8 @@ export class Tickets { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -252,17 +272,21 @@ export class Tickets { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Ticket; + return { data: _response.body as Intercom.Ticket, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -272,12 +296,14 @@ export class Tickets { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /tickets."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -295,10 +321,17 @@ export class Tickets { * ticket_id: "ticket_id" * }) */ - public async get( + public get( + request: Intercom.FindTicketRequest, + requestOptions?: Tickets.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__get(request, requestOptions)); + } + + private async __get( request: Intercom.FindTicketRequest, requestOptions?: Tickets.RequestOptions, - ): Promise { + ): Promise> { const { ticket_id: ticketId } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -312,8 +345,8 @@ export class Tickets { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -326,17 +359,21 @@ export class Tickets { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Ticket; + return { data: _response.body as Intercom.Ticket, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -346,12 +383,14 @@ export class Tickets { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /tickets/{ticket_id}."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -409,10 +448,17 @@ export class Tickets { * } * }) */ - public async update( + public update( + request: Intercom.UpdateTicketRequest, + requestOptions?: Tickets.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions)); + } + + private async __update( request: Intercom.UpdateTicketRequest, requestOptions?: Tickets.RequestOptions, - ): Promise { + ): Promise> { const { ticket_id: ticketId, ..._body } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( @@ -426,8 +472,8 @@ export class Tickets { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -441,19 +487,23 @@ export class Tickets { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Ticket; + return { data: _response.body as Intercom.Ticket, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -463,12 +513,14 @@ export class Tickets { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling PUT /tickets/{ticket_id}."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -558,58 +610,66 @@ export class Tickets { request: Intercom.SearchRequest, requestOptions?: Tickets.RequestOptions, ): Promise> { - const list = async (request: Intercom.SearchRequest): Promise => { - const _response = await (this._options.fetcher ?? core.fetcher)({ - url: urlJoin( - (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.IntercomEnvironment.UsProduction, - "tickets/search", - ), - method: "POST", - headers: { - Authorization: await this._getAuthorizationHeader(), - "X-Fern-Language": "JavaScript", - "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", - "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", - "X-Fern-Runtime": core.RUNTIME.type, - "X-Fern-Runtime-Version": core.RUNTIME.version, - ...requestOptions?.headers, - }, - contentType: "application/json", - requestType: "json", - body: request, - timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, - maxRetries: requestOptions?.maxRetries, - abortSignal: requestOptions?.abortSignal, - }); - if (_response.ok) { - return _response.body as Intercom.TicketList; - } - if (_response.error.reason === "status-code") { - throw new errors.IntercomError({ - statusCode: _response.error.statusCode, - body: _response.error.body, + const list = core.HttpResponsePromise.interceptFunction( + async (request: Intercom.SearchRequest): Promise> => { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "tickets/search", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: + requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, }); - } - switch (_response.error.reason) { - case "non-json": + if (_response.ok) { + return { data: _response.body as Intercom.TicketList, rawResponse: _response.rawResponse }; + } + if (_response.error.reason === "status-code") { throw new errors.IntercomError({ statusCode: _response.error.statusCode, - body: _response.error.rawBody, - }); - case "timeout": - throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /tickets/search."); - case "unknown": - throw new errors.IntercomError({ - message: _response.error.errorMessage, + body: _response.error.body, + rawResponse: _response.rawResponse, }); - } - }; + } + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /tickets/search."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + }, + ); + const dataWithRawResponse = await list(request).withRawResponse(); return new core.Pageable({ - response: await list(request), + response: dataWithRawResponse.data, + rawResponse: dataWithRawResponse.rawResponse, hasNextPage: (response) => response?.pages?.next?.starting_after != null, getItems: (response) => response?.tickets ?? [], loadPage: (response) => { diff --git a/src/api/resources/tickets/client/requests/index.ts b/src/api/resources/tickets/client/requests/index.ts index 083c02e9..23ce5a7f 100644 --- a/src/api/resources/tickets/client/requests/index.ts +++ b/src/api/resources/tickets/client/requests/index.ts @@ -1,4 +1,3 @@ export { type ReplyToTicketRequest } from "./ReplyToTicketRequest"; -export { type CreateTicketRequest } from "./CreateTicketRequest"; export { type FindTicketRequest } from "./FindTicketRequest"; export { type UpdateTicketRequest } from "./UpdateTicketRequest"; diff --git a/src/api/resources/unstable/client/Client.ts b/src/api/resources/unstable/client/Client.ts new file mode 100644 index 00000000..d05f4c7f --- /dev/null +++ b/src/api/resources/unstable/client/Client.ts @@ -0,0 +1,209 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import { Admins } from "../resources/admins/client/Client"; +import { AiContent } from "../resources/aiContent/client/Client"; +import { Articles } from "../resources/articles/client/Client"; +import { AwayStatusReasons } from "../resources/awayStatusReasons/client/Client"; +import { Export } from "../resources/export/client/Client"; +import { HelpCenter } from "../resources/helpCenter/client/Client"; +import { Companies } from "../resources/companies/client/Client"; +import { Contacts } from "../resources/contacts/client/Client"; +import { Notes } from "../resources/notes/client/Client"; +import { SubscriptionTypes } from "../resources/subscriptionTypes/client/Client"; +import { Tags } from "../resources/tags/client/Client"; +import { Conversations } from "../resources/conversations/client/Client"; +import { CustomChannelEvents } from "../resources/customChannelEvents/client/Client"; +import { CustomObjectInstances } from "../resources/customObjectInstances/client/Client"; +import { DataAttributes } from "../resources/dataAttributes/client/Client"; +import { DataEvents } from "../resources/dataEvents/client/Client"; +import { DataExport } from "../resources/dataExport/client/Client"; +import { Jobs } from "../resources/jobs/client/Client"; +import { Messages } from "../resources/messages/client/Client"; +import { News } from "../resources/news/client/Client"; +import { Segments } from "../resources/segments/client/Client"; +import { Switch } from "../resources/switch/client/Client"; +import { Teams } from "../resources/teams/client/Client"; +import { TicketStates } from "../resources/ticketStates/client/Client"; +import { TicketTypeAttributes } from "../resources/ticketTypeAttributes/client/Client"; +import { TicketTypes } from "../resources/ticketTypes/client/Client"; +import { Tickets } from "../resources/tickets/client/Client"; +import { Visitors } from "../resources/visitors/client/Client"; + +export declare namespace Unstable { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } +} + +export class Unstable { + protected _admins: Admins | undefined; + protected _aiContent: AiContent | undefined; + protected _articles: Articles | undefined; + protected _awayStatusReasons: AwayStatusReasons | undefined; + protected _export: Export | undefined; + protected _helpCenter: HelpCenter | undefined; + protected _companies: Companies | undefined; + protected _contacts: Contacts | undefined; + protected _notes: Notes | undefined; + protected _subscriptionTypes: SubscriptionTypes | undefined; + protected _tags: Tags | undefined; + protected _conversations: Conversations | undefined; + protected _customChannelEvents: CustomChannelEvents | undefined; + protected _customObjectInstances: CustomObjectInstances | undefined; + protected _dataAttributes: DataAttributes | undefined; + protected _dataEvents: DataEvents | undefined; + protected _dataExport: DataExport | undefined; + protected _jobs: Jobs | undefined; + protected _messages: Messages | undefined; + protected _news: News | undefined; + protected _segments: Segments | undefined; + protected _switch: Switch | undefined; + protected _teams: Teams | undefined; + protected _ticketStates: TicketStates | undefined; + protected _ticketTypeAttributes: TicketTypeAttributes | undefined; + protected _ticketTypes: TicketTypes | undefined; + protected _tickets: Tickets | undefined; + protected _visitors: Visitors | undefined; + + constructor(protected readonly _options: Unstable.Options = {}) {} + + public get admins(): Admins { + return (this._admins ??= new Admins(this._options)); + } + + public get aiContent(): AiContent { + return (this._aiContent ??= new AiContent(this._options)); + } + + public get articles(): Articles { + return (this._articles ??= new Articles(this._options)); + } + + public get awayStatusReasons(): AwayStatusReasons { + return (this._awayStatusReasons ??= new AwayStatusReasons(this._options)); + } + + public get export(): Export { + return (this._export ??= new Export(this._options)); + } + + public get helpCenter(): HelpCenter { + return (this._helpCenter ??= new HelpCenter(this._options)); + } + + public get companies(): Companies { + return (this._companies ??= new Companies(this._options)); + } + + public get contacts(): Contacts { + return (this._contacts ??= new Contacts(this._options)); + } + + public get notes(): Notes { + return (this._notes ??= new Notes(this._options)); + } + + public get subscriptionTypes(): SubscriptionTypes { + return (this._subscriptionTypes ??= new SubscriptionTypes(this._options)); + } + + public get tags(): Tags { + return (this._tags ??= new Tags(this._options)); + } + + public get conversations(): Conversations { + return (this._conversations ??= new Conversations(this._options)); + } + + public get customChannelEvents(): CustomChannelEvents { + return (this._customChannelEvents ??= new CustomChannelEvents(this._options)); + } + + public get customObjectInstances(): CustomObjectInstances { + return (this._customObjectInstances ??= new CustomObjectInstances(this._options)); + } + + public get dataAttributes(): DataAttributes { + return (this._dataAttributes ??= new DataAttributes(this._options)); + } + + public get dataEvents(): DataEvents { + return (this._dataEvents ??= new DataEvents(this._options)); + } + + public get dataExport(): DataExport { + return (this._dataExport ??= new DataExport(this._options)); + } + + public get jobs(): Jobs { + return (this._jobs ??= new Jobs(this._options)); + } + + public get messages(): Messages { + return (this._messages ??= new Messages(this._options)); + } + + public get news(): News { + return (this._news ??= new News(this._options)); + } + + public get segments(): Segments { + return (this._segments ??= new Segments(this._options)); + } + + public get switch(): Switch { + return (this._switch ??= new Switch(this._options)); + } + + public get teams(): Teams { + return (this._teams ??= new Teams(this._options)); + } + + public get ticketStates(): TicketStates { + return (this._ticketStates ??= new TicketStates(this._options)); + } + + public get ticketTypeAttributes(): TicketTypeAttributes { + return (this._ticketTypeAttributes ??= new TicketTypeAttributes(this._options)); + } + + public get ticketTypes(): TicketTypes { + return (this._ticketTypes ??= new TicketTypes(this._options)); + } + + public get tickets(): Tickets { + return (this._tickets ??= new Tickets(this._options)); + } + + public get visitors(): Visitors { + return (this._visitors ??= new Visitors(this._options)); + } +} diff --git a/src/api/resources/customChannelEvents/client/index.ts b/src/api/resources/unstable/client/index.ts similarity index 100% rename from src/api/resources/customChannelEvents/client/index.ts rename to src/api/resources/unstable/client/index.ts diff --git a/src/api/resources/unstable/errors/BadRequestError.ts b/src/api/resources/unstable/errors/BadRequestError.ts new file mode 100644 index 00000000..d7e71d09 --- /dev/null +++ b/src/api/resources/unstable/errors/BadRequestError.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as errors from "../../../../errors/index"; +import * as core from "../../../../core"; + +export class BadRequestError extends errors.IntercomError { + constructor(body?: unknown, rawResponse?: core.RawResponse) { + super({ + message: "BadRequestError", + statusCode: 400, + body: body, + rawResponse: rawResponse, + }); + Object.setPrototypeOf(this, BadRequestError.prototype); + } +} diff --git a/src/api/resources/unstable/errors/ForbiddenError.ts b/src/api/resources/unstable/errors/ForbiddenError.ts new file mode 100644 index 00000000..c98ade42 --- /dev/null +++ b/src/api/resources/unstable/errors/ForbiddenError.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as errors from "../../../../errors/index"; +import * as Intercom from "../../../index"; +import * as core from "../../../../core"; + +export class ForbiddenError extends errors.IntercomError { + constructor(body: Intercom.unstable.Error_, rawResponse?: core.RawResponse) { + super({ + message: "ForbiddenError", + statusCode: 403, + body: body, + rawResponse: rawResponse, + }); + Object.setPrototypeOf(this, ForbiddenError.prototype); + } +} diff --git a/src/api/resources/unstable/errors/InternalServerError.ts b/src/api/resources/unstable/errors/InternalServerError.ts new file mode 100644 index 00000000..6e6ad916 --- /dev/null +++ b/src/api/resources/unstable/errors/InternalServerError.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as errors from "../../../../errors/index"; +import * as Intercom from "../../../index"; +import * as core from "../../../../core"; + +export class InternalServerError extends errors.IntercomError { + constructor(body: Intercom.unstable.Error_, rawResponse?: core.RawResponse) { + super({ + message: "InternalServerError", + statusCode: 500, + body: body, + rawResponse: rawResponse, + }); + Object.setPrototypeOf(this, InternalServerError.prototype); + } +} diff --git a/src/api/resources/unstable/errors/NotFoundError.ts b/src/api/resources/unstable/errors/NotFoundError.ts new file mode 100644 index 00000000..323b5b44 --- /dev/null +++ b/src/api/resources/unstable/errors/NotFoundError.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as errors from "../../../../errors/index"; +import * as core from "../../../../core"; + +export class NotFoundError extends errors.IntercomError { + constructor(body?: unknown, rawResponse?: core.RawResponse) { + super({ + message: "NotFoundError", + statusCode: 404, + body: body, + rawResponse: rawResponse, + }); + Object.setPrototypeOf(this, NotFoundError.prototype); + } +} diff --git a/src/api/resources/unstable/errors/TooManyRequestsError.ts b/src/api/resources/unstable/errors/TooManyRequestsError.ts new file mode 100644 index 00000000..e9ff4d56 --- /dev/null +++ b/src/api/resources/unstable/errors/TooManyRequestsError.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as errors from "../../../../errors/index"; +import * as Intercom from "../../../index"; +import * as core from "../../../../core"; + +export class TooManyRequestsError extends errors.IntercomError { + constructor(body: Intercom.unstable.Error_, rawResponse?: core.RawResponse) { + super({ + message: "TooManyRequestsError", + statusCode: 429, + body: body, + rawResponse: rawResponse, + }); + Object.setPrototypeOf(this, TooManyRequestsError.prototype); + } +} diff --git a/src/api/resources/unstable/errors/UnauthorizedError.ts b/src/api/resources/unstable/errors/UnauthorizedError.ts new file mode 100644 index 00000000..33fb0bce --- /dev/null +++ b/src/api/resources/unstable/errors/UnauthorizedError.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as errors from "../../../../errors/index"; +import * as Intercom from "../../../index"; +import * as core from "../../../../core"; + +export class UnauthorizedError extends errors.IntercomError { + constructor(body: Intercom.unstable.Error_, rawResponse?: core.RawResponse) { + super({ + message: "UnauthorizedError", + statusCode: 401, + body: body, + rawResponse: rawResponse, + }); + Object.setPrototypeOf(this, UnauthorizedError.prototype); + } +} diff --git a/src/api/resources/unstable/errors/UnprocessableEntityError.ts b/src/api/resources/unstable/errors/UnprocessableEntityError.ts new file mode 100644 index 00000000..912441d7 --- /dev/null +++ b/src/api/resources/unstable/errors/UnprocessableEntityError.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as errors from "../../../../errors/index"; +import * as core from "../../../../core"; + +export class UnprocessableEntityError extends errors.IntercomError { + constructor(body?: unknown, rawResponse?: core.RawResponse) { + super({ + message: "UnprocessableEntityError", + statusCode: 422, + body: body, + rawResponse: rawResponse, + }); + Object.setPrototypeOf(this, UnprocessableEntityError.prototype); + } +} diff --git a/src/api/resources/unstable/errors/index.ts b/src/api/resources/unstable/errors/index.ts new file mode 100644 index 00000000..6190d905 --- /dev/null +++ b/src/api/resources/unstable/errors/index.ts @@ -0,0 +1,7 @@ +export * from "./BadRequestError"; +export * from "./UnauthorizedError"; +export * from "./NotFoundError"; +export * from "./TooManyRequestsError"; +export * from "./ForbiddenError"; +export * from "./UnprocessableEntityError"; +export * from "./InternalServerError"; diff --git a/src/api/resources/unstable/index.ts b/src/api/resources/unstable/index.ts new file mode 100644 index 00000000..d5c609c4 --- /dev/null +++ b/src/api/resources/unstable/index.ts @@ -0,0 +1,4 @@ +export * from "./resources"; +export * from "./types"; +export * from "./errors"; +export * from "./client"; diff --git a/src/api/resources/unstable/resources/admins/client/Client.ts b/src/api/resources/unstable/resources/admins/client/Client.ts new file mode 100644 index 00000000..fad5ac42 --- /dev/null +++ b/src/api/resources/unstable/resources/admins/client/Client.ts @@ -0,0 +1,536 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace Admins { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + } +} + +/** + * Everything about your Admins + */ +export class Admins { + constructor(protected readonly _options: Admins.Options = {}) {} + + /** + * + * You can view the currently authorised admin along with the embedded app object (a "workspace" in legacy terminology). + * + * > 🚧 Single Sign On + * > + * > 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. + * + * @param {Admins.RequestOptions} requestOptions - Request-specific configuration. + * + * @example + * await client.unstable.admins.identifyAdmin() + */ + public identifyAdmin( + requestOptions?: Admins.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__identifyAdmin(requestOptions)); + } + + private async __identifyAdmin( + requestOptions?: Admins.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "me", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.AdminWithApp | undefined, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /me."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can set an Admin as away for the Inbox. + * + * @param {Intercom.unstable.SetAwayAdminRequest} request + * @param {Admins.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.BadRequestError} + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.admins.setAwayAdmin({ + * id: 1, + * away_mode_enabled: true, + * away_mode_reassign: true, + * away_status_reason_id: 12345 + * }) + * + * @example + * await client.unstable.admins.setAwayAdmin({ + * id: 1, + * away_mode_enabled: true, + * away_mode_reassign: true + * }) + */ + public setAwayAdmin( + request: Intercom.unstable.SetAwayAdminRequest, + requestOptions?: Admins.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__setAwayAdmin(request, requestOptions)); + } + + private async __setAwayAdmin( + request: Intercom.unstable.SetAwayAdminRequest, + requestOptions?: Admins.RequestOptions, + ): Promise> { + const { id, ..._body } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `admins/${encodeURIComponent(id)}/away`, + ), + method: "PUT", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: _body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Admin | undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling PUT /admins/{id}/away."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can get a log of activities by all admins in an app. + * + * @param {Intercom.unstable.ListActivityLogsRequest} request + * @param {Admins.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.admins.listActivityLogs({ + * created_at_after: "1677253093", + * created_at_before: "1677861493" + * }) + */ + public listActivityLogs( + request: Intercom.unstable.ListActivityLogsRequest, + requestOptions?: Admins.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listActivityLogs(request, requestOptions)); + } + + private async __listActivityLogs( + request: Intercom.unstable.ListActivityLogsRequest, + requestOptions?: Admins.RequestOptions, + ): Promise> { + const { created_at_after: createdAtAfter, created_at_before: createdAtBefore } = request; + const _queryParams: Record = {}; + _queryParams["created_at_after"] = createdAtAfter; + if (createdAtBefore != null) { + _queryParams["created_at_before"] = createdAtBefore; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "admins/activity_logs", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.ActivityLogList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /admins/activity_logs."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can fetch a list of admins for a given workspace. + * + * @param {Admins.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.admins.listAdmins() + */ + public listAdmins(requestOptions?: Admins.RequestOptions): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listAdmins(requestOptions)); + } + + private async __listAdmins( + requestOptions?: Admins.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "admins", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.AdminList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /admins."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can retrieve the details of a single admin. + * + * @param {Intercom.unstable.RetrieveAdminRequest} request + * @param {Admins.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.admins.retrieveAdmin({ + * id: 1 + * }) + */ + public retrieveAdmin( + request: Intercom.unstable.RetrieveAdminRequest, + requestOptions?: Admins.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveAdmin(request, requestOptions)); + } + + private async __retrieveAdmin( + request: Intercom.unstable.RetrieveAdminRequest, + requestOptions?: Admins.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `admins/${encodeURIComponent(id)}`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Admin | undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /admins/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["INTERCOM_API_KEY"]; + if (bearer == null) { + throw new errors.IntercomError({ + message: + "Please specify a bearer by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", + }); + } + + return `Bearer ${bearer}`; + } +} diff --git a/src/api/resources/unstable/resources/admins/client/index.ts b/src/api/resources/unstable/resources/admins/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/api/resources/unstable/resources/admins/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/unstable/resources/admins/client/requests/ListActivityLogsRequest.ts b/src/api/resources/unstable/resources/admins/client/requests/ListActivityLogsRequest.ts new file mode 100644 index 00000000..88dbafc4 --- /dev/null +++ b/src/api/resources/unstable/resources/admins/client/requests/ListActivityLogsRequest.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * created_at_after: "1677253093", + * created_at_before: "1677861493" + * } + */ +export interface ListActivityLogsRequest { + /** + * The start date that you request data for. It must be formatted as a UNIX timestamp. + */ + created_at_after: string; + /** + * The end date that you request data for. It must be formatted as a UNIX timestamp. + */ + created_at_before?: string; +} diff --git a/src/api/resources/unstable/resources/admins/client/requests/RetrieveAdminRequest.ts b/src/api/resources/unstable/resources/admins/client/requests/RetrieveAdminRequest.ts new file mode 100644 index 00000000..49fb29b2 --- /dev/null +++ b/src/api/resources/unstable/resources/admins/client/requests/RetrieveAdminRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: 1 + * } + */ +export interface RetrieveAdminRequest { + /** + * The unique identifier of a given admin + */ + id: number; +} diff --git a/src/api/resources/unstable/resources/admins/client/requests/SetAwayAdminRequest.ts b/src/api/resources/unstable/resources/admins/client/requests/SetAwayAdminRequest.ts new file mode 100644 index 00000000..2b986684 --- /dev/null +++ b/src/api/resources/unstable/resources/admins/client/requests/SetAwayAdminRequest.ts @@ -0,0 +1,39 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: 1, + * away_mode_enabled: true, + * away_mode_reassign: true, + * away_status_reason_id: 12345 + * } + * + * @example + * { + * id: 1, + * away_mode_enabled: true, + * away_mode_reassign: true + * } + * + * @example + * { + * id: 1, + * away_mode_enabled: true, + * away_mode_reassign: true + * } + */ +export interface SetAwayAdminRequest { + /** + * The unique identifier of a given admin + */ + id: number; + /** Set to "true" to change the status of the admin to away. */ + away_mode_enabled: boolean; + /** Set to "true" to assign any new conversation replies to your default inbox. */ + away_mode_reassign: boolean; + /** The unique identifier of the away status reason */ + away_status_reason_id?: number; +} diff --git a/src/api/resources/unstable/resources/admins/client/requests/index.ts b/src/api/resources/unstable/resources/admins/client/requests/index.ts new file mode 100644 index 00000000..9ca82847 --- /dev/null +++ b/src/api/resources/unstable/resources/admins/client/requests/index.ts @@ -0,0 +1,3 @@ +export { type SetAwayAdminRequest } from "./SetAwayAdminRequest"; +export { type ListActivityLogsRequest } from "./ListActivityLogsRequest"; +export { type RetrieveAdminRequest } from "./RetrieveAdminRequest"; diff --git a/src/api/resources/unstable/resources/admins/index.ts b/src/api/resources/unstable/resources/admins/index.ts new file mode 100644 index 00000000..c9240f83 --- /dev/null +++ b/src/api/resources/unstable/resources/admins/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/unstable/resources/admins/types/Admin.ts b/src/api/resources/unstable/resources/admins/types/Admin.ts new file mode 100644 index 00000000..8e1794d6 --- /dev/null +++ b/src/api/resources/unstable/resources/admins/types/Admin.ts @@ -0,0 +1,34 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +/** + * Admins are teammate accounts that have access to a workspace. + */ +export interface Admin { + /** String representing the object's type. Always has the value `admin`. */ + type?: string; + /** The id representing the admin. */ + id?: string; + /** The name of the admin. */ + name?: string; + /** The email of the admin. */ + email?: string; + /** The job title of the admin. */ + job_title?: string; + /** Identifies if this admin is currently set in away mode. */ + away_mode_enabled?: boolean; + /** Identifies if this admin is set to automatically reassign new conversations to the apps default inbox. */ + away_mode_reassign?: boolean; + /** The unique identifier of the away status reason */ + away_status_reason_id?: number; + /** Identifies if this admin has a paid inbox seat to restrict/allow features that require them. */ + has_inbox_seat?: boolean; + /** This object represents the avatar associated with the admin. */ + team_ids?: number[]; + /** Image for the associated team or teammate */ + avatar?: string; + team_priority_level?: Intercom.unstable.TeamPriorityLevel; +} diff --git a/src/api/resources/unstable/resources/admins/types/index.ts b/src/api/resources/unstable/resources/admins/types/index.ts new file mode 100644 index 00000000..c950b2eb --- /dev/null +++ b/src/api/resources/unstable/resources/admins/types/index.ts @@ -0,0 +1 @@ +export * from "./Admin"; diff --git a/src/api/resources/unstable/resources/aiAgent/index.ts b/src/api/resources/unstable/resources/aiAgent/index.ts new file mode 100644 index 00000000..eea524d6 --- /dev/null +++ b/src/api/resources/unstable/resources/aiAgent/index.ts @@ -0,0 +1 @@ +export * from "./types"; diff --git a/src/api/resources/unstable/resources/aiAgent/types/AiAgent.ts b/src/api/resources/unstable/resources/aiAgent/types/AiAgent.ts new file mode 100644 index 00000000..bc37ada3 --- /dev/null +++ b/src/api/resources/unstable/resources/aiAgent/types/AiAgent.ts @@ -0,0 +1,38 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +/** + * Data related to AI Agent involvement in the conversation. + */ +export interface AiAgent { + /** The type of the source that triggered AI Agent involvement in the conversation. */ + source_type?: AiAgent.SourceType; + /** The title of the source that triggered AI Agent involvement in the conversation. If this is `essentials_plan_setup` then it will return `null`. */ + source_title?: string; + /** The type of the last answer delivered by AI Agent. If no answer was delivered then this will return `null` */ + last_answer_type?: string; + /** The resolution state of AI Agent. If no AI or custom answer has been delivered then this will return `null`. */ + resolution_state?: string; + /** The customer satisfaction rating given to AI Agent, from 1-5. */ + rating?: number; + /** The customer satisfaction rating remark given to AI Agent. */ + rating_remark?: string; + content_sources?: Intercom.unstable.ContentSourcesList; +} + +export namespace AiAgent { + /** + * The type of the source that triggered AI Agent involvement in the conversation. + */ + export type SourceType = "essentials_plan_setup" | "profile" | "workflow" | "workflow_preview" | "fin_preview"; + export const SourceType = { + EssentialsPlanSetup: "essentials_plan_setup", + Profile: "profile", + Workflow: "workflow", + WorkflowPreview: "workflow_preview", + FinPreview: "fin_preview", + } as const; +} diff --git a/src/api/resources/unstable/resources/aiAgent/types/index.ts b/src/api/resources/unstable/resources/aiAgent/types/index.ts new file mode 100644 index 00000000..05de312f --- /dev/null +++ b/src/api/resources/unstable/resources/aiAgent/types/index.ts @@ -0,0 +1 @@ +export * from "./AiAgent"; diff --git a/src/api/resources/unstable/resources/aiContent/client/Client.ts b/src/api/resources/unstable/resources/aiContent/client/Client.ts new file mode 100644 index 00000000..55afcd8a --- /dev/null +++ b/src/api/resources/unstable/resources/aiContent/client/Client.ts @@ -0,0 +1,988 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace AiContent { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + } +} + +/** + * With the AI Content APIs, you can create and manage External Pages and Content Import Sources for your Fin Content Library. + * + *   + * + * *External Pages* are pages that you want Fin to be able to answer questions about. The API for External Pages is a great way to ingest into your Fin Content Library pages that are not publicly accessible and hence can't be crawled by Intercom. + * + *   + * + * *Content Import Sources* are the sources of those pages, and they are used to determine the default audience for the pages (configured via the UI). You should create a Content Import Source for each source of External Pages that you want to ingest into your Fin Content Library. + * + *   + * + * You can then iterate through the content from that source via its API and POST it to the External Pages endpoint. That endpoint has an *external_id* parameter which allows you to specify the identifier from the source. The endpoint will then either create a new External Page or update an existing one as appropriate.", + */ +export class AiContent { + constructor(protected readonly _options: AiContent.Options = {}) {} + + /** + * You can retrieve a list of all content import sources for a workspace. + * + * @param {AiContent.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.aiContent.listContentImportSources() + */ + public listContentImportSources( + requestOptions?: AiContent.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listContentImportSources(requestOptions)); + } + + private async __listContentImportSources( + requestOptions?: AiContent.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "ai/content_import_sources", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.ContentImportSourcesList, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /ai/content_import_sources."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can create a new content import source by sending a POST request to this endpoint. + * + * @param {Intercom.unstable.CreateContentImportSourceRequest} request + * @param {AiContent.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.aiContent.createContentImportSource({ + * url: "https://www.example.com" + * }) + */ + public createContentImportSource( + request: Intercom.unstable.CreateContentImportSourceRequest, + requestOptions?: AiContent.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createContentImportSource(request, requestOptions)); + } + + private async __createContentImportSource( + request: Intercom.unstable.CreateContentImportSourceRequest, + requestOptions?: AiContent.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "ai/content_import_sources", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: { ...request, sync_behavior: "api" }, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.ContentImportSource, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /ai/content_import_sources."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * @param {Intercom.unstable.GetContentImportSourceRequest} request + * @param {AiContent.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.aiContent.getContentImportSource({ + * id: "id" + * }) + */ + public getContentImportSource( + request: Intercom.unstable.GetContentImportSourceRequest, + requestOptions?: AiContent.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__getContentImportSource(request, requestOptions)); + } + + private async __getContentImportSource( + request: Intercom.unstable.GetContentImportSourceRequest, + requestOptions?: AiContent.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `ai/content_import_sources/${encodeURIComponent(id)}`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.ContentImportSource, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling GET /ai/content_import_sources/{id}.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can update an existing content import source. + * + * @param {Intercom.unstable.UpdateContentImportSourceRequest} request + * @param {AiContent.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.aiContent.updateContentImportSource({ + * id: "id", + * sync_behavior: "api", + * url: "https://www.example.com" + * }) + */ + public updateContentImportSource( + request: Intercom.unstable.UpdateContentImportSourceRequest, + requestOptions?: AiContent.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__updateContentImportSource(request, requestOptions)); + } + + private async __updateContentImportSource( + request: Intercom.unstable.UpdateContentImportSourceRequest, + requestOptions?: AiContent.RequestOptions, + ): Promise> { + const { id, ..._body } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `ai/content_import_sources/${encodeURIComponent(id)}`, + ), + method: "PUT", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: _body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.ContentImportSource, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling PUT /ai/content_import_sources/{id}.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can delete a content import source by making a DELETE request this endpoint. This will also delete all external pages that were imported from this source. + * + * @param {Intercom.unstable.DeleteContentImportSourceRequest} request + * @param {AiContent.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.aiContent.deleteContentImportSource({ + * id: "id" + * }) + */ + public deleteContentImportSource( + request: Intercom.unstable.DeleteContentImportSourceRequest, + requestOptions?: AiContent.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteContentImportSource(request, requestOptions)); + } + + private async __deleteContentImportSource( + request: Intercom.unstable.DeleteContentImportSourceRequest, + requestOptions?: AiContent.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `ai/content_import_sources/${encodeURIComponent(id)}`, + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling DELETE /ai/content_import_sources/{id}.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can retrieve a list of all external pages for a workspace. + * + * @param {AiContent.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.aiContent.listExternalPages() + */ + public listExternalPages( + requestOptions?: AiContent.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listExternalPages(requestOptions)); + } + + private async __listExternalPages( + requestOptions?: AiContent.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "ai/external_pages", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.ExternalPagesList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /ai/external_pages."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can create a new external page by sending a POST request to this endpoint. If an external page already exists with the specified source_id and external_id, it will be updated instead. + * + * @param {Intercom.unstable.CreateExternalPageRequest} request + * @param {AiContent.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.aiContent.createExternalPage({ + * title: "Test", + * html: "

Test

", + * url: "https://www.example.com", + * source_id: 44, + * external_id: "abc1234" + * }) + */ + public createExternalPage( + request: Intercom.unstable.CreateExternalPageRequest, + requestOptions?: AiContent.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createExternalPage(request, requestOptions)); + } + + private async __createExternalPage( + request: Intercom.unstable.CreateExternalPageRequest, + requestOptions?: AiContent.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "ai/external_pages", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: { ...request, locale: "en" }, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.ExternalPage, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /ai/external_pages."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can retrieve an external page. + * + * @param {Intercom.unstable.GetExternalPageRequest} request + * @param {AiContent.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.aiContent.getExternalPage({ + * id: "id" + * }) + */ + public getExternalPage( + request: Intercom.unstable.GetExternalPageRequest, + requestOptions?: AiContent.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__getExternalPage(request, requestOptions)); + } + + private async __getExternalPage( + request: Intercom.unstable.GetExternalPageRequest, + requestOptions?: AiContent.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `ai/external_pages/${encodeURIComponent(id)}`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.ExternalPage, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /ai/external_pages/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can update an existing external page (if it was created via the API). + * + * @param {Intercom.unstable.UpdateExternalPageRequest} request + * @param {AiContent.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.aiContent.updateExternalPage({ + * id: "id", + * title: "Test", + * html: "

Test

", + * url: "https://www.example.com", + * source_id: 47, + * external_id: "5678" + * }) + */ + public updateExternalPage( + request: Intercom.unstable.UpdateExternalPageRequest, + requestOptions?: AiContent.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__updateExternalPage(request, requestOptions)); + } + + private async __updateExternalPage( + request: Intercom.unstable.UpdateExternalPageRequest, + requestOptions?: AiContent.RequestOptions, + ): Promise> { + const { id, ..._body } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `ai/external_pages/${encodeURIComponent(id)}`, + ), + method: "PUT", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: { ..._body, locale: "en" }, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.ExternalPage, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling PUT /ai/external_pages/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * Sending a DELETE request for an external page will remove it from the content library UI and from being used for AI answers. + * + * @param {Intercom.unstable.DeleteExternalPageRequest} request + * @param {AiContent.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.aiContent.deleteExternalPage({ + * id: "id" + * }) + */ + public deleteExternalPage( + request: Intercom.unstable.DeleteExternalPageRequest, + requestOptions?: AiContent.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteExternalPage(request, requestOptions)); + } + + private async __deleteExternalPage( + request: Intercom.unstable.DeleteExternalPageRequest, + requestOptions?: AiContent.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `ai/external_pages/${encodeURIComponent(id)}`, + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.ExternalPage, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling DELETE /ai/external_pages/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["INTERCOM_API_KEY"]; + if (bearer == null) { + throw new errors.IntercomError({ + message: + "Please specify a bearer by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", + }); + } + + return `Bearer ${bearer}`; + } +} diff --git a/src/api/resources/unstable/resources/aiContent/client/index.ts b/src/api/resources/unstable/resources/aiContent/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/api/resources/unstable/resources/aiContent/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/unstable/resources/aiContent/client/requests/CreateContentImportSourceRequest.ts b/src/api/resources/unstable/resources/aiContent/client/requests/CreateContentImportSourceRequest.ts new file mode 100644 index 00000000..06da2b4a --- /dev/null +++ b/src/api/resources/unstable/resources/aiContent/client/requests/CreateContentImportSourceRequest.ts @@ -0,0 +1,27 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * url: "https://www.example.com" + * } + */ +export interface CreateContentImportSourceRequest { + /** The status of the content import source. */ + status?: CreateContentImportSourceRequest.Status; + /** The URL of the content import source. */ + url: string; +} + +export namespace CreateContentImportSourceRequest { + /** + * The status of the content import source. + */ + export type Status = "active" | "deactivated"; + export const Status = { + Active: "active", + Deactivated: "deactivated", + } as const; +} diff --git a/src/api/resources/unstable/resources/aiContent/client/requests/CreateExternalPageRequest.ts b/src/api/resources/unstable/resources/aiContent/client/requests/CreateExternalPageRequest.ts new file mode 100644 index 00000000..d0d37237 --- /dev/null +++ b/src/api/resources/unstable/resources/aiContent/client/requests/CreateExternalPageRequest.ts @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * title: "Test", + * html: "

Test

", + * url: "https://www.example.com", + * source_id: 44, + * external_id: "abc1234" + * } + */ +export interface CreateExternalPageRequest { + /** The title of the external page. */ + title: string; + /** The body of the external page in HTML. */ + html: string; + /** The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. When a URL is not present, Fin will not reference the source. */ + url?: string; + /** Whether the external page should be used to answer questions by AI Agent. Will not default when updating an existing external page. */ + ai_agent_availability?: boolean; + /** Whether the external page should be used to answer questions by AI Copilot. Will not default when updating an existing external page. */ + ai_copilot_availability?: boolean; + /** The unique identifier for the source of the external page which was given by Intercom. Every external page must be associated with a Content Import Source which represents the place it comes from and from which it inherits a default audience (configured in the UI). For a new source, make a POST request to the Content Import Source endpoint and an ID for the source will be returned in the response. */ + source_id: number; + /** The identifier for the external page which was given by the source. Must be unique for the source. */ + external_id: string; +} diff --git a/src/api/resources/unstable/resources/aiContent/client/requests/DeleteContentImportSourceRequest.ts b/src/api/resources/unstable/resources/aiContent/client/requests/DeleteContentImportSourceRequest.ts new file mode 100644 index 00000000..6d921146 --- /dev/null +++ b/src/api/resources/unstable/resources/aiContent/client/requests/DeleteContentImportSourceRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "id" + * } + */ +export interface DeleteContentImportSourceRequest { + /** + * The unique identifier for the content import source which is given by Intercom. + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/aiContent/client/requests/DeleteExternalPageRequest.ts b/src/api/resources/unstable/resources/aiContent/client/requests/DeleteExternalPageRequest.ts new file mode 100644 index 00000000..cf5c01d3 --- /dev/null +++ b/src/api/resources/unstable/resources/aiContent/client/requests/DeleteExternalPageRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "id" + * } + */ +export interface DeleteExternalPageRequest { + /** + * The unique identifier for the external page which is given by Intercom. + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/aiContent/client/requests/GetContentImportSourceRequest.ts b/src/api/resources/unstable/resources/aiContent/client/requests/GetContentImportSourceRequest.ts new file mode 100644 index 00000000..68b77b47 --- /dev/null +++ b/src/api/resources/unstable/resources/aiContent/client/requests/GetContentImportSourceRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "id" + * } + */ +export interface GetContentImportSourceRequest { + /** + * The unique identifier for the content import source which is given by Intercom. + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/aiContent/client/requests/GetExternalPageRequest.ts b/src/api/resources/unstable/resources/aiContent/client/requests/GetExternalPageRequest.ts new file mode 100644 index 00000000..bb1c963e --- /dev/null +++ b/src/api/resources/unstable/resources/aiContent/client/requests/GetExternalPageRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "id" + * } + */ +export interface GetExternalPageRequest { + /** + * The unique identifier for the external page which is given by Intercom. + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/aiContent/client/requests/UpdateContentImportSourceRequest.ts b/src/api/resources/unstable/resources/aiContent/client/requests/UpdateContentImportSourceRequest.ts new file mode 100644 index 00000000..bac30489 --- /dev/null +++ b/src/api/resources/unstable/resources/aiContent/client/requests/UpdateContentImportSourceRequest.ts @@ -0,0 +1,44 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "id", + * sync_behavior: "api", + * url: "https://www.example.com" + * } + */ +export interface UpdateContentImportSourceRequest { + /** + * The unique identifier for the content import source which is given by Intercom. + */ + id: string; + /** If you intend to create or update External Pages via the API, this should be set to `api`. You can not change the value to or from api. */ + sync_behavior: UpdateContentImportSourceRequest.SyncBehavior; + /** The status of the content import source. */ + status?: UpdateContentImportSourceRequest.Status; + /** The URL of the content import source. This may only be different from the existing value if the sync behavior is API. */ + url: string; +} + +export namespace UpdateContentImportSourceRequest { + /** + * If you intend to create or update External Pages via the API, this should be set to `api`. You can not change the value to or from api. + */ + export type SyncBehavior = "api" | "automated" | "manual"; + export const SyncBehavior = { + Api: "api", + Automated: "automated", + Manual: "manual", + } as const; + /** + * The status of the content import source. + */ + export type Status = "active" | "deactivated"; + export const Status = { + Active: "active", + Deactivated: "deactivated", + } as const; +} diff --git a/src/api/resources/unstable/resources/aiContent/client/requests/UpdateExternalPageRequest.ts b/src/api/resources/unstable/resources/aiContent/client/requests/UpdateExternalPageRequest.ts new file mode 100644 index 00000000..162b3c77 --- /dev/null +++ b/src/api/resources/unstable/resources/aiContent/client/requests/UpdateExternalPageRequest.ts @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "id", + * title: "Test", + * html: "

Test

", + * url: "https://www.example.com", + * source_id: 47, + * external_id: "5678" + * } + */ +export interface UpdateExternalPageRequest { + /** + * The unique identifier for the external page which is given by Intercom. + */ + id: string; + /** The title of the external page. */ + title: string; + /** The body of the external page in HTML. */ + html: string; + /** The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. */ + url: string; + /** Whether the external page should be used to answer questions by Fin. */ + fin_availability?: boolean; + /** The unique identifier for the source of the external page which was given by Intercom. Every external page must be associated with a Content Import Source which represents the place it comes from and from which it inherits a default audience (configured in the UI). For a new source, make a POST request to the Content Import Source endpoint and an ID for the source will be returned in the response. */ + source_id: number; + /** The identifier for the external page which was given by the source. Must be unique for the source. */ + external_id?: string; +} diff --git a/src/api/resources/unstable/resources/aiContent/client/requests/index.ts b/src/api/resources/unstable/resources/aiContent/client/requests/index.ts new file mode 100644 index 00000000..820c72ee --- /dev/null +++ b/src/api/resources/unstable/resources/aiContent/client/requests/index.ts @@ -0,0 +1,8 @@ +export { type CreateContentImportSourceRequest } from "./CreateContentImportSourceRequest"; +export { type GetContentImportSourceRequest } from "./GetContentImportSourceRequest"; +export { type UpdateContentImportSourceRequest } from "./UpdateContentImportSourceRequest"; +export { type DeleteContentImportSourceRequest } from "./DeleteContentImportSourceRequest"; +export { type CreateExternalPageRequest } from "./CreateExternalPageRequest"; +export { type GetExternalPageRequest } from "./GetExternalPageRequest"; +export { type UpdateExternalPageRequest } from "./UpdateExternalPageRequest"; +export { type DeleteExternalPageRequest } from "./DeleteExternalPageRequest"; diff --git a/src/api/resources/unstable/resources/aiContent/index.ts b/src/api/resources/unstable/resources/aiContent/index.ts new file mode 100644 index 00000000..c9240f83 --- /dev/null +++ b/src/api/resources/unstable/resources/aiContent/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/unstable/resources/aiContent/types/ContentImportSource.ts b/src/api/resources/unstable/resources/aiContent/types/ContentImportSource.ts new file mode 100644 index 00000000..ef5cd352 --- /dev/null +++ b/src/api/resources/unstable/resources/aiContent/types/ContentImportSource.ts @@ -0,0 +1,45 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * An external source for External Pages that you add to your Fin Content Library. + */ +export interface ContentImportSource { + /** Always external_page */ + type: "content_import_source"; + /** The unique identifier for the content import source which is given by Intercom. */ + id: number; + /** The time when the content import source was last synced. */ + last_synced_at: number; + /** If you intend to create or update External Pages via the API, this should be set to `api`. */ + sync_behavior: ContentImportSource.SyncBehavior; + /** The status of the content import source. */ + status: ContentImportSource.Status; + /** The URL of the root of the external source. */ + url: string; + /** The time when the content import source was created. */ + created_at: number; + /** The time when the content import source was last updated. */ + updated_at: number; +} + +export namespace ContentImportSource { + /** + * If you intend to create or update External Pages via the API, this should be set to `api`. + */ + export type SyncBehavior = "api" | "automatic" | "manual"; + export const SyncBehavior = { + Api: "api", + Automatic: "automatic", + Manual: "manual", + } as const; + /** + * The status of the content import source. + */ + export type Status = "active" | "deactivated"; + export const Status = { + Active: "active", + Deactivated: "deactivated", + } as const; +} diff --git a/src/api/resources/unstable/resources/aiContent/types/ContentImportSourcesList.ts b/src/api/resources/unstable/resources/aiContent/types/ContentImportSourcesList.ts new file mode 100644 index 00000000..ede951a5 --- /dev/null +++ b/src/api/resources/unstable/resources/aiContent/types/ContentImportSourcesList.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +/** + * This will return a list of the content import sources for the App. + */ +export interface ContentImportSourcesList { + /** The type of the object - `list`. */ + type?: "list"; + pages?: Intercom.unstable.PagesLink; + /** A count of the total number of content import sources. */ + total_count?: number; + /** An array of Content Import Source objects */ + data?: Intercom.unstable.ContentImportSource[]; +} diff --git a/src/api/resources/unstable/resources/aiContent/types/ExternalPage.ts b/src/api/resources/unstable/resources/aiContent/types/ExternalPage.ts new file mode 100644 index 00000000..93a5eaf4 --- /dev/null +++ b/src/api/resources/unstable/resources/aiContent/types/ExternalPage.ts @@ -0,0 +1,37 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * External pages that you have added to your Fin Content Library. + */ +export interface ExternalPage { + /** Always external_page */ + type: "external_page"; + /** The unique identifier for the external page which is given by Intercom. */ + id: string; + /** The title of the external page. */ + title: string; + /** The body of the external page in HTML. */ + html: string; + /** The URL of the external page. This will be used by Fin to link end users to the page it based its answer on. */ + url?: string; + /** Whether the external page should be used to answer questions by AI Agent. */ + ai_agent_availability: boolean; + /** Whether the external page should be used to answer questions by AI Copilot. */ + ai_copilot_availability: boolean; + /** Deprecated. Use ai_agent_availability and ai_copilot_availability instead. */ + fin_availability?: boolean; + /** Always en */ + locale: "en"; + /** The unique identifier for the source of the external page which was given by Intercom. Every external page must be associated with a Content Import Source which represents the place it comes from and from which it inherits a default audience (configured in the UI). For a new source, make a POST request to the Content Import Source endpoint and an ID for the source will be returned in the response. */ + source_id: number; + /** The identifier for the external page which was given by the source. Must be unique for the source. */ + external_id: string; + /** The time when the external page was created. */ + created_at: number; + /** The time when the external page was last updated. */ + updated_at: number; + /** The time when the external page was last ingested. */ + last_ingested_at: number; +} diff --git a/src/api/resources/unstable/resources/aiContent/types/ExternalPagesList.ts b/src/api/resources/unstable/resources/aiContent/types/ExternalPagesList.ts new file mode 100644 index 00000000..d3c610c2 --- /dev/null +++ b/src/api/resources/unstable/resources/aiContent/types/ExternalPagesList.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +/** + * This will return a list of external pages for the App. + */ +export interface ExternalPagesList { + /** The type of the object - `list`. */ + type?: "list"; + pages?: Intercom.unstable.PagesLink; + /** A count of the total number of external pages. */ + total_count?: number; + /** An array of External Page objects */ + data?: Intercom.unstable.ExternalPage[]; +} diff --git a/src/api/resources/unstable/resources/aiContent/types/index.ts b/src/api/resources/unstable/resources/aiContent/types/index.ts new file mode 100644 index 00000000..a1b39227 --- /dev/null +++ b/src/api/resources/unstable/resources/aiContent/types/index.ts @@ -0,0 +1,4 @@ +export * from "./ContentImportSource"; +export * from "./ContentImportSourcesList"; +export * from "./ExternalPage"; +export * from "./ExternalPagesList"; diff --git a/src/api/resources/unstable/resources/aiContentSource/index.ts b/src/api/resources/unstable/resources/aiContentSource/index.ts new file mode 100644 index 00000000..eea524d6 --- /dev/null +++ b/src/api/resources/unstable/resources/aiContentSource/index.ts @@ -0,0 +1 @@ +export * from "./types"; diff --git a/src/api/resources/unstable/resources/aiContentSource/types/ContentSource.ts b/src/api/resources/unstable/resources/aiContentSource/types/ContentSource.ts new file mode 100644 index 00000000..3baaae4a --- /dev/null +++ b/src/api/resources/unstable/resources/aiContentSource/types/ContentSource.ts @@ -0,0 +1,31 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The content source used by AI Agent in the conversation. + */ +export interface ContentSource { + /** The type of the content source. */ + content_type?: ContentSource.ContentType; + /** The internal URL linking to the content source for teammates. */ + url?: string; + /** The title of the content source. */ + title?: string; + /** The ISO 639 language code of the content source. */ + locale?: string; +} + +export namespace ContentSource { + /** + * The type of the content source. + */ + export type ContentType = "file" | "article" | "external_content" | "content_snippet" | "workflow_connector_action"; + export const ContentType = { + File: "file", + Article: "article", + ExternalContent: "external_content", + ContentSnippet: "content_snippet", + WorkflowConnectorAction: "workflow_connector_action", + } as const; +} diff --git a/src/api/resources/unstable/resources/aiContentSource/types/index.ts b/src/api/resources/unstable/resources/aiContentSource/types/index.ts new file mode 100644 index 00000000..68047f7e --- /dev/null +++ b/src/api/resources/unstable/resources/aiContentSource/types/index.ts @@ -0,0 +1 @@ +export * from "./ContentSource"; diff --git a/src/api/resources/unstable/resources/articles/client/Client.ts b/src/api/resources/unstable/resources/articles/client/Client.ts new file mode 100644 index 00000000..ec87cbce --- /dev/null +++ b/src/api/resources/unstable/resources/articles/client/Client.ts @@ -0,0 +1,556 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace Articles { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + } +} + +/** + * Everything about your Articles + */ +export class Articles { + constructor(protected readonly _options: Articles.Options = {}) {} + + /** + * You can fetch a list of all articles by making a GET request to `https://api.intercom.io/articles`. + * + * > 📘 How are the articles sorted and ordered? + * > + * > 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. + * + * @param {Articles.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.articles.listArticles() + */ + public listArticles( + requestOptions?: Articles.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listArticles(requestOptions)); + } + + private async __listArticles( + requestOptions?: Articles.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "articles", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.ArticleList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /articles."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can create a new article by making a POST request to `https://api.intercom.io/articles`. + * + * @param {unknown} request + * @param {Articles.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.BadRequestError} + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.articles.createArticle({ + * "key": "value" + * }) + */ + public createArticle( + request?: unknown, + requestOptions?: Articles.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createArticle(request, requestOptions)); + } + + private async __createArticle( + request?: unknown, + requestOptions?: Articles.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "articles", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Article, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /articles."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can fetch the details of a single article by making a GET request to `https://api.intercom.io/articles/`. + * + * @param {Intercom.unstable.RetrieveArticleRequest} request + * @param {Articles.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.articles.retrieveArticle({ + * id: 1 + * }) + */ + public retrieveArticle( + request: Intercom.unstable.RetrieveArticleRequest, + requestOptions?: Articles.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveArticle(request, requestOptions)); + } + + private async __retrieveArticle( + request: Intercom.unstable.RetrieveArticleRequest, + requestOptions?: Articles.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `articles/${encodeURIComponent(id)}`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Article, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /articles/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can delete a single article by making a DELETE request to `https://api.intercom.io/articles/`. + * + * @param {Intercom.unstable.DeleteArticleRequest} request + * @param {Articles.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.articles.deleteArticle({ + * id: 1 + * }) + */ + public deleteArticle( + request: Intercom.unstable.DeleteArticleRequest, + requestOptions?: Articles.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteArticle(request, requestOptions)); + } + + private async __deleteArticle( + request: Intercom.unstable.DeleteArticleRequest, + requestOptions?: Articles.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `articles/${encodeURIComponent(id)}`, + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.DeletedArticleObject, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling DELETE /articles/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can search for articles by making a GET request to `https://api.intercom.io/articles/search`. + * + * @param {Intercom.unstable.SearchArticlesRequest} request + * @param {Articles.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.articles.searchArticles({ + * phrase: "Getting started", + * state: "published" + * }) + */ + public searchArticles( + request: Intercom.unstable.SearchArticlesRequest = {}, + requestOptions?: Articles.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__searchArticles(request, requestOptions)); + } + + private async __searchArticles( + request: Intercom.unstable.SearchArticlesRequest = {}, + requestOptions?: Articles.RequestOptions, + ): Promise> { + const { phrase, state, help_center_id: helpCenterId, highlight } = request; + const _queryParams: Record = {}; + if (phrase != null) { + _queryParams["phrase"] = phrase; + } + + if (state != null) { + _queryParams["state"] = state; + } + + if (helpCenterId != null) { + _queryParams["help_center_id"] = helpCenterId.toString(); + } + + if (highlight != null) { + _queryParams["highlight"] = highlight.toString(); + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "articles/search", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.ArticleSearchResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /articles/search."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["INTERCOM_API_KEY"]; + if (bearer == null) { + throw new errors.IntercomError({ + message: + "Please specify a bearer by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", + }); + } + + return `Bearer ${bearer}`; + } +} diff --git a/src/api/resources/unstable/resources/articles/client/index.ts b/src/api/resources/unstable/resources/articles/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/api/resources/unstable/resources/articles/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/unstable/resources/articles/client/requests/DeleteArticleRequest.ts b/src/api/resources/unstable/resources/articles/client/requests/DeleteArticleRequest.ts new file mode 100644 index 00000000..51b8ba6a --- /dev/null +++ b/src/api/resources/unstable/resources/articles/client/requests/DeleteArticleRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: 1 + * } + */ +export interface DeleteArticleRequest { + /** + * The unique identifier for the article which is given by Intercom. + */ + id: number; +} diff --git a/src/api/resources/unstable/resources/articles/client/requests/RetrieveArticleRequest.ts b/src/api/resources/unstable/resources/articles/client/requests/RetrieveArticleRequest.ts new file mode 100644 index 00000000..d9920ed0 --- /dev/null +++ b/src/api/resources/unstable/resources/articles/client/requests/RetrieveArticleRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: 1 + * } + */ +export interface RetrieveArticleRequest { + /** + * The unique identifier for the article which is given by Intercom. + */ + id: number; +} diff --git a/src/api/resources/unstable/resources/articles/client/requests/SearchArticlesRequest.ts b/src/api/resources/unstable/resources/articles/client/requests/SearchArticlesRequest.ts new file mode 100644 index 00000000..7c07777d --- /dev/null +++ b/src/api/resources/unstable/resources/articles/client/requests/SearchArticlesRequest.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * phrase: "Getting started", + * state: "published" + * } + */ +export interface SearchArticlesRequest { + /** + * The phrase within your articles to search for. + */ + phrase?: string; + /** + * The state of the Articles returned. One of `published`, `draft` or `all`. + */ + state?: string; + /** + * The ID of the Help Center to search in. + */ + help_center_id?: number; + /** + * Return a highlighted version of the matching content within your articles. Refer to the response schema for more details. + */ + highlight?: boolean; +} diff --git a/src/api/resources/unstable/resources/articles/client/requests/index.ts b/src/api/resources/unstable/resources/articles/client/requests/index.ts new file mode 100644 index 00000000..a0beaf5f --- /dev/null +++ b/src/api/resources/unstable/resources/articles/client/requests/index.ts @@ -0,0 +1,3 @@ +export { type RetrieveArticleRequest } from "./RetrieveArticleRequest"; +export { type DeleteArticleRequest } from "./DeleteArticleRequest"; +export { type SearchArticlesRequest } from "./SearchArticlesRequest"; diff --git a/src/api/resources/unstable/resources/articles/index.ts b/src/api/resources/unstable/resources/articles/index.ts new file mode 100644 index 00000000..c9240f83 --- /dev/null +++ b/src/api/resources/unstable/resources/articles/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/unstable/resources/articles/types/Article.ts b/src/api/resources/unstable/resources/articles/types/Article.ts new file mode 100644 index 00000000..adb8fda9 --- /dev/null +++ b/src/api/resources/unstable/resources/articles/types/Article.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +/** + * The Articles API is a central place to gather all information and take actions on your articles. Articles can live within collections and sections, or alternatively they can stand alone. + */ +export interface Article extends Intercom.unstable.ArticleListItem { + statistics?: Intercom.unstable.ArticleStatistics; +} diff --git a/src/api/resources/unstable/resources/articles/types/ArticleListItem.ts b/src/api/resources/unstable/resources/articles/types/ArticleListItem.ts new file mode 100644 index 00000000..01c385fe --- /dev/null +++ b/src/api/resources/unstable/resources/articles/types/ArticleListItem.ts @@ -0,0 +1,53 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +/** + * The data returned about your articles when you list them. + */ +export interface ArticleListItem { + /** The type of object - `article`. */ + type?: "article"; + /** The unique identifier for the article which is given by Intercom. */ + id?: string; + /** The id of the workspace which the article belongs to. */ + workspace_id?: string; + /** The title of the article. For multilingual articles, this will be the title of the default language's content. */ + title?: string; + /** The description of the article. For multilingual articles, this will be the description of the default language's content. */ + description?: string; + /** The body of the article in HTML. For multilingual articles, this will be the body of the default language's content. */ + body?: string; + /** The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace. */ + author_id?: number; + /** Whether the article is `published` or is a `draft`. For multilingual articles, this will be the state of the default language's content. */ + state?: ArticleListItem.State; + /** The time when the article was created. For multilingual articles, this will be the timestamp of creation of the default language's content in seconds. */ + created_at?: number; + /** The time when the article was last updated. For multilingual articles, this will be the timestamp of last update of the default language's content in seconds. */ + updated_at?: number; + /** The URL of the article. For multilingual articles, this will be the URL of the default language's content. */ + url?: string; + /** The id of the article's parent collection or section. An article without this field stands alone. */ + parent_id?: number; + /** The ids of the article's parent collections or sections. An article without this field stands alone. */ + parent_ids?: number[]; + /** The type of parent, which can either be a `collection` or `section`. */ + parent_type?: string; + /** The default locale of the help center. This field is only returned for multilingual help centers. */ + default_locale?: string; + translated_content?: Intercom.unstable.ArticleTranslatedContent; +} + +export namespace ArticleListItem { + /** + * Whether the article is `published` or is a `draft`. For multilingual articles, this will be the state of the default language's content. + */ + export type State = "published" | "draft"; + export const State = { + Published: "published", + Draft: "draft", + } as const; +} diff --git a/src/api/resources/unstable/resources/articles/types/ArticleSearchHighlights.ts b/src/api/resources/unstable/resources/articles/types/ArticleSearchHighlights.ts new file mode 100644 index 00000000..5e1f607b --- /dev/null +++ b/src/api/resources/unstable/resources/articles/types/ArticleSearchHighlights.ts @@ -0,0 +1,67 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The highlighted results of an Article search. In the examples provided my search query is always "my query". + */ +export interface ArticleSearchHighlights { + /** The ID of the corresponding article. */ + article_id?: string; + /** An Article title highlighted. */ + highlighted_title?: ArticleSearchHighlights.HighlightedTitle.Item[]; + /** An Article description and body text highlighted. */ + highlighted_summary?: ArticleSearchHighlights.HighlightedSummary.Item[][]; +} + +export namespace ArticleSearchHighlights { + export type HighlightedTitle = HighlightedTitle.Item[]; + + export namespace HighlightedTitle { + /** + * A highlighted article title. + */ + export interface Item { + /** The type of text - `highlight` or `plain`. */ + type?: Item.Type; + /** The text of the title. */ + text?: string; + } + + export namespace Item { + /** + * The type of text - `highlight` or `plain`. + */ + export type Type = "highlight" | "plain"; + export const Type = { + Highlight: "highlight", + Plain: "plain", + } as const; + } + } + + export type HighlightedSummary = HighlightedSummary.Item[]; + + export namespace HighlightedSummary { + /** + * An instance of highlighted summary text. + */ + export interface Item { + /** The type of text - `highlight` or `plain`. */ + type?: Item.Type; + /** The text of the title. */ + text?: string; + } + + export namespace Item { + /** + * The type of text - `highlight` or `plain`. + */ + export type Type = "highlight" | "plain"; + export const Type = { + Highlight: "highlight", + Plain: "plain", + } as const; + } + } +} diff --git a/src/api/resources/unstable/resources/articles/types/ArticleSearchResponse.ts b/src/api/resources/unstable/resources/articles/types/ArticleSearchResponse.ts new file mode 100644 index 00000000..38cd179a --- /dev/null +++ b/src/api/resources/unstable/resources/articles/types/ArticleSearchResponse.ts @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +/** + * The results of an Article search + */ +export interface ArticleSearchResponse { + /** The type of the object - `list`. */ + type?: "list"; + /** The total number of Articles matching the search query */ + total_count?: number; + /** An object containing the results of the search. */ + data?: ArticleSearchResponse.Data; + pages?: Intercom.unstable.CursorPages; +} + +export namespace ArticleSearchResponse { + /** + * An object containing the results of the search. + */ + export interface Data { + /** An array of Article objects */ + articles?: Intercom.unstable.Article[]; + /** A corresponding array of highlighted Article content */ + highlights?: Intercom.unstable.ArticleSearchHighlights[]; + } +} diff --git a/src/api/resources/unstable/resources/articles/types/index.ts b/src/api/resources/unstable/resources/articles/types/index.ts new file mode 100644 index 00000000..815412c7 --- /dev/null +++ b/src/api/resources/unstable/resources/articles/types/index.ts @@ -0,0 +1,4 @@ +export * from "./Article"; +export * from "./ArticleListItem"; +export * from "./ArticleSearchHighlights"; +export * from "./ArticleSearchResponse"; diff --git a/src/api/resources/unstable/resources/awayStatusReasons/client/Client.ts b/src/api/resources/unstable/resources/awayStatusReasons/client/Client.ts new file mode 100644 index 00000000..9ff1532d --- /dev/null +++ b/src/api/resources/unstable/resources/awayStatusReasons/client/Client.ts @@ -0,0 +1,170 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace AwayStatusReasons { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + } +} + +/** + * Everything about your Away Status Reasons + */ +export class AwayStatusReasons { + constructor(protected readonly _options: AwayStatusReasons.Options = {}) {} + + /** + * Returns a list of all away status reasons configured for the workspace, including deleted ones. + * + * @param {AwayStatusReasons.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.awayStatusReasons.listAwayStatusReasons() + */ + public listAwayStatusReasons( + requestOptions?: AwayStatusReasons.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listAwayStatusReasons(requestOptions)); + } + + private async __listAwayStatusReasons( + requestOptions?: AwayStatusReasons.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "away_status_reasons", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.AwayStatusReason[], rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /away_status_reasons."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["INTERCOM_API_KEY"]; + if (bearer == null) { + throw new errors.IntercomError({ + message: + "Please specify a bearer by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", + }); + } + + return `Bearer ${bearer}`; + } +} diff --git a/src/api/resources/unstable/resources/awayStatusReasons/client/index.ts b/src/api/resources/unstable/resources/awayStatusReasons/client/index.ts new file mode 100644 index 00000000..cb0ff5c3 --- /dev/null +++ b/src/api/resources/unstable/resources/awayStatusReasons/client/index.ts @@ -0,0 +1 @@ +export {}; diff --git a/src/api/resources/customChannelEvents/index.ts b/src/api/resources/unstable/resources/awayStatusReasons/index.ts similarity index 100% rename from src/api/resources/customChannelEvents/index.ts rename to src/api/resources/unstable/resources/awayStatusReasons/index.ts diff --git a/src/api/resources/unstable/resources/companies/client/Client.ts b/src/api/resources/unstable/resources/companies/client/Client.ts new file mode 100644 index 00000000..b5593293 --- /dev/null +++ b/src/api/resources/unstable/resources/companies/client/Client.ts @@ -0,0 +1,1196 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace Companies { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + } +} + +/** + * Everything about your Companies + */ +export class Companies { + constructor(protected readonly _options: Companies.Options = {}) {} + + /** + * You can fetch a single company by passing in `company_id` or `name`. + * + * `https://api.intercom.io/companies?name={name}` + * + * `https://api.intercom.io/companies?company_id={company_id}` + * + * You can fetch all companies and filter by `segment_id` or `tag_id` as a query parameter. + * + * `https://api.intercom.io/companies?tag_id={tag_id}` + * + * `https://api.intercom.io/companies?segment_id={segment_id}` + * + * @param {Intercom.unstable.RetrieveCompanyRequest} request + * @param {Companies.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.companies.retrieveCompany({ + * name: "my company", + * company_id: "12345", + * tag_id: "678910", + * segment_id: "98765" + * }) + */ + public retrieveCompany( + request: Intercom.unstable.RetrieveCompanyRequest = {}, + requestOptions?: Companies.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveCompany(request, requestOptions)); + } + + private async __retrieveCompany( + request: Intercom.unstable.RetrieveCompanyRequest = {}, + requestOptions?: Companies.RequestOptions, + ): Promise> { + const { name, company_id: companyId, tag_id: tagId, segment_id: segmentId, page, per_page: perPage } = request; + const _queryParams: Record = {}; + if (name != null) { + _queryParams["name"] = name; + } + + if (companyId != null) { + _queryParams["company_id"] = companyId; + } + + if (tagId != null) { + _queryParams["tag_id"] = tagId; + } + + if (segmentId != null) { + _queryParams["segment_id"] = segmentId; + } + + if (page != null) { + _queryParams["page"] = page.toString(); + } + + if (perPage != null) { + _queryParams["per_page"] = perPage.toString(); + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "companies", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.CompanyList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /companies."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can create or update a company. + * + * Companies will be only visible in Intercom when there is at least one associated user. + * + * Companies are looked up via `company_id` in a `POST` request, if not found via `company_id`, the new company will be created, if found, that company will be updated. + * + * {% admonition type="warning" name="Using `company_id`" %} + * You can set a unique `company_id` value when creating a company. However, it is not possible to update `company_id`. Be sure to set a unique value once upon creation of the company. + * {% /admonition %} + * + * @param {unknown} request + * @param {Companies.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.BadRequestError} + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.companies.createOrUpdateCompany({ + * "key": "value" + * }) + */ + public createOrUpdateCompany( + request?: unknown, + requestOptions?: Companies.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createOrUpdateCompany(request, requestOptions)); + } + + private async __createOrUpdateCompany( + request?: unknown, + requestOptions?: Companies.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "companies", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Company, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /companies."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can fetch a single company. + * + * @param {Intercom.unstable.RetrieveACompanyByIdRequest} request + * @param {Companies.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.companies.retrieveACompanyById({ + * id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" + * }) + */ + public retrieveACompanyById( + request: Intercom.unstable.RetrieveACompanyByIdRequest, + requestOptions?: Companies.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveACompanyById(request, requestOptions)); + } + + private async __retrieveACompanyById( + request: Intercom.unstable.RetrieveACompanyByIdRequest, + requestOptions?: Companies.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `companies/${encodeURIComponent(id)}`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Company, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /companies/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can update a single company using the Intercom provisioned `id`. + * + * {% admonition type="warning" name="Using `company_id`" %} + * When updating a company it is not possible to update `company_id`. This can only be set once upon creation of the company. + * {% /admonition %} + * + * @param {Intercom.unstable.UpdateCompanyRequest} request + * @param {Companies.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.companies.updateCompany({ + * id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" + * }) + */ + public updateCompany( + request: Intercom.unstable.UpdateCompanyRequest, + requestOptions?: Companies.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__updateCompany(request, requestOptions)); + } + + private async __updateCompany( + request: Intercom.unstable.UpdateCompanyRequest, + requestOptions?: Companies.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `companies/${encodeURIComponent(id)}`, + ), + method: "PUT", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Company, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling PUT /companies/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can delete a single company. + * + * @param {Intercom.unstable.DeleteCompanyRequest} request + * @param {Companies.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.companies.deleteCompany({ + * id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" + * }) + */ + public deleteCompany( + request: Intercom.unstable.DeleteCompanyRequest, + requestOptions?: Companies.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteCompany(request, requestOptions)); + } + + private async __deleteCompany( + request: Intercom.unstable.DeleteCompanyRequest, + requestOptions?: Companies.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `companies/${encodeURIComponent(id)}`, + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.DeletedCompanyObject, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling DELETE /companies/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can fetch a list of all contacts that belong to a company. + * + * @param {Intercom.unstable.ListAttachedContactsRequest} request + * @param {Companies.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.companies.listAttachedContacts({ + * id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" + * }) + */ + public listAttachedContacts( + request: Intercom.unstable.ListAttachedContactsRequest, + requestOptions?: Companies.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listAttachedContacts(request, requestOptions)); + } + + private async __listAttachedContacts( + request: Intercom.unstable.ListAttachedContactsRequest, + requestOptions?: Companies.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `companies/${encodeURIComponent(id)}/contacts`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.CompanyAttachedContacts, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /companies/{id}/contacts."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can fetch a list of all segments that belong to a company. + * + * @param {Intercom.unstable.ListAttachedSegmentsForCompaniesRequest} request + * @param {Companies.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.companies.listAttachedSegmentsForCompanies({ + * id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" + * }) + */ + public listAttachedSegmentsForCompanies( + request: Intercom.unstable.ListAttachedSegmentsForCompaniesRequest, + requestOptions?: Companies.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listAttachedSegmentsForCompanies(request, requestOptions)); + } + + private async __listAttachedSegmentsForCompanies( + request: Intercom.unstable.ListAttachedSegmentsForCompaniesRequest, + requestOptions?: Companies.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `companies/${encodeURIComponent(id)}/segments`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.CompanyAttachedSegments, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /companies/{id}/segments."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can list companies. The company list is sorted by the `last_request_at` field and by default is ordered descending, most recently requested first. + * + * Note that the API does not include companies who have no associated users in list responses. + * + * When using the Companies endpoint and the pages object to iterate through the returned companies, there is a limit of 10,000 Companies that can be returned. If you need to list or iterate on more than 10,000 Companies, please use the [Scroll API](https://developers.intercom.com/reference#iterating-over-all-companies). + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is `20` results per page. + * 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 %} + * + * @param {Intercom.unstable.ListAllCompaniesRequest} request + * @param {Companies.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.companies.listAllCompanies({ + * order: "desc" + * }) + */ + public listAllCompanies( + request: Intercom.unstable.ListAllCompaniesRequest = {}, + requestOptions?: Companies.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listAllCompanies(request, requestOptions)); + } + + private async __listAllCompanies( + request: Intercom.unstable.ListAllCompaniesRequest = {}, + requestOptions?: Companies.RequestOptions, + ): Promise> { + const { page, per_page: perPage, order } = request; + const _queryParams: Record = {}; + if (page != null) { + _queryParams["page"] = page.toString(); + } + + if (perPage != null) { + _queryParams["per_page"] = perPage.toString(); + } + + if (order != null) { + _queryParams["order"] = order; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "companies/list", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.CompanyList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /companies/list."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * The `list all companies` functionality does not work well for huge datasets, and can result in errors and performance problems when paging deeply. The Scroll API provides an efficient mechanism for iterating over all companies in a dataset. + * + * - Each app can only have 1 scroll open at a time. You'll get an error message if you try to have more than one open per app. + * - If the scroll isn't used for 1 minute, it expires and calls with that scroll param will fail + * - If the end of the scroll is reached, "companies" will be empty and the scroll parameter will expire + * + * {% admonition type="info" name="Scroll Parameter" %} + * You can get the first page of companies by simply sending a GET request to the scroll endpoint. + * For subsequent requests you will need to use the scroll parameter from the response. + * {% /admonition %} + * {% admonition type="danger" name="Scroll network timeouts" %} + * Since scroll is often used on large datasets network errors such as timeouts can be encountered. When this occurs you will see a HTTP 500 error with the following message: + * "Request failed due to an internal network error. Please restart the scroll operation." + * 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 %} + * + * @param {Intercom.unstable.ScrollOverAllCompaniesRequest} request + * @param {Companies.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.companies.scrollOverAllCompanies() + */ + public scrollOverAllCompanies( + request: Intercom.unstable.ScrollOverAllCompaniesRequest = {}, + requestOptions?: Companies.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__scrollOverAllCompanies(request, requestOptions)); + } + + private async __scrollOverAllCompanies( + request: Intercom.unstable.ScrollOverAllCompaniesRequest = {}, + requestOptions?: Companies.RequestOptions, + ): Promise> { + const { scroll_param: scrollParam } = request; + const _queryParams: Record = {}; + if (scrollParam != null) { + _queryParams["scroll_param"] = scrollParam; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "companies/scroll", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.CompanyScroll | undefined, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /companies/scroll."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can attach a company to a single contact. + * + * @param {Intercom.unstable.AttachContactToACompanyRequest} request + * @param {Companies.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.BadRequestError} + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.companies.attachContactToACompany({ + * id: "id", + * company_id: "6762f09a1bb69f9f2193bb34" + * }) + * + * @example + * await client.unstable.companies.attachContactToACompany({ + * id: "id", + * company_id: "58a430d35458202d41b1e65b" + * }) + * + * @example + * await client.unstable.companies.attachContactToACompany({ + * id: "id", + * company_id: "123" + * }) + */ + public attachContactToACompany( + request: Intercom.unstable.AttachContactToACompanyRequest, + requestOptions?: Companies.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__attachContactToACompany(request, requestOptions)); + } + + private async __attachContactToACompany( + request: Intercom.unstable.AttachContactToACompanyRequest, + requestOptions?: Companies.RequestOptions, + ): Promise> { + const { id, ..._body } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${encodeURIComponent(id)}/companies`, + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: _body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Company, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /contacts/{id}/companies."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can detach a company from a single contact. + * + * @param {Intercom.unstable.DetachContactFromACompanyRequest} request + * @param {Companies.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.companies.detachContactFromACompany({ + * contact_id: "58a430d35458202d41b1e65b", + * id: "58a430d35458202d41b1e65b" + * }) + */ + public detachContactFromACompany( + request: Intercom.unstable.DetachContactFromACompanyRequest, + requestOptions?: Companies.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__detachContactFromACompany(request, requestOptions)); + } + + private async __detachContactFromACompany( + request: Intercom.unstable.DetachContactFromACompanyRequest, + requestOptions?: Companies.RequestOptions, + ): Promise> { + const { contact_id: contactId, id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${encodeURIComponent(contactId)}/companies/${encodeURIComponent(id)}`, + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Company, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling DELETE /contacts/{contact_id}/companies/{id}.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["INTERCOM_API_KEY"]; + if (bearer == null) { + throw new errors.IntercomError({ + message: + "Please specify a bearer by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", + }); + } + + return `Bearer ${bearer}`; + } +} diff --git a/src/api/resources/unstable/resources/companies/client/index.ts b/src/api/resources/unstable/resources/companies/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/api/resources/unstable/resources/companies/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/unstable/resources/companies/client/requests/AttachContactToACompanyRequest.ts b/src/api/resources/unstable/resources/companies/client/requests/AttachContactToACompanyRequest.ts new file mode 100644 index 00000000..d82657ba --- /dev/null +++ b/src/api/resources/unstable/resources/companies/client/requests/AttachContactToACompanyRequest.ts @@ -0,0 +1,31 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "id", + * company_id: "6762f09a1bb69f9f2193bb34" + * } + * + * @example + * { + * id: "id", + * company_id: "58a430d35458202d41b1e65b" + * } + * + * @example + * { + * id: "id", + * company_id: "123" + * } + */ +export interface AttachContactToACompanyRequest { + /** + * The unique identifier for the contact which is given by Intercom + */ + id: string; + /** The unique identifier for the company which is given by Intercom */ + company_id: string; +} diff --git a/src/api/resources/unstable/resources/companies/client/requests/DeleteCompanyRequest.ts b/src/api/resources/unstable/resources/companies/client/requests/DeleteCompanyRequest.ts new file mode 100644 index 00000000..abe9080b --- /dev/null +++ b/src/api/resources/unstable/resources/companies/client/requests/DeleteCompanyRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" + * } + */ +export interface DeleteCompanyRequest { + /** + * The unique identifier for the company which is given by Intercom + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/companies/client/requests/DetachContactFromACompanyRequest.ts b/src/api/resources/unstable/resources/companies/client/requests/DetachContactFromACompanyRequest.ts new file mode 100644 index 00000000..3cbcb14d --- /dev/null +++ b/src/api/resources/unstable/resources/companies/client/requests/DetachContactFromACompanyRequest.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * contact_id: "58a430d35458202d41b1e65b", + * id: "58a430d35458202d41b1e65b" + * } + */ +export interface DetachContactFromACompanyRequest { + /** + * The unique identifier for the contact which is given by Intercom + */ + contact_id: string; + /** + * The unique identifier for the company which is given by Intercom + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/companies/client/requests/ListAllCompaniesRequest.ts b/src/api/resources/unstable/resources/companies/client/requests/ListAllCompaniesRequest.ts new file mode 100644 index 00000000..0829eab0 --- /dev/null +++ b/src/api/resources/unstable/resources/companies/client/requests/ListAllCompaniesRequest.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * order: "desc" + * } + */ +export interface ListAllCompaniesRequest { + /** + * The page of results to fetch. Defaults to first page + */ + page?: number; + /** + * How many results to return per page. Defaults to 15 + */ + per_page?: number; + /** + * `asc` or `desc`. Return the companies in ascending or descending order. Defaults to desc + */ + order?: string; +} diff --git a/src/api/resources/unstable/resources/companies/client/requests/ListAttachedContactsRequest.ts b/src/api/resources/unstable/resources/companies/client/requests/ListAttachedContactsRequest.ts new file mode 100644 index 00000000..0dc176ea --- /dev/null +++ b/src/api/resources/unstable/resources/companies/client/requests/ListAttachedContactsRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" + * } + */ +export interface ListAttachedContactsRequest { + /** + * The unique identifier for the company which is given by Intercom + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/companies/client/requests/ListAttachedSegmentsForCompaniesRequest.ts b/src/api/resources/unstable/resources/companies/client/requests/ListAttachedSegmentsForCompaniesRequest.ts new file mode 100644 index 00000000..3e2c05a4 --- /dev/null +++ b/src/api/resources/unstable/resources/companies/client/requests/ListAttachedSegmentsForCompaniesRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" + * } + */ +export interface ListAttachedSegmentsForCompaniesRequest { + /** + * The unique identifier for the company which is given by Intercom + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/companies/client/requests/RetrieveACompanyByIdRequest.ts b/src/api/resources/unstable/resources/companies/client/requests/RetrieveACompanyByIdRequest.ts new file mode 100644 index 00000000..8b4afb24 --- /dev/null +++ b/src/api/resources/unstable/resources/companies/client/requests/RetrieveACompanyByIdRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" + * } + */ +export interface RetrieveACompanyByIdRequest { + /** + * The unique identifier for the company which is given by Intercom + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/companies/client/requests/RetrieveCompanyRequest.ts b/src/api/resources/unstable/resources/companies/client/requests/RetrieveCompanyRequest.ts new file mode 100644 index 00000000..557a2e00 --- /dev/null +++ b/src/api/resources/unstable/resources/companies/client/requests/RetrieveCompanyRequest.ts @@ -0,0 +1,39 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * name: "my company", + * company_id: "12345", + * tag_id: "678910", + * segment_id: "98765" + * } + */ +export interface RetrieveCompanyRequest { + /** + * The `name` of the company to filter by. + */ + name?: string; + /** + * The `company_id` of the company to filter by. + */ + company_id?: string; + /** + * The `tag_id` of the company to filter by. + */ + tag_id?: string; + /** + * The `segment_id` of the company to filter by. + */ + segment_id?: string; + /** + * The page of results to fetch. Defaults to first page + */ + page?: number; + /** + * How many results to display per page. Defaults to 15 + */ + per_page?: number; +} diff --git a/src/api/resources/unstable/resources/companies/client/requests/ScrollOverAllCompaniesRequest.ts b/src/api/resources/unstable/resources/companies/client/requests/ScrollOverAllCompaniesRequest.ts new file mode 100644 index 00000000..9d7a6877 --- /dev/null +++ b/src/api/resources/unstable/resources/companies/client/requests/ScrollOverAllCompaniesRequest.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + */ +export interface ScrollOverAllCompaniesRequest { + /** + * + */ + scroll_param?: string; +} diff --git a/src/api/resources/unstable/resources/companies/client/requests/UpdateCompanyRequest.ts b/src/api/resources/unstable/resources/companies/client/requests/UpdateCompanyRequest.ts new file mode 100644 index 00000000..1b2d26a4 --- /dev/null +++ b/src/api/resources/unstable/resources/companies/client/requests/UpdateCompanyRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "5f4d3c1c-7b1b-4d7d-a97e-6095715c6632" + * } + */ +export interface UpdateCompanyRequest { + /** + * The unique identifier for the company which is given by Intercom + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/companies/client/requests/index.ts b/src/api/resources/unstable/resources/companies/client/requests/index.ts new file mode 100644 index 00000000..2db00d94 --- /dev/null +++ b/src/api/resources/unstable/resources/companies/client/requests/index.ts @@ -0,0 +1,10 @@ +export { type RetrieveCompanyRequest } from "./RetrieveCompanyRequest"; +export { type RetrieveACompanyByIdRequest } from "./RetrieveACompanyByIdRequest"; +export { type UpdateCompanyRequest } from "./UpdateCompanyRequest"; +export { type DeleteCompanyRequest } from "./DeleteCompanyRequest"; +export { type ListAttachedContactsRequest } from "./ListAttachedContactsRequest"; +export { type ListAttachedSegmentsForCompaniesRequest } from "./ListAttachedSegmentsForCompaniesRequest"; +export { type ListAllCompaniesRequest } from "./ListAllCompaniesRequest"; +export { type ScrollOverAllCompaniesRequest } from "./ScrollOverAllCompaniesRequest"; +export { type AttachContactToACompanyRequest } from "./AttachContactToACompanyRequest"; +export { type DetachContactFromACompanyRequest } from "./DetachContactFromACompanyRequest"; diff --git a/src/api/resources/unstable/resources/companies/index.ts b/src/api/resources/unstable/resources/companies/index.ts new file mode 100644 index 00000000..c9240f83 --- /dev/null +++ b/src/api/resources/unstable/resources/companies/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/unstable/resources/companies/types/Company.ts b/src/api/resources/unstable/resources/companies/types/Company.ts new file mode 100644 index 00000000..ebce2925 --- /dev/null +++ b/src/api/resources/unstable/resources/companies/types/Company.ts @@ -0,0 +1,77 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +/** + * Companies allow you to represent organizations using your product. Each company will have its own description and be associated with contacts. You can fetch, create, update and list companies. + */ +export interface Company { + /** Value is `company` */ + type?: "company"; + /** The Intercom defined id representing the company. */ + id?: string; + /** The name of the company. */ + name?: string; + /** The Intercom defined code of the workspace the company is associated to. */ + app_id?: string; + plan?: Company.Plan; + /** The company id you have defined for the company. */ + company_id?: string; + /** The time the company was created by you. */ + remote_created_at?: number; + /** The time the company was added in Intercom. */ + created_at?: number; + /** The last time the company was updated. */ + updated_at?: number; + /** The time the company last recorded making a request. */ + last_request_at?: number; + /** The number of employees in the company. */ + size?: number; + /** The URL for the company website. */ + website?: string; + /** The industry that the company operates in. */ + industry?: string; + /** How much revenue the company generates for your business. */ + monthly_spend?: number; + /** How many sessions the company has recorded. */ + session_count?: number; + /** The number of users in the company. */ + user_count?: number; + /** The custom attributes you have set on the company. */ + custom_attributes?: Record; + /** The list of tags associated with the company */ + tags?: Company.Tags; + /** The list of segments associated with the company */ + segments?: Company.Segments; +} + +export namespace Company { + export interface Plan { + /** Value is always "plan" */ + type?: string; + /** The id of the plan */ + id?: string; + /** The name of the plan */ + name?: string; + } + + /** + * The list of tags associated with the company + */ + export interface Tags { + /** The type of the object */ + type?: "tag.list"; + tags?: unknown[]; + } + + /** + * The list of segments associated with the company + */ + export interface Segments { + /** The type of the object */ + type?: "segment.list"; + segments?: Intercom.unstable.Segment[]; + } +} diff --git a/src/api/resources/unstable/resources/companies/types/index.ts b/src/api/resources/unstable/resources/companies/types/index.ts new file mode 100644 index 00000000..d15bbd39 --- /dev/null +++ b/src/api/resources/unstable/resources/companies/types/index.ts @@ -0,0 +1 @@ +export * from "./Company"; diff --git a/src/api/resources/unstable/resources/contacts/client/Client.ts b/src/api/resources/unstable/resources/contacts/client/Client.ts new file mode 100644 index 00000000..432c912e --- /dev/null +++ b/src/api/resources/unstable/resources/contacts/client/Client.ts @@ -0,0 +1,1536 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace Contacts { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + } +} + +/** + * Everything about your contacts + */ +export class Contacts { + constructor(protected readonly _options: Contacts.Options = {}) {} + + /** + * You can fetch a list of companies that are associated to a contact. + * + * @param {Intercom.unstable.ListCompaniesForAContactRequest} request + * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.contacts.listCompaniesForAContact({ + * id: "63a07ddf05a32042dffac965" + * }) + */ + public listCompaniesForAContact( + request: Intercom.unstable.ListCompaniesForAContactRequest, + requestOptions?: Contacts.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listCompaniesForAContact(request, requestOptions)); + } + + private async __listCompaniesForAContact( + request: Intercom.unstable.ListCompaniesForAContactRequest, + requestOptions?: Contacts.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${encodeURIComponent(id)}/companies`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.ContactAttachedCompanies, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /contacts/{id}/companies."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can fetch a list of segments that are associated to a contact. + * + * @param {Intercom.unstable.ListSegmentsForAContactRequest} request + * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.contacts.listSegmentsForAContact({ + * contact_id: "63a07ddf05a32042dffac965" + * }) + */ + public listSegmentsForAContact( + request: Intercom.unstable.ListSegmentsForAContactRequest, + requestOptions?: Contacts.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listSegmentsForAContact(request, requestOptions)); + } + + private async __listSegmentsForAContact( + request: Intercom.unstable.ListSegmentsForAContactRequest, + requestOptions?: Contacts.RequestOptions, + ): Promise> { + const { contact_id: contactId } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${encodeURIComponent(contactId)}/segments`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.ContactSegments, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling GET /contacts/{contact_id}/segments.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can fetch a list of subscription types that are attached to a contact. These can be subscriptions that a user has 'opted-in' to or has 'opted-out' from, depending on the subscription type. + * This will return a list of Subscription Type objects that the contact is associated with. + * + * The data property will show a combined list of: + * + * 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. + * + * @param {Intercom.unstable.ListSubscriptionsForAContactRequest} request + * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.contacts.listSubscriptionsForAContact({ + * contact_id: "63a07ddf05a32042dffac965" + * }) + */ + public listSubscriptionsForAContact( + request: Intercom.unstable.ListSubscriptionsForAContactRequest, + requestOptions?: Contacts.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listSubscriptionsForAContact(request, requestOptions)); + } + + private async __listSubscriptionsForAContact( + request: Intercom.unstable.ListSubscriptionsForAContactRequest, + requestOptions?: Contacts.RequestOptions, + ): Promise> { + const { contact_id: contactId } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${encodeURIComponent(contactId)}/subscriptions`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.SubscriptionTypeList, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling GET /contacts/{contact_id}/subscriptions.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can fetch a list of all tags that are attached to a specific contact. + * + * @param {Intercom.unstable.ListTagsForAContactRequest} request + * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.contacts.listTagsForAContact({ + * contact_id: "63a07ddf05a32042dffac965" + * }) + */ + public listTagsForAContact( + request: Intercom.unstable.ListTagsForAContactRequest, + requestOptions?: Contacts.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listTagsForAContact(request, requestOptions)); + } + + private async __listTagsForAContact( + request: Intercom.unstable.ListTagsForAContactRequest, + requestOptions?: Contacts.RequestOptions, + ): Promise> { + const { contact_id: contactId } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${encodeURIComponent(contactId)}/tags`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.TagList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /contacts/{contact_id}/tags."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can fetch the details of a single contact. + * + * @param {Intercom.unstable.ShowContactRequest} request + * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.contacts.showContact({ + * id: "63a07ddf05a32042dffac965" + * }) + */ + public showContact( + request: Intercom.unstable.ShowContactRequest, + requestOptions?: Contacts.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__showContact(request, requestOptions)); + } + + private async __showContact( + request: Intercom.unstable.ShowContactRequest, + requestOptions?: Contacts.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${encodeURIComponent(id)}`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.ShowContactResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /contacts/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can update an existing contact (ie. user or lead). + * + * {% admonition type="info" %} + * This endpoint handles both **contact updates** and **custom object associations**. + * + * See _`update a contact with an association to a custom object instance`_ in the request/response examples to see the custom object association format. + * {% /admonition %} + * + * @param {Intercom.unstable.UpdateContactRequest} request + * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.contacts.updateContact({ + * id: "63a07ddf05a32042dffac965", + * email: "joebloggs@intercom.io", + * name: "joe bloggs" + * }) + * + * @example + * await client.unstable.contacts.updateContact({ + * id: "63a07ddf05a32042dffac965", + * custom_attributes: { + * "order": [ + * "21" + * ] + * } + * }) + */ + public updateContact( + request: Intercom.unstable.UpdateContactRequest, + requestOptions?: Contacts.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__updateContact(request, requestOptions)); + } + + private async __updateContact( + request: Intercom.unstable.UpdateContactRequest, + requestOptions?: Contacts.RequestOptions, + ): Promise> { + const { id, ..._body } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${encodeURIComponent(id)}`, + ), + method: "PUT", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: _body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.UpdateContactResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling PUT /contacts/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can delete a single contact. + * + * @param {Intercom.unstable.DeleteContactRequest} request + * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.contacts.deleteContact({ + * id: "id" + * }) + */ + public deleteContact( + request: Intercom.unstable.DeleteContactRequest, + requestOptions?: Contacts.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteContact(request, requestOptions)); + } + + private async __deleteContact( + request: Intercom.unstable.DeleteContactRequest, + requestOptions?: Contacts.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${encodeURIComponent(id)}`, + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.ContactDeleted, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling DELETE /contacts/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can merge a contact with a `role` of `lead` into a contact with a `role` of `user`. + * + * @param {Intercom.unstable.MergeContactsRequest} request + * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.contacts.mergeContact({ + * from: "6762f0d51bb69f9f2193bb7f", + * into: "6762f0d51bb69f9f2193bb80" + * }) + */ + public mergeContact( + request: Intercom.unstable.MergeContactsRequest = {}, + requestOptions?: Contacts.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__mergeContact(request, requestOptions)); + } + + private async __mergeContact( + request: Intercom.unstable.MergeContactsRequest = {}, + requestOptions?: Contacts.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "contacts/merge", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.MergeContactResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /contacts/merge."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can search for multiple contacts by the value of their attributes in order to fetch exactly who you want. + * + * To search for contacts, you need to send a `POST` request to `https://api.intercom.io/contacts/search`. + * + * This will accept a query object in the body which will define your filters in order to search for contacts. + * + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the `AND` and `OR` operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is `50` results per page. + * See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param. + * {% /admonition %} + * ### Contact Creation Delay + * + * If a contact has recently been created, there is a possibility that it will not yet be available when searching. This means that it may not appear in the response. This delay can take a few minutes. If you need to be instantly notified it is recommended to use webhooks and iterate to see if they match your search filters. + * + * ### Nesting & Limitations + * + * You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be: + * * There's a limit of max 2 nested filters + * * There's a limit of max 15 filters for each AND or OR group + * + * ### Searching for Timestamp Fields + * + * All timestamp fields (created_at, updated_at etc.) are indexed as Dates for Contact Search queries; Datetime queries are not currently supported. This means you can only query for timestamp fields by day - not hour, minute or second. + * For example, if you search for all Contacts with a created_at value greater (>) than 1577869200 (the UNIX timestamp for January 1st, 2020 9:00 AM), that will be interpreted as 1577836800 (January 1st, 2020 12:00 AM). The search results will then include Contacts created from January 2nd, 2020 12:00 AM onwards. + * If you'd like to get contacts created on January 1st, 2020 you should search with a created_at value equal (=) to 1577836800 (January 1st, 2020 12:00 AM). + * This behaviour applies only to timestamps used in search queries. The search results will still contain the full UNIX timestamp and be sorted accordingly. + * + * ### Accepted Fields + * + * Most key listed as part of the Contacts Model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foorbar"`). + * + * | Field | Type | + * | ---------------------------------- | ------------------------------ | + * | id | String | + * | role | String
Accepts user or lead | + * | name | String | + * | avatar | String | + * | owner_id | Integer | + * | email | String | + * | email_domain | String | + * | phone | String | + * | formatted_phone | String | + * | external_id | String | + * | created_at | Date (UNIX Timestamp) | + * | signed_up_at | Date (UNIX Timestamp) | + * | updated_at | Date (UNIX Timestamp) | + * | last_seen_at | Date (UNIX Timestamp) | + * | last_contacted_at | Date (UNIX Timestamp) | + * | last_replied_at | Date (UNIX Timestamp) | + * | last_email_opened_at | Date (UNIX Timestamp) | + * | last_email_clicked_at | Date (UNIX Timestamp) | + * | language_override | String | + * | browser | String | + * | browser_language | String | + * | os | String | + * | location.country | String | + * | location.region | String | + * | location.city | String | + * | unsubscribed_from_emails | Boolean | + * | marked_email_as_spam | Boolean | + * | has_hard_bounced | Boolean | + * | ios_last_seen_at | Date (UNIX Timestamp) | + * | ios_app_version | String | + * | ios_device | String | + * | ios_app_device | String | + * | ios_os_version | String | + * | ios_app_name | String | + * | ios_sdk_version | String | + * | android_last_seen_at | Date (UNIX Timestamp) | + * | android_app_version | String | + * | android_device | String | + * | android_app_name | String | + * | andoid_sdk_version | String | + * | segment_id | String | + * | tag_id | String | + * | custom_attributes.{attribute_name} | String | + * + * ### Accepted Operators + * + * {% admonition type="warning" name="Searching based on `created_at`" %} + * You cannot use the `<=` or `>=` operators to search by `created_at`. + * {% /admonition %} + * + * The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). The operator has to be compatible with the field's type (eg. you cannot search with `>` for a given string value as it's only compatible for integer's and dates). + * + * | Operator | Valid Types | Description | + * | :------- | :------------------------------- | :--------------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In
Shortcut for `OR` queries
Values must be in Array | + * | NIN | All | Not In
Shortcut for `OR !` queries
Values must be in Array | + * | > | Integer
Date (UNIX Timestamp) | Greater than | + * | < | Integer
Date (UNIX Timestamp) | Lower than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With | + * + * @param {Intercom.unstable.SearchRequest} request + * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.contacts.searchContacts({ + * query: { + * operator: "AND", + * value: [{ + * field: "created_at", + * operator: ">", + * value: "1306054154" + * }] + * }, + * pagination: { + * per_page: 5 + * } + * }) + */ + public searchContacts( + request: Intercom.unstable.SearchRequest, + requestOptions?: Contacts.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__searchContacts(request, requestOptions)); + } + + private async __searchContacts( + request: Intercom.unstable.SearchRequest, + requestOptions?: Contacts.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "contacts/search", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.ContactList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /contacts/search."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can fetch a list of all contacts (ie. users or leads) in your workspace. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is `50` results per page. + * 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 %} + * + * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.contacts.listContacts() + */ + public listContacts( + requestOptions?: Contacts.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listContacts(requestOptions)); + } + + private async __listContacts( + requestOptions?: Contacts.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "contacts", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.ContactList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /contacts."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can create a new contact (ie. user or lead). + * + * @param {Intercom.CreateContactRequestTwo} request + * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.contacts.createContact({ + * "email": "joebloggs@intercom.io" + * }) + */ + public createContact( + request?: Intercom.CreateContactRequestTwo, + requestOptions?: Contacts.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createContact(request, requestOptions)); + } + + private async __createContact( + request?: Intercom.CreateContactRequestTwo, + requestOptions?: Contacts.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "contacts", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.CreateContactResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /contacts."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can fetch the details of a single contact by external ID. Note that this endpoint only supports users and not leads. + * + * @param {Intercom.unstable.ShowContactByExternalIdRequest} request + * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.contacts.showContactByExternalId({ + * external_id: "cdd29344-5e0c-4ef0-ac56-f9ba2979bc27" + * }) + */ + public showContactByExternalId( + request: Intercom.unstable.ShowContactByExternalIdRequest, + requestOptions?: Contacts.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__showContactByExternalId(request, requestOptions)); + } + + private async __showContactByExternalId( + request: Intercom.unstable.ShowContactByExternalIdRequest, + requestOptions?: Contacts.RequestOptions, + ): Promise> { + const { external_id: externalId } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/find_by_external_id/${encodeURIComponent(externalId)}`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.ShowContactByExternalIdResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling GET /contacts/find_by_external_id/{external_id}.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can archive a single contact. + * + * @param {Intercom.unstable.ArchiveContactRequest} request + * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration. + * + * @example + * await client.unstable.contacts.archiveContact({ + * id: "63a07ddf05a32042dffac965" + * }) + */ + public archiveContact( + request: Intercom.unstable.ArchiveContactRequest, + requestOptions?: Contacts.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__archiveContact(request, requestOptions)); + } + + private async __archiveContact( + request: Intercom.unstable.ArchiveContactRequest, + requestOptions?: Contacts.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${encodeURIComponent(id)}/archive`, + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.ContactArchived, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /contacts/{id}/archive."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can unarchive a single contact. + * + * @param {Intercom.unstable.UnarchiveContactRequest} request + * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration. + * + * @example + * await client.unstable.contacts.unarchiveContact({ + * id: "63a07ddf05a32042dffac965" + * }) + */ + public unarchiveContact( + request: Intercom.unstable.UnarchiveContactRequest, + requestOptions?: Contacts.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__unarchiveContact(request, requestOptions)); + } + + private async __unarchiveContact( + request: Intercom.unstable.UnarchiveContactRequest, + requestOptions?: Contacts.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${encodeURIComponent(id)}/unarchive`, + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.ContactUnarchived, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /contacts/{id}/unarchive."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * Block a single contact.
**Note:** conversations of the contact will also be archived during the process.
More details in [FAQ How do I block Inbox spam?](https://www.intercom.com/help/en/articles/8838656-inbox-faqs) + * + * @param {Intercom.unstable.BlockContactRequest} request + * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration. + * + * @example + * await client.unstable.contacts.blockContact({ + * id: "63a07ddf05a32042dffac965" + * }) + */ + public blockContact( + request: Intercom.unstable.BlockContactRequest, + requestOptions?: Contacts.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__blockContact(request, requestOptions)); + } + + private async __blockContact( + request: Intercom.unstable.BlockContactRequest, + requestOptions?: Contacts.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${encodeURIComponent(id)}/block`, + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.ContactBlocked, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /contacts/{id}/block."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["INTERCOM_API_KEY"]; + if (bearer == null) { + throw new errors.IntercomError({ + message: + "Please specify a bearer by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", + }); + } + + return `Bearer ${bearer}`; + } +} diff --git a/src/api/resources/unstable/resources/contacts/client/index.ts b/src/api/resources/unstable/resources/contacts/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/api/resources/unstable/resources/contacts/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/unstable/resources/contacts/client/requests/ArchiveContactRequest.ts b/src/api/resources/unstable/resources/contacts/client/requests/ArchiveContactRequest.ts new file mode 100644 index 00000000..f44c40c3 --- /dev/null +++ b/src/api/resources/unstable/resources/contacts/client/requests/ArchiveContactRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "63a07ddf05a32042dffac965" + * } + */ +export interface ArchiveContactRequest { + /** + * id + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/contacts/client/requests/BlockContactRequest.ts b/src/api/resources/unstable/resources/contacts/client/requests/BlockContactRequest.ts new file mode 100644 index 00000000..497e928a --- /dev/null +++ b/src/api/resources/unstable/resources/contacts/client/requests/BlockContactRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "63a07ddf05a32042dffac965" + * } + */ +export interface BlockContactRequest { + /** + * id + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/contacts/client/requests/DeleteContactRequest.ts b/src/api/resources/unstable/resources/contacts/client/requests/DeleteContactRequest.ts new file mode 100644 index 00000000..e70f0504 --- /dev/null +++ b/src/api/resources/unstable/resources/contacts/client/requests/DeleteContactRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "id" + * } + */ +export interface DeleteContactRequest { + /** + * id + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/contacts/client/requests/ListCompaniesForAContactRequest.ts b/src/api/resources/unstable/resources/contacts/client/requests/ListCompaniesForAContactRequest.ts new file mode 100644 index 00000000..af4ebe19 --- /dev/null +++ b/src/api/resources/unstable/resources/contacts/client/requests/ListCompaniesForAContactRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "63a07ddf05a32042dffac965" + * } + */ +export interface ListCompaniesForAContactRequest { + /** + * The unique identifier for the contact which is given by Intercom + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/contacts/client/requests/ListSegmentsForAContactRequest.ts b/src/api/resources/unstable/resources/contacts/client/requests/ListSegmentsForAContactRequest.ts new file mode 100644 index 00000000..22e71773 --- /dev/null +++ b/src/api/resources/unstable/resources/contacts/client/requests/ListSegmentsForAContactRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * contact_id: "63a07ddf05a32042dffac965" + * } + */ +export interface ListSegmentsForAContactRequest { + /** + * The unique identifier for the contact which is given by Intercom + */ + contact_id: string; +} diff --git a/src/api/resources/unstable/resources/contacts/client/requests/ListSubscriptionsForAContactRequest.ts b/src/api/resources/unstable/resources/contacts/client/requests/ListSubscriptionsForAContactRequest.ts new file mode 100644 index 00000000..3e48e0c9 --- /dev/null +++ b/src/api/resources/unstable/resources/contacts/client/requests/ListSubscriptionsForAContactRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * contact_id: "63a07ddf05a32042dffac965" + * } + */ +export interface ListSubscriptionsForAContactRequest { + /** + * The unique identifier for the contact which is given by Intercom + */ + contact_id: string; +} diff --git a/src/api/resources/unstable/resources/contacts/client/requests/ListTagsForAContactRequest.ts b/src/api/resources/unstable/resources/contacts/client/requests/ListTagsForAContactRequest.ts new file mode 100644 index 00000000..f91dffdc --- /dev/null +++ b/src/api/resources/unstable/resources/contacts/client/requests/ListTagsForAContactRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * contact_id: "63a07ddf05a32042dffac965" + * } + */ +export interface ListTagsForAContactRequest { + /** + * The unique identifier for the contact which is given by Intercom + */ + contact_id: string; +} diff --git a/src/api/resources/unstable/resources/contacts/client/requests/MergeContactsRequest.ts b/src/api/resources/unstable/resources/contacts/client/requests/MergeContactsRequest.ts new file mode 100644 index 00000000..a9009e6a --- /dev/null +++ b/src/api/resources/unstable/resources/contacts/client/requests/MergeContactsRequest.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * from: "6762f0d51bb69f9f2193bb7f", + * into: "6762f0d51bb69f9f2193bb80" + * } + */ +export interface MergeContactsRequest { + /** The unique identifier for the contact to merge away from. Must be a lead. */ + from?: string; + /** The unique identifier for the contact to merge into. Must be a user. */ + into?: string; +} diff --git a/src/api/resources/unstable/resources/contacts/client/requests/ShowContactByExternalIdRequest.ts b/src/api/resources/unstable/resources/contacts/client/requests/ShowContactByExternalIdRequest.ts new file mode 100644 index 00000000..af3dff76 --- /dev/null +++ b/src/api/resources/unstable/resources/contacts/client/requests/ShowContactByExternalIdRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * external_id: "cdd29344-5e0c-4ef0-ac56-f9ba2979bc27" + * } + */ +export interface ShowContactByExternalIdRequest { + /** + * The external ID of the user that you want to retrieve + */ + external_id: string; +} diff --git a/src/api/resources/unstable/resources/contacts/client/requests/ShowContactRequest.ts b/src/api/resources/unstable/resources/contacts/client/requests/ShowContactRequest.ts new file mode 100644 index 00000000..6abbc7ab --- /dev/null +++ b/src/api/resources/unstable/resources/contacts/client/requests/ShowContactRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "63a07ddf05a32042dffac965" + * } + */ +export interface ShowContactRequest { + /** + * id + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/contacts/client/requests/UnarchiveContactRequest.ts b/src/api/resources/unstable/resources/contacts/client/requests/UnarchiveContactRequest.ts new file mode 100644 index 00000000..e6a5af5e --- /dev/null +++ b/src/api/resources/unstable/resources/contacts/client/requests/UnarchiveContactRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "63a07ddf05a32042dffac965" + * } + */ +export interface UnarchiveContactRequest { + /** + * id + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/contacts/client/requests/UpdateContactRequest.ts b/src/api/resources/unstable/resources/contacts/client/requests/UpdateContactRequest.ts new file mode 100644 index 00000000..b130cd58 --- /dev/null +++ b/src/api/resources/unstable/resources/contacts/client/requests/UpdateContactRequest.ts @@ -0,0 +1,50 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "63a07ddf05a32042dffac965", + * email: "joebloggs@intercom.io", + * name: "joe bloggs" + * } + * + * @example + * { + * id: "63a07ddf05a32042dffac965", + * custom_attributes: { + * "order": [ + * "21" + * ] + * } + * } + */ +export interface UpdateContactRequest { + /** + * id + */ + id: string; + /** The role of the contact. */ + role?: string; + /** A unique identifier for the contact which is given to Intercom */ + external_id?: string; + /** The contacts email */ + email?: string; + /** The contacts phone */ + phone?: string; + /** The contacts name */ + name?: string; + /** An image URL containing the avatar of a contact */ + avatar?: string; + /** The time specified for when a contact signed up */ + signed_up_at?: number; + /** The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually) */ + last_seen_at?: number; + /** The id of an admin that has been assigned account ownership of the contact */ + owner_id?: number; + /** Whether the contact is unsubscribed from emails */ + unsubscribed_from_emails?: boolean; + /** The custom attributes which are set for the contact */ + custom_attributes?: Record; +} diff --git a/src/api/resources/unstable/resources/contacts/client/requests/index.ts b/src/api/resources/unstable/resources/contacts/client/requests/index.ts new file mode 100644 index 00000000..2c00f2f2 --- /dev/null +++ b/src/api/resources/unstable/resources/contacts/client/requests/index.ts @@ -0,0 +1,12 @@ +export { type ListCompaniesForAContactRequest } from "./ListCompaniesForAContactRequest"; +export { type ListSegmentsForAContactRequest } from "./ListSegmentsForAContactRequest"; +export { type ListSubscriptionsForAContactRequest } from "./ListSubscriptionsForAContactRequest"; +export { type ListTagsForAContactRequest } from "./ListTagsForAContactRequest"; +export { type ShowContactRequest } from "./ShowContactRequest"; +export { type UpdateContactRequest } from "./UpdateContactRequest"; +export { type DeleteContactRequest } from "./DeleteContactRequest"; +export { type MergeContactsRequest } from "./MergeContactsRequest"; +export { type ShowContactByExternalIdRequest } from "./ShowContactByExternalIdRequest"; +export { type ArchiveContactRequest } from "./ArchiveContactRequest"; +export { type UnarchiveContactRequest } from "./UnarchiveContactRequest"; +export { type BlockContactRequest } from "./BlockContactRequest"; diff --git a/src/api/resources/unstable/resources/contacts/index.ts b/src/api/resources/unstable/resources/contacts/index.ts new file mode 100644 index 00000000..c9240f83 --- /dev/null +++ b/src/api/resources/unstable/resources/contacts/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/unstable/resources/contacts/types/Contact.ts b/src/api/resources/unstable/resources/contacts/types/Contact.ts new file mode 100644 index 00000000..156e327d --- /dev/null +++ b/src/api/resources/unstable/resources/contacts/types/Contact.ts @@ -0,0 +1,106 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +/** + * Contacts represent your leads and users in Intercom. + */ +export interface Contact { + /** The type of object. */ + type?: string; + /** The unique identifier for the contact which is given by Intercom. */ + id?: string; + /** The unique identifier for the contact which is provided by the Client. */ + external_id?: string; + /** The id of the workspace which the contact belongs to. */ + workspace_id?: string; + /** The role of the contact. */ + role?: string; + /** The contact's email. */ + email?: string; + /** The contact's email domain. */ + email_domain?: string; + /** The contacts phone. */ + phone?: string; + /** The contacts phone number normalized to the E164 format */ + formatted_phone?: string; + /** The contacts name. */ + name?: string; + /** The id of an admin that has been assigned account ownership of the contact. */ + owner_id?: number; + /** Whether the contact has had an email sent to them hard bounce. */ + has_hard_bounced?: boolean; + /** Whether the contact has marked an email sent to them as spam. */ + marked_email_as_spam?: boolean; + /** Whether the contact is unsubscribed from emails. */ + unsubscribed_from_emails?: boolean; + /** (UNIX timestamp) The time when the contact was created. */ + created_at?: number; + /** (UNIX timestamp) The time when the contact was last updated. */ + updated_at?: number; + /** (UNIX timestamp) The time specified for when a contact signed up. */ + signed_up_at?: number; + /** (UNIX timestamp) The time when the contact was last seen (either where the Intercom Messenger was installed or when specified manually). */ + last_seen_at?: number; + /** (UNIX timestamp) The time when the contact last messaged in. */ + last_replied_at?: number; + /** (UNIX timestamp) The time when the contact was last messaged. */ + last_contacted_at?: number; + /** (UNIX timestamp) The time when the contact last opened an email. */ + last_email_opened_at?: number; + /** (UNIX timestamp) The time when the contact last clicked a link in an email. */ + last_email_clicked_at?: number; + /** A preferred language setting for the contact, used by the Intercom Messenger even if their browser settings change. */ + language_override?: string; + /** The name of the browser which the contact is using. */ + browser?: string; + /** The version of the browser which the contact is using. */ + browser_version?: string; + /** The language set by the browser which the contact is using. */ + browser_language?: string; + /** The operating system which the contact is using. */ + os?: string; + /** The name of the Android app which the contact is using. */ + android_app_name?: string; + /** The version of the Android app which the contact is using. */ + android_app_version?: string; + /** The Android device which the contact is using. */ + android_device?: string; + /** The version of the Android OS which the contact is using. */ + android_os_version?: string; + /** The version of the Android SDK which the contact is using. */ + android_sdk_version?: string; + /** (UNIX timestamp) The time when the contact was last seen on an Android device. */ + android_last_seen_at?: number; + /** The name of the iOS app which the contact is using. */ + ios_app_name?: string; + /** The version of the iOS app which the contact is using. */ + ios_app_version?: string; + /** The iOS device which the contact is using. */ + ios_device?: string; + /** The version of iOS which the contact is using. */ + ios_os_version?: string; + /** The version of the iOS SDK which the contact is using. */ + ios_sdk_version?: string; + /** (UNIX timestamp) The last time the contact used the iOS app. */ + ios_last_seen_at?: number; + /** The custom attributes which are set for the contact. */ + custom_attributes?: Record; + avatar?: Contact.Avatar; + tags?: Intercom.unstable.ContactTags; + notes?: Intercom.unstable.ContactNotes; + companies?: Intercom.unstable.ContactCompanies; + location?: Intercom.unstable.ContactLocation; + social_profiles?: Intercom.unstable.ContactSocialProfiles; +} + +export namespace Contact { + export interface Avatar { + /** The type of object */ + type?: string; + /** An image URL containing the avatar of a contact. */ + image_url?: string; + } +} diff --git a/src/api/resources/unstable/resources/contacts/types/CreateContactResponse.ts b/src/api/resources/unstable/resources/contacts/types/CreateContactResponse.ts new file mode 100644 index 00000000..1455fa8f --- /dev/null +++ b/src/api/resources/unstable/resources/contacts/types/CreateContactResponse.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +export interface CreateContactResponse extends Intercom.unstable.Contact { + /** If the user has enabled push messaging. */ + enabled_push_messaging?: boolean; +} diff --git a/src/api/resources/unstable/resources/contacts/types/MergeContactResponse.ts b/src/api/resources/unstable/resources/contacts/types/MergeContactResponse.ts new file mode 100644 index 00000000..b67e7baa --- /dev/null +++ b/src/api/resources/unstable/resources/contacts/types/MergeContactResponse.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +export interface MergeContactResponse extends Intercom.unstable.Contact { + /** If the user has enabled push messaging. */ + enabled_push_messaging?: boolean; +} diff --git a/src/api/resources/unstable/resources/contacts/types/ShowContactByExternalIdResponse.ts b/src/api/resources/unstable/resources/contacts/types/ShowContactByExternalIdResponse.ts new file mode 100644 index 00000000..d11d1d83 --- /dev/null +++ b/src/api/resources/unstable/resources/contacts/types/ShowContactByExternalIdResponse.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +export interface ShowContactByExternalIdResponse extends Intercom.unstable.Contact { + /** If the user has enabled push messaging. */ + enabled_push_messaging?: boolean; +} diff --git a/src/api/resources/unstable/resources/contacts/types/ShowContactResponse.ts b/src/api/resources/unstable/resources/contacts/types/ShowContactResponse.ts new file mode 100644 index 00000000..58bc07cc --- /dev/null +++ b/src/api/resources/unstable/resources/contacts/types/ShowContactResponse.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +export interface ShowContactResponse extends Intercom.unstable.Contact { + /** If the user has enabled push messaging. */ + enabled_push_messaging?: boolean; +} diff --git a/src/api/resources/unstable/resources/contacts/types/UpdateContactResponse.ts b/src/api/resources/unstable/resources/contacts/types/UpdateContactResponse.ts new file mode 100644 index 00000000..8919485b --- /dev/null +++ b/src/api/resources/unstable/resources/contacts/types/UpdateContactResponse.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +export interface UpdateContactResponse extends Intercom.unstable.Contact { + /** If the user has enabled push messaging. */ + enabled_push_messaging?: boolean; +} diff --git a/src/api/resources/unstable/resources/contacts/types/index.ts b/src/api/resources/unstable/resources/contacts/types/index.ts new file mode 100644 index 00000000..12ec2438 --- /dev/null +++ b/src/api/resources/unstable/resources/contacts/types/index.ts @@ -0,0 +1,6 @@ +export * from "./ShowContactResponse"; +export * from "./UpdateContactResponse"; +export * from "./MergeContactResponse"; +export * from "./CreateContactResponse"; +export * from "./ShowContactByExternalIdResponse"; +export * from "./Contact"; diff --git a/src/api/resources/unstable/resources/conversations/client/Client.ts b/src/api/resources/unstable/resources/conversations/client/Client.ts new file mode 100644 index 00000000..87442ffe --- /dev/null +++ b/src/api/resources/unstable/resources/conversations/client/Client.ts @@ -0,0 +1,1553 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace Conversations { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + } +} + +/** + * Everything about your Conversations + */ +export class Conversations { + constructor(protected readonly _options: Conversations.Options = {}) {} + + /** + * You can fetch a list of all conversations. + * + * You can optionally request the result page size and the cursor to start after to fetch the result. + * {% admonition type="warning" name="Pagination" %} + * You can use pagination to limit the number of results returned. The default is `20` results per page. + * 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 %} + * + * @param {Intercom.unstable.ListConversationsRequest} request + * @param {Conversations.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.ForbiddenError} + * + * @example + * await client.unstable.conversations.listConversations() + */ + public listConversations( + request: Intercom.unstable.ListConversationsRequest = {}, + requestOptions?: Conversations.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listConversations(request, requestOptions)); + } + + private async __listConversations( + request: Intercom.unstable.ListConversationsRequest = {}, + requestOptions?: Conversations.RequestOptions, + ): Promise> { + const { per_page: perPage, starting_after: startingAfter } = request; + const _queryParams: Record = {}; + if (perPage != null) { + _queryParams["per_page"] = perPage.toString(); + } + + if (startingAfter != null) { + _queryParams["starting_after"] = startingAfter; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "conversations", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.ConversationList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.unstable.ForbiddenError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /conversations."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can create a conversation that has been initiated by a contact (ie. user or lead). + * The conversation can be an in-app message only. + * + * {% admonition type="info" name="Sending for visitors" %} + * You can also send a message from a visitor by specifying their `user_id` or `id` value in the `from` field, along with a `type` field value of `contact`. + * This visitor will be automatically converted to a contact with a lead role once the conversation is created. + * {% /admonition %} + * + * This will return the Message model that has been created. + * + * @param {Intercom.unstable.CreateConversationRequest} request + * @param {Conversations.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.ForbiddenError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.conversations.createConversation({ + * from: { + * type: "user", + * id: "6762f11b1bb69f9f2193bba3" + * }, + * body: "Hello there" + * }) + * + * @example + * await client.unstable.conversations.createConversation({ + * from: { + * type: "user", + * id: "123_doesnt_exist" + * }, + * body: "Hello there" + * }) + */ + public createConversation( + request: Intercom.unstable.CreateConversationRequest, + requestOptions?: Conversations.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createConversation(request, requestOptions)); + } + + private async __createConversation( + request: Intercom.unstable.CreateConversationRequest, + requestOptions?: Conversations.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "conversations", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Message, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.unstable.ForbiddenError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /conversations."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * + * You can fetch the details of a single conversation. + * + * This will return a single Conversation model with all its conversation parts. + * + * {% admonition type="warning" name="Hard limit of 500 parts" %} + * The maximum number of conversation parts that can be returned via the API is 500. If you have more than that we will return the 500 most recent conversation parts. + * {% /admonition %} + * + * 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). + * + * @param {Intercom.unstable.RetrieveConversationRequest} request + * @param {Conversations.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.ForbiddenError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.conversations.retrieveConversation({ + * id: 1, + * display_as: "plaintext" + * }) + */ + public retrieveConversation( + request: Intercom.unstable.RetrieveConversationRequest, + requestOptions?: Conversations.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveConversation(request, requestOptions)); + } + + private async __retrieveConversation( + request: Intercom.unstable.RetrieveConversationRequest, + requestOptions?: Conversations.RequestOptions, + ): Promise> { + const { id, display_as: displayAs } = request; + const _queryParams: Record = {}; + if (displayAs != null) { + _queryParams["display_as"] = displayAs; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `conversations/${encodeURIComponent(id)}`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Conversation, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.unstable.ForbiddenError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /conversations/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * + * You can update an existing conversation. + * + * {% admonition type="info" name="Replying and other actions" %} + * If you want to reply to a coveration or take an action such as assign, unassign, open, close or snooze, take a look at the reply and manage endpoints. + * {% /admonition %} + * + * {% admonition type="info" %} + * This endpoint handles both **conversation updates** and **custom object associations**. + * + * See _`update a conversation with an association to a custom object instance`_ in the request/response examples to see the custom object association format. + * {% /admonition %} + * + * @param {Intercom.unstable.UpdateConversationRequest} request + * @param {Conversations.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.ForbiddenError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.conversations.updateConversation({ + * id: 1, + * display_as: "plaintext", + * read: true, + * title: "new conversation title", + * custom_attributes: { + * "issue_type": "Billing", + * "priority": "High" + * } + * }) + * + * @example + * await client.unstable.conversations.updateConversation({ + * id: 1, + * display_as: "plaintext", + * custom_attributes: { + * "order": {} + * } + * }) + */ + public updateConversation( + request: Intercom.unstable.UpdateConversationRequest, + requestOptions?: Conversations.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__updateConversation(request, requestOptions)); + } + + private async __updateConversation( + request: Intercom.unstable.UpdateConversationRequest, + requestOptions?: Conversations.RequestOptions, + ): Promise> { + const { id, display_as: displayAs, ..._body } = request; + const _queryParams: Record = {}; + if (displayAs != null) { + _queryParams["display_as"] = displayAs; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `conversations/${encodeURIComponent(id)}`, + ), + method: "PUT", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + body: _body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Conversation, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.unstable.ForbiddenError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling PUT /conversations/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can delete a single conversation. + * + * @param {Intercom.unstable.DeleteConversationRequest} request + * @param {Conversations.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.ForbiddenError} + * + * @example + * await client.unstable.conversations.deleteConversation({ + * id: 1 + * }) + */ + public deleteConversation( + request: Intercom.unstable.DeleteConversationRequest, + requestOptions?: Conversations.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteConversation(request, requestOptions)); + } + + private async __deleteConversation( + request: Intercom.unstable.DeleteConversationRequest, + requestOptions?: Conversations.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `conversations/${encodeURIComponent(id)}`, + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.ConversationDeleted, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.unstable.ForbiddenError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling DELETE /conversations/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can search for multiple conversations by the value of their attributes in order to fetch exactly which ones you want. + * + * To search for conversations, you need to send a `POST` request to `https://api.intercom.io/conversations/search`. + * + * This will accept a query object in the body which will define your filters in order to search for conversations. + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the `AND` and `OR` operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is `20` results per page and maximum is `150`. + * See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param. + * {% /admonition %} + * + * ### Nesting & Limitations + * + * You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiple's there can be: + * - There's a limit of max 2 nested filters + * - There's a limit of max 15 filters for each AND or OR group + * + * ### Accepted Fields + * + * Most keys listed in the conversation model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foorbar"`). + * The `source.body` field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a `"I need support"` body - the query should contain a `=` operator with the value `"support"` for such conversation to be returned. A query with a `=` operator and a `"need support"` value will not yield a result. + * + * | Field | Type | + * | :---------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- | + * | id | String | + * | created_at | Date (UNIX timestamp) | + * | updated_at | Date (UNIX timestamp) | + * | source.type | String
Accepted fields are `conversation`, `email`, `facebook`, `instagram`, `phone_call`, `phone_switch`, `push`, `sms`, `twitter` and `whatsapp`. | + * | source.id | String | + * | source.delivered_as | String | + * | source.subject | String | + * | source.body | String | + * | source.author.id | String | + * | source.author.type | String | + * | source.author.name | String | + * | source.author.email | String | + * | source.url | String | + * | contact_ids | String | + * | teammate_ids | String | + * | admin_assignee_id | String | + * | team_assignee_id | String | + * | channel_initiated | String | + * | open | Boolean | + * | read | Boolean | + * | state | String | + * | waiting_since | Date (UNIX timestamp) | + * | snoozed_until | Date (UNIX timestamp) | + * | tag_ids | String | + * | priority | String | + * | statistics.time_to_assignment | Integer | + * | statistics.time_to_admin_reply | Integer | + * | statistics.time_to_first_close | Integer | + * | statistics.time_to_last_close | Integer | + * | statistics.median_time_to_reply | Integer | + * | statistics.first_contact_reply_at | Date (UNIX timestamp) | + * | statistics.first_assignment_at | Date (UNIX timestamp) | + * | statistics.first_admin_reply_at | Date (UNIX timestamp) | + * | statistics.first_close_at | Date (UNIX timestamp) | + * | statistics.last_assignment_at | Date (UNIX timestamp) | + * | statistics.last_assignment_admin_reply_at | Date (UNIX timestamp) | + * | statistics.last_contact_reply_at | Date (UNIX timestamp) | + * | statistics.last_admin_reply_at | Date (UNIX timestamp) | + * | statistics.last_close_at | Date (UNIX timestamp) | + * | statistics.last_closed_by_id | String | + * | statistics.count_reopens | Integer | + * | statistics.count_assignments | Integer | + * | statistics.count_conversation_parts | Integer | + * | conversation_rating.requested_at | Date (UNIX timestamp) | + * | conversation_rating.replied_at | Date (UNIX timestamp) | + * | conversation_rating.score | Integer | + * | conversation_rating.remark | String | + * | conversation_rating.contact_id | String | + * | conversation_rating.admin_d | String | + * | ai_agent_participated | Boolean | + * | ai_agent.resolution_state | String | + * | ai_agent.last_answer_type | String | + * | ai_agent.rating | Integer | + * | ai_agent.rating_remark | String | + * | ai_agent.source_type | String | + * | ai_agent.source_title | String | + * + * ### Accepted Operators + * + * The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). The operator has to be compatible with the field's type (eg. you cannot search with `>` for a given string value as it's only compatible for integer's and dates). + * + * | Operator | Valid Types | Description | + * | :------- | :----------------------------- | :----------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In Shortcut for `OR` queries Values most be in Array | + * | NIN | All | Not In Shortcut for `OR !` queries Values must be in Array | + * | > | Integer Date (UNIX Timestamp) | Greater (or equal) than | + * | < | Integer Date (UNIX Timestamp) | Lower (or equal) than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With | + * + * @param {Intercom.unstable.SearchRequest} request + * @param {Conversations.RequestOptions} requestOptions - Request-specific configuration. + * + * @example + * await client.unstable.conversations.searchConversations({ + * query: { + * operator: "AND", + * value: [{ + * field: "created_at", + * operator: ">", + * value: "1306054154" + * }] + * }, + * pagination: { + * per_page: 5 + * } + * }) + */ + public searchConversations( + request: Intercom.unstable.SearchRequest, + requestOptions?: Conversations.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__searchConversations(request, requestOptions)); + } + + private async __searchConversations( + request: Intercom.unstable.SearchRequest, + requestOptions?: Conversations.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "conversations/search", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.ConversationList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /conversations/search."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * 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 {Intercom.unstable.ReplyConversationRequest} request + * @param {Conversations.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.ForbiddenError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.conversations.replyConversation({ + * id: "123 or \"last\"", + * body: { + * message_type: "comment", + * type: "user", + * body: "Thanks again :)", + * intercom_user_id: "6762f1571bb69f9f2193bbbb" + * } + * }) + * + * @example + * await client.unstable.conversations.replyConversation({ + * id: "123 or \"last\"", + * body: { + * message_type: "note", + * type: "admin", + * body: "

An Unordered HTML List

  • Coffee
  • Tea
  • Milk

An Ordered HTML List

  1. Coffee
  2. Tea
  3. Milk
", + * admin_id: "3156780" + * } + * }) + * + * @example + * await client.unstable.conversations.replyConversation({ + * id: "123 or \"last\"", + * body: { + * message_type: "quick_reply", + * type: "admin", + * admin_id: "3156780", + * reply_options: [{ + * text: "Yes", + * uuid: "a5e1c524-5ddd-4c3e-9328-6bca5d6e3edb" + * }, { + * text: "No", + * uuid: "f4a98af1-be56-4948-a57e-e1a83f8484c6" + * }] + * } + * }) + * + * @example + * await client.unstable.conversations.replyConversation({ + * id: "123 or \"last\"", + * body: { + * message_type: "comment", + * type: "user", + * body: "body", + * reply_options: [{ + * text: "Yes", + * uuid: "a5e1c524-5ddd-4c3e-9328-6bca5d6e3edb" + * }], + * intercom_user_id: "6762f1621bb69f9f2193bbbe" + * } + * }) + * + * @example + * await client.unstable.conversations.replyConversation({ + * id: "123 or \"last\"", + * body: { + * message_type: "comment", + * type: "user", + * body: "Thanks again :)", + * intercom_user_id: "6762f1661bb69f9f2193bbbf" + * } + * }) + */ + public replyConversation( + request: Intercom.unstable.ReplyConversationRequest, + requestOptions?: Conversations.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__replyConversation(request, requestOptions)); + } + + private async __replyConversation( + request: Intercom.unstable.ReplyConversationRequest, + requestOptions?: Conversations.RequestOptions, + ): Promise> { + const { id, body: _body } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `conversations/${encodeURIComponent(id)}/reply`, + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: _body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Conversation, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.unstable.ForbiddenError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /conversations/{id}/reply."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * For managing conversations you can: + * - Close a conversation + * - Snooze a conversation to reopen on a future date + * - Open a conversation which is `snoozed` or `closed` + * - Assign a conversation to an admin and/or team. + * + * @param {Intercom.unstable.ManageConversationRequest} request + * @param {Conversations.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.ForbiddenError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.conversations.manageConversation({ + * id: "123", + * body: { + * message_type: "close", + * type: "admin", + * admin_id: "12345" + * } + * }) + * + * @example + * await client.unstable.conversations.manageConversation({ + * id: "123", + * body: { + * message_type: "snoozed", + * admin_id: "5017691", + * snoozed_until: 1673609604 + * } + * }) + * + * @example + * await client.unstable.conversations.manageConversation({ + * id: "123", + * body: { + * message_type: "open", + * admin_id: "5017690" + * } + * }) + * + * @example + * await client.unstable.conversations.manageConversation({ + * id: "123", + * body: { + * message_type: "assignment", + * type: "admin", + * admin_id: "12345", + * assignee_id: "4324241" + * } + * }) + */ + public manageConversation( + request: Intercom.unstable.ManageConversationRequest, + requestOptions?: Conversations.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__manageConversation(request, requestOptions)); + } + + private async __manageConversation( + request: Intercom.unstable.ManageConversationRequest, + requestOptions?: Conversations.RequestOptions, + ): Promise> { + const { id, body: _body } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `conversations/${encodeURIComponent(id)}/parts`, + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: _body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Conversation, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.unstable.ForbiddenError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /conversations/{id}/parts."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + * + * {% admonition type="warning" name="Contacts without an email" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with `role` set to `lead`. + * {% /admonition %} + * + * @param {Intercom.unstable.AttachContactToConversationRequest} request + * @param {Conversations.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.ForbiddenError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.conversations.attachContactToConversation({ + * id: "123", + * admin_id: "12345", + * customer: { + * intercom_user_id: "6762f19b1bb69f9f2193bbd4" + * } + * }) + * + * @example + * await client.unstable.conversations.attachContactToConversation({ + * id: "123", + * admin_id: "12345", + * customer: { + * intercom_user_id: "6762f19e1bb69f9f2193bbd5" + * } + * }) + */ + public attachContactToConversation( + request: Intercom.unstable.AttachContactToConversationRequest, + requestOptions?: Conversations.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__attachContactToConversation(request, requestOptions)); + } + + private async __attachContactToConversation( + request: Intercom.unstable.AttachContactToConversationRequest, + requestOptions?: Conversations.RequestOptions, + ): Promise> { + const { id, ..._body } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `conversations/${encodeURIComponent(id)}/customers`, + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: _body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Conversation, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.unstable.ForbiddenError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling POST /conversations/{id}/customers.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can add participants who are contacts to a conversation, on behalf of either another contact or an admin. + * + * {% admonition type="warning" name="Contacts without an email" %} + * If you add a contact via the email parameter and there is no user/lead found on that workspace with he given email, then we will create a new contact with `role` set to `lead`. + * {% /admonition %} + * + * @param {Intercom.unstable.DetachContactFromConversationRequest} request + * @param {Conversations.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.ForbiddenError} + * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.unstable.UnprocessableEntityError} + * + * @example + * await client.unstable.conversations.detachContactFromConversation({ + * conversation_id: "123", + * contact_id: "123", + * admin_id: "5017690" + * }) + */ + public detachContactFromConversation( + request: Intercom.unstable.DetachContactFromConversationRequest, + requestOptions?: Conversations.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__detachContactFromConversation(request, requestOptions)); + } + + private async __detachContactFromConversation( + request: Intercom.unstable.DetachContactFromConversationRequest, + requestOptions?: Conversations.RequestOptions, + ): Promise> { + const { conversation_id: conversationId, contact_id: contactId, ..._body } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `conversations/${encodeURIComponent(conversationId)}/customers/${encodeURIComponent(contactId)}`, + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: _body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Conversation, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.unstable.ForbiddenError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.unstable.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling DELETE /conversations/{conversation_id}/customers/{contact_id}.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can redact a conversation part or the source message of a conversation (as seen in the source object). + * + * {% admonition type="info" name="Redacting parts and messages" %} + * If you are redacting a conversation part, it must have a `body`. If you are redacting a source message, it must have been created by a contact. We will return a `conversation_part_not_redactable` error if these criteria are not met. + * {% /admonition %} + * + * @param {Intercom.unstable.RedactConversationRequest} request + * @param {Conversations.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.conversations.redactConversation({ + * type: "conversation_part", + * conversation_id: "19894788788", + * conversation_part_id: "19381789428" + * }) + * + * @example + * await client.unstable.conversations.redactConversation({ + * type: "conversation_part", + * conversation_id: "really_123_doesnt_exist", + * conversation_part_id: "really_123_doesnt_exist" + * }) + */ + public redactConversation( + request: Intercom.unstable.RedactConversationRequest, + requestOptions?: Conversations.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__redactConversation(request, requestOptions)); + } + + private async __redactConversation( + request: Intercom.unstable.RedactConversationRequest, + requestOptions?: Conversations.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "conversations/redact", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Conversation, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /conversations/redact."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can convert a conversation to a ticket. + * + * @param {Intercom.unstable.ConvertConversationToTicketRequest} request + * @param {Conversations.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.BadRequestError} + * + * @example + * await client.unstable.conversations.convertConversationToTicket({ + * id: 1, + * ticket_type_id: "53" + * }) + * + * @example + * await client.unstable.conversations.convertConversationToTicket({ + * id: 1, + * ticket_type_id: "54" + * }) + */ + public convertConversationToTicket( + request: Intercom.unstable.ConvertConversationToTicketRequest, + requestOptions?: Conversations.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__convertConversationToTicket(request, requestOptions)); + } + + private async __convertConversationToTicket( + request: Intercom.unstable.ConvertConversationToTicketRequest, + requestOptions?: Conversations.RequestOptions, + ): Promise> { + const { id, ..._body } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `conversations/${encodeURIComponent(id)}/convert`, + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: _body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Ticket | undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling POST /conversations/{id}/convert.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["INTERCOM_API_KEY"]; + if (bearer == null) { + throw new errors.IntercomError({ + message: + "Please specify a bearer by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", + }); + } + + return `Bearer ${bearer}`; + } +} diff --git a/src/api/resources/unstable/resources/conversations/client/index.ts b/src/api/resources/unstable/resources/conversations/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/api/resources/unstable/resources/conversations/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/unstable/resources/conversations/client/requests/AttachContactToConversationRequest.ts b/src/api/resources/unstable/resources/conversations/client/requests/AttachContactToConversationRequest.ts new file mode 100644 index 00000000..d887df62 --- /dev/null +++ b/src/api/resources/unstable/resources/conversations/client/requests/AttachContactToConversationRequest.ts @@ -0,0 +1,50 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../../index"; + +/** + * @example + * { + * id: "123", + * admin_id: "12345", + * customer: { + * intercom_user_id: "6762f19b1bb69f9f2193bbd4" + * } + * } + * + * @example + * { + * id: "123", + * admin_id: "12345", + * customer: { + * intercom_user_id: "6762f19e1bb69f9f2193bbd5" + * } + * } + */ +export interface AttachContactToConversationRequest { + /** + * The identifier for the conversation as given by Intercom. + */ + id: string; + /** The `id` of the admin who is adding the new participant. */ + admin_id?: string; + customer?: AttachContactToConversationRequest.Customer; +} + +export namespace AttachContactToConversationRequest { + export type Customer = + | { + intercom_user_id: string; + customer?: Intercom.unstable.CustomerRequest | undefined; + } + | { + user_id: string; + customer?: Intercom.unstable.CustomerRequest | undefined; + } + | { + email: string; + customer?: Intercom.unstable.CustomerRequest | undefined; + }; +} diff --git a/src/api/resources/unstable/resources/conversations/client/requests/ConvertConversationToTicketRequest.ts b/src/api/resources/unstable/resources/conversations/client/requests/ConvertConversationToTicketRequest.ts new file mode 100644 index 00000000..2e317651 --- /dev/null +++ b/src/api/resources/unstable/resources/conversations/client/requests/ConvertConversationToTicketRequest.ts @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../../index"; + +/** + * @example + * { + * id: 1, + * ticket_type_id: "53" + * } + * + * @example + * { + * id: 1, + * ticket_type_id: "54" + * } + */ +export interface ConvertConversationToTicketRequest { + /** + * The id of the conversation to target + */ + id: number; + /** The ID of the type of ticket you want to convert the conversation to */ + ticket_type_id: string; + attributes?: Intercom.unstable.TicketRequestCustomAttributes; +} diff --git a/src/api/resources/unstable/resources/conversations/client/requests/CreateConversationRequest.ts b/src/api/resources/unstable/resources/conversations/client/requests/CreateConversationRequest.ts new file mode 100644 index 00000000..93ec0636 --- /dev/null +++ b/src/api/resources/unstable/resources/conversations/client/requests/CreateConversationRequest.ts @@ -0,0 +1,51 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * from: { + * type: "user", + * id: "6762f11b1bb69f9f2193bba3" + * }, + * body: "Hello there" + * } + * + * @example + * { + * from: { + * type: "user", + * id: "123_doesnt_exist" + * }, + * body: "Hello there" + * } + */ +export interface CreateConversationRequest { + from: CreateConversationRequest.From; + /** The content of the message. HTML is not supported. */ + body: string; + /** The time the conversation was created as a UTC Unix timestamp. If not provided, the current time will be used. This field is only recommneded for migrating past conversations from another source into Intercom. */ + created_at?: number; +} + +export namespace CreateConversationRequest { + export interface From { + /** The role associated to the contact - user or lead. */ + type: From.Type; + /** The identifier for the contact which is given by Intercom. */ + id: string; + } + + export namespace From { + /** + * The role associated to the contact - user or lead. + */ + export type Type = "lead" | "user" | "contact"; + export const Type = { + Lead: "lead", + User: "user", + Contact: "contact", + } as const; + } +} diff --git a/src/api/resources/unstable/resources/conversations/client/requests/DeleteConversationRequest.ts b/src/api/resources/unstable/resources/conversations/client/requests/DeleteConversationRequest.ts new file mode 100644 index 00000000..9ef40c85 --- /dev/null +++ b/src/api/resources/unstable/resources/conversations/client/requests/DeleteConversationRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: 1 + * } + */ +export interface DeleteConversationRequest { + /** + * id + */ + id: number; +} diff --git a/src/api/resources/unstable/resources/conversations/client/requests/DetachContactFromConversationRequest.ts b/src/api/resources/unstable/resources/conversations/client/requests/DetachContactFromConversationRequest.ts new file mode 100644 index 00000000..e245b23d --- /dev/null +++ b/src/api/resources/unstable/resources/conversations/client/requests/DetachContactFromConversationRequest.ts @@ -0,0 +1,45 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * conversation_id: "123", + * contact_id: "123", + * admin_id: "5017690" + * } + * + * @example + * { + * conversation_id: "123", + * contact_id: "123", + * admin_id: "5017690" + * } + * + * @example + * { + * conversation_id: "123", + * contact_id: "123", + * admin_id: "5017690" + * } + * + * @example + * { + * conversation_id: "123", + * contact_id: "123", + * admin_id: "5017690" + * } + */ +export interface DetachContactFromConversationRequest { + /** + * The identifier for the conversation as given by Intercom. + */ + conversation_id: string; + /** + * The identifier for the contact as given by Intercom. + */ + contact_id: string; + /** The `id` of the admin who is performing the action. */ + admin_id: string; +} diff --git a/src/api/resources/unstable/resources/conversations/client/requests/ListConversationsRequest.ts b/src/api/resources/unstable/resources/conversations/client/requests/ListConversationsRequest.ts new file mode 100644 index 00000000..f3c7f741 --- /dev/null +++ b/src/api/resources/unstable/resources/conversations/client/requests/ListConversationsRequest.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + */ +export interface ListConversationsRequest { + /** + * How many results per page + */ + per_page?: number; + /** + * String used to get the next page of conversations. + */ + starting_after?: string; +} diff --git a/src/api/resources/unstable/resources/conversations/client/requests/ManageConversationRequest.ts b/src/api/resources/unstable/resources/conversations/client/requests/ManageConversationRequest.ts new file mode 100644 index 00000000..59c70d65 --- /dev/null +++ b/src/api/resources/unstable/resources/conversations/client/requests/ManageConversationRequest.ts @@ -0,0 +1,64 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../../index"; + +/** + * @example + * { + * id: "123", + * body: { + * message_type: "close", + * type: "admin", + * admin_id: "12345" + * } + * } + * + * @example + * { + * id: "123", + * body: { + * message_type: "snoozed", + * admin_id: "5017691", + * snoozed_until: 1673609604 + * } + * } + * + * @example + * { + * id: "123", + * body: { + * message_type: "open", + * admin_id: "5017690" + * } + * } + * + * @example + * { + * id: "123", + * body: { + * message_type: "assignment", + * type: "admin", + * admin_id: "12345", + * assignee_id: "4324241" + * } + * } + * + * @example + * { + * id: "123", + * body: { + * message_type: "close", + * type: "admin", + * admin_id: "12345" + * } + * } + */ +export interface ManageConversationRequest { + /** + * The identifier for the conversation as given by Intercom. + */ + id: string; + body: Intercom.unstable.ManageConversationRequestBody; +} diff --git a/src/api/resources/unstable/resources/conversations/client/requests/ReplyConversationRequest.ts b/src/api/resources/unstable/resources/conversations/client/requests/ReplyConversationRequest.ts new file mode 100644 index 00000000..fb35a919 --- /dev/null +++ b/src/api/resources/unstable/resources/conversations/client/requests/ReplyConversationRequest.ts @@ -0,0 +1,79 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../../index"; + +/** + * @example + * { + * id: "123 or \"last\"", + * body: { + * message_type: "comment", + * type: "user", + * body: "Thanks again :)", + * intercom_user_id: "6762f1571bb69f9f2193bbbb" + * } + * } + * + * @example + * { + * id: "123 or \"last\"", + * body: { + * message_type: "note", + * type: "admin", + * body: "

An Unordered HTML List

  • Coffee
  • Tea
  • Milk

An Ordered HTML List

  1. Coffee
  2. Tea
  3. Milk
", + * admin_id: "3156780" + * } + * } + * + * @example + * { + * id: "123 or \"last\"", + * body: { + * message_type: "quick_reply", + * type: "admin", + * admin_id: "3156780", + * reply_options: [{ + * text: "Yes", + * uuid: "a5e1c524-5ddd-4c3e-9328-6bca5d6e3edb" + * }, { + * text: "No", + * uuid: "f4a98af1-be56-4948-a57e-e1a83f8484c6" + * }] + * } + * } + * + * @example + * { + * id: "123 or \"last\"", + * body: { + * message_type: "comment", + * type: "user", + * body: "body", + * reply_options: [{ + * text: "Yes", + * uuid: "a5e1c524-5ddd-4c3e-9328-6bca5d6e3edb" + * }], + * intercom_user_id: "6762f1621bb69f9f2193bbbe" + * } + * } + * + * @example + * { + * id: "123 or \"last\"", + * body: { + * message_type: "comment", + * type: "user", + * body: "Thanks again :)", + * intercom_user_id: "6762f1661bb69f9f2193bbbf" + * } + * } + */ +export interface ReplyConversationRequest { + /** + * The Intercom provisioned identifier for the conversation or the string "last" to reply to the last part of the conversation + */ + id: string; + body: Intercom.unstable.ReplyConversationRequestBody; +} diff --git a/src/api/resources/unstable/resources/conversations/client/requests/RetrieveConversationRequest.ts b/src/api/resources/unstable/resources/conversations/client/requests/RetrieveConversationRequest.ts new file mode 100644 index 00000000..8849068d --- /dev/null +++ b/src/api/resources/unstable/resources/conversations/client/requests/RetrieveConversationRequest.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: 1, + * display_as: "plaintext" + * } + */ +export interface RetrieveConversationRequest { + /** + * The id of the conversation to target + */ + id: number; + /** + * Set to plaintext to retrieve conversation messages in plain text. + */ + display_as?: string; +} diff --git a/src/api/resources/unstable/resources/conversations/client/requests/UpdateConversationRequest.ts b/src/api/resources/unstable/resources/conversations/client/requests/UpdateConversationRequest.ts new file mode 100644 index 00000000..76276853 --- /dev/null +++ b/src/api/resources/unstable/resources/conversations/client/requests/UpdateConversationRequest.ts @@ -0,0 +1,55 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../../index"; + +/** + * @example + * { + * id: 1, + * display_as: "plaintext", + * read: true, + * title: "new conversation title", + * custom_attributes: { + * "issue_type": "Billing", + * "priority": "High" + * } + * } + * + * @example + * { + * id: 1, + * display_as: "plaintext", + * custom_attributes: { + * "order": {} + * } + * } + * + * @example + * { + * id: 1, + * display_as: "plaintext", + * read: true, + * title: "new conversation title", + * custom_attributes: { + * "issue_type": "Billing", + * "priority": "High" + * } + * } + */ +export interface UpdateConversationRequest { + /** + * The id of the conversation to target + */ + id: number; + /** + * Set to plaintext to retrieve conversation messages in plain text. + */ + display_as?: string; + /** Mark a conversation as read within Intercom. */ + read?: boolean; + /** The title given to the conversation */ + title?: string; + custom_attributes?: Intercom.unstable.CustomAttributes; +} diff --git a/src/api/resources/unstable/resources/conversations/client/requests/index.ts b/src/api/resources/unstable/resources/conversations/client/requests/index.ts new file mode 100644 index 00000000..b297425a --- /dev/null +++ b/src/api/resources/unstable/resources/conversations/client/requests/index.ts @@ -0,0 +1,10 @@ +export { type ListConversationsRequest } from "./ListConversationsRequest"; +export { type CreateConversationRequest } from "./CreateConversationRequest"; +export { type RetrieveConversationRequest } from "./RetrieveConversationRequest"; +export { type UpdateConversationRequest } from "./UpdateConversationRequest"; +export { type DeleteConversationRequest } from "./DeleteConversationRequest"; +export { type ReplyConversationRequest } from "./ReplyConversationRequest"; +export { type ManageConversationRequest } from "./ManageConversationRequest"; +export { type AttachContactToConversationRequest } from "./AttachContactToConversationRequest"; +export { type DetachContactFromConversationRequest } from "./DetachContactFromConversationRequest"; +export { type ConvertConversationToTicketRequest } from "./ConvertConversationToTicketRequest"; diff --git a/src/api/resources/unstable/resources/conversations/index.ts b/src/api/resources/unstable/resources/conversations/index.ts new file mode 100644 index 00000000..c9240f83 --- /dev/null +++ b/src/api/resources/unstable/resources/conversations/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/unstable/resources/conversations/types/Conversation.ts b/src/api/resources/unstable/resources/conversations/types/Conversation.ts new file mode 100644 index 00000000..2531c62d --- /dev/null +++ b/src/api/resources/unstable/resources/conversations/types/Conversation.ts @@ -0,0 +1,71 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +/** + * Conversations are how you can communicate with users in Intercom. They are created when a contact replies to an outbound message, or when one admin directly sends a message to a single contact. + */ +export interface Conversation { + /** Always conversation. */ + type?: string; + /** The id representing the conversation. */ + id?: string; + /** The title given to the conversation. */ + title?: string; + /** The time the conversation was created. */ + created_at?: number; + /** The last time the conversation was updated. */ + updated_at?: number; + /** The last time a Contact responded to an Admin. In other words, the time a customer started waiting for a response. Set to null if last reply is from an Admin. */ + waiting_since?: number; + /** If set this is the time in the future when this conversation will be marked as open. i.e. it will be in a snoozed state until this time. i.e. it will be in a snoozed state until this time. */ + snoozed_until?: number; + /** Indicates whether a conversation is open (true) or closed (false). */ + open?: boolean; + /** Can be set to "open", "closed" or "snoozed". */ + state?: Conversation.State; + /** Indicates whether a conversation has been read. */ + read?: boolean; + /** If marked as priority, it will return priority or else not_priority. */ + priority?: Conversation.Priority; + /** The id of the admin assigned to the conversation. If it's not assigned to an admin it will return null. */ + admin_assignee_id?: number; + /** The id of the team assigned to the conversation. If it's not assigned to a team it will return null. */ + team_assignee_id?: string; + tags?: Intercom.unstable.Tags; + conversation_rating?: Intercom.unstable.ConversationRating; + source?: Intercom.unstable.ConversationSource; + contacts?: Intercom.unstable.ConversationContacts; + teammates?: Intercom.unstable.ConversationTeammates; + custom_attributes?: Intercom.unstable.CustomAttributes; + first_contact_reply?: Intercom.unstable.ConversationFirstContactReply; + sla_applied?: Intercom.unstable.SlaApplied; + statistics?: Intercom.unstable.ConversationStatistics; + conversation_parts?: Intercom.unstable.ConversationParts; + linked_objects?: Intercom.unstable.LinkedObjectList; + /** Indicates whether the AI Agent participated in the conversation. */ + ai_agent_participated?: boolean; + ai_agent?: Intercom.unstable.AiAgent; +} + +export namespace Conversation { + /** + * Can be set to "open", "closed" or "snoozed". + */ + export type State = "open" | "closed" | "snoozed"; + export const State = { + Open: "open", + Closed: "closed", + Snoozed: "snoozed", + } as const; + /** + * If marked as priority, it will return priority or else not_priority. + */ + export type Priority = "priority" | "not_priority"; + export const Priority = { + Priority: "priority", + NotPriority: "not_priority", + } as const; +} diff --git a/src/api/resources/unstable/resources/conversations/types/ManageConversationRequestBody.ts b/src/api/resources/unstable/resources/conversations/types/ManageConversationRequestBody.ts new file mode 100644 index 00000000..cceeedbb --- /dev/null +++ b/src/api/resources/unstable/resources/conversations/types/ManageConversationRequestBody.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +export type ManageConversationRequestBody = + | Intercom.unstable.ManageConversationRequestBody.Close + | Intercom.unstable.ManageConversationRequestBody.Snoozed + | Intercom.unstable.ManageConversationRequestBody.Open + | Intercom.unstable.ManageConversationRequestBody.Assignment; + +export namespace ManageConversationRequestBody { + export interface Close extends Intercom.unstable.CloseConversationRequest { + message_type: "close"; + } + + export interface Snoozed extends Intercom.unstable.SnoozeConversationRequest { + message_type: "snoozed"; + } + + export interface Open extends Intercom.unstable.OpenConversationRequest { + message_type: "open"; + } + + export interface Assignment extends Intercom.unstable.AssignConversationRequest { + message_type: "assignment"; + } +} diff --git a/src/api/resources/unstable/resources/conversations/types/index.ts b/src/api/resources/unstable/resources/conversations/types/index.ts new file mode 100644 index 00000000..b2325882 --- /dev/null +++ b/src/api/resources/unstable/resources/conversations/types/index.ts @@ -0,0 +1,2 @@ +export * from "./ManageConversationRequestBody"; +export * from "./Conversation"; diff --git a/src/api/resources/unstable/resources/customChannelEvents/client/Client.ts b/src/api/resources/unstable/resources/customChannelEvents/client/Client.ts new file mode 100644 index 00000000..fab44a35 --- /dev/null +++ b/src/api/resources/unstable/resources/customChannelEvents/client/Client.ts @@ -0,0 +1,540 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace CustomChannelEvents { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + } +} + +export class CustomChannelEvents { + constructor(protected readonly _options: CustomChannelEvents.Options = {}) {} + + /** + * Notifies Intercom that a new conversation was created in your custom channel/platform. This triggers conversation creation and workflow automations within Intercom for your custom channel integration. + * > **Note:** This endpoint is restricted to customers with access to the closed beta for "Fin over API". + * + * @param {Intercom.unstable.CustomChannelBaseEvent} request + * @param {CustomChannelEvents.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.BadRequestError} + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.unstable.UnprocessableEntityError} + * + * @example + * await client.unstable.customChannelEvents.notifyNewConversation({ + * event_id: "evt_12345", + * external_conversation_id: "conv_67890", + * contact: { + * type: "user", + * external_id: "user_001", + * name: "Jane Doe", + * email: "jane.doe@example.com" + * } + * }) + */ + public notifyNewConversation( + request: Intercom.unstable.CustomChannelBaseEvent, + requestOptions?: CustomChannelEvents.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__notifyNewConversation(request, requestOptions)); + } + + private async __notifyNewConversation( + request: Intercom.unstable.CustomChannelBaseEvent, + requestOptions?: CustomChannelEvents.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "custom_channel_events/notify_new_conversation", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.CustomChannelNotificationResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.unstable.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling POST /custom_channel_events/notify_new_conversation.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * 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 restricted to customers with access to the closed beta for "Fin over API". + * + * @param {Intercom.unstable.NotifyNewMessageRequest} request + * @param {CustomChannelEvents.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.BadRequestError} + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.unstable.UnprocessableEntityError} + * + * @example + * await client.unstable.customChannelEvents.notifyNewMessage({ + * event_id: "evt_54321", + * external_conversation_id: "conv_98765", + * contact: { + * type: "user", + * external_id: "user_002", + * name: "John Smith", + * email: "john.smith@example.com" + * }, + * body: "Hello, I need help with my order." + * }) + */ + public notifyNewMessage( + request: Intercom.unstable.NotifyNewMessageRequest, + requestOptions?: CustomChannelEvents.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__notifyNewMessage(request, requestOptions)); + } + + private async __notifyNewMessage( + request: Intercom.unstable.NotifyNewMessageRequest, + requestOptions?: CustomChannelEvents.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "custom_channel_events/notify_new_message", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.CustomChannelNotificationResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.unstable.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling POST /custom_channel_events/notify_new_message.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * 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 restricted to customers with access to the closed beta for "Fin over API". + * + * @param {Intercom.unstable.NotifyQuickReplySelectedRequest} request + * @param {CustomChannelEvents.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.BadRequestError} + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.unstable.UnprocessableEntityError} + * + * @example + * await client.unstable.customChannelEvents.notifyQuickReplySelected({ + * event_id: "evt_67890", + * external_conversation_id: "conv_13579", + * contact: { + * type: "user", + * external_id: "user_003", + * name: "Alice Example", + * email: "alice@example.com" + * }, + * quick_reply_option_id: "1234" + * }) + */ + public notifyQuickReplySelected( + request: Intercom.unstable.NotifyQuickReplySelectedRequest, + requestOptions?: CustomChannelEvents.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__notifyQuickReplySelected(request, requestOptions)); + } + + private async __notifyQuickReplySelected( + request: Intercom.unstable.NotifyQuickReplySelectedRequest, + requestOptions?: CustomChannelEvents.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "custom_channel_events/notify_quick_reply_selected", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.CustomChannelNotificationResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.unstable.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling POST /custom_channel_events/notify_quick_reply_selected.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * 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 restricted to customers with access to the closed beta for "Fin over API". + * + * @param {Intercom.unstable.NotifyAttributeCollectedRequest} request + * @param {CustomChannelEvents.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.BadRequestError} + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.unstable.UnprocessableEntityError} + * + * @example + * await client.unstable.customChannelEvents.notifyAttributeCollected({ + * event_id: "evt_24680", + * external_conversation_id: "conv_11223", + * contact: { + * type: "user", + * external_id: "user_004", + * name: "Bob Example", + * email: "bob@example.com" + * }, + * attribute: { + * id: "shipping_address", + * value: "123 Main St, Springfield" + * } + * }) + */ + public notifyAttributeCollected( + request: Intercom.unstable.NotifyAttributeCollectedRequest, + requestOptions?: CustomChannelEvents.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__notifyAttributeCollected(request, requestOptions)); + } + + private async __notifyAttributeCollected( + request: Intercom.unstable.NotifyAttributeCollectedRequest, + requestOptions?: CustomChannelEvents.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "custom_channel_events/notify_attribute_collected", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.CustomChannelNotificationResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.unstable.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling POST /custom_channel_events/notify_attribute_collected.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["INTERCOM_API_KEY"]; + if (bearer == null) { + throw new errors.IntercomError({ + message: + "Please specify a bearer by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", + }); + } + + return `Bearer ${bearer}`; + } +} diff --git a/src/api/resources/unstable/resources/customChannelEvents/client/index.ts b/src/api/resources/unstable/resources/customChannelEvents/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/api/resources/unstable/resources/customChannelEvents/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/unstable/resources/customChannelEvents/client/requests/NotifyAttributeCollectedRequest.ts b/src/api/resources/unstable/resources/customChannelEvents/client/requests/NotifyAttributeCollectedRequest.ts new file mode 100644 index 00000000..f3a2660d --- /dev/null +++ b/src/api/resources/unstable/resources/customChannelEvents/client/requests/NotifyAttributeCollectedRequest.ts @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../../index"; + +/** + * @example + * { + * event_id: "evt_24680", + * external_conversation_id: "conv_11223", + * contact: { + * type: "user", + * external_id: "user_004", + * name: "Bob Example", + * email: "bob@example.com" + * }, + * attribute: { + * id: "shipping_address", + * value: "123 Main St, Springfield" + * } + * } + */ +export interface NotifyAttributeCollectedRequest extends Intercom.unstable.CustomChannelBaseEvent { + attribute: Intercom.unstable.CustomChannelAttribute; +} diff --git a/src/api/resources/unstable/resources/customChannelEvents/client/requests/NotifyNewMessageRequest.ts b/src/api/resources/unstable/resources/customChannelEvents/client/requests/NotifyNewMessageRequest.ts new file mode 100644 index 00000000..1ed15c6e --- /dev/null +++ b/src/api/resources/unstable/resources/customChannelEvents/client/requests/NotifyNewMessageRequest.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../../index"; + +/** + * @example + * { + * event_id: "evt_54321", + * external_conversation_id: "conv_98765", + * contact: { + * type: "user", + * external_id: "user_002", + * name: "John Smith", + * email: "john.smith@example.com" + * }, + * body: "Hello, I need help with my order." + * } + */ +export interface NotifyNewMessageRequest extends Intercom.unstable.CustomChannelBaseEvent { + /** The message content sent by the user. */ + body: string; +} diff --git a/src/api/resources/unstable/resources/customChannelEvents/client/requests/NotifyQuickReplySelectedRequest.ts b/src/api/resources/unstable/resources/customChannelEvents/client/requests/NotifyQuickReplySelectedRequest.ts new file mode 100644 index 00000000..499b11d6 --- /dev/null +++ b/src/api/resources/unstable/resources/customChannelEvents/client/requests/NotifyQuickReplySelectedRequest.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../../index"; + +/** + * @example + * { + * event_id: "evt_67890", + * external_conversation_id: "conv_13579", + * contact: { + * type: "user", + * external_id: "user_003", + * name: "Alice Example", + * email: "alice@example.com" + * }, + * quick_reply_option_id: "1234" + * } + */ +export interface NotifyQuickReplySelectedRequest extends Intercom.unstable.CustomChannelBaseEvent { + /** Id of the selected quick reply option. */ + quick_reply_option_id: string; +} diff --git a/src/api/resources/unstable/resources/customChannelEvents/client/requests/index.ts b/src/api/resources/unstable/resources/customChannelEvents/client/requests/index.ts new file mode 100644 index 00000000..007800f3 --- /dev/null +++ b/src/api/resources/unstable/resources/customChannelEvents/client/requests/index.ts @@ -0,0 +1,3 @@ +export { type NotifyNewMessageRequest } from "./NotifyNewMessageRequest"; +export { type NotifyQuickReplySelectedRequest } from "./NotifyQuickReplySelectedRequest"; +export { type NotifyAttributeCollectedRequest } from "./NotifyAttributeCollectedRequest"; diff --git a/src/api/resources/unstable/resources/customChannelEvents/index.ts b/src/api/resources/unstable/resources/customChannelEvents/index.ts new file mode 100644 index 00000000..5ec76921 --- /dev/null +++ b/src/api/resources/unstable/resources/customChannelEvents/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/unstable/resources/customObjectInstances/client/Client.ts b/src/api/resources/unstable/resources/customObjectInstances/client/Client.ts new file mode 100644 index 00000000..8d8d1ca5 --- /dev/null +++ b/src/api/resources/unstable/resources/customObjectInstances/client/Client.ts @@ -0,0 +1,589 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace CustomObjectInstances { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + } +} + +/** + * Everything about your Custom Object instances. + * {% admonition type="warning" name="Permission Requirements" %} + * From now on, to access this endpoint, you need additional permissions. Please head over to the [Developer Hub](https://app.intercom.com/a/apps/_/developer-hub) app package authentication settings to configure the required permissions. + * {% /admonition %} + */ +export class CustomObjectInstances { + constructor(protected readonly _options: CustomObjectInstances.Options = {}) {} + + /** + * Fetch a Custom Object Instance by external_id. + * + * @param {Intercom.unstable.GetCustomObjectInstancesByExternalIdRequest} request + * @param {CustomObjectInstances.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.customObjectInstances.getCustomObjectInstancesByExternalId({ + * custom_object_type_identifier: "Order", + * external_id: "external_id" + * }) + */ + public getCustomObjectInstancesByExternalId( + request: Intercom.unstable.GetCustomObjectInstancesByExternalIdRequest, + requestOptions?: CustomObjectInstances.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise( + this.__getCustomObjectInstancesByExternalId(request, requestOptions), + ); + } + + private async __getCustomObjectInstancesByExternalId( + request: Intercom.unstable.GetCustomObjectInstancesByExternalIdRequest, + requestOptions?: CustomObjectInstances.RequestOptions, + ): Promise> { + const { custom_object_type_identifier: customObjectTypeIdentifier, external_id: externalId } = request; + const _queryParams: Record = {}; + _queryParams["external_id"] = externalId; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `custom_object_instances/${encodeURIComponent(customObjectTypeIdentifier)}`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.CustomObjectInstance | undefined, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling GET /custom_object_instances/{custom_object_type_identifier}.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * Create or update a custom object instance + * + * @param {Intercom.unstable.CreateOrUpdateCustomObjectInstanceRequest} request + * @param {CustomObjectInstances.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.customObjectInstances.createCustomObjectInstances({ + * custom_object_type_identifier: "Order", + * external_id: "123", + * external_created_at: 1392036272, + * external_updated_at: 1392036272, + * custom_attributes: { + * "order_number": "ORDER-12345", + * "total_amount": "custom_attributes" + * } + * }) + */ + public createCustomObjectInstances( + request: Intercom.unstable.CreateOrUpdateCustomObjectInstanceRequest, + requestOptions?: CustomObjectInstances.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createCustomObjectInstances(request, requestOptions)); + } + + private async __createCustomObjectInstances( + request: Intercom.unstable.CreateOrUpdateCustomObjectInstanceRequest, + requestOptions?: CustomObjectInstances.RequestOptions, + ): Promise> { + const { custom_object_type_identifier: customObjectTypeIdentifier, ..._body } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `custom_object_instances/${encodeURIComponent(customObjectTypeIdentifier)}`, + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: _body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.CustomObjectInstance | undefined, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling POST /custom_object_instances/{custom_object_type_identifier}.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * Delete a single Custom Object instance by external_id. + * + * @param {Intercom.unstable.DeleteCustomObjectInstancesByIdRequest} request + * @param {CustomObjectInstances.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.customObjectInstances.deleteCustomObjectInstancesById({ + * custom_object_type_identifier: "Order", + * external_id: "external_id" + * }) + */ + public deleteCustomObjectInstancesById( + request: Intercom.unstable.DeleteCustomObjectInstancesByIdRequest, + requestOptions?: CustomObjectInstances.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteCustomObjectInstancesById(request, requestOptions)); + } + + private async __deleteCustomObjectInstancesById( + request: Intercom.unstable.DeleteCustomObjectInstancesByIdRequest, + requestOptions?: CustomObjectInstances.RequestOptions, + ): Promise> { + const { custom_object_type_identifier: customObjectTypeIdentifier, external_id: externalId } = request; + const _queryParams: Record = {}; + _queryParams["external_id"] = externalId; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `custom_object_instances/${encodeURIComponent(customObjectTypeIdentifier)}`, + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.CustomObjectInstanceDeleted, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling DELETE /custom_object_instances/{custom_object_type_identifier}.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * Fetch a Custom Object Instance by id. + * + * @param {Intercom.unstable.GetCustomObjectInstancesByIdRequest} request + * @param {CustomObjectInstances.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.customObjectInstances.getCustomObjectInstancesById({ + * custom_object_type_identifier: "Order", + * id: "id" + * }) + */ + public getCustomObjectInstancesById( + request: Intercom.unstable.GetCustomObjectInstancesByIdRequest, + requestOptions?: CustomObjectInstances.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__getCustomObjectInstancesById(request, requestOptions)); + } + + private async __getCustomObjectInstancesById( + request: Intercom.unstable.GetCustomObjectInstancesByIdRequest, + requestOptions?: CustomObjectInstances.RequestOptions, + ): Promise> { + const { custom_object_type_identifier: customObjectTypeIdentifier, id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `custom_object_instances/${encodeURIComponent(customObjectTypeIdentifier)}/${encodeURIComponent(id)}`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.CustomObjectInstance | undefined, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling GET /custom_object_instances/{custom_object_type_identifier}/{id}.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * Delete a single Custom Object instance using the Intercom defined id. + * + * @param {Intercom.unstable.DeleteCustomObjectInstancesByExternalIdRequest} request + * @param {CustomObjectInstances.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.customObjectInstances.deleteCustomObjectInstancesByExternalId({ + * custom_object_type_identifier: "Order", + * id: "id" + * }) + */ + public deleteCustomObjectInstancesByExternalId( + request: Intercom.unstable.DeleteCustomObjectInstancesByExternalIdRequest, + requestOptions?: CustomObjectInstances.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise( + this.__deleteCustomObjectInstancesByExternalId(request, requestOptions), + ); + } + + private async __deleteCustomObjectInstancesByExternalId( + request: Intercom.unstable.DeleteCustomObjectInstancesByExternalIdRequest, + requestOptions?: CustomObjectInstances.RequestOptions, + ): Promise> { + const { custom_object_type_identifier: customObjectTypeIdentifier, id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `custom_object_instances/${encodeURIComponent(customObjectTypeIdentifier)}/${encodeURIComponent(id)}`, + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.CustomObjectInstanceDeleted, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling DELETE /custom_object_instances/{custom_object_type_identifier}/{id}.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["INTERCOM_API_KEY"]; + if (bearer == null) { + throw new errors.IntercomError({ + message: + "Please specify a bearer by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", + }); + } + + return `Bearer ${bearer}`; + } +} diff --git a/src/api/resources/unstable/resources/customObjectInstances/client/index.ts b/src/api/resources/unstable/resources/customObjectInstances/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/api/resources/unstable/resources/customObjectInstances/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/unstable/resources/customObjectInstances/client/requests/CreateOrUpdateCustomObjectInstanceRequest.ts b/src/api/resources/unstable/resources/customObjectInstances/client/requests/CreateOrUpdateCustomObjectInstanceRequest.ts new file mode 100644 index 00000000..6366c551 --- /dev/null +++ b/src/api/resources/unstable/resources/customObjectInstances/client/requests/CreateOrUpdateCustomObjectInstanceRequest.ts @@ -0,0 +1,31 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * custom_object_type_identifier: "Order", + * external_id: "123", + * external_created_at: 1392036272, + * external_updated_at: 1392036272, + * custom_attributes: { + * "order_number": "ORDER-12345", + * "total_amount": "custom_attributes" + * } + * } + */ +export interface CreateOrUpdateCustomObjectInstanceRequest { + /** + * The unique identifier of the custom object type that defines the structure of the custom object instance. + */ + custom_object_type_identifier: string; + /** A unique identifier for the Custom Object instance in the external system it originated from. */ + external_id?: string; + /** The time when the Custom Object instance was created in the external system it originated from. */ + external_created_at?: number; + /** The time when the Custom Object instance was last updated in the external system it originated from. */ + external_updated_at?: number; + /** The custom attributes which are set for the Custom Object instance. */ + custom_attributes?: Record; +} diff --git a/src/api/resources/unstable/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByExternalIdRequest.ts b/src/api/resources/unstable/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByExternalIdRequest.ts new file mode 100644 index 00000000..4674b582 --- /dev/null +++ b/src/api/resources/unstable/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByExternalIdRequest.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * custom_object_type_identifier: "Order", + * id: "id" + * } + */ +export interface DeleteCustomObjectInstancesByExternalIdRequest { + /** + * The unique identifier of the custom object type that defines the structure of the custom object instance. + */ + custom_object_type_identifier: string; + /** + * The Intercom defined id of the custom object instance + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByIdRequest.ts b/src/api/resources/unstable/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByIdRequest.ts new file mode 100644 index 00000000..b14cf673 --- /dev/null +++ b/src/api/resources/unstable/resources/customObjectInstances/client/requests/DeleteCustomObjectInstancesByIdRequest.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * custom_object_type_identifier: "Order", + * external_id: "external_id" + * } + */ +export interface DeleteCustomObjectInstancesByIdRequest { + /** + * The unique identifier of the custom object type that defines the structure of the custom object instance. + */ + custom_object_type_identifier: string; + external_id: string; +} diff --git a/src/api/resources/unstable/resources/customObjectInstances/client/requests/GetCustomObjectInstancesByExternalIdRequest.ts b/src/api/resources/unstable/resources/customObjectInstances/client/requests/GetCustomObjectInstancesByExternalIdRequest.ts new file mode 100644 index 00000000..5ca2f7d0 --- /dev/null +++ b/src/api/resources/unstable/resources/customObjectInstances/client/requests/GetCustomObjectInstancesByExternalIdRequest.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * custom_object_type_identifier: "Order", + * external_id: "external_id" + * } + */ +export interface GetCustomObjectInstancesByExternalIdRequest { + /** + * The unique identifier of the custom object type that defines the structure of the custom object instance. + */ + custom_object_type_identifier: string; + external_id: string; +} diff --git a/src/api/resources/unstable/resources/customObjectInstances/client/requests/GetCustomObjectInstancesByIdRequest.ts b/src/api/resources/unstable/resources/customObjectInstances/client/requests/GetCustomObjectInstancesByIdRequest.ts new file mode 100644 index 00000000..9350898c --- /dev/null +++ b/src/api/resources/unstable/resources/customObjectInstances/client/requests/GetCustomObjectInstancesByIdRequest.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * custom_object_type_identifier: "Order", + * id: "id" + * } + */ +export interface GetCustomObjectInstancesByIdRequest { + /** + * The unique identifier of the custom object type that defines the structure of the custom object instance. + */ + custom_object_type_identifier: string; + /** + * The id or external_id of the custom object instance + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/customObjectInstances/client/requests/index.ts b/src/api/resources/unstable/resources/customObjectInstances/client/requests/index.ts new file mode 100644 index 00000000..5382e3d2 --- /dev/null +++ b/src/api/resources/unstable/resources/customObjectInstances/client/requests/index.ts @@ -0,0 +1,5 @@ +export { type GetCustomObjectInstancesByExternalIdRequest } from "./GetCustomObjectInstancesByExternalIdRequest"; +export { type CreateOrUpdateCustomObjectInstanceRequest } from "./CreateOrUpdateCustomObjectInstanceRequest"; +export { type DeleteCustomObjectInstancesByIdRequest } from "./DeleteCustomObjectInstancesByIdRequest"; +export { type GetCustomObjectInstancesByIdRequest } from "./GetCustomObjectInstancesByIdRequest"; +export { type DeleteCustomObjectInstancesByExternalIdRequest } from "./DeleteCustomObjectInstancesByExternalIdRequest"; diff --git a/src/api/resources/unstable/resources/customObjectInstances/index.ts b/src/api/resources/unstable/resources/customObjectInstances/index.ts new file mode 100644 index 00000000..c9240f83 --- /dev/null +++ b/src/api/resources/unstable/resources/customObjectInstances/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/unstable/resources/customObjectInstances/types/CustomObjectInstance.ts b/src/api/resources/unstable/resources/customObjectInstances/types/CustomObjectInstance.ts new file mode 100644 index 00000000..aab4a843 --- /dev/null +++ b/src/api/resources/unstable/resources/customObjectInstances/types/CustomObjectInstance.ts @@ -0,0 +1,25 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A Custom Object Instance represents an instance of a custom object type. This allows you to create and set custom attributes to store data about your customers that is not already captured by Intercom. The parent object includes recommended default attributes and you can add your own custom attributes. + */ +export interface CustomObjectInstance { + /** The Intercom defined id representing the custom object instance. */ + id?: string; + /** The id you have defined for the custom object instance. */ + external_id?: string; + /** The time when the Custom Object instance was created in the external system it originated from. */ + external_created_at?: number; + /** The time when the Custom Object instance was last updated in the external system it originated from. */ + external_updated_at?: number; + /** The time the attribute was created as a UTC Unix timestamp */ + created_at?: number; + /** The time the attribute was last updated as a UTC Unix timestamp */ + updated_at?: number; + /** The identifier of the custom object type that defines the structure of the custom object instance. */ + type?: string; + /** The custom attributes you have set on the custom object instance. */ + custom_attributes?: Record; +} diff --git a/src/api/resources/unstable/resources/customObjectInstances/types/index.ts b/src/api/resources/unstable/resources/customObjectInstances/types/index.ts new file mode 100644 index 00000000..d5c782f8 --- /dev/null +++ b/src/api/resources/unstable/resources/customObjectInstances/types/index.ts @@ -0,0 +1 @@ +export * from "./CustomObjectInstance"; diff --git a/src/api/resources/unstable/resources/dataAttributes/client/Client.ts b/src/api/resources/unstable/resources/dataAttributes/client/Client.ts new file mode 100644 index 00000000..03670ff6 --- /dev/null +++ b/src/api/resources/unstable/resources/dataAttributes/client/Client.ts @@ -0,0 +1,436 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace DataAttributes { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + } +} + +/** + * Everything about your Data Attributes + */ +export class DataAttributes { + constructor(protected readonly _options: DataAttributes.Options = {}) {} + + /** + * You can fetch a list of all data attributes belonging to a workspace for contacts, companies or conversations. + * + * @param {Intercom.unstable.LisDataAttributesRequest} request + * @param {DataAttributes.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.dataAttributes.lisDataAttributes() + */ + public lisDataAttributes( + request: Intercom.unstable.LisDataAttributesRequest = {}, + requestOptions?: DataAttributes.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__lisDataAttributes(request, requestOptions)); + } + + private async __lisDataAttributes( + request: Intercom.unstable.LisDataAttributesRequest = {}, + requestOptions?: DataAttributes.RequestOptions, + ): Promise> { + const { model, include_archived: includeArchived } = request; + const _queryParams: Record = {}; + if (model != null) { + _queryParams["model"] = model; + } + + if (includeArchived != null) { + _queryParams["include_archived"] = includeArchived.toString(); + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "data_attributes", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.DataAttributeList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /data_attributes."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can create a data attributes for a `contact` or a `company`. + * + * @param {Intercom.unstable.CreateDataAttributeRequest} request + * @param {DataAttributes.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.BadRequestError} + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.dataAttributes.createDataAttribute({ + * name: "Mithril Shirt", + * model: "company", + * data_type: "string" + * }) + * + * @example + * await client.unstable.dataAttributes.createDataAttribute({ + * name: "The One Ring", + * model: "contact", + * data_type: "integer" + * }) + * + * @example + * await client.unstable.dataAttributes.createDataAttribute({ + * name: "!nv@l!d n@me", + * model: "company", + * data_type: "string" + * }) + * + * @example + * await client.unstable.dataAttributes.createDataAttribute({ + * name: "The One Ring", + * model: "company", + * data_type: "string" + * }) + * + * @example + * await client.unstable.dataAttributes.createDataAttribute({ + * name: "The Second Ring", + * model: "company", + * data_type: "string" + * }) + * + * @example + * await client.unstable.dataAttributes.createDataAttribute({ + * name: "My Data Attribute", + * model: "contact", + * data_type: "string", + * description: "Just a plain old ring", + * options: ["options"] + * }) + */ + public createDataAttribute( + request: Intercom.unstable.CreateDataAttributeRequest, + requestOptions?: DataAttributes.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createDataAttribute(request, requestOptions)); + } + + private async __createDataAttribute( + request: Intercom.unstable.CreateDataAttributeRequest, + requestOptions?: DataAttributes.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "data_attributes", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.DataAttribute, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /data_attributes."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * + * You can update a data attribute. + * + * > 🚧 Updating the data type is not possible + * > + * > 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 {Intercom.unstable.UpdateDataAttributeRequest} request + * @param {DataAttributes.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.BadRequestError} + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * @throws {@link Intercom.unstable.UnprocessableEntityError} + * + * @example + * await client.unstable.dataAttributes.updateDataAttribute({ + * id: 1, + * archived: false, + * description: "Just a plain old ring", + * options: ["options", "options"] + * }) + * + * @example + * await client.unstable.dataAttributes.updateDataAttribute({ + * id: 1, + * archived: false, + * description: "Too few options", + * options: ["option1", "option2"] + * }) + * + * @example + * await client.unstable.dataAttributes.updateDataAttribute({ + * id: 1, + * archived: true, + * description: "Trying to archieve" + * }) + */ + public updateDataAttribute( + request: Intercom.unstable.UpdateDataAttributeRequest, + requestOptions?: DataAttributes.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__updateDataAttribute(request, requestOptions)); + } + + private async __updateDataAttribute( + request: Intercom.unstable.UpdateDataAttributeRequest, + requestOptions?: DataAttributes.RequestOptions, + ): Promise> { + const { id, ..._body } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `data_attributes/${encodeURIComponent(id)}`, + ), + method: "PUT", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: _body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.DataAttribute, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Intercom.unstable.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling PUT /data_attributes/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["INTERCOM_API_KEY"]; + if (bearer == null) { + throw new errors.IntercomError({ + message: + "Please specify a bearer by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", + }); + } + + return `Bearer ${bearer}`; + } +} diff --git a/src/api/resources/unstable/resources/dataAttributes/client/index.ts b/src/api/resources/unstable/resources/dataAttributes/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/api/resources/unstable/resources/dataAttributes/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/unstable/resources/dataAttributes/client/requests/CreateDataAttributeRequest.ts b/src/api/resources/unstable/resources/dataAttributes/client/requests/CreateDataAttributeRequest.ts new file mode 100644 index 00000000..d0856471 --- /dev/null +++ b/src/api/resources/unstable/resources/dataAttributes/client/requests/CreateDataAttributeRequest.ts @@ -0,0 +1,86 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * name: "Mithril Shirt", + * model: "company", + * data_type: "string" + * } + * + * @example + * { + * name: "The One Ring", + * model: "contact", + * data_type: "integer" + * } + * + * @example + * { + * name: "!nv@l!d n@me", + * model: "company", + * data_type: "string" + * } + * + * @example + * { + * name: "The One Ring", + * model: "company", + * data_type: "string" + * } + * + * @example + * { + * name: "The Second Ring", + * model: "company", + * data_type: "string" + * } + * + * @example + * { + * name: "My Data Attribute", + * model: "contact", + * data_type: "string", + * description: "Just a plain old ring", + * options: ["options"] + * } + */ +export interface CreateDataAttributeRequest { + /** The name of the data attribute. */ + name: string; + /** The model that the data attribute belongs to. */ + model: CreateDataAttributeRequest.Model; + /** The type of data stored for this attribute. */ + data_type: CreateDataAttributeRequest.DataType; + /** The readable description you see in the UI for the attribute. */ + description?: string; + /** To create list attributes. Provide a set of hashes with `value` as the key of the options you want to make. `data_type` must be `string`. */ + options?: string[]; + /** Can this attribute be updated by the Messenger */ + messenger_writable?: boolean; +} + +export namespace CreateDataAttributeRequest { + /** + * The model that the data attribute belongs to. + */ + export type Model = "contact" | "company"; + export const Model = { + Contact: "contact", + Company: "company", + } as const; + /** + * The type of data stored for this attribute. + */ + export type DataType = "string" | "integer" | "float" | "boolean" | "datetime" | "date"; + export const DataType = { + String: "string", + Integer: "integer", + Float: "float", + Boolean: "boolean", + Datetime: "datetime", + Date: "date", + } as const; +} diff --git a/src/api/resources/unstable/resources/dataAttributes/client/requests/LisDataAttributesRequest.ts b/src/api/resources/unstable/resources/dataAttributes/client/requests/LisDataAttributesRequest.ts new file mode 100644 index 00000000..4764c380 --- /dev/null +++ b/src/api/resources/unstable/resources/dataAttributes/client/requests/LisDataAttributesRequest.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../../index"; + +/** + * @example + * {} + */ +export interface LisDataAttributesRequest { + /** + * Specify the data attribute model to return. + */ + model?: Intercom.unstable.LisDataAttributesRequestModel; + /** + * Include archived attributes in the list. By default we return only non archived data attributes. + */ + include_archived?: boolean; +} diff --git a/src/api/resources/unstable/resources/dataAttributes/client/requests/UpdateDataAttributeRequest.ts b/src/api/resources/unstable/resources/dataAttributes/client/requests/UpdateDataAttributeRequest.ts new file mode 100644 index 00000000..80ea0b29 --- /dev/null +++ b/src/api/resources/unstable/resources/dataAttributes/client/requests/UpdateDataAttributeRequest.ts @@ -0,0 +1,50 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: 1, + * archived: false, + * description: "Just a plain old ring", + * options: ["options", "options"] + * } + * + * @example + * { + * id: 1, + * archived: false, + * description: "Too few options", + * options: ["option1", "option2"] + * } + * + * @example + * { + * id: 1, + * archived: false, + * description: "Just a plain old ring", + * options: ["options", "options"] + * } + * + * @example + * { + * id: 1, + * archived: true, + * description: "Trying to archieve" + * } + */ +export interface UpdateDataAttributeRequest { + /** + * The data attribute id + */ + id: number; + /** Whether the attribute is to be archived or not. */ + archived?: boolean; + /** The readable description you see in the UI for the attribute. */ + description?: string; + /** To create list attributes. Provide a set of hashes with `value` as the key of the options you want to make. `data_type` must be `string`. */ + options?: string[]; + /** Can this attribute be updated by the Messenger */ + messenger_writable?: boolean; +} diff --git a/src/api/resources/unstable/resources/dataAttributes/client/requests/index.ts b/src/api/resources/unstable/resources/dataAttributes/client/requests/index.ts new file mode 100644 index 00000000..5b0976fe --- /dev/null +++ b/src/api/resources/unstable/resources/dataAttributes/client/requests/index.ts @@ -0,0 +1,3 @@ +export { type LisDataAttributesRequest } from "./LisDataAttributesRequest"; +export { type CreateDataAttributeRequest } from "./CreateDataAttributeRequest"; +export { type UpdateDataAttributeRequest } from "./UpdateDataAttributeRequest"; diff --git a/src/api/resources/unstable/resources/dataAttributes/index.ts b/src/api/resources/unstable/resources/dataAttributes/index.ts new file mode 100644 index 00000000..c9240f83 --- /dev/null +++ b/src/api/resources/unstable/resources/dataAttributes/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/unstable/resources/dataAttributes/types/DataAttribute.ts b/src/api/resources/unstable/resources/dataAttributes/types/DataAttribute.ts new file mode 100644 index 00000000..cacf2b7b --- /dev/null +++ b/src/api/resources/unstable/resources/dataAttributes/types/DataAttribute.ts @@ -0,0 +1,65 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Data Attributes are metadata used to describe your contact, company and conversation models. These include standard and custom attributes. By using the data attributes endpoint, you can get the global list of attributes for your workspace, as well as create and archive custom attributes. + */ +export interface DataAttribute { + /** Value is `data_attribute`. */ + type?: "data_attribute"; + /** The unique identifier for the data attribute which is given by Intercom. Only available for custom attributes. */ + id?: number; + /** Value is `contact` for user/lead attributes and `company` for company attributes. */ + model?: DataAttribute.Model; + /** Name of the attribute. */ + name?: string; + /** Full name of the attribute. Should match the name unless it's a nested attribute. We can split full_name on `.` to access nested user object values. */ + full_name?: string; + /** Readable name of the attribute (i.e. name you see in the UI) */ + label?: string; + /** Readable description of the attribute. */ + description?: string; + /** The data type of the attribute. */ + data_type?: DataAttribute.DataType; + /** List of predefined options for attribute value. */ + options?: string[]; + /** Can this attribute be updated through API */ + api_writable?: boolean; + /** Can this attribute be updated by the Messenger */ + messenger_writable?: boolean; + /** Can this attribute be updated in the UI */ + ui_writable?: boolean; + /** Set to true if this is a CDA */ + custom?: boolean; + /** Is this attribute archived. (Only applicable to CDAs) */ + archived?: boolean; + /** The time the attribute was created as a UTC Unix timestamp */ + created_at?: number; + /** The time the attribute was last updated as a UTC Unix timestamp */ + updated_at?: number; + /** Teammate who created the attribute. Only applicable to CDAs */ + admin_id?: string; +} + +export namespace DataAttribute { + /** + * Value is `contact` for user/lead attributes and `company` for company attributes. + */ + export type Model = "contact" | "company"; + export const Model = { + Contact: "contact", + Company: "company", + } as const; + /** + * The data type of the attribute. + */ + export type DataType = "string" | "integer" | "float" | "boolean" | "date"; + export const DataType = { + String: "string", + Integer: "integer", + Float: "float", + Boolean: "boolean", + Date: "date", + } as const; +} diff --git a/src/api/resources/unstable/resources/dataAttributes/types/LisDataAttributesRequestModel.ts b/src/api/resources/unstable/resources/dataAttributes/types/LisDataAttributesRequestModel.ts new file mode 100644 index 00000000..9ee462c6 --- /dev/null +++ b/src/api/resources/unstable/resources/dataAttributes/types/LisDataAttributesRequestModel.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type LisDataAttributesRequestModel = "contact" | "company" | "conversation"; +export const LisDataAttributesRequestModel = { + Contact: "contact", + Company: "company", + Conversation: "conversation", +} as const; diff --git a/src/api/resources/unstable/resources/dataAttributes/types/index.ts b/src/api/resources/unstable/resources/dataAttributes/types/index.ts new file mode 100644 index 00000000..f452bb6b --- /dev/null +++ b/src/api/resources/unstable/resources/dataAttributes/types/index.ts @@ -0,0 +1,2 @@ +export * from "./LisDataAttributesRequestModel"; +export * from "./DataAttribute"; diff --git a/src/api/resources/unstable/resources/dataEvents/client/Client.ts b/src/api/resources/unstable/resources/dataEvents/client/Client.ts new file mode 100644 index 00000000..7349e445 --- /dev/null +++ b/src/api/resources/unstable/resources/dataEvents/client/Client.ts @@ -0,0 +1,413 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; +import { toJson } from "../../../../../../core/json"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace DataEvents { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + } +} + +/** + * Everything about your Data Events + */ +export class DataEvents { + constructor(protected readonly _options: DataEvents.Options = {}) {} + + /** + * + * > 🚧 + * > + * > Please note that you can only 'list' events that are less than 90 days old. Event counts and summaries will still include your events older than 90 days but you cannot 'list' these events individually if they are older than 90 days + * + * The events belonging to a customer can be listed by sending a GET request to `https://api.intercom.io/events` with a user or lead identifier along with a `type` parameter. The identifier parameter can be one of `user_id`, `email` or `intercom_user_id`. The `type` parameter value must be `user`. + * + * - `https://api.intercom.io/events?type=user&user_id={user_id}` + * - `https://api.intercom.io/events?type=user&email={email}` + * - `https://api.intercom.io/events?type=user&intercom_user_id={id}` (this call can be used to list leads) + * + * The `email` parameter value should be [url encoded](http://en.wikipedia.org/wiki/Percent-encoding) when sending. + * + * You can optionally define the result page size as well with the `per_page` parameter. + * + * @param {Intercom.unstable.LisDataEventsRequest} request + * @param {DataEvents.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.dataEvents.lisDataEvents({ + * filter: { + * user_id: "user_id" + * }, + * type: "type" + * }) + */ + public lisDataEvents( + request: Intercom.unstable.LisDataEventsRequest, + requestOptions?: DataEvents.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__lisDataEvents(request, requestOptions)); + } + + private async __lisDataEvents( + request: Intercom.unstable.LisDataEventsRequest, + requestOptions?: DataEvents.RequestOptions, + ): Promise> { + const { filter, type: type_, summary } = request; + const _queryParams: Record = {}; + _queryParams["filter"] = typeof filter === "string" ? filter : toJson(filter); + _queryParams["type"] = type_; + if (summary != null) { + _queryParams["summary"] = summary.toString(); + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "events", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.DataEventSummary, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /events."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * + * You will need an Access Token that has write permissions to send Events. Once you have a key you can submit events via POST to the Events resource, which is located at https://api.intercom.io/events, or you can send events using one of the client libraries. When working with the HTTP API directly a client should send the event with a `Content-Type` of `application/json`. + * + * When using the JavaScript API, [adding the code to your app](http://docs.intercom.io/configuring-Intercom/tracking-user-events-in-your-app) makes the Events API available. Once added, you can submit an event using the `trackEvent` method. This will associate the event with the Lead or currently logged-in user or logged-out visitor/lead and send it to Intercom. The final parameter is a map that can be used to send optional metadata about the event. + * + * With the Ruby client you pass a hash describing the event to `Intercom::Event.create`, or call the `track_user` method directly on the current user object (e.g. `user.track_event`). + * + * **NB: For the JSON object types, please note that we do not currently support nested JSON structure.** + * + * | Type | Description | Example | + * | :-------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-------------------------------------------------------------------------------- | + * | String | The value is a JSON String | `"source":"desktop"` | + * | Number | The value is a JSON Number | `"load": 3.67` | + * | Date | The key ends with the String `_date` and the value is a [Unix timestamp](http://en.wikipedia.org/wiki/Unix_time), assumed to be in the [UTC](http://en.wikipedia.org/wiki/Coordinated_Universal_Time) timezone. | `"contact_date": 1392036272` | + * | Link | The value is a HTTP or HTTPS URI. | `"article": "https://example.org/ab1de.html"` | + * | Rich Link | The value is a JSON object that contains `url` and `value` keys. | `"article": {"url": "https://example.org/ab1de.html", "value":"the dude abides"}` | + * | Monetary Amount | The value is a JSON object that contains `amount` and `currency` keys. The `amount` key is a positive integer representing the amount in cents. The price in the example to the right denotes €349.99. | `"price": {"amount": 34999, "currency": "eur"}` | + * + * **Lead Events** + * + * When submitting events for Leads, you will need to specify the Lead's `id`. + * + * **Metadata behaviour** + * + * - We currently limit the number of tracked metadata keys to 10 per event. Once the quota is reached, we ignore any further keys we receive. The first 10 metadata keys are determined by the order in which they are sent in with the event. + * - It is not possible to change the metadata keys once the event has been sent. A new event will need to be created with the new keys and you can archive the old one. + * - There might be up to 24 hrs delay when you send a new metadata for an existing event. + * + * **Event de-duplication** + * + * The API may detect and ignore duplicate events. Each event is uniquely identified as a combination of the following data - the Workspace identifier, the Contact external identifier, the Data Event name and the Data Event created time. As a result, it is **strongly recommended** to send a second granularity Unix timestamp in the `created_at` field. + * + * Duplicated events are responded to using the normal `202 Accepted` code - an error is not thrown, however repeat requests will be counted against any rate limit that is in place. + * + * ### HTTP API Responses + * + * - Successful responses to submitted events return `202 Accepted` with an empty body. + * - Unauthorised access will be rejected with a `401 Unauthorized` or `403 Forbidden` response code. + * - Events sent about users that cannot be found will return a `404 Not Found`. + * - Event lists containing duplicate events will have those duplicates ignored. + * - Server errors will return a `500` response code and may contain an error message in the body. + * + * @param {Intercom.CreateDataEventRequestTwo} request + * @param {DataEvents.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.dataEvents.createDataEvent({ + * "key": "value" + * }) + */ + public createDataEvent( + request?: Intercom.CreateDataEventRequestTwo, + requestOptions?: DataEvents.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createDataEvent(request, requestOptions)); + } + + private async __createDataEvent( + request?: Intercom.CreateDataEventRequestTwo, + requestOptions?: DataEvents.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "events", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /events."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * 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. + * + * @param {Intercom.unstable.CreateDataEventSummariesRequest} request + * @param {DataEvents.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.dataEvents.dataEventSummaries() + */ + public dataEventSummaries( + request: Intercom.unstable.CreateDataEventSummariesRequest = {}, + requestOptions?: DataEvents.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__dataEventSummaries(request, requestOptions)); + } + + private async __dataEventSummaries( + request: Intercom.unstable.CreateDataEventSummariesRequest = {}, + requestOptions?: DataEvents.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "events/summaries", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /events/summaries."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["INTERCOM_API_KEY"]; + if (bearer == null) { + throw new errors.IntercomError({ + message: + "Please specify a bearer by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", + }); + } + + return `Bearer ${bearer}`; + } +} diff --git a/src/api/resources/unstable/resources/dataEvents/client/index.ts b/src/api/resources/unstable/resources/dataEvents/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/api/resources/unstable/resources/dataEvents/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/unstable/resources/dataEvents/client/requests/CreateDataEventSummariesRequest.ts b/src/api/resources/unstable/resources/dataEvents/client/requests/CreateDataEventSummariesRequest.ts new file mode 100644 index 00000000..9e731802 --- /dev/null +++ b/src/api/resources/unstable/resources/dataEvents/client/requests/CreateDataEventSummariesRequest.ts @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + */ +export interface CreateDataEventSummariesRequest { + /** Your identifier for the user. */ + user_id?: string; + /** A list of event summaries for the user. Each event summary should contain the event name, the time the event occurred, and the number of times the event occurred. The event name should be a past tense 'verb-noun' combination, to improve readability, for example `updated-plan`. */ + event_summaries?: CreateDataEventSummariesRequest.EventSummaries; +} + +export namespace CreateDataEventSummariesRequest { + /** + * A list of event summaries for the user. Each event summary should contain the event name, the time the event occurred, and the number of times the event occurred. The event name should be a past tense 'verb-noun' combination, to improve readability, for example `updated-plan`. + */ + export interface EventSummaries { + /** The name of the event that occurred. A good event name is typically a past tense 'verb-noun' combination, to improve readability, for example `updated-plan`. */ + event_name?: string; + /** The number of times the event occurred. */ + count?: number; + /** The first time the event was sent */ + first?: number; + /** The last time the event was sent */ + last?: number; + } +} diff --git a/src/api/resources/unstable/resources/dataEvents/client/requests/LisDataEventsRequest.ts b/src/api/resources/unstable/resources/dataEvents/client/requests/LisDataEventsRequest.ts new file mode 100644 index 00000000..713df5e3 --- /dev/null +++ b/src/api/resources/unstable/resources/dataEvents/client/requests/LisDataEventsRequest.ts @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../../index"; + +/** + * @example + * { + * filter: { + * user_id: "user_id" + * }, + * type: "type" + * } + */ +export interface LisDataEventsRequest { + filter: Intercom.unstable.LisDataEventsRequestFilter; + /** + * The value must be user + */ + type: string; + /** + * summary flag + */ + summary?: boolean; +} diff --git a/src/api/resources/unstable/resources/dataEvents/client/requests/index.ts b/src/api/resources/unstable/resources/dataEvents/client/requests/index.ts new file mode 100644 index 00000000..59b33a62 --- /dev/null +++ b/src/api/resources/unstable/resources/dataEvents/client/requests/index.ts @@ -0,0 +1,2 @@ +export { type LisDataEventsRequest } from "./LisDataEventsRequest"; +export { type CreateDataEventSummariesRequest } from "./CreateDataEventSummariesRequest"; diff --git a/src/api/resources/unstable/resources/dataEvents/index.ts b/src/api/resources/unstable/resources/dataEvents/index.ts new file mode 100644 index 00000000..c9240f83 --- /dev/null +++ b/src/api/resources/unstable/resources/dataEvents/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/unstable/resources/dataEvents/types/DataEvent.ts b/src/api/resources/unstable/resources/dataEvents/types/DataEvent.ts new file mode 100644 index 00000000..124221eb --- /dev/null +++ b/src/api/resources/unstable/resources/dataEvents/types/DataEvent.ts @@ -0,0 +1,25 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Data events are used to notify Intercom of changes to your data. + */ +export interface DataEvent { + /** The type of the object */ + type?: "event"; + /** The name of the event that occurred. This is presented to your App's admins when filtering and creating segments - a good event name is typically a past tense 'verb-noun' combination, to improve readability, for example `updated-plan`. */ + event_name: string; + /** The time the event occurred as a UTC Unix timestamp */ + created_at: number; + /** Your identifier for the user. */ + user_id?: string; + /** Your identifier for a lead or a user. */ + id?: string; + /** The Intercom identifier for the user. */ + intercom_user_id?: string; + /** An email address for your user. An email should only be used where your application uses email to uniquely identify users. */ + email?: string; + /** Optional metadata about the event. */ + metadata?: Record; +} diff --git a/src/api/resources/unstable/resources/dataEvents/types/LisDataEventsRequestFilter.ts b/src/api/resources/unstable/resources/dataEvents/types/LisDataEventsRequestFilter.ts new file mode 100644 index 00000000..a12948ea --- /dev/null +++ b/src/api/resources/unstable/resources/dataEvents/types/LisDataEventsRequestFilter.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type LisDataEventsRequestFilter = + | { + user_id: string; + } + | { + intercom_user_id: string; + } + | { + email: string; + }; diff --git a/src/api/resources/unstable/resources/dataEvents/types/index.ts b/src/api/resources/unstable/resources/dataEvents/types/index.ts new file mode 100644 index 00000000..57668594 --- /dev/null +++ b/src/api/resources/unstable/resources/dataEvents/types/index.ts @@ -0,0 +1,2 @@ +export * from "./LisDataEventsRequestFilter"; +export * from "./DataEvent"; diff --git a/src/api/resources/customChannelEvents/client/Client.ts b/src/api/resources/unstable/resources/dataExport/client/Client.ts similarity index 54% rename from src/api/resources/customChannelEvents/client/Client.ts rename to src/api/resources/unstable/resources/dataExport/client/Client.ts index fa662231..6f6a2ebe 100644 --- a/src/api/resources/customChannelEvents/client/Client.ts +++ b/src/api/resources/unstable/resources/dataExport/client/Client.ts @@ -2,12 +2,13 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as environments from "../../../../environments"; -import * as core from "../../../../core"; +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; import urlJoin from "url-join"; -import * as errors from "../../../../errors/index"; +import * as errors from "../../../../../../errors/index"; -export declare namespace CustomChannelEvents { +export declare namespace DataExport { export interface Options { environment?: core.Supplier; /** Specify a custom URL to connect the client to. */ @@ -68,30 +69,63 @@ export declare namespace CustomChannelEvents { } } -export class CustomChannelEvents { - constructor(protected readonly _options: CustomChannelEvents.Options = {}) {} +/** + * Everything about your Data Exports + */ +export class DataExport { + constructor(protected readonly _options: DataExport.Options = {}) {} /** - * @param {CustomChannelEvents.RequestOptions} requestOptions - Request-specific configuration. + * To create your export job, you need to send a `POST` request to the export endpoint `https://api.intercom.io/export/content/data`. + * + * The only parameters you need to provide are the range of dates that you want exported. + * + * >🚧 Limit of one active job + * > + * > You can only have one active job per workspace. You will receive a HTTP status code of 429 with the message Exceeded rate limit of 1 pending message data export jobs if you attempt to create a second concurrent job. + * + * >❗️ Updated_at not included + * > + * > It should be noted that the timeframe only includes messages sent during the time period and not messages that were only updated during this period. For example, if a message was updated yesterday but sent two days ago, you would need to set the created_at_after date before the message was sent to include that in your retrieval job. + * + * >📘 Date ranges are inclusive + * > + * > 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. + * + * @param {Intercom.unstable.CreateDataExportsRequest} request + * @param {DataExport.RequestOptions} requestOptions - Request-specific configuration. * * @example - * await client.customChannelEvents.notifyAttributeCollected() + * await client.unstable.dataExport.createDataExport({ + * created_at_after: 1734519776, + * created_at_before: 1734537776 + * }) */ - public async notifyAttributeCollected(requestOptions?: CustomChannelEvents.RequestOptions): Promise { + public createDataExport( + request: Intercom.unstable.CreateDataExportsRequest, + requestOptions?: DataExport.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createDataExport(request, requestOptions)); + } + + private async __createDataExport( + request: Intercom.unstable.CreateDataExportsRequest, + requestOptions?: DataExport.RequestOptions, + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - "custom_channel_events/notify_attribute_collected", + "export/content/data", ), method: "POST", headers: { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -99,18 +133,20 @@ export class CustomChannelEvents { }, contentType: "application/json", requestType: "json", + body: request, timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, maxRetries: requestOptions?.maxRetries, abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return; + return { data: _response.body as Intercom.unstable.DataExport, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } @@ -119,39 +155,59 @@ export class CustomChannelEvents { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": - throw new errors.IntercomTimeoutError( - "Timeout exceeded when calling POST /custom_channel_events/notify_attribute_collected.", - ); + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /export/content/data."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } /** - * @param {CustomChannelEvents.RequestOptions} requestOptions - Request-specific configuration. + * You can view the status of your job by sending a `GET` request to the URL + * `https://api.intercom.io/export/content/data/{job_identifier}` - the `{job_identifier}` is the value returned in the response when you first created the export job. More on it can be seen in the Export Job Model. + * + * > 🚧 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. + * + * @param {Intercom.unstable.GetDataExportRequest} request + * @param {DataExport.RequestOptions} requestOptions - Request-specific configuration. * * @example - * await client.customChannelEvents.notifyNewMessage() + * await client.unstable.dataExport.getDataExport({ + * job_identifier: "job_identifier" + * }) */ - public async notifyNewMessage(requestOptions?: CustomChannelEvents.RequestOptions): Promise { + public getDataExport( + request: Intercom.unstable.GetDataExportRequest, + requestOptions?: DataExport.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__getDataExport(request, requestOptions)); + } + + private async __getDataExport( + request: Intercom.unstable.GetDataExportRequest, + requestOptions?: DataExport.RequestOptions, + ): Promise> { + const { job_identifier: jobIdentifier } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - "custom_channel_events/notify_new_message", + `export/content/data/${encodeURIComponent(jobIdentifier)}`, ), - method: "POST", + method: "GET", headers: { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -164,13 +220,14 @@ export class CustomChannelEvents { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return; + return { data: _response.body as Intercom.unstable.DataExport, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } @@ -179,39 +236,57 @@ export class CustomChannelEvents { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( - "Timeout exceeded when calling POST /custom_channel_events/notify_new_message.", + "Timeout exceeded when calling GET /export/content/data/{job_identifier}.", ); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } /** - * @param {CustomChannelEvents.RequestOptions} requestOptions - Request-specific configuration. + * You can cancel your job + * + * @param {Intercom.unstable.CancelDataExportRequest} request + * @param {DataExport.RequestOptions} requestOptions - Request-specific configuration. * * @example - * await client.customChannelEvents.notifyNewConversation() + * await client.unstable.dataExport.cancelDataExport({ + * job_identifier: "job_identifier" + * }) */ - public async notifyNewConversation(requestOptions?: CustomChannelEvents.RequestOptions): Promise { + public cancelDataExport( + request: Intercom.unstable.CancelDataExportRequest, + requestOptions?: DataExport.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__cancelDataExport(request, requestOptions)); + } + + private async __cancelDataExport( + request: Intercom.unstable.CancelDataExportRequest, + requestOptions?: DataExport.RequestOptions, + ): Promise> { + const { job_identifier: jobIdentifier } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - "custom_channel_events/notify_new_conversation", + `export/cancel/${encodeURIComponent(jobIdentifier)}`, ), method: "POST", headers: { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -224,13 +299,14 @@ export class CustomChannelEvents { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return; + return { data: _response.body as Intercom.unstable.DataExport, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } @@ -239,39 +315,63 @@ export class CustomChannelEvents { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( - "Timeout exceeded when calling POST /custom_channel_events/notify_new_conversation.", + "Timeout exceeded when calling POST /export/cancel/{job_identifier}.", ); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } /** - * @param {CustomChannelEvents.RequestOptions} requestOptions - Request-specific configuration. + * When a job has a status of complete, and thus a filled download_url, you can download your data by hitting that provided URL, formatted like so: https://api.intercom.io/download/content/data/xyz1234. + * + * Your exported message data will be streamed continuously back down to you in a gzipped CSV format. + * + * > 📘 Octet header required + * > + * > You will have to specify the header Accept: `application/octet-stream` when hitting this endpoint. + * + * @param {Intercom.unstable.DownloadDataExportRequest} request + * @param {DataExport.RequestOptions} requestOptions - Request-specific configuration. * * @example - * await client.customChannelEvents.notifyQuickReplySelected() + * await client.unstable.dataExport.downloadDataExport({ + * job_identifier: "job_identifier" + * }) */ - public async notifyQuickReplySelected(requestOptions?: CustomChannelEvents.RequestOptions): Promise { + public downloadDataExport( + request: Intercom.unstable.DownloadDataExportRequest, + requestOptions?: DataExport.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__downloadDataExport(request, requestOptions)); + } + + private async __downloadDataExport( + request: Intercom.unstable.DownloadDataExportRequest, + requestOptions?: DataExport.RequestOptions, + ): Promise> { + const { job_identifier: jobIdentifier } = request; const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? (await core.Supplier.get(this._options.environment)) ?? environments.IntercomEnvironment.UsProduction, - "custom_channel_events/notify_quick_reply_selected", + `download/content/data/${encodeURIComponent(jobIdentifier)}`, ), - method: "POST", + method: "GET", headers: { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -284,13 +384,14 @@ export class CustomChannelEvents { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return; + return { data: undefined, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } @@ -299,14 +400,16 @@ export class CustomChannelEvents { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError( - "Timeout exceeded when calling POST /custom_channel_events/notify_quick_reply_selected.", + "Timeout exceeded when calling GET /download/content/data/{job_identifier}.", ); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } diff --git a/src/api/resources/unstable/resources/dataExport/client/index.ts b/src/api/resources/unstable/resources/dataExport/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/api/resources/unstable/resources/dataExport/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/unstable/resources/dataExport/client/requests/CancelDataExportRequest.ts b/src/api/resources/unstable/resources/dataExport/client/requests/CancelDataExportRequest.ts new file mode 100644 index 00000000..39ed6925 --- /dev/null +++ b/src/api/resources/unstable/resources/dataExport/client/requests/CancelDataExportRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * job_identifier: "job_identifier" + * } + */ +export interface CancelDataExportRequest { + /** + * job_identifier + */ + job_identifier: string; +} diff --git a/src/api/resources/unstable/resources/dataExport/client/requests/CreateDataExportsRequest.ts b/src/api/resources/unstable/resources/dataExport/client/requests/CreateDataExportsRequest.ts new file mode 100644 index 00000000..78a96196 --- /dev/null +++ b/src/api/resources/unstable/resources/dataExport/client/requests/CreateDataExportsRequest.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * created_at_after: 1734519776, + * created_at_before: 1734537776 + * } + */ +export interface CreateDataExportsRequest { + /** The start date that you request data for. It must be formatted as a unix timestamp. */ + created_at_after: number; + /** The end date that you request data for. It must be formatted as a unix timestamp. */ + created_at_before: number; +} diff --git a/src/api/resources/unstable/resources/dataExport/client/requests/DownloadDataExportRequest.ts b/src/api/resources/unstable/resources/dataExport/client/requests/DownloadDataExportRequest.ts new file mode 100644 index 00000000..4a7ee828 --- /dev/null +++ b/src/api/resources/unstable/resources/dataExport/client/requests/DownloadDataExportRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * job_identifier: "job_identifier" + * } + */ +export interface DownloadDataExportRequest { + /** + * job_identifier + */ + job_identifier: string; +} diff --git a/src/api/resources/unstable/resources/dataExport/client/requests/GetDataExportRequest.ts b/src/api/resources/unstable/resources/dataExport/client/requests/GetDataExportRequest.ts new file mode 100644 index 00000000..b03dfb16 --- /dev/null +++ b/src/api/resources/unstable/resources/dataExport/client/requests/GetDataExportRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * job_identifier: "job_identifier" + * } + */ +export interface GetDataExportRequest { + /** + * job_identifier + */ + job_identifier: string; +} diff --git a/src/api/resources/unstable/resources/dataExport/client/requests/index.ts b/src/api/resources/unstable/resources/dataExport/client/requests/index.ts new file mode 100644 index 00000000..4f6d12f0 --- /dev/null +++ b/src/api/resources/unstable/resources/dataExport/client/requests/index.ts @@ -0,0 +1,4 @@ +export { type CreateDataExportsRequest } from "./CreateDataExportsRequest"; +export { type GetDataExportRequest } from "./GetDataExportRequest"; +export { type CancelDataExportRequest } from "./CancelDataExportRequest"; +export { type DownloadDataExportRequest } from "./DownloadDataExportRequest"; diff --git a/src/api/resources/unstable/resources/dataExport/index.ts b/src/api/resources/unstable/resources/dataExport/index.ts new file mode 100644 index 00000000..c9240f83 --- /dev/null +++ b/src/api/resources/unstable/resources/dataExport/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/unstable/resources/dataExport/types/DataExport.ts b/src/api/resources/unstable/resources/dataExport/types/DataExport.ts new file mode 100644 index 00000000..bd19f8c9 --- /dev/null +++ b/src/api/resources/unstable/resources/dataExport/types/DataExport.ts @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The data export api is used to view all message sent & viewed in a given timeframe. + */ +export interface DataExport { + /** The identifier for your job. */ + job_identfier?: string; + /** The current state of your job. */ + status?: DataExport.Status; + /** The time after which you will not be able to access the data. */ + download_expires_at?: string; + /** The location where you can download your data. */ + download_url?: string; +} + +export namespace DataExport { + /** + * The current state of your job. + */ + export type Status = "pending" | "in_progress" | "failed" | "completed" | "no_data" | "canceled"; + export const Status = { + Pending: "pending", + InProgress: "in_progress", + Failed: "failed", + Completed: "completed", + NoData: "no_data", + Canceled: "canceled", + } as const; +} diff --git a/src/api/resources/unstable/resources/dataExport/types/index.ts b/src/api/resources/unstable/resources/dataExport/types/index.ts new file mode 100644 index 00000000..7cea751a --- /dev/null +++ b/src/api/resources/unstable/resources/dataExport/types/index.ts @@ -0,0 +1 @@ +export * from "./DataExport"; diff --git a/src/api/resources/unstable/resources/export/client/Client.ts b/src/api/resources/unstable/resources/export/client/Client.ts new file mode 100644 index 00000000..b067f559 --- /dev/null +++ b/src/api/resources/unstable/resources/export/client/Client.ts @@ -0,0 +1,262 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace Export { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + } +} + +export class Export { + constructor(protected readonly _options: Export.Options = {}) {} + + /** + * @param {Intercom.unstable.PostExportReportingDataEnqueueRequest} request + * @param {Export.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.BadRequestError} + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.TooManyRequestsError} + * + * @example + * await client.unstable.export.enqueueANewReportingDataExportJob({ + * dataset_id: "conversation", + * attribute_ids: ["conversation.id", "conversation.first_user_conversation_part_created_at"], + * start_time: 1717490000, + * end_time: 1717510000 + * }) + */ + public enqueueANewReportingDataExportJob( + request: Intercom.unstable.PostExportReportingDataEnqueueRequest, + requestOptions?: Export.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__enqueueANewReportingDataExportJob(request, requestOptions)); + } + + private async __enqueueANewReportingDataExportJob( + request: Intercom.unstable.PostExportReportingDataEnqueueRequest, + requestOptions?: Export.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "export/reporting_data/enqueue", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.PostExportReportingDataEnqueueResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 429: + throw new Intercom.unstable.TooManyRequestsError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling POST /export/reporting_data/enqueue.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * @param {Export.RequestOptions} requestOptions - Request-specific configuration. + * + * @example + * await client.unstable.export.listAvailableDatasetsAndAttributes() + */ + public listAvailableDatasetsAndAttributes( + requestOptions?: Export.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listAvailableDatasetsAndAttributes(requestOptions)); + } + + private async __listAvailableDatasetsAndAttributes( + requestOptions?: Export.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "export/reporting_data/get_datasets", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.GetExportReportingDataGetDatasetsResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling GET /export/reporting_data/get_datasets.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["INTERCOM_API_KEY"]; + if (bearer == null) { + throw new errors.IntercomError({ + message: + "Please specify a bearer by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", + }); + } + + return `Bearer ${bearer}`; + } +} diff --git a/src/api/resources/unstable/resources/export/client/index.ts b/src/api/resources/unstable/resources/export/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/api/resources/unstable/resources/export/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/unstable/resources/export/client/requests/PostExportReportingDataEnqueueRequest.ts b/src/api/resources/unstable/resources/export/client/requests/PostExportReportingDataEnqueueRequest.ts new file mode 100644 index 00000000..55c7d4f8 --- /dev/null +++ b/src/api/resources/unstable/resources/export/client/requests/PostExportReportingDataEnqueueRequest.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * dataset_id: "conversation", + * attribute_ids: ["conversation.id", "conversation.first_user_conversation_part_created_at"], + * start_time: 1717490000, + * end_time: 1717510000 + * } + */ +export interface PostExportReportingDataEnqueueRequest { + dataset_id: string; + attribute_ids: string[]; + start_time: number; + end_time: number; +} diff --git a/src/api/resources/unstable/resources/export/client/requests/index.ts b/src/api/resources/unstable/resources/export/client/requests/index.ts new file mode 100644 index 00000000..bcda81be --- /dev/null +++ b/src/api/resources/unstable/resources/export/client/requests/index.ts @@ -0,0 +1 @@ +export { type PostExportReportingDataEnqueueRequest } from "./PostExportReportingDataEnqueueRequest"; diff --git a/src/api/resources/unstable/resources/export/index.ts b/src/api/resources/unstable/resources/export/index.ts new file mode 100644 index 00000000..c9240f83 --- /dev/null +++ b/src/api/resources/unstable/resources/export/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/unstable/resources/export/types/GetExportReportingDataGetDatasetsResponse.ts b/src/api/resources/unstable/resources/export/types/GetExportReportingDataGetDatasetsResponse.ts new file mode 100644 index 00000000..ab8c3ba6 --- /dev/null +++ b/src/api/resources/unstable/resources/export/types/GetExportReportingDataGetDatasetsResponse.ts @@ -0,0 +1,33 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface GetExportReportingDataGetDatasetsResponse { + type?: string; + data?: GetExportReportingDataGetDatasetsResponse.Data.Item[]; +} + +export namespace GetExportReportingDataGetDatasetsResponse { + export type Data = Data.Item[]; + + export namespace Data { + export interface Item { + id?: string; + name?: string; + description?: string; + default_time_attribute_id?: string; + attributes?: Item.Attributes.Item[]; + } + + export namespace Item { + export type Attributes = Attributes.Item[]; + + export namespace Attributes { + export interface Item { + id?: string; + name?: string; + } + } + } + } +} diff --git a/src/api/resources/unstable/resources/export/types/PostExportReportingDataEnqueueResponse.ts b/src/api/resources/unstable/resources/export/types/PostExportReportingDataEnqueueResponse.ts new file mode 100644 index 00000000..55a28e65 --- /dev/null +++ b/src/api/resources/unstable/resources/export/types/PostExportReportingDataEnqueueResponse.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface PostExportReportingDataEnqueueResponse { + job_identifier?: string; + status?: string; + download_url?: string; + download_expires_at?: string; +} diff --git a/src/api/resources/unstable/resources/export/types/index.ts b/src/api/resources/unstable/resources/export/types/index.ts new file mode 100644 index 00000000..cc8706ee --- /dev/null +++ b/src/api/resources/unstable/resources/export/types/index.ts @@ -0,0 +1,2 @@ +export * from "./PostExportReportingDataEnqueueResponse"; +export * from "./GetExportReportingDataGetDatasetsResponse"; diff --git a/src/api/resources/unstable/resources/helpCenter/client/Client.ts b/src/api/resources/unstable/resources/helpCenter/client/Client.ts new file mode 100644 index 00000000..776053b4 --- /dev/null +++ b/src/api/resources/unstable/resources/helpCenter/client/Client.ts @@ -0,0 +1,722 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace HelpCenter { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + } +} + +/** + * Everything about your Help Center + */ +export class HelpCenter { + constructor(protected readonly _options: HelpCenter.Options = {}) {} + + /** + * You can fetch a list of all collections by making a GET request to `https://api.intercom.io/help_center/collections`. + * + * 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. + * + * @param {HelpCenter.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.helpCenter.listAllCollections() + */ + public listAllCollections( + requestOptions?: HelpCenter.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listAllCollections(requestOptions)); + } + + private async __listAllCollections( + requestOptions?: HelpCenter.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "help_center/collections", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.CollectionList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /help_center/collections."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can create a new collection by making a POST request to `https://api.intercom.io/help_center/collections.` + * + * @param {Intercom.unstable.CreateCollectionRequest} request + * @param {HelpCenter.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.BadRequestError} + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.helpCenter.createCollection({ + * name: "Thanks for everything" + * }) + * + * @example + * await client.unstable.helpCenter.createCollection({ + * name: "collection 51", + * description: "Missing required parameter" + * }) + */ + public createCollection( + request: Intercom.unstable.CreateCollectionRequest, + requestOptions?: HelpCenter.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createCollection(request, requestOptions)); + } + + private async __createCollection( + request: Intercom.unstable.CreateCollectionRequest, + requestOptions?: HelpCenter.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "help_center/collections", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Collection, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /help_center/collections."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can fetch the details of a single collection by making a GET request to `https://api.intercom.io/help_center/collections/`. + * + * @param {Intercom.unstable.RetrieveCollectionRequest} request + * @param {HelpCenter.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.helpCenter.retrieveCollection({ + * id: 1 + * }) + */ + public retrieveCollection( + request: Intercom.unstable.RetrieveCollectionRequest, + requestOptions?: HelpCenter.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveCollection(request, requestOptions)); + } + + private async __retrieveCollection( + request: Intercom.unstable.RetrieveCollectionRequest, + requestOptions?: HelpCenter.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `help_center/collections/${encodeURIComponent(id)}`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Collection, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling GET /help_center/collections/{id}.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can update the details of a single collection by making a PUT request to `https://api.intercom.io/collections/`. + * + * @param {Intercom.unstable.UpdateCollectionRequest} request + * @param {HelpCenter.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.helpCenter.updateCollection({ + * id: 1, + * name: "Update collection name" + * }) + */ + public updateCollection( + request: Intercom.unstable.UpdateCollectionRequest, + requestOptions?: HelpCenter.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__updateCollection(request, requestOptions)); + } + + private async __updateCollection( + request: Intercom.unstable.UpdateCollectionRequest, + requestOptions?: HelpCenter.RequestOptions, + ): Promise> { + const { id, ..._body } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `help_center/collections/${encodeURIComponent(id)}`, + ), + method: "PUT", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: _body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Collection, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling PUT /help_center/collections/{id}.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can delete a single collection by making a DELETE request to `https://api.intercom.io/collections/`. + * + * @param {Intercom.unstable.DeleteCollectionRequest} request + * @param {HelpCenter.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.helpCenter.deleteCollection({ + * id: 1 + * }) + */ + public deleteCollection( + request: Intercom.unstable.DeleteCollectionRequest, + requestOptions?: HelpCenter.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteCollection(request, requestOptions)); + } + + private async __deleteCollection( + request: Intercom.unstable.DeleteCollectionRequest, + requestOptions?: HelpCenter.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `help_center/collections/${encodeURIComponent(id)}`, + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.DeletedCollectionObject, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling DELETE /help_center/collections/{id}.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can fetch the details of a single Help Center by making a GET request to `https://api.intercom.io/help_center/help_center/`. + * + * @param {Intercom.unstable.RetrieveHelpCenterRequest} request + * @param {HelpCenter.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.helpCenter.retrieveHelpCenter({ + * id: 1 + * }) + */ + public retrieveHelpCenter( + request: Intercom.unstable.RetrieveHelpCenterRequest, + requestOptions?: HelpCenter.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveHelpCenter(request, requestOptions)); + } + + private async __retrieveHelpCenter( + request: Intercom.unstable.RetrieveHelpCenterRequest, + requestOptions?: HelpCenter.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `help_center/help_centers/${encodeURIComponent(id)}`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.HelpCenter, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling GET /help_center/help_centers/{id}.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can list all Help Centers by making a GET request to `https://api.intercom.io/help_center/help_centers`. + * + * @param {HelpCenter.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.helpCenter.listHelpCenters() + */ + public listHelpCenters( + requestOptions?: HelpCenter.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listHelpCenters(requestOptions)); + } + + private async __listHelpCenters( + requestOptions?: HelpCenter.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "help_center/help_centers", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.HelpCenterList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /help_center/help_centers."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["INTERCOM_API_KEY"]; + if (bearer == null) { + throw new errors.IntercomError({ + message: + "Please specify a bearer by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", + }); + } + + return `Bearer ${bearer}`; + } +} diff --git a/src/api/resources/unstable/resources/helpCenter/client/index.ts b/src/api/resources/unstable/resources/helpCenter/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/api/resources/unstable/resources/helpCenter/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/unstable/resources/helpCenter/client/requests/CreateCollectionRequest.ts b/src/api/resources/unstable/resources/helpCenter/client/requests/CreateCollectionRequest.ts new file mode 100644 index 00000000..7b50caa9 --- /dev/null +++ b/src/api/resources/unstable/resources/helpCenter/client/requests/CreateCollectionRequest.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../../index"; + +/** + * @example + * { + * name: "Thanks for everything" + * } + * + * @example + * { + * name: "collection 51", + * description: "Missing required parameter" + * } + */ +export interface CreateCollectionRequest { + /** The name of the collection. For multilingual collections, this will be the name of the default language's content. */ + name: string; + /** The description of the collection. For multilingual collections, this will be the description of the default language's content. */ + description?: string; + translated_content?: Intercom.unstable.GroupTranslatedContent; + /** The id of the parent collection. If `null` then it will be created as the first level collection. */ + parent_id?: string; + /** The id of the help center where the collection will be created. If `null` then it will be created in the default help center. */ + help_center_id?: number; +} diff --git a/src/api/resources/unstable/resources/helpCenter/client/requests/DeleteCollectionRequest.ts b/src/api/resources/unstable/resources/helpCenter/client/requests/DeleteCollectionRequest.ts new file mode 100644 index 00000000..eaf33993 --- /dev/null +++ b/src/api/resources/unstable/resources/helpCenter/client/requests/DeleteCollectionRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: 1 + * } + */ +export interface DeleteCollectionRequest { + /** + * The unique identifier for the collection which is given by Intercom. + */ + id: number; +} diff --git a/src/api/resources/unstable/resources/helpCenter/client/requests/RetrieveCollectionRequest.ts b/src/api/resources/unstable/resources/helpCenter/client/requests/RetrieveCollectionRequest.ts new file mode 100644 index 00000000..4737b56b --- /dev/null +++ b/src/api/resources/unstable/resources/helpCenter/client/requests/RetrieveCollectionRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: 1 + * } + */ +export interface RetrieveCollectionRequest { + /** + * The unique identifier for the collection which is given by Intercom. + */ + id: number; +} diff --git a/src/api/resources/unstable/resources/helpCenter/client/requests/RetrieveHelpCenterRequest.ts b/src/api/resources/unstable/resources/helpCenter/client/requests/RetrieveHelpCenterRequest.ts new file mode 100644 index 00000000..42057096 --- /dev/null +++ b/src/api/resources/unstable/resources/helpCenter/client/requests/RetrieveHelpCenterRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: 1 + * } + */ +export interface RetrieveHelpCenterRequest { + /** + * The unique identifier for the collection which is given by Intercom. + */ + id: number; +} diff --git a/src/api/resources/unstable/resources/helpCenter/client/requests/UpdateCollectionRequest.ts b/src/api/resources/unstable/resources/helpCenter/client/requests/UpdateCollectionRequest.ts new file mode 100644 index 00000000..58505b62 --- /dev/null +++ b/src/api/resources/unstable/resources/helpCenter/client/requests/UpdateCollectionRequest.ts @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../../index"; + +/** + * @example + * { + * id: 1, + * name: "Update collection name" + * } + * + * @example + * { + * id: 1, + * name: "Update collection name" + * } + */ +export interface UpdateCollectionRequest { + /** + * The unique identifier for the collection which is given by Intercom. + */ + id: number; + /** The name of the collection. For multilingual collections, this will be the name of the default language's content. */ + name?: string; + /** The description of the collection. For multilingual collections, this will be the description of the default language's content. */ + description?: string; + translated_content?: Intercom.unstable.GroupTranslatedContent; + /** The id of the parent collection. If `null` then it will be updated as the first level collection. */ + parent_id?: string; +} diff --git a/src/api/resources/unstable/resources/helpCenter/client/requests/index.ts b/src/api/resources/unstable/resources/helpCenter/client/requests/index.ts new file mode 100644 index 00000000..b39271fa --- /dev/null +++ b/src/api/resources/unstable/resources/helpCenter/client/requests/index.ts @@ -0,0 +1,5 @@ +export { type CreateCollectionRequest } from "./CreateCollectionRequest"; +export { type RetrieveCollectionRequest } from "./RetrieveCollectionRequest"; +export { type UpdateCollectionRequest } from "./UpdateCollectionRequest"; +export { type DeleteCollectionRequest } from "./DeleteCollectionRequest"; +export { type RetrieveHelpCenterRequest } from "./RetrieveHelpCenterRequest"; diff --git a/src/api/resources/unstable/resources/helpCenter/index.ts b/src/api/resources/unstable/resources/helpCenter/index.ts new file mode 100644 index 00000000..c9240f83 --- /dev/null +++ b/src/api/resources/unstable/resources/helpCenter/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/unstable/resources/helpCenter/types/Collection.ts b/src/api/resources/unstable/resources/helpCenter/types/Collection.ts new file mode 100644 index 00000000..ef0fa2ec --- /dev/null +++ b/src/api/resources/unstable/resources/helpCenter/types/Collection.ts @@ -0,0 +1,36 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +/** + * Collections are top level containers for Articles within the Help Center. + */ +export interface Collection { + /** The unique identifier for the collection which is given by Intercom. */ + id?: string; + /** The id of the workspace which the collection belongs to. */ + workspace_id?: string; + /** The name of the collection. For multilingual collections, this will be the name of the default language's content. */ + name?: string; + /** The description of the collection. For multilingual help centers, this will be the description of the collection for the default language. */ + description?: string; + /** The time when the article was created (seconds). For multilingual articles, this will be the timestamp of creation of the default language's content. */ + created_at?: number; + /** The time when the article was last updated (seconds). For multilingual articles, this will be the timestamp of last update of the default language's content. */ + updated_at?: number; + /** The URL of the collection. For multilingual help centers, this will be the URL of the collection for the default language. */ + url?: string; + /** The icon of the collection. */ + icon?: string; + /** The order of the section in relation to others sections within a collection. Values go from `0` upwards. `0` is the default if there's no order. */ + order?: number; + /** The default locale of the help center. This field is only returned for multilingual help centers. */ + default_locale?: string; + translated_content?: Intercom.unstable.GroupTranslatedContent; + /** The id of the parent collection. If `null` then it is the first level collection. */ + parent_id?: string; + /** The id of the help center the collection is in. */ + help_center_id?: number; +} diff --git a/src/api/resources/unstable/resources/helpCenter/types/HelpCenter.ts b/src/api/resources/unstable/resources/helpCenter/types/HelpCenter.ts new file mode 100644 index 00000000..30cba20e --- /dev/null +++ b/src/api/resources/unstable/resources/helpCenter/types/HelpCenter.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Help Centers contain collections + */ +export interface HelpCenter { + /** The unique identifier for the Help Center which is given by Intercom. */ + id?: string; + /** The id of the workspace which the Help Center belongs to. */ + workspace_id?: string; + /** The time when the Help Center was created. */ + created_at?: number; + /** The time when the Help Center was last updated. */ + updated_at?: number; + /** The identifier of the Help Center. This is used in the URL of the Help Center. */ + identifier?: string; + /** Whether the Help Center is turned on or not. This is controlled in your Help Center settings. */ + website_turned_on?: boolean; + /** The display name of the Help Center only seen by teammates. */ + display_name?: string; +} diff --git a/src/api/resources/unstable/resources/helpCenter/types/HelpCenterList.ts b/src/api/resources/unstable/resources/helpCenter/types/HelpCenterList.ts new file mode 100644 index 00000000..ee6c2a05 --- /dev/null +++ b/src/api/resources/unstable/resources/helpCenter/types/HelpCenterList.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +/** + * A list of Help Centers belonging to the App + */ +export interface HelpCenterList { + /** The type of the object - `list`. */ + type?: "list"; + /** An array of Help Center objects */ + data?: Intercom.unstable.HelpCenter[]; +} diff --git a/src/api/resources/unstable/resources/helpCenter/types/index.ts b/src/api/resources/unstable/resources/helpCenter/types/index.ts new file mode 100644 index 00000000..65d348a7 --- /dev/null +++ b/src/api/resources/unstable/resources/helpCenter/types/index.ts @@ -0,0 +1,3 @@ +export * from "./Collection"; +export * from "./HelpCenter"; +export * from "./HelpCenterList"; diff --git a/src/api/resources/unstable/resources/index.ts b/src/api/resources/unstable/resources/index.ts new file mode 100644 index 00000000..a7c8f375 --- /dev/null +++ b/src/api/resources/unstable/resources/index.ts @@ -0,0 +1,78 @@ +export * as admins from "./admins"; +export * from "./admins/types"; +export * as aiContent from "./aiContent"; +export * from "./aiContent/types"; +export * as articles from "./articles"; +export * from "./articles/types"; +export * as export_ from "./export"; +export * from "./export/types"; +export * as helpCenter from "./helpCenter"; +export * from "./helpCenter/types"; +export * as companies from "./companies"; +export * from "./companies/types"; +export * as contacts from "./contacts"; +export * from "./contacts/types"; +export * as notes from "./notes"; +export * from "./notes/types"; +export * as subscriptionTypes from "./subscriptionTypes"; +export * from "./subscriptionTypes/types"; +export * as tags from "./tags"; +export * from "./tags/types"; +export * as conversations from "./conversations"; +export * from "./conversations/types"; +export * as customObjectInstances from "./customObjectInstances"; +export * from "./customObjectInstances/types"; +export * as dataAttributes from "./dataAttributes"; +export * from "./dataAttributes/types"; +export * as dataEvents from "./dataEvents"; +export * from "./dataEvents/types"; +export * as dataExport from "./dataExport"; +export * from "./dataExport/types"; +export * as jobs from "./jobs"; +export * from "./jobs/types"; +export * as messages from "./messages"; +export * from "./messages/types"; +export * as news from "./news"; +export * from "./news/types"; +export * as segments from "./segments"; +export * from "./segments/types"; +export * as teams from "./teams"; +export * from "./teams/types"; +export * as tickets from "./tickets"; +export * from "./tickets/types"; +export * as aiAgent from "./aiAgent"; +export * from "./aiAgent/types"; +export * as aiContentSource from "./aiContentSource"; +export * from "./aiContentSource/types"; +export * as awayStatusReasons from "./awayStatusReasons"; +export * as customChannelEvents from "./customChannelEvents"; +export * as switch_ from "./switch"; +export * as ticketStates from "./ticketStates"; +export * as ticketTypeAttributes from "./ticketTypeAttributes"; +export * as ticketTypes from "./ticketTypes"; +export * as visitors from "./visitors"; +export * from "./admins/client/requests"; +export * from "./aiContent/client/requests"; +export * from "./articles/client/requests"; +export * from "./export/client/requests"; +export * from "./helpCenter/client/requests"; +export * from "./companies/client/requests"; +export * from "./contacts/client/requests"; +export * from "./notes/client/requests"; +export * from "./subscriptionTypes/client/requests"; +export * from "./tags/client/requests"; +export * from "./conversations/client/requests"; +export * from "./customChannelEvents/client/requests"; +export * from "./customObjectInstances/client/requests"; +export * from "./dataAttributes/client/requests"; +export * from "./dataEvents/client/requests"; +export * from "./dataExport/client/requests"; +export * from "./jobs/client/requests"; +export * from "./messages/client/requests"; +export * from "./news/client/requests"; +export * from "./segments/client/requests"; +export * from "./teams/client/requests"; +export * from "./ticketTypeAttributes/client/requests"; +export * from "./ticketTypes/client/requests"; +export * from "./tickets/client/requests"; +export * from "./visitors/client/requests"; diff --git a/src/api/resources/unstable/resources/jobs/client/Client.ts b/src/api/resources/unstable/resources/jobs/client/Client.ts new file mode 100644 index 00000000..3c114bdf --- /dev/null +++ b/src/api/resources/unstable/resources/jobs/client/Client.ts @@ -0,0 +1,179 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace Jobs { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + } +} + +/** + * Everything about jobs + */ +export class Jobs { + constructor(protected readonly _options: Jobs.Options = {}) {} + + /** + * Retrieve the status of job execution. + * + * @param {Intercom.unstable.JobsStatusRequest} request + * @param {Jobs.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.jobs.status({ + * id: "id" + * }) + */ + public status( + request: Intercom.unstable.JobsStatusRequest, + requestOptions?: Jobs.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__status(request, requestOptions)); + } + + private async __status( + request: Intercom.unstable.JobsStatusRequest, + requestOptions?: Jobs.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `jobs/status/${encodeURIComponent(id)}`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Jobs, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /jobs/status/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["INTERCOM_API_KEY"]; + if (bearer == null) { + throw new errors.IntercomError({ + message: + "Please specify a bearer by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", + }); + } + + return `Bearer ${bearer}`; + } +} diff --git a/src/api/resources/unstable/resources/jobs/client/index.ts b/src/api/resources/unstable/resources/jobs/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/api/resources/unstable/resources/jobs/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/unstable/resources/jobs/client/requests/JobsStatusRequest.ts b/src/api/resources/unstable/resources/jobs/client/requests/JobsStatusRequest.ts new file mode 100644 index 00000000..861e1c7d --- /dev/null +++ b/src/api/resources/unstable/resources/jobs/client/requests/JobsStatusRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "id" + * } + */ +export interface JobsStatusRequest { + /** + * The unique identifier for the job which is given by Intercom + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/jobs/client/requests/index.ts b/src/api/resources/unstable/resources/jobs/client/requests/index.ts new file mode 100644 index 00000000..0d9f97d0 --- /dev/null +++ b/src/api/resources/unstable/resources/jobs/client/requests/index.ts @@ -0,0 +1 @@ +export { type JobsStatusRequest } from "./JobsStatusRequest"; diff --git a/src/api/resources/unstable/resources/jobs/index.ts b/src/api/resources/unstable/resources/jobs/index.ts new file mode 100644 index 00000000..c9240f83 --- /dev/null +++ b/src/api/resources/unstable/resources/jobs/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/unstable/resources/jobs/types/Jobs.ts b/src/api/resources/unstable/resources/jobs/types/Jobs.ts new file mode 100644 index 00000000..e2192f11 --- /dev/null +++ b/src/api/resources/unstable/resources/jobs/types/Jobs.ts @@ -0,0 +1,35 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Jobs are tasks that are processed asynchronously by the Intercom system after being enqueued via the API. This allows for efficient handling of operations that may take time to complete, such as data imports or exports. You can check the status of your jobs to monitor their progress and ensure they are completed successfully. + */ +export interface Jobs { + /** The type of the object */ + type?: "job"; + /** The id of the job that's currently being processed or has completed. */ + id: string; + /** API endpoint URL to check the job status. */ + url?: string; + /** The status of the job execution. */ + status?: Jobs.Status; + /** The type of resource created during job execution. */ + resource_type?: string; + /** The id of the resource created during job execution (e.g. ticket id) */ + resource_id?: string; + /** The url of the resource created during job exeuction. Use this url to fetch the resource. */ + resource_url?: string; +} + +export namespace Jobs { + /** + * The status of the job execution. + */ + export type Status = "pending" | "success" | "failed"; + export const Status = { + Pending: "pending", + Success: "success", + Failed: "failed", + } as const; +} diff --git a/src/api/resources/unstable/resources/jobs/types/index.ts b/src/api/resources/unstable/resources/jobs/types/index.ts new file mode 100644 index 00000000..c46ba3db --- /dev/null +++ b/src/api/resources/unstable/resources/jobs/types/index.ts @@ -0,0 +1 @@ +export * from "./Jobs"; diff --git a/src/api/resources/unstable/resources/messages/client/Client.ts b/src/api/resources/unstable/resources/messages/client/Client.ts new file mode 100644 index 00000000..e49625bc --- /dev/null +++ b/src/api/resources/unstable/resources/messages/client/Client.ts @@ -0,0 +1,446 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace Messages { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + } +} + +/** + * Everything about your messages + */ +export class Messages { + constructor(protected readonly _options: Messages.Options = {}) {} + + /** + * You can create a message that has been initiated by an admin. The conversation can be either an in-app message, an email or sms. + * + * > 🚧 Sending for visitors + * > + * > There can be a short delay between when a contact is created and when a contact becomes available to be messaged through the API. A 404 Not Found error will be returned in this case. + * + * This will return the Message model that has been created. + * + * > 🚧 Retrieving Associated Conversations + * > + * > 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 {Intercom.CreateMessageRequestTwo} request + * @param {Messages.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.BadRequestError} + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.ForbiddenError} + * @throws {@link Intercom.unstable.UnprocessableEntityError} + * + * @example + * await client.unstable.messages.createMessage({ + * "from": { + * "type": "user", + * "id": "6762f2341bb69f9f2193bc17" + * }, + * "body": "heyy", + * "referer": "https://twitter.com/bob" + * }) + * + * @example + * await client.unstable.messages.createMessage({ + * "from": { + * "type": "lead", + * "id": "6762f2371bb69f9f2193bc18" + * }, + * "body": "heyy", + * "referer": "https://twitter.com/bob" + * }) + * + * @example + * await client.unstable.messages.createMessage({ + * "from": { + * "type": "admin", + * "id": "991267816" + * }, + * "to": [ + * { + * "type": "user", + * "id": "6762f2391bb69f9f2193bc19" + * }, + * { + * "type": "lead", + * "id": "6762f23c1bb69f9f2193bc1b" + * }, + * { + * "type": "user", + * "id": "6762f23d1bb69f9f2193bc1c" + * } + * ], + * "cc": [ + * { + * "type": "user", + * "id": "6762f23e1bb69f9f2193bc1d" + * }, + * { + * "type": "user", + * "id": "6762f23f1bb69f9f2193bc1e" + * } + * ], + * "bcc": [ + * { + * "type": "user", + * "id": "6762f23e1bb69f9f2193bc2f" + * } + * ], + * "message_type": "conversation", + * "body": "heyy" + * }) + * + * @example + * await client.unstable.messages.createMessage({ + * "from": { + * "type": "admin", + * "id": "991267817" + * }, + * "to": { + * "type": "user", + * "id": "6762f23a1bb69f9f2193bc1a" + * }, + * "message_type": "sms", + * "body": "heyy" + * }) + * + * @example + * await client.unstable.messages.createMessage({ + * "from": { + * "type": "admin", + * "id": "991267818" + * }, + * "to": { + * "type": "user", + * "id": "6762f23b1bb69f9f2193bc1a" + * }, + * "message_type": "inapp", + * "subject": "heyy" + * }) + * + * @example + * await client.unstable.messages.createMessage({ + * "from": { + * "type": "admin", + * "id": "991267819" + * }, + * "to": { + * "type": "user", + * "user_id": "70" + * }, + * "message_type": "email", + * "body": "hey there" + * }) + * + * @example + * await client.unstable.messages.createMessage({ + * "from": { + * "type": "admin", + * "id": "991267820" + * }, + * "to": { + * "type": "user", + * "id": "6762f23d1bb69f9f2193bc1c" + * }, + * "message_type": "email", + * "subject": "heyy" + * }) + * + * @example + * await client.unstable.messages.createMessage({ + * "from": { + * "type": "admin", + * "id": "991267821" + * }, + * "to": { + * "type": "user", + * "id": "6762f23b1bb69f9f2193bc1d" + * }, + * "message_type": "sms", + * "body": "heyy https://picsum.photos/200/300" + * }) + */ + public createMessage( + request?: Intercom.CreateMessageRequestTwo, + requestOptions?: Messages.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createMessage(request, requestOptions)); + } + + private async __createMessage( + request?: Intercom.CreateMessageRequestTwo, + requestOptions?: Messages.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "messages", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Message, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.unstable.ForbiddenError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 422: + throw new Intercom.unstable.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /messages."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * Retrieves statuses of messages sent from the Outbound module. Currently, this API only supports WhatsApp messages. + * + * + * This endpoint returns paginated status events for WhatsApp messages sent via the Outbound module, providing + * information about delivery state and related message details. + * + * @param {Intercom.unstable.GetWhatsAppMessageStatusRequest} request + * @param {Messages.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.BadRequestError} + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.ForbiddenError} + * @throws {@link Intercom.unstable.InternalServerError} + * + * @example + * await client.unstable.messages.getWhatsAppMessageStatus({ + * ruleset_id: "ruleset_id" + * }) + */ + public getWhatsAppMessageStatus( + request: Intercom.unstable.GetWhatsAppMessageStatusRequest, + requestOptions?: Messages.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__getWhatsAppMessageStatus(request, requestOptions)); + } + + private async __getWhatsAppMessageStatus( + request: Intercom.unstable.GetWhatsAppMessageStatusRequest, + requestOptions?: Messages.RequestOptions, + ): Promise> { + const { ruleset_id: rulesetId, per_page: perPage, starting_after: startingAfter } = request; + const _queryParams: Record = {}; + _queryParams["ruleset_id"] = rulesetId; + if (perPage != null) { + _queryParams["per_page"] = perPage.toString(); + } + + if (startingAfter != null) { + _queryParams["starting_after"] = startingAfter; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "messages/status", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.WhatsappMessageStatusList, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 403: + throw new Intercom.unstable.ForbiddenError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 500: + throw new Intercom.unstable.InternalServerError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /messages/status."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["INTERCOM_API_KEY"]; + if (bearer == null) { + throw new errors.IntercomError({ + message: + "Please specify a bearer by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", + }); + } + + return `Bearer ${bearer}`; + } +} diff --git a/src/api/resources/unstable/resources/messages/client/index.ts b/src/api/resources/unstable/resources/messages/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/api/resources/unstable/resources/messages/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/unstable/resources/messages/client/requests/GetWhatsAppMessageStatusRequest.ts b/src/api/resources/unstable/resources/messages/client/requests/GetWhatsAppMessageStatusRequest.ts new file mode 100644 index 00000000..9f14d703 --- /dev/null +++ b/src/api/resources/unstable/resources/messages/client/requests/GetWhatsAppMessageStatusRequest.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * ruleset_id: "ruleset_id" + * } + */ +export interface GetWhatsAppMessageStatusRequest { + /** + * The unique identifier for the set of messages to check status for + */ + ruleset_id: string; + /** + * Number of results per page (default 50, max 100) + */ + per_page?: number; + /** + * Cursor for pagination, used to fetch the next page of results + */ + starting_after?: string; +} diff --git a/src/api/resources/unstable/resources/messages/client/requests/index.ts b/src/api/resources/unstable/resources/messages/client/requests/index.ts new file mode 100644 index 00000000..73c16159 --- /dev/null +++ b/src/api/resources/unstable/resources/messages/client/requests/index.ts @@ -0,0 +1 @@ +export { type GetWhatsAppMessageStatusRequest } from "./GetWhatsAppMessageStatusRequest"; diff --git a/src/api/resources/unstable/resources/messages/index.ts b/src/api/resources/unstable/resources/messages/index.ts new file mode 100644 index 00000000..c9240f83 --- /dev/null +++ b/src/api/resources/unstable/resources/messages/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/unstable/resources/messages/types/Message.ts b/src/api/resources/unstable/resources/messages/types/Message.ts new file mode 100644 index 00000000..35585c59 --- /dev/null +++ b/src/api/resources/unstable/resources/messages/types/Message.ts @@ -0,0 +1,37 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Message are how you reach out to contacts in Intercom. They are created when an admin sends an outbound message to a contact. + */ +export interface Message { + /** The type of the message */ + type: string; + /** The id representing the message. */ + id: string; + /** The time the conversation was created. */ + created_at: number; + /** The subject of the message. Only present if message_type: email. */ + subject?: string; + /** The message body, which may contain HTML. */ + body: string; + /** The type of message that was sent. Can be email, inapp, facebook ,twitter or sms. */ + message_type: Message.MessageType; + /** The associated conversation_id */ + conversation_id?: string; +} + +export namespace Message { + /** + * The type of message that was sent. Can be email, inapp, facebook ,twitter or sms. + */ + export type MessageType = "email" | "inapp" | "facebook" | "twitter" | "sms"; + export const MessageType = { + Email: "email", + Inapp: "inapp", + Facebook: "facebook", + Twitter: "twitter", + Sms: "sms", + } as const; +} diff --git a/src/api/resources/unstable/resources/messages/types/index.ts b/src/api/resources/unstable/resources/messages/types/index.ts new file mode 100644 index 00000000..6596816a --- /dev/null +++ b/src/api/resources/unstable/resources/messages/types/index.ts @@ -0,0 +1 @@ +export * from "./Message"; diff --git a/src/api/resources/unstable/resources/news/client/Client.ts b/src/api/resources/unstable/resources/news/client/Client.ts new file mode 100644 index 00000000..f42e1729 --- /dev/null +++ b/src/api/resources/unstable/resources/news/client/Client.ts @@ -0,0 +1,808 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace News { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + } +} + +/** + * Everything about your News + */ +export class News { + constructor(protected readonly _options: News.Options = {}) {} + + /** + * You can fetch a list of all news items + * + * @param {News.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.news.listNewsItems() + */ + public listNewsItems( + requestOptions?: News.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listNewsItems(requestOptions)); + } + + private async __listNewsItems( + requestOptions?: News.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "news/news_items", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.PaginatedResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /news/news_items."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can create a news item + * + * @param {Intercom.unstable.NewsItemRequest} request + * @param {News.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.news.createNewsItem({ + * title: "Halloween is here!", + * body: "

New costumes in store for this spooky season

", + * sender_id: 991267834, + * state: "live", + * deliver_silently: true, + * labels: ["Product", "Update", "New"], + * reactions: ["\uD83D\uDE06", "\uD83D\uDE05"], + * newsfeed_assignments: [{ + * newsfeed_id: 53, + * published_at: 1664638214 + * }] + * }) + */ + public createNewsItem( + request: Intercom.unstable.NewsItemRequest, + requestOptions?: News.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createNewsItem(request, requestOptions)); + } + + private async __createNewsItem( + request: Intercom.unstable.NewsItemRequest, + requestOptions?: News.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "news/news_items", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.NewsItem, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /news/news_items."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can fetch the details of a single news item. + * + * @param {Intercom.unstable.RetrieveNewsItemRequest} request + * @param {News.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.news.retrieveNewsItem({ + * id: 1 + * }) + */ + public retrieveNewsItem( + request: Intercom.unstable.RetrieveNewsItemRequest, + requestOptions?: News.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveNewsItem(request, requestOptions)); + } + + private async __retrieveNewsItem( + request: Intercom.unstable.RetrieveNewsItemRequest, + requestOptions?: News.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `news/news_items/${encodeURIComponent(id)}`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.NewsItem, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /news/news_items/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * @param {Intercom.unstable.UpdateNewsItemRequest} request + * @param {News.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.news.updateNewsItem({ + * id: 1, + * body: { + * title: "Christmas is here!", + * body: "

New gifts in store for the jolly season

", + * sender_id: 991267845, + * reactions: ["\uD83D\uDE1D", "\uD83D\uDE02"] + * } + * }) + * + * @example + * await client.unstable.news.updateNewsItem({ + * id: 1, + * body: { + * title: "Christmas is here!", + * body: "

New gifts in store for the jolly season

", + * sender_id: 991267848, + * reactions: ["\uD83D\uDE1D", "\uD83D\uDE02"] + * } + * }) + */ + public updateNewsItem( + request: Intercom.unstable.UpdateNewsItemRequest, + requestOptions?: News.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__updateNewsItem(request, requestOptions)); + } + + private async __updateNewsItem( + request: Intercom.unstable.UpdateNewsItemRequest, + requestOptions?: News.RequestOptions, + ): Promise> { + const { id, body: _body } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `news/news_items/${encodeURIComponent(id)}`, + ), + method: "PUT", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: _body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.NewsItem, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling PUT /news/news_items/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can delete a single news item. + * + * @param {Intercom.unstable.DeleteNewsItemRequest} request + * @param {News.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.news.deleteNewsItem({ + * id: 1 + * }) + */ + public deleteNewsItem( + request: Intercom.unstable.DeleteNewsItemRequest, + requestOptions?: News.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteNewsItem(request, requestOptions)); + } + + private async __deleteNewsItem( + request: Intercom.unstable.DeleteNewsItemRequest, + requestOptions?: News.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `news/news_items/${encodeURIComponent(id)}`, + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.DeletedObject, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling DELETE /news/news_items/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can fetch a list of all news items that are live on a given newsfeed + * + * @param {Intercom.unstable.ListLiveNewsfeedItemsRequest} request + * @param {News.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.news.listLiveNewsfeedItems({ + * id: "123" + * }) + */ + public listLiveNewsfeedItems( + request: Intercom.unstable.ListLiveNewsfeedItemsRequest, + requestOptions?: News.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listLiveNewsfeedItems(request, requestOptions)); + } + + private async __listLiveNewsfeedItems( + request: Intercom.unstable.ListLiveNewsfeedItemsRequest, + requestOptions?: News.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `news/newsfeeds/${encodeURIComponent(id)}/items`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.PaginatedResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /news/newsfeeds/{id}/items."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can fetch a list of all newsfeeds + * + * @param {News.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.news.listNewsfeeds() + */ + public listNewsfeeds( + requestOptions?: News.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listNewsfeeds(requestOptions)); + } + + private async __listNewsfeeds( + requestOptions?: News.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "news/newsfeeds", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.PaginatedResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /news/newsfeeds."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can fetch the details of a single newsfeed + * + * @param {Intercom.unstable.RetrieveNewsfeedRequest} request + * @param {News.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.news.retrieveNewsfeed({ + * id: "123" + * }) + */ + public retrieveNewsfeed( + request: Intercom.unstable.RetrieveNewsfeedRequest, + requestOptions?: News.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveNewsfeed(request, requestOptions)); + } + + private async __retrieveNewsfeed( + request: Intercom.unstable.RetrieveNewsfeedRequest, + requestOptions?: News.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `news/newsfeeds/${encodeURIComponent(id)}`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Newsfeed, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /news/newsfeeds/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["INTERCOM_API_KEY"]; + if (bearer == null) { + throw new errors.IntercomError({ + message: + "Please specify a bearer by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", + }); + } + + return `Bearer ${bearer}`; + } +} diff --git a/src/api/resources/unstable/resources/news/client/index.ts b/src/api/resources/unstable/resources/news/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/api/resources/unstable/resources/news/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/unstable/resources/news/client/requests/DeleteNewsItemRequest.ts b/src/api/resources/unstable/resources/news/client/requests/DeleteNewsItemRequest.ts new file mode 100644 index 00000000..5edfca2a --- /dev/null +++ b/src/api/resources/unstable/resources/news/client/requests/DeleteNewsItemRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: 1 + * } + */ +export interface DeleteNewsItemRequest { + /** + * The unique identifier for the news item which is given by Intercom. + */ + id: number; +} diff --git a/src/api/resources/unstable/resources/news/client/requests/ListLiveNewsfeedItemsRequest.ts b/src/api/resources/unstable/resources/news/client/requests/ListLiveNewsfeedItemsRequest.ts new file mode 100644 index 00000000..4101909c --- /dev/null +++ b/src/api/resources/unstable/resources/news/client/requests/ListLiveNewsfeedItemsRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "123" + * } + */ +export interface ListLiveNewsfeedItemsRequest { + /** + * The unique identifier for the news feed item which is given by Intercom. + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/news/client/requests/RetrieveNewsItemRequest.ts b/src/api/resources/unstable/resources/news/client/requests/RetrieveNewsItemRequest.ts new file mode 100644 index 00000000..b2e33231 --- /dev/null +++ b/src/api/resources/unstable/resources/news/client/requests/RetrieveNewsItemRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: 1 + * } + */ +export interface RetrieveNewsItemRequest { + /** + * The unique identifier for the news item which is given by Intercom. + */ + id: number; +} diff --git a/src/api/resources/unstable/resources/news/client/requests/RetrieveNewsfeedRequest.ts b/src/api/resources/unstable/resources/news/client/requests/RetrieveNewsfeedRequest.ts new file mode 100644 index 00000000..a4d0663a --- /dev/null +++ b/src/api/resources/unstable/resources/news/client/requests/RetrieveNewsfeedRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "123" + * } + */ +export interface RetrieveNewsfeedRequest { + /** + * The unique identifier for the news feed item which is given by Intercom. + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/news/client/requests/UpdateNewsItemRequest.ts b/src/api/resources/unstable/resources/news/client/requests/UpdateNewsItemRequest.ts new file mode 100644 index 00000000..e0962588 --- /dev/null +++ b/src/api/resources/unstable/resources/news/client/requests/UpdateNewsItemRequest.ts @@ -0,0 +1,36 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../../index"; + +/** + * @example + * { + * id: 1, + * body: { + * title: "Christmas is here!", + * body: "

New gifts in store for the jolly season

", + * sender_id: 991267845, + * reactions: ["\uD83D\uDE1D", "\uD83D\uDE02"] + * } + * } + * + * @example + * { + * id: 1, + * body: { + * title: "Christmas is here!", + * body: "

New gifts in store for the jolly season

", + * sender_id: 991267848, + * reactions: ["\uD83D\uDE1D", "\uD83D\uDE02"] + * } + * } + */ +export interface UpdateNewsItemRequest { + /** + * The unique identifier for the news item which is given by Intercom. + */ + id: number; + body: Intercom.unstable.NewsItemRequest; +} diff --git a/src/api/resources/unstable/resources/news/client/requests/index.ts b/src/api/resources/unstable/resources/news/client/requests/index.ts new file mode 100644 index 00000000..94944125 --- /dev/null +++ b/src/api/resources/unstable/resources/news/client/requests/index.ts @@ -0,0 +1,5 @@ +export { type RetrieveNewsItemRequest } from "./RetrieveNewsItemRequest"; +export { type UpdateNewsItemRequest } from "./UpdateNewsItemRequest"; +export { type DeleteNewsItemRequest } from "./DeleteNewsItemRequest"; +export { type ListLiveNewsfeedItemsRequest } from "./ListLiveNewsfeedItemsRequest"; +export { type RetrieveNewsfeedRequest } from "./RetrieveNewsfeedRequest"; diff --git a/src/api/resources/unstable/resources/news/index.ts b/src/api/resources/unstable/resources/news/index.ts new file mode 100644 index 00000000..c9240f83 --- /dev/null +++ b/src/api/resources/unstable/resources/news/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/unstable/resources/news/types/NewsItem.ts b/src/api/resources/unstable/resources/news/types/NewsItem.ts new file mode 100644 index 00000000..6650f0c5 --- /dev/null +++ b/src/api/resources/unstable/resources/news/types/NewsItem.ts @@ -0,0 +1,48 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +/** + * A News Item is a content type in Intercom enabling you to announce product updates, company news, promotions, events and more with your customers. + */ +export interface NewsItem { + /** The unique identifier for the news item which is given by Intercom. */ + id?: string; + /** The id of the workspace which the news item belongs to. */ + workspace_id?: string; + /** The title of the news item. */ + title?: string; + /** The news item body, which may contain HTML. */ + body?: string; + /** The id of the sender of the news item. Must be a teammate on the workspace. */ + sender_id?: number; + /** News items will not be visible to your users in the assigned newsfeeds until they are set live. */ + state?: NewsItem.State; + /** A list of newsfeed_assignments to assign to the specified newsfeed. */ + newsfeed_assignments?: Intercom.unstable.NewsfeedAssignment[]; + /** Label names displayed to users to categorize the news item. */ + labels?: (string | undefined)[]; + /** URL of the image used as cover. Must have .jpg or .png extension. */ + cover_image_url?: string; + /** Ordered list of emoji reactions to the news item. When empty, reactions are disabled. */ + reactions?: (string | undefined)[]; + /** When set to true, the news item will appear in the messenger newsfeed without showing a notification badge. */ + deliver_silently?: boolean; + /** Timestamp for when the news item was created. */ + created_at?: number; + /** Timestamp for when the news item was last updated. */ + updated_at?: number; +} + +export namespace NewsItem { + /** + * News items will not be visible to your users in the assigned newsfeeds until they are set live. + */ + export type State = "draft" | "live"; + export const State = { + Draft: "draft", + Live: "live", + } as const; +} diff --git a/src/api/resources/unstable/resources/news/types/Newsfeed.ts b/src/api/resources/unstable/resources/news/types/Newsfeed.ts new file mode 100644 index 00000000..10dc3a1f --- /dev/null +++ b/src/api/resources/unstable/resources/news/types/Newsfeed.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A newsfeed is a collection of news items, targeted to a specific audience. + * + * Newsfeeds currently cannot be edited through the API, please refer to [this article](https://www.intercom.com/help/en/articles/6362267-getting-started-with-news) to set up your newsfeeds in Intercom. + */ +export interface Newsfeed { + /** The unique identifier for the newsfeed which is given by Intercom. */ + id?: string; + /** The name of the newsfeed. This name will never be visible to your users. */ + name?: string; + /** Timestamp for when the newsfeed was created. */ + created_at?: number; + /** Timestamp for when the newsfeed was last updated. */ + updated_at?: number; +} diff --git a/src/api/resources/unstable/resources/news/types/NewsfeedAssignment.ts b/src/api/resources/unstable/resources/news/types/NewsfeedAssignment.ts new file mode 100644 index 00000000..2eb97d45 --- /dev/null +++ b/src/api/resources/unstable/resources/news/types/NewsfeedAssignment.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Assigns a news item to a newsfeed. + */ +export interface NewsfeedAssignment { + /** The unique identifier for the newsfeed which is given by Intercom. Publish dates cannot be in the future, to schedule news items use the dedicated feature in app (see this article). */ + newsfeed_id?: number; + /** Publish date of the news item on the newsfeed, use this field if you want to set a publish date in the past (e.g. when importing existing news items). On write, this field will be ignored if the news item state is "draft". */ + published_at?: number; +} diff --git a/src/api/resources/unstable/resources/news/types/index.ts b/src/api/resources/unstable/resources/news/types/index.ts new file mode 100644 index 00000000..b8c22f3c --- /dev/null +++ b/src/api/resources/unstable/resources/news/types/index.ts @@ -0,0 +1,3 @@ +export * from "./NewsItem"; +export * from "./Newsfeed"; +export * from "./NewsfeedAssignment"; diff --git a/src/api/resources/unstable/resources/notes/client/Client.ts b/src/api/resources/unstable/resources/notes/client/Client.ts new file mode 100644 index 00000000..b82d5191 --- /dev/null +++ b/src/api/resources/unstable/resources/notes/client/Client.ts @@ -0,0 +1,367 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace Notes { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + } +} + +/** + * Everything about your Notes + */ +export class Notes { + constructor(protected readonly _options: Notes.Options = {}) {} + + /** + * You can fetch a list of notes that are associated to a contact. + * + * @param {Intercom.unstable.ListNotesRequest} request + * @param {Notes.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.notes.listNotes({ + * id: 1 + * }) + */ + public listNotes( + request: Intercom.unstable.ListNotesRequest, + requestOptions?: Notes.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listNotes(request, requestOptions)); + } + + private async __listNotes( + request: Intercom.unstable.ListNotesRequest, + requestOptions?: Notes.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${encodeURIComponent(id)}/notes`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.NoteList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /contacts/{id}/notes."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can add a note to a single contact. + * + * @param {Intercom.unstable.CreateNoteRequest} request + * @param {Notes.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.notes.createNote({ + * id: 1, + * body: "Hello", + * contact_id: "6762f0ad1bb69f9f2193bb62", + * admin_id: "123" + * }) + * + * @example + * await client.unstable.notes.createNote({ + * id: 1, + * body: "Hello", + * contact_id: "6762f0af1bb69f9f2193bb63", + * admin_id: "123" + * }) + * + * @example + * await client.unstable.notes.createNote({ + * id: 1, + * body: "Hello", + * contact_id: "123", + * admin_id: "123" + * }) + */ + public createNote( + request: Intercom.unstable.CreateNoteRequest, + requestOptions?: Notes.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createNote(request, requestOptions)); + } + + private async __createNote( + request: Intercom.unstable.CreateNoteRequest, + requestOptions?: Notes.RequestOptions, + ): Promise> { + const { id, ..._body } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${encodeURIComponent(id)}/notes`, + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: _body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Note, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /contacts/{id}/notes."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can fetch the details of a single note. + * + * @param {Intercom.unstable.RetrieveNoteRequest} request + * @param {Notes.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.notes.retrieveNote({ + * id: 1 + * }) + */ + public retrieveNote( + request: Intercom.unstable.RetrieveNoteRequest, + requestOptions?: Notes.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveNote(request, requestOptions)); + } + + private async __retrieveNote( + request: Intercom.unstable.RetrieveNoteRequest, + requestOptions?: Notes.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `notes/${encodeURIComponent(id)}`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Note, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /notes/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["INTERCOM_API_KEY"]; + if (bearer == null) { + throw new errors.IntercomError({ + message: + "Please specify a bearer by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", + }); + } + + return `Bearer ${bearer}`; + } +} diff --git a/src/api/resources/unstable/resources/notes/client/index.ts b/src/api/resources/unstable/resources/notes/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/api/resources/unstable/resources/notes/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/unstable/resources/notes/client/requests/CreateNoteRequest.ts b/src/api/resources/unstable/resources/notes/client/requests/CreateNoteRequest.ts new file mode 100644 index 00000000..8fe9c7ae --- /dev/null +++ b/src/api/resources/unstable/resources/notes/client/requests/CreateNoteRequest.ts @@ -0,0 +1,41 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: 1, + * body: "Hello", + * contact_id: "6762f0ad1bb69f9f2193bb62", + * admin_id: "123" + * } + * + * @example + * { + * id: 1, + * body: "Hello", + * contact_id: "6762f0af1bb69f9f2193bb63", + * admin_id: "123" + * } + * + * @example + * { + * id: 1, + * body: "Hello", + * contact_id: "123", + * admin_id: "123" + * } + */ +export interface CreateNoteRequest { + /** + * The unique identifier of a given contact. + */ + id: number; + /** The text of the note. */ + body: string; + /** The unique identifier of a given contact. */ + contact_id?: string; + /** The unique identifier of a given admin. */ + admin_id?: string; +} diff --git a/src/api/resources/unstable/resources/notes/client/requests/ListNotesRequest.ts b/src/api/resources/unstable/resources/notes/client/requests/ListNotesRequest.ts new file mode 100644 index 00000000..7d8052df --- /dev/null +++ b/src/api/resources/unstable/resources/notes/client/requests/ListNotesRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: 1 + * } + */ +export interface ListNotesRequest { + /** + * The unique identifier of a contact. + */ + id: number; +} diff --git a/src/api/resources/unstable/resources/notes/client/requests/RetrieveNoteRequest.ts b/src/api/resources/unstable/resources/notes/client/requests/RetrieveNoteRequest.ts new file mode 100644 index 00000000..8fc83798 --- /dev/null +++ b/src/api/resources/unstable/resources/notes/client/requests/RetrieveNoteRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: 1 + * } + */ +export interface RetrieveNoteRequest { + /** + * The unique identifier of a given note + */ + id: number; +} diff --git a/src/api/resources/unstable/resources/notes/client/requests/index.ts b/src/api/resources/unstable/resources/notes/client/requests/index.ts new file mode 100644 index 00000000..4fa65001 --- /dev/null +++ b/src/api/resources/unstable/resources/notes/client/requests/index.ts @@ -0,0 +1,3 @@ +export { type ListNotesRequest } from "./ListNotesRequest"; +export { type CreateNoteRequest } from "./CreateNoteRequest"; +export { type RetrieveNoteRequest } from "./RetrieveNoteRequest"; diff --git a/src/api/resources/unstable/resources/notes/index.ts b/src/api/resources/unstable/resources/notes/index.ts new file mode 100644 index 00000000..c9240f83 --- /dev/null +++ b/src/api/resources/unstable/resources/notes/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/unstable/resources/notes/types/Note.ts b/src/api/resources/unstable/resources/notes/types/Note.ts new file mode 100644 index 00000000..d4bc42b2 --- /dev/null +++ b/src/api/resources/unstable/resources/notes/types/Note.ts @@ -0,0 +1,35 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +/** + * Notes allow you to annotate and comment on your contacts. + */ +export interface Note { + /** String representing the object's type. Always has the value `note`. */ + type?: string; + /** The id of the note. */ + id?: string; + /** The time the note was created. */ + created_at?: number; + /** Represents the contact that the note was created about. */ + contact?: Note.Contact; + /** Optional. Represents the Admin that created the note. */ + author?: Intercom.unstable.Admin; + /** The body text of the note. */ + body?: string; +} + +export namespace Note { + /** + * Represents the contact that the note was created about. + */ + export interface Contact { + /** String representing the object's type. Always has the value `contact`. */ + type?: string; + /** The id of the contact. */ + id?: string; + } +} diff --git a/src/api/resources/unstable/resources/notes/types/index.ts b/src/api/resources/unstable/resources/notes/types/index.ts new file mode 100644 index 00000000..cf881fa5 --- /dev/null +++ b/src/api/resources/unstable/resources/notes/types/index.ts @@ -0,0 +1 @@ +export * from "./Note"; diff --git a/src/api/resources/unstable/resources/segments/client/Client.ts b/src/api/resources/unstable/resources/segments/client/Client.ts new file mode 100644 index 00000000..67d08f1f --- /dev/null +++ b/src/api/resources/unstable/resources/segments/client/Client.ts @@ -0,0 +1,270 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace Segments { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + } +} + +/** + * Everything about your Segments + */ +export class Segments { + constructor(protected readonly _options: Segments.Options = {}) {} + + /** + * You can fetch a list of all segments. + * + * @param {Intercom.unstable.ListSegmentsRequest} request + * @param {Segments.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.segments.listSegments() + */ + public listSegments( + request: Intercom.unstable.ListSegmentsRequest = {}, + requestOptions?: Segments.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listSegments(request, requestOptions)); + } + + private async __listSegments( + request: Intercom.unstable.ListSegmentsRequest = {}, + requestOptions?: Segments.RequestOptions, + ): Promise> { + const { include_count: includeCount } = request; + const _queryParams: Record = {}; + if (includeCount != null) { + _queryParams["include_count"] = includeCount.toString(); + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "segments", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.SegmentList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /segments."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can fetch the details of a single segment. + * + * @param {Intercom.unstable.RetrieveSegmentRequest} request + * @param {Segments.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.segments.retrieveSegment({ + * id: "123" + * }) + */ + public retrieveSegment( + request: Intercom.unstable.RetrieveSegmentRequest, + requestOptions?: Segments.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveSegment(request, requestOptions)); + } + + private async __retrieveSegment( + request: Intercom.unstable.RetrieveSegmentRequest, + requestOptions?: Segments.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `segments/${encodeURIComponent(id)}`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Segment, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /segments/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["INTERCOM_API_KEY"]; + if (bearer == null) { + throw new errors.IntercomError({ + message: + "Please specify a bearer by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", + }); + } + + return `Bearer ${bearer}`; + } +} diff --git a/src/api/resources/unstable/resources/segments/client/index.ts b/src/api/resources/unstable/resources/segments/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/api/resources/unstable/resources/segments/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/unstable/resources/segments/client/requests/ListSegmentsRequest.ts b/src/api/resources/unstable/resources/segments/client/requests/ListSegmentsRequest.ts new file mode 100644 index 00000000..116acd5e --- /dev/null +++ b/src/api/resources/unstable/resources/segments/client/requests/ListSegmentsRequest.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * {} + */ +export interface ListSegmentsRequest { + /** + * It includes the count of contacts that belong to each segment. + */ + include_count?: boolean; +} diff --git a/src/api/resources/unstable/resources/segments/client/requests/RetrieveSegmentRequest.ts b/src/api/resources/unstable/resources/segments/client/requests/RetrieveSegmentRequest.ts new file mode 100644 index 00000000..0ba937bf --- /dev/null +++ b/src/api/resources/unstable/resources/segments/client/requests/RetrieveSegmentRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "123" + * } + */ +export interface RetrieveSegmentRequest { + /** + * The unique identified of a given segment. + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/segments/client/requests/index.ts b/src/api/resources/unstable/resources/segments/client/requests/index.ts new file mode 100644 index 00000000..d31998d0 --- /dev/null +++ b/src/api/resources/unstable/resources/segments/client/requests/index.ts @@ -0,0 +1,2 @@ +export { type ListSegmentsRequest } from "./ListSegmentsRequest"; +export { type RetrieveSegmentRequest } from "./RetrieveSegmentRequest"; diff --git a/src/api/resources/unstable/resources/segments/index.ts b/src/api/resources/unstable/resources/segments/index.ts new file mode 100644 index 00000000..c9240f83 --- /dev/null +++ b/src/api/resources/unstable/resources/segments/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/unstable/resources/segments/types/Segment.ts b/src/api/resources/unstable/resources/segments/types/Segment.ts new file mode 100644 index 00000000..b297f427 --- /dev/null +++ b/src/api/resources/unstable/resources/segments/types/Segment.ts @@ -0,0 +1,34 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A segment is a group of your contacts defined by the rules that you set. + */ +export interface Segment { + /** The type of object. */ + type?: "segment"; + /** The unique identifier representing the segment. */ + id?: string; + /** The name of the segment. */ + name?: string; + /** The time the segment was created. */ + created_at?: number; + /** The time the segment was updated. */ + updated_at?: number; + /** Type of the contact: contact (lead) or user. */ + person_type?: Segment.PersonType; + /** The number of items in the user segment. It's returned when `include_count=true` is included in the request. */ + count?: number; +} + +export namespace Segment { + /** + * Type of the contact: contact (lead) or user. + */ + export type PersonType = "contact" | "user"; + export const PersonType = { + Contact: "contact", + User: "user", + } as const; +} diff --git a/src/api/resources/unstable/resources/segments/types/index.ts b/src/api/resources/unstable/resources/segments/types/index.ts new file mode 100644 index 00000000..957aab14 --- /dev/null +++ b/src/api/resources/unstable/resources/segments/types/index.ts @@ -0,0 +1 @@ +export * from "./Segment"; diff --git a/src/api/resources/unstable/resources/subscriptionTypes/client/Client.ts b/src/api/resources/unstable/resources/subscriptionTypes/client/Client.ts new file mode 100644 index 00000000..38e70154 --- /dev/null +++ b/src/api/resources/unstable/resources/subscriptionTypes/client/Client.ts @@ -0,0 +1,374 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace SubscriptionTypes { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + } +} + +/** + * Everything about subscription types + */ +export class SubscriptionTypes { + constructor(protected readonly _options: SubscriptionTypes.Options = {}) {} + + /** + * You can add a specific subscription to a contact. In Intercom, we have two different subscription types based on user consent - opt-out and opt-in: + * + * 1.Attaching a contact to an opt-out subscription type will opt that user out from receiving messages related to that subscription type. + * + * 2.Attaching a contact to an opt-in subscription type will opt that user in to receiving messages related to that subscription type. + * + * This will return a subscription type model for the subscription type that was added to the contact. + * + * @param {Intercom.unstable.AttachSubscriptionTypeToContactRequest} request + * @param {SubscriptionTypes.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.subscriptionTypes.attachSubscriptionTypeToContact({ + * contact_id: "63a07ddf05a32042dffac965", + * id: "37846", + * consent_type: "opt_in" + * }) + * + * @example + * await client.unstable.subscriptionTypes.attachSubscriptionTypeToContact({ + * contact_id: "63a07ddf05a32042dffac965", + * id: "invalid_id", + * consent_type: "opt_in" + * }) + */ + public attachSubscriptionTypeToContact( + request: Intercom.unstable.AttachSubscriptionTypeToContactRequest, + requestOptions?: SubscriptionTypes.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__attachSubscriptionTypeToContact(request, requestOptions)); + } + + private async __attachSubscriptionTypeToContact( + request: Intercom.unstable.AttachSubscriptionTypeToContactRequest, + requestOptions?: SubscriptionTypes.RequestOptions, + ): Promise> { + const { contact_id: contactId, ..._body } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${encodeURIComponent(contactId)}/subscriptions`, + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: _body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.SubscriptionType, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling POST /contacts/{contact_id}/subscriptions.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * 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. + * + * @param {Intercom.unstable.DetachSubscriptionTypeToContactRequest} request + * @param {SubscriptionTypes.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.subscriptionTypes.detachSubscriptionTypeToContact({ + * contact_id: "63a07ddf05a32042dffac965", + * id: "37846" + * }) + */ + public detachSubscriptionTypeToContact( + request: Intercom.unstable.DetachSubscriptionTypeToContactRequest, + requestOptions?: SubscriptionTypes.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__detachSubscriptionTypeToContact(request, requestOptions)); + } + + private async __detachSubscriptionTypeToContact( + request: Intercom.unstable.DetachSubscriptionTypeToContactRequest, + requestOptions?: SubscriptionTypes.RequestOptions, + ): Promise> { + const { contact_id: contactId, id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${encodeURIComponent(contactId)}/subscriptions/${encodeURIComponent(id)}`, + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.SubscriptionType, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling DELETE /contacts/{contact_id}/subscriptions/{id}.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can list all subscription types. A list of subscription type objects will be returned. + * + * @param {SubscriptionTypes.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.subscriptionTypes.listSubscriptionTypes() + */ + public listSubscriptionTypes( + requestOptions?: SubscriptionTypes.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listSubscriptionTypes(requestOptions)); + } + + private async __listSubscriptionTypes( + requestOptions?: SubscriptionTypes.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "subscription_types", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.SubscriptionTypeList, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /subscription_types."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["INTERCOM_API_KEY"]; + if (bearer == null) { + throw new errors.IntercomError({ + message: + "Please specify a bearer by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", + }); + } + + return `Bearer ${bearer}`; + } +} diff --git a/src/api/resources/unstable/resources/subscriptionTypes/client/index.ts b/src/api/resources/unstable/resources/subscriptionTypes/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/api/resources/unstable/resources/subscriptionTypes/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/unstable/resources/subscriptionTypes/client/requests/AttachSubscriptionTypeToContactRequest.ts b/src/api/resources/unstable/resources/subscriptionTypes/client/requests/AttachSubscriptionTypeToContactRequest.ts new file mode 100644 index 00000000..742321c7 --- /dev/null +++ b/src/api/resources/unstable/resources/subscriptionTypes/client/requests/AttachSubscriptionTypeToContactRequest.ts @@ -0,0 +1,36 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * contact_id: "63a07ddf05a32042dffac965", + * id: "37846", + * consent_type: "opt_in" + * } + * + * @example + * { + * contact_id: "63a07ddf05a32042dffac965", + * id: "37846", + * consent_type: "opt_in" + * } + * + * @example + * { + * contact_id: "63a07ddf05a32042dffac965", + * id: "invalid_id", + * consent_type: "opt_in" + * } + */ +export interface AttachSubscriptionTypeToContactRequest { + /** + * The unique identifier for the contact which is given by Intercom + */ + contact_id: string; + /** The unique identifier for the subscription which is given by Intercom */ + id: string; + /** The consent_type of a subscription, opt_out or opt_in. */ + consent_type: string; +} diff --git a/src/api/resources/unstable/resources/subscriptionTypes/client/requests/DetachSubscriptionTypeToContactRequest.ts b/src/api/resources/unstable/resources/subscriptionTypes/client/requests/DetachSubscriptionTypeToContactRequest.ts new file mode 100644 index 00000000..8ad29dba --- /dev/null +++ b/src/api/resources/unstable/resources/subscriptionTypes/client/requests/DetachSubscriptionTypeToContactRequest.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * contact_id: "63a07ddf05a32042dffac965", + * id: "37846" + * } + */ +export interface DetachSubscriptionTypeToContactRequest { + /** + * The unique identifier for the contact which is given by Intercom + */ + contact_id: string; + /** + * The unique identifier for the subscription type which is given by Intercom + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/subscriptionTypes/client/requests/index.ts b/src/api/resources/unstable/resources/subscriptionTypes/client/requests/index.ts new file mode 100644 index 00000000..d5cc644c --- /dev/null +++ b/src/api/resources/unstable/resources/subscriptionTypes/client/requests/index.ts @@ -0,0 +1,2 @@ +export { type AttachSubscriptionTypeToContactRequest } from "./AttachSubscriptionTypeToContactRequest"; +export { type DetachSubscriptionTypeToContactRequest } from "./DetachSubscriptionTypeToContactRequest"; diff --git a/src/api/resources/unstable/resources/subscriptionTypes/index.ts b/src/api/resources/unstable/resources/subscriptionTypes/index.ts new file mode 100644 index 00000000..c9240f83 --- /dev/null +++ b/src/api/resources/unstable/resources/subscriptionTypes/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/unstable/resources/subscriptionTypes/types/SubscriptionType.ts b/src/api/resources/unstable/resources/subscriptionTypes/types/SubscriptionType.ts new file mode 100644 index 00000000..bcb2bd27 --- /dev/null +++ b/src/api/resources/unstable/resources/subscriptionTypes/types/SubscriptionType.ts @@ -0,0 +1,53 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +/** + * A subscription type lets customers easily opt out of non-essential communications without missing what's important to them. + */ +export interface SubscriptionType { + /** The type of the object - subscription */ + type?: string; + /** The unique identifier representing the subscription type. */ + id?: string; + /** The state of the subscription type. */ + state?: SubscriptionType.State; + default_translation?: Intercom.unstable.Translation; + /** An array of translations objects with the localised version of the subscription type in each available locale within your translation settings. */ + translations?: Intercom.unstable.Translation[]; + /** Describes the type of consent. */ + consent_type?: SubscriptionType.ConsentType; + /** The message types that this subscription supports - can contain `email` or `sms_message`. */ + content_types?: SubscriptionType.ContentTypes.Item[]; +} + +export namespace SubscriptionType { + /** + * The state of the subscription type. + */ + export type State = "live" | "draft" | "archived"; + export const State = { + Live: "live", + Draft: "draft", + Archived: "archived", + } as const; + /** + * Describes the type of consent. + */ + export type ConsentType = "opt_out" | "opt_in"; + export const ConsentType = { + OptOut: "opt_out", + OptIn: "opt_in", + } as const; + export type ContentTypes = ContentTypes.Item[]; + + export namespace ContentTypes { + export type Item = "email" | "sms_message"; + export const Item = { + Email: "email", + SmsMessage: "sms_message", + } as const; + } +} diff --git a/src/api/resources/unstable/resources/subscriptionTypes/types/index.ts b/src/api/resources/unstable/resources/subscriptionTypes/types/index.ts new file mode 100644 index 00000000..fe95bab5 --- /dev/null +++ b/src/api/resources/unstable/resources/subscriptionTypes/types/index.ts @@ -0,0 +1 @@ +export * from "./SubscriptionType"; diff --git a/src/api/resources/unstable/resources/switch/client/Client.ts b/src/api/resources/unstable/resources/switch/client/Client.ts new file mode 100644 index 00000000..543d2759 --- /dev/null +++ b/src/api/resources/unstable/resources/switch/client/Client.ts @@ -0,0 +1,191 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace Switch { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + } +} + +/** + * Everything about Switch + */ +export class Switch { + constructor(protected readonly _options: Switch.Options = {}) {} + + /** + * You can use the API to deflect phone calls to the Intercom Messenger. + * Calling this endpoint will send an SMS with a link to the Messenger to the phone number specified. + * + * If custom attributes are specified, they will be added to the user or lead's custom data attributes. + * + * @param {unknown} request + * @param {Switch.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.BadRequestError} + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.UnprocessableEntityError} + * + * @example + * await client.unstable.switch.createPhoneSwitch({ + * "key": "value" + * }) + */ + public createPhoneSwitch( + request?: unknown, + requestOptions?: Switch.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createPhoneSwitch(request, requestOptions)); + } + + private async __createPhoneSwitch( + request?: unknown, + requestOptions?: Switch.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "phone_call_redirects", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.PhoneSwitch | undefined, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 422: + throw new Intercom.unstable.UnprocessableEntityError( + _response.error.body as unknown, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /phone_call_redirects."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["INTERCOM_API_KEY"]; + if (bearer == null) { + throw new errors.IntercomError({ + message: + "Please specify a bearer by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", + }); + } + + return `Bearer ${bearer}`; + } +} diff --git a/src/api/resources/unstable/resources/switch/client/index.ts b/src/api/resources/unstable/resources/switch/client/index.ts new file mode 100644 index 00000000..cb0ff5c3 --- /dev/null +++ b/src/api/resources/unstable/resources/switch/client/index.ts @@ -0,0 +1 @@ +export {}; diff --git a/src/api/resources/unstable/resources/switch/index.ts b/src/api/resources/unstable/resources/switch/index.ts new file mode 100644 index 00000000..5ec76921 --- /dev/null +++ b/src/api/resources/unstable/resources/switch/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/unstable/resources/tags/client/Client.ts b/src/api/resources/unstable/resources/tags/client/Client.ts new file mode 100644 index 00000000..279f075c --- /dev/null +++ b/src/api/resources/unstable/resources/tags/client/Client.ts @@ -0,0 +1,1049 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace Tags { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + } +} + +/** + * Everything about tags + */ +export class Tags { + constructor(protected readonly _options: Tags.Options = {}) {} + + /** + * You can tag a specific contact. This will return a tag object for the tag that was added to the contact. + * + * @param {Intercom.unstable.AttachTagToContactRequest} request + * @param {Tags.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.tags.attachTagToContact({ + * contact_id: "63a07ddf05a32042dffac965", + * id: "7522907" + * }) + * + * @example + * await client.unstable.tags.attachTagToContact({ + * contact_id: "63a07ddf05a32042dffac965", + * id: "123" + * }) + */ + public attachTagToContact( + request: Intercom.unstable.AttachTagToContactRequest, + requestOptions?: Tags.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__attachTagToContact(request, requestOptions)); + } + + private async __attachTagToContact( + request: Intercom.unstable.AttachTagToContactRequest, + requestOptions?: Tags.RequestOptions, + ): Promise> { + const { contact_id: contactId, ..._body } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${encodeURIComponent(contactId)}/tags`, + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: _body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Tag, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling POST /contacts/{contact_id}/tags.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can remove tag from a specific contact. This will return a tag object for the tag that was removed from the contact. + * + * @param {Intercom.unstable.DetachTagFromContactRequest} request + * @param {Tags.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.tags.detachTagFromContact({ + * contact_id: "63a07ddf05a32042dffac965", + * id: "7522907" + * }) + */ + public detachTagFromContact( + request: Intercom.unstable.DetachTagFromContactRequest, + requestOptions?: Tags.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__detachTagFromContact(request, requestOptions)); + } + + private async __detachTagFromContact( + request: Intercom.unstable.DetachTagFromContactRequest, + requestOptions?: Tags.RequestOptions, + ): Promise> { + const { contact_id: contactId, id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `contacts/${encodeURIComponent(contactId)}/tags/${encodeURIComponent(id)}`, + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Tag, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling DELETE /contacts/{contact_id}/tags/{id}.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can tag a specific conversation. This will return a tag object for the tag that was added to the conversation. + * + * @param {Intercom.unstable.AttachTagToConversationRequest} request + * @param {Tags.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.tags.attachTagToConversation({ + * conversation_id: "64619700005694", + * id: "7522907", + * admin_id: "780" + * }) + */ + public attachTagToConversation( + request: Intercom.unstable.AttachTagToConversationRequest, + requestOptions?: Tags.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__attachTagToConversation(request, requestOptions)); + } + + private async __attachTagToConversation( + request: Intercom.unstable.AttachTagToConversationRequest, + requestOptions?: Tags.RequestOptions, + ): Promise> { + const { conversation_id: conversationId, ..._body } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `conversations/${encodeURIComponent(conversationId)}/tags`, + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: _body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Tag, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling POST /conversations/{conversation_id}/tags.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can remove tag from a specific conversation. This will return a tag object for the tag that was removed from the conversation. + * + * @param {Intercom.unstable.DetachTagFromConversationRequest} request + * @param {Tags.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.tags.detachTagFromConversation({ + * conversation_id: "64619700005694", + * id: "7522907", + * admin_id: "123" + * }) + */ + public detachTagFromConversation( + request: Intercom.unstable.DetachTagFromConversationRequest, + requestOptions?: Tags.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__detachTagFromConversation(request, requestOptions)); + } + + private async __detachTagFromConversation( + request: Intercom.unstable.DetachTagFromConversationRequest, + requestOptions?: Tags.RequestOptions, + ): Promise> { + const { conversation_id: conversationId, id, ..._body } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `conversations/${encodeURIComponent(conversationId)}/tags/${encodeURIComponent(id)}`, + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: _body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Tag, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling DELETE /conversations/{conversation_id}/tags/{id}.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can fetch a list of all tags for a given workspace. + * + * @param {Tags.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.tags.listTags() + */ + public listTags(requestOptions?: Tags.RequestOptions): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listTags(requestOptions)); + } + + private async __listTags( + requestOptions?: Tags.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "tags", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.TagList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /tags."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can use this endpoint to perform the following operations: + * + * **1. Create a new tag:** You can create a new tag by passing in the tag name as specified in "Create or Update Tag Request Payload" described below. + * + * **2. Update an existing tag:** You can update an existing tag by passing the id of the tag as specified in "Create or Update Tag Request Payload" described below. + * + * **3. Tag Companies:** You can tag single company or a list of companies. You can tag a company by passing in the tag name and the company details as specified in "Tag Company Request Payload" described below. Also, if the tag doesn't exist then a new one will be created automatically. + * + * **4. Untag Companies:** You can untag a single company or a list of companies. You can untag a company by passing in the tag id and the company details as specified in "Untag Company Request Payload" described below. + * + * **5. Tag Multiple Users:** You can tag a list of users. You can tag the users by passing in the tag name and the user details as specified in "Tag Users Request Payload" described below. + * + * Each operation will return a tag object. + * + * @param {Intercom.unstable.CreateTagRequestBody} request + * @param {Tags.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.BadRequestError} + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.tags.createTag({ + * name: "test" + * }) + * + * @example + * await client.unstable.tags.createTag({ + * name: "Independent" + * }) + * + * @example + * await client.unstable.tags.createTag({ + * name: "test", + * companies: [{ + * company_id: "123" + * }] + * }) + * + * @example + * await client.unstable.tags.createTag({ + * name: "test", + * users: [{ + * id: "123" + * }] + * }) + */ + public createTag( + request: Intercom.unstable.CreateTagRequestBody, + requestOptions?: Tags.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createTag(request, requestOptions)); + } + + private async __createTag( + request: Intercom.unstable.CreateTagRequestBody, + requestOptions?: Tags.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "tags", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Tag, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /tags."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can fetch the details of tags that are on the workspace by their id. + * This will return a tag object. + * + * @param {Intercom.unstable.FindTagRequest} request + * @param {Tags.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.tags.findTag({ + * id: "123" + * }) + */ + public findTag( + request: Intercom.unstable.FindTagRequest, + requestOptions?: Tags.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__findTag(request, requestOptions)); + } + + private async __findTag( + request: Intercom.unstable.FindTagRequest, + requestOptions?: Tags.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `tags/${encodeURIComponent(id)}`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Tag, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /tags/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can delete the details of tags that are on the workspace by passing in the id. + * + * @param {Intercom.unstable.DeleteTagRequest} request + * @param {Tags.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.BadRequestError} + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.tags.deleteTag({ + * id: "123" + * }) + */ + public deleteTag( + request: Intercom.unstable.DeleteTagRequest, + requestOptions?: Tags.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteTag(request, requestOptions)); + } + + private async __deleteTag( + request: Intercom.unstable.DeleteTagRequest, + requestOptions?: Tags.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `tags/${encodeURIComponent(id)}`, + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling DELETE /tags/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can tag a specific ticket. This will return a tag object for the tag that was added to the ticket. + * + * @param {Intercom.unstable.AttachTagToTicketRequest} request + * @param {Tags.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.tags.attachTagToTicket({ + * ticket_id: "64619700005694", + * id: "7522907", + * admin_id: "780" + * }) + */ + public attachTagToTicket( + request: Intercom.unstable.AttachTagToTicketRequest, + requestOptions?: Tags.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__attachTagToTicket(request, requestOptions)); + } + + private async __attachTagToTicket( + request: Intercom.unstable.AttachTagToTicketRequest, + requestOptions?: Tags.RequestOptions, + ): Promise> { + const { ticket_id: ticketId, ..._body } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `tickets/${encodeURIComponent(ticketId)}/tags`, + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: _body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Tag, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /tickets/{ticket_id}/tags."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can remove tag from a specific ticket. This will return a tag object for the tag that was removed from the ticket. + * + * @param {Intercom.unstable.DetachTagFromTicketRequest} request + * @param {Tags.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.tags.detachTagFromTicket({ + * ticket_id: "64619700005694", + * id: "7522907", + * admin_id: "123" + * }) + */ + public detachTagFromTicket( + request: Intercom.unstable.DetachTagFromTicketRequest, + requestOptions?: Tags.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__detachTagFromTicket(request, requestOptions)); + } + + private async __detachTagFromTicket( + request: Intercom.unstable.DetachTagFromTicketRequest, + requestOptions?: Tags.RequestOptions, + ): Promise> { + const { ticket_id: ticketId, id, ..._body } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `tickets/${encodeURIComponent(ticketId)}/tags/${encodeURIComponent(id)}`, + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: _body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Tag, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling DELETE /tickets/{ticket_id}/tags/{id}.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["INTERCOM_API_KEY"]; + if (bearer == null) { + throw new errors.IntercomError({ + message: + "Please specify a bearer by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", + }); + } + + return `Bearer ${bearer}`; + } +} diff --git a/src/api/resources/unstable/resources/tags/client/index.ts b/src/api/resources/unstable/resources/tags/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/api/resources/unstable/resources/tags/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/unstable/resources/tags/client/requests/AttachTagToContactRequest.ts b/src/api/resources/unstable/resources/tags/client/requests/AttachTagToContactRequest.ts new file mode 100644 index 00000000..2d9e27cc --- /dev/null +++ b/src/api/resources/unstable/resources/tags/client/requests/AttachTagToContactRequest.ts @@ -0,0 +1,31 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * contact_id: "63a07ddf05a32042dffac965", + * id: "7522907" + * } + * + * @example + * { + * contact_id: "63a07ddf05a32042dffac965", + * id: "7522907" + * } + * + * @example + * { + * contact_id: "63a07ddf05a32042dffac965", + * id: "123" + * } + */ +export interface AttachTagToContactRequest { + /** + * The unique identifier for the contact which is given by Intercom + */ + contact_id: string; + /** The unique identifier for the tag which is given by Intercom */ + id: string; +} diff --git a/src/api/resources/unstable/resources/tags/client/requests/AttachTagToConversationRequest.ts b/src/api/resources/unstable/resources/tags/client/requests/AttachTagToConversationRequest.ts new file mode 100644 index 00000000..f3533c92 --- /dev/null +++ b/src/api/resources/unstable/resources/tags/client/requests/AttachTagToConversationRequest.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * conversation_id: "64619700005694", + * id: "7522907", + * admin_id: "780" + * } + * + * @example + * { + * conversation_id: "64619700005694", + * id: "7522907", + * admin_id: "780" + * } + */ +export interface AttachTagToConversationRequest { + /** + * conversation_id + */ + conversation_id: string; + /** The unique identifier for the tag which is given by Intercom */ + id: string; + /** The unique identifier for the admin which is given by Intercom. */ + admin_id: string; +} diff --git a/src/api/resources/unstable/resources/tags/client/requests/AttachTagToTicketRequest.ts b/src/api/resources/unstable/resources/tags/client/requests/AttachTagToTicketRequest.ts new file mode 100644 index 00000000..55d90d6b --- /dev/null +++ b/src/api/resources/unstable/resources/tags/client/requests/AttachTagToTicketRequest.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * ticket_id: "64619700005694", + * id: "7522907", + * admin_id: "780" + * } + * + * @example + * { + * ticket_id: "64619700005694", + * id: "7522907", + * admin_id: "780" + * } + */ +export interface AttachTagToTicketRequest { + /** + * ticket_id + */ + ticket_id: string; + /** The unique identifier for the tag which is given by Intercom */ + id: string; + /** The unique identifier for the admin which is given by Intercom. */ + admin_id: string; +} diff --git a/src/api/resources/unstable/resources/tags/client/requests/DeleteTagRequest.ts b/src/api/resources/unstable/resources/tags/client/requests/DeleteTagRequest.ts new file mode 100644 index 00000000..95921be7 --- /dev/null +++ b/src/api/resources/unstable/resources/tags/client/requests/DeleteTagRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "123" + * } + */ +export interface DeleteTagRequest { + /** + * The unique identifier of a given tag + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/tags/client/requests/DetachTagFromContactRequest.ts b/src/api/resources/unstable/resources/tags/client/requests/DetachTagFromContactRequest.ts new file mode 100644 index 00000000..a4d90398 --- /dev/null +++ b/src/api/resources/unstable/resources/tags/client/requests/DetachTagFromContactRequest.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * contact_id: "63a07ddf05a32042dffac965", + * id: "7522907" + * } + */ +export interface DetachTagFromContactRequest { + /** + * The unique identifier for the contact which is given by Intercom + */ + contact_id: string; + /** + * The unique identifier for the tag which is given by Intercom + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/tags/client/requests/DetachTagFromConversationRequest.ts b/src/api/resources/unstable/resources/tags/client/requests/DetachTagFromConversationRequest.ts new file mode 100644 index 00000000..b41584c0 --- /dev/null +++ b/src/api/resources/unstable/resources/tags/client/requests/DetachTagFromConversationRequest.ts @@ -0,0 +1,38 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * conversation_id: "64619700005694", + * id: "7522907", + * admin_id: "123" + * } + * + * @example + * { + * conversation_id: "64619700005694", + * id: "7522907", + * admin_id: "123" + * } + * + * @example + * { + * conversation_id: "64619700005694", + * id: "7522907", + * admin_id: "123" + * } + */ +export interface DetachTagFromConversationRequest { + /** + * conversation_id + */ + conversation_id: string; + /** + * id + */ + id: string; + /** The unique identifier for the admin which is given by Intercom. */ + admin_id: string; +} diff --git a/src/api/resources/unstable/resources/tags/client/requests/DetachTagFromTicketRequest.ts b/src/api/resources/unstable/resources/tags/client/requests/DetachTagFromTicketRequest.ts new file mode 100644 index 00000000..ed321a9a --- /dev/null +++ b/src/api/resources/unstable/resources/tags/client/requests/DetachTagFromTicketRequest.ts @@ -0,0 +1,38 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * ticket_id: "64619700005694", + * id: "7522907", + * admin_id: "123" + * } + * + * @example + * { + * ticket_id: "64619700005694", + * id: "7522907", + * admin_id: "123" + * } + * + * @example + * { + * ticket_id: "64619700005694", + * id: "7522907", + * admin_id: "123" + * } + */ +export interface DetachTagFromTicketRequest { + /** + * ticket_id + */ + ticket_id: string; + /** + * The unique identifier for the tag which is given by Intercom + */ + id: string; + /** The unique identifier for the admin which is given by Intercom. */ + admin_id: string; +} diff --git a/src/api/resources/unstable/resources/tags/client/requests/FindTagRequest.ts b/src/api/resources/unstable/resources/tags/client/requests/FindTagRequest.ts new file mode 100644 index 00000000..7f23eca2 --- /dev/null +++ b/src/api/resources/unstable/resources/tags/client/requests/FindTagRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "123" + * } + */ +export interface FindTagRequest { + /** + * The unique identifier of a given tag + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/tags/client/requests/index.ts b/src/api/resources/unstable/resources/tags/client/requests/index.ts new file mode 100644 index 00000000..f529317a --- /dev/null +++ b/src/api/resources/unstable/resources/tags/client/requests/index.ts @@ -0,0 +1,8 @@ +export { type AttachTagToContactRequest } from "./AttachTagToContactRequest"; +export { type DetachTagFromContactRequest } from "./DetachTagFromContactRequest"; +export { type AttachTagToConversationRequest } from "./AttachTagToConversationRequest"; +export { type DetachTagFromConversationRequest } from "./DetachTagFromConversationRequest"; +export { type FindTagRequest } from "./FindTagRequest"; +export { type DeleteTagRequest } from "./DeleteTagRequest"; +export { type AttachTagToTicketRequest } from "./AttachTagToTicketRequest"; +export { type DetachTagFromTicketRequest } from "./DetachTagFromTicketRequest"; diff --git a/src/api/resources/unstable/resources/tags/index.ts b/src/api/resources/unstable/resources/tags/index.ts new file mode 100644 index 00000000..c9240f83 --- /dev/null +++ b/src/api/resources/unstable/resources/tags/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/unstable/resources/tags/types/CreateTagRequestBody.ts b/src/api/resources/unstable/resources/tags/types/CreateTagRequestBody.ts new file mode 100644 index 00000000..cd52e610 --- /dev/null +++ b/src/api/resources/unstable/resources/tags/types/CreateTagRequestBody.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +export type CreateTagRequestBody = + | Intercom.unstable.CreateOrUpdateTagRequest + | Intercom.unstable.TagCompanyRequest + | Intercom.unstable.UntagCompanyRequest + | Intercom.unstable.TagMultipleUsersRequest; diff --git a/src/api/resources/unstable/resources/tags/types/Tag.ts b/src/api/resources/unstable/resources/tags/types/Tag.ts new file mode 100644 index 00000000..869f2171 --- /dev/null +++ b/src/api/resources/unstable/resources/tags/types/Tag.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +/** + * A tag allows you to label your contacts, companies, and conversations and list them using that tag. + */ +export interface Tag { + /** value is "tag" */ + type?: string; + /** The id of the tag */ + id?: string; + /** The name of the tag */ + name?: string; + /** The time when the tag was applied to the object */ + applied_at?: number; + applied_by?: Intercom.unstable.Reference; +} diff --git a/src/api/resources/unstable/resources/tags/types/TagBasic.ts b/src/api/resources/unstable/resources/tags/types/TagBasic.ts new file mode 100644 index 00000000..7067f78b --- /dev/null +++ b/src/api/resources/unstable/resources/tags/types/TagBasic.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A tag allows you to label your contacts, companies, and conversations and list them using that tag. + */ +export interface TagBasic { + /** value is "tag" */ + type?: string; + /** The id of the tag */ + id?: string; + /** The name of the tag */ + name?: string; +} diff --git a/src/api/resources/unstable/resources/tags/types/index.ts b/src/api/resources/unstable/resources/tags/types/index.ts new file mode 100644 index 00000000..0188807b --- /dev/null +++ b/src/api/resources/unstable/resources/tags/types/index.ts @@ -0,0 +1,3 @@ +export * from "./CreateTagRequestBody"; +export * from "./Tag"; +export * from "./TagBasic"; diff --git a/src/api/resources/unstable/resources/teams/client/Client.ts b/src/api/resources/unstable/resources/teams/client/Client.ts new file mode 100644 index 00000000..1a849930 --- /dev/null +++ b/src/api/resources/unstable/resources/teams/client/Client.ts @@ -0,0 +1,258 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace Teams { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + } +} + +/** + * Everything about your Teams + */ +export class Teams { + constructor(protected readonly _options: Teams.Options = {}) {} + + /** + * This will return a list of team objects for the App. + * + * @param {Teams.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.teams.listTeams() + */ + public listTeams(requestOptions?: Teams.RequestOptions): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listTeams(requestOptions)); + } + + private async __listTeams( + requestOptions?: Teams.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "teams", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.TeamList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /teams."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can fetch the details of a single team, containing an array of admins that belong to this team. + * + * @param {Intercom.unstable.RetrieveTeamRequest} request + * @param {Teams.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.teams.retrieveTeam({ + * id: "123" + * }) + */ + public retrieveTeam( + request: Intercom.unstable.RetrieveTeamRequest, + requestOptions?: Teams.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveTeam(request, requestOptions)); + } + + private async __retrieveTeam( + request: Intercom.unstable.RetrieveTeamRequest, + requestOptions?: Teams.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `teams/${encodeURIComponent(id)}`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Team, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /teams/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["INTERCOM_API_KEY"]; + if (bearer == null) { + throw new errors.IntercomError({ + message: + "Please specify a bearer by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", + }); + } + + return `Bearer ${bearer}`; + } +} diff --git a/src/api/resources/unstable/resources/teams/client/index.ts b/src/api/resources/unstable/resources/teams/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/api/resources/unstable/resources/teams/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/unstable/resources/teams/client/requests/RetrieveTeamRequest.ts b/src/api/resources/unstable/resources/teams/client/requests/RetrieveTeamRequest.ts new file mode 100644 index 00000000..0b09296c --- /dev/null +++ b/src/api/resources/unstable/resources/teams/client/requests/RetrieveTeamRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "123" + * } + */ +export interface RetrieveTeamRequest { + /** + * The unique identifier of a given team. + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/teams/client/requests/index.ts b/src/api/resources/unstable/resources/teams/client/requests/index.ts new file mode 100644 index 00000000..b8dd50a7 --- /dev/null +++ b/src/api/resources/unstable/resources/teams/client/requests/index.ts @@ -0,0 +1 @@ +export { type RetrieveTeamRequest } from "./RetrieveTeamRequest"; diff --git a/src/api/resources/unstable/resources/teams/index.ts b/src/api/resources/unstable/resources/teams/index.ts new file mode 100644 index 00000000..c9240f83 --- /dev/null +++ b/src/api/resources/unstable/resources/teams/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/unstable/resources/teams/types/Team.ts b/src/api/resources/unstable/resources/teams/types/Team.ts new file mode 100644 index 00000000..8ba1d68f --- /dev/null +++ b/src/api/resources/unstable/resources/teams/types/Team.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +/** + * Teams are groups of admins in Intercom. + */ +export interface Team { + /** Value is always "team" */ + type?: string; + /** The id of the team */ + id?: string; + /** The name of the team */ + name?: string; + /** The list of admin IDs that are a part of the team. */ + admin_ids?: number[]; + admin_priority_level?: Intercom.unstable.AdminPriorityLevel; +} diff --git a/src/api/resources/unstable/resources/teams/types/index.ts b/src/api/resources/unstable/resources/teams/types/index.ts new file mode 100644 index 00000000..e3645596 --- /dev/null +++ b/src/api/resources/unstable/resources/teams/types/index.ts @@ -0,0 +1 @@ +export * from "./Team"; diff --git a/src/api/resources/unstable/resources/ticketStates/client/Client.ts b/src/api/resources/unstable/resources/ticketStates/client/Client.ts new file mode 100644 index 00000000..9df86fd0 --- /dev/null +++ b/src/api/resources/unstable/resources/ticketStates/client/Client.ts @@ -0,0 +1,170 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace TicketStates { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + } +} + +/** + * Everything about your ticket states + */ +export class TicketStates { + constructor(protected readonly _options: TicketStates.Options = {}) {} + + /** + * You can get a list of all ticket states for a workspace. + * + * @param {TicketStates.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.ticketStates.listTicketStates() + */ + public listTicketStates( + requestOptions?: TicketStates.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listTicketStates(requestOptions)); + } + + private async __listTicketStates( + requestOptions?: TicketStates.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "ticket_states", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.TicketStateList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /ticket_states."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["INTERCOM_API_KEY"]; + if (bearer == null) { + throw new errors.IntercomError({ + message: + "Please specify a bearer by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", + }); + } + + return `Bearer ${bearer}`; + } +} diff --git a/src/api/resources/unstable/resources/ticketStates/client/index.ts b/src/api/resources/unstable/resources/ticketStates/client/index.ts new file mode 100644 index 00000000..cb0ff5c3 --- /dev/null +++ b/src/api/resources/unstable/resources/ticketStates/client/index.ts @@ -0,0 +1 @@ +export {}; diff --git a/src/api/resources/unstable/resources/ticketStates/index.ts b/src/api/resources/unstable/resources/ticketStates/index.ts new file mode 100644 index 00000000..5ec76921 --- /dev/null +++ b/src/api/resources/unstable/resources/ticketStates/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/unstable/resources/ticketTypeAttributes/client/Client.ts b/src/api/resources/unstable/resources/ticketTypeAttributes/client/Client.ts new file mode 100644 index 00000000..4db689cf --- /dev/null +++ b/src/api/resources/unstable/resources/ticketTypeAttributes/client/Client.ts @@ -0,0 +1,281 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace TicketTypeAttributes { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + } +} + +/** + * Everything about your ticket type attributes + */ +export class TicketTypeAttributes { + constructor(protected readonly _options: TicketTypeAttributes.Options = {}) {} + + /** + * You can create a new attribute for a ticket type. + * + * @param {Intercom.unstable.CreateTicketTypeAttributeRequest} request + * @param {TicketTypeAttributes.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.ticketTypeAttributes.createTicketTypeAttribute({ + * ticket_type_id: "ticket_type_id", + * name: "Attribute Title", + * description: "Attribute Description", + * data_type: "string", + * required_to_create: false + * }) + */ + public createTicketTypeAttribute( + request: Intercom.unstable.CreateTicketTypeAttributeRequest, + requestOptions?: TicketTypeAttributes.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createTicketTypeAttribute(request, requestOptions)); + } + + private async __createTicketTypeAttribute( + request: Intercom.unstable.CreateTicketTypeAttributeRequest, + requestOptions?: TicketTypeAttributes.RequestOptions, + ): Promise> { + const { ticket_type_id: ticketTypeId, ..._body } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `ticket_types/${encodeURIComponent(ticketTypeId)}/attributes`, + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: _body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.TicketTypeAttribute | undefined, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling POST /ticket_types/{ticket_type_id}/attributes.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can update an existing attribute for a ticket type. + * + * @param {Intercom.unstable.UpdateTicketTypeAttributeRequest} request + * @param {TicketTypeAttributes.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.ticketTypeAttributes.updateTicketTypeAttribute({ + * ticket_type_id: "ticket_type_id", + * id: "id", + * description: "New Attribute Description" + * }) + */ + public updateTicketTypeAttribute( + request: Intercom.unstable.UpdateTicketTypeAttributeRequest, + requestOptions?: TicketTypeAttributes.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__updateTicketTypeAttribute(request, requestOptions)); + } + + private async __updateTicketTypeAttribute( + request: Intercom.unstable.UpdateTicketTypeAttributeRequest, + requestOptions?: TicketTypeAttributes.RequestOptions, + ): Promise> { + const { ticket_type_id: ticketTypeId, id, ..._body } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `ticket_types/${encodeURIComponent(ticketTypeId)}/attributes/${encodeURIComponent(id)}`, + ), + method: "PUT", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: _body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.TicketTypeAttribute | undefined, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError( + "Timeout exceeded when calling PUT /ticket_types/{ticket_type_id}/attributes/{id}.", + ); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["INTERCOM_API_KEY"]; + if (bearer == null) { + throw new errors.IntercomError({ + message: + "Please specify a bearer by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", + }); + } + + return `Bearer ${bearer}`; + } +} diff --git a/src/api/resources/unstable/resources/ticketTypeAttributes/client/index.ts b/src/api/resources/unstable/resources/ticketTypeAttributes/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/api/resources/unstable/resources/ticketTypeAttributes/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/unstable/resources/ticketTypeAttributes/client/requests/CreateTicketTypeAttributeRequest.ts b/src/api/resources/unstable/resources/ticketTypeAttributes/client/requests/CreateTicketTypeAttributeRequest.ts new file mode 100644 index 00000000..0a9604c1 --- /dev/null +++ b/src/api/resources/unstable/resources/ticketTypeAttributes/client/requests/CreateTicketTypeAttributeRequest.ts @@ -0,0 +1,56 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * ticket_type_id: "ticket_type_id", + * name: "Attribute Title", + * description: "Attribute Description", + * data_type: "string", + * required_to_create: false + * } + */ +export interface CreateTicketTypeAttributeRequest { + /** + * The unique identifier for the ticket type which is given by Intercom. + */ + ticket_type_id: string; + /** The name of the ticket type attribute */ + name: string; + /** The description of the attribute presented to the teammate or contact */ + description: string; + /** The data type of the attribute */ + data_type: CreateTicketTypeAttributeRequest.DataType; + /** Whether the attribute is required to be filled in when teammates are creating the ticket in Inbox. */ + required_to_create?: boolean; + /** Whether the attribute is required to be filled in when contacts are creating the ticket in Messenger. */ + required_to_create_for_contacts?: boolean; + /** Whether the attribute is visible to teammates when creating a ticket in Inbox. */ + visible_on_create?: boolean; + /** Whether the attribute is visible to contacts when creating a ticket in Messenger. */ + visible_to_contacts?: boolean; + /** Whether the attribute allows multiple lines of text (only applicable to string attributes) */ + multiline?: boolean; + /** A comma delimited list of items for the attribute value (only applicable to list attributes) */ + list_items?: string; + /** Whether the attribute allows multiple files to be attached to it (only applicable to file attributes) */ + allow_multiple_values?: boolean; +} + +export namespace CreateTicketTypeAttributeRequest { + /** + * The data type of the attribute + */ + export type DataType = "string" | "list" | "integer" | "decimal" | "boolean" | "datetime" | "files"; + export const DataType = { + String: "string", + List: "list", + Integer: "integer", + Decimal: "decimal", + Boolean: "boolean", + Datetime: "datetime", + Files: "files", + } as const; +} diff --git a/src/api/resources/unstable/resources/ticketTypeAttributes/client/requests/UpdateTicketTypeAttributeRequest.ts b/src/api/resources/unstable/resources/ticketTypeAttributes/client/requests/UpdateTicketTypeAttributeRequest.ts new file mode 100644 index 00000000..9575db2d --- /dev/null +++ b/src/api/resources/unstable/resources/ticketTypeAttributes/client/requests/UpdateTicketTypeAttributeRequest.ts @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * ticket_type_id: "ticket_type_id", + * id: "id", + * description: "New Attribute Description" + * } + */ +export interface UpdateTicketTypeAttributeRequest { + /** + * The unique identifier for the ticket type which is given by Intercom. + */ + ticket_type_id: string; + /** + * The unique identifier for the ticket type attribute which is given by Intercom. + */ + id: string; + /** The name of the ticket type attribute */ + name?: string; + /** The description of the attribute presented to the teammate or contact */ + description?: string; + /** Whether the attribute is required to be filled in when teammates are creating the ticket in Inbox. */ + required_to_create?: boolean; + /** Whether the attribute is required to be filled in when contacts are creating the ticket in Messenger. */ + required_to_create_for_contacts?: boolean; + /** Whether the attribute is visible to teammates when creating a ticket in Inbox. */ + visible_on_create?: boolean; + /** Whether the attribute is visible to contacts when creating a ticket in Messenger. */ + visible_to_contacts?: boolean; + /** Whether the attribute allows multiple lines of text (only applicable to string attributes) */ + multiline?: boolean; + /** A comma delimited list of items for the attribute value (only applicable to list attributes) */ + list_items?: string; + /** Whether the attribute allows multiple files to be attached to it (only applicable to file attributes) */ + allow_multiple_values?: boolean; + /** Whether the attribute should be archived and not shown during creation of the ticket (it will still be present on previously created tickets) */ + archived?: boolean; +} diff --git a/src/api/resources/unstable/resources/ticketTypeAttributes/client/requests/index.ts b/src/api/resources/unstable/resources/ticketTypeAttributes/client/requests/index.ts new file mode 100644 index 00000000..b2d37564 --- /dev/null +++ b/src/api/resources/unstable/resources/ticketTypeAttributes/client/requests/index.ts @@ -0,0 +1,2 @@ +export { type CreateTicketTypeAttributeRequest } from "./CreateTicketTypeAttributeRequest"; +export { type UpdateTicketTypeAttributeRequest } from "./UpdateTicketTypeAttributeRequest"; diff --git a/src/api/resources/unstable/resources/ticketTypeAttributes/index.ts b/src/api/resources/unstable/resources/ticketTypeAttributes/index.ts new file mode 100644 index 00000000..5ec76921 --- /dev/null +++ b/src/api/resources/unstable/resources/ticketTypeAttributes/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/unstable/resources/ticketTypes/client/Client.ts b/src/api/resources/unstable/resources/ticketTypes/client/Client.ts new file mode 100644 index 00000000..857fd1f7 --- /dev/null +++ b/src/api/resources/unstable/resources/ticketTypes/client/Client.ts @@ -0,0 +1,354 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace TicketTypes { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + } +} + +/** + * Everything about your ticket types + */ +export class TicketTypes { + constructor(protected readonly _options: TicketTypes.Options = {}) {} + + /** + * You can get a list of all ticket types for a workspace. + * + * @param {TicketTypes.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.ticketTypes.listTicketTypes() + */ + public listTicketTypes( + requestOptions?: TicketTypes.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__listTicketTypes(requestOptions)); + } + + private async __listTicketTypes( + requestOptions?: TicketTypes.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "ticket_types", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.TicketTypeList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /ticket_types."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can create a new ticket type. + * > 📘 Creating ticket types. + * > + * > Every ticket type will be created with two default attributes: _default_title_ and _default_description_. + * > For the `icon` propery, use an emoji from [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app/) + * + * @param {unknown} request + * @param {TicketTypes.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.ticketTypes.createTicketType({ + * "key": "value" + * }) + */ + public createTicketType( + request?: unknown, + requestOptions?: TicketTypes.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__createTicketType(request, requestOptions)); + } + + private async __createTicketType( + request?: unknown, + requestOptions?: TicketTypes.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "ticket_types", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.TicketType | undefined, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /ticket_types."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can fetch the details of a single ticket type. + * + * @param {Intercom.unstable.GetTicketTypeRequest} request + * @param {TicketTypes.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.ticketTypes.getTicketType({ + * id: "id" + * }) + */ + public getTicketType( + request: Intercom.unstable.GetTicketTypeRequest, + requestOptions?: TicketTypes.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__getTicketType(request, requestOptions)); + } + + private async __getTicketType( + request: Intercom.unstable.GetTicketTypeRequest, + requestOptions?: TicketTypes.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `ticket_types/${encodeURIComponent(id)}`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.TicketType | undefined, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /ticket_types/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["INTERCOM_API_KEY"]; + if (bearer == null) { + throw new errors.IntercomError({ + message: + "Please specify a bearer by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", + }); + } + + return `Bearer ${bearer}`; + } +} diff --git a/src/api/resources/unstable/resources/ticketTypes/client/index.ts b/src/api/resources/unstable/resources/ticketTypes/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/api/resources/unstable/resources/ticketTypes/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/unstable/resources/ticketTypes/client/requests/GetTicketTypeRequest.ts b/src/api/resources/unstable/resources/ticketTypes/client/requests/GetTicketTypeRequest.ts new file mode 100644 index 00000000..b9868adc --- /dev/null +++ b/src/api/resources/unstable/resources/ticketTypes/client/requests/GetTicketTypeRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "id" + * } + */ +export interface GetTicketTypeRequest { + /** + * The unique identifier for the ticket type which is given by Intercom. + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/ticketTypes/client/requests/index.ts b/src/api/resources/unstable/resources/ticketTypes/client/requests/index.ts new file mode 100644 index 00000000..c25063a7 --- /dev/null +++ b/src/api/resources/unstable/resources/ticketTypes/client/requests/index.ts @@ -0,0 +1 @@ +export { type GetTicketTypeRequest } from "./GetTicketTypeRequest"; diff --git a/src/api/resources/unstable/resources/ticketTypes/index.ts b/src/api/resources/unstable/resources/ticketTypes/index.ts new file mode 100644 index 00000000..5ec76921 --- /dev/null +++ b/src/api/resources/unstable/resources/ticketTypes/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/unstable/resources/tickets/client/Client.ts b/src/api/resources/unstable/resources/tickets/client/Client.ts new file mode 100644 index 00000000..116eed02 --- /dev/null +++ b/src/api/resources/unstable/resources/tickets/client/Client.ts @@ -0,0 +1,770 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace Tickets { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + } +} + +/** + * Everything about your tickets + */ +export class Tickets { + constructor(protected readonly _options: Tickets.Options = {}) {} + + /** + * You can reply to a ticket with a message from an admin or on behalf of a contact, or with a note for admins. + * + * @param {Intercom.unstable.ReplyTicketRequest} request + * @param {Tickets.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.BadRequestError} + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.tickets.replyTicket({ + * id: "123", + * body: { + * message_type: "comment", + * type: "user", + * body: "Thanks again :)", + * intercom_user_id: "6762f2971bb69f9f2193bc49" + * } + * }) + * + * @example + * await client.unstable.tickets.replyTicket({ + * id: "123", + * body: { + * message_type: "note", + * type: "admin", + * body: "

An Unordered HTML List

  • Coffee
  • Tea
  • Milk

An Ordered HTML List

  1. Coffee
  2. Tea
  3. Milk
", + * admin_id: "3156780" + * } + * }) + * + * @example + * await client.unstable.tickets.replyTicket({ + * id: "123", + * body: { + * message_type: "quick_reply", + * type: "admin", + * admin_id: "3156780", + * reply_options: [{ + * text: "Yes", + * uuid: "0df48b85-9a93-4c66-a167-753eff0baaec" + * }, { + * text: "No", + * uuid: "4f0b5145-4193-4b4f-8cad-ce19478a3938" + * }] + * } + * }) + * + * @example + * await client.unstable.tickets.replyTicket({ + * id: "123", + * body: { + * message_type: "comment", + * type: "user", + * body: "Thanks again :)", + * intercom_user_id: "6762f2a41bb69f9f2193bc4c" + * } + * }) + */ + public replyTicket( + request: Intercom.unstable.ReplyTicketRequest, + requestOptions?: Tickets.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__replyTicket(request, requestOptions)); + } + + private async __replyTicket( + request: Intercom.unstable.ReplyTicketRequest, + requestOptions?: Tickets.RequestOptions, + ): Promise> { + const { id, body: _body } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `tickets/${encodeURIComponent(id)}/reply`, + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: _body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.TicketReply, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /tickets/{id}/reply."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * Enqueues ticket creation for asynchronous processing, returning if the job was enqueued successfully to be processed. We attempt to perform a best-effort validation on inputs before tasks are enqueued. If the given parameters are incorrect, we won't enqueue the job. + * + * @param {Intercom.unstable.EnqueueCreateTicketRequest} request + * @param {Tickets.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.BadRequestError} + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.tickets.enqueueCreateTicket({ + * ticket_type_id: "1234", + * contacts: [{ + * id: "6762f2d81bb69f9f2193bc54" + * }] + * }) + */ + public enqueueCreateTicket( + request: Intercom.unstable.EnqueueCreateTicketRequest, + requestOptions?: Tickets.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__enqueueCreateTicket(request, requestOptions)); + } + + private async __enqueueCreateTicket( + request: Intercom.unstable.EnqueueCreateTicketRequest, + requestOptions?: Tickets.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "tickets/enqueue", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Jobs, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /tickets/enqueue."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can fetch the details of a single ticket. + * + * @param {Intercom.unstable.GetTicketRequest} request + * @param {Tickets.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.tickets.getTicket({ + * id: "id" + * }) + */ + public getTicket( + request: Intercom.unstable.GetTicketRequest, + requestOptions?: Tickets.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__getTicket(request, requestOptions)); + } + + private async __getTicket( + request: Intercom.unstable.GetTicketRequest, + requestOptions?: Tickets.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `tickets/${encodeURIComponent(id)}`, + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Ticket | undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /tickets/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can update a ticket. + * + * @param {Intercom.unstable.UpdateTicketRequest} request + * @param {Tickets.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.BadRequestError} + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.tickets.updateTicket({ + * id: "id", + * ticket_attributes: { + * "_default_title_": "example", + * "_default_description_": "there is a problem" + * }, + * ticket_state_id: "123", + * open: true, + * snoozed_until: 1673609604, + * admin_id: 991268011, + * assignee_id: "123" + * }) + * + * @example + * await client.unstable.tickets.updateTicket({ + * id: "id", + * ticket_attributes: { + * "_default_title_": "example", + * "_default_description_": "there is a problem" + * }, + * ticket_state_id: "123", + * admin_id: 991268011, + * assignee_id: "123" + * }) + * + * @example + * await client.unstable.tickets.updateTicket({ + * id: "id", + * ticket_state_id: "123" + * }) + */ + public updateTicket( + request: Intercom.unstable.UpdateTicketRequest, + requestOptions?: Tickets.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__updateTicket(request, requestOptions)); + } + + private async __updateTicket( + request: Intercom.unstable.UpdateTicketRequest, + requestOptions?: Tickets.RequestOptions, + ): Promise> { + const { id, ..._body } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `tickets/${encodeURIComponent(id)}`, + ), + method: "PUT", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: _body, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Ticket | undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Intercom.unstable.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling PUT /tickets/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can delete a ticket using the Intercom provided ID. + * + * @param {Intercom.unstable.DeleteTicketRequest} request + * @param {Tickets.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.tickets.deleteTicket({ + * id: "id" + * }) + */ + public deleteTicket( + request: Intercom.unstable.DeleteTicketRequest, + requestOptions?: Tickets.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__deleteTicket(request, requestOptions)); + } + + private async __deleteTicket( + request: Intercom.unstable.DeleteTicketRequest, + requestOptions?: Tickets.RequestOptions, + ): Promise> { + const { id } = request; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + `tickets/${encodeURIComponent(id)}`, + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.DeleteTicketResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling DELETE /tickets/{id}."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can search for multiple tickets by the value of their attributes in order to fetch exactly which ones you want. + * + * To search for tickets, you send a `POST` request to `https://api.intercom.io/tickets/search`. + * + * This will accept a query object in the body which will define your filters. + * {% admonition type="warning" name="Optimizing search queries" %} + * Search queries can be complex, so optimizing them can help the performance of your search. + * Use the `AND` and `OR` operators to combine multiple filters to get the exact results you need and utilize + * pagination to limit the number of results returned. The default is `20` results per page. + * See the [pagination section](https://developers.intercom.com/docs/build-an-integration/learn-more/rest-apis/pagination/#example-search-conversations-request) for more details on how to use the `starting_after` param. + * {% /admonition %} + * + * ### Nesting & Limitations + * + * You can nest these filters in order to get even more granular insights that pinpoint exactly what you need. Example: (1 OR 2) AND (3 OR 4). + * There are some limitations to the amount of multiples there can be: + * - There's a limit of max 2 nested filters + * - There's a limit of max 15 filters for each AND or OR group + * + * ### Accepted Fields + * + * Most keys listed as part of the Ticket model are searchable, whether writeable or not. The value you search for has to match the accepted type, otherwise the query will fail (ie. as `created_at` accepts a date, the `value` cannot be a string such as `"foobar"`). + * The `source.body` field is unique as the search will not be performed against the entire value, but instead against every element of the value separately. For example, when searching for a conversation with a `"I need support"` body - the query should contain a `=` operator with the value `"support"` for such conversation to be returned. A query with a `=` operator and a `"need support"` value will not yield a result. + * + * | Field | Type | + * | :---------------------------------------- | :--------------------------------------------------------------------------------------- | + * | id | String | + * | created_at | Date (UNIX timestamp) | + * | updated_at | Date (UNIX timestamp) | + * | _default_title_ | String | + * | _default_description_ | String | + * | category | String | + * | ticket_type_id | String | + * | contact_ids | String | + * | teammate_ids | String | + * | admin_assignee_id | String | + * | team_assignee_id | String | + * | open | Boolean | + * | state | String | + * | snoozed_until | Date (UNIX timestamp) | + * | ticket_attribute.{id} | String or Boolean or Date (UNIX timestamp) or Float or Integer | + * + * ### Accepted Operators + * + * {% admonition type="info" name="Searching based on `created_at`" %} + * You may use the `<=` or `>=` operators to search by `created_at`. + * {% /admonition %} + * + * The table below shows the operators you can use to define how you want to search for the value. The operator should be put in as a string (`"="`). The operator has to be compatible with the field's type (eg. you cannot search with `>` for a given string value as it's only compatible for integer's and dates). + * + * | Operator | Valid Types | Description | + * | :------- | :----------------------------- | :----------------------------------------------------------- | + * | = | All | Equals | + * | != | All | Doesn't Equal | + * | IN | All | In Shortcut for `OR` queries Values most be in Array | + * | NIN | All | Not In Shortcut for `OR !` queries Values must be in Array | + * | > | Integer Date (UNIX Timestamp) | Greater (or equal) than | + * | < | Integer Date (UNIX Timestamp) | Lower (or equal) than | + * | ~ | String | Contains | + * | !~ | String | Doesn't Contain | + * | ^ | String | Starts With | + * | $ | String | Ends With | + * + * @param {Intercom.unstable.SearchRequest} request + * @param {Tickets.RequestOptions} requestOptions - Request-specific configuration. + * + * @example + * await client.unstable.tickets.searchTickets({ + * query: { + * operator: "AND", + * value: [{ + * field: "created_at", + * operator: ">", + * value: "1306054154" + * }] + * }, + * pagination: { + * per_page: 5 + * } + * }) + */ + public searchTickets( + request: Intercom.unstable.SearchRequest, + requestOptions?: Tickets.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__searchTickets(request, requestOptions)); + } + + private async __searchTickets( + request: Intercom.unstable.SearchRequest, + requestOptions?: Tickets.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "tickets/search", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.TicketList, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /tickets/search."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["INTERCOM_API_KEY"]; + if (bearer == null) { + throw new errors.IntercomError({ + message: + "Please specify a bearer by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", + }); + } + + return `Bearer ${bearer}`; + } +} diff --git a/src/api/resources/unstable/resources/tickets/client/index.ts b/src/api/resources/unstable/resources/tickets/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/api/resources/unstable/resources/tickets/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/unstable/resources/tickets/client/requests/DeleteTicketRequest.ts b/src/api/resources/unstable/resources/tickets/client/requests/DeleteTicketRequest.ts new file mode 100644 index 00000000..3a9f96f8 --- /dev/null +++ b/src/api/resources/unstable/resources/tickets/client/requests/DeleteTicketRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "id" + * } + */ +export interface DeleteTicketRequest { + /** + * The unique identifier for the ticket which is given by Intercom. + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/tickets/client/requests/EnqueueCreateTicketRequest.ts b/src/api/resources/unstable/resources/tickets/client/requests/EnqueueCreateTicketRequest.ts new file mode 100644 index 00000000..d1d3b5ee --- /dev/null +++ b/src/api/resources/unstable/resources/tickets/client/requests/EnqueueCreateTicketRequest.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../../index"; + +/** + * @example + * { + * ticket_type_id: "1234", + * contacts: [{ + * id: "6762f2d81bb69f9f2193bc54" + * }] + * } + */ +export interface EnqueueCreateTicketRequest extends Intercom.unstable.CreateTicketRequestBody { + /** Option to disable notifications when a Ticket is created. */ + skip_notifications?: boolean; +} diff --git a/src/api/resources/unstable/resources/tickets/client/requests/GetTicketRequest.ts b/src/api/resources/unstable/resources/tickets/client/requests/GetTicketRequest.ts new file mode 100644 index 00000000..ea0795f8 --- /dev/null +++ b/src/api/resources/unstable/resources/tickets/client/requests/GetTicketRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "id" + * } + */ +export interface GetTicketRequest { + /** + * The unique identifier for the ticket which is given by Intercom. + */ + id: string; +} diff --git a/src/api/resources/unstable/resources/tickets/client/requests/ReplyTicketRequest.ts b/src/api/resources/unstable/resources/tickets/client/requests/ReplyTicketRequest.ts new file mode 100644 index 00000000..ae8e6378 --- /dev/null +++ b/src/api/resources/unstable/resources/tickets/client/requests/ReplyTicketRequest.ts @@ -0,0 +1,61 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../../index"; + +/** + * @example + * { + * id: "123", + * body: { + * message_type: "comment", + * type: "user", + * body: "Thanks again :)", + * intercom_user_id: "6762f2971bb69f9f2193bc49" + * } + * } + * + * @example + * { + * id: "123", + * body: { + * message_type: "note", + * type: "admin", + * body: "

An Unordered HTML List

  • Coffee
  • Tea
  • Milk

An Ordered HTML List

  1. Coffee
  2. Tea
  3. Milk
", + * admin_id: "3156780" + * } + * } + * + * @example + * { + * id: "123", + * body: { + * message_type: "quick_reply", + * type: "admin", + * admin_id: "3156780", + * reply_options: [{ + * text: "Yes", + * uuid: "0df48b85-9a93-4c66-a167-753eff0baaec" + * }, { + * text: "No", + * uuid: "4f0b5145-4193-4b4f-8cad-ce19478a3938" + * }] + * } + * } + * + * @example + * { + * id: "123", + * body: { + * message_type: "comment", + * type: "user", + * body: "Thanks again :)", + * intercom_user_id: "6762f2a41bb69f9f2193bc4c" + * } + * } + */ +export interface ReplyTicketRequest { + id: string; + body: Intercom.unstable.ReplyTicketRequestBody; +} diff --git a/src/api/resources/unstable/resources/tickets/client/requests/UpdateTicketRequest.ts b/src/api/resources/unstable/resources/tickets/client/requests/UpdateTicketRequest.ts new file mode 100644 index 00000000..28c7e40f --- /dev/null +++ b/src/api/resources/unstable/resources/tickets/client/requests/UpdateTicketRequest.ts @@ -0,0 +1,71 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * id: "id", + * ticket_attributes: { + * "_default_title_": "example", + * "_default_description_": "there is a problem" + * }, + * ticket_state_id: "123", + * open: true, + * snoozed_until: 1673609604, + * admin_id: 991268011, + * assignee_id: "123" + * } + * + * @example + * { + * id: "id", + * ticket_attributes: { + * "_default_title_": "example", + * "_default_description_": "there is a problem" + * }, + * ticket_state_id: "123", + * admin_id: 991268011, + * assignee_id: "123" + * } + * + * @example + * { + * id: "id", + * ticket_attributes: { + * "_default_title_": "example", + * "_default_description_": "there is a problem" + * }, + * ticket_state_id: "123", + * admin_id: 991268011, + * assignee_id: "123" + * } + * + * @example + * { + * id: "id", + * ticket_state_id: "123" + * } + */ +export interface UpdateTicketRequest { + /** + * The unique identifier for the ticket which is given by Intercom + */ + id: string; + /** The attributes set on the ticket. */ + ticket_attributes?: Record; + /** The ID of the ticket state associated with the ticket type. */ + ticket_state_id?: string; + /** The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom. Set to nil to remove company. */ + company_id?: string; + /** Specify if a ticket is open. Set to false to close a ticket. Closing a ticket will also unsnooze it. */ + open?: boolean; + /** Specify whether the ticket is visible to users. */ + is_shared?: boolean; + /** The time you want the ticket to reopen. */ + snoozed_until?: number; + /** The ID of the admin performing ticket update. Needed for workflows execution and attributing actions to specific admins. */ + admin_id?: number; + /** The ID of the admin or team to which the ticket is assigned. Set this 0 to unassign it. */ + assignee_id?: string; +} diff --git a/src/api/resources/unstable/resources/tickets/client/requests/index.ts b/src/api/resources/unstable/resources/tickets/client/requests/index.ts new file mode 100644 index 00000000..b6a892f9 --- /dev/null +++ b/src/api/resources/unstable/resources/tickets/client/requests/index.ts @@ -0,0 +1,5 @@ +export { type ReplyTicketRequest } from "./ReplyTicketRequest"; +export { type EnqueueCreateTicketRequest } from "./EnqueueCreateTicketRequest"; +export { type GetTicketRequest } from "./GetTicketRequest"; +export { type UpdateTicketRequest } from "./UpdateTicketRequest"; +export { type DeleteTicketRequest } from "./DeleteTicketRequest"; diff --git a/src/api/resources/unstable/resources/tickets/index.ts b/src/api/resources/unstable/resources/tickets/index.ts new file mode 100644 index 00000000..c9240f83 --- /dev/null +++ b/src/api/resources/unstable/resources/tickets/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/api/resources/unstable/resources/tickets/types/DeleteTicketResponse.ts b/src/api/resources/unstable/resources/tickets/types/DeleteTicketResponse.ts new file mode 100644 index 00000000..579725c6 --- /dev/null +++ b/src/api/resources/unstable/resources/tickets/types/DeleteTicketResponse.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Response when a ticket is deleted. + */ +export interface DeleteTicketResponse { + /** The unique identifier for the ticket. */ + id?: string; + /** always ticket */ + object?: "ticket"; + /** Whether the ticket is deleted or not. */ + deleted?: boolean; +} diff --git a/src/api/resources/unstable/resources/tickets/types/ReplyTicketRequestBody.ts b/src/api/resources/unstable/resources/tickets/types/ReplyTicketRequestBody.ts new file mode 100644 index 00000000..3f2ede0c --- /dev/null +++ b/src/api/resources/unstable/resources/tickets/types/ReplyTicketRequestBody.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +export type ReplyTicketRequestBody = + | Intercom.unstable.ContactReplyTicketRequest + | Intercom.unstable.AdminReplyTicketRequest; diff --git a/src/api/resources/unstable/resources/tickets/types/Ticket.ts b/src/api/resources/unstable/resources/tickets/types/Ticket.ts new file mode 100644 index 00000000..45defe9b --- /dev/null +++ b/src/api/resources/unstable/resources/tickets/types/Ticket.ts @@ -0,0 +1,51 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +/** + * Tickets are how you track requests from your users. + */ +export interface Ticket { + /** Always ticket */ + type?: "ticket"; + /** The unique identifier for the ticket which is given by Intercom. */ + id?: string; + /** The ID of the Ticket used in the Intercom Inbox and Messenger. Do not use ticket_id for API queries. */ + ticket_id?: string; + /** Category of the Ticket. */ + category?: Ticket.Category; + ticket_attributes?: Intercom.unstable.TicketCustomAttributes; + ticket_state?: Intercom.unstable.TicketState; + ticket_type?: Intercom.unstable.TicketType; + contacts?: Intercom.unstable.TicketContacts; + /** The id representing the admin assigned to the ticket. */ + admin_assignee_id?: string; + /** The id representing the team assigned to the ticket. */ + team_assignee_id?: string; + /** The time the ticket was created as a UTC Unix timestamp. */ + created_at?: number; + /** The last time the ticket was updated as a UTC Unix timestamp. */ + updated_at?: number; + /** Whether or not the ticket is open. If false, the ticket is closed. */ + open?: boolean; + /** The time the ticket will be snoozed until as a UTC Unix timestamp. If null, the ticket is not currently snoozed. */ + snoozed_until?: number; + linked_objects?: Intercom.unstable.LinkedObjectList; + ticket_parts?: Intercom.unstable.TicketParts; + /** Whether or not the ticket is shared with the customer. */ + is_shared?: boolean; +} + +export namespace Ticket { + /** + * Category of the Ticket. + */ + export type Category = "Customer" | "Back-office" | "Tracker"; + export const Category = { + Customer: "Customer", + BackOffice: "Back-office", + Tracker: "Tracker", + } as const; +} diff --git a/src/api/resources/unstable/resources/tickets/types/TicketContacts.ts b/src/api/resources/unstable/resources/tickets/types/TicketContacts.ts new file mode 100644 index 00000000..e025dd66 --- /dev/null +++ b/src/api/resources/unstable/resources/tickets/types/TicketContacts.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +/** + * The list of contacts affected by a ticket. + */ +export interface TicketContacts { + /** always contact.list */ + type?: "contact.list"; + /** The list of contacts affected by this ticket. */ + contacts?: Intercom.unstable.ContactReference[]; +} diff --git a/src/api/resources/unstable/resources/tickets/types/TicketPart.ts b/src/api/resources/unstable/resources/tickets/types/TicketPart.ts new file mode 100644 index 00000000..9153bf31 --- /dev/null +++ b/src/api/resources/unstable/resources/tickets/types/TicketPart.ts @@ -0,0 +1,115 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +/** + * A Ticket Part represents a message in the ticket. + */ +export interface TicketPart { + /** Always ticket_part */ + type?: string; + /** The id representing the ticket part. */ + id?: string; + /** The type of ticket part. */ + part_type?: string; + /** The message body, which may contain HTML. */ + body?: string; + /** The previous state of the ticket. */ + previous_ticket_state?: TicketPart.PreviousTicketState; + /** The state of the ticket. */ + ticket_state?: TicketPart.TicketState; + /** The time the ticket part was created. */ + created_at?: number; + /** The last time the ticket part was updated. */ + updated_at?: number; + /** The id of the admin that was assigned the ticket by this ticket_part (null if there has been no change in assignment.) */ + assigned_to?: Intercom.unstable.Reference; + author?: Intercom.unstable.TicketPartAuthor; + /** A list of attachments for the part. */ + attachments?: Intercom.unstable.PartAttachment[]; + /** The external id of the ticket part */ + external_id?: string; + /** Whether or not the ticket part has been redacted. */ + redacted?: boolean; + /** The app package code if this part was created via API. Note this field won't show if the part was not created via API. */ + app_package_code?: string; + /** The updated attribute data of the ticket part. Only present for attribute update parts. */ + updated_attribute_data?: TicketPart.UpdatedAttributeData; +} + +export namespace TicketPart { + /** + * The previous state of the ticket. + */ + export type PreviousTicketState = "submitted" | "in_progress" | "waiting_on_customer" | "resolved"; + export const PreviousTicketState = { + Submitted: "submitted", + InProgress: "in_progress", + WaitingOnCustomer: "waiting_on_customer", + Resolved: "resolved", + } as const; + /** + * The state of the ticket. + */ + export type TicketState = "submitted" | "in_progress" | "waiting_on_customer" | "resolved"; + export const TicketState = { + Submitted: "submitted", + InProgress: "in_progress", + WaitingOnCustomer: "waiting_on_customer", + Resolved: "resolved", + } as const; + + /** + * The updated attribute data of the ticket part. Only present for attribute update parts. + */ + export interface UpdatedAttributeData { + /** Information about the attribute that was updated. */ + attribute: UpdatedAttributeData.Attribute; + /** The new value of the attribute. */ + value: UpdatedAttributeData.Value; + } + + export namespace UpdatedAttributeData { + /** + * Information about the attribute that was updated. + */ + export interface Attribute { + /** The type of the object. Always 'attribute'. */ + type: "attribute"; + /** The unique identifier of the attribute. */ + id: string; + /** The human-readable name of the attribute. */ + label: string; + } + + /** + * The new value of the attribute. + */ + export interface Value { + /** The type of the object. Always 'value'. */ + type: "value"; + id: Value.Id; + label: Value.Label; + } + + export namespace Value { + export type Id = + /** + * The value for text/number/decimal/boolean/date attributes, or the ID of the list option for list attributes. */ + | string + | undefined + /** + * Array of file IDs for file attributes. */ + | number[]; + export type Label = + /** + * The display value for text/number/decimal/boolean/date/list attributes. */ + | string + /** + * Array of file names for file attributes. */ + | string[]; + } + } +} diff --git a/src/api/resources/unstable/resources/tickets/types/TicketState.ts b/src/api/resources/unstable/resources/tickets/types/TicketState.ts new file mode 100644 index 00000000..70427191 --- /dev/null +++ b/src/api/resources/unstable/resources/tickets/types/TicketState.ts @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A ticket state, used to define the state of a ticket. + */ +export interface TicketState { + /** String representing the object's type. Always has the value `ticket_state`. */ + type?: string; + /** The id of the ticket state */ + id?: string; + /** The category of the ticket state */ + category?: TicketState.Category; + /** The state the ticket is currently in, in a human readable form - visible in Intercom */ + internal_label?: string; + /** The state the ticket is currently in, in a human readable form - visible to customers, in the messenger, email and tickets portal. */ + external_label?: string; +} + +export namespace TicketState { + /** + * The category of the ticket state + */ + export type Category = "submitted" | "in_progress" | "waiting_on_customer" | "resolved"; + export const Category = { + Submitted: "submitted", + InProgress: "in_progress", + WaitingOnCustomer: "waiting_on_customer", + Resolved: "resolved", + } as const; +} diff --git a/src/api/resources/unstable/resources/tickets/types/TicketStateDetailed.ts b/src/api/resources/unstable/resources/tickets/types/TicketStateDetailed.ts new file mode 100644 index 00000000..2502a84b --- /dev/null +++ b/src/api/resources/unstable/resources/tickets/types/TicketStateDetailed.ts @@ -0,0 +1,48 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +/** + * A ticket state, used to define the state of a ticket. + */ +export interface TicketStateDetailed { + /** String representing the object's type. Always has the value `ticket_state`. */ + type?: string; + /** The id of the ticket state */ + id?: string; + /** The category of the ticket state */ + category?: TicketStateDetailed.Category; + /** The state the ticket is currently in, in a human readable form - visible in Intercom */ + internal_label?: string; + /** The state the ticket is currently in, in a human readable form - visible to customers, in the messenger, email and tickets portal. */ + external_label?: string; + /** Whether the ticket state is archived */ + archived?: boolean; + /** A list of ticket types associated with a given ticket state. */ + ticket_types?: TicketStateDetailed.TicketTypes; +} + +export namespace TicketStateDetailed { + /** + * The category of the ticket state + */ + export type Category = "submitted" | "in_progress" | "waiting_on_customer" | "resolved"; + export const Category = { + Submitted: "submitted", + InProgress: "in_progress", + WaitingOnCustomer: "waiting_on_customer", + Resolved: "resolved", + } as const; + + /** + * A list of ticket types associated with a given ticket state. + */ + export interface TicketTypes { + /** String representing the object's type. Always has the value `list`. */ + type?: string; + /** A list of ticket type attributes associated with a given ticket type. */ + data?: (Intercom.unstable.TicketType | undefined)[]; + } +} diff --git a/src/api/resources/unstable/resources/tickets/types/TicketType.ts b/src/api/resources/unstable/resources/tickets/types/TicketType.ts new file mode 100644 index 00000000..3af90517 --- /dev/null +++ b/src/api/resources/unstable/resources/tickets/types/TicketType.ts @@ -0,0 +1,56 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../../../index"; + +/** + * A ticket type, used to define the data fields to be captured in a ticket. + */ +export interface TicketType { + /** String representing the object's type. Always has the value `ticket_type`. */ + type?: string; + /** The id representing the ticket type. */ + id?: string; + /** Category of the Ticket Type. */ + category?: TicketType.Category; + /** The name of the ticket type */ + name?: string; + /** The description of the ticket type */ + description?: string; + /** The icon of the ticket type */ + icon?: string; + /** The id of the workspace that the ticket type belongs to. */ + workspace_id?: string; + ticket_type_attributes?: Intercom.unstable.TicketTypeAttributeList; + /** A list of ticket states associated with a given ticket type. */ + ticket_states?: TicketType.TicketStates; + /** Whether the ticket type is archived or not. */ + archived?: boolean; + /** The date and time the ticket type was created. */ + created_at?: number; + /** The date and time the ticket type was last updated. */ + updated_at?: number; +} + +export namespace TicketType { + /** + * Category of the Ticket Type. + */ + export type Category = "Customer" | "Back-office" | "Tracker"; + export const Category = { + Customer: "Customer", + BackOffice: "Back-office", + Tracker: "Tracker", + } as const; + + /** + * A list of ticket states associated with a given ticket type. + */ + export interface TicketStates { + /** String representing the object's type. Always has the value `list`. */ + type?: string; + /** A list of ticket states associated with a given ticket type. */ + data?: (Intercom.unstable.TicketState | undefined)[]; + } +} diff --git a/src/api/resources/unstable/resources/tickets/types/index.ts b/src/api/resources/unstable/resources/tickets/types/index.ts new file mode 100644 index 00000000..5c6f7a46 --- /dev/null +++ b/src/api/resources/unstable/resources/tickets/types/index.ts @@ -0,0 +1,8 @@ +export * from "./ReplyTicketRequestBody"; +export * from "./DeleteTicketResponse"; +export * from "./Ticket"; +export * from "./TicketContacts"; +export * from "./TicketPart"; +export * from "./TicketState"; +export * from "./TicketStateDetailed"; +export * from "./TicketType"; diff --git a/src/api/resources/unstable/resources/visitors/client/Client.ts b/src/api/resources/unstable/resources/visitors/client/Client.ts new file mode 100644 index 00000000..ef6e2e8a --- /dev/null +++ b/src/api/resources/unstable/resources/visitors/client/Client.ts @@ -0,0 +1,386 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../../../environments"; +import * as core from "../../../../../../core"; +import * as Intercom from "../../../../../index"; +import urlJoin from "url-join"; +import * as errors from "../../../../../../errors/index"; + +export declare namespace Visitors { + export interface Options { + environment?: core.Supplier; + /** Specify a custom URL to connect the client to. */ + baseUrl?: core.Supplier; + token?: core.Supplier; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + fetcher?: core.FetchFunction; + } + + export interface RequestOptions { + /** The maximum time to wait for a response in seconds. */ + timeoutInSeconds?: number; + /** The number of times to retry the request. Defaults to 2. */ + maxRetries?: number; + /** A hook to abort the request. */ + abortSignal?: AbortSignal; + /** Additional headers to include in the request. */ + headers?: Record; + /** Override the Intercom-Version header */ + version?: + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; + } +} + +/** + * Everything about your Visitors + */ +export class Visitors { + constructor(protected readonly _options: Visitors.Options = {}) {} + + /** + * You can fetch the details of a single visitor. + * + * @param {Intercom.unstable.RetrieveVisitorWithUserIdRequest} request + * @param {Visitors.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.visitors.retrieveVisitorWithUserId({ + * user_id: "user_id" + * }) + */ + public retrieveVisitorWithUserId( + request: Intercom.unstable.RetrieveVisitorWithUserIdRequest, + requestOptions?: Visitors.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__retrieveVisitorWithUserId(request, requestOptions)); + } + + private async __retrieveVisitorWithUserId( + request: Intercom.unstable.RetrieveVisitorWithUserIdRequest, + requestOptions?: Visitors.RequestOptions, + ): Promise> { + const { user_id: userId } = request; + const _queryParams: Record = {}; + _queryParams["user_id"] = userId; + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "visitors", + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.Visitor | undefined, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /visitors."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * Sending a PUT request to `/visitors` will result in an update of an existing Visitor. + * + * **Option 1.** You can update a visitor by passing in the `user_id` of the visitor in the Request body. + * + * **Option 2.** You can update a visitor by passing in the `id` of the visitor in the Request body. + * + * @param {Intercom.UpdateVisitorRequestOne} request + * @param {Visitors.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * @throws {@link Intercom.unstable.NotFoundError} + * + * @example + * await client.unstable.visitors.updateVisitor({ + * "id": "6762f30c1bb69f9f2193bc5e", + * "name": "Gareth Bale" + * }) + * + * @example + * await client.unstable.visitors.updateVisitor({ + * "user_id": "fail", + * "name": "Christian Fail" + * }) + */ + public updateVisitor( + request?: Intercom.UpdateVisitorRequestOne, + requestOptions?: Visitors.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__updateVisitor(request, requestOptions)); + } + + private async __updateVisitor( + request?: Intercom.UpdateVisitorRequestOne, + requestOptions?: Visitors.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "visitors", + ), + method: "PUT", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { + data: _response.body as Intercom.unstable.Visitor | undefined, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + case 404: + throw new Intercom.unstable.NotFoundError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling PUT /visitors."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + /** + * You can merge a Visitor to a Contact of role type `lead` or `user`. + * + * > 📘 What happens upon a visitor being converted? + * > + * > 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. + * + * @param {Intercom.unstable.ConvertVisitorRequest} request + * @param {Visitors.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Intercom.unstable.UnauthorizedError} + * + * @example + * await client.unstable.visitors.convertVisitor({ + * type: "user", + * user: { + * "email": "foo@bar.com" + * }, + * visitor: { + * "user_id": "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3" + * } + * }) + */ + public convertVisitor( + request: Intercom.unstable.ConvertVisitorRequest, + requestOptions?: Visitors.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__convertVisitor(request, requestOptions)); + } + + private async __convertVisitor( + request: Intercom.unstable.ConvertVisitorRequest, + requestOptions?: Visitors.RequestOptions, + ): Promise> { + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)) ?? + environments.IntercomEnvironment.UsProduction, + "visitors/convert", + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "intercom-client", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", + "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + ...requestOptions?.headers, + }, + contentType: "application/json", + requestType: "json", + body: request, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 20000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return { data: _response.body as Intercom.unstable.Contact, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Intercom.unstable.UnauthorizedError( + _response.error.body as Intercom.unstable.Error_, + _response.rawResponse, + ); + default: + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.IntercomError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + rawResponse: _response.rawResponse, + }); + case "timeout": + throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /visitors/convert."); + case "unknown": + throw new errors.IntercomError({ + message: _response.error.errorMessage, + rawResponse: _response.rawResponse, + }); + } + } + + protected async _getAuthorizationHeader(): Promise { + const bearer = (await core.Supplier.get(this._options.token)) ?? process?.env["INTERCOM_API_KEY"]; + if (bearer == null) { + throw new errors.IntercomError({ + message: + "Please specify a bearer by either passing it in to the constructor or initializing a INTERCOM_API_KEY environment variable", + }); + } + + return `Bearer ${bearer}`; + } +} diff --git a/src/api/resources/unstable/resources/visitors/client/index.ts b/src/api/resources/unstable/resources/visitors/client/index.ts new file mode 100644 index 00000000..415726b7 --- /dev/null +++ b/src/api/resources/unstable/resources/visitors/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/unstable/resources/visitors/client/requests/ConvertVisitorRequest.ts b/src/api/resources/unstable/resources/visitors/client/requests/ConvertVisitorRequest.ts new file mode 100644 index 00000000..275e76e7 --- /dev/null +++ b/src/api/resources/unstable/resources/visitors/client/requests/ConvertVisitorRequest.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * type: "user", + * user: { + * "email": "foo@bar.com" + * }, + * visitor: { + * "user_id": "3ecf64d0-9ed1-4e9f-88e1-da7d6e6782f3" + * } + * } + */ +export interface ConvertVisitorRequest { + /** Represents the role of the Contact model. Accepts `lead` or `user`. */ + type: string; + user?: unknown; + visitor?: unknown; +} diff --git a/src/api/resources/unstable/resources/visitors/client/requests/RetrieveVisitorWithUserIdRequest.ts b/src/api/resources/unstable/resources/visitors/client/requests/RetrieveVisitorWithUserIdRequest.ts new file mode 100644 index 00000000..27554599 --- /dev/null +++ b/src/api/resources/unstable/resources/visitors/client/requests/RetrieveVisitorWithUserIdRequest.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * @example + * { + * user_id: "user_id" + * } + */ +export interface RetrieveVisitorWithUserIdRequest { + /** + * The user_id of the Visitor you want to retrieve. + */ + user_id: string; +} diff --git a/src/api/resources/unstable/resources/visitors/client/requests/index.ts b/src/api/resources/unstable/resources/visitors/client/requests/index.ts new file mode 100644 index 00000000..8878667c --- /dev/null +++ b/src/api/resources/unstable/resources/visitors/client/requests/index.ts @@ -0,0 +1,2 @@ +export { type RetrieveVisitorWithUserIdRequest } from "./RetrieveVisitorWithUserIdRequest"; +export { type ConvertVisitorRequest } from "./ConvertVisitorRequest"; diff --git a/src/api/resources/unstable/resources/visitors/index.ts b/src/api/resources/unstable/resources/visitors/index.ts new file mode 100644 index 00000000..5ec76921 --- /dev/null +++ b/src/api/resources/unstable/resources/visitors/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/unstable/types/ActivityLog.ts b/src/api/resources/unstable/types/ActivityLog.ts new file mode 100644 index 00000000..1815ce24 --- /dev/null +++ b/src/api/resources/unstable/types/ActivityLog.ts @@ -0,0 +1,175 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * Activities performed by Admins. + */ +export interface ActivityLog { + /** The id representing the activity. */ + id?: string; + /** Details about the Admin involved in the activity. */ + performed_by?: ActivityLog.PerformedBy; + metadata?: Intercom.unstable.ActivityLogMetadata; + /** The time the activity was created. */ + created_at?: number; + activity_type?: ActivityLog.ActivityType; + /** A sentence or two describing the activity. */ + activity_description?: string; +} + +export namespace ActivityLog { + /** + * Details about the Admin involved in the activity. + */ + export interface PerformedBy { + /** String representing the object's type. Always has the value `admin`. */ + type?: string; + /** The id representing the admin. */ + id?: string; + /** The email of the admin. */ + email?: string; + /** The IP address of the admin. */ + ip?: string; + } + + export type ActivityType = + | "admin_assignment_limit_change" + | "admin_away_mode_change" + | "admin_deletion" + | "admin_deprovisioned" + | "admin_impersonation_end" + | "admin_impersonation_start" + | "admin_invite_change" + | "admin_invite_creation" + | "admin_invite_deletion" + | "admin_login_failure" + | "admin_login_success" + | "admin_logout" + | "admin_password_reset_request" + | "admin_password_reset_success" + | "admin_permission_change" + | "admin_provisioned" + | "admin_two_factor_auth_change" + | "admin_unauthorized_sign_in_method" + | "app_admin_join" + | "app_authentication_method_change" + | "app_data_deletion" + | "app_data_export" + | "app_google_sso_domain_change" + | "app_identity_verification_change" + | "app_name_change" + | "app_outbound_address_change" + | "app_package_installation" + | "app_package_token_regeneration" + | "app_package_uninstallation" + | "app_team_creation" + | "app_team_deletion" + | "app_team_membership_modification" + | "app_timezone_change" + | "app_webhook_creation" + | "app_webhook_deletion" + | "articles_in_messenger_enabled_change" + | "bulk_delete" + | "bulk_export" + | "campaign_deletion" + | "campaign_state_change" + | "conversation_part_deletion" + | "conversation_topic_change" + | "conversation_topic_creation" + | "conversation_topic_deletion" + | "help_center_settings_change" + | "inbound_conversations_change" + | "inbox_access_change" + | "message_deletion" + | "message_state_change" + | "messenger_look_and_feel_change" + | "messenger_search_required_change" + | "messenger_spaces_change" + | "office_hours_change" + | "role_change" + | "role_creation" + | "role_deletion" + | "ruleset_activation_title_preview" + | "ruleset_creation" + | "ruleset_deletion" + | "search_browse_enabled_change" + | "search_browse_required_change" + | "seat_change" + | "seat_revoke" + | "security_settings_change" + | "temporary_expectation_change" + | "upfront_email_collection_change" + | "welcome_message_change"; + export const ActivityType = { + AdminAssignmentLimitChange: "admin_assignment_limit_change", + AdminAwayModeChange: "admin_away_mode_change", + AdminDeletion: "admin_deletion", + AdminDeprovisioned: "admin_deprovisioned", + AdminImpersonationEnd: "admin_impersonation_end", + AdminImpersonationStart: "admin_impersonation_start", + AdminInviteChange: "admin_invite_change", + AdminInviteCreation: "admin_invite_creation", + AdminInviteDeletion: "admin_invite_deletion", + AdminLoginFailure: "admin_login_failure", + AdminLoginSuccess: "admin_login_success", + AdminLogout: "admin_logout", + AdminPasswordResetRequest: "admin_password_reset_request", + AdminPasswordResetSuccess: "admin_password_reset_success", + AdminPermissionChange: "admin_permission_change", + AdminProvisioned: "admin_provisioned", + AdminTwoFactorAuthChange: "admin_two_factor_auth_change", + AdminUnauthorizedSignInMethod: "admin_unauthorized_sign_in_method", + AppAdminJoin: "app_admin_join", + AppAuthenticationMethodChange: "app_authentication_method_change", + AppDataDeletion: "app_data_deletion", + AppDataExport: "app_data_export", + AppGoogleSsoDomainChange: "app_google_sso_domain_change", + AppIdentityVerificationChange: "app_identity_verification_change", + AppNameChange: "app_name_change", + AppOutboundAddressChange: "app_outbound_address_change", + AppPackageInstallation: "app_package_installation", + AppPackageTokenRegeneration: "app_package_token_regeneration", + AppPackageUninstallation: "app_package_uninstallation", + AppTeamCreation: "app_team_creation", + AppTeamDeletion: "app_team_deletion", + AppTeamMembershipModification: "app_team_membership_modification", + AppTimezoneChange: "app_timezone_change", + AppWebhookCreation: "app_webhook_creation", + AppWebhookDeletion: "app_webhook_deletion", + ArticlesInMessengerEnabledChange: "articles_in_messenger_enabled_change", + BulkDelete: "bulk_delete", + BulkExport: "bulk_export", + CampaignDeletion: "campaign_deletion", + CampaignStateChange: "campaign_state_change", + ConversationPartDeletion: "conversation_part_deletion", + ConversationTopicChange: "conversation_topic_change", + ConversationTopicCreation: "conversation_topic_creation", + ConversationTopicDeletion: "conversation_topic_deletion", + HelpCenterSettingsChange: "help_center_settings_change", + InboundConversationsChange: "inbound_conversations_change", + InboxAccessChange: "inbox_access_change", + MessageDeletion: "message_deletion", + MessageStateChange: "message_state_change", + MessengerLookAndFeelChange: "messenger_look_and_feel_change", + MessengerSearchRequiredChange: "messenger_search_required_change", + MessengerSpacesChange: "messenger_spaces_change", + OfficeHoursChange: "office_hours_change", + RoleChange: "role_change", + RoleCreation: "role_creation", + RoleDeletion: "role_deletion", + RulesetActivationTitlePreview: "ruleset_activation_title_preview", + RulesetCreation: "ruleset_creation", + RulesetDeletion: "ruleset_deletion", + SearchBrowseEnabledChange: "search_browse_enabled_change", + SearchBrowseRequiredChange: "search_browse_required_change", + SeatChange: "seat_change", + SeatRevoke: "seat_revoke", + SecuritySettingsChange: "security_settings_change", + TemporaryExpectationChange: "temporary_expectation_change", + UpfrontEmailCollectionChange: "upfront_email_collection_change", + WelcomeMessageChange: "welcome_message_change", + } as const; +} diff --git a/src/api/resources/unstable/types/ActivityLogList.ts b/src/api/resources/unstable/types/ActivityLogList.ts new file mode 100644 index 00000000..7c9d4e57 --- /dev/null +++ b/src/api/resources/unstable/types/ActivityLogList.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * A paginated list of activity logs. + */ +export interface ActivityLogList { + /** String representing the object's type. Always has the value `activity_log.list`. */ + type?: string; + pages?: Intercom.unstable.CursorPages; + /** An array of activity logs */ + activity_logs?: (Intercom.unstable.ActivityLog | undefined)[]; +} diff --git a/src/api/resources/unstable/types/ActivityLogMetadata.ts b/src/api/resources/unstable/types/ActivityLogMetadata.ts new file mode 100644 index 00000000..4814d8e5 --- /dev/null +++ b/src/api/resources/unstable/types/ActivityLogMetadata.ts @@ -0,0 +1,27 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Additional data provided about Admin activity. + */ +export interface ActivityLogMetadata { + /** The way the admin signed in. */ + sign_in_method?: string; + /** The unique identifier for the contact which is provided by the Client. */ + external_id?: string; + /** The away mode status which is set to true when away and false when returned. */ + away_mode?: boolean; + /** The reason the Admin is away. */ + away_status_reason?: string; + /** Indicates if conversations should be reassigned while an Admin is away. */ + reassign_conversations?: boolean; + /** The action that initiated the status change. */ + source?: string; + /** Indicates if the status was changed automatically or manually. */ + auto_changed?: string; + /** The ID of the Admin who initiated the activity. */ + update_by?: number; + /** The name of the Admin who initiated the activity. */ + update_by_name?: string; +} diff --git a/src/api/resources/unstable/types/AddressableList.ts b/src/api/resources/unstable/types/AddressableList.ts new file mode 100644 index 00000000..787be0f6 --- /dev/null +++ b/src/api/resources/unstable/types/AddressableList.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A list used to access other resources from a parent model. + */ +export interface AddressableList { + /** The addressable object type */ + type?: string; + /** The id of the addressable object */ + id?: string; + /** Url to get more company resources for this contact */ + url?: string; +} diff --git a/src/api/resources/unstable/types/AdminList.ts b/src/api/resources/unstable/types/AdminList.ts new file mode 100644 index 00000000..b5fc73d2 --- /dev/null +++ b/src/api/resources/unstable/types/AdminList.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * A list of admins associated with a given workspace. + */ +export interface AdminList { + /** String representing the object's type. Always has the value `admin.list`. */ + type?: string; + /** A list of admins associated with a given workspace. */ + admins?: (Intercom.unstable.Admin | undefined)[]; +} diff --git a/src/api/resources/unstable/types/AdminPriorityLevel.ts b/src/api/resources/unstable/types/AdminPriorityLevel.ts new file mode 100644 index 00000000..659f95f2 --- /dev/null +++ b/src/api/resources/unstable/types/AdminPriorityLevel.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Admin priority levels for the team + */ +export interface AdminPriorityLevel { + /** The primary admin ids for the team */ + primary_admin_ids?: number[]; + /** The secondary admin ids for the team */ + secondary_admin_ids?: number[]; +} diff --git a/src/api/resources/unstable/types/AdminReplyConversationRequest.ts b/src/api/resources/unstable/types/AdminReplyConversationRequest.ts new file mode 100644 index 00000000..b0bcb16c --- /dev/null +++ b/src/api/resources/unstable/types/AdminReplyConversationRequest.ts @@ -0,0 +1,34 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * Payload of the request to reply on behalf of an admin + */ +export interface AdminReplyConversationRequest { + message_type: AdminReplyConversationRequest.MessageType; + type: "admin"; + /** The text body of the reply. Notes accept some HTML formatting. Must be present for comment and note message types. */ + body?: string; + /** The id of the admin who is authoring the comment. */ + admin_id: string; + /** The time the reply was created. If not provided, the current time will be used. */ + created_at?: number; + /** The quick reply options to display to the end user. Must be present for quick_reply message types. */ + reply_options?: Intercom.unstable.QuickReplyOption[]; + /** A list of image URLs that will be added as attachments. You can include up to 10 URLs. */ + attachment_urls?: string[]; + /** A list of files that will be added as attachments. You can include up to 10 files */ + attachment_files?: Intercom.unstable.ConversationAttachmentFiles[]; +} + +export namespace AdminReplyConversationRequest { + export type MessageType = "comment" | "note" | "quick_reply"; + export const MessageType = { + Comment: "comment", + Note: "note", + QuickReply: "quick_reply", + } as const; +} diff --git a/src/api/resources/unstable/types/AdminReplyTicketRequest.ts b/src/api/resources/unstable/types/AdminReplyTicketRequest.ts new file mode 100644 index 00000000..dfc2ae57 --- /dev/null +++ b/src/api/resources/unstable/types/AdminReplyTicketRequest.ts @@ -0,0 +1,40 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Payload of the request to reply on behalf of an admin + */ +export interface AdminReplyTicketRequest { + message_type: AdminReplyTicketRequest.MessageType; + type: "admin"; + /** The text body of the reply. Notes accept some HTML formatting. Must be present for comment and note message types. */ + body?: string; + /** The id of the admin who is authoring the comment. */ + admin_id: string; + /** The time the reply was created. If not provided, the current time will be used. */ + created_at?: number; + /** The quick reply options to display. Must be present for quick_reply message types. */ + reply_options?: AdminReplyTicketRequest.ReplyOptions.Item[]; + /** A list of image URLs that will be added as attachments. You can include up to 10 URLs. */ + attachment_urls?: string[]; +} + +export namespace AdminReplyTicketRequest { + export type MessageType = "comment" | "note" | "quick_reply"; + export const MessageType = { + Comment: "comment", + Note: "note", + QuickReply: "quick_reply", + } as const; + export type ReplyOptions = ReplyOptions.Item[]; + + export namespace ReplyOptions { + export interface Item { + /** The text to display in this quick reply option. */ + text: string; + /** A unique identifier for this quick reply option. This value will be available within the metadata of the comment ticket part that is created when a user clicks on this reply option. */ + uuid: string; + } + } +} diff --git a/src/api/resources/unstable/types/AdminWithApp.ts b/src/api/resources/unstable/types/AdminWithApp.ts new file mode 100644 index 00000000..4d7f69ed --- /dev/null +++ b/src/api/resources/unstable/types/AdminWithApp.ts @@ -0,0 +1,47 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * Admins are the teammate accounts that have access to a workspace + */ +export interface AdminWithApp { + /** String representing the object's type. Always has the value `admin`. */ + type?: string; + /** The id representing the admin. */ + id?: string; + /** The name of the admin. */ + name?: string; + /** The email of the admin. */ + email?: string; + /** The job title of the admin. */ + job_title?: string; + /** Identifies if this admin is currently set in away mode. */ + away_mode_enabled?: boolean; + /** Identifies if this admin is set to automatically reassign new conversations to the apps default inbox. */ + away_mode_reassign?: boolean; + /** Identifies if this admin has a paid inbox seat to restrict/allow features that require them. */ + has_inbox_seat?: boolean; + /** This is a list of ids of the teams that this admin is part of. */ + team_ids?: number[]; + /** This object represents the avatar associated with the admin. */ + avatar?: AdminWithApp.Avatar; + /** Identifies if this admin's email is verified. */ + email_verified?: boolean; + /** App that the admin belongs to. */ + app?: Intercom.unstable.App; +} + +export namespace AdminWithApp { + /** + * This object represents the avatar associated with the admin. + */ + export interface Avatar { + /** This is a string that identifies the type of the object. It will always have the value `avatar`. */ + type?: string; + /** This object represents the avatar associated with the admin. */ + image_url?: string; + } +} diff --git a/src/api/resources/unstable/types/App.ts b/src/api/resources/unstable/types/App.ts new file mode 100644 index 00000000..fd2d8319 --- /dev/null +++ b/src/api/resources/unstable/types/App.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * App is a workspace on Intercom + */ +export interface App { + /** */ + type?: string; + /** The id of the app. */ + id_code?: string; + /** The name of the app. */ + name?: string; + /** The Intercom region the app is located in. */ + region?: string; + /** The timezone of the region where the app is located. */ + timezone?: string; + /** When the app was created. */ + created_at?: number; + /** Whether or not the app uses identity verification. */ + identity_verification?: boolean; +} diff --git a/src/api/resources/unstable/types/ArticleContent.ts b/src/api/resources/unstable/types/ArticleContent.ts new file mode 100644 index 00000000..31652500 --- /dev/null +++ b/src/api/resources/unstable/types/ArticleContent.ts @@ -0,0 +1,38 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The Content of an Article. + */ +export interface ArticleContent { + /** The type of object - `article_content` . */ + type?: string; + /** The title of the article. */ + title?: string; + /** The description of the article. */ + description?: string; + /** The body of the article. */ + body?: string; + /** The ID of the author of the article. */ + author_id?: number; + /** Whether the article is `published` or is a `draft` . */ + state?: ArticleContent.State; + /** The time when the article was created (seconds). */ + created_at?: number; + /** The time when the article was last updated (seconds). */ + updated_at?: number; + /** The URL of the article. */ + url?: string; +} + +export namespace ArticleContent { + /** + * Whether the article is `published` or is a `draft` . + */ + export type State = "published" | "draft"; + export const State = { + Published: "published", + Draft: "draft", + } as const; +} diff --git a/src/api/resources/unstable/types/ArticleList.ts b/src/api/resources/unstable/types/ArticleList.ts new file mode 100644 index 00000000..5dbc0a01 --- /dev/null +++ b/src/api/resources/unstable/types/ArticleList.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * This will return a list of articles for the App. + */ +export interface ArticleList { + /** The type of the object - `list`. */ + type?: "list"; + pages?: Intercom.unstable.CursorPages; + /** A count of the total number of articles. */ + total_count?: number; + /** An array of Article objects */ + data?: Intercom.unstable.ArticleListItem[]; +} diff --git a/src/api/resources/unstable/types/ArticleStatistics.ts b/src/api/resources/unstable/types/ArticleStatistics.ts new file mode 100644 index 00000000..2e12b7b3 --- /dev/null +++ b/src/api/resources/unstable/types/ArticleStatistics.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The statistics of an article. + */ +export interface ArticleStatistics { + /** The type of object - `article_statistics`. */ + type?: "article_statistics"; + /** The number of total views the article has received. */ + views?: number; + /** The number of conversations started from the article. */ + conversions?: number; + /** The number of total reactions the article has received. */ + reactions?: number; + /** The percentage of happy reactions the article has received against other types of reaction. */ + happy_reaction_percentage?: number; + /** The percentage of neutral reactions the article has received against other types of reaction. */ + neutral_reaction_percentage?: number; + /** The percentage of sad reactions the article has received against other types of reaction. */ + sad_reaction_percentage?: number; +} diff --git a/src/api/resources/unstable/types/ArticleTranslatedContent.ts b/src/api/resources/unstable/types/ArticleTranslatedContent.ts new file mode 100644 index 00000000..5e4e52bd --- /dev/null +++ b/src/api/resources/unstable/types/ArticleTranslatedContent.ts @@ -0,0 +1,87 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * The Translated Content of an Article. The keys are the locale codes and the values are the translated content of the article. + */ +export interface ArticleTranslatedContent { + /** The type of object - article_translated_content. */ + type?: string; + /** The content of the article in Arabic */ + ar?: Intercom.unstable.ArticleContent; + /** The content of the article in Bulgarian */ + bg?: Intercom.unstable.ArticleContent; + /** The content of the article in Bosnian */ + bs?: Intercom.unstable.ArticleContent; + /** The content of the article in Catalan */ + ca?: Intercom.unstable.ArticleContent; + /** The content of the article in Czech */ + cs?: Intercom.unstable.ArticleContent; + /** The content of the article in Danish */ + da?: Intercom.unstable.ArticleContent; + /** The content of the article in German */ + de?: Intercom.unstable.ArticleContent; + /** The content of the article in Greek */ + el?: Intercom.unstable.ArticleContent; + /** The content of the article in English */ + en?: Intercom.unstable.ArticleContent; + /** The content of the article in Spanish */ + es?: Intercom.unstable.ArticleContent; + /** The content of the article in Estonian */ + et?: Intercom.unstable.ArticleContent; + /** The content of the article in Finnish */ + fi?: Intercom.unstable.ArticleContent; + /** The content of the article in French */ + fr?: Intercom.unstable.ArticleContent; + /** The content of the article in Hebrew */ + he?: Intercom.unstable.ArticleContent; + /** The content of the article in Croatian */ + hr?: Intercom.unstable.ArticleContent; + /** The content of the article in Hungarian */ + hu?: Intercom.unstable.ArticleContent; + /** The content of the article in Indonesian */ + id?: Intercom.unstable.ArticleContent; + /** The content of the article in Italian */ + it?: Intercom.unstable.ArticleContent; + /** The content of the article in Japanese */ + ja?: Intercom.unstable.ArticleContent; + /** The content of the article in Korean */ + ko?: Intercom.unstable.ArticleContent; + /** The content of the article in Lithuanian */ + lt?: Intercom.unstable.ArticleContent; + /** The content of the article in Latvian */ + lv?: Intercom.unstable.ArticleContent; + /** The content of the article in Mongolian */ + mn?: Intercom.unstable.ArticleContent; + /** The content of the article in Norwegian */ + nb?: Intercom.unstable.ArticleContent; + /** The content of the article in Dutch */ + nl?: Intercom.unstable.ArticleContent; + /** The content of the article in Polish */ + pl?: Intercom.unstable.ArticleContent; + /** The content of the article in Portuguese (Portugal) */ + pt?: Intercom.unstable.ArticleContent; + /** The content of the article in Romanian */ + ro?: Intercom.unstable.ArticleContent; + /** The content of the article in Russian */ + ru?: Intercom.unstable.ArticleContent; + /** The content of the article in Slovenian */ + sl?: Intercom.unstable.ArticleContent; + /** The content of the article in Serbian */ + sr?: Intercom.unstable.ArticleContent; + /** The content of the article in Swedish */ + sv?: Intercom.unstable.ArticleContent; + /** The content of the article in Turkish */ + tr?: Intercom.unstable.ArticleContent; + /** The content of the article in Vietnamese */ + vi?: Intercom.unstable.ArticleContent; + /** The content of the article in Portuguese (Brazil) */ + "pt-BR"?: Intercom.unstable.ArticleContent; + /** The content of the article in Chinese (China) */ + "zh-CN"?: Intercom.unstable.ArticleContent; + /** The content of the article in Chinese (Taiwan) */ + "zh-TW"?: Intercom.unstable.ArticleContent; +} diff --git a/src/api/resources/unstable/types/AssignConversationRequest.ts b/src/api/resources/unstable/types/AssignConversationRequest.ts new file mode 100644 index 00000000..e3eef208 --- /dev/null +++ b/src/api/resources/unstable/types/AssignConversationRequest.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Payload of the request to assign a conversation + */ +export interface AssignConversationRequest { + type: AssignConversationRequest.Type; + /** The id of the admin who is performing the action. */ + admin_id: string; + /** The `id` of the `admin` or `team` which will be assigned the conversation. A conversation can be assigned both an admin and a team.\nSet `0` if you want this assign to no admin or team (ie. Unassigned). */ + assignee_id: string; + /** Optionally you can send a response in the conversation when it is assigned. */ + body?: string; +} + +export namespace AssignConversationRequest { + export type Type = "admin" | "team"; + export const Type = { + Admin: "admin", + Team: "team", + } as const; +} diff --git a/src/api/resources/unstable/types/AwayStatusReason.ts b/src/api/resources/unstable/types/AwayStatusReason.ts new file mode 100644 index 00000000..02f9e7a8 --- /dev/null +++ b/src/api/resources/unstable/types/AwayStatusReason.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface AwayStatusReason { + type?: string; + /** The unique identifier for the away status reason */ + id?: string; + /** The display text for the away status reason */ + label?: string; + /** The emoji associated with the status reason */ + emoji?: string; + /** The display order of the status reason */ + order?: number; + /** Whether the status reason has been soft deleted */ + deleted?: boolean; + /** The Unix timestamp when the status reason was created */ + created_at?: number; + /** The Unix timestamp when the status reason was last updated */ + updated_at?: number; +} diff --git a/src/api/resources/unstable/types/CloseConversationRequest.ts b/src/api/resources/unstable/types/CloseConversationRequest.ts new file mode 100644 index 00000000..56f0755e --- /dev/null +++ b/src/api/resources/unstable/types/CloseConversationRequest.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Payload of the request to close a conversation + */ +export interface CloseConversationRequest { + type: "admin"; + /** The id of the admin who is performing the action. */ + admin_id: string; + /** Optionally you can leave a message in the conversation to provide additional context to the user and other teammates. */ + body?: string; +} diff --git a/src/api/resources/unstable/types/CollectionList.ts b/src/api/resources/unstable/types/CollectionList.ts new file mode 100644 index 00000000..ee2bbe53 --- /dev/null +++ b/src/api/resources/unstable/types/CollectionList.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * This will return a list of Collections for the App. + */ +export interface CollectionList { + /** The type of the object - `list`. */ + type?: "list"; + pages?: Intercom.unstable.CursorPages; + /** A count of the total number of collections. */ + total_count?: number; + /** An array of collection objects */ + data?: Intercom.unstable.Collection[]; +} diff --git a/src/api/resources/unstable/types/CompanyAttachedContacts.ts b/src/api/resources/unstable/types/CompanyAttachedContacts.ts new file mode 100644 index 00000000..c4490d96 --- /dev/null +++ b/src/api/resources/unstable/types/CompanyAttachedContacts.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * A list of Contact Objects + */ +export interface CompanyAttachedContacts { + /** The type of object - `list` */ + type?: "list"; + /** An array containing Contact Objects */ + data?: Intercom.unstable.Contact[]; + /** The total number of contacts */ + total_count?: number; + pages?: Intercom.unstable.CursorPages; +} diff --git a/src/api/resources/unstable/types/CompanyAttachedSegments.ts b/src/api/resources/unstable/types/CompanyAttachedSegments.ts new file mode 100644 index 00000000..b7c72a13 --- /dev/null +++ b/src/api/resources/unstable/types/CompanyAttachedSegments.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * A list of Segment Objects + */ +export interface CompanyAttachedSegments { + /** The type of object - `list` */ + type?: "list"; + /** An array containing Segment Objects */ + data?: Intercom.unstable.Segment[]; +} diff --git a/src/api/resources/unstable/types/CompanyData.ts b/src/api/resources/unstable/types/CompanyData.ts new file mode 100644 index 00000000..de38845a --- /dev/null +++ b/src/api/resources/unstable/types/CompanyData.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * An object containing data about the companies that a contact is associated with. + */ +export interface CompanyData { + /** The unique identifier for the company which is given by Intercom. */ + id?: string; + /** The type of the object. Always company. */ + type?: "company"; + /** The relative URL of the company. */ + url?: string; +} diff --git a/src/api/resources/unstable/types/CompanyList.ts b/src/api/resources/unstable/types/CompanyList.ts new file mode 100644 index 00000000..af078812 --- /dev/null +++ b/src/api/resources/unstable/types/CompanyList.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * This will return a list of companies for the App. + */ +export interface CompanyList { + /** The type of object - `list`. */ + type?: "list"; + pages?: Intercom.unstable.CursorPages; + /** The total number of companies. */ + total_count?: number; + /** An array containing Company Objects. */ + data?: Intercom.unstable.Company[]; +} diff --git a/src/api/resources/unstable/types/CompanyScroll.ts b/src/api/resources/unstable/types/CompanyScroll.ts new file mode 100644 index 00000000..95030bb2 --- /dev/null +++ b/src/api/resources/unstable/types/CompanyScroll.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * Companies allow you to represent organizations using your product. Each company will have its own description and be associated with contacts. You can fetch, create, update and list companies. + */ +export interface CompanyScroll { + /** The type of object - `list` */ + type?: "list"; + data?: Intercom.unstable.Company[]; + pages?: Intercom.unstable.CursorPages; + /** The total number of companies */ + total_count?: number; + /** The scroll parameter to use in the next request to fetch the next page of results. */ + scroll_param?: string; +} diff --git a/src/api/resources/unstable/types/ContactArchived.ts b/src/api/resources/unstable/types/ContactArchived.ts new file mode 100644 index 00000000..9a5527f7 --- /dev/null +++ b/src/api/resources/unstable/types/ContactArchived.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * archived contact object + */ +export interface ContactArchived extends Intercom.unstable.ContactReference { + /** Whether the contact is archived or not. */ + archived?: boolean; +} diff --git a/src/api/resources/unstable/types/ContactAttachedCompanies.ts b/src/api/resources/unstable/types/ContactAttachedCompanies.ts new file mode 100644 index 00000000..d4a80f8f --- /dev/null +++ b/src/api/resources/unstable/types/ContactAttachedCompanies.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * A list of Company Objects + */ +export interface ContactAttachedCompanies { + /** The type of object */ + type?: "list"; + /** An array containing Company Objects */ + companies?: Intercom.unstable.Company[]; + /** The total number of companies associated to this contact */ + total_count?: number; + pages?: Intercom.unstable.PagesLink; +} diff --git a/src/api/resources/unstable/types/ContactBlocked.ts b/src/api/resources/unstable/types/ContactBlocked.ts new file mode 100644 index 00000000..203b8792 --- /dev/null +++ b/src/api/resources/unstable/types/ContactBlocked.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * blocked contact object + */ +export interface ContactBlocked extends Intercom.unstable.ContactReference { + /** Always true. */ + blocked?: boolean; +} diff --git a/src/api/resources/unstable/types/ContactCompanies.ts b/src/api/resources/unstable/types/ContactCompanies.ts new file mode 100644 index 00000000..a827865a --- /dev/null +++ b/src/api/resources/unstable/types/ContactCompanies.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * An object with metadata about companies attached to a contact . Up to 10 will be displayed here. Use the url to get more. + */ +export interface ContactCompanies { + /** An array of company data objects attached to the contact. */ + data?: Intercom.unstable.CompanyData[]; + /** Url to get more company resources for this contact */ + url?: string; + /** Integer representing the total number of companies attached to this contact */ + total_count?: number; + /** Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ + has_more?: boolean; +} diff --git a/src/api/resources/unstable/types/ContactDeleted.ts b/src/api/resources/unstable/types/ContactDeleted.ts new file mode 100644 index 00000000..38fc4950 --- /dev/null +++ b/src/api/resources/unstable/types/ContactDeleted.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * deleted contact object + */ +export interface ContactDeleted extends Intercom.unstable.ContactReference { + /** Whether the contact is deleted or not. */ + deleted?: boolean; +} diff --git a/src/api/resources/unstable/types/ContactList.ts b/src/api/resources/unstable/types/ContactList.ts new file mode 100644 index 00000000..51a0df3c --- /dev/null +++ b/src/api/resources/unstable/types/ContactList.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * Contacts are your users in Intercom. + */ +export interface ContactList { + /** Always list */ + type?: "list"; + /** The list of contact objects */ + data?: Intercom.unstable.Contact[]; + /** A count of the total number of objects. */ + total_count?: number; + pages?: Intercom.unstable.CursorPages; +} diff --git a/src/api/resources/unstable/types/ContactLocation.ts b/src/api/resources/unstable/types/ContactLocation.ts new file mode 100644 index 00000000..6f3ca2ec --- /dev/null +++ b/src/api/resources/unstable/types/ContactLocation.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * An object containing location meta data about a Intercom contact. + */ +export interface ContactLocation { + /** Always location */ + type?: string; + /** The country that the contact is located in */ + country?: string; + /** The overal region that the contact is located in */ + region?: string; + /** The city that the contact is located in */ + city?: string; +} diff --git a/src/api/resources/unstable/types/ContactNotes.ts b/src/api/resources/unstable/types/ContactNotes.ts new file mode 100644 index 00000000..fe835d12 --- /dev/null +++ b/src/api/resources/unstable/types/ContactNotes.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * An object containing notes meta data about the notes that a contact has. Up to 10 will be displayed here. Use the url to get more. + */ +export interface ContactNotes { + /** This object represents the notes attached to a contact. */ + data?: Intercom.unstable.AddressableList[]; + /** Url to get more company resources for this contact */ + url?: string; + /** Int representing the total number of companyies attached to this contact */ + total_count?: number; + /** Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ + has_more?: boolean; +} diff --git a/src/api/resources/unstable/types/ContactReference.ts b/src/api/resources/unstable/types/ContactReference.ts new file mode 100644 index 00000000..d202aadc --- /dev/null +++ b/src/api/resources/unstable/types/ContactReference.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * reference to contact object + */ +export interface ContactReference { + /** always contact */ + type?: "contact"; + /** The unique identifier for the contact which is given by Intercom. */ + id?: string; + /** The unique identifier for the contact which is provided by the Client. */ + external_id?: string; +} diff --git a/src/api/resources/unstable/types/ContactReplyBaseRequest.ts b/src/api/resources/unstable/types/ContactReplyBaseRequest.ts new file mode 100644 index 00000000..0559f83e --- /dev/null +++ b/src/api/resources/unstable/types/ContactReplyBaseRequest.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface ContactReplyBaseRequest { + message_type: "comment"; + type: "user"; + /** The text body of the comment. */ + body: string; + /** The time the reply was created. If not provided, the current time will be used. */ + created_at?: number; + /** A list of image URLs that will be added as attachments. You can include up to 10 URLs. */ + attachment_urls?: string[]; + /** The quick reply selection the contact wishes to respond with. These map to buttons displayed in the Messenger UI if sent by a bot, or the reply options sent by an Admin via the API. */ + reply_options?: ContactReplyBaseRequest.ReplyOptions.Item[]; +} + +export namespace ContactReplyBaseRequest { + export type ReplyOptions = ReplyOptions.Item[]; + + export namespace ReplyOptions { + export interface Item { + /** The text of the chosen reply option. */ + text: string; + /** The unique identifier for the quick reply option selected. */ + uuid: string; + } + } +} diff --git a/src/api/resources/unstable/types/ContactReplyConversationRequest.ts b/src/api/resources/unstable/types/ContactReplyConversationRequest.ts new file mode 100644 index 00000000..74fe2c40 --- /dev/null +++ b/src/api/resources/unstable/types/ContactReplyConversationRequest.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +export type ContactReplyConversationRequest = + | Intercom.unstable.ContactReplyIntercomUserIdRequest + | Intercom.unstable.ContactReplyEmailRequest + | Intercom.unstable.ContactReplyUserIdRequest; diff --git a/src/api/resources/unstable/types/ContactReplyEmailRequest.ts b/src/api/resources/unstable/types/ContactReplyEmailRequest.ts new file mode 100644 index 00000000..f00aaaec --- /dev/null +++ b/src/api/resources/unstable/types/ContactReplyEmailRequest.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * Payload of the request to reply on behalf of a contact using their `email` + */ +export interface ContactReplyEmailRequest extends Intercom.unstable.ContactReplyBaseRequest { + /** The email you have defined for the user. */ + email: string; + /** A list of files that will be added as attachments. */ + attachment_files?: Intercom.unstable.ConversationAttachmentFiles[]; +} diff --git a/src/api/resources/unstable/types/ContactReplyIntercomUserIdRequest.ts b/src/api/resources/unstable/types/ContactReplyIntercomUserIdRequest.ts new file mode 100644 index 00000000..0b6e3424 --- /dev/null +++ b/src/api/resources/unstable/types/ContactReplyIntercomUserIdRequest.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * Payload of the request to reply on behalf of a contact using their `intercom_user_id` + */ +export interface ContactReplyIntercomUserIdRequest extends Intercom.unstable.ContactReplyBaseRequest { + /** The identifier for the contact as given by Intercom. */ + intercom_user_id: string; + /** A list of files that will be added as attachments. */ + attachment_files?: Intercom.unstable.ConversationAttachmentFiles[]; +} diff --git a/src/api/resources/unstable/types/ContactReplyTicketEmailRequest.ts b/src/api/resources/unstable/types/ContactReplyTicketEmailRequest.ts new file mode 100644 index 00000000..b66e60dd --- /dev/null +++ b/src/api/resources/unstable/types/ContactReplyTicketEmailRequest.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * Payload of the request to reply on behalf of a contact using their `email` + */ +export interface ContactReplyTicketEmailRequest extends Intercom.unstable.ContactReplyBaseRequest { + /** The email you have defined for the user. */ + email: string; +} diff --git a/src/api/resources/unstable/types/ContactReplyTicketIntercomUserIdRequest.ts b/src/api/resources/unstable/types/ContactReplyTicketIntercomUserIdRequest.ts new file mode 100644 index 00000000..fd94eb7f --- /dev/null +++ b/src/api/resources/unstable/types/ContactReplyTicketIntercomUserIdRequest.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * Payload of the request to reply on behalf of a contact using their `intercom_user_id` + */ +export interface ContactReplyTicketIntercomUserIdRequest extends Intercom.unstable.ContactReplyBaseRequest { + /** The identifier for the contact as given by Intercom. */ + intercom_user_id: string; +} diff --git a/src/api/resources/unstable/types/ContactReplyTicketRequest.ts b/src/api/resources/unstable/types/ContactReplyTicketRequest.ts new file mode 100644 index 00000000..c83977cc --- /dev/null +++ b/src/api/resources/unstable/types/ContactReplyTicketRequest.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +export type ContactReplyTicketRequest = + | Intercom.unstable.ContactReplyTicketIntercomUserIdRequest + | Intercom.unstable.ContactReplyTicketUserIdRequest + | Intercom.unstable.ContactReplyTicketEmailRequest; diff --git a/src/api/resources/unstable/types/ContactReplyTicketUserIdRequest.ts b/src/api/resources/unstable/types/ContactReplyTicketUserIdRequest.ts new file mode 100644 index 00000000..5a6d2796 --- /dev/null +++ b/src/api/resources/unstable/types/ContactReplyTicketUserIdRequest.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * Payload of the request to reply on behalf of a contact using their `user_id` + */ +export interface ContactReplyTicketUserIdRequest extends Intercom.unstable.ContactReplyBaseRequest { + /** The external_id you have defined for the contact. */ + user_id: string; +} diff --git a/src/api/resources/unstable/types/ContactReplyUserIdRequest.ts b/src/api/resources/unstable/types/ContactReplyUserIdRequest.ts new file mode 100644 index 00000000..b7e32da0 --- /dev/null +++ b/src/api/resources/unstable/types/ContactReplyUserIdRequest.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * Payload of the request to reply on behalf of a contact using their `user_id` + */ +export interface ContactReplyUserIdRequest extends Intercom.unstable.ContactReplyBaseRequest { + /** The external_id you have defined for the contact. */ + user_id: string; + /** A list of files that will be added as attachments. You can include up to 10 files. */ + attachment_files?: Intercom.unstable.ConversationAttachmentFiles[]; +} diff --git a/src/api/resources/unstable/types/ContactSegments.ts b/src/api/resources/unstable/types/ContactSegments.ts new file mode 100644 index 00000000..21a83fec --- /dev/null +++ b/src/api/resources/unstable/types/ContactSegments.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * A list of segments objects attached to a specific contact. + */ +export interface ContactSegments { + /** The type of the object */ + type?: "list"; + /** Segment objects associated with the contact. */ + data?: Intercom.unstable.Segment[]; +} diff --git a/src/api/resources/unstable/types/ContactSocialProfiles.ts b/src/api/resources/unstable/types/ContactSocialProfiles.ts new file mode 100644 index 00000000..32b4dfde --- /dev/null +++ b/src/api/resources/unstable/types/ContactSocialProfiles.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * An object containing social profiles that a contact has. + */ +export interface ContactSocialProfiles { + /** A list of social profiles objects associated with the contact. */ + data?: Intercom.unstable.SocialProfile[]; +} diff --git a/src/api/resources/unstable/types/ContactSubscriptionTypes.ts b/src/api/resources/unstable/types/ContactSubscriptionTypes.ts new file mode 100644 index 00000000..fc133189 --- /dev/null +++ b/src/api/resources/unstable/types/ContactSubscriptionTypes.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * An object containing Subscription Types meta data about the SubscriptionTypes that a contact has. + */ +export interface ContactSubscriptionTypes { + /** This object represents the subscriptions attached to a contact. */ + data?: Intercom.unstable.AddressableList[]; + /** Url to get more subscription type resources for this contact */ + url?: string; + /** Int representing the total number of subscription types attached to this contact */ + total_count?: number; + /** Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ + has_more?: boolean; +} diff --git a/src/api/resources/unstable/types/ContactTags.ts b/src/api/resources/unstable/types/ContactTags.ts new file mode 100644 index 00000000..c7bc0e62 --- /dev/null +++ b/src/api/resources/unstable/types/ContactTags.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * An object containing tags meta data about the tags that a contact has. Up to 10 will be displayed here. Use the url to get more. + */ +export interface ContactTags { + /** This object represents the tags attached to a contact. */ + data?: Intercom.unstable.AddressableList[]; + /** url to get more tag resources for this contact */ + url?: string; + /** Int representing the total number of tags attached to this contact */ + total_count?: number; + /** Whether there's more Addressable Objects to be viewed. If true, use the url to view all */ + has_more?: boolean; +} diff --git a/src/api/resources/unstable/types/ContactUnarchived.ts b/src/api/resources/unstable/types/ContactUnarchived.ts new file mode 100644 index 00000000..38322437 --- /dev/null +++ b/src/api/resources/unstable/types/ContactUnarchived.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * unarchived contact object + */ +export interface ContactUnarchived extends Intercom.unstable.ContactReference { + /** Whether the contact is archived or not. */ + archived?: boolean; +} diff --git a/src/api/resources/unstable/types/ContentSourcesList.ts b/src/api/resources/unstable/types/ContentSourcesList.ts new file mode 100644 index 00000000..9250df9d --- /dev/null +++ b/src/api/resources/unstable/types/ContentSourcesList.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +export interface ContentSourcesList { + type?: "content_source.list"; + /** The total number of content sources used by AI Agent in the conversation. */ + total_count?: number; + /** The content sources used by AI Agent in the conversation. */ + content_sources?: Intercom.unstable.ContentSource[]; +} diff --git a/src/api/resources/unstable/types/ConversationAttachmentFiles.ts b/src/api/resources/unstable/types/ConversationAttachmentFiles.ts new file mode 100644 index 00000000..98d751b4 --- /dev/null +++ b/src/api/resources/unstable/types/ConversationAttachmentFiles.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Properties of the attachment files in a conversation part + */ +export interface ConversationAttachmentFiles { + /** The content type of the file */ + content_type?: string; + /** The base64 encoded file data. */ + data?: string; + /** The name of the file. */ + name?: string; +} diff --git a/src/api/resources/unstable/types/ConversationAttributeUpdatedByAdmin.ts b/src/api/resources/unstable/types/ConversationAttributeUpdatedByAdmin.ts new file mode 100644 index 00000000..1c49cecf --- /dev/null +++ b/src/api/resources/unstable/types/ConversationAttributeUpdatedByAdmin.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Contains details about Custom Data Attributes (CDAs) that were modified by an admin (operator) for conversation part type conversation_attribute_updated_by_admin. + */ +export interface ConversationAttributeUpdatedByAdmin { + attribute?: ConversationAttributeUpdatedByAdmin.Attribute; + value?: ConversationAttributeUpdatedByAdmin.Value; +} + +export namespace ConversationAttributeUpdatedByAdmin { + export interface Attribute { + /** Name of the CDA updated */ + name?: string; + } + + export interface Value { + /** Value of the CDA updated */ + name?: string; + } +} diff --git a/src/api/resources/unstable/types/ConversationAttributeUpdatedByWorkflow.ts b/src/api/resources/unstable/types/ConversationAttributeUpdatedByWorkflow.ts new file mode 100644 index 00000000..65572650 --- /dev/null +++ b/src/api/resources/unstable/types/ConversationAttributeUpdatedByWorkflow.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Contains details about the workflow that was triggered and any Custom Data Attributes (CDAs) that were modified during the workflow execution for conversation part type conversation_attribute_updated_by_workflow. + */ +export interface ConversationAttributeUpdatedByWorkflow { + workflow?: ConversationAttributeUpdatedByWorkflow.Workflow; + attribute?: ConversationAttributeUpdatedByWorkflow.Attribute; + value?: ConversationAttributeUpdatedByWorkflow.Value; +} + +export namespace ConversationAttributeUpdatedByWorkflow { + export interface Workflow { + /** Name of the workflow */ + name?: string; + } + + export interface Attribute { + /** Name of the CDA updated */ + name?: string; + } + + export interface Value { + /** Value of the CDA updated */ + name?: string; + } +} diff --git a/src/api/resources/unstable/types/ConversationContacts.ts b/src/api/resources/unstable/types/ConversationContacts.ts new file mode 100644 index 00000000..c9818ad5 --- /dev/null +++ b/src/api/resources/unstable/types/ConversationContacts.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * The list of contacts (users or leads) involved in this conversation. This will only contain one customer unless more were added via the group conversation feature. + */ +export interface ConversationContacts { + /** */ + type?: "contact.list"; + /** The list of contacts (users or leads) involved in this conversation. This will only contain one customer unless more were added via the group conversation feature. */ + contacts?: Intercom.unstable.ContactReference[]; +} diff --git a/src/api/resources/unstable/types/ConversationDeleted.ts b/src/api/resources/unstable/types/ConversationDeleted.ts new file mode 100644 index 00000000..c45bc58f --- /dev/null +++ b/src/api/resources/unstable/types/ConversationDeleted.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * deleted conversation object + */ +export interface ConversationDeleted { + /** The unique identifier for the conversation. */ + id?: string; + /** always conversation */ + object?: "conversation"; + /** Whether the conversation is deleted or not. */ + deleted?: boolean; +} diff --git a/src/api/resources/unstable/types/ConversationFirstContactReply.ts b/src/api/resources/unstable/types/ConversationFirstContactReply.ts new file mode 100644 index 00000000..7d859b74 --- /dev/null +++ b/src/api/resources/unstable/types/ConversationFirstContactReply.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * An object containing information on the first users message. For a contact initiated message this will represent the users original message. + */ +export interface ConversationFirstContactReply { + /** */ + created_at?: number; + /** */ + type?: string; + /** */ + url?: string; +} diff --git a/src/api/resources/unstable/types/ConversationList.ts b/src/api/resources/unstable/types/ConversationList.ts new file mode 100644 index 00000000..402dae67 --- /dev/null +++ b/src/api/resources/unstable/types/ConversationList.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * Conversations are how you can communicate with users in Intercom. They are created when a contact replies to an outbound message, or when one admin directly sends a message to a single contact. + */ +export interface ConversationList { + /** Always conversation.list */ + type?: "conversation.list"; + /** The list of conversation objects */ + conversations?: Intercom.unstable.Conversation[]; + /** A count of the total number of objects. */ + total_count?: number; + pages?: Intercom.unstable.CursorPages; +} diff --git a/src/api/resources/unstable/types/ConversationPart.ts b/src/api/resources/unstable/types/ConversationPart.ts new file mode 100644 index 00000000..e724eb88 --- /dev/null +++ b/src/api/resources/unstable/types/ConversationPart.ts @@ -0,0 +1,55 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * A Conversation Part represents a message in the conversation. + */ +export interface ConversationPart { + /** Always conversation_part */ + type?: string; + /** The id representing the conversation part. */ + id?: string; + /** The type of conversation part. */ + part_type?: string; + /** The message body, which may contain HTML. For Twitter, this will show a generic message regarding why the body is obscured. */ + body?: string; + /** The time the conversation part was created. */ + created_at?: number; + /** The last time the conversation part was updated. */ + updated_at?: number; + /** The time the user was notified with the conversation part. */ + notified_at?: number; + /** The id of the admin that was assigned the conversation by this conversation_part (null if there has been no change in assignment.) */ + assigned_to?: Intercom.unstable.Reference; + author?: Intercom.unstable.ConversationPartAuthor; + /** A list of attachments for the part. */ + attachments?: Intercom.unstable.PartAttachment[]; + /** The external id of the conversation part */ + external_id?: string; + /** Whether or not the conversation part has been redacted. */ + redacted?: boolean; + email_message_metadata?: Intercom.unstable.EmailMessageMetadata; + metadata?: Intercom.unstable.ConversationPartMetadata; + /** Indicates the current state of conversation when the conversation part was created. */ + state?: ConversationPart.State; + /** A list of tags objects associated with the conversation part. */ + tags?: Intercom.unstable.TagBasic[]; + event_details?: Intercom.unstable.EventDetails; + /** The app package code if this part was created via API. null if the part was not created via API. */ + app_package_code?: string; +} + +export namespace ConversationPart { + /** + * Indicates the current state of conversation when the conversation part was created. + */ + export type State = "open" | "closed" | "snoozed"; + export const State = { + Open: "open", + Closed: "closed", + Snoozed: "snoozed", + } as const; +} diff --git a/src/api/resources/unstable/types/ConversationPartAuthor.ts b/src/api/resources/unstable/types/ConversationPartAuthor.ts new file mode 100644 index 00000000..01a62b9f --- /dev/null +++ b/src/api/resources/unstable/types/ConversationPartAuthor.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The object who initiated the conversation, which can be a Contact, Admin or Team. Bots and campaigns send messages on behalf of Admins or Teams. For Twitter, this will be blank. + */ +export interface ConversationPartAuthor { + /** The type of the author */ + type?: string; + /** The id of the author */ + id?: string; + /** The name of the author */ + name?: string; + /** The email of the author */ + email?: string; + /** If this conversation part was sent by the AI Agent */ + from_ai_agent?: boolean; + /** If this conversation part body was generated by the AI Agent */ + is_ai_answer?: boolean; +} diff --git a/src/api/resources/unstable/types/ConversationPartMetadata.ts b/src/api/resources/unstable/types/ConversationPartMetadata.ts new file mode 100644 index 00000000..1a71c4a2 --- /dev/null +++ b/src/api/resources/unstable/types/ConversationPartMetadata.ts @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * Metadata for a conversation part + */ +export interface ConversationPartMetadata { + /** The quick reply options sent by the Admin or bot, presented in this conversation part. */ + quick_reply_options?: ConversationPartMetadata.QuickReplyOptions.Item[]; + /** The unique identifier for the quick reply option that was clicked by the end user. */ + quick_reply_uuid?: string; +} + +export namespace ConversationPartMetadata { + export type QuickReplyOptions = QuickReplyOptions.Item[]; + + export namespace QuickReplyOptions { + export interface Item extends Intercom.unstable.QuickReplyOption { + /** The translations for the quick reply option. */ + translations?: Record; + } + } +} diff --git a/src/api/resources/unstable/types/ConversationParts.ts b/src/api/resources/unstable/types/ConversationParts.ts new file mode 100644 index 00000000..2c21bccd --- /dev/null +++ b/src/api/resources/unstable/types/ConversationParts.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * A list of Conversation Part objects for each part message in the conversation. This is only returned when Retrieving a Conversation, and ignored when Listing all Conversations. There is a limit of 500 parts. + */ +export interface ConversationParts { + /** */ + type?: "conversation_part.list"; + /** A list of Conversation Part objects for each part message in the conversation. This is only returned when Retrieving a Conversation, and ignored when Listing all Conversations. There is a limit of 500 parts. */ + conversation_parts?: Intercom.unstable.ConversationPart[]; + /** */ + total_count?: number; +} diff --git a/src/api/resources/unstable/types/ConversationRating.ts b/src/api/resources/unstable/types/ConversationRating.ts new file mode 100644 index 00000000..5b5a7899 --- /dev/null +++ b/src/api/resources/unstable/types/ConversationRating.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * The Conversation Rating object which contains information on the rating and/or remark added by a Contact and the Admin assigned to the conversation. + */ +export interface ConversationRating { + /** The rating, between 1 and 5, for the conversation. */ + rating?: number; + /** An optional field to add a remark to correspond to the number rating */ + remark?: string; + /** The time the rating was requested in the conversation being rated. */ + created_at?: number; + contact?: Intercom.unstable.ContactReference; + teammate?: Intercom.unstable.Reference; +} diff --git a/src/api/resources/unstable/types/ConversationResponseTime.ts b/src/api/resources/unstable/types/ConversationResponseTime.ts new file mode 100644 index 00000000..56d2b0ae --- /dev/null +++ b/src/api/resources/unstable/types/ConversationResponseTime.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Details of first response time of assigned team in seconds. + */ +export interface ConversationResponseTime { + /** Id of the assigned team. */ + team_id?: number; + /** Name of the assigned Team, null if team does not exist, Unassigned if no team is assigned. */ + team_name?: string; + /** First response time of assigned team in seconds. */ + response_time?: number; +} diff --git a/src/api/resources/unstable/types/ConversationSource.ts b/src/api/resources/unstable/types/ConversationSource.ts new file mode 100644 index 00000000..e9ade720 --- /dev/null +++ b/src/api/resources/unstable/types/ConversationSource.ts @@ -0,0 +1,57 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * The type of the conversation part that started this conversation. Can be Contact, Admin, Campaign, Automated or Operator initiated. + */ +export interface ConversationSource { + /** This includes conversation, email, facebook, instagram, phone_call, phone_switch, push, sms, twitter and whatsapp. */ + type?: ConversationSource.Type; + /** The id representing the message. */ + id?: string; + /** The conversation's initiation type. Possible values are customer_initiated, campaigns_initiated (legacy campaigns), operator_initiated (Custom bot), automated (Series and other outbounds with dynamic audience message) and admin_initiated (fixed audience message, ticket initiated by an admin, group email). */ + delivered_as?: string; + /** Optional. The message subject. For Twitter, this will show a generic message regarding why the subject is obscured. */ + subject?: string; + /** The message body, which may contain HTML. For Twitter, this will show a generic message regarding why the body is obscured. */ + body?: string; + author?: Intercom.unstable.ConversationPartAuthor; + /** A list of attachments for the part. */ + attachments?: Intercom.unstable.PartAttachment[]; + /** The URL where the conversation was started. For Twitter, Email, and Bots, this will be blank. */ + url?: string; + /** Whether or not the source message has been redacted. Only applicable for contact initiated messages. */ + redacted?: boolean; +} + +export namespace ConversationSource { + /** + * This includes conversation, email, facebook, instagram, phone_call, phone_switch, push, sms, twitter and whatsapp. + */ + export type Type = + | "conversation" + | "email" + | "facebook" + | "instagram" + | "phone_call" + | "phone_switch" + | "push" + | "sms" + | "twitter" + | "whatsapp"; + export const Type = { + Conversation: "conversation", + Email: "email", + Facebook: "facebook", + Instagram: "instagram", + PhoneCall: "phone_call", + PhoneSwitch: "phone_switch", + Push: "push", + Sms: "sms", + Twitter: "twitter", + Whatsapp: "whatsapp", + } as const; +} diff --git a/src/api/resources/unstable/types/ConversationStatistics.ts b/src/api/resources/unstable/types/ConversationStatistics.ts new file mode 100644 index 00000000..03dc8b5c --- /dev/null +++ b/src/api/resources/unstable/types/ConversationStatistics.ts @@ -0,0 +1,55 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * A Statistics object containing all information required for reporting, with timestamps and calculated metrics. + */ +export interface ConversationStatistics { + /** */ + type?: string; + /** Duration until last assignment before first admin reply. In seconds. */ + time_to_assignment?: number; + /** Duration until first admin reply. Subtracts out of business hours. In seconds. */ + time_to_admin_reply?: number; + /** Duration until conversation was closed first time. Subtracts out of business hours. In seconds. */ + time_to_first_close?: number; + /** Duration until conversation was closed last time. Subtracts out of business hours. In seconds. */ + time_to_last_close?: number; + /** Median based on all admin replies after a contact reply. Subtracts out of business hours. In seconds. */ + median_time_to_reply?: number; + /** Time of first text conversation part from a contact. */ + first_contact_reply_at?: number; + /** Time of first assignment after first_contact_reply_at. */ + first_assignment_at?: number; + /** Time of first admin reply after first_contact_reply_at. */ + first_admin_reply_at?: number; + /** Time of first close after first_contact_reply_at. */ + first_close_at?: number; + /** Time of last assignment after first_contact_reply_at. */ + last_assignment_at?: number; + /** Time of first admin reply since most recent assignment. */ + last_assignment_admin_reply_at?: number; + /** Time of the last conversation part from a contact. */ + last_contact_reply_at?: number; + /** Time of the last conversation part from an admin. */ + last_admin_reply_at?: number; + /** Time of the last conversation close. */ + last_close_at?: number; + /** The last admin who closed the conversation. Returns a reference to an Admin object. */ + last_closed_by_id?: string; + /** Number of reopens after first_contact_reply_at. */ + count_reopens?: number; + /** Number of assignments after first_contact_reply_at. */ + count_assignments?: number; + /** Total number of conversation parts. */ + count_conversation_parts?: number; + /** An array of conversation response time objects */ + assigned_team_first_response_time_by_team?: Intercom.unstable.ConversationResponseTime[]; + /** An array of conversation response time objects within office hours */ + assigned_team_first_response_time_in_office_hours?: Intercom.unstable.ConversationResponseTime[]; + /** Time from conversation assignment to conversation close in seconds. */ + handling_time?: number; +} diff --git a/src/api/resources/unstable/types/ConversationTeammates.ts b/src/api/resources/unstable/types/ConversationTeammates.ts new file mode 100644 index 00000000..b72a5928 --- /dev/null +++ b/src/api/resources/unstable/types/ConversationTeammates.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * The list of teammates who participated in the conversation (wrote at least one conversation part). + */ +export interface ConversationTeammates { + /** The type of the object - `admin.list`. */ + type?: string; + /** The list of teammates who participated in the conversation (wrote at least one conversation part). */ + teammates?: Intercom.unstable.Reference[]; +} diff --git a/src/api/resources/unstable/types/CreateOrUpdateTagRequest.ts b/src/api/resources/unstable/types/CreateOrUpdateTagRequest.ts new file mode 100644 index 00000000..a79ff2e0 --- /dev/null +++ b/src/api/resources/unstable/types/CreateOrUpdateTagRequest.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * You can create or update an existing tag. + */ +export interface CreateOrUpdateTagRequest { + /** The name of the tag, which will be created if not found, or the new name for the tag if this is an update request. Names are case insensitive. */ + name: string; + /** The id of tag to updates. */ + id?: string; +} diff --git a/src/api/resources/unstable/types/CreateTicketReplyWithCommentRequest.ts b/src/api/resources/unstable/types/CreateTicketReplyWithCommentRequest.ts new file mode 100644 index 00000000..cbca0524 --- /dev/null +++ b/src/api/resources/unstable/types/CreateTicketReplyWithCommentRequest.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +export type CreateTicketReplyWithCommentRequest = + | Intercom.unstable.ContactReplyTicketRequest + | Intercom.unstable.AdminReplyTicketRequest; diff --git a/src/api/resources/unstable/types/CreateTicketRequestBody.ts b/src/api/resources/unstable/types/CreateTicketRequestBody.ts new file mode 100644 index 00000000..b5af5ba1 --- /dev/null +++ b/src/api/resources/unstable/types/CreateTicketRequestBody.ts @@ -0,0 +1,50 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * You can create a Ticket + */ +export interface CreateTicketRequestBody { + /** The ID of the type of ticket you want to create */ + ticket_type_id: string; + /** The list of contacts (users or leads) affected by this ticket. Currently only one is allowed */ + contacts: CreateTicketRequestBody.Contacts.Item[]; + /** + * The ID of the conversation you want to link to the ticket. Here are the valid ways of linking two tickets: + * - conversation | back-office ticket + * - customer tickets | non-shared back-office ticket + * - conversation | tracker ticket + * - customer ticket | tracker ticket + */ + conversation_to_link_id?: string; + /** The ID of the company that the ticket is associated with. The unique identifier for the company which is given by Intercom */ + company_id?: string; + /** The time the ticket was created. If not provided, the current time will be used. */ + created_at?: number; + assignment?: CreateTicketRequestBody.Assignment; +} + +export namespace CreateTicketRequestBody { + export type Contacts = Contacts.Item[]; + + export namespace Contacts { + export type Item = + | { + id: string; + } + | { + external_id: string; + } + | { + email: string; + }; + } + + export interface Assignment { + /** The ID of the admin to which the ticket is assigned. If not provided, the ticket will be unassigned. */ + admin_assignee_id?: string; + /** The ID of the team to which the ticket is assigned. If not provided, the ticket will be unassigned. */ + team_assignee_id?: string; + } +} diff --git a/src/api/resources/unstable/types/CursorPages.ts b/src/api/resources/unstable/types/CursorPages.ts new file mode 100644 index 00000000..b289ca72 --- /dev/null +++ b/src/api/resources/unstable/types/CursorPages.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * Cursor-based pagination is a technique used in the Intercom API to navigate through large amounts of data. + * A "cursor" or pointer is used to keep track of the current position in the result set, allowing the API to return the data in small chunks or "pages" as needed. + */ +export interface CursorPages { + /** the type of object `pages`. */ + type?: "pages"; + /** The current page */ + page?: number; + next?: Intercom.unstable.StartingAfterPaging; + /** Number of results per page */ + per_page?: number; + /** Total number of pages */ + total_pages?: number; +} diff --git a/src/api/resources/unstable/types/CustomActionFinished.ts b/src/api/resources/unstable/types/CustomActionFinished.ts new file mode 100644 index 00000000..95484be5 --- /dev/null +++ b/src/api/resources/unstable/types/CustomActionFinished.ts @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Contains details about final status of the completed action for conversation part type custom_action_finished. + */ +export interface CustomActionFinished { + action?: CustomActionFinished.Action; +} + +export namespace CustomActionFinished { + export interface Action { + /** Name of the action */ + name?: string; + /** Status of the action */ + result?: Action.Result; + } + + export namespace Action { + /** + * Status of the action + */ + export type Result = "success" | "failed"; + export const Result = { + Success: "success", + Failed: "failed", + } as const; + } +} diff --git a/src/api/resources/unstable/types/CustomActionStarted.ts b/src/api/resources/unstable/types/CustomActionStarted.ts new file mode 100644 index 00000000..eb089da6 --- /dev/null +++ b/src/api/resources/unstable/types/CustomActionStarted.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Contains details about name of the action that was initiated for conversation part type custom_action_started. + */ +export interface CustomActionStarted { + action?: CustomActionStarted.Action; +} + +export namespace CustomActionStarted { + export interface Action { + /** Name of the action */ + name?: string; + } +} diff --git a/src/api/resources/unstable/types/CustomAttributes.ts b/src/api/resources/unstable/types/CustomAttributes.ts new file mode 100644 index 00000000..1a8f52e6 --- /dev/null +++ b/src/api/resources/unstable/types/CustomAttributes.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * An object containing the different custom attributes associated to the conversation as key-value pairs. For relationship attributes the value will be a list of custom object instance models. + */ +export type CustomAttributes = Record; + +export namespace CustomAttributes { + export type Value = string | number | Intercom.unstable.Datetime | Intercom.unstable.CustomObjectInstanceList; +} diff --git a/src/api/resources/unstable/types/CustomChannelAttribute.ts b/src/api/resources/unstable/types/CustomChannelAttribute.ts new file mode 100644 index 00000000..1f5ffeb6 --- /dev/null +++ b/src/api/resources/unstable/types/CustomChannelAttribute.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface CustomChannelAttribute { + /** Identifier for the attribute being collected. */ + id: string; + /** Value provided by the user for the attribute. */ + value: string; +} diff --git a/src/api/resources/unstable/types/CustomChannelBaseEvent.ts b/src/api/resources/unstable/types/CustomChannelBaseEvent.ts new file mode 100644 index 00000000..16b7996e --- /dev/null +++ b/src/api/resources/unstable/types/CustomChannelBaseEvent.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +export interface CustomChannelBaseEvent { + /** Unique identifier for the event. */ + event_id: string; + /** Identifier for the conversation in your application. */ + external_conversation_id: string; + contact: Intercom.unstable.CustomChannelContact; +} diff --git a/src/api/resources/unstable/types/CustomChannelContact.ts b/src/api/resources/unstable/types/CustomChannelContact.ts new file mode 100644 index 00000000..e1e7eabc --- /dev/null +++ b/src/api/resources/unstable/types/CustomChannelContact.ts @@ -0,0 +1,25 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface CustomChannelContact { + /** Type of contact, must be "user" or "lead". */ + type: CustomChannelContact.Type; + /** External identifier for the contact. Intercom will take care of the mapping of your external_id with our internal ones so you don't have to worry about it. */ + external_id: string; + /** Name of the contact. */ + name: string; + /** Email address of the contact. */ + email: string; +} + +export namespace CustomChannelContact { + /** + * Type of contact, must be "user" or "lead". + */ + export type Type = "user" | "lead"; + export const Type = { + User: "user", + Lead: "lead", + } as const; +} diff --git a/src/api/resources/unstable/types/CustomChannelNotificationResponse.ts b/src/api/resources/unstable/types/CustomChannelNotificationResponse.ts new file mode 100644 index 00000000..ae5a5611 --- /dev/null +++ b/src/api/resources/unstable/types/CustomChannelNotificationResponse.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface CustomChannelNotificationResponse { + /** The external conversation ID provided in the notification request */ + external_conversation_id: string; + /** The Intercom conversation ID mapped to the external conversation ID */ + conversation_id: string; + /** The external contact ID provided in the notification request */ + external_contact_id: string; + /** The Intercom contact ID mapped to the external contact ID */ + contact_id: string; +} diff --git a/src/api/resources/unstable/types/CustomObjectInstanceDeleted.ts b/src/api/resources/unstable/types/CustomObjectInstanceDeleted.ts new file mode 100644 index 00000000..091e1ec4 --- /dev/null +++ b/src/api/resources/unstable/types/CustomObjectInstanceDeleted.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * deleted custom object instance object + */ +export interface CustomObjectInstanceDeleted { + /** The unique identifier of the Custom Object type that defines the structure of the Custom Object instance. */ + object?: string; + /** The Intercom defined id representing the Custom Object instance. */ + id?: string; + /** Whether the Custom Object instance is deleted or not. */ + deleted?: boolean; +} diff --git a/src/api/resources/unstable/types/CustomObjectInstanceList.ts b/src/api/resources/unstable/types/CustomObjectInstanceList.ts new file mode 100644 index 00000000..8bfd0ef2 --- /dev/null +++ b/src/api/resources/unstable/types/CustomObjectInstanceList.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * The list of associated custom object instances for a given reference attribute on the parent object. + */ +export interface CustomObjectInstanceList { + type?: string; + /** The list of associated custom object instances for a given reference attribute on the parent object. */ + instances?: (Intercom.unstable.CustomObjectInstance | undefined)[]; +} diff --git a/src/api/resources/unstable/types/CustomerRequest.ts b/src/api/resources/unstable/types/CustomerRequest.ts new file mode 100644 index 00000000..6ede7a3d --- /dev/null +++ b/src/api/resources/unstable/types/CustomerRequest.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type CustomerRequest = + | { + intercom_user_id: string; + } + | { + user_id: string; + } + | { + email: string; + }; diff --git a/src/api/resources/unstable/types/DataAttributeList.ts b/src/api/resources/unstable/types/DataAttributeList.ts new file mode 100644 index 00000000..5242a0bf --- /dev/null +++ b/src/api/resources/unstable/types/DataAttributeList.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * A list of all data attributes belonging to a workspace for contacts, companies or conversations. + */ +export interface DataAttributeList { + /** The type of the object */ + type?: "list"; + /** A list of data attributes */ + data?: Intercom.unstable.DataAttribute[]; +} diff --git a/src/api/resources/unstable/types/DataEventList.ts b/src/api/resources/unstable/types/DataEventList.ts new file mode 100644 index 00000000..09ed47e2 --- /dev/null +++ b/src/api/resources/unstable/types/DataEventList.ts @@ -0,0 +1,27 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * This will return a list of data events for the App. + */ +export interface DataEventList { + /** The type of the object */ + type?: "event.list"; + /** A list of data events */ + events?: Intercom.unstable.DataEvent[]; + /** Pagination */ + pages?: DataEventList.Pages; +} + +export namespace DataEventList { + /** + * Pagination + */ + export interface Pages { + next?: string; + since?: string; + } +} diff --git a/src/api/resources/unstable/types/DataEventSummary.ts b/src/api/resources/unstable/types/DataEventSummary.ts new file mode 100644 index 00000000..87791da0 --- /dev/null +++ b/src/api/resources/unstable/types/DataEventSummary.ts @@ -0,0 +1,21 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * This will return a summary of data events for the App. + */ +export interface DataEventSummary { + /** The type of the object */ + type?: "event.summary"; + /** The email address of the user */ + email?: string; + /** The Intercom user ID of the user */ + intercom_user_id?: string; + /** The user ID of the user */ + user_id?: string; + /** A summary of data events */ + events?: (Intercom.unstable.DataEventSummaryItem | undefined)[]; +} diff --git a/src/api/resources/unstable/types/DataEventSummaryItem.ts b/src/api/resources/unstable/types/DataEventSummaryItem.ts new file mode 100644 index 00000000..26f9e3a5 --- /dev/null +++ b/src/api/resources/unstable/types/DataEventSummaryItem.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * This will return a summary of a data event for the App. + */ +export interface DataEventSummaryItem { + /** The name of the event */ + name?: string; + /** The first time the event was sent */ + first?: string; + /** The last time the event was sent */ + last?: string; + /** The number of times the event was sent */ + count?: number; + /** The description of the event */ + description?: string; +} diff --git a/src/api/resources/unstable/types/DataExportCsv.ts b/src/api/resources/unstable/types/DataExportCsv.ts new file mode 100644 index 00000000..5cc3bea0 --- /dev/null +++ b/src/api/resources/unstable/types/DataExportCsv.ts @@ -0,0 +1,61 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A CSV output file + */ +export interface DataExportCsv { + /** The user_id of the user who was sent the message. */ + user_id?: string; + /** The external_user_id of the user who was sent the message */ + user_external_id?: string; + /** The company ID of the user in relation to the message that was sent. Will return -1 if no company is present. */ + company_id?: string; + /** The users email who was sent the message. */ + email?: string; + /** The full name of the user receiving the message */ + name?: string; + /** The id of the message. */ + ruleset_id?: string; + /** The specific content that was received. In an A/B test each version has its own Content ID. */ + content_id?: string; + /** Email, Chat, Post etc. */ + content_type?: string; + /** The title of the content you see in your Intercom workspace. */ + content_title?: string; + /** As you edit content we record new versions. This ID can help you determine which version of a piece of content that was received. */ + ruleset_version_id?: string; + /** ID for this receipt. Will be included with any related stats in other files to identify this specific delivery of a message. */ + receipt_id?: string; + /** Timestamp for when the receipt was recorded. */ + received_at?: number; + /** The id of the series that this content is part of. Will return -1 if not part of a series. */ + series_id?: string; + /** The title of the series that this content is part of. */ + series_title?: string; + /** The id of the series node that this ruleset is associated with. Each block in a series has a corresponding node_id. */ + node_id?: string; + /** The first time a user replied to this message if the content was able to receive replies. */ + first_reply?: number; + /** The first time a user completed this message if the content was able to be completed e.g. Tours, Surveys. */ + first_completion?: number; + /** The first time the series this message was a part of was completed by the user. */ + first_series_completion?: number; + /** The first time the series this message was a part of was disengaged by the user. */ + first_series_disengagement?: number; + /** The first time the series this message was a part of was exited by the user. */ + first_series_exit?: number; + /** The first time the user met this messages associated goal if one exists. */ + first_goal_success?: number; + /** The first time the user opened this message. */ + first_open?: number; + /** The first time the series the user clicked on a link within this message. */ + first_click?: number; + /** The first time the series the user dismissed this message. */ + first_dismisall?: number; + /** The first time the user unsubscribed from this message. */ + first_unsubscribe?: number; + /** The first time this message hard bounced for this user */ + first_hard_bounce?: number; +} diff --git a/src/api/resources/unstable/types/Datetime.ts b/src/api/resources/unstable/types/Datetime.ts new file mode 100644 index 00000000..c291e607 --- /dev/null +++ b/src/api/resources/unstable/types/Datetime.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type Datetime = + /** + * A date and time following the ISO8601 notation. */ + | string + /** + * A date and time as UNIX timestamp notation. */ + | number; diff --git a/src/api/resources/unstable/types/DeletedArticleObject.ts b/src/api/resources/unstable/types/DeletedArticleObject.ts new file mode 100644 index 00000000..2fb626a8 --- /dev/null +++ b/src/api/resources/unstable/types/DeletedArticleObject.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Response returned when an object is deleted + */ +export interface DeletedArticleObject { + /** The unique identifier for the article which you provided in the URL. */ + id?: string; + /** The type of object which was deleted. - article */ + object?: "article"; + /** Whether the article was deleted successfully or not. */ + deleted?: boolean; +} diff --git a/src/api/resources/unstable/types/DeletedCollectionObject.ts b/src/api/resources/unstable/types/DeletedCollectionObject.ts new file mode 100644 index 00000000..9f09babd --- /dev/null +++ b/src/api/resources/unstable/types/DeletedCollectionObject.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Response returned when an object is deleted + */ +export interface DeletedCollectionObject { + /** The unique identifier for the collection which you provided in the URL. */ + id?: string; + /** The type of object which was deleted. - `collection` */ + object?: "collection"; + /** Whether the collection was deleted successfully or not. */ + deleted?: boolean; +} diff --git a/src/api/resources/unstable/types/DeletedCompanyObject.ts b/src/api/resources/unstable/types/DeletedCompanyObject.ts new file mode 100644 index 00000000..f93f0699 --- /dev/null +++ b/src/api/resources/unstable/types/DeletedCompanyObject.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Response returned when an object is deleted + */ +export interface DeletedCompanyObject { + /** The unique identifier for the company which is given by Intercom. */ + id?: string; + /** The type of object which was deleted. - `company` */ + object?: "company"; + /** Whether the company was deleted successfully or not. */ + deleted?: boolean; +} diff --git a/src/api/resources/unstable/types/DeletedObject.ts b/src/api/resources/unstable/types/DeletedObject.ts new file mode 100644 index 00000000..613a0f83 --- /dev/null +++ b/src/api/resources/unstable/types/DeletedObject.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Response returned when an object is deleted + */ +export interface DeletedObject { + /** The unique identifier for the news item which you provided in the URL. */ + id?: string; + /** The type of object which was deleted - news-item. */ + object?: "news-item"; + /** Whether the news item was deleted successfully or not. */ + deleted?: boolean; +} diff --git a/src/api/resources/unstable/types/EmailAddressHeader.ts b/src/api/resources/unstable/types/EmailAddressHeader.ts new file mode 100644 index 00000000..81f30d02 --- /dev/null +++ b/src/api/resources/unstable/types/EmailAddressHeader.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Contains data for an email address header for a conversation part that was sent as an email. + */ +export interface EmailAddressHeader { + /** The type of email address header */ + type?: string; + /** The email address */ + email_address?: string; + /** The name associated with the email address */ + name?: string; +} diff --git a/src/api/resources/unstable/types/EmailMessageMetadata.ts b/src/api/resources/unstable/types/EmailMessageMetadata.ts new file mode 100644 index 00000000..6a407392 --- /dev/null +++ b/src/api/resources/unstable/types/EmailMessageMetadata.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * Contains metadata if the message was sent as an email + */ +export interface EmailMessageMetadata { + /** The subject of the email */ + subject?: string; + /** A list of an email address headers. */ + email_address_headers?: Intercom.unstable.EmailAddressHeader[]; +} diff --git a/src/api/resources/unstable/types/Error_.ts b/src/api/resources/unstable/types/Error_.ts new file mode 100644 index 00000000..1526174a --- /dev/null +++ b/src/api/resources/unstable/types/Error_.ts @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The API will return an Error List for a failed request, which will contain one or more Error objects. + */ +export interface Error_ { + /** The type is error.list */ + type: string; + /** */ + request_id?: string; + /** An array of one or more error objects */ + errors: Error_.Errors.Item[]; +} + +export namespace Error_ { + export type Errors = Errors.Item[]; + + export namespace Errors { + export interface Item { + /** A string indicating the kind of error, used to further qualify the HTTP response code */ + code: string; + /** Optional. Human readable description of the error. */ + message?: string; + /** Optional. Used to identify a particular field or query parameter that was in error. */ + field?: string; + } + } +} diff --git a/src/api/resources/unstable/types/EventDetails.ts b/src/api/resources/unstable/types/EventDetails.ts new file mode 100644 index 00000000..a5bddd05 --- /dev/null +++ b/src/api/resources/unstable/types/EventDetails.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +export type EventDetails = + | Intercom.unstable.ConversationAttributeUpdatedByWorkflow + | Intercom.unstable.ConversationAttributeUpdatedByAdmin + | Intercom.unstable.CustomActionStarted + | Intercom.unstable.CustomActionFinished + | Intercom.unstable.OperatorWorkflowEvent; diff --git a/src/api/resources/unstable/types/FileAttribute.ts b/src/api/resources/unstable/types/FileAttribute.ts new file mode 100644 index 00000000..e0c5f023 --- /dev/null +++ b/src/api/resources/unstable/types/FileAttribute.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The value describing a file upload set for a custom attribute + */ +export interface FileAttribute { + type?: string; + /** The name of the file */ + name?: string; + /** The url of the file. This is a temporary URL and will expire after 30 minutes. */ + url?: string; + /** The type of file */ + content_type?: string; + /** The size of the file in bytes */ + filesize?: number; + /** The width of the file in pixels, if applicable */ + width?: number; + /** The height of the file in pixels, if applicable */ + height?: number; +} diff --git a/src/api/resources/unstable/types/GroupContent.ts b/src/api/resources/unstable/types/GroupContent.ts new file mode 100644 index 00000000..a7fb4506 --- /dev/null +++ b/src/api/resources/unstable/types/GroupContent.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The Content of a Group. + */ +export interface GroupContent { + /** The type of object - `group_content` . */ + type?: string; + /** The name of the collection or section. */ + name?: string; + /** The description of the collection. Only available for collections. */ + description?: string; +} diff --git a/src/api/resources/unstable/types/GroupTranslatedContent.ts b/src/api/resources/unstable/types/GroupTranslatedContent.ts new file mode 100644 index 00000000..5df6fde7 --- /dev/null +++ b/src/api/resources/unstable/types/GroupTranslatedContent.ts @@ -0,0 +1,87 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * The Translated Content of an Group. The keys are the locale codes and the values are the translated content of the Group. + */ +export interface GroupTranslatedContent { + /** The type of object - group_translated_content. */ + type?: string; + /** The content of the group in Arabic */ + ar?: Intercom.unstable.GroupContent; + /** The content of the group in Bulgarian */ + bg?: Intercom.unstable.GroupContent; + /** The content of the group in Bosnian */ + bs?: Intercom.unstable.GroupContent; + /** The content of the group in Catalan */ + ca?: Intercom.unstable.GroupContent; + /** The content of the group in Czech */ + cs?: Intercom.unstable.GroupContent; + /** The content of the group in Danish */ + da?: Intercom.unstable.GroupContent; + /** The content of the group in German */ + de?: Intercom.unstable.GroupContent; + /** The content of the group in Greek */ + el?: Intercom.unstable.GroupContent; + /** The content of the group in English */ + en?: Intercom.unstable.GroupContent; + /** The content of the group in Spanish */ + es?: Intercom.unstable.GroupContent; + /** The content of the group in Estonian */ + et?: Intercom.unstable.GroupContent; + /** The content of the group in Finnish */ + fi?: Intercom.unstable.GroupContent; + /** The content of the group in French */ + fr?: Intercom.unstable.GroupContent; + /** The content of the group in Hebrew */ + he?: Intercom.unstable.GroupContent; + /** The content of the group in Croatian */ + hr?: Intercom.unstable.GroupContent; + /** The content of the group in Hungarian */ + hu?: Intercom.unstable.GroupContent; + /** The content of the group in Indonesian */ + id?: Intercom.unstable.GroupContent; + /** The content of the group in Italian */ + it?: Intercom.unstable.GroupContent; + /** The content of the group in Japanese */ + ja?: Intercom.unstable.GroupContent; + /** The content of the group in Korean */ + ko?: Intercom.unstable.GroupContent; + /** The content of the group in Lithuanian */ + lt?: Intercom.unstable.GroupContent; + /** The content of the group in Latvian */ + lv?: Intercom.unstable.GroupContent; + /** The content of the group in Mongolian */ + mn?: Intercom.unstable.GroupContent; + /** The content of the group in Norwegian */ + nb?: Intercom.unstable.GroupContent; + /** The content of the group in Dutch */ + nl?: Intercom.unstable.GroupContent; + /** The content of the group in Polish */ + pl?: Intercom.unstable.GroupContent; + /** The content of the group in Portuguese (Portugal) */ + pt?: Intercom.unstable.GroupContent; + /** The content of the group in Romanian */ + ro?: Intercom.unstable.GroupContent; + /** The content of the group in Russian */ + ru?: Intercom.unstable.GroupContent; + /** The content of the group in Slovenian */ + sl?: Intercom.unstable.GroupContent; + /** The content of the group in Serbian */ + sr?: Intercom.unstable.GroupContent; + /** The content of the group in Swedish */ + sv?: Intercom.unstable.GroupContent; + /** The content of the group in Turkish */ + tr?: Intercom.unstable.GroupContent; + /** The content of the group in Vietnamese */ + vi?: Intercom.unstable.GroupContent; + /** The content of the group in Portuguese (Brazil) */ + "pt-BR"?: Intercom.unstable.GroupContent; + /** The content of the group in Chinese (China) */ + "zh-CN"?: Intercom.unstable.GroupContent; + /** The content of the group in Chinese (Taiwan) */ + "zh-TW"?: Intercom.unstable.GroupContent; +} diff --git a/src/api/resources/unstable/types/IntercomVersion.ts b/src/api/resources/unstable/types/IntercomVersion.ts new file mode 100644 index 00000000..921f8ae6 --- /dev/null +++ b/src/api/resources/unstable/types/IntercomVersion.ts @@ -0,0 +1,46 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Intercom API version.
By default, it's equal to the version set in the app package. + */ +export type IntercomVersion = + | "1.0" + | "1.1" + | "1.2" + | "1.3" + | "1.4" + | "2.0" + | "2.1" + | "2.2" + | "2.3" + | "2.4" + | "2.5" + | "2.6" + | "2.7" + | "2.8" + | "2.9" + | "2.10" + | "2.11" + | "Unstable"; +export const IntercomVersion = { + One0: "1.0", + One1: "1.1", + One2: "1.2", + One3: "1.3", + One4: "1.4", + Two0: "2.0", + Two1: "2.1", + Two2: "2.2", + Two3: "2.3", + Two4: "2.4", + Two5: "2.5", + Two6: "2.6", + Two7: "2.7", + Two8: "2.8", + Two9: "2.9", + Two10: "2.10", + Two11: "2.11", + Unstable: "Unstable", +} as const; diff --git a/src/api/resources/unstable/types/IntercomVersionUnstable.ts b/src/api/resources/unstable/types/IntercomVersionUnstable.ts new file mode 100644 index 00000000..1bbcf600 --- /dev/null +++ b/src/api/resources/unstable/types/IntercomVersionUnstable.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Unstable Intercom API version. Used for closed beta endpoints. + */ +export type IntercomVersionUnstable = "unstable"; diff --git a/src/api/resources/unstable/types/LinkedObject.ts b/src/api/resources/unstable/types/LinkedObject.ts new file mode 100644 index 00000000..d7eaf21d --- /dev/null +++ b/src/api/resources/unstable/types/LinkedObject.ts @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A linked conversation or ticket. + */ +export interface LinkedObject { + /** ticket or conversation */ + type?: LinkedObject.Type; + /** The ID of the linked object */ + id?: string; + /** Category of the Linked Ticket Object. */ + category?: string; +} + +export namespace LinkedObject { + /** + * ticket or conversation + */ + export type Type = "ticket" | "conversation"; + export const Type = { + Ticket: "ticket", + Conversation: "conversation", + } as const; +} diff --git a/src/api/resources/unstable/types/LinkedObjectList.ts b/src/api/resources/unstable/types/LinkedObjectList.ts new file mode 100644 index 00000000..8a95b96a --- /dev/null +++ b/src/api/resources/unstable/types/LinkedObjectList.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * An object containing metadata about linked conversations and linked tickets. Up to 1000 can be returned. + */ +export interface LinkedObjectList { + /** Always list. */ + type?: "list"; + /** The total number of linked objects. */ + total_count?: number; + /** Whether or not there are more linked objects than returned. */ + has_more?: boolean; + /** An array containing the linked conversations and linked tickets. */ + data?: Intercom.unstable.LinkedObject[]; +} diff --git a/src/api/resources/unstable/types/MultipleFilterSearchRequest.ts b/src/api/resources/unstable/types/MultipleFilterSearchRequest.ts new file mode 100644 index 00000000..9f184175 --- /dev/null +++ b/src/api/resources/unstable/types/MultipleFilterSearchRequest.ts @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * Search using Intercoms Search APIs with more than one filter. + */ +export interface MultipleFilterSearchRequest { + /** An operator to allow boolean inspection between multiple fields. */ + operator?: MultipleFilterSearchRequest.Operator; + value?: MultipleFilterSearchRequest.Value; +} + +export namespace MultipleFilterSearchRequest { + /** + * An operator to allow boolean inspection between multiple fields. + */ + export type Operator = "AND" | "OR"; + export const Operator = { + And: "AND", + Or: "OR", + } as const; + export type Value = + /** + * Add mutiple filters. */ + | Intercom.unstable.MultipleFilterSearchRequest[] + /** + * Add a single filter field. */ + | Intercom.unstable.SingleFilterSearchRequest[]; +} diff --git a/src/api/resources/unstable/types/NewsItemRequest.ts b/src/api/resources/unstable/types/NewsItemRequest.ts new file mode 100644 index 00000000..3e3791a2 --- /dev/null +++ b/src/api/resources/unstable/types/NewsItemRequest.ts @@ -0,0 +1,38 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * A News Item is a content type in Intercom enabling you to announce product updates, company news, promotions, events and more with your customers. + */ +export interface NewsItemRequest { + /** The title of the news item. */ + title: string; + /** The news item body, which may contain HTML. */ + body?: string; + /** The id of the sender of the news item. Must be a teammate on the workspace. */ + sender_id: number; + /** News items will not be visible to your users in the assigned newsfeeds until they are set live. */ + state?: NewsItemRequest.State; + /** When set to `true`, the news item will appear in the messenger newsfeed without showing a notification badge. */ + deliver_silently?: boolean; + /** Label names displayed to users to categorize the news item. */ + labels?: string[]; + /** Ordered list of emoji reactions to the news item. When empty, reactions are disabled. */ + reactions?: (string | undefined)[]; + /** A list of newsfeed_assignments to assign to the specified newsfeed. */ + newsfeed_assignments?: Intercom.unstable.NewsfeedAssignment[]; +} + +export namespace NewsItemRequest { + /** + * News items will not be visible to your users in the assigned newsfeeds until they are set live. + */ + export type State = "draft" | "live"; + export const State = { + Draft: "draft", + Live: "live", + } as const; +} diff --git a/src/api/resources/unstable/types/NotFoundErrorBody.ts b/src/api/resources/unstable/types/NotFoundErrorBody.ts new file mode 100644 index 00000000..0893b81e --- /dev/null +++ b/src/api/resources/unstable/types/NotFoundErrorBody.ts @@ -0,0 +1,25 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface NotFoundErrorBody { + /** The type is error.list */ + type: string; + /** */ + request_id?: string; + /** An array of one or more error objects */ + errors: NotFoundErrorBody.Errors.Item[]; +} + +export namespace NotFoundErrorBody { + export type Errors = Errors.Item[]; + + export namespace Errors { + export interface Item { + /** ticket_not_found */ + code: string; + /** Ticket not found */ + message?: string; + } + } +} diff --git a/src/api/resources/unstable/types/NoteList.ts b/src/api/resources/unstable/types/NoteList.ts new file mode 100644 index 00000000..162d648f --- /dev/null +++ b/src/api/resources/unstable/types/NoteList.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * A paginated list of notes associated with a contact. + */ +export interface NoteList { + /** String representing the object's type. Always has the value `list`. */ + type?: string; + /** An array of notes. */ + data?: Intercom.unstable.Note[]; + /** A count of the total number of notes. */ + total_count?: number; + pages?: Intercom.unstable.CursorPages; +} diff --git a/src/api/resources/unstable/types/OpenConversationRequest.ts b/src/api/resources/unstable/types/OpenConversationRequest.ts new file mode 100644 index 00000000..682699e3 --- /dev/null +++ b/src/api/resources/unstable/types/OpenConversationRequest.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Payload of the request to open a conversation + */ +export interface OpenConversationRequest { + /** The id of the admin who is performing the action. */ + admin_id: string; +} diff --git a/src/api/resources/unstable/types/OperatorWorkflowEvent.ts b/src/api/resources/unstable/types/OperatorWorkflowEvent.ts new file mode 100644 index 00000000..336b4885 --- /dev/null +++ b/src/api/resources/unstable/types/OperatorWorkflowEvent.ts @@ -0,0 +1,25 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Contains details about name of the workflow for conversation part type operator_workflow_event. + */ +export interface OperatorWorkflowEvent { + workflow?: OperatorWorkflowEvent.Workflow; + event?: OperatorWorkflowEvent.Event; +} + +export namespace OperatorWorkflowEvent { + export interface Workflow { + /** The name of the workflow */ + name?: string; + } + + export interface Event { + /** Type of the workflow event initiated */ + type?: string; + /** Result of the workflow event */ + result?: string; + } +} diff --git a/src/api/resources/unstable/types/PagesLink.ts b/src/api/resources/unstable/types/PagesLink.ts new file mode 100644 index 00000000..4dd36d75 --- /dev/null +++ b/src/api/resources/unstable/types/PagesLink.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The majority of list resources in the API are paginated to allow clients to traverse data over multiple requests. + * + * Their responses are likely to contain a pages object that hosts pagination links which a client can use to paginate through the data without having to construct a query. The link relations for the pages field are as follows. + */ +export interface PagesLink { + type?: "pages"; + page?: number; + /** A link to the next page of results. A response that does not contain a next link does not have further data to fetch. */ + next?: string; + per_page?: number; + total_pages?: number; +} diff --git a/src/api/resources/unstable/types/PaginatedResponse.ts b/src/api/resources/unstable/types/PaginatedResponse.ts new file mode 100644 index 00000000..af97a516 --- /dev/null +++ b/src/api/resources/unstable/types/PaginatedResponse.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * Paginated Response + */ +export interface PaginatedResponse { + /** The type of object */ + type?: PaginatedResponse.Type; + pages?: Intercom.unstable.CursorPages; + /** A count of the total number of objects. */ + total_count?: number; + /** An array of Objects */ + data?: Intercom.unstable.PaginatedResponseDataItem[]; +} + +export namespace PaginatedResponse { + /** + * The type of object + */ + export type Type = "list" | "conversation.list"; + export const Type = { + List: "list", + ConversationList: "conversation.list", + } as const; +} diff --git a/src/api/resources/unstable/types/PaginatedResponseDataItem.ts b/src/api/resources/unstable/types/PaginatedResponseDataItem.ts new file mode 100644 index 00000000..fc09f5f8 --- /dev/null +++ b/src/api/resources/unstable/types/PaginatedResponseDataItem.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +export type PaginatedResponseDataItem = + | Intercom.unstable.PaginatedResponseDataItem.NewsItem + | Intercom.unstable.PaginatedResponseDataItem.Newsfeed; + +export namespace PaginatedResponseDataItem { + export interface NewsItem extends Intercom.unstable.NewsItem { + type: "news-item"; + } + + export interface Newsfeed extends Intercom.unstable.Newsfeed { + type: "newsfeed"; + } +} diff --git a/src/api/resources/unstable/types/PartAttachment.ts b/src/api/resources/unstable/types/PartAttachment.ts new file mode 100644 index 00000000..690152f9 --- /dev/null +++ b/src/api/resources/unstable/types/PartAttachment.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The file attached to a part + */ +export interface PartAttachment { + /** The type of attachment */ + type?: string; + /** The name of the attachment */ + name?: string; + /** The URL of the attachment */ + url?: string; + /** The content type of the attachment */ + content_type?: string; + /** The size of the attachment */ + filesize?: number; + /** The width of the attachment */ + width?: number; + /** The height of the attachment */ + height?: number; +} diff --git a/src/api/resources/unstable/types/PhoneSwitch.ts b/src/api/resources/unstable/types/PhoneSwitch.ts new file mode 100644 index 00000000..3e6aad44 --- /dev/null +++ b/src/api/resources/unstable/types/PhoneSwitch.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Phone Switch Response + */ +export interface PhoneSwitch { + /** */ + type?: "phone_call_redirect"; + /** Phone number in E.164 format, that has received the SMS to continue the conversation in the Messenger. */ + phone?: string; +} diff --git a/src/api/resources/unstable/types/QuickReplyOption.ts b/src/api/resources/unstable/types/QuickReplyOption.ts new file mode 100644 index 00000000..379777e5 --- /dev/null +++ b/src/api/resources/unstable/types/QuickReplyOption.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface QuickReplyOption { + /** The text to display in this quick reply option. */ + text: string; + /** A unique identifier for this quick reply option. This value will be available within the metadata of the comment conversation part that is created when a user clicks on this reply option. */ + uuid: string; +} diff --git a/src/api/resources/unstable/types/Recipient.ts b/src/api/resources/unstable/types/Recipient.ts new file mode 100644 index 00000000..25e28bb9 --- /dev/null +++ b/src/api/resources/unstable/types/Recipient.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A recipient of a message + */ +export interface Recipient { + /** The role associated to the contact - `user` or `lead`. */ + type: Recipient.Type; + /** The identifier for the contact which is given by Intercom. */ + id: string; +} + +export namespace Recipient { + /** + * The role associated to the contact - `user` or `lead`. + */ + export type Type = "user" | "lead"; + export const Type = { + User: "user", + Lead: "lead", + } as const; +} diff --git a/src/api/resources/unstable/types/RedactConversationRequest.ts b/src/api/resources/unstable/types/RedactConversationRequest.ts new file mode 100644 index 00000000..968bb6af --- /dev/null +++ b/src/api/resources/unstable/types/RedactConversationRequest.ts @@ -0,0 +1,31 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +export type RedactConversationRequest = + /** + * Payload of the request to redact a conversation part */ + | Intercom.unstable.RedactConversationRequest.ConversationPart + /** + * Payload of the request to redact a conversation source */ + | Intercom.unstable.RedactConversationRequest.Source; + +export namespace RedactConversationRequest { + export interface ConversationPart { + type: "conversation_part"; + /** The id of the conversation. */ + conversation_id: string; + /** The id of the conversation_part. */ + conversation_part_id: string; + } + + export interface Source { + type: "source"; + /** The id of the conversation. */ + conversation_id: string; + /** The id of the source. */ + source_id: string; + } +} diff --git a/src/api/resources/unstable/types/Reference.ts b/src/api/resources/unstable/types/Reference.ts new file mode 100644 index 00000000..b14f584f --- /dev/null +++ b/src/api/resources/unstable/types/Reference.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * reference to another object + */ +export interface Reference { + /** */ + type?: string; + /** */ + id?: string; +} diff --git a/src/api/resources/unstable/types/ReplyConversationRequestBody.ts b/src/api/resources/unstable/types/ReplyConversationRequestBody.ts new file mode 100644 index 00000000..261d4f73 --- /dev/null +++ b/src/api/resources/unstable/types/ReplyConversationRequestBody.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +export type ReplyConversationRequestBody = + | Intercom.unstable.ContactReplyConversationRequest + | Intercom.unstable.AdminReplyConversationRequest; diff --git a/src/api/resources/unstable/types/SearchRequest.ts b/src/api/resources/unstable/types/SearchRequest.ts new file mode 100644 index 00000000..7dc82a61 --- /dev/null +++ b/src/api/resources/unstable/types/SearchRequest.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * Search using Intercoms Search APIs. + */ +export interface SearchRequest { + query: SearchRequest.Query; + pagination?: Intercom.unstable.StartingAfterPaging; +} + +export namespace SearchRequest { + export type Query = Intercom.unstable.SingleFilterSearchRequest | Intercom.unstable.MultipleFilterSearchRequest; +} diff --git a/src/api/resources/unstable/types/SegmentList.ts b/src/api/resources/unstable/types/SegmentList.ts new file mode 100644 index 00000000..22f29cc3 --- /dev/null +++ b/src/api/resources/unstable/types/SegmentList.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * This will return a list of Segment Objects. The result may also have a pages object if the response is paginated. + */ +export interface SegmentList { + /** The type of the object */ + type?: "segment.list"; + /** A list of Segment objects */ + segments?: Intercom.unstable.Segment[]; + /** A pagination object, which may be empty, indicating no further pages to fetch. */ + pages?: Record; +} diff --git a/src/api/resources/unstable/types/SingleFilterSearchRequest.ts b/src/api/resources/unstable/types/SingleFilterSearchRequest.ts new file mode 100644 index 00000000..1d1e1613 --- /dev/null +++ b/src/api/resources/unstable/types/SingleFilterSearchRequest.ts @@ -0,0 +1,34 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Search using Intercoms Search APIs with a single filter. + */ +export interface SingleFilterSearchRequest { + /** The accepted field that you want to search on. */ + field?: string; + /** The accepted operators you can use to define how you want to search for the value. */ + operator?: SingleFilterSearchRequest.Operator; + /** The value that you want to search on. */ + value?: SingleFilterSearchRequest.Value; +} + +export namespace SingleFilterSearchRequest { + /** + * The accepted operators you can use to define how you want to search for the value. + */ + export type Operator = "=" | "!=" | "IN" | "NIN" | "<" | ">"; + export const Operator = { + EqualTo: "=", + NotEquals: "!=", + In: "IN", + Nin: "NIN", + LessThan: "<", + GreaterThan: ">", + } as const; + /** + * The value that you want to search on. + */ + export type Value = string | number | (string | number)[]; +} diff --git a/src/api/resources/unstable/types/SlaApplied.ts b/src/api/resources/unstable/types/SlaApplied.ts new file mode 100644 index 00000000..1a7049bb --- /dev/null +++ b/src/api/resources/unstable/types/SlaApplied.ts @@ -0,0 +1,37 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The SLA Applied object contains the details for which SLA has been applied to this conversation. + * Important: if there are any canceled sla_events for the conversation - meaning an SLA has been manually removed from a conversation, the sla_status will always be returned as null. + */ +export interface SlaApplied { + /** object type */ + type?: string; + /** The name of the SLA as given by the teammate when it was created. */ + sla_name?: string; + /** + * SLA statuses: + * - `hit`: If there’s at least one hit event in the underlying sla_events table, and no “missed” or “canceled” events for the conversation. + * - `missed`: If there are any missed sla_events for the conversation and no canceled events. If there’s even a single missed sla event, the status will always be missed. A missed status is not applied when the SLA expires, only the next time a teammate replies. + * - `active`: An SLA has been applied to a conversation, but has not yet been fulfilled. SLA status is active only if there are no “hit, “missed”, or “canceled” events. + */ + sla_status?: SlaApplied.SlaStatus; +} + +export namespace SlaApplied { + /** + * SLA statuses: + * - `hit`: If there’s at least one hit event in the underlying sla_events table, and no “missed” or “canceled” events for the conversation. + * - `missed`: If there are any missed sla_events for the conversation and no canceled events. If there’s even a single missed sla event, the status will always be missed. A missed status is not applied when the SLA expires, only the next time a teammate replies. + * - `active`: An SLA has been applied to a conversation, but has not yet been fulfilled. SLA status is active only if there are no “hit, “missed”, or “canceled” events. + */ + export type SlaStatus = "hit" | "missed" | "cancelled" | "active"; + export const SlaStatus = { + Hit: "hit", + Missed: "missed", + Cancelled: "cancelled", + Active: "active", + } as const; +} diff --git a/src/api/resources/unstable/types/SnoozeConversationRequest.ts b/src/api/resources/unstable/types/SnoozeConversationRequest.ts new file mode 100644 index 00000000..25429753 --- /dev/null +++ b/src/api/resources/unstable/types/SnoozeConversationRequest.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Payload of the request to snooze a conversation + */ +export interface SnoozeConversationRequest { + /** The id of the admin who is performing the action. */ + admin_id: string; + /** The time you want the conversation to reopen. */ + snoozed_until: number; +} diff --git a/src/api/resources/unstable/types/SocialProfile.ts b/src/api/resources/unstable/types/SocialProfile.ts new file mode 100644 index 00000000..3598c433 --- /dev/null +++ b/src/api/resources/unstable/types/SocialProfile.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A Social Profile allows you to label your contacts, companies, and conversations and list them using that Social Profile. + */ +export interface SocialProfile { + /** value is "social_profile" */ + type?: string; + /** The name of the Social media profile */ + name?: string; + /** The name of the Social media profile */ + url?: string; +} diff --git a/src/api/resources/unstable/types/StartingAfterPaging.ts b/src/api/resources/unstable/types/StartingAfterPaging.ts new file mode 100644 index 00000000..e2d31e3f --- /dev/null +++ b/src/api/resources/unstable/types/StartingAfterPaging.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface StartingAfterPaging { + /** The number of results to fetch per page. */ + per_page?: number; + /** The cursor to use in the next request to get the next page of results. */ + starting_after?: string; +} diff --git a/src/api/resources/unstable/types/SubscriptionTypeList.ts b/src/api/resources/unstable/types/SubscriptionTypeList.ts new file mode 100644 index 00000000..3aa55e5c --- /dev/null +++ b/src/api/resources/unstable/types/SubscriptionTypeList.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * A list of subscription type objects. + */ +export interface SubscriptionTypeList { + /** The type of the object */ + type?: "list"; + /** A list of subscription type objects associated with the workspace . */ + data?: Intercom.unstable.SubscriptionType[]; +} diff --git a/src/api/resources/unstable/types/TagCompanyRequest.ts b/src/api/resources/unstable/types/TagCompanyRequest.ts new file mode 100644 index 00000000..23231949 --- /dev/null +++ b/src/api/resources/unstable/types/TagCompanyRequest.ts @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * You can tag a single company or a list of companies. + */ +export interface TagCompanyRequest { + /** The name of the tag, which will be created if not found. */ + name: string; + /** The id or company_id of the company can be passed as input parameters. */ + companies: TagCompanyRequest.Companies.Item[]; +} + +export namespace TagCompanyRequest { + export type Companies = Companies.Item[]; + + export namespace Companies { + export interface Item { + /** The Intercom defined id representing the company. */ + id?: string; + /** The company id you have defined for the company. */ + company_id?: string; + } + } +} diff --git a/src/api/resources/unstable/types/TagList.ts b/src/api/resources/unstable/types/TagList.ts new file mode 100644 index 00000000..f42df4b4 --- /dev/null +++ b/src/api/resources/unstable/types/TagList.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * A list of tags objects in the workspace. + */ +export interface TagList { + /** The type of the object */ + type?: "list"; + /** A list of tags objects associated with the workspace . */ + data?: Intercom.unstable.Tag[]; +} diff --git a/src/api/resources/unstable/types/TagMultipleUsersRequest.ts b/src/api/resources/unstable/types/TagMultipleUsersRequest.ts new file mode 100644 index 00000000..df2f72b2 --- /dev/null +++ b/src/api/resources/unstable/types/TagMultipleUsersRequest.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * You can tag a list of users. + */ +export interface TagMultipleUsersRequest { + /** The name of the tag, which will be created if not found. */ + name: string; + users: TagMultipleUsersRequest.Users.Item[]; +} + +export namespace TagMultipleUsersRequest { + export type Users = Users.Item[]; + + export namespace Users { + export interface Item { + /** The Intercom defined id representing the user. */ + id?: string; + } + } +} diff --git a/src/api/resources/unstable/types/Tags.ts b/src/api/resources/unstable/types/Tags.ts new file mode 100644 index 00000000..980aba63 --- /dev/null +++ b/src/api/resources/unstable/types/Tags.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * A list of tags objects associated with a conversation + */ +export interface Tags { + /** The type of the object */ + type?: "tag.list"; + /** A list of tags objects associated with the conversation. */ + tags?: Intercom.unstable.Tag[]; +} diff --git a/src/api/resources/unstable/types/TeamList.ts b/src/api/resources/unstable/types/TeamList.ts new file mode 100644 index 00000000..6728f16f --- /dev/null +++ b/src/api/resources/unstable/types/TeamList.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * This will return a list of team objects for the App. + */ +export interface TeamList { + /** The type of the object */ + type?: "team.list"; + /** A list of team objects */ + teams?: Intercom.unstable.Team[]; +} diff --git a/src/api/resources/unstable/types/TeamPriorityLevel.ts b/src/api/resources/unstable/types/TeamPriorityLevel.ts new file mode 100644 index 00000000..b979fa1d --- /dev/null +++ b/src/api/resources/unstable/types/TeamPriorityLevel.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Admin priority levels for teams + */ +export interface TeamPriorityLevel { + /** The primary team ids for the team */ + primary_team_ids?: number[]; + /** The secondary team ids for the team */ + secondary_team_ids?: number[]; +} diff --git a/src/api/resources/unstable/types/TicketCustomAttributes.ts b/src/api/resources/unstable/types/TicketCustomAttributes.ts new file mode 100644 index 00000000..50eb281d --- /dev/null +++ b/src/api/resources/unstable/types/TicketCustomAttributes.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * An object containing the different attributes associated to the ticket as key-value pairs. For the default title and description attributes, the keys are `_default_title_` and `_default_description_`. + */ +export type TicketCustomAttributes = Record; + +export namespace TicketCustomAttributes { + export type Value = string | undefined | number | boolean | unknown[] | Intercom.unstable.FileAttribute; +} diff --git a/src/api/resources/unstable/types/TicketList.ts b/src/api/resources/unstable/types/TicketList.ts new file mode 100644 index 00000000..0457d26e --- /dev/null +++ b/src/api/resources/unstable/types/TicketList.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * Tickets are how you track requests from your users. + */ +export interface TicketList { + /** Always ticket.list */ + type?: "ticket.list"; + /** The list of ticket objects */ + tickets?: (Intercom.unstable.Ticket | undefined)[]; + /** A count of the total number of objects. */ + total_count?: number; + pages?: Intercom.unstable.CursorPages; +} diff --git a/src/api/resources/unstable/types/TicketPartAuthor.ts b/src/api/resources/unstable/types/TicketPartAuthor.ts new file mode 100644 index 00000000..6dc2eb3b --- /dev/null +++ b/src/api/resources/unstable/types/TicketPartAuthor.ts @@ -0,0 +1,30 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The author that wrote or triggered the part. Can be a bot, admin, team or user. + */ +export interface TicketPartAuthor { + /** The type of the author */ + type?: TicketPartAuthor.Type; + /** The id of the author */ + id?: string; + /** The name of the author */ + name?: string; + /** The email of the author */ + email?: string; +} + +export namespace TicketPartAuthor { + /** + * The type of the author + */ + export type Type = "admin" | "bot" | "team" | "user"; + export const Type = { + Admin: "admin", + Bot: "bot", + Team: "team", + User: "user", + } as const; +} diff --git a/src/api/resources/unstable/types/TicketParts.ts b/src/api/resources/unstable/types/TicketParts.ts new file mode 100644 index 00000000..f4847b22 --- /dev/null +++ b/src/api/resources/unstable/types/TicketParts.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * A list of Ticket Part objects for each note and event in the ticket. There is a limit of 500 parts. + */ +export interface TicketParts { + /** */ + type?: "ticket_part.list"; + /** A list of Ticket Part objects for each ticket. There is a limit of 500 parts. */ + ticket_parts?: Intercom.unstable.TicketPart[]; + /** */ + total_count?: number; +} diff --git a/src/api/resources/unstable/types/TicketReply.ts b/src/api/resources/unstable/types/TicketReply.ts new file mode 100644 index 00000000..d1e66754 --- /dev/null +++ b/src/api/resources/unstable/types/TicketReply.ts @@ -0,0 +1,40 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * A Ticket Part representing a note, comment, or quick_reply on a ticket + */ +export interface TicketReply { + /** Always ticket_part */ + type?: "ticket_part"; + /** The id representing the part. */ + id?: string; + /** Type of the part */ + part_type?: TicketReply.PartType; + /** The message body, which may contain HTML. */ + body?: string; + /** The time the note was created. */ + created_at?: number; + /** The last time the note was updated. */ + updated_at?: number; + author?: Intercom.unstable.TicketPartAuthor; + /** A list of attachments for the part. */ + attachments?: Intercom.unstable.PartAttachment[]; + /** Whether or not the ticket part has been redacted. */ + redacted?: boolean; +} + +export namespace TicketReply { + /** + * Type of the part + */ + export type PartType = "note" | "comment" | "quick_reply"; + export const PartType = { + Note: "note", + Comment: "comment", + QuickReply: "quick_reply", + } as const; +} diff --git a/src/api/resources/unstable/types/TicketRequestCustomAttributes.ts b/src/api/resources/unstable/types/TicketRequestCustomAttributes.ts new file mode 100644 index 00000000..6a3af042 --- /dev/null +++ b/src/api/resources/unstable/types/TicketRequestCustomAttributes.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The attributes set on the ticket. When setting the default title and description attributes, the attribute keys that should be used are `_default_title_` and `_default_description_`. When setting ticket type attributes of the list attribute type, the key should be the attribute name and the value of the attribute should be the list item id, obtainable by [listing the ticket type](ref:get_ticket-types). For example, if the ticket type has an attribute called `priority` of type `list`, the key should be `priority` and the value of the attribute should be the guid of the list item (e.g. `de1825a0-0164-4070-8ca6-13e22462fa7e`). + */ +export type TicketRequestCustomAttributes = Record; + +export namespace TicketRequestCustomAttributes { + export type Value = string | undefined | number | boolean | unknown[]; +} diff --git a/src/api/resources/unstable/types/TicketStateList.ts b/src/api/resources/unstable/types/TicketStateList.ts new file mode 100644 index 00000000..7e3bfbe6 --- /dev/null +++ b/src/api/resources/unstable/types/TicketStateList.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * A list of ticket states associated with a given ticket type. + */ +export interface TicketStateList { + /** String representing the object's type. Always has the value `list`. */ + type?: string; + /** A list of ticket states associated with a given ticket type. */ + data?: (Intercom.unstable.TicketStateDetailed | undefined)[]; +} diff --git a/src/api/resources/unstable/types/TicketTypeAttribute.ts b/src/api/resources/unstable/types/TicketTypeAttribute.ts new file mode 100644 index 00000000..269e5f99 --- /dev/null +++ b/src/api/resources/unstable/types/TicketTypeAttribute.ts @@ -0,0 +1,43 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Ticket type attribute, used to define each data field to be captured in a ticket. + */ +export interface TicketTypeAttribute { + /** String representing the object's type. Always has the value `ticket_type_attribute`. */ + type?: string; + /** The id representing the ticket type attribute. */ + id?: string; + /** The id of the workspace that the ticket type attribute belongs to. */ + workspace_id?: string; + /** The name of the ticket type attribute */ + name?: string; + /** The description of the ticket type attribute */ + description?: string; + /** The type of the data attribute (allowed values: "string list integer decimal boolean datetime files") */ + data_type?: string; + /** Input options for the attribute */ + input_options?: Record; + /** The order of the attribute against other attributes */ + order?: number; + /** Whether the attribute is required or not for teammates. */ + required_to_create?: boolean; + /** Whether the attribute is required or not for contacts. */ + required_to_create_for_contacts?: boolean; + /** Whether the attribute is visible or not to teammates. */ + visible_on_create?: boolean; + /** Whether the attribute is visible or not to contacts. */ + visible_to_contacts?: boolean; + /** Whether the attribute is built in or not. */ + default?: boolean; + /** The id of the ticket type that the attribute belongs to. */ + ticket_type_id?: number; + /** Whether the ticket type attribute is archived or not. */ + archived?: boolean; + /** The date and time the ticket type attribute was created. */ + created_at?: number; + /** The date and time the ticket type attribute was last updated. */ + updated_at?: number; +} diff --git a/src/api/resources/unstable/types/TicketTypeAttributeList.ts b/src/api/resources/unstable/types/TicketTypeAttributeList.ts new file mode 100644 index 00000000..ed242103 --- /dev/null +++ b/src/api/resources/unstable/types/TicketTypeAttributeList.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * A list of attributes associated with a given ticket type. + */ +export interface TicketTypeAttributeList { + /** String representing the object's type. Always has the value `ticket_type_attributes.list`. */ + type?: string; + /** A list of ticket type attributes associated with a given ticket type. */ + ticket_type_attributes?: (Intercom.unstable.TicketTypeAttribute | undefined)[]; +} diff --git a/src/api/resources/unstable/types/TicketTypeList.ts b/src/api/resources/unstable/types/TicketTypeList.ts new file mode 100644 index 00000000..572085e6 --- /dev/null +++ b/src/api/resources/unstable/types/TicketTypeList.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * A list of ticket types associated with a given workspace. + */ +export interface TicketTypeList { + /** String representing the object's type. Always has the value `list`. */ + type?: string; + /** A list of ticket_types associated with a given workspace. */ + data?: (Intercom.unstable.TicketType | undefined)[]; +} diff --git a/src/api/resources/unstable/types/Translation.ts b/src/api/resources/unstable/types/Translation.ts new file mode 100644 index 00000000..9807efeb --- /dev/null +++ b/src/api/resources/unstable/types/Translation.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * A translation object contains the localised details of a subscription type. + */ +export interface Translation { + /** The localised name of the subscription type. */ + name?: string; + /** The localised description of the subscription type. */ + description?: string; + /** The two character identifier for the language of the translation object. */ + locale?: string; +} diff --git a/src/api/resources/unstable/types/UntagCompanyRequest.ts b/src/api/resources/unstable/types/UntagCompanyRequest.ts new file mode 100644 index 00000000..b970ebc4 --- /dev/null +++ b/src/api/resources/unstable/types/UntagCompanyRequest.ts @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * You can tag a single company or a list of companies. + */ +export interface UntagCompanyRequest { + /** The name of the tag which will be untagged from the company */ + name: string; + /** The id or company_id of the company can be passed as input parameters. */ + companies: UntagCompanyRequest.Companies.Item[]; +} + +export namespace UntagCompanyRequest { + export type Companies = Companies.Item[]; + + export namespace Companies { + export interface Item { + /** The Intercom defined id representing the company. */ + id?: string; + /** The company id you have defined for the company. */ + company_id?: string; + /** Always set to true */ + untag?: boolean; + } + } +} diff --git a/src/api/resources/unstable/types/UpdateArticleRequestBody.ts b/src/api/resources/unstable/types/UpdateArticleRequestBody.ts new file mode 100644 index 00000000..09be43a9 --- /dev/null +++ b/src/api/resources/unstable/types/UpdateArticleRequestBody.ts @@ -0,0 +1,37 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * You can Update an Article + */ +export interface UpdateArticleRequestBody { + /** The title of the article.For multilingual articles, this will be the title of the default language's content. */ + title?: string; + /** The description of the article. For multilingual articles, this will be the description of the default language's content. */ + description?: string; + /** The content of the article. For multilingual articles, this will be the body of the default language's content. */ + body?: string; + /** The id of the author of the article. For multilingual articles, this will be the id of the author of the default language's content. Must be a teammate on the help center's workspace. */ + author_id?: number; + /** 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. */ + state?: UpdateArticleRequestBody.State; + /** The id of the article's parent collection or section. An article without this field stands alone. */ + parent_id?: string; + /** The type of parent, which can either be a `collection` or `section`. */ + parent_type?: string; + translated_content?: Intercom.unstable.ArticleTranslatedContent; +} + +export namespace UpdateArticleRequestBody { + /** + * 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. + */ + export type State = "published" | "draft"; + export const State = { + Published: "published", + Draft: "draft", + } as const; +} diff --git a/src/api/resources/unstable/types/UpdateTicketTypeRequestBody.ts b/src/api/resources/unstable/types/UpdateTicketTypeRequestBody.ts new file mode 100644 index 00000000..2eca441d --- /dev/null +++ b/src/api/resources/unstable/types/UpdateTicketTypeRequestBody.ts @@ -0,0 +1,34 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The request payload for updating a ticket type. + * You can copy the `icon` property for your ticket type from [Twemoji Cheatsheet](https://twemoji-cheatsheet.vercel.app/) + */ +export interface UpdateTicketTypeRequestBody { + /** The name of the ticket type. */ + name?: string; + /** The description of the ticket type. */ + description?: string; + /** Category of the Ticket Type. */ + category?: UpdateTicketTypeRequestBody.Category; + /** The icon of the ticket type. */ + icon?: string; + /** The archived status of the ticket type. */ + archived?: boolean; + /** Whether the tickets associated with this ticket type are intended for internal use only or will be shared with customers. This is currently a limited attribute. */ + is_internal?: boolean; +} + +export namespace UpdateTicketTypeRequestBody { + /** + * Category of the Ticket Type. + */ + export type Category = "Customer" | "Back-office" | "Tracker"; + export const Category = { + Customer: "Customer", + BackOffice: "Back-office", + Tracker: "Tracker", + } as const; +} diff --git a/src/api/resources/unstable/types/Visitor.ts b/src/api/resources/unstable/types/Visitor.ts new file mode 100644 index 00000000..272de16a --- /dev/null +++ b/src/api/resources/unstable/types/Visitor.ts @@ -0,0 +1,138 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../../../index"; + +/** + * Visitors are useful for representing anonymous people that have not yet been identified. They usually represent website visitors. Visitors are not visible in Intercom platform. The Visitors resource provides methods to fetch, update, convert and delete. + */ +export interface Visitor { + /** Value is 'visitor' */ + type?: string; + /** The Intercom defined id representing the Visitor. */ + id?: string; + /** Automatically generated identifier for the Visitor. */ + user_id?: string; + /** Identifies if this visitor is anonymous. */ + anonymous?: boolean; + /** The email of the visitor. */ + email?: string; + /** The phone number of the visitor. */ + phone?: string; + /** The name of the visitor. */ + name?: string; + /** The pseudonym of the visitor. */ + pseudonym?: string; + avatar?: Visitor.Avatar; + /** The id of the app the visitor is associated with. */ + app_id?: string; + companies?: Visitor.Companies; + location_data?: Visitor.LocationData; + /** The time the Lead last recorded making a request. */ + las_request_at?: number; + /** The time the Visitor was added to Intercom. */ + created_at?: number; + /** The time the Visitor was added to Intercom. */ + remote_created_at?: number; + /** The time the Visitor signed up for your product. */ + signed_up_at?: number; + /** The last time the Visitor was updated. */ + updated_at?: number; + /** The number of sessions the Visitor has had. */ + session_count?: number; + social_profiles?: Visitor.SocialProfiles; + /** The id of the admin that owns the Visitor. */ + owner_id?: string; + /** Whether the Visitor is unsubscribed from emails. */ + unsubscribed_from_emails?: boolean; + /** Identifies if this visitor has marked an email as spam. */ + marked_email_as_spam?: boolean; + /** Identifies if this visitor has had a hard bounce. */ + has_hard_bounced?: boolean; + tags?: Visitor.Tags; + segments?: Visitor.Segments; + /** The custom attributes you have set on the Visitor. */ + custom_attributes?: Record; + /** The referer of the visitor. */ + referrer?: string; + /** The utm_campaign of the visitor. */ + utm_campaign?: string; + /** The utm_content of the visitor. */ + utm_content?: string; + /** The utm_medium of the visitor. */ + utm_medium?: string; + /** The utm_source of the visitor. */ + utm_source?: string; + /** The utm_term of the visitor. */ + utm_term?: string; + /** Identifies if this visitor has do not track enabled. */ + do_not_track?: boolean; +} + +export namespace Visitor { + export interface Avatar { + /** */ + type?: string; + /** This object represents the avatar associated with the visitor. */ + image_url?: string; + } + + export interface Companies { + /** The type of the object */ + type?: "company.list"; + companies?: Intercom.unstable.Company[]; + } + + export interface LocationData { + /** */ + type?: string; + /** The city name of the visitor. */ + city_name?: string; + /** The continent code of the visitor. */ + continent_code?: string; + /** The country code of the visitor. */ + country_code?: string; + /** The country name of the visitor. */ + country_name?: string; + /** The postal code of the visitor. */ + postal_code?: string; + /** The region name of the visitor. */ + region_name?: string; + /** The timezone of the visitor. */ + timezone?: string; + } + + export interface SocialProfiles { + /** The type of the object */ + type?: "social_profile.list"; + social_profiles?: string[]; + } + + export interface Tags { + /** The type of the object */ + type?: "tag.list"; + tags?: Tags.Tags.Item[]; + } + + export namespace Tags { + export type Tags = Tags.Item[]; + + export namespace Tags { + export interface Item { + /** The type of the object */ + type?: "tag"; + /** The id of the tag. */ + id?: string; + /** The name of the tag. */ + name?: string; + } + } + } + + export interface Segments { + /** The type of the object */ + type?: "segment.list"; + segments?: string[]; + } +} diff --git a/src/api/resources/unstable/types/VisitorDeletedObject.ts b/src/api/resources/unstable/types/VisitorDeletedObject.ts new file mode 100644 index 00000000..6d2dcfd3 --- /dev/null +++ b/src/api/resources/unstable/types/VisitorDeletedObject.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * Response returned when an object is deleted + */ +export interface VisitorDeletedObject { + /** The unique identifier for the visitor which is given by Intercom. */ + id?: string; + /** The type of object which was deleted */ + type?: "visitor"; + /** Automatically generated identifier for the Visitor. */ + user_id?: string; +} diff --git a/src/api/resources/unstable/types/WhatsappMessageStatusList.ts b/src/api/resources/unstable/types/WhatsappMessageStatusList.ts new file mode 100644 index 00000000..71377c21 --- /dev/null +++ b/src/api/resources/unstable/types/WhatsappMessageStatusList.ts @@ -0,0 +1,71 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface WhatsappMessageStatusList { + type: "list"; + /** The provided ruleset ID */ + ruleset_id: string; + pages: WhatsappMessageStatusList.Pages; + /** Total number of events */ + total_count: number; + events: WhatsappMessageStatusList.Events.Item[]; +} + +export namespace WhatsappMessageStatusList { + export interface Pages { + type: "pages"; + /** Number of results per page */ + per_page: number; + /** Total number of pages */ + total_pages: number; + /** Information for fetching next page (null if no more pages) */ + next?: Pages.Next; + } + + export namespace Pages { + /** + * Information for fetching next page (null if no more pages) + */ + export interface Next { + /** Cursor for the next page */ + starting_after?: string; + } + } + + export type Events = Events.Item[]; + + export namespace Events { + export interface Item { + /** Event ID */ + id: string; + /** ID of the conversation */ + conversation_id: string; + /** Current status of the message */ + status: Item.Status; + /** Event type */ + type: "broadcast_outbound"; + /** Creation timestamp */ + created_at: number; + /** Last update timestamp */ + updated_at: number; + /** WhatsApp's message identifier */ + whatsapp_message_id: string; + /** Name of the WhatsApp template used */ + template_name?: string; + } + + export namespace Item { + /** + * Current status of the message + */ + export type Status = "sent" | "delivered" | "read" | "failed"; + export const Status = { + Sent: "sent", + Delivered: "delivered", + Read: "read", + Failed: "failed", + } as const; + } + } +} diff --git a/src/api/resources/unstable/types/index.ts b/src/api/resources/unstable/types/index.ts new file mode 100644 index 00000000..129ed3c6 --- /dev/null +++ b/src/api/resources/unstable/types/index.ts @@ -0,0 +1,145 @@ +export * from "./NotFoundErrorBody"; +export * from "./Datetime"; +export * from "./ActivityLog"; +export * from "./ActivityLogList"; +export * from "./ActivityLogMetadata"; +export * from "./AddressableList"; +export * from "./AdminList"; +export * from "./AdminPriorityLevel"; +export * from "./AdminReplyConversationRequest"; +export * from "./AdminReplyTicketRequest"; +export * from "./AdminWithApp"; +export * from "./App"; +export * from "./ArticleContent"; +export * from "./ArticleList"; +export * from "./ArticleStatistics"; +export * from "./ArticleTranslatedContent"; +export * from "./AssignConversationRequest"; +export * from "./AwayStatusReason"; +export * from "./CloseConversationRequest"; +export * from "./CollectionList"; +export * from "./CompanyAttachedContacts"; +export * from "./CompanyAttachedSegments"; +export * from "./CompanyList"; +export * from "./CompanyScroll"; +export * from "./ContactAttachedCompanies"; +export * from "./ContactCompanies"; +export * from "./CompanyData"; +export * from "./ContactDeleted"; +export * from "./ContactList"; +export * from "./ContactLocation"; +export * from "./ContactNotes"; +export * from "./ContactReference"; +export * from "./ContactReplyBaseRequest"; +export * from "./ContactReplyConversationRequest"; +export * from "./ContactReplyEmailRequest"; +export * from "./ContactReplyIntercomUserIdRequest"; +export * from "./ContactReplyTicketEmailRequest"; +export * from "./ContactReplyTicketIntercomUserIdRequest"; +export * from "./ContactReplyTicketRequest"; +export * from "./ContactReplyTicketUserIdRequest"; +export * from "./ContactReplyUserIdRequest"; +export * from "./ContactSegments"; +export * from "./ContactSocialProfiles"; +export * from "./ContactSubscriptionTypes"; +export * from "./ContactTags"; +export * from "./ContactArchived"; +export * from "./ContactUnarchived"; +export * from "./ContactBlocked"; +export * from "./ContentSourcesList"; +export * from "./ConversationAttachmentFiles"; +export * from "./ConversationContacts"; +export * from "./ConversationDeleted"; +export * from "./ConversationFirstContactReply"; +export * from "./ConversationList"; +export * from "./ConversationPart"; +export * from "./ConversationPartAuthor"; +export * from "./ConversationParts"; +export * from "./ConversationPartMetadata"; +export * from "./ConversationRating"; +export * from "./ConversationResponseTime"; +export * from "./ConversationSource"; +export * from "./ConversationStatistics"; +export * from "./ConversationTeammates"; +export * from "./Recipient"; +export * from "./CreateOrUpdateTagRequest"; +export * from "./CreateTicketReplyWithCommentRequest"; +export * from "./CreateTicketRequestBody"; +export * from "./CursorPages"; +export * from "./CustomAttributes"; +export * from "./CustomObjectInstanceDeleted"; +export * from "./CustomObjectInstanceList"; +export * from "./CustomerRequest"; +export * from "./DataAttributeList"; +export * from "./DataEventList"; +export * from "./DataEventSummary"; +export * from "./DataEventSummaryItem"; +export * from "./DataExportCsv"; +export * from "./DeletedArticleObject"; +export * from "./DeletedCollectionObject"; +export * from "./DeletedCompanyObject"; +export * from "./DeletedObject"; +export * from "./EmailAddressHeader"; +export * from "./EmailMessageMetadata"; +export * from "./ConversationAttributeUpdatedByWorkflow"; +export * from "./ConversationAttributeUpdatedByAdmin"; +export * from "./CustomActionStarted"; +export * from "./CustomChannelAttribute"; +export * from "./CustomChannelBaseEvent"; +export * from "./CustomChannelContact"; +export * from "./CustomChannelNotificationResponse"; +export * from "./CustomActionFinished"; +export * from "./OperatorWorkflowEvent"; +export * from "./EventDetails"; +export * from "./Error_"; +export * from "./FileAttribute"; +export * from "./GroupContent"; +export * from "./GroupTranslatedContent"; +export * from "./IntercomVersion"; +export * from "./LinkedObject"; +export * from "./IntercomVersionUnstable"; +export * from "./LinkedObjectList"; +export * from "./WhatsappMessageStatusList"; +export * from "./MultipleFilterSearchRequest"; +export * from "./NewsItemRequest"; +export * from "./NoteList"; +export * from "./OpenConversationRequest"; +export * from "./PagesLink"; +export * from "./PaginatedResponseDataItem"; +export * from "./PaginatedResponse"; +export * from "./PartAttachment"; +export * from "./PhoneSwitch"; +export * from "./QuickReplyOption"; +export * from "./RedactConversationRequest"; +export * from "./Reference"; +export * from "./ReplyConversationRequestBody"; +export * from "./SearchRequest"; +export * from "./SegmentList"; +export * from "./SingleFilterSearchRequest"; +export * from "./SlaApplied"; +export * from "./SnoozeConversationRequest"; +export * from "./SocialProfile"; +export * from "./StartingAfterPaging"; +export * from "./SubscriptionTypeList"; +export * from "./TagCompanyRequest"; +export * from "./TagList"; +export * from "./TagMultipleUsersRequest"; +export * from "./Tags"; +export * from "./TeamList"; +export * from "./TeamPriorityLevel"; +export * from "./TicketCustomAttributes"; +export * from "./TicketList"; +export * from "./TicketPartAuthor"; +export * from "./TicketParts"; +export * from "./TicketReply"; +export * from "./TicketRequestCustomAttributes"; +export * from "./TicketStateList"; +export * from "./TicketTypeAttribute"; +export * from "./TicketTypeAttributeList"; +export * from "./TicketTypeList"; +export * from "./Translation"; +export * from "./UntagCompanyRequest"; +export * from "./UpdateArticleRequestBody"; +export * from "./UpdateTicketTypeRequestBody"; +export * from "./Visitor"; +export * from "./VisitorDeletedObject"; diff --git a/src/api/resources/visitors/client/Client.ts b/src/api/resources/visitors/client/Client.ts index 531cd2a7..e18896e6 100644 --- a/src/api/resources/visitors/client/Client.ts +++ b/src/api/resources/visitors/client/Client.ts @@ -89,10 +89,17 @@ export class Visitors { * user_id: "user_id" * }) */ - public async find( + public find( request: Intercom.FindVisitorRequest, requestOptions?: Visitors.RequestOptions, - ): Promise { + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__find(request, requestOptions)); + } + + private async __find( + request: Intercom.FindVisitorRequest, + requestOptions?: Visitors.RequestOptions, + ): Promise> { const { user_id: userId } = request; const _queryParams: Record = {}; _queryParams["user_id"] = userId; @@ -108,8 +115,8 @@ export class Visitors { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -123,19 +130,23 @@ export class Visitors { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Visitor; + return { data: _response.body as Intercom.Visitor, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -145,12 +156,14 @@ export class Visitors { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling GET /visitors."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -180,10 +193,17 @@ export class Visitors { * name: "Christian Fail" * }) */ - public async update( + public update( + request: Intercom.UpdateVisitorRequest, + requestOptions?: Visitors.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions)); + } + + private async __update( request: Intercom.UpdateVisitorRequest, requestOptions?: Visitors.RequestOptions, - ): Promise { + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -196,8 +216,8 @@ export class Visitors { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -211,19 +231,23 @@ export class Visitors { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Visitor; + return { data: _response.body as Intercom.Visitor, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); case 404: - throw new Intercom.NotFoundError(_response.error.body as unknown); + throw new Intercom.NotFoundError(_response.error.body as unknown, _response.rawResponse); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -233,12 +257,14 @@ export class Visitors { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling PUT /visitors."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } @@ -267,10 +293,17 @@ export class Visitors { * } * }) */ - public async mergeToContact( + public mergeToContact( + request: Intercom.MergeVisitorToContactRequest, + requestOptions?: Visitors.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__mergeToContact(request, requestOptions)); + } + + private async __mergeToContact( request: Intercom.MergeVisitorToContactRequest, requestOptions?: Visitors.RequestOptions, - ): Promise { + ): Promise> { const _response = await (this._options.fetcher ?? core.fetcher)({ url: urlJoin( (await core.Supplier.get(this._options.baseUrl)) ?? @@ -283,8 +316,8 @@ export class Visitors { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "intercom-client", - "X-Fern-SDK-Version": "6.3.0", - "User-Agent": "intercom-client/6.3.0", + "X-Fern-SDK-Version": "6.4.0", + "User-Agent": "intercom-client/6.4.0", "Intercom-Version": requestOptions?.version ?? this._options?.version ?? "2.11", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version, @@ -298,17 +331,21 @@ export class Visitors { abortSignal: requestOptions?.abortSignal, }); if (_response.ok) { - return _response.body as Intercom.Contact; + return { data: _response.body as Intercom.Contact, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: - throw new Intercom.UnauthorizedError(_response.error.body as Intercom.Error_); + throw new Intercom.UnauthorizedError( + _response.error.body as Intercom.Error_, + _response.rawResponse, + ); default: throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.body, + rawResponse: _response.rawResponse, }); } } @@ -318,12 +355,14 @@ export class Visitors { throw new errors.IntercomError({ statusCode: _response.error.statusCode, body: _response.error.rawBody, + rawResponse: _response.rawResponse, }); case "timeout": throw new errors.IntercomTimeoutError("Timeout exceeded when calling POST /visitors/convert."); case "unknown": throw new errors.IntercomError({ message: _response.error.errorMessage, + rawResponse: _response.rawResponse, }); } } diff --git a/src/api/types/CreateContactRequestTwo.ts b/src/api/types/CreateContactRequestTwo.ts new file mode 100644 index 00000000..b3041530 --- /dev/null +++ b/src/api/types/CreateContactRequestTwo.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type CreateContactRequestTwo = unknown; diff --git a/src/api/types/CreateDataEventRequestTwo.ts b/src/api/types/CreateDataEventRequestTwo.ts new file mode 100644 index 00000000..5eb4bbe5 --- /dev/null +++ b/src/api/types/CreateDataEventRequestTwo.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type CreateDataEventRequestTwo = unknown; diff --git a/src/api/types/CreateMessageRequestTwo.ts b/src/api/types/CreateMessageRequestTwo.ts new file mode 100644 index 00000000..1c075b32 --- /dev/null +++ b/src/api/types/CreateMessageRequestTwo.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type CreateMessageRequestTwo = unknown; diff --git a/src/api/resources/tickets/client/requests/CreateTicketRequest.ts b/src/api/types/CreateTicketRequest.ts similarity index 74% rename from src/api/resources/tickets/client/requests/CreateTicketRequest.ts rename to src/api/types/CreateTicketRequest.ts index db4974e5..272de2b7 100644 --- a/src/api/resources/tickets/client/requests/CreateTicketRequest.ts +++ b/src/api/types/CreateTicketRequest.ts @@ -2,20 +2,10 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as Intercom from "../../../../index"; +import * as Intercom from "../index"; /** - * @example - * { - * ticket_type_id: "1234", - * contacts: [{ - * id: "667d61b78a68186f43bafe8d" - * }], - * ticket_attributes: { - * "_default_title_": "example", - * "_default_description_": "there is a problem" - * } - * } + * You can create a Ticket */ export interface CreateTicketRequest { /** The ID of the type of ticket you want to create */ diff --git a/src/api/types/Metadata.ts b/src/api/types/Metadata.ts new file mode 100644 index 00000000..1c29cca9 --- /dev/null +++ b/src/api/types/Metadata.ts @@ -0,0 +1,7 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Intercom from "../index"; + +export type Metadata = Intercom.unstable.ConversationPartMetadata; diff --git a/src/api/types/UpdateVisitorRequestOne.ts b/src/api/types/UpdateVisitorRequestOne.ts new file mode 100644 index 00000000..67858b8e --- /dev/null +++ b/src/api/types/UpdateVisitorRequestOne.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type UpdateVisitorRequestOne = unknown; diff --git a/src/api/types/index.ts b/src/api/types/index.ts index ded80781..2a4c1060 100644 --- a/src/api/types/index.ts +++ b/src/api/types/index.ts @@ -69,6 +69,7 @@ export * from "./CreateDataEventRequest"; export * from "./CreateMessageRequest"; export * from "./CreateOrUpdateTagRequest"; export * from "./CreateTicketReplyWithCommentRequest"; +export * from "./CreateTicketRequest"; export * from "./CurrentCanvas"; export * from "./CursorPages"; export * from "./CustomerRequest"; @@ -157,3 +158,8 @@ export * from "./Visitor"; export * from "./VisitorDeletedObject"; export * from "./CustomAttributes"; export * from "./OffsetPages"; +export * from "./CreateContactRequestTwo"; +export * from "./CreateDataEventRequestTwo"; +export * from "./CreateMessageRequestTwo"; +export * from "./Metadata"; +export * from "./UpdateVisitorRequestOne"; diff --git a/src/core/fetcher/APIResponse.ts b/src/core/fetcher/APIResponse.ts index 3664d09e..6335291b 100644 --- a/src/core/fetcher/APIResponse.ts +++ b/src/core/fetcher/APIResponse.ts @@ -1,12 +1,23 @@ +import { RawResponse } from "./RawResponse"; + +/** + * The response of an API call. + * It is a successful response or a failed response. + */ export type APIResponse = SuccessfulResponse | FailedResponse; export interface SuccessfulResponse { ok: true; body: T; + /** + * @deprecated Use `rawResponse` instead + */ headers?: Record; + rawResponse: RawResponse; } export interface FailedResponse { ok: false; error: T; + rawResponse: RawResponse; } diff --git a/src/core/fetcher/Fetcher.ts b/src/core/fetcher/Fetcher.ts index f3ee18ee..336ee10b 100644 --- a/src/core/fetcher/Fetcher.ts +++ b/src/core/fetcher/Fetcher.ts @@ -1,5 +1,6 @@ import { toJson } from "../json"; import { APIResponse } from "./APIResponse"; +import { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse"; import { createRequestUrl } from "./createRequestUrl"; import { getFetchFn } from "./getFetchFn"; import { getRequestBody } from "./getRequestBody"; @@ -94,6 +95,7 @@ export async function fetcherImpl(args: Fetcher.Args): Promise(args: Fetcher.Args): Promise(args: Fetcher.Args): Promise(args: Fetcher.Args): Promise(args: Fetcher.Args): Promise(args: Fetcher.Args): Promise; + + constructor(init?: HeadersInit) { + this.headers = new Map(); + + if (init) { + if (init instanceof Headers) { + init.forEach((value, key) => this.append(key, value)); + } else if (Array.isArray(init)) { + for (const [key, value] of init) { + if (typeof key === "string" && typeof value === "string") { + this.append(key, value); + } else { + throw new TypeError("Each header entry must be a [string, string] tuple"); + } + } + } else { + for (const [key, value] of Object.entries(init)) { + if (typeof value === "string") { + this.append(key, value); + } else { + throw new TypeError("Header values must be strings"); + } + } + } + } + } + + append(name: string, value: string): void { + const key = name.toLowerCase(); + const existing = this.headers.get(key) || []; + this.headers.set(key, [...existing, value]); + } + + delete(name: string): void { + const key = name.toLowerCase(); + this.headers.delete(key); + } + + get(name: string): string | null { + const key = name.toLowerCase(); + const values = this.headers.get(key); + return values ? values.join(", ") : null; + } + + has(name: string): boolean { + const key = name.toLowerCase(); + return this.headers.has(key); + } + + set(name: string, value: string): void { + const key = name.toLowerCase(); + this.headers.set(key, [value]); + } + + forEach(callbackfn: (value: string, key: string, parent: Headers) => void, thisArg?: unknown): void { + const boundCallback = thisArg ? callbackfn.bind(thisArg) : callbackfn; + this.headers.forEach((values, key) => boundCallback(values.join(", "), key, this)); + } + + getSetCookie(): string[] { + return this.headers.get("set-cookie") || []; + } + + *entries(): HeadersIterator<[string, string]> { + for (const [key, values] of this.headers.entries()) { + yield [key, values.join(", ")]; + } + } + + *keys(): HeadersIterator { + yield* this.headers.keys(); + } + + *values(): HeadersIterator { + for (const values of this.headers.values()) { + yield values.join(", "); + } + } + + [Symbol.iterator](): HeadersIterator<[string, string]> { + return this.entries(); + } + }; +} + +export { Headers }; diff --git a/src/core/fetcher/HttpResponsePromise.ts b/src/core/fetcher/HttpResponsePromise.ts new file mode 100644 index 00000000..6b0bc4fc --- /dev/null +++ b/src/core/fetcher/HttpResponsePromise.ts @@ -0,0 +1,116 @@ +import { WithRawResponse } from "./RawResponse"; + +/** + * A promise that returns the parsed response and lets you retrieve the raw response too. + */ +export class HttpResponsePromise extends Promise { + private innerPromise: Promise>; + private unwrappedPromise: Promise | undefined; + + private constructor(promise: Promise>) { + // Initialize with a no-op to avoid premature parsing + super((resolve) => { + resolve(undefined as unknown as T); + }); + this.innerPromise = promise; + } + + /** + * Creates an `HttpResponsePromise` from a function that returns a promise. + * + * @param fn - A function that returns a promise resolving to a `WithRawResponse` object. + * @param args - Arguments to pass to the function. + * @returns An `HttpResponsePromise` instance. + */ + public static fromFunction Promise>, T>( + fn: F, + ...args: Parameters + ): HttpResponsePromise { + return new HttpResponsePromise(fn(...args)); + } + + /** + * Creates a function that returns an `HttpResponsePromise` from a function that returns a promise. + * + * @param fn - A function that returns a promise resolving to a `WithRawResponse` object. + * @returns A function that returns an `HttpResponsePromise` instance. + */ + public static interceptFunction< + F extends (...args: never[]) => Promise>, + T = Awaited>["data"], + >(fn: F): (...args: Parameters) => HttpResponsePromise { + return (...args: Parameters): HttpResponsePromise => { + return HttpResponsePromise.fromPromise(fn(...args)); + }; + } + + /** + * Creates an `HttpResponsePromise` from an existing promise. + * + * @param promise - A promise resolving to a `WithRawResponse` object. + * @returns An `HttpResponsePromise` instance. + */ + public static fromPromise(promise: Promise>): HttpResponsePromise { + return new HttpResponsePromise(promise); + } + + /** + * Creates an `HttpResponsePromise` from an executor function. + * + * @param executor - A function that takes resolve and reject callbacks to create a promise. + * @returns An `HttpResponsePromise` instance. + */ + public static fromExecutor( + executor: (resolve: (value: WithRawResponse) => void, reject: (reason?: unknown) => void) => void, + ): HttpResponsePromise { + const promise = new Promise>(executor); + return new HttpResponsePromise(promise); + } + + /** + * Creates an `HttpResponsePromise` from a resolved result. + * + * @param result - A `WithRawResponse` object to resolve immediately. + * @returns An `HttpResponsePromise` instance. + */ + public static fromResult(result: WithRawResponse): HttpResponsePromise { + const promise = Promise.resolve(result); + return new HttpResponsePromise(promise); + } + + private unwrap(): Promise { + if (!this.unwrappedPromise) { + this.unwrappedPromise = this.innerPromise.then(({ data }) => data); + } + return this.unwrappedPromise; + } + + /** @inheritdoc */ + public override then( + onfulfilled?: ((value: T) => TResult1 | PromiseLike) | null, + onrejected?: ((reason: unknown) => TResult2 | PromiseLike) | null, + ): Promise { + return this.unwrap().then(onfulfilled, onrejected); + } + + /** @inheritdoc */ + public override catch( + onrejected?: ((reason: unknown) => TResult | PromiseLike) | null, + ): Promise { + return this.unwrap().catch(onrejected); + } + + /** @inheritdoc */ + public override finally(onfinally?: (() => void) | null): Promise { + return this.unwrap().finally(onfinally); + } + + /** + * Retrieves the data and raw response. + * + * @returns A promise resolving to a `WithRawResponse` object. + */ + public async withRawResponse(): Promise> { + return await this.innerPromise; + } +} diff --git a/src/core/fetcher/RawResponse.ts b/src/core/fetcher/RawResponse.ts new file mode 100644 index 00000000..bdaa614a --- /dev/null +++ b/src/core/fetcher/RawResponse.ts @@ -0,0 +1,61 @@ +import { Headers } from "./Headers"; + +/** + * The raw response from the fetch call excluding the body. + */ +export type RawResponse = Omit< + { + [K in keyof Response as Response[K] extends Function ? never : K]: Response[K]; // strips out functions + }, + "ok" | "body" | "bodyUsed" +>; // strips out body and bodyUsed + +/** + * A raw response indicating that the request was aborted. + */ +export const abortRawResponse: RawResponse = { + headers: new Headers(), + redirected: false, + status: 499, + statusText: "Client Closed Request", + type: "error", + url: "", +} as const; + +/** + * A raw response indicating an unknown error. + */ +export const unknownRawResponse: RawResponse = { + headers: new Headers(), + redirected: false, + status: 0, + statusText: "Unknown Error", + type: "error", + url: "", +} as const; + +/** + * Converts a `RawResponse` object into a `RawResponse` by extracting its properties, + * excluding the `body` and `bodyUsed` fields. + * + * @param response - The `RawResponse` object to convert. + * @returns A `RawResponse` object containing the extracted properties of the input response. + */ +export function toRawResponse(response: Response): RawResponse { + return { + headers: response.headers, + redirected: response.redirected, + status: response.status, + statusText: response.statusText, + type: response.type, + url: response.url, + }; +} + +/** + * Creates a `RawResponse` from a standard `Response` object. + */ +export interface WithRawResponse { + readonly data: T; + readonly rawResponse: RawResponse; +} diff --git a/src/core/fetcher/index.ts b/src/core/fetcher/index.ts index 2d658ca4..249f5176 100644 --- a/src/core/fetcher/index.ts +++ b/src/core/fetcher/index.ts @@ -3,3 +3,6 @@ export { fetcher } from "./Fetcher"; export type { Fetcher, FetchFunction } from "./Fetcher"; export { getHeader } from "./getHeader"; export { Supplier } from "./Supplier"; +export { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse"; +export type { RawResponse, WithRawResponse } from "./RawResponse"; +export { HttpResponsePromise } from "./HttpResponsePromise"; diff --git a/src/core/index.ts b/src/core/index.ts index eaa51053..466b3c3a 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -1,5 +1,5 @@ export * from "./fetcher"; -export * from "./auth"; export * from "./runtime"; +export * from "./auth"; export * from "./utils"; export * from "./pagination"; diff --git a/src/core/pagination/Page.ts b/src/core/pagination/Page.ts index 07c6796e..30df7280 100644 --- a/src/core/pagination/Page.ts +++ b/src/core/pagination/Page.ts @@ -1,3 +1,5 @@ +import { HttpResponsePromise, RawResponse } from "../fetcher"; + /** * A page of results from a paginated API. * @@ -5,24 +7,28 @@ */ export class Page implements AsyncIterable { public data: T[]; + public rawResponse: RawResponse; private response: unknown; private _hasNextPage: (response: unknown) => boolean; private getItems: (response: unknown) => T[]; - private loadNextPage: (response: unknown) => Promise; + private loadNextPage: (response: unknown) => HttpResponsePromise; constructor({ response, + rawResponse, hasNextPage, getItems, loadPage, }: { response: unknown; + rawResponse: RawResponse; hasNextPage: (response: unknown) => boolean; getItems: (response: unknown) => T[]; - loadPage: (response: unknown) => Promise; + loadPage: (response: unknown) => HttpResponsePromise; }) { this.response = response; + this.rawResponse = rawResponse; this.data = getItems(response); this._hasNextPage = hasNextPage; this.getItems = getItems; @@ -34,7 +40,9 @@ export class Page implements AsyncIterable { * @returns this */ public async getNextPage(): Promise { - this.response = await this.loadNextPage(this.response); + const { data, rawResponse } = await this.loadNextPage(this.response).withRawResponse(); + this.response = data; + this.rawResponse = rawResponse; this.data = this.getItems(this.response); return this; } diff --git a/src/core/pagination/Pageable.ts b/src/core/pagination/Pageable.ts index befce635..3a5220eb 100644 --- a/src/core/pagination/Pageable.ts +++ b/src/core/pagination/Pageable.ts @@ -1,8 +1,10 @@ +import { RawResponse } from "../fetcher"; import { Page } from "./Page"; export declare namespace Pageable { interface Args { response: Response; + rawResponse: RawResponse; hasNextPage: (response: Response) => boolean; getItems: (response: Response) => Item[]; loadPage: (response: Response) => Promise; diff --git a/src/errors/IntercomError.ts b/src/errors/IntercomError.ts index add6ed73..0f91cad3 100644 --- a/src/errors/IntercomError.ts +++ b/src/errors/IntercomError.ts @@ -2,22 +2,30 @@ * This file was auto-generated by Fern from our API Definition. */ +import * as core from "../core"; import { toJson } from "../core/json"; export class IntercomError extends Error { - readonly statusCode?: number; - readonly body?: unknown; - - constructor({ message, statusCode, body }: { message?: string; statusCode?: number; body?: unknown }) { + public readonly statusCode?: number; + public readonly body?: unknown; + public readonly rawResponse?: core.RawResponse; + + constructor({ + message, + statusCode, + body, + rawResponse, + }: { + message?: string; + statusCode?: number; + body?: unknown; + rawResponse?: core.RawResponse; + }) { super(buildMessage({ message, statusCode, body })); Object.setPrototypeOf(this, IntercomError.prototype); - if (statusCode != null) { - this.statusCode = statusCode; - } - - if (body !== undefined) { - this.body = body; - } + this.statusCode = statusCode; + this.body = body; + this.rawResponse = rawResponse; } } diff --git a/src/version.ts b/src/version.ts index 0ea5cbcb..1420c168 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const SDK_VERSION = "6.3.0"; +export const SDK_VERSION = "6.4.0"; diff --git a/tests/unit/fetcher/HttpResponsePromise.test.ts b/tests/unit/fetcher/HttpResponsePromise.test.ts new file mode 100644 index 00000000..2216a33e --- /dev/null +++ b/tests/unit/fetcher/HttpResponsePromise.test.ts @@ -0,0 +1,143 @@ +import { beforeEach, describe, expect, it, jest } from "@jest/globals"; + +import { HttpResponsePromise } from "../../../src/core/fetcher/HttpResponsePromise"; +import { RawResponse, WithRawResponse } from "../../../src/core/fetcher/RawResponse"; + +describe("HttpResponsePromise", () => { + const mockRawResponse: RawResponse = { + headers: new Headers(), + redirected: false, + status: 200, + statusText: "OK", + type: "basic" as ResponseType, + url: "https://example.com", + }; + const mockData = { id: "123", name: "test" }; + const mockWithRawResponse: WithRawResponse = { + data: mockData, + rawResponse: mockRawResponse, + }; + + describe("fromFunction", () => { + it("should create an HttpResponsePromise from a function", async () => { + const mockFn = jest + .fn<(arg1: string, arg2: string) => Promise>>() + .mockResolvedValue(mockWithRawResponse); + + const responsePromise = HttpResponsePromise.fromFunction(mockFn, "arg1", "arg2"); + + const result = await responsePromise; + expect(result).toEqual(mockData); + expect(mockFn).toHaveBeenCalledWith("arg1", "arg2"); + + const resultWithRawResponse = await responsePromise.withRawResponse(); + expect(resultWithRawResponse).toEqual({ + data: mockData, + rawResponse: mockRawResponse, + }); + }); + }); + + describe("fromPromise", () => { + it("should create an HttpResponsePromise from a promise", async () => { + const promise = Promise.resolve(mockWithRawResponse); + + const responsePromise = HttpResponsePromise.fromPromise(promise); + + const result = await responsePromise; + expect(result).toEqual(mockData); + + const resultWithRawResponse = await responsePromise.withRawResponse(); + expect(resultWithRawResponse).toEqual({ + data: mockData, + rawResponse: mockRawResponse, + }); + }); + }); + + describe("fromExecutor", () => { + it("should create an HttpResponsePromise from an executor function", async () => { + const responsePromise = HttpResponsePromise.fromExecutor((resolve) => { + resolve(mockWithRawResponse); + }); + + const result = await responsePromise; + expect(result).toEqual(mockData); + + const resultWithRawResponse = await responsePromise.withRawResponse(); + expect(resultWithRawResponse).toEqual({ + data: mockData, + rawResponse: mockRawResponse, + }); + }); + }); + + describe("fromResult", () => { + it("should create an HttpResponsePromise from a result", async () => { + const responsePromise = HttpResponsePromise.fromResult(mockWithRawResponse); + + const result = await responsePromise; + expect(result).toEqual(mockData); + + const resultWithRawResponse = await responsePromise.withRawResponse(); + expect(resultWithRawResponse).toEqual({ + data: mockData, + rawResponse: mockRawResponse, + }); + }); + }); + + describe("Promise methods", () => { + let responsePromise: HttpResponsePromise; + + beforeEach(() => { + responsePromise = HttpResponsePromise.fromResult(mockWithRawResponse); + }); + + it("should support then() method", async () => { + const result = await responsePromise.then((data) => ({ + ...data, + modified: true, + })); + + expect(result).toEqual({ + ...mockData, + modified: true, + }); + }); + + it("should support catch() method", async () => { + const errorResponsePromise = HttpResponsePromise.fromExecutor((_, reject) => { + reject(new Error("Test error")); + }); + + const catchSpy = jest.fn(); + await errorResponsePromise.catch(catchSpy); + + expect(catchSpy).toHaveBeenCalled(); + const error = catchSpy.mock.calls[0]?.[0]; + expect(error).toBeInstanceOf(Error); + expect((error as Error).message).toBe("Test error"); + }); + + it("should support finally() method", async () => { + const finallySpy = jest.fn(); + await responsePromise.finally(finallySpy); + + expect(finallySpy).toHaveBeenCalled(); + }); + }); + + describe("withRawResponse", () => { + it("should return both data and raw response", async () => { + const responsePromise = HttpResponsePromise.fromResult(mockWithRawResponse); + + const result = await responsePromise.withRawResponse(); + + expect(result).toEqual({ + data: mockData, + rawResponse: mockRawResponse, + }); + }); + }); +}); diff --git a/tests/unit/fetcher/RawResponse.test.ts b/tests/unit/fetcher/RawResponse.test.ts new file mode 100644 index 00000000..9ccd5e1e --- /dev/null +++ b/tests/unit/fetcher/RawResponse.test.ts @@ -0,0 +1,34 @@ +import { describe, expect, it } from "@jest/globals"; + +import { toRawResponse } from "../../../src/core/fetcher/RawResponse"; + +describe("RawResponse", () => { + describe("toRawResponse", () => { + it("should convert Response to RawResponse by removing body, bodyUsed, and ok properties", () => { + const mockHeaders = new Headers({ "content-type": "application/json" }); + const mockResponse = { + body: "test body", + bodyUsed: false, + ok: true, + headers: mockHeaders, + redirected: false, + status: 200, + statusText: "OK", + type: "basic" as ResponseType, + url: "https://example.com", + }; + + const result = toRawResponse(mockResponse as unknown as Response); + + expect("body" in result).toBe(false); + expect("bodyUsed" in result).toBe(false); + expect("ok" in result).toBe(false); + expect(result.headers).toBe(mockHeaders); + expect(result.redirected).toBe(false); + expect(result.status).toBe(200); + expect(result.statusText).toBe("OK"); + expect(result.type).toBe("basic"); + expect(result.url).toBe("https://example.com"); + }); + }); +}); diff --git a/tests/unit/fetcher/stream-wrappers/webpack.test.ts b/tests/unit/fetcher/stream-wrappers/webpack.test.ts index 63fa0a78..f7537d3c 100644 --- a/tests/unit/fetcher/stream-wrappers/webpack.test.ts +++ b/tests/unit/fetcher/stream-wrappers/webpack.test.ts @@ -38,5 +38,5 @@ describe("test env compatibility", () => { }, ); }); - }, 90_000); + }, 180_000); }); diff --git a/yarn.lock b/yarn.lock index 33ecf06c..fb6d3874 100644 --- a/yarn.lock +++ b/yarn.lock @@ -20,43 +20,43 @@ picocolors "^1.1.1" "@babel/compat-data@^7.27.2": - version "7.27.2" - resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.27.2.tgz#4183f9e642fd84e74e3eea7ffa93a412e3b102c9" - integrity sha512-TUtMJYRPyUb/9aU8f3K0mjmjf6M9N5Woshn2CS6nqJSeJtTtQcpLUXjGt9vbF8ZGff0El99sWkLgzwW3VXnxZQ== + version "7.27.5" + resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.27.5.tgz#7d0658ec1a8420fc866d1df1b03bea0e79934c82" + integrity sha512-KiRAp/VoJaWkkte84TvUd9qjdbZAdiqyvMxrGl1N6vzFogKmaLgoM3L1kgtLicp2HP5fBJS8JrZKLVIZGVJAVg== "@babel/core@^7.11.6", "@babel/core@^7.12.3", "@babel/core@^7.23.9": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.27.1.tgz#89de51e86bd12246003e3524704c49541b16c3e6" - integrity sha512-IaaGWsQqfsQWVLqMn9OB92MNN7zukfVA4s7KKAI0KfrrDsZ0yhi5uV4baBuLuN7n3vsZpwP8asPPcVwApxvjBQ== + version "7.27.4" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.27.4.tgz#cc1fc55d0ce140a1828d1dd2a2eba285adbfb3ce" + integrity sha512-bXYxrXFubeYdvB0NhD/NBB3Qi6aZeV20GOWVI47t2dkecCEoneR4NPVcb7abpXDEvejgrUfFtG6vG/zxAKmg+g== dependencies: "@ampproject/remapping" "^2.2.0" "@babel/code-frame" "^7.27.1" - "@babel/generator" "^7.27.1" - "@babel/helper-compilation-targets" "^7.27.1" - "@babel/helper-module-transforms" "^7.27.1" - "@babel/helpers" "^7.27.1" - "@babel/parser" "^7.27.1" - "@babel/template" "^7.27.1" - "@babel/traverse" "^7.27.1" - "@babel/types" "^7.27.1" + "@babel/generator" "^7.27.3" + "@babel/helper-compilation-targets" "^7.27.2" + "@babel/helper-module-transforms" "^7.27.3" + "@babel/helpers" "^7.27.4" + "@babel/parser" "^7.27.4" + "@babel/template" "^7.27.2" + "@babel/traverse" "^7.27.4" + "@babel/types" "^7.27.3" convert-source-map "^2.0.0" debug "^4.1.0" gensync "^1.0.0-beta.2" json5 "^2.2.3" semver "^6.3.1" -"@babel/generator@^7.27.1", "@babel/generator@^7.7.2": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.27.1.tgz#862d4fad858f7208edd487c28b58144036b76230" - integrity sha512-UnJfnIpc/+JO0/+KRVQNGU+y5taA5vCbwN8+azkX6beii/ZF+enZJSOKo11ZSzGJjlNfJHfQtmQT8H+9TXPG2w== +"@babel/generator@^7.27.3", "@babel/generator@^7.7.2": + version "7.27.5" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.27.5.tgz#3eb01866b345ba261b04911020cbe22dd4be8c8c" + integrity sha512-ZGhA37l0e/g2s1Cnzdix0O3aLYm66eF8aufiVteOgnwxgnRP8GoyMj7VWsgWnQbVKXyge7hqrFh2K2TQM6t1Hw== dependencies: - "@babel/parser" "^7.27.1" - "@babel/types" "^7.27.1" + "@babel/parser" "^7.27.5" + "@babel/types" "^7.27.3" "@jridgewell/gen-mapping" "^0.3.5" "@jridgewell/trace-mapping" "^0.3.25" jsesc "^3.0.2" -"@babel/helper-compilation-targets@^7.27.1": +"@babel/helper-compilation-targets@^7.27.2": version "7.27.2" resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.27.2.tgz#46a0f6efab808d51d29ce96858dd10ce8732733d" integrity sha512-2+1thGUUWWjLTYTHZWK1n8Yga0ijBz1XAhUXcKy81rd5g6yh7hGqMp45v7cadSbEHc9G3OTv45SyneRN3ps4DQ== @@ -75,14 +75,14 @@ "@babel/traverse" "^7.27.1" "@babel/types" "^7.27.1" -"@babel/helper-module-transforms@^7.27.1": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.27.1.tgz#e1663b8b71d2de948da5c4fb2a20ca4f3ec27a6f" - integrity sha512-9yHn519/8KvTU5BjTVEEeIM3w9/2yXNKoD82JifINImhpKkARMJKPP59kLo+BafpdN5zgNeIcS4jsGDmd3l58g== +"@babel/helper-module-transforms@^7.27.3": + version "7.27.3" + resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.27.3.tgz#db0bbcfba5802f9ef7870705a7ef8788508ede02" + integrity sha512-dSOvYwvyLsWBeIRyOeHXp5vPj5l1I011r52FM1+r1jCERv+aFXYk4whgQccYEGYxK2H3ZAIA8nuPkQ0HaUo3qg== dependencies: "@babel/helper-module-imports" "^7.27.1" "@babel/helper-validator-identifier" "^7.27.1" - "@babel/traverse" "^7.27.1" + "@babel/traverse" "^7.27.3" "@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.12.13", "@babel/helper-plugin-utils@^7.14.5", "@babel/helper-plugin-utils@^7.27.1", "@babel/helper-plugin-utils@^7.8.0": version "7.27.1" @@ -104,20 +104,20 @@ resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.27.1.tgz#fa52f5b1e7db1ab049445b421c4471303897702f" integrity sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg== -"@babel/helpers@^7.27.1": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.27.1.tgz#ffc27013038607cdba3288e692c3611c06a18aa4" - integrity sha512-FCvFTm0sWV8Fxhpp2McP5/W53GPllQ9QeQ7SiqGWjMf/LVG07lFa5+pgK05IRhVwtvafT22KF+ZSnM9I545CvQ== +"@babel/helpers@^7.27.4": + version "7.27.6" + resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.27.6.tgz#6456fed15b2cb669d2d1fabe84b66b34991d812c" + integrity sha512-muE8Tt8M22638HU31A3CgfSUciwz1fhATfoVai05aPXGor//CdWDCbnlY1yvBPo07njuVOCNGCSp/GTt12lIug== dependencies: - "@babel/template" "^7.27.1" - "@babel/types" "^7.27.1" + "@babel/template" "^7.27.2" + "@babel/types" "^7.27.6" -"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.20.7", "@babel/parser@^7.23.9", "@babel/parser@^7.27.1", "@babel/parser@^7.27.2": - version "7.27.2" - resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.27.2.tgz#577518bedb17a2ce4212afd052e01f7df0941127" - integrity sha512-QYLs8299NA7WM/bZAdp+CviYYkVoYXlDW2rzliy3chxd1PQjej7JORuMJDJXJUb9g0TT+B99EwaVLKmX+sPXWw== +"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.20.7", "@babel/parser@^7.23.9", "@babel/parser@^7.27.2", "@babel/parser@^7.27.4", "@babel/parser@^7.27.5": + version "7.27.5" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.27.5.tgz#ed22f871f110aa285a6fd934a0efed621d118826" + integrity sha512-OsQd175SxWkGlzbny8J3K8TnnDD0N3lrIUtB92xwyRpzaenGZhxDvxN/JgU00U3CDZNj9tPuDJ5H0WS4Nt3vKg== dependencies: - "@babel/types" "^7.27.1" + "@babel/types" "^7.27.3" "@babel/plugin-syntax-async-generators@^7.8.4": version "7.8.4" @@ -238,7 +238,7 @@ dependencies: "@babel/helper-plugin-utils" "^7.27.1" -"@babel/template@^7.27.1", "@babel/template@^7.3.3": +"@babel/template@^7.27.2", "@babel/template@^7.3.3": version "7.27.2" resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.27.2.tgz#fa78ceed3c4e7b63ebf6cb39e5852fca45f6809d" integrity sha512-LPDZ85aEJyYSd18/DkjNh4/y1ntkE5KwUHWTiqgRxruuZL2F1yuHligVHLvcHY2vMHXttKFpJn6LwfI7cw7ODw== @@ -247,23 +247,23 @@ "@babel/parser" "^7.27.2" "@babel/types" "^7.27.1" -"@babel/traverse@^7.27.1": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.27.1.tgz#4db772902b133bbddd1c4f7a7ee47761c1b9f291" - integrity sha512-ZCYtZciz1IWJB4U61UPu4KEaqyfj+r5T1Q5mqPo+IBpcG9kHv30Z0aD8LXPgC1trYa6rK0orRyAhqUgk4MjmEg== +"@babel/traverse@^7.27.1", "@babel/traverse@^7.27.3", "@babel/traverse@^7.27.4": + version "7.27.4" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.27.4.tgz#b0045ac7023c8472c3d35effd7cc9ebd638da6ea" + integrity sha512-oNcu2QbHqts9BtOWJosOVJapWjBDSxGCpFvikNR5TGDYDQf3JwpIoMzIKrvfoti93cLfPJEG4tH9SPVeyCGgdA== dependencies: "@babel/code-frame" "^7.27.1" - "@babel/generator" "^7.27.1" - "@babel/parser" "^7.27.1" - "@babel/template" "^7.27.1" - "@babel/types" "^7.27.1" + "@babel/generator" "^7.27.3" + "@babel/parser" "^7.27.4" + "@babel/template" "^7.27.2" + "@babel/types" "^7.27.3" debug "^4.3.1" globals "^11.1.0" -"@babel/types@^7.0.0", "@babel/types@^7.20.7", "@babel/types@^7.27.1", "@babel/types@^7.3.3": - version "7.27.1" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.27.1.tgz#9defc53c16fc899e46941fc6901a9eea1c9d8560" - integrity sha512-+EzkxvLNfiUeKMgy/3luqfsCWFRXLb7U6wNQTk60tovuckwB15B191tJWvpp4HjiQWdJkCxO3Wbvc6jlk3Xb2Q== +"@babel/types@^7.0.0", "@babel/types@^7.20.7", "@babel/types@^7.27.1", "@babel/types@^7.27.3", "@babel/types@^7.27.6", "@babel/types@^7.3.3": + version "7.27.6" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.27.6.tgz#a434ca7add514d4e646c80f7375c0aa2befc5535" + integrity sha512-ETyHEk2VHHvl9b9jZP5IHPavHYk57EhanlRRuae9XCpb/j5bDCbPPMOBfCWhnl/7EDJz0jEMCi/RhccCE8r1+Q== dependencies: "@babel/helper-string-parser" "^7.27.1" "@babel/helper-validator-identifier" "^7.27.1" @@ -595,9 +595,9 @@ "@types/json-schema" "*" "@types/estree@*", "@types/estree@^1.0.6": - version "1.0.7" - resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.7.tgz#4158d3105276773d5b7695cd4834b1722e4f37a8" - integrity sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ== + version "1.0.8" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.8.tgz#958b91c991b1867ced318bedea0e215ee050726e" + integrity sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w== "@types/graceful-fs@^4.1.3": version "4.1.9" @@ -656,16 +656,16 @@ form-data "^4.0.0" "@types/node@*": - version "22.15.21" - resolved "https://registry.yarnpkg.com/@types/node/-/node-22.15.21.tgz#196ef14fe20d87f7caf1e7b39832767f9a995b77" - integrity sha512-EV/37Td6c+MgKAbkcLG6vqZ2zEYHD7bvSrzqqs2RIhbA6w3x+Dqz8MZM3sP6kGTeLrdoOgKZe+Xja7tUB2DNkQ== + version "24.0.4" + resolved "https://registry.yarnpkg.com/@types/node/-/node-24.0.4.tgz#dbae889912bda33a7f57669fb8587c1a56bc0c1f" + integrity sha512-ulyqAkrhnuNq9pB76DRBTkcS6YsmDALy6Ua63V8OhrOBgbcYt6IOdzpw5P1+dyRIyMerzLkeYWBeOXPpA9GMAA== dependencies: - undici-types "~6.21.0" + undici-types "~7.8.0" "@types/node@^18.19.70": - version "18.19.103" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.19.103.tgz#9bbd31a54e240fc469cca409d7507ebc77536458" - integrity sha512-hHTHp+sEz6SxFsp+SA+Tqrua3AbmlAw+Y//aEwdHrdZkYVRWdvWD3y5uPZ0flYOkgskaFWqZ/YGFm3FaFQ0pRw== + version "18.19.112" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.19.112.tgz#cd2aee9c075402e0e1942a44101428881dbeb110" + integrity sha512-i+Vukt9POdS/MBI7YrrkkI5fMfwFtOjphSmt4WXYLfwqsfr6z/HdCx7LqT9M7JktGob8WNgj8nFB4TbGNE4Cog== dependencies: undici-types "~5.26.4" @@ -675,9 +675,9 @@ integrity sha512-eOunJqu0K1923aExK6y8p6fsihYEn/BYuQ4g0CxAAgFc4b/ZLN4CrsRZ55srTdqoiLzU2B2evC+apEIxprEzkQ== "@types/readable-stream@^4.0.18": - version "4.0.19" - resolved "https://registry.yarnpkg.com/@types/readable-stream/-/readable-stream-4.0.19.tgz#e2392f17a9e11aca6e6b21b537aa13bc96a57e46" - integrity sha512-6Tgd3lMocKwOul/kwAAgSebkhdMCLhRvcJ6CKHA6wdql2qNIwK6hw3Y4PZQxn9HcJogoC/1ZOmkFM7OZKH/VrA== + version "4.0.21" + resolved "https://registry.yarnpkg.com/@types/readable-stream/-/readable-stream-4.0.21.tgz#716558454a5e0c3c0651520f8154efc3288f59cb" + integrity sha512-19eKVv9tugr03IgfXlA9UVUVRbW6IuqRO5B92Dl4a6pT7K8uaGrNS0GkxiZD0BOk6PLuXl5FhWl//eX/pzYdTQ== dependencies: "@types/node" "*" @@ -867,9 +867,9 @@ acorn-walk@^8.0.2: acorn "^8.11.0" acorn@^8.1.0, acorn@^8.11.0, acorn@^8.14.0, acorn@^8.8.1: - version "8.14.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.14.1.tgz#721d5dc10f7d5b5609a891773d47731796935dfb" - integrity sha512-OvQ/2pUDKmgfCg++xsTX1wGxfTaszcHVcTctW4UJB4hibJx2HXxxO5UmVgyjMa+ZDsiaf5wWLXYpRWMmBI0QHg== + version "8.15.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.15.0.tgz#a360898bc415edaac46c8241f6383975b930b816" + integrity sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg== agent-base@6: version "6.0.2" @@ -1025,17 +1025,17 @@ base64-js@^1.3.1: integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== + version "1.1.12" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.12.tgz#ab9b454466e5a8cc3a187beaad580412a9c5b843" + integrity sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg== dependencies: balanced-match "^1.0.0" concat-map "0.0.1" brace-expansion@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae" - integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA== + version "2.0.2" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.2.tgz#54fc53237a613d854c7bd37463aad17df87214e7" + integrity sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ== dependencies: balanced-match "^1.0.0" @@ -1047,12 +1047,12 @@ braces@^3.0.3: fill-range "^7.1.1" browserslist@^4.24.0: - version "4.24.5" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.24.5.tgz#aa0f5b8560fe81fde84c6dcb38f759bafba0e11b" - integrity sha512-FDToo4Wo82hIdgc1CQ+NQD0hEhmpPjrZ3hiUgwgOG6IuTdlpr8jdjyG24P6cNP1yJpTLzS5OcGgSw0xmDU1/Tw== + version "4.25.1" + resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.25.1.tgz#ba9e8e6f298a1d86f829c9b975e07948967bb111" + integrity sha512-KGj0KoOMXLpSNkkEI6Z6mShmQy0bc1I+T7K9N81k4WWMrfz+6fQ6es80B/YLAeRoKvjYE1YSHHOW1qe9xIVzHw== dependencies: - caniuse-lite "^1.0.30001716" - electron-to-chromium "^1.5.149" + caniuse-lite "^1.0.30001726" + electron-to-chromium "^1.5.173" node-releases "^2.0.19" update-browserslist-db "^1.1.3" @@ -1114,10 +1114,10 @@ camelcase@^6.2.0: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== -caniuse-lite@^1.0.30001716: - version "1.0.30001718" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001718.tgz#dae13a9c80d517c30c6197515a96131c194d8f82" - integrity sha512-AflseV1ahcSunK53NfEs9gFWgOEmzr0f+kaMFA4xiLZlr9Hzt7HxcSpIFcnNCUkz6R6dWKa54rUz3HUmI3nVcw== +caniuse-lite@^1.0.30001726: + version "1.0.30001726" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001726.tgz#a15bd87d5a4bf01f6b6f70ae7c97fdfd28b5ae47" + integrity sha512-VQAUIUzBiZ/UnlM28fSp2CRF3ivUn1BWEvxMcVTNwpw91Py1pGbPIyIKtd+tzct9C3ouceCVdGAXxZOpZAsgdw== chalk@^4.0.0, chalk@^4.0.2, chalk@^4.1.0: version "4.1.2" @@ -1308,10 +1308,10 @@ ejs@^3.1.10: dependencies: jake "^10.8.5" -electron-to-chromium@^1.5.149: - version "1.5.155" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.155.tgz#809dd0ae9ae1db87c358e0c0c17c09a2ffc432d1" - integrity sha512-ps5KcGGmwL8VaeJlvlDlu4fORQpv3+GIcF5I3f9tUKUlJ/wsysh6HU8P5L1XWRYeXfA0oJd4PyM8ds8zTFf6Ng== +electron-to-chromium@^1.5.173: + version "1.5.173" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.5.173.tgz#1aeba57204fe19425921a29946ef543653f5e896" + integrity sha512-2bFhXP2zqSfQHugjqJIDFVwa+qIxyNApenmXTp9EjaKtdPrES5Qcn9/aSFy/NaP2E+fWG/zxKu/LBvY36p5VNQ== emittery@^0.13.1: version "0.13.1" @@ -1324,17 +1324,17 @@ emoji-regex@^8.0.0: integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A== enhanced-resolve@^5.0.0, enhanced-resolve@^5.17.1: - version "5.18.1" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.18.1.tgz#728ab082f8b7b6836de51f1637aab5d3b9568faf" - integrity sha512-ZSW3ma5GkcQBIpwZTSRAI8N71Uuwgs93IezB7mf7R60tC8ZbJideoDNKjHn2O9KIlx6rkGTTEk1xUCK2E1Y2Yg== + version "5.18.2" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.18.2.tgz#7903c5b32ffd4b2143eeb4b92472bd68effd5464" + integrity sha512-6Jw4sE1maoRJo3q8MsSIn2onJFbLTOjY9hlx4DZXmOKvLRd1Ok2kXmAGXaafL2+ijsJZ1ClYbl/pmqr9+k4iUQ== dependencies: graceful-fs "^4.2.4" tapable "^2.2.0" entities@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/entities/-/entities-6.0.0.tgz#09c9e29cb79b0a6459a9b9db9efb418ac5bb8e51" - integrity sha512-aKstq2TDOndCn4diEyp9Uq/Flu2i1GlLkc6XIDQSDMuaFE3OPW5OphLCyQ5SpSJZTb4reN+kTcYru5yIfXoRPw== + version "6.0.1" + resolved "https://registry.yarnpkg.com/entities/-/entities-6.0.1.tgz#c28c34a43379ca7f61d074130b2f5f7020a30694" + integrity sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g== error-ex@^1.3.1: version "1.3.2" @@ -1517,13 +1517,14 @@ find-up@^4.0.0, find-up@^4.1.0: path-exists "^4.0.0" form-data@^4.0.0: - version "4.0.2" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.2.tgz#35cabbdd30c3ce73deb2c42d3c8d3ed9ca51794c" - integrity sha512-hGfm/slu0ZabnNt4oaRZ6uREyfCj6P4fT/n6A1rGV+Z0VdGXjfOhVUpkn6qVQONHGIFwmveGXyDs75+nr6FM8w== + version "4.0.3" + resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.3.tgz#608b1b3f3e28be0fccf5901fc85fb3641e5cf0ae" + integrity sha512-qsITQPfmvMOSAdeyZ+12I1c+CKSstAFAwu+97zrnWAbIr5u8wfsExUzCesVLC8NgHuRUqNN4Zy6UPWUTRGslcA== dependencies: asynckit "^0.4.0" combined-stream "^1.0.8" es-set-tostringtag "^2.1.0" + hasown "^2.0.2" mime-types "^2.1.12" formdata-node@^6.0.3: @@ -2137,7 +2138,7 @@ jest-snapshot@^29.7.0: pretty-format "^29.7.0" semver "^7.5.3" -jest-util@^29.0.0, jest-util@^29.7.0: +jest-util@^29.7.0: version "29.7.0" resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-29.7.0.tgz#23c2b62bfb22be82b44de98055802ff3710fc0bc" integrity sha512-z6EbKajIpqGKU56y5KBUgy1dt1ihhQJgWzUlZHArA/+X2ad7Cb5iF+AK1EWVL/Bo7Rz9uurpqw6SiBCefUbCGA== @@ -2535,9 +2536,9 @@ pkg-dir@^4.2.0: find-up "^4.0.0" prettier@^3.4.2: - version "3.5.3" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.5.3.tgz#4fc2ce0d657e7a02e602549f053b239cb7dfe1b5" - integrity sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw== + version "3.6.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.6.1.tgz#cc3bce21c09a477b1e987b76ce9663925d86ae44" + integrity sha512-5xGWRa90Sp2+x1dQtNpIpeOQpTDBs9cZDmA/qs2vDNN2i18PdapqY7CmBeyLlMuGqXJRIOPaCaVZTLNQRWUH/A== pretty-format@^29.0.0, pretty-format@^29.7.0: version "29.7.0" @@ -2890,9 +2891,9 @@ terser-webpack-plugin@^5.3.11: terser "^5.31.1" terser@^5.31.1: - version "5.39.2" - resolved "https://registry.yarnpkg.com/terser/-/terser-5.39.2.tgz#5a1626030724a672e2e5b5c9cd9070308c20e8f9" - integrity sha512-yEPUmWve+VA78bI71BW70Dh0TuV4HHd+I5SHOAfS1+QBOmvmCiiffgjR8ryyEd3KIfvPGFqoADt8LdQ6XpXIvg== + version "5.43.1" + resolved "https://registry.yarnpkg.com/terser/-/terser-5.43.1.tgz#88387f4f9794ff1a29e7ad61fb2932e25b4fdb6d" + integrity sha512-+6erLbBm0+LROX2sPXlUYx/ux5PyE9K/a92Wrt6oA+WDAoFTdpHE5tCYCI5PNzq2y8df4rA+QgHLJuR4jNymsg== dependencies: "@jridgewell/source-map" "^0.3.3" acorn "^8.14.0" @@ -2943,14 +2944,13 @@ tr46@~0.0.3: integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== ts-jest@^29.1.1: - version "29.3.4" - resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-29.3.4.tgz#9354472aceae1d3867a80e8e02014ea5901aee41" - integrity sha512-Iqbrm8IXOmV+ggWHOTEbjwyCf2xZlUMv5npExksXohL+tk8va4Fjhb+X2+Rt9NBmgO7bJ8WpnMLOwih/DnMlFA== + version "29.4.0" + resolved "https://registry.yarnpkg.com/ts-jest/-/ts-jest-29.4.0.tgz#bef0ee98d94c83670af7462a1617bf2367a83740" + integrity sha512-d423TJMnJGu80/eSgfQ5w/R+0zFJvdtTxwtF9KzFFunOpSeD+79lHJQIiAhluJoyGRbvj9NZJsl9WjCUo0ND7Q== dependencies: bs-logger "^0.2.6" ejs "^3.1.10" fast-json-stable-stringify "^2.1.0" - jest-util "^29.0.0" json5 "^2.2.3" lodash.memoize "^4.1.2" make-error "^1.3.6" @@ -2994,10 +2994,10 @@ undici-types@~5.26.4: resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== -undici-types@~6.21.0: - version "6.21.0" - resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.21.0.tgz#691d00af3909be93a7faa13be61b3a5b50ef12cb" - integrity sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ== +undici-types@~7.8.0: + version "7.8.0" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-7.8.0.tgz#de00b85b710c54122e44fbfd911f8d70174cd294" + integrity sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw== universalify@^0.2.0: version "0.2.0" @@ -3067,9 +3067,9 @@ webidl-conversions@^7.0.0: integrity sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g== webpack-sources@^3.2.3: - version "3.2.3" - resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde" - integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w== + version "3.3.3" + resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.3.3.tgz#d4bf7f9909675d7a070ff14d0ef2a4f3c982c723" + integrity sha512-yd1RBzSGanHkitROoPFd6qsrxt+oFhg/129YzheDGqeustzX0vTZJZsSsQjVQC4yzBQ56K55XU8gaNCtIzOnTg== webpack@^5.97.1: version "5.99.9"